nrf-rs / nrf-hal

A Rust HAL for the nRF family of devices
Apache License 2.0
499 stars 139 forks source link

nrf51 uart write blocks in qemu #426

Open JoshMcguigan opened 1 year ago

JoshMcguigan commented 1 year ago

Hello! I am following along the rust discovery uart example by running the microbit v1 (nrf51) in qemu.

$ cargo build --features v1 --target thumbv6m-none-eabi

$ qemu-system-arm -machine microbit -display none -serial stdio -s -kernel target/thumbv6m-none-eabi/debug/uart

At first I thought the qemu emulation might be at fault, but I found this forum post where they seem to see a similar problem on real hardware with code that matches the uart write impl here:

https://github.com/nrf-rs/nrf-hal/blob/939c0175dbbebdb9457a492a9912b755cc56737c/nrf-hal-common/src/uart.rs#L134-L141

This check for txdrdy hangs when trying to send the first byte. The reference manual says the txdrdy event is triggered only when a byte is actually sent. That aligns with the findings in the forum post that show very similar code blocking indefinitely.

Unfortunately I don't have real hardware to test this on at the moment.