rust-exercises icon indicating copy to clipboard operation
rust-exercises copied to clipboard

USB exercise panics when using cyme for USB enumeration

Open robamu opened this issue 1 month ago • 0 comments

When running the USB-5 solution and then running cyme, the application crashes inside the usb-2 parser:

rust-exercises/nrf52-code/usb-app-solutions on  main [$] is 📦 v0.0.0 via 🦀 v1.90.0 took 48s
❯ cargo run --bin usb-5
    Finished `dev` profile [optimized + debuginfo] target(s) in 0.02s
     Running `probe-rs run --chip=nRF52840_xxAA --allow-erase-all --log-format=oneline target/thumbv7em-none-eabihf/debug/usb-5`
Available Probes:
0: Digilent USB Device -- 0403:6014:210248B780F8 (FTDI)
1: J-Link -- 1366:1051:001050238928 (J-Link)
Selection: 1
      Erasing ✔ 100% [####################]  20.00 KiB @  26.92 KiB/s (took 1s)
  Programming ✔ 100% [####################]  20.00 KiB @  17.95 KiB/s (took 1s)                                                Finished in 1.86s
00:00:00.000000 [DEBUG] Initializing the board (dk dk/src/lib.rs:323)
00:00:00.000000 [DEBUG] Clocks configured (dk dk/src/lib.rs:341)
00:00:00.000000 [DEBUG] RTC started (dk dk/src/lib.rs:360)
00:00:00.000000 [DEBUG] I/O pins have been configured for digital output (dk dk/src/lib.rs:370)
00:00:00.310638 [DEBUG] USB: UsbReset @ 00:00:00.310607 (usb_5 src/bin/usb-5.rs:59)
00:00:00.310699 [WARN ] USB reset condition detected (usb_5 src/bin/usb-5.rs:63)
00:00:00.388916 [DEBUG] USB: UsbEp0Setup @ 00:00:00.388916 (usb_5 src/bin/usb-5.rs:59)
00:00:00.389007 [DEBUG] SETUP: bmrequesttype: 0b10000000, brequest: 6, wlength: 64, windex: 0x0000, wvalue: 0x0100 (usb_5 src/bin/usb-5.rs:89)
00:00:00.389068 [INFO ] EP0: GetDescriptor { descriptor: Device, length: 64 } (usb_5 src/bin/usb-5.rs:100)
00:00:00.389404 [DEBUG] EP0IN: start 18B transfer (dk dk/src/usbd.rs:59)
00:00:00.389648 [DEBUG] USB: UsbEp0DataDone @ 00:00:00.389617 (usb_5 src/bin/usb-5.rs:59)
00:00:00.389709 [INFO ] EP0IN: transfer complete (usb_5 src/bin/usb-5.rs:68)
00:00:00.389770 [INFO ] EP0IN: transfer done (dk dk/src/usbd.rs:83)
00:00:00.390747 [DEBUG] USB: UsbReset @ 00:00:00.390747 (usb_5 src/bin/usb-5.rs:59)
00:00:00.390838 [WARN ] USB reset condition detected (usb_5 src/bin/usb-5.rs:63)
00:00:00.466796 [DEBUG] USB: UsbEp0Setup @ 00:00:00.466796 (usb_5 src/bin/usb-5.rs:59)
00:00:00.466888 [DEBUG] SETUP: bmrequesttype: 0b00000000, brequest: 5, wlength: 0, windex: 0x0000, wvalue: 0x000b (usb_5 src/bin/usb-5.rs:89)
00:00:00.466949 [INFO ] EP0: SetAddress { address: Some(11) } (usb_5 src/bin/usb-5.rs:100)
00:00:00.478790 [DEBUG] USB: UsbEp0Setup @ 00:00:00.478759 (usb_5 src/bin/usb-5.rs:59)
00:00:00.478851 [DEBUG] SETUP: bmrequesttype: 0b10000000, brequest: 6, wlength: 18, windex: 0x0000, wvalue: 0x0100 (usb_5 src/bin/usb-5.rs:89)
00:00:00.478942 [INFO ] EP0: GetDescriptor { descriptor: Device, length: 18 } (usb_5 src/bin/usb-5.rs:100)
00:00:00.479248 [DEBUG] EP0IN: start 18B transfer (dk dk/src/usbd.rs:59)
00:00:00.479644 [DEBUG] USB: UsbEp0DataDone @ 00:00:00.479614 (usb_5 src/bin/usb-5.rs:59)
00:00:00.479705 [INFO ] EP0IN: transfer complete (usb_5 src/bin/usb-5.rs:68)
00:00:00.479766 [INFO ] EP0IN: transfer done (dk dk/src/usbd.rs:83)
00:00:00.481628 [DEBUG] USB: UsbEp0Setup @ 00:00:00.481628 (usb_5 src/bin/usb-5.rs:59)
00:00:00.481719 [DEBUG] SETUP: bmrequesttype: 0b10000000, brequest: 6, wlength: 10, windex: 0x0000, wvalue: 0x0600 (usb_5 src/bin/usb-5.rs:89)
00:00:00.481781 [INFO ] EP0: GetDescriptor { descriptor: DeviceQualifier, length: 10 } (usb_5 src/bin/usb-5.rs:100)
00:00:00.482147 [WARN ] EP0IN: unexpected request; stalling the endpoint (usb_5 src/bin/usb-5.rs:74)
00:00:00.482757 [DEBUG] USB: UsbEp0Setup @ 00:00:00.482757 (usb_5 src/bin/usb-5.rs:59)
00:00:00.482849 [DEBUG] SETUP: bmrequesttype: 0b10000000, brequest: 6, wlength: 10, windex: 0x0000, wvalue: 0x0600 (usb_5 src/bin/usb-5.rs:89)
00:00:00.482910 [INFO ] EP0: GetDescriptor { descriptor: DeviceQualifier, length: 10 } (usb_5 src/bin/usb-5.rs:100)
00:00:00.483276 [WARN ] EP0IN: unexpected request; stalling the endpoint (usb_5 src/bin/usb-5.rs:74)
00:00:00.483764 [DEBUG] USB: UsbEp0Setup @ 00:00:00.483734 (usb_5 src/bin/usb-5.rs:59)
00:00:00.483825 [DEBUG] SETUP: bmrequesttype: 0b10000000, brequest: 6, wlength: 10, windex: 0x0000, wvalue: 0x0600 (usb_5 src/bin/usb-5.rs:89)
00:00:00.483917 [INFO ] EP0: GetDescriptor { descriptor: DeviceQualifier, length: 10 } (usb_5 src/bin/usb-5.rs:100)
00:00:00.484283 [WARN ] EP0IN: unexpected request; stalling the endpoint (usb_5 src/bin/usb-5.rs:74)
00:00:00.484771 [DEBUG] USB: UsbEp0Setup @ 00:00:00.484741 (usb_5 src/bin/usb-5.rs:59)
00:00:00.484832 [DEBUG] SETUP: bmrequesttype: 0b10000000, brequest: 6, wlength: 9, windex: 0x0000, wvalue: 0x0200 (usb_5 src/bin/usb-5.rs:89)
00:00:00.484924 [INFO ] EP0: GetDescriptor { descriptor: Configuration { index: 0 }, length: 9 } (usb_5 src/bin/usb-5.rs:100)
00:00:00.485351 [DEBUG] EP0IN: start 9B transfer (dk dk/src/usbd.rs:59)
00:00:00.485626 [DEBUG] USB: UsbEp0DataDone @ 00:00:00.485626 (usb_5 src/bin/usb-5.rs:59)
00:00:00.485717 [INFO ] EP0IN: transfer complete (usb_5 src/bin/usb-5.rs:68)
00:00:00.485748 [INFO ] EP0IN: transfer done (dk dk/src/usbd.rs:83)
00:00:00.487640 [DEBUG] USB: UsbEp0Setup @ 00:00:00.487609 (usb_5 src/bin/usb-5.rs:59)
00:00:00.487701 [DEBUG] SETUP: bmrequesttype: 0b10000000, brequest: 6, wlength: 18, windex: 0x0000, wvalue: 0x0200 (usb_5src/bin/usb-5.rs:89)
00:00:00.487792 [INFO ] EP0: GetDescriptor { descriptor: Configuration { index: 0 }, length: 18 } (usb_5 src/bin/usb-5.rs:100)
00:00:00.488220 [DEBUG] EP0IN: start 18B transfer (dk dk/src/usbd.rs:59)
00:00:00.488647 [DEBUG] USB: UsbEp0DataDone @ 00:00:00.488616 (usb_5 src/bin/usb-5.rs:59)
00:00:00.488708 [INFO ] EP0IN: transfer complete (usb_5 src/bin/usb-5.rs:68)
00:00:00.488739 [INFO ] EP0IN: transfer done (dk dk/src/usbd.rs:83)
00:00:00.490631 [DEBUG] USB: UsbEp0Setup @ 00:00:00.490631 (usb_5 src/bin/usb-5.rs:59)
00:00:00.490722 [DEBUG] SETUP: bmrequesttype: 0b00000000, brequest: 9, wlength: 0, windex: 0x0000, wvalue: 0x002a (usb_5 src/bin/usb-5.rs:89)
00:00:00.490783 [INFO ] EP0: SetConfiguration { value: Some(42) } (usb_5 src/bin/usb-5.rs:100)
00:00:00.491027 [INFO ] entering the configured state (usb_5 src/bin/usb-5.rs:207)
00:00:02.778991 [DEBUG] USB: UsbEp0Setup @ 00:00:02.778991 (usb_5 src/bin/usb-5.rs:59)
00:00:02.779083 [DEBUG] SETUP: bmrequesttype: 0b10000000, brequest: 6, wlength: 4096, windex: 0x0000, wvalue: 0x0300 (usb_5 src/bin/usb-5.rs:89)
00:00:02.779144 [INFO ] EP0: GetDescriptor { descriptor: String { index: 0, lang_id: 0 }, length: 4096 } (usb_5 src/bin/usb-5.rs:100)
00:00:02.779602 [WARN ] EP0IN: unexpected request; stalling the endpoint (usb_5 src/bin/usb-5.rs:74)
00:00:02.780761 [DEBUG] USB: UsbEp0Setup @ 00:00:02.780731 (usb_5 src/bin/usb-5.rs:59)
00:00:02.780822 [DEBUG] SETUP: bmrequesttype: 0b10000000, brequest: 0, wlength: 2, windex: 0x0000, wvalue: 0x0000 (usb_5 src/bin/usb-5.rs:89)
00:00:02.780883 [INFO ] EP0: GetStatus(Device) (usb_5 src/bin/usb-5.rs:100)
00:00:02.781036 [WARN ] EP0IN: unexpected request; stalling the endpoint (usb_5 src/bin/usb-5.rs:74)
00:00:02.781707 [DEBUG] USB: UsbEp0Setup @ 00:00:02.781677 (usb_5 src/bin/usb-5.rs:59)
00:00:02.781768 [DEBUG] SETUP: bmrequesttype: 0b10000000, brequest: 0, wlength: 2, windex: 0x0000, wvalue: 0x0000 (usb_5 src/bin/usb-5.rs:89)
00:00:02.781829 [INFO ] EP0: GetStatus(Device) (usb_5 src/bin/usb-5.rs:100)
00:00:02.781982 [WARN ] EP0IN: unexpected request; stalling the endpoint (usb_5 src/bin/usb-5.rs:74)
00:00:02.782684 [DEBUG] USB: UsbEp0Setup @ 00:00:02.782684 (usb_5 src/bin/usb-5.rs:59)
00:00:02.782775 [DEBUG] SETUP: bmrequesttype: 0b10000000, brequest: 6, wlength: 2, windex: 0x0000, wvalue: 0x0a00 (usb_5 src/bin/usb-5.rs:89)
00:00:02.782836 [ERROR] panicked at src/bin/usb-5.rs:99:10:
Error parsing request: () (usb_app usb-app-solutions/src/lib.rs:8)
`dk::fail()` called; exiting ...
Firmware exited with: Unknown runtime error
Core 0
    Frame 0: syscall1 @ 0x000020ae inline
       /home/muellerr/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/cortex-m-semihosting-0.5.0/src/lib.rs:201:13
    Frame 1: report_exception @ 0x00000000000020ac inline
       /home/muellerr/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/cortex-m-semihosting-0.5.0/src/macros.rs:28:9
    Frame 2: exit @ 0x00000000000020ac
       /home/muellerr/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/cortex-m-semihosting-0.5.0/src/debug.rs:74:25
    Frame 3: fail @ 0x00001770
       /home/muellerr/Rust/rust-exercises/nrf52-code/boards/dk/src/lib.rs:462:9
    Frame 4: __cortex_m_rt_HardFault @ 0x00000df4
       /home/muellerr/Rust/rust-exercises/nrf52-code/usb-app-solutions/src/lib.rs:14:1

It might be a good idea to improve the usb2 error parsing and then print an error + continue instead of panicking. Right now, the error output is not too useful, although we get the raw request information that caused the error at the very least.

robamu avatar Nov 04 '25 10:11 robamu