Skip to content

Commit 17a0ce6

Browse files
committed
Merge branch 'master' into h5
2 parents f3d713a + 9474db8 commit 17a0ce6

File tree

14 files changed

+141
-43
lines changed

14 files changed

+141
-43
lines changed

.github/workflows/build_esp.yml

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,15 @@ jobs:
8181
rm -rf "${{ github.workspace }}"
8282
mkdir -p "${{ github.workspace }}"
8383
84+
# USB bus on rpi4 is not stable, reset it before testing
85+
- name: Reset USB bus
86+
run: |
87+
for port in $(lspci | grep USB | cut -d' ' -f1); do
88+
echo -n "0000:${port}"| sudo tee /sys/bus/pci/drivers/xhci_hcd/unbind;
89+
sleep 0.1;
90+
echo -n "0000:${port}" | sudo tee /sys/bus/pci/drivers/xhci_hcd/bind;
91+
done
92+
8493
- name: Checkout test/hil
8594
uses: actions/checkout@v3
8695
with:
@@ -95,11 +104,3 @@ jobs:
95104
- name: Test on actual hardware
96105
run: |
97106
python3 test/hil/hil_test.py --board ${{ matrix.board }} hil_pi4.json
98-
99-
- name: Reset USB bus
100-
run: |
101-
for port in $(lspci | grep USB | cut -d' ' -f1); do
102-
echo -n "0000:${port}"| sudo tee /sys/bus/pci/drivers/xhci_hcd/unbind;
103-
sleep 1;
104-
echo -n "0000:${port}" | sudo tee /sys/bus/pci/drivers/xhci_hcd/bind;
105-
done

.github/workflows/cmake_arm.yml

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,13 @@ jobs:
102102
path: |
103103
cmake-build/cmake-build-feather_nrf52840_express/*/*/*.elf
104104
105+
- name: Upload Artifacts for Hardware Testing (samd51)
106+
if: matrix.family == 'samd51' && github.repository_owner == 'hathach'
107+
uses: actions/upload-artifact@v3
108+
with:
109+
name: itsybitsy_m4
110+
path: |
111+
cmake-build/cmake-build-itsybitsy_m4/*/*/*.bin
105112
106113
# ---------------------------------------
107114
# Hardware in the loop (HIL)
@@ -116,15 +123,25 @@ jobs:
116123
fail-fast: false
117124
matrix:
118125
board:
119-
- 'raspberry_pi_pico'
120126
- 'feather_nrf52840_express'
127+
- 'itsybitsy_m4'
128+
- 'raspberry_pi_pico'
121129
steps:
122130
- name: Clean workspace
123131
run: |
124132
echo "Cleaning up previous run"
125133
rm -rf "${{ github.workspace }}"
126134
mkdir -p "${{ github.workspace }}"
127135
136+
# USB bus on rpi4 is not stable, reset it before testing
137+
- name: Reset USB bus
138+
run: |
139+
for port in $(lspci | grep USB | cut -d' ' -f1); do
140+
echo -n "0000:${port}"| sudo tee /sys/bus/pci/drivers/xhci_hcd/unbind;
141+
sleep 0.1;
142+
echo -n "0000:${port}" | sudo tee /sys/bus/pci/drivers/xhci_hcd/bind;
143+
done
144+
128145
- name: Checkout test/hil
129146
uses: actions/checkout@v3
130147
with:
@@ -139,11 +156,3 @@ jobs:
139156
- name: Test on actual hardware
140157
run: |
141158
python3 test/hil/hil_test.py --board ${{ matrix.board }} hil_pi4.json
142-
143-
- name: Reset USB bus
144-
run: |
145-
for port in $(lspci | grep USB | cut -d' ' -f1); do
146-
echo -n "0000:${port}"| sudo tee /sys/bus/pci/drivers/xhci_hcd/unbind;
147-
sleep 1;
148-
echo -n "0000:${port}" | sudo tee /sys/bus/pci/drivers/xhci_hcd/bind;
149-
done

docs/reference/getting_started.rst

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,10 @@ Some board use uf2 bootloader for drag & drop in to mass storage device, uf2 can
178178
$ make BOARD=feather_nrf52840_express all uf2
179179
180180
IAR Support
181-
^^^^^^^^^^^
181+
-----------
182+
183+
Use project connection
184+
^^^^^^^^^^^^^^^^^^^^^^
182185

183186
IAR Project Connection files are provided to import TinyUSB stack into your project.
184187

@@ -191,19 +194,19 @@ IAR Project Connection files are provided to import TinyUSB stack into your proj
191194

192195
- `STM32L0xx_HAL_Driver` is only needed to run examples, TinyUSB stack itself doesn't rely on MCU's SDKs.
193196

