nrf-rs / nrf-hal

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

ieee802154: `Radio::send` followed by `Radio::recv` panics with v0.14 #368

Closed japaric closed 2 years ago

japaric commented 2 years ago

steps to reproduce

(sorry I did not try to minimize the repro case):

stack backtrace:

stack backtrace:
   0: HardFaultTrampoline
      <exception entry>
   1: lib::inline::__udf
        at ./asm/inline.rs:172:5
   2: __udf
        at ./asm/lib.rs:49:17
   3: cortex_m::asm::udf
        at /home/japaric/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-m-0.7.3/src/asm.rs:43:5
   4: rust_begin_unwind
        at /home/japaric/github/ferrous-systems/embedded-trainings/common/panic-log/src/lib.rs:12:5
   5: core::panicking::panic_fmt
        at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/core/src/panicking.rs:100:14
   6: core::panicking::panic
        at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/core/src/panicking.rs:50:5
   7: nrf_hal_common::ieee802154::Radio::state
        at /home/japaric/.cargo/registry/src/github.com-1ecc6299db9ec823/nrf-hal-common-0.14.0/src/ieee802154.rs:665:18
   8: nrf_hal_common::ieee802154::Radio::put_in_rx_mode
        at /home/japaric/.cargo/registry/src/github.com-1ecc6299db9ec823/nrf-hal-common-0.14.0/src/ieee802154.rs:626:21
   9: nrf_hal_common::ieee802154::Radio::start_recv
        at /home/japaric/.cargo/registry/src/github.com-1ecc6299db9ec823/nrf-hal-common-0.14.0/src/ieee802154.rs:397:9
  10: nrf_hal_common::ieee802154::Radio::recv_timeout
        at /home/japaric/.cargo/registry/src/github.com-1ecc6299db9ec823/nrf-hal-common-0.14.0/src/ieee802154.rs:355:13
  11: radio_recv::__cortex_m_rt_main
        at src/bin/radio-recv.rs:36:15
  12: main
        at src/bin/radio-recv.rs:13:1
  13: Reset
(HOST) ERROR the program panicked

hal v0.13.0 works fine. I'm currently investigating the cause

japaric commented 2 years ago

after PR #356 a send operation leaves the radio in the TXDISABLED state (instead of TXIDLE). recv is lacking the logic to handle starting from that state so it panics. looking into adding code to handle that case