Skip to content

Commit 542e5b4

Browse files
authored
Merge pull request #3114 from hathach/fix-sigma-mouse-multiple-attach
Fix sigma mouse multiple attach
2 parents 1a783b3 + a05fc50 commit 542e5b4

File tree

5 files changed

+250
-260
lines changed

5 files changed

+250
-260
lines changed

.github/workflows/build.yml

Lines changed: 121 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ on:
88
- 'examples/**'
99
- 'lib/**'
1010
- 'hw/**'
11-
- 'tools/get_deps.py'
1211
- 'tools/build.py'
12+
- 'tools/get_deps.py'
1313
- '.github/actions/**'
1414
- '.github/workflows/build.yml'
1515
- '.github/workflows/build_util.yml'
@@ -21,8 +21,9 @@ on:
2121
- 'examples/**'
2222
- 'lib/**'
2323
- 'hw/**'
24-
- 'tools/get_deps.py'
24+
- 'test/hil/**'
2525
- 'tools/build.py'
26+
- 'tools/get_deps.py'
2627
- '.github/actions/**'
2728
- '.github/workflows/build.yml'
2829
- '.github/workflows/build_util.yml'
@@ -31,21 +32,35 @@ concurrency:
3132
group: ${{ github.workflow }}-${{ github.ref }}
3233
cancel-in-progress: true
3334

35+
env:
36+
HIL_JSON: test/hil/tinyusb.json
37+
3438
jobs:
39+
# ---------------------------------------
40+
#
41+
# Build
42+
#
43+
# ---------------------------------------
3544
set-matrix:
3645
runs-on: ubuntu-latest
3746
outputs:
3847
json: ${{ steps.set-matrix-json.outputs.matrix }}
48+
hil_json: ${{ steps.set-matrix-json.outputs.hil_matrix }}
3949
steps:
4050
- name: Checkout TinyUSB
4151
uses: actions/checkout@v4
4252

