Skip to content

Forever waiting for AHB clock in nightly #33

Closed
@hacknus

Description

@hacknus

Original issue, was redirected here.

I tried both USB-examples on my STM32F405; poll and interrupt and both work with rust stable (rustc 1.66.0 ) but hang with nightly (rustc 1.68.0-nightly).
By using the debugger, I notice that I get stuck in this line:

// Wait for AHB ready
while read_reg!(otg_global, regs.global(), GRSTCTL, AHBIDL) == 0 {}

line 365 in .cargo/registry/src/6github.com-1ecc6299db9ec823/synopsys-usb-otg-0.3.1/src/bus.rs

full output of the debugger:

synopsys_usb_otg::bus::{impl#2}::enable::{closure#0}<stm32f4xx_hal::otg_fs::USB> (cs=<optimized out>)
    at /Users/linus/.cargo/registry/src/6github.com-1ecc6299db9ec823/synopsys-usb-otg-0.3.1/src/bus.rs:365
365	            while read_reg!(otg_global, regs.global(), GRSTCTL, AHBIDL) == 0 {}
(gdb) 
halted: PC: 0x08002ace
halted: PC: 0x08002ac6
synopsys_usb_otg::ral::register::RWRegister<u32>::read<u32> (self=<optimized out>)
    at /Users/linus/.cargo/registry/src/6github.com-1ecc6299db9ec823/synopsys-usb-otg-0.3.1/src/ral/register.rs:23
23	        unsafe { ::core::ptr::read_volatile(self.register.get()) }
(gdb) step
0x08002ac6 in core::ptr::read_volatile<u32> (src=<optimized out>) at /rustc/659e169d37990b9c730a59a96081f2ef7afbe8f1/library/core/src/ptr/mod.rs:1521
1521	/rustc/659e169d37990b9c730a59a96081f2ef7afbe8f1/library/core/src/ptr/mod.rs: No such file or directory.
(gdb) step
halted: PC: 0x08002aca
synopsys_usb_otg::bus::{impl#2}::enable::{closure#0}<stm32f4xx_hal::otg_fs::USB> (cs=<optimized out>)
    at /Users/linus/.cargo/registry/src/6github.com-1ecc6299db9ec823/synopsys-usb-otg-0.3.1/src/bus.rs:365
365	            while read_reg!(otg_global, regs.global(), GRSTCTL, AHBIDL) == 0 {}
(gdb) 
halted: PC: 0x08002ace
halted: PC: 0x08002ac6

it seems in --release some stuff is optimized out, but it gets stuck at the same point in debug:

linuss-MacBook-Pro:stm32-usb-rust linus$ arm-none-eabi-gdb -q -ex "target remote :3333" target/thumbv7em-none-eabihf/debug/stm32-usb-rust
Reading symbols from target/thumbv7em-none-eabihf/debug/stm32-usb-rust...
Remote debugging using :3333
core::ptr::read_volatile<u32> (src=0x500000d8) at /rustc/659e169d37990b9c730a59a96081f2ef7afbe8f1/library/core/src/ptr/mod.rs:1523
1523	/rustc/659e169d37990b9c730a59a96081f2ef7afbe8f1/library/core/src/ptr/mod.rs: No such file or directory.
(gdb) step
halted: PC: 0x08013160
halted: PC: 0x08003590
halted: PC: 0x08003592
synopsys_usb_otg::bus::{impl#2}::enable::{closure#0}<stm32f4xx_hal::otg_fs::USB> (cs=0x2000971c)
    at /Users/linus/.cargo/registry/src/6github.com-1ecc6299db9ec823/synopsys-usb-otg-0.3.1/src/bus.rs:365
365	            while read_reg!(otg_global, regs.global(), GRSTCTL, AHBIDL) == 0 {}
(gdb) 
halted: PC: 0x08003594
halted: PC: 0x08003596
halted: PC: 0x0800359a
halted: PC: 0x08003580
halted: PC: 0x08003582
halted: PC: 0x08003584
365	            while read_reg!(otg_global, regs.global(), GRSTCTL, AHBIDL) == 0 {}
(gdb) 
synopsys_usb_otg::target::UsbRegisters::global (self=0x20009c38)
    at /Users/linus/.cargo/registry/src/6github.com-1ecc6299db9ec823/synopsys-usb-otg-0.3.1/src/target.rs:51
51	        unsafe { &*(self.0 as *const _) }
(gdb) 
halted: PC: 0x08003586
synopsys_usb_otg::bus::{impl#2}::enable::{closure#0}<stm32f4xx_hal::otg_fs::USB> (cs=0x2000971c)
    at /Users/linus/.cargo/registry/src/6github.com-1ecc6299db9ec823/synopsys-usb-otg-0.3.1/src/bus.rs:365
365	            while read_reg!(otg_global, regs.global(), GRSTCTL, AHBIDL) == 0 {}
(gdb) 
halted: PC: 0x08003588
halted: PC: 0x0800358a
halted: PC: 0x0800358c
synopsys_usb_otg::ral::register::RWRegister<u32>::read<u32> (self=0x500000d8)
    at /Users/linus/.cargo/registry/src/6github.com-1ecc6299db9ec823/synopsys-usb-otg-0.3.1/src/ral/register.rs:23
23	        unsafe { ::core::ptr::read_volatile(self.register.get()) }
(gdb) 
halted: PC: 0x08013154
Note: automatically using hardware breakpoints for read-only addresses.
core::ptr::read_volatile<u32> (src=0x500000d8) at /rustc/659e169d37990b9c730a59a96081f2ef7afbe8f1/library/core/src/ptr/mod.rs:1521
1521	/rustc/659e169d37990b9c730a59a96081f2ef7afbe8f1/library/core/src/ptr/mod.rs: No such file or directory.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions