Potential bug with DAP_PACKET_SIZE configuration on STM32F103CB
- Dominant language
- C
- Stars
- 2.8k
- Forks
- 1.1k
- Avg merge
- 3d 12h
- Merged PRs (30d)
- 1
Description
I'm compiling daplink firmware for STM323F103CB.
Full version with hid+bulk+etc works fine as daplink v2.
When I compiled it without HID to use it as only bulk+cdc then I observe that USB transfer hangs up.
I've found this configuration of DAP_PACKET_SIZE in source code (hic_hal/stm32/stm32f103xb):
```
/// Maximum Package Size for Command and Response data.
/// This configuration settings is used to optimize the communication performance with the
/// debugger and depends on the USB peripheral. Typical vales are 64 for Full-speed USB HID or WinUSB,
/// 1024 for High-speed USB HID and 512 for High-speed USB WinUSB.
#ifndef HID_ENDPOINT //HID end points currently set limits to 64
#define DAP_PACKET_SIZE 512 ///< Specifies Packet Size in bytes.
#else
#define DAP_PACKET_SIZE 64 ///< Specifies Packet Size in bytes.
#endif
```
STM32F103CB has Full-speed USB so USB packet size should be set to 64B not 512B.
I changed it to 64 and now compiled firmware works.
I think no one found this bug earlier because a full build uses HID, and then the packet size is fortunately set to 64.
Contributor guide
Research direction
Start in hic_hal/stm32/stm32f103xb and inspect how DAP_PACKET_SIZE is selected when HID_ENDPOINT is not defined. Build the firmware without HID for the STM32F103CB and verify that the full-speed USB configuration uses a 64-byte packet size and that USB transfers no longer hang.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c
- Domain
- embedded-iot
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 48/100