Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions .github/actions/get_deps/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,12 @@ runs:
using: "composite"
steps:
- name: Checkout pico-sdk for rp2040
if: contains(inputs.arg, 'rp2040') || contains(inputs.arg, 'raspberry_pi_pico')
uses: actions/checkout@v4
if: >-
contains(inputs.arg, 'rp2040') ||
contains(inputs.arg, 'rp2350') ||
contains(inputs.arg, 'raspberry_pi_pico') ||
contains(inputs.arg, 'adafruit_fruit_jam')
uses: actions/checkout@v6
with:
repository: raspberrypi/pico-sdk
ref: master
Expand Down
2 changes: 1 addition & 1 deletion .github/actions/setup_toolchain/download/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ runs:
steps:
- name: Cache Toolchain
if: ${{ !startsWith(inputs.toolchain_url, 'https://github.com') }}
uses: actions/cache@v4
uses: actions/cache@v5
id: cache-toolchain-download
with:
path: ~/cache/${{ inputs.toolchain }}
Expand Down
2 changes: 1 addition & 1 deletion .github/actions/setup_toolchain/espressif/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ runs:
shell: bash

- name: Cache Docker Image
uses: actions/cache@v4
uses: actions/cache@v5
id: cache-toolchain-espressif
with:
path: ${{ env.DOCKER_ESP_IDF }}
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
- uses: actions/checkout@v6
with:
fetch-depth: 2 # Needed for push commit comparison
- uses: dorny/paths-filter@v3
- uses: dorny/paths-filter@v4
id: filter
with:
filters: |
Expand Down Expand Up @@ -124,7 +124,7 @@ jobs:

- name: Upload Metrics Artifact
if: github.event_name == 'push' || github.event_name == 'release'
uses: actions/upload-artifact@v5
uses: actions/upload-artifact@v7
with:
name: metrics-tinyusb
path: metrics.json
Expand Down Expand Up @@ -179,7 +179,7 @@ jobs:

- name: Upload Metrics Comment Artifact
if: github.event_name == 'pull_request'
uses: actions/upload-artifact@v5
uses: actions/upload-artifact@v7
with:
name: metrics-comment
path: |
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/build_util.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,14 @@ jobs:

- name: Upload Artifacts for Metrics
if: inputs.upload-metrics == true && inputs.code-changed == true
uses: actions/upload-artifact@v5
uses: actions/upload-artifact@v7
with:
name: metrics-${{ matrix.arg }}
path: cmake-build/cmake-build-*/metrics.json

- name: Upload Artifacts for Hardware Testing
if: inputs.upload-artifacts == true && inputs.code-changed == true
uses: actions/upload-artifact@v5
uses: actions/upload-artifact@v7
with:
name: binaries-${{ matrix.arg }}
path: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/cifuzz.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
fuzz-seconds: 400

- name: Upload Crash
uses: actions/upload-artifact@v5
uses: actions/upload-artifact@v7
if: failure() && steps.build.outcome == 'success'
with:
name: artifacts
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/static_analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ jobs:
category: CodeQL

- name: Upload artifact
uses: actions/upload-artifact@v5
uses: actions/upload-artifact@v7
with:
name: codeql-${{ matrix.board }}
path: ${{ steps.analyze.outputs.sarif-output }}
Expand Down Expand Up @@ -136,7 +136,7 @@ jobs:
category: PVS-Studio

- name: Upload artifact
uses: actions/upload-artifact@v5
uses: actions/upload-artifact@v7
with:
name: pvs-studio-${{ matrix.board }}
path: pvs-studio-${{ matrix.board }}.sarif
Expand Down Expand Up @@ -236,7 +236,7 @@ jobs:
category: IAR-CStat

- name: Upload artifact
uses: actions/upload-artifact@v5
uses: actions/upload-artifact@v7
with:
name: iar-cstat-${{ matrix.board }}
path: iar-cstat-${{ matrix.board }}.sarif
8 changes: 7 additions & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ information that does not match the info here.
## Build Examples

