Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

pico_usb-cdc example fails with panic

Abierto
#928 10 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
22/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Tranquilo
Área
embedded-iot

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

rp usb

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
Lenguaje dominante
Zig
Estrellas
2.3k
Forks
198
Merge medio
1 d 8 h
PR fusionados (30 d)
37

Preparar el entorno

Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de ZigEmbeddedGroup/microzig

Todos los issues de ZigEmbeddedGroup/microzig

Issues similares

Más issues de Embedded & IoT

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.