194-
* Open `Tools -> Configure Custom Argument Variables` (Switch to `Global` tab if you want to do it for all your projects)
197+
* Open ``Tools -> Configure Custom Argument Variables`` (Switch to `Global` tab if you want to do it for all your projects)
195198
Click `New Group ...`, name it to `TUSB`, Click `Add Variable ...`, name it to `TUSB_DIR`, change it's value to the path of your TinyUSB stack,
196199
for example `C:\\tinyusb`
197200

198201
Import stack only
199202
~~~~~~~~~~~~~~~~~
200203

201-
1. Open `Project -> Add project Connection ...`, click `OK`, choose `tinyusb\\tools\\iar_template.ipcf`.
204+
1. Open ``Project -> Add project Connection ...``, click `OK`, choose `tinyusb\\tools\\iar_template.ipcf`.
202205

203206
Run examples
204207
~~~~~~~~~~~~
205208

206-
1. (Python3 is needed) Run `iar_gen.py` to generate .ipcf files of examples:
209+
1. (Python3 is needed) Run ``iar_gen.py`` to generate .ipcf files of examples:
207210

208211
.. code-block::
209212
@@ -212,3 +215,15 @@ Run examples
212215
213216
2. Open `Project -> Add project Connection ...`, click `OK`, choose `tinyusb\\examples\\(.ipcf of example)`.
214217
For example `C:\\tinyusb\\examples\\device\\cdc_msc\\iar_cdc_msc.ipcf`
218+
219+
Native CMake support (9.50.1+)
220+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
221+
222+
With 9.50.1 release, IAR added experimental native CMake support (strangely not mentioned in public release note). Now it's possible to import CMakeLists.txt then build and debug as a normal project.
223+
224+
Following these steps:
225+
226+
1. Add IAR compiler binary path to system ``PATH`` environment variable, such as ``C:\Program Files\IAR Systems\Embedded Workbench 9.2\arm\bin``.
227+
2. Create new project in IAR, in Tool chain dropdown menu, choose CMake for Arm then Import ``CMakeLists.txt`` from chosen example directory.
228+
3. Set up board option in ``Option - CMake/CMSIS-TOOLBOX - CMake``, for example :code:`-DBOARD=stm32f439nucleo -DTOOLCHAIN=iar`, **Uncheck 'Override tools in env'**.
229+
4. (For debug only) Choose correct CPU model in ``Option - General Options - Target``, to profit register and memory view.

examples/build_system/cmake/cpu/cortex-m4.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ if (TOOLCHAIN STREQUAL "gcc")
1313
elseif (TOOLCHAIN STREQUAL "iar")
1414
set(TOOLCHAIN_COMMON_FLAGS
1515
--cpu cortex-m4
16-
--fpu VFPv4
16+
--fpu VFPv4_sp
1717
)
1818

1919
if (NOT DEFINED FREERTOS_PORT)

examples/build_system/cmake/toolchain/arm_iar.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ list(APPEND TOOLCHAIN_COMMON_FLAGS
2626
)
2727

2828
list(APPEND TOOLCHAIN_EXE_LINKER_FLAGS
29+
--diag_suppress=Li065
2930
)
3031

3132
include(${CMAKE_CURRENT_LIST_DIR}/set_flags.cmake)

hw/bsp/family_support.cmake

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ set(WARNING_FLAGS_GNU
7272
-Wredundant-decls
7373
)
7474

75-
set(WARNINGS_FLAGS_IAR "")
75+
set(WARNING_FLAGS_IAR "")
7676

7777

7878
# Filter example based on only.txt and skip.txt
@@ -191,10 +191,12 @@ function(family_configure_common TARGET RTOS)
191191
)
192192

193193
# run size after build
194-
add_custom_command(TARGET ${TARGET} POST_BUILD
195-
COMMAND ${CMAKE_SIZE} $<TARGET_FILE:${TARGET}>
196-
)
197-
194+
find_program(SIZE_EXE ${CMAKE_SIZE})
195+
if(NOT ${SIZE_EXE} STREQUAL SIZE_EXE-NOTFOUND)
196+
add_custom_command(TARGET ${TARGET} POST_BUILD
197+
COMMAND ${SIZE_EXE} $<TARGET_FILE:${TARGET}>
198+
)
199+
endif ()
198200
# Add warnings flags
199201
target_compile_options(${TARGET} PUBLIC ${WARNING_FLAGS_${CMAKE_C_COMPILER_ID}})
200202

@@ -205,6 +207,10 @@ function(family_configure_common TARGET RTOS)
205207
target_link_options(${TARGET} PUBLIC "LINKER:--no-warn-rwx-segments")
206208
endif ()
207209
endif()
210+
if (CMAKE_C_COMPILER_ID STREQUAL "IAR")
211+
target_link_options(${TARGET} PUBLIC "LINKER:--map=$<TARGET_FILE:${TARGET}>.map")
212+
endif()
213+
208214