4353
- name: Generate matrix json
4454
id: set-matrix-json
4555
run: |
56+
# build matrix
4657
MATRIX_JSON=$(python .github/workflows/ci_set_matrix.py)
4758
echo "matrix=$MATRIX_JSON"
4859
echo "matrix=$MATRIX_JSON" >> $GITHUB_OUTPUT
60+
# hil matrix
61+
HIL_MATRIX_JSON=$(python test/hil/hil_ci_set_matrix.py ${{ env.HIL_JSON }})
62+
echo "hil_matrix=$HIL_MATRIX_JSON"
63+
echo "hil_matrix=$HIL_MATRIX_JSON" >> $GITHUB_OUTPUT
4964
5065
# ---------------------------------------
5166
# Build CMake
@@ -151,3 +166,107 @@ jobs:
151166
run: |
152167
west build -b pca10056 -d examples/device/cdc_msc/build examples/device/cdc_msc -- -DRTOS=zephyr
153168
west build -b pca10056 -d examples/device/msc_dual_lun/build examples/device/msc_dual_lun -- -DRTOS=zephyr
169+
170+
# ---------------------------------------
171+
#
172+
# Hardware in the loop (HIL)
173+
# Run on PR only (hil-tinyusb), hil-hfp only run on non-forked PR
174+
# ---------------------------------------
175+
176+
# ---------------------------------------
177+
# Build arm-gcc
178+
# ---------------------------------------
179+
hil-build:
180+
if: |
181+
github.repository_owner == 'hathach' &&
182+
(github.event_name == 'pull_request' || github.event_name == 'workflow_dispatch')
183+
needs: set-matrix
184+
uses: ./.github/workflows/build_util.yml
185+
strategy:
186+
fail-fast: false
187+
matrix:
188+
toolchain:
189+
- 'arm-gcc'
190+
- 'esp-idf'
191+
with:
192+
build-system: 'cmake'
193+
toolchain: ${{ matrix.toolchain }}
194+
build-args: ${{ toJSON(fromJSON(needs.set-matrix.outputs.hil_json)[matrix.toolchain]) }}
195+
one-per-family: true
196+
upload-artifacts: true
197+
198+
# ---------------------------------------
199+
# Hardware in the loop (HIL)
200+
# self-hosted on local VM, for attached hardware checkout HIL_JSON
201+
# ---------------------------------------
202+
hil-tinyusb:
203+
if: |
204+
github.repository_owner == 'hathach' &&
205+
(github.event_name == 'pull_request' || github.event_name == 'workflow_dispatch')
206+
needs: hil-build
207+
runs-on: [self-hosted, X64, hathach, hardware-in-the-loop]
208+
steps:
209+
- name: Clean workspace
210+
run: |
211+
echo "Cleaning up previous run"
212+
rm -rf "${{ github.workspace }}"
213+
mkdir -p "${{ github.workspace }}"
214+
215+
- name: Checkout TinyUSB
216+
uses: actions/checkout@v4
217+
with:
218+
sparse-checkout: test/hil
219+
220+
- name: Download Artifacts
221+
uses: actions/download-artifact@v4
222+
with:
223+
path: cmake-build
224+
merge-multiple: true
225+
226+
- name: Test on actual hardware
227+
run: |
228+
ls cmake-build/
229+
python3 test/hil/hil_test.py ${{ env.HIL_JSON }}
230+
231+
# ---------------------------------------
232+
# Hardware in the loop (HIL)
233+
# self-hosted by HFP, build with IAR toolchain, for attached hardware checkout test/hil/hfp.json
234+
# Since IAR Token secret is not passed to forked PR, only build non-forked PR
235+
# ---------------------------------------
236+
hil-hfp:
237+
if: |
238+
github.repository_owner == 'hathach' &&
239+
github.event.pull_request.head.repo.fork == false &&
240+
(github.event_name == 'pull_request' || github.event_name == 'workflow_dispatch')
241+
runs-on: [self-hosted, Linux, X64, hifiphile]
242+
env:
243+
IAR_LMS_BEARER_TOKEN: ${{ secrets.IAR_LMS_BEARER_TOKEN }}
244+
steps:
245+
- name: Clean workspace
246+
run: |
247+
echo "Cleaning up previous run"
248+
rm -rf "${{ github.workspace }}"3
249+
mkdir -p "${{ github.workspace }}"
250+
251+
- name: Toolchain version
252+
run: |
253+
iccarm --version
254+
255+
- name: Checkout TinyUSB
256+
uses: actions/checkout@v4
257+
258+
- name: Get build boards
259+
run: |
260+
MATRIX_JSON=$(python test/hil/hil_ci_set_matrix.py test/hil/hfp.json)
261+
BUILD_ARGS=$(echo $MATRIX_JSON | jq -r '.["arm-gcc"] | join(" ")')
262+
echo "BUILD_ARGS=$BUILD_ARGS"
263+
echo "BUILD_ARGS=$BUILD_ARGS" >> $GITHUB_ENV
264+
265+
- name: Get Dependencies
266+
run: python3 tools/get_deps.py $BUILD_ARGS
267+
268+
- name: Build
269+
run: python3 tools/build.py --toolchain iar $BUILD_ARGS
270+
271+
- name: Test on actual hardware (hardware in the loop)
272+
run: python3 test/hil/hil_test.py hfp.json

.github/workflows/hil_test.yml

Lines changed: 0 additions & 128 deletions
This file was deleted.

.idea/debugServers/rt1064.xml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/host/hub.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,8 @@ static void process_new_status(tuh_xfer_t* xfer) {
459459
}
460460
};
461461
hcd_event_handler(&event, false);
462-
processed = true; // usbh queue status after handled this in (de)enumeration
462+
// skip status for attach event, usbh will do it after handled this enumeration
463+
processed = (event.event_id == HCD_EVENT_DEVICE_ATTACH);
463464
break;
464465
}
465466

0 commit comments

Comments
 (0)