From 5fa03dd906574e775ec025b12ee6c1bc490d87b9 Mon Sep 17 00:00:00 2001 From: hathach Date: Thu, 1 Aug 2024 13:00:38 +0700 Subject: [PATCH 1/6] add stm32g0 (fsdev 2k) to hil pool remove esp32s3 since cp210x cause usb bus issue in the long run --- .github/workflows/build.yml | 4 +-- .github/workflows/hil_test.yml | 14 +++++---- test/hil/hil_test.py | 10 +++++-- test/hil/rpi.json | 53 ++++++++++++++++++++-------------- 4 files changed, 48 insertions(+), 33 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 712c7dd438..fda7f02941 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -120,10 +120,8 @@ jobs: fail-fast: false matrix: board: - # ESP32-S2 - 'espressif_kaluga_1' - # ESP32-S3 skip since devkitm is also compiled in hil-test workflow - #- 'espressif_s3_devkitm' + - 'espressif_s3_devkitm' with: build-system: 'cmake' toolchain: 'esp-idf' diff --git a/.github/workflows/hil_test.yml b/.github/workflows/hil_test.yml index 51227d4082..a95bd9bb84 100644 --- a/.github/workflows/hil_test.yml +++ b/.github/workflows/hil_test.yml @@ -66,9 +66,11 @@ jobs: cmake-build/cmake-build-*/*/*/*.bin # --------------------------------------- - # Build Espressif + # Build Espressif (skipped since CP210x cause USB bus issue) + # cp210x ttyUSB0: usb_serial_generic_write_bulk_callback - nonzero urb status: -71 # --------------------------------------- build-esp: + if: false runs-on: ubuntu-latest outputs: BOARDS_LIST: ${{ steps.parse_hil_json.outputs.BOARDS_LIST }} @@ -121,10 +123,10 @@ jobs: if: github.repository_owner == 'hathach' needs: - build - - build-esp + #- build-esp runs-on: [self-hosted, ARM64, rpi, hardware-in-the-loop] env: - BOARDS_LIST: "${{ needs.build.outputs.BOARDS_LIST }} ${{ needs.build-esp.outputs.BOARDS_LIST }}" + BOARDS_LIST: "${{ needs.build-esp.outputs.BOARDS_LIST }} ${{ needs.build.outputs.BOARDS_LIST }}" steps: - name: Clean workspace run: | @@ -135,9 +137,9 @@ jobs: # USB bus on rpi is not stable, reset it before testing # - name: Reset USB bus # run: | -# # reset VIA Labs 2.0 hub -# sudo usbreset 001/002 -# lsusb -t +# echo "1-2" | sudo tee /sys/bus/usb/drivers/usb/unbind +# sleep 5 +# echo "1-2" | sudo tee /sys/bus/usb/drivers/usb/bind - name: Checkout TinyUSB uses: actions/checkout@v4 diff --git a/test/hil/hil_test.py b/test/hil/hil_test.py index e2a2f01a0c..bda66a2b50 100644 --- a/test/hil/hil_test.py +++ b/test/hil/hil_test.py @@ -138,10 +138,15 @@ def flash_jlink(board, firmware): def flash_stlink(board, firmware): - #ret = run_cmd(f'st-flash --serial {board["flasher_sn"]} write {firmware}.bin 0x08000000') ret = run_cmd(f'STM32_Programmer_CLI --connect port=swd sn={board["flasher_sn"]} --write {firmware}.elf --go') return ret + +def flash_stflash(board, firmware): + ret = run_cmd(f'st-flash --serial {board["flasher_sn"]} write {firmware}.bin 0x8000000') + return ret + + def flash_openocd(board, firmware): ret = run_cmd(f'openocd -c "adapter serial {board["flasher_sn"]}" {board["flasher_args"]} -c "program {firmware}.elf reset exit"') return ret @@ -378,7 +383,8 @@ def main(): if not os.path.exists(fw_dir): fw_dir = f'examples/cmake-build-{name}/device/{test}' fw_name = f'{fw_dir}/{test}' - print(f' {test} ...', end='') + print(f' {test} ... ', end='') + sys.stdout.flush() if not os.path.exists(fw_dir): print('Skip') diff --git a/test/hil/rpi.json b/test/hil/rpi.json index dae3094b59..4d9b0f2164 100644 --- a/test/hil/rpi.json +++ b/test/hil/rpi.json @@ -1,12 +1,5 @@ { "boards": [ - { - "name": "raspberry_pi_pico", - "uid": "E6614C311B764A37", - "flasher": "openocd", - "flasher_sn": "E6614103E72C1D2F", - "flasher_args": "-f interface/cmsis-dap.cfg -f target/rp2040.cfg -c \"adapter speed 5000\"" - }, { "name": "feather_nrf52840_express", "uid": "1F0479CD0F764471", @@ -21,16 +14,6 @@ "flasher_sn": "E6614C311B597D32", "flasher_args": "-f interface/cmsis-dap.cfg -f target/atsame5x.cfg -c \"adapter speed 5000\"" }, - { - "name": "espressif_s3_devkitm", - "uid": "84F703C084E4", - "tests": [ - "cdc_msc_freertos", "hid_composite_freertos" - ], - "flasher": "esptool", - "flasher_sn": "3ea619acd1cdeb11a0a0b806e93fd3f1", - "flasher_args": "-b 921600" - }, { "name": "metro_m7_1011", "uid": "9CE8715DD71137363E00005002004200", @@ -38,6 +21,13 @@ "flasher_sn": "000611000000", "flasher_args": "-device MIMXRT1011xxx5A" }, + { + "name": "lpcxpresso11u37", + "uid": "17121919", + "flasher": "jlink", + "flasher_sn": "000724441579", + "flasher_args": "-device LPC11U37/401" + }, { "name": "ra4m1_ek", "uid": "152E163038303131393346E46F26574B", @@ -48,11 +38,30 @@ "flasher_args": "-device R7FA4M1AB" }, { - "name": "lpcxpresso11u37", - "uid": "17121919", - "flasher": "jlink", - "flasher_sn": "000724441579", - "flasher_args": "-device LPC11U37/401" + "name": "raspberry_pi_pico", + "uid": "E6614C311B764A37", + "flasher": "openocd", + "flasher_sn": "E6614103E72C1D2F", + "flasher_args": "-f interface/cmsis-dap.cfg -f target/rp2040.cfg -c \"adapter speed 5000\"" + }, + { + "name": "stm32g0b1nucleo", + "uid": "4D0038000450434E37343120", + "flasher": "openocd", + "flasher_sn": "066FFF495087534867063844", + "flasher_args": "-f interface/stlink.cfg -f target/stm32g0x.cfg" + } + ], + "boards-skip": [ + { + "name": "espressif_s3_devkitm", + "uid": "84F703C084E4", + "tests": [ + "cdc_msc_freertos", "hid_composite_freertos" + ], + "flasher": "esptool", + "flasher_sn": "3ea619acd1cdeb11a0a0b806e93fd3f1", + "flasher_args": "-b 921600" } ] } From 4e114b7bfa1c694e587c81993560424627ded26e Mon Sep 17 00:00:00 2001 From: hathach Date: Thu, 1 Aug 2024 14:01:35 +0700 Subject: [PATCH 2/6] update hil ci --- .github/workflows/hil_test.yml | 7 ------- 1 file changed, 7 deletions(-) diff --git a/.github/workflows/hil_test.yml b/.github/workflows/hil_test.yml index a95bd9bb84..4939cdcff0 100644 --- a/.github/workflows/hil_test.yml +++ b/.github/workflows/hil_test.yml @@ -149,13 +149,6 @@ jobs: - name: Download Artifacts uses: actions/download-artifact@v4 with: - name: hil_rpi - path: cmake-build - - - name: Download Artifacts - uses: actions/download-artifact@v4 - with: - name: hil_rpi_esp path: cmake-build - name: Test on actual hardware From 8407252fa351e80a0abb3cfe4952213f96b486cd Mon Sep 17 00:00:00 2001 From: hathach Date: Thu, 1 Aug 2024 14:13:03 +0700 Subject: [PATCH 3/6] fix hil ci --- .github/workflows/hil_test.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/hil_test.yml b/.github/workflows/hil_test.yml index 4939cdcff0..a4573faf71 100644 --- a/.github/workflows/hil_test.yml +++ b/.github/workflows/hil_test.yml @@ -150,6 +150,7 @@ jobs: uses: actions/download-artifact@v4 with: path: cmake-build + merge-multiple: true - name: Test on actual hardware run: | From 46fd82299040ff8c572f2b991f5226bf18405ffe Mon Sep 17 00:00:00 2001 From: hathach Date: Thu, 1 Aug 2024 14:24:23 +0700 Subject: [PATCH 4/6] increase freerto min task stack for some stm32 --- hw/bsp/family_support.cmake | 19 +++++++++++++++++++ .../stm32f0/FreeRTOSConfig/FreeRTOSConfig.h | 2 +- .../stm32g0/FreeRTOSConfig/FreeRTOSConfig.h | 2 +- hw/bsp/stm32g0/family.cmake | 5 +++-- .../stm32h5/FreeRTOSConfig/FreeRTOSConfig.h | 2 +- src/device/usbd.c | 2 +- 6 files changed, 26 insertions(+), 6 deletions(-) diff --git a/hw/bsp/family_support.cmake b/hw/bsp/family_support.cmake index 6a1e966241..9a7eaeb920 100644 --- a/hw/bsp/family_support.cmake +++ b/hw/bsp/family_support.cmake @@ -428,6 +428,19 @@ function(family_flash_stlink TARGET) endfunction() +# Add flash st-flash target +function(family_flash_stflash TARGET) + if (NOT DEFINED ST_FLASH) + set(ST_FLASH st-flash) + endif () + + add_custom_target(${TARGET}-stflash + DEPENDS ${TARGET} + COMMAND ${ST_FLASH} write $/${TARGET}.bin 0x8000000 + ) +endfunction() + + # Add flash openocd target function(family_flash_openocd TARGET) if (NOT DEFINED OPENOCD) @@ -449,6 +462,7 @@ function(family_flash_openocd TARGET) ) endfunction() + # Add flash openocd-wch target # compiled from https://github.com/hathach/riscv-openocd-wch or https://github.com/dragonlock2/miscboards/blob/main/wch/SDK/riscv-openocd.tar.xz function(family_flash_openocd_wch TARGET) @@ -459,6 +473,7 @@ function(family_flash_openocd_wch TARGET) family_flash_openocd(${TARGET}) endfunction() + # Add flash with https://github.com/ch32-rs/wlink function(family_flash_wlink_rs TARGET) if (NOT DEFINED WLINK_RS) @@ -471,6 +486,7 @@ function(family_flash_wlink_rs TARGET) ) endfunction() + # Add flash pycod target function(family_flash_pyocd TARGET) if (NOT DEFINED PYOC) @@ -483,6 +499,7 @@ function(family_flash_pyocd TARGET) ) endfunction() + # Flash with UF2 function(family_flash_uf2 TARGET FAMILY_ID) add_custom_target(${TARGET}-uf2 @@ -491,6 +508,7 @@ function(family_flash_uf2 TARGET FAMILY_ID) ) endfunction() + # Add flash teensy_cli target function(family_flash_teensy TARGET) if (NOT DEFINED TEENSY_CLI) @@ -503,6 +521,7 @@ function(family_flash_teensy TARGET) ) endfunction() + # Add flash using NXP's LinkServer (redserver) # https://www.nxp.com/design/software/development-software/mcuxpresso-software-and-tools-/linkserver-for-microcontrollers:LINKERSERVER function(family_flash_nxplink TARGET) diff --git a/hw/bsp/stm32f0/FreeRTOSConfig/FreeRTOSConfig.h b/hw/bsp/stm32f0/FreeRTOSConfig/FreeRTOSConfig.h index 37e7e09435..999dbfe9e4 100644 --- a/hw/bsp/stm32f0/FreeRTOSConfig/FreeRTOSConfig.h +++ b/hw/bsp/stm32f0/FreeRTOSConfig/FreeRTOSConfig.h @@ -58,7 +58,7 @@ #define configCPU_CLOCK_HZ SystemCoreClock #define configTICK_RATE_HZ ( 1000 ) #define configMAX_PRIORITIES ( 5 ) -#define configMINIMAL_STACK_SIZE ( 128 ) +#define configMINIMAL_STACK_SIZE ( 200 ) #define configTOTAL_HEAP_SIZE ( configSUPPORT_DYNAMIC_ALLOCATION*4*1024 ) #define configMAX_TASK_NAME_LEN 16 #define configUSE_16_BIT_TICKS 0 diff --git a/hw/bsp/stm32g0/FreeRTOSConfig/FreeRTOSConfig.h b/hw/bsp/stm32g0/FreeRTOSConfig/FreeRTOSConfig.h index 82cb0cdb3f..76133ea2d6 100644 --- a/hw/bsp/stm32g0/FreeRTOSConfig/FreeRTOSConfig.h +++ b/hw/bsp/stm32g0/FreeRTOSConfig/FreeRTOSConfig.h @@ -58,7 +58,7 @@ #define configCPU_CLOCK_HZ SystemCoreClock #define configTICK_RATE_HZ ( 1000 ) #define configMAX_PRIORITIES ( 5 ) -#define configMINIMAL_STACK_SIZE ( 128 ) +#define configMINIMAL_STACK_SIZE ( 200 ) #define configTOTAL_HEAP_SIZE ( configSUPPORT_DYNAMIC_ALLOCATION*4*1024 ) #define configMAX_TASK_NAME_LEN 16 #define configUSE_16_BIT_TICKS 0 diff --git a/hw/bsp/stm32g0/family.cmake b/hw/bsp/stm32g0/family.cmake index b6838c6199..0dafa9c0a7 100644 --- a/hw/bsp/stm32g0/family.cmake +++ b/hw/bsp/stm32g0/family.cmake @@ -15,7 +15,7 @@ set(CMAKE_SYSTEM_PROCESSOR cortex-m0plus CACHE INTERNAL "System Processor") set(CMAKE_TOOLCHAIN_FILE ${TOP}/examples/build_system/cmake/toolchain/arm_${TOOLCHAIN}.cmake) set(FAMILY_MCUS STM32G0 CACHE INTERNAL "") - +set(OPENOCD_OPTION "-f interface/stlink.cfg -f target/stm32g0x.cfg") #------------------------------------ # BOARD_TARGET @@ -112,6 +112,7 @@ function(family_configure_example TARGET RTOS) target_link_libraries(${TARGET} PUBLIC board_${BOARD} ${TARGET}-tinyusb) # Flashing - family_flash_stlink(${TARGET}) family_flash_jlink(${TARGET}) + family_flash_stlink(${TARGET}) + #family_flash_openocd(${TARGET}) endfunction() diff --git a/hw/bsp/stm32h5/FreeRTOSConfig/FreeRTOSConfig.h b/hw/bsp/stm32h5/FreeRTOSConfig/FreeRTOSConfig.h index cf6e23c1be..6a9c90a4ab 100644 --- a/hw/bsp/stm32h5/FreeRTOSConfig/FreeRTOSConfig.h +++ b/hw/bsp/stm32h5/FreeRTOSConfig/FreeRTOSConfig.h @@ -58,7 +58,7 @@ #define configCPU_CLOCK_HZ SystemCoreClock #define configTICK_RATE_HZ ( 1000 ) #define configMAX_PRIORITIES ( 5 ) -#define configMINIMAL_STACK_SIZE ( 128 ) +#define configMINIMAL_STACK_SIZE ( 200 ) #define configTOTAL_HEAP_SIZE ( configSUPPORT_DYNAMIC_ALLOCATION*4*1024 ) #define configMAX_TASK_NAME_LEN 16 #define configUSE_16_BIT_TICKS 0 diff --git a/src/device/usbd.c b/src/device/usbd.c index d9b20d26d8..6d27a37356 100644 --- a/src/device/usbd.c +++ b/src/device/usbd.c @@ -1201,7 +1201,7 @@ TU_ATTR_FAST_FUNC void dcd_event_handler(dcd_event_t const* event, bool in_isr) break; case DCD_EVENT_SETUP_RECEIVED: - // TU_ASSERT(event->setup_received.bRequest != 0,); + // TU_ASSERT(event->setup_received.bRequest != 0,); // for catching issue with ch32v203 and windows with -O0/-Og _usbd_queued_setup++; send = true; break; From f5d8796a6c59714d3096cf78cd7b4e8e114993a1 Mon Sep 17 00:00:00 2001 From: hathach Date: Thu, 1 Aug 2024 15:24:55 +0700 Subject: [PATCH 5/6] add f072 (fsdev 1k) to hil test --- .github/workflows/cifuzz.yml | 2 +- test/hil/rpi.json | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/.github/workflows/cifuzz.yml b/.github/workflows/cifuzz.yml index 622d261a0c..d7f1fc0667 100644 --- a/.github/workflows/cifuzz.yml +++ b/.github/workflows/cifuzz.yml @@ -26,7 +26,7 @@ jobs: with: oss-fuzz-project-name: 'tinyusb' language: c++ - fuzz-seconds: 600 + fuzz-seconds: 400 - name: Upload Crash uses: actions/upload-artifact@v4 diff --git a/test/hil/rpi.json b/test/hil/rpi.json index 4d9b0f2164..9520f30e24 100644 --- a/test/hil/rpi.json +++ b/test/hil/rpi.json @@ -44,6 +44,13 @@ "flasher_sn": "E6614103E72C1D2F", "flasher_args": "-f interface/cmsis-dap.cfg -f target/rp2040.cfg -c \"adapter speed 5000\"" }, + { + "name": "stm32f072disco", + "uid": "3A001A001357364230353532", + "flasher": "jlink", + "flasher_sn": "779541626", + "flasher_args": "-device stm32f072rb" + }, { "name": "stm32g0b1nucleo", "uid": "4D0038000450434E37343120", From 3f4f6c0ec7f5c95ca8a1965a078c0f92d0d4e8ad Mon Sep 17 00:00:00 2001 From: hathach Date: Thu, 1 Aug 2024 15:40:47 +0700 Subject: [PATCH 6/6] increase hil timeout, reduce fuzzing from 600 to 400 seconds --- test/hil/hil_test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/hil/hil_test.py b/test/hil/hil_test.py index bda66a2b50..bdc48591ec 100644 --- a/test/hil/hil_test.py +++ b/test/hil/hil_test.py @@ -43,7 +43,7 @@ pass -ENUM_TIMEOUT = 10 +ENUM_TIMEOUT = 30 # get usb serial by id