-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Description
Describe the bug
When trying to use cdc acm with micropython's zephyr port, using Zephyr 4.2.0 or latest, and micropython 1.26.1 or latest, the USB Next UDC driver causes a fault:
***** USAGE FAULT *****
Unaligned memory access
r0/a1: 0x50100109 r1/a2: 0x20066589 r2/a3: 0x80000000
r3/a4: 0x00000000 r12/ip: 0x50100100 r14/lr: 0x20000e71
xpsr: 0xa100001e
Faulting instruction address (r15/pc): 0x10001ae8
(In this log from uart, usb driver was relocated to RAM, however this also happens if it is in XIP).
The full stack trace:
arch_system_halt (reason=31) at /home/vdragon/dev/zephyr_upstreaming/zephyr/kernel/fatal.c:30
30 for (;;) {
(gdb) bt
#0 arch_system_halt (reason=31) at /home/vdragon/dev/zephyr_upstreaming/zephyr/kernel/fatal.c:30
#1 0x10026720 in k_sys_fatal_error_handler (reason=<optimized out>, esf=esf@entry=0x20067738 <z_interrupt_stacks+1848>) at /home/vdragon/dev/zephyr_upstreaming/zephyr/kernel/fatal.c:44
#2 0x10009950 in z_fatal_error (reason=<optimized out>, esf=esf@entry=0x20067738 <z_interrupt_stacks+1848>) at /home/vdragon/dev/zephyr_upstreaming/zephyr/kernel/fatal.c:119
#3 0x10003be0 in z_arm_fatal_error (reason=<optimized out>, esf=esf@entry=0x20067738 <z_interrupt_stacks+1848>) at /home/vdragon/dev/zephyr_upstreaming/zephyr/arch/arm/core/fatal.c:87
#4 0x10003f4a in z_arm_fault (msp=<optimized out>, psp=<optimized out>, exc_return=<optimized out>, callee_regs=<optimized out>) at /home/vdragon/dev/zephyr_upstreaming/zephyr/arch/arm/core/cortex_m/fault.c:1083
#5 0x10004000 in z_arm_usage_fault () at /home/vdragon/dev/zephyr_upstreaming/zephyr/arch/arm/core/cortex_m/fault_s.S:102
#6 <signal handler called>
#7 0x10001ae8 in memcpy ()
#8 0x20000e70 in rpi_pico_prep_tx (dev=dev@entry=0x1002f510 <__device_dts_ord_77>, buf=buf@entry=0x2006a098 <_net_buf_udc_ep_pool>, cfg=cfg@entry=0x20003030 <ep_cfg_out>)
at /home/vdragon/dev/zephyr_upstreaming/zephyr/drivers/usb/udc/udc_rpi_pico.c:293
#9 0x20000d44 in rpi_pico_handle_buff_status_in (ep=128 '\200', dev=0x1002f510 <__device_dts_ord_77>) at /home/vdragon/dev/zephyr_upstreaming/zephyr/drivers/usb/udc/udc_rpi_pico.c:600
#10 rpi_pico_handle_buff_status (dev=0x1002f510 <__device_dts_ord_77>) at /home/vdragon/dev/zephyr_upstreaming/zephyr/drivers/usb/udc/udc_rpi_pico.c:664
#11 rpi_pico_isr_handler (dev=0x1002f510 <__device_dts_ord_77>) at /home/vdragon/dev/zephyr_upstreaming/zephyr/drivers/usb/udc/udc_rpi_pico.c:808
#12 0x1000428a in _isr_wrapper () at /home/vdragon/dev/zephyr_upstreaming/zephyr/arch/arm/core/cortex_m/isr_wrapper.c:80
#13 <signal handler called>
#14 0x10022a36 in arch_cpu_idle () at /home/vdragon/dev/zephyr_upstreaming/zephyr/arch/arm/core/cortex_m/cpu_idle.c:106
#15 0x100268a4 in k_cpu_idle () at /home/vdragon/dev/zephyr_upstreaming/zephyr/include/zephyr/kernel.h:6395
#16 idle (unused1=<optimized out>, unused2=<optimized out>, unused3=<optimized out>) at /home/vdragon/dev/zephyr_upstreaming/zephyr/kernel/idle.c:75
#17 0x1002247a in z_thread_entry (entry=0x10, p1=<optimized out>, p2=<optimized out>, p3=<optimized out>) at /home/vdragon/dev/zephyr_upstreaming/zephyr/lib/os/thread_entry.c:48
#18 0xaaaaaaaa in ?? ()
This however, is no reproducible when restarting the rp2350 with the debugger (USB looks entirely disabled).
It is also also not reproducible with the Hazard3 core, where it works mostly fine with the firmware either in XIP or RAM.
Not been able to reproduce with the usb next console sample.
micropython's code has been checked over, is pretty much the usb next console sample for the usb part, and works fine on hazard3, rp2040, and other devices capable of cdc acm i have tested.
Regression
- This is a regression.
Steps to reproduce
Build micropython zephyr port (CONFIG_XIP=y or CONFIG_XIP=n)
Put micropython zephyr port on the device
Run
Bug happens (no usb device if console is cdc, error on uart if it is uart).
Relevant log output
Impact
Major – Severely degrades functionality; workaround is difficult or unavailable.
Environment
The hw is weact RP2350B with the newer revision of rp2350.
sdk 0.17.2
Additional Context
https://discord.com/channels/720317445772017664/1423742660291727370