Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nrf5340dk: first flash issue #198

Open
emmanuelsearch opened this issue Mar 19, 2024 · 1 comment
Open

nrf5340dk: first flash issue #198

emmanuelsearch opened this issue Mar 19, 2024 · 1 comment
Labels
board Board support

Comments

@emmanuelsearch
Copy link
Contributor

emmanuelsearch commented Mar 19, 2024

Upon first flash of a brand new board, you get this error, related to #127 :

Running probe-rs run --chip nrf5340_xxAA ../../build/bin/nrf5340dk/hello-world/cargo/thumbv8m.main-none-eabi/release/hello-world

 WARN probe_rs::config::sequences::nrf: Core 0 is locked. Erase procedure will be started to unlock it.
Error: Connecting to the chip was unsuccessful.

Caused by:
    0: An ARM specific error occurred.
    1: An operation could not be performed because it lacked the permission to do so: erase_all

Running with the target flash-erase-all as specified in #128 fixes it but you still get a bunch of warnings (see below). What's to do about this?

warning: use of inline assembly is unsafe and requires unsafe block (error E0133)
  --> src/riot-rs-threads/src/arch/cortex_m.rs:82:5
   |
82 | /     asm!(
83 | |         "
84 | |             movw LR, #0xFFFd
85 | |             movt LR, #0xFFFF
...  |
88 | |         options(noreturn)
89 | |     );
   | |_____^ use of inline assembly
   |
   = note: for more information, see issue #71668 <https://github.com/rust-lang/rust/issues/71668>
   = note: inline assembly is entirely unchecked and can cause undefined behavior
note: an unsafe function restricts its caller, but its body is safe by default
  --> src/riot-rs-threads/src/arch/cortex_m.rs:81:1
   |
