fix(usb): resolve USB CDC TX failure — DCache coherency + buffer + IMU API (bd-1lo) #6
Loading…
x
Reference in New Issue
Block a user
No description provided.
Delete Branch "sl-firmware/bd-1lo-usb-cdc-fix"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
SCB_DisableDCache()was insideicm42688_init(), called ~3.5s after USB starts. STM32F7SystemInit()enables DCache; CPU writes to TX buffers stay in cache and USB hardware reads stale SRAM → sends zeros/garbage. Fix:SCB_DisableDCache()moved tomain()beforeHAL_Init(), before USB starts.CDC_Transmit()passed caller stack buffer pointer to USB hardware. USB TXFE IRQ fires async; buffer could be overwritten before FIFO is loaded. Fix: alwaysmemcpyinto staticUserTxBufferbefore transmitting.main.ccalledicm42688_read()directly and passedicm42688_data_t*tobalance_update()which expectsIMUData*(float pitch/pitch_rate). Type mismatch produced garbage balance values. Fix: usempu6000_init()/mpu6000_read()which wraps icm42688 + complementary filter. Bonus: fixicm42688_init()returning 0 whenwho==0(false IMU success).Test plan
/dev/cu.usbmodemSALTY*)Scommand — streaming toggles off/onp(pitch) andr(pitch_rate) values are plausibleRcommand — DFU reboot works🤖 Generated with Claude Code