pico_usb-cdc example fails with panic
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 22/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 冷清
- 领域
- embedded-iot
调研方向
The gdb backtrace points to the assert in ep_writev in port/raspberrypi/rp2xxx/src/hal/usb.zig (around line 287), reached from on_setup_req in core/src/core/usb.zig (line 482) and the poll loop in examples/raspberrypi/rp2xxx/src/usb_cdc.zig (line 76). Start by reading why the endpoint 0 write assertion fails during setup handling, then check the device descriptor response. Done means the pico_usb-cdc example enumerates on hardware without a HardFault.
由索引模型根据 Issue 内容生成。
描述
I built the rp2xxx examples with zig 0.15.1 on a Linux (Mint) system and uploaded the pico_usb-cdc example to a Raspberry Pi Pico with the command:
openocd -f interface/cmsis-dap.cfg \
-f target/rp2040.cfg \
-c "adapter speed 5000" \
-c "program zig-out/firmware/pico_usb-cdc.elf verify reset exit"
The serial port output shows the "STARTING NEW LOGGER" banner, then nothing. The device does not show up when using the lsusb command on the Raspberry Pi 5 to which the Pico's USB port is connected and nothing appears in the Pi's logs.
If I unplug the Pico from the USB Port and plug it back in, the serial port log shows:
================ STARTING NEW LOGGER ================
[5.355586] error: panic: reached unreachable code
[5.361085] error: panic: Unhandled exception: HardFault
Looking at the log on the Raspberry Pi I see that it did recognise that something was connected:
Apr 05 08:25:17 hal kernel: usb 3-2: new full-speed USB device number 123 using xhci-hcd
Apr 05 08:25:32 hal kernel: usb 3-2: device descriptor read/64, error -110
Apr 05 08:25:48 hal kernel: usb 3-2: device descriptor read/64, error -110
Apr 05 08:25:48 hal kernel: usb 3-2: new full-speed USB device number 124 using xhci-hcd
Apr 05 08:26:03 hal kernel: usb 3-2: device descriptor read/64, error -110
Note that after the panic happens before the second of these log lines is printed so the read error is unsurprising.
I ran the program again omitting the "exit" from the openocd command. Then after unplugging and plugging in the USB I connected to the Pico with gdb. The stack trace shows:
(gdb) bt
#0 usb_cdc.panic (message=...) at /home/craig/Git_Projects/microzig/examples/raspberrypi/rp2xxx/src/usb_cdc.zig:37
#1 0x100002e0 in builtin.panic__struct_2051.panic (msg=..., ra=...) at /home/craig/.zvm/0.15.1/lib/std/builtin.zig:1091
#2 0x10000ce0 in debug.FullPanic((function 'panic')).reachedUnreachable () at /home/craig/.zvm/0.15.1/lib/std/debug.zig:64
#3 0x10000308 in debug.assert (ok=false) at /home/craig/.zvm/0.15.1/lib/std/debug.zig:559
#4 0x1000fa04 in hal.usb.Polled(.{ .max_endpoints_count = 16, .max_interfaces_count = 16, .sync_noops = 3 }).ep_writev (itf=0x20000120 <usb_cdc.usb_device+264>, ep_num=ep0, data=...)
at /home/craig/Git_Projects/microzig/port/raspberrypi/rp2xxx/src/hal/usb.zig:287
#5 0x10009f52 in core.usb.DeviceInterface.ep_writev (self=0x20000120 <usb_cdc.usb_device+264>, ep_num=ep0, data=...) at /home/craig/Git_Projects/microzig/core/src/core/usb.zig:128
#6 0x100060ee in core.usb.DeviceController(.{ .bcd_usb = .{ ... }, .device_triple = .{ ... }, .vendor = .{ ... }, .product = .{ ... }, .bcd_device = .{ ... }, .language = .English, .serial = &.{ ... }[0..(...)], .max_supported_packet_size = 64, .configurations = &.{ ... }[0..(...)], .unique_endpoints = true },.{ .{ ... } }).on_setup_req (self=0x20000124 <usb_cdc.usb_controller>,
device_itf=0x20000120 <usb_cdc.usb_device+264>, setup=0x2003f9d0) at /home/craig/Git_Projects/microzig/core/src/core/usb.zig:482
#7 0x1000491a in hal.usb.Polled(.{ .max_endpoints_count = 16, .max_interfaces_count = 16, .sync_noops = 3 }).poll__anon_16389 (self=0x20000018 <usb_cdc.usb_device>,
controller=0x20000124 <usb_cdc.usb_controller>) at /home/craig/Git_Projects/microzig/port/raspberrypi/rp2xxx/src/hal/usb.zig:131
#8 0x10003f04 in usb_cdc.main () at /home/craig/Git_Projects/microzig/examples/raspberrypi/rp2xxx/src/usb_cdc.zig:76
#9 0x1000598a in start.microzig_main () at start.zig:62
#10 0x1000f15e in cortex_m.startup_logic._start () at /home/craig/Git_Projects/microzig/core/src/cpus/cortex_m.zig:761
Running uname on the Pi:
Linux hal 6.12.75+rpt-rpi-2712 #1 SMP PREEMPT Debian 1:6.12.75-1+rpt1 (2026-03-11) aarch64 GNU/Linux
- 主要语言
- Zig
- 星标
- 2.3k
- 派生
- 198
- 平均合并
- 1 天 8 小时
- 30 天内合并 PR
- 37
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
ZigEmbeddedGroup/microzig 的其他 Issue
-
难度 1/5 1 小时以内 新手友好度 88/100
ZigEmbeddedGroup/microzig#1086 ·
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 69/100
ZigEmbeddedGroup/microzig#1085 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 65/100
ZigEmbeddedGroup/microzig#1061 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 65/100
ZigEmbeddedGroup/microzig#1059 · 1 条评论 ·
维护者通常 1 天内回复
-
regz: AVR peripherals generated at address 0 when the register-group name matches the module (ATDF)未关闭
难度 4/5 3-5 天 新手友好度 48/100
ZigEmbeddedGroup/microzig#1072 ·
维护者通常 1 天内回复
查看 ZigEmbeddedGroup/microzig 的全部 Issue
相似的 Issue
-
[BUG] OTA Requestor accepts reserved provider endpoint 0xFFFF可能已有人在做 @Chapoly1305 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 72/100
project-chip/connectedhomeip#74742 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 63/100
Xinyuan-LilyGO/T-Display-S3#352 · 3 条评论 ·
-
难度 2/5 1-3 小时 新手友好度 79/100
lsongdev/node-bluetooth#62 ·
-
难度 2/5 1-3 小时 新手友好度 68/100
-
`espup update` fails with `File exists (os error 17)` when `~/.espup/esp-clang` is a dangling symlink可能已有人在做 @SergioGasquez 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 78/100