tweedegolf / dis-bootloader

A rust bootloader for our internal project using the nRF9160 chip.
Other
4 stars 4 forks source link

application using embassy_time not working #13

Closed macthestack closed 2 years ago

macthestack commented 2 years ago

An application using embassy_time and "time-driver-rtc1" from embassy-nrf crashes.

(HOST) INFO  flashing program (8.71 KiB)
(HOST) INFO  success!
────────────────────────────────────────────────────────────────────────────────
────────────────────────────────────────────────────────────────────────────────
stack backtrace:
   0: HardFaultTrampoline
      <exception entry>
   1: _ZN4core3ptr13read_volatile17hd3f8821b78d6920fE
        at /rustc/8b705839cd656d202e920efa8769cbe43a5ee269/library/core/src/ptr/mod.rs:1474:9
   2: _ZN5vcell21VolatileCell$LT$T$GT$3get17h846ed7bb76a64525E
        at /Users/martin/.cargo/registry/src/github.com-1ecc6299db9ec823/vcell-0.1.3/src/lib.rs:33:18
   3: _ZN11nrf9160_pac7generic14Reg$LT$REG$GT$4read17h781ecf172b477ff2E
        at /Users/martin/.cargo/registry/src/github.com-1ecc6299db9ec823/nrf9160-pac-0.11.0/src/generic.rs:65:19
   4: _ZN84_$LT$embassy_nrf..time_driver..RtcDriver$u20$as$u20$embassy_time..driver..Driver$GT$3now17h4e33ced8e698ee26E
        at /Users/martin/.cargo/git/checkouts/embassy-9312dcb0ed774b29/d49d1b6/embassy-nrf/src/time_driver.rs:218:23
   5: _embassy_time_now
        at /Users/martin/.cargo/git/checkouts/embassy-9312dcb0ed774b29/d49d1b6/embassy-time/src/driver.rs:156:13
   6: _ZN12embassy_time6driver3now17hf91ab4d33d5c6c11E
        at /Users/martin/.cargo/git/checkouts/embassy-9312dcb0ed774b29/d49d1b6/embassy-time/src/driver.rs:126:14
   7: _ZN12embassy_time7instant7Instant3now17h0483671508ea8743E
        at /Users/martin/.cargo/git/checkouts/embassy-9312dcb0ed774b29/d49d1b6/embassy-time/src/instant.rs:21:26
   8: _ZN16embassy_executor3raw8Executor4poll17h42b4164cf3414afbE
        at /Users/martin/.cargo/git/checkouts/embassy-9312dcb0ed774b29/d49d1b6/embassy-executor/src/raw/mod.rs:358:42
   9: _ZN16embassy_executor4arch8Executor3run17hb54781054eaf4739E
        at /Users/martin/.cargo/git/checkouts/embassy-9312dcb0ed774b29/d49d1b6/embassy-executor/src/arch/cortex_m.rs:54:17
  10: _ZN7bateman18__cortex_m_rt_main17hf74310984f680484E
        at src/main.rs:12:1
  11: main
        at src/main.rs:12:1
  12: Reset
(HOST) ERROR the program panicked

If I run it without any time features it works.

diondokter commented 2 years ago

That's strange because embassy-time is not used by the bootloader

diondokter commented 2 years ago

I just checked the embassy time driver. It seems it properly selects the S or NS peripherals for the time driver. You've got to make sure to use the nrf9160-ns feature if you use the SPM and the nrf9160-s feature if you don't use the SPM.

macthestack commented 2 years ago

Thank you for clarifying something for me. I had misunderstood the role of the spm and thought that the bootloader would load in NS too.

diondokter commented 2 years ago

We're planning to let it do that in the future though! I've been working on Trustzone tools and once that is done and working I want to apply it to this bootloader

macthestack commented 2 years ago

That would be a great addition!