Choose ONE of these approaches:

**Option 1: Individual Example with CMake and Ninja (RECOMMENDED)**

```bash
Expand Down Expand Up @@ -152,6 +151,13 @@ openocd -f interface/stlink.cfg -f target/stm32h7x.cfg
openocd -f interface/jlink.cfg -f target/stm32h7x.cfg
```

For **rp2040/rp2350** with a CMSIS-DAP probe (e.g. Picoprobe, debugprobe):
```bash
openocd -f interface/cmsis-dap.cfg -f target/rp2040.cfg -c "adapter speed 5000"
# or for rp2350:
openocd -f interface/cmsis-dap.cfg -f target/rp2350.cfg -c "adapter speed 5000"
```

For boards that define `OPENOCD_OPTION` in `board.cmake`, use those options directly:
```bash
openocd $(cat hw/bsp/FAMILY/boards/BOARD/board.cmake | grep OPENOCD_OPTION | ...)
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2018, hathach (tinyusb.org)
Copyright (c) 2012-2026, hathach (tinyusb.org)

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
12 changes: 10 additions & 2 deletions examples/device/hid_generic_inout/src/usb_descriptors.c
Original file line number Diff line number Diff line change
Expand Up @@ -97,15 +97,23 @@

#define CONFIG_TOTAL_LEN (TUD_CONFIG_DESC_LEN + TUD_HID_INOUT_DESC_LEN)

#define EPNUM_HID 0x01
#if defined(TUD_ENDPOINT_ONE_DIRECTION_ONLY)
// MCUs that don't support a same endpoint number with different direction IN and OUT defined in tusb_mcu.h
// e.g EP1 OUT & EP1 IN cannot exist together
#define EPNUM_HID_OUT 0x01
#define EPNUM_HID_IN 0x82
#else
#define EPNUM_HID_OUT 0x01
#define EPNUM_HID_IN 0x81
#endif

uint8_t const desc_configuration[] =
{
// Config number, interface count, string index, total length, attribute, power in mA
TUD_CONFIG_DESCRIPTOR(1, ITF_NUM_TOTAL, 0, CONFIG_TOTAL_LEN, 0x00, 100),

// Interface number, string index, protocol, report descriptor len, EP Out & In address, size & polling interval
TUD_HID_INOUT_DESCRIPTOR(ITF_NUM_HID, 0, HID_ITF_PROTOCOL_NONE, sizeof(desc_hid_report), EPNUM_HID, 0x80 | EPNUM_HID, CFG_TUD_HID_EP_BUFSIZE, 10)
TUD_HID_INOUT_DESCRIPTOR(ITF_NUM_HID, 0, HID_ITF_PROTOCOL_NONE, sizeof(desc_hid_report), EPNUM_HID_OUT, EPNUM_HID_IN, CFG_TUD_HID_EP_BUFSIZE, 10)
};

// Invoked when received GET CONFIGURATION DESCRIPTOR
Expand Down
11 changes: 8 additions & 3 deletions examples/host/msc_file_explorer/src/msc_app.c
Original file line number Diff line number Diff line change
Expand Up @@ -130,11 +130,16 @@ static bool inquiry_complete_cb(uint8_t dev_addr, const tuh_msc_complete_data_t
drive_path[0] += drive_num;

if (f_mount(&fatfs[drive_num], drive_path, 1) != FR_OK) {
puts("mount failed");
printf("mount failed\r\n");
return true;
}

// change to newly mounted drive
f_chdir(drive_path);
f_chdrive(drive_path);
FRESULT rc = f_chdir("/");
if (rc != FR_OK) {
printf("chdir failed: %d\r\n", rc);
}

// print the drive label
// char label[34];
Expand All @@ -148,7 +153,7 @@ static bool inquiry_complete_cb(uint8_t dev_addr, const tuh_msc_complete_data_t

//------------- IMPLEMENTATION -------------//
void tuh_msc_mount_cb(uint8_t dev_addr) {
printf("A MassStorage device is mounted\r\n");
printf("A MassStorage device (addr = %u) is mounted\r\n", dev_addr);

const uint8_t lun = 0;
tuh_msc_inquiry(dev_addr, lun, &scsi_resp.inquiry, inquiry_complete_cb, 0);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
set(PICO_PLATFORM rp2040)
set(PICO_BOARD adafruit_feather_rp2040_usb_host)
set(CFG_TUH_RPI_PIO_USB 1)
2 changes: 2 additions & 0 deletions hw/bsp/rp2040/boards/adafruit_fruit_jam/board.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@ set(PICO_PLATFORM rp2350-arm-s)
set(PICO_BOARD adafruit_fruit_jam)
set(PICO_BOARD_HEADER_DIRS ${CMAKE_CURRENT_LIST_DIR})
#set(OPENOCD_SERIAL E6614103E78E8324)

set(CFG_TUH_RPI_PIO_USB 1)
2 changes: 2 additions & 0 deletions hw/bsp/rp2040/boards/adafruit_metro_rp2350/board.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@ set(PICO_PLATFORM rp2350-arm-s)
set(PICO_BOARD adafruit_metro_rp2350)
set(PICO_BOARD_HEADER_DIRS ${CMAKE_CURRENT_LIST_DIR})
#set(OPENOCD_SERIAL E6614103E78E8324)

set(CFG_TUH_RPI_PIO_USB 1)
6 changes: 6 additions & 0 deletions hw/bsp/rp2040/family.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,12 @@ target_compile_definitions(tinyusb_common_base INTERFACE
CFG_TUSB_DEBUG=${TINYUSB_DEBUG_LEVEL}
)

if (CFG_TUH_RPI_PIO_USB)
target_compile_definitions(tinyusb_common_base INTERFACE
CFG_TUH_RPI_PIO_USB=1
)
endif()

target_link_libraries(tinyusb_common_base INTERFACE
hardware_structs
hardware_irq
Expand Down
28 changes: 25 additions & 3 deletions hw/bsp/stm32f7/family.c
Original file line number Diff line number Diff line change
Expand Up @@ -289,14 +289,31 @@ size_t board_get_unique_id(uint8_t id[], size_t max_len) {
}

int board_uart_read(uint8_t *buf, int len) {
(void) buf;
(void) len;
#ifdef UART_DEV
int count = 0;
// clear overrun error if any
if (__HAL_UART_GET_FLAG(&UartHandle, UART_FLAG_ORE)) {
__HAL_UART_CLEAR_FLAG(&UartHandle, UART_CLEAR_OREF);
}
for (int i = 0; i < len; i++) {
if (__HAL_UART_GET_FLAG(&UartHandle, UART_FLAG_RXNE)) {
buf[i] = (uint8_t) UartHandle.Instance->RDR;
count++;
} else {
break;
}
}
return count;
#else
(void) buf; (void) len;
return 0;
#endif
}

int board_uart_write(void const *buf, int len) {
#ifdef UART_DEV
HAL_UART_Transmit(&UartHandle, (uint8_t *) (uintptr_t) buf, len, 0xffff);
HAL_UART_Transmit(&UartHandle, (uint8_t * )(uintptr_t)
buf, len, 0xffff);
return len;
#else
(void) buf; (void) len;
Expand All @@ -316,6 +333,11 @@ uint32_t tusb_time_millis_api(void) {
return system_ticks;
}

#elif CFG_TUSB_OS == OPT_OS_THREADX
// Keep HAL_GetTick() working for HAL functions called from board_init()
void osal_threadx_tick_cb(void) {
HAL_IncTick();
}
#endif

void HardFault_Handler(void) {
Expand Down
18 changes: 14 additions & 4 deletions hw/bsp/stm32h7/boards/stm32h743eval/board.h
Original file line number Diff line number Diff line change
Expand Up @@ -205,13 +205,23 @@ static int32_t board_i2c_deinit(void) {
}

static int32_t i2c_readreg(uint16_t DevAddr, uint16_t Reg, uint8_t *pData, uint16_t Length) {
TU_ASSERT (HAL_OK == HAL_I2C_Mem_Read(&i2c_handle, DevAddr, Reg, I2C_MEMADD_SIZE_8BIT, pData, Length, 10000));
return 0;
for (int retry = 0; retry < 3; retry++) {
if (HAL_OK == HAL_I2C_Mem_Read(&i2c_handle, DevAddr, Reg, I2C_MEMADD_SIZE_8BIT, pData, Length, 10000)) {
return 0;
}
HAL_Delay(10);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Avoid HAL_Delay retries during pre-scheduler init

Using HAL_Delay(10) in this retry loop can deadlock STM32H7 FreeRTOS startups: board_init() disables SysTick before calling board_init2() in hw/bsp/stm32h7/family.c, so if the first I2C access fails here, HAL_Delay() has no advancing tick source and blocks indefinitely instead of retrying. This retry path needs a delay mechanism that works before the scheduler/tick is running.

Useful? React with 👍 / 👎.

}
return -1;
}

static int32_t i2c_writereg(uint16_t DevAddr, uint16_t Reg, uint8_t *pData, uint16_t Length) {
TU_ASSERT(HAL_OK == HAL_I2C_Mem_Write(&i2c_handle, DevAddr, Reg, I2C_MEMADD_SIZE_8BIT, pData, Length, 10000));
return 0;
for (int retry = 0; retry < 3; retry++) {
if (HAL_OK == HAL_I2C_Mem_Write(&i2c_handle, DevAddr, Reg, I2C_MEMADD_SIZE_8BIT, pData, Length, 10000)) {
return 0;
}
HAL_Delay(10);
}
return -1;
}

static int32_t i2c_get_tick(void) {
Expand Down
20 changes: 18 additions & 2 deletions hw/bsp/stm32h7/family.c
Original file line number Diff line number Diff line change
Expand Up @@ -275,9 +275,25 @@ size_t board_get_unique_id(uint8_t id[], size_t max_len) {
}

int board_uart_read(uint8_t *buf, int len) {
(void) buf;
(void) len;
#ifdef UART_DEV
int count = 0;
// clear overrun error if any
if (__HAL_UART_GET_FLAG(&UartHandle, UART_FLAG_ORE)) {
__HAL_UART_CLEAR_FLAG(&UartHandle, UART_CLEAR_OREF);
}
for (int i = 0; i < len; i++) {
if (__HAL_UART_GET_FLAG(&UartHandle, UART_FLAG_RXNE)) {
buf[i] = (uint8_t) UartHandle.Instance->RDR;
count++;
} else {
break;
}
}
return count;
#else
(void) buf; (void) len;
return 0;
#endif
}

int board_uart_write(void const *buf, int len) {
Expand Down
2 changes: 1 addition & 1 deletion src/portable/mentor/musb/dcd_musb.c
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ static void process_bus_reset(uint8_t rhport) {
*------------------------------------------------------------------*/

#if CFG_TUSB_DEBUG >= MUSB_DEBUG
void print_musb_info(musb_regs_t* musb_regs) {
static void print_musb_info(musb_regs_t* musb_regs) {
// print version, epinfo, raminfo, config_data0, fifo_size
TU_LOG1("musb version = %u.%u\r\n", musb_regs->hwvers_bit.major, musb_regs->hwvers_bit.minor);
TU_LOG1("Number of endpoints: %u TX, %u RX\r\n", musb_regs->epinfo_bit.tx_ep_num, musb_regs->epinfo_bit.rx_ep_num);
Expand Down
Loading
Loading