81 | unsafe extern "C" fn SVCall() {
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   = note: requested on the command line with `-W unsafe-op-in-unsafe-fn`

warning: use of inline assembly is unsafe and requires unsafe block (error E0133)
   --> src/riot-rs-threads/src/arch/cortex_m.rs:122:5
    |
122 | /     asm!(
123 | |         "
124 | |             mrs r0, psp
125 | |             cpsid i
...   |
145 | |         options(noreturn)
146 | |     );
    | |_____^ use of inline assembly
    |
    = note: for more information, see issue #71668 <https://github.com/rust-lang/rust/issues/71668>
    = note: inline assembly is entirely unchecked and can cause undefined behavior
note: an unsafe function restricts its caller, but its body is safe by default
   --> src/riot-rs-threads/src/arch/cortex_m.rs:121:1
    |
121 | unsafe extern "C" fn PendSV() {
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

warning: call to unsafe function `critical_section::CriticalSection::<'cs>::new` is unsafe and requires unsafe block (error E0133)
   --> src/riot-rs-threads/src/arch/cortex_m.rs:220:14
    |
220 |     let cs = CriticalSection::new();
    |              ^^^^^^^^^^^^^^^^^^^^^^ call to unsafe function
    |
    = note: for more information, see issue #71668 <https://github.com/rust-lang/rust/issues/71668>
    = note: consult the function's documentation for information on how to avoid undefined behavior
note: an unsafe function restricts its caller, but its body is safe by default
   --> src/riot-rs-threads/src/arch/cortex_m.rs:219:1
    |
219 | unsafe fn sched(old_sp: usize) -> usize {
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

warning: dereference of raw pointer is unsafe and requires unsafe block (error E0133)
   --> src/riot-rs-threads/src/arch/cortex_m.rs:225:34
    |
225 |             if let Some(pid) = (&*THREADS.as_ptr(cs)).runqueue.get_next() {
    |                                  ^^^^^^^^^^^^^^^^^^^ dereference of raw pointer
    |
    = note: for more information, see issue #71668 <https://github.com/rust-lang/rust/issues/71668>
    = note: raw pointers may be null, dangling or unaligned; they can violate aliasing rules and cause data races: all of these are undefined behavior

warning: call to unsafe function `cortex_m::interrupt::enable` is unsafe and requires unsafe block (error E0133)
   --> src/riot-rs-threads/src/arch/cortex_m.rs:232:9
    |
232 |         cortex_m::interrupt::enable();
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ call to unsafe function
    |
    = note: for more information, see issue #71668 <https://github.com/rust-lang/rust/issues/71668>
    = note: consult the function's documentation for information on how to avoid undefined behavior

warning: dereference of raw pointer is unsafe and requires unsafe block (error E0133)
   --> src/riot-rs-threads/src/arch/cortex_m.rs:238:24
    |
238 |     let threads = &mut *THREADS.as_ptr(cs);
    |                        ^^^^^^^^^^^^^^^^^^^ dereference of raw pointer
    |
    = note: for more information, see issue #71668 <https://github.com/rust-lang/rust/issues/71668>
    = note: raw pointers may be null, dangling or unaligned; they can violate aliasing rules and cause data races: all of these are undefined behavior

warning: use of inline assembly is unsafe and requires unsafe block (error E0133)
   --> src/riot-rs-threads/src/arch/cortex_m.rs:265:5
    |
265 |     asm!("", in("r1") current_high_regs, in("r2") next_high_regs);
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ use of inline assembly
    |
    = note: for more information, see issue #71668 <https://github.com/rust-lang/rust/issues/71668>
    = note: inline assembly is entirely unchecked and can cause undefined behavior

warning: call to unsafe function `critical_section::CriticalSection::<'cs>::new` is unsafe and requires unsafe block (error E0133)
   --> src/riot-rs-threads/src/lib.rs:178:14
    |
178 |     let cs = CriticalSection::new();
    |              ^^^^^^^^^^^^^^^^^^^^^^ call to unsafe function
    |
    = note: for more information, see issue #71668 <https://github.com/rust-lang/rust/issues/71668>
    = note: consult the function's documentation for information on how to avoid undefined behavior
note: an unsafe function restricts its caller, but its body is safe by default
   --> src/riot-rs-threads/src/lib.rs:176:1
    |
176 | pub unsafe fn start_threading() {
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

warning: `riot-rs-threads` (lib) generated 8 warnings (run `cargo fix --lib -p riot-rs-threads` to apply 4 suggestions)
    Finished `release` profile [optimized + debuginfo] target(s) in 0.50s
     Running `probe-rs run --chip nrf5340_xxAA ../../build/bin/nrf5340dk/hello-world/cargo/thumbv8m.main-none-eabi/release/hello-world`
 WARN probe_rs::architecture::arm::core::armv8m: The core is in locked up status as a result of an unrecoverable exception
 WARN probe_rs::architecture::arm::core::armv8m: The core is in locked up status as a result of an unrecoverable exception
      Erasing ✔ [00:00:00] [############################################################################################################################################] 8.00 KiB/8.00 KiB @ 29.56 KiB/s (eta 0s )
  Programming ✔ [00:00:00] [############################################################################################################################################] 8.00 KiB/8.00 KiB @ 24.12 KiB/s (eta 0s )    Finished in 0.681s
riot_rs_rt::startup()
nrf5340dk::init()
nrf5340::init()
riot-rs-embassy::init()
riot-rs-embassy::init_task()
riot-rs-embassy::init_task() done
Hello from main()! Running on a nrf5340dk board.
 WARN probe_rs::session: Could not clear all hardware breakpoints: An ARM specific error occurred.

Caused by:
    Timeout occurred during operation.
@emmanuelsearch emmanuelsearch added the board Board support label Mar 19, 2024
@emmanuelsearch emmanuelsearch changed the title nrf53840dk: first flash issue nrf5340dk: first flash issue Mar 19, 2024
@kaspar030
Copy link
Collaborator

So the Rust warnings are our zealous linter settings. Yeah we need to something about them.

WARN probe_rs::session: Could not clear all hardware breakpoints: An ARM specific error occurred.

Caused by: Timeout occurred during operation.

This I've seen, too. I don't know what it is. I didn't give it much thought b/c apart from the warning, everything works fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
board Board support
Projects
None yet
Development

No branches or pull requests

2 participants