209215
# ETM Trace option
210216
if (TRACE_ETM STREQUAL "1")
@@ -367,7 +373,7 @@ function(family_flash_jlink TARGET)
367373
endif ()
368374

369375
file(GENERATE
370-
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${TARGET}.jlink
376+
OUTPUT $<TARGET_FILE_DIR:${TARGET}>/${TARGET}.jlink
371377
CONTENT "halt
372378
loadfile $<TARGET_FILE:${TARGET}>
373379
r
@@ -377,7 +383,7 @@ exit"
377383

378384
add_custom_target(${TARGET}-jlink
379385
DEPENDS ${TARGET}
380-
COMMAND ${JLINKEXE} -device ${JLINK_DEVICE} -if swd -JTAGConf -1,-1 -speed auto -CommandFile ${CMAKE_CURRENT_BINARY_DIR}/${TARGET}.jlink
386+
COMMAND ${JLINKEXE} -device ${JLINK_DEVICE} -if swd -JTAGConf -1,-1 -speed auto -CommandFile $<TARGET_FILE_DIR:${TARGET}>/${TARGET}.jlink
381387
)
382388
endfunction()
383389

hw/bsp/samd21/family.cmake

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ set(CMAKE_SYSTEM_PROCESSOR cortex-m0plus CACHE INTERNAL "System Processor")
1010
set(CMAKE_TOOLCHAIN_FILE ${TOP}/examples/build_system/cmake/toolchain/arm_${TOOLCHAIN}.cmake)
1111

1212
set(FAMILY_MCUS SAMD21 CACHE INTERNAL "")
13-
13+
set(OPENOCD_OPTION "-f interface/cmsis-dap.cfg -c \"transport select swd\" -f target/at91samdXX.cfg")
1414

1515
#------------------------------------
1616
# BOARD_TARGET
@@ -102,4 +102,5 @@ function(family_configure_example TARGET RTOS)
102102

103103
# Flashing
104104
family_flash_jlink(${TARGET})
105+
#family_flash_openocd(${TARGET} ${OPENOCD_OPTION})
105106
endfunction()

hw/bsp/samd51/family.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,20 @@ uint32_t board_button_read(void) {
157157
return gpio_get_pin_level(BUTTON_PIN) ? 0 : 1;
158158
}
159159

160+
size_t board_get_unique_id(uint8_t id[], size_t max_len) {
161+
(void) max_len;
162+
163+
uint32_t did_addr[4] = {0x008061FC, 0x00806010, 0x00806014, 0x00806018};
164+
165+
for (int i = 0; i < 4; i++) {
166+
uint32_t did = *((uint32_t const*) did_addr[i]);
167+
did = TU_BSWAP32(did); // swap endian to match samd51 uf2 bootloader
168+
memcpy(id + i * 4, &did, 4);
169+
}
170+
171+
return 16;
172+
}
173+
160174
int board_uart_read(uint8_t* buf, int len) {
161175
(void) buf;
162176
(void) len;

hw/bsp/samd51/family.cmake

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ set(CMAKE_SYSTEM_PROCESSOR cortex-m4 CACHE INTERNAL "System Processor")
1010
set(CMAKE_TOOLCHAIN_FILE ${TOP}/examples/build_system/cmake/toolchain/arm_${TOOLCHAIN}.cmake)
1111

1212
set(FAMILY_MCUS SAMD51 CACHE INTERNAL "")
13-
13+
set(OPENOCD_OPTION "-f interface/cmsis-dap.cfg -c \"transport select swd\" -c \"set CHIPNAME samd51\" -f target/atsame5x.cfg")
1414

1515
#------------------------------------
1616
# BOARD_TARGET
@@ -100,5 +100,7 @@ function(family_configure_example TARGET RTOS)
100100
target_link_libraries(${TARGET} PUBLIC board_${BOARD} ${TARGET}-tinyusb)
101101

102102
# Flashing
103+
family_add_bin_hex(${TARGET})
103104
family_flash_jlink(${TARGET})
105+
#family_flash_openocd(${TARGET} ${OPENOCD_OPTION})
104106
endfunction()

src/device/usbd_pvt.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,6 @@
3333
extern "C" {
3434
#endif
3535

36-
// Level where CFG_TUSB_DEBUG must be at least for USBD is logged
37-
#ifndef CFG_TUD_LOG_LEVEL
38-
#define CFG_TUD_LOG_LEVEL 2
39-
#endif
40-
4136
#define TU_LOG_USBD(...) TU_LOG(CFG_TUD_LOG_LEVEL, __VA_ARGS__)
4237

4338
//--------------------------------------------------------------------+

0 commit comments

Comments
 (0)