"No loadable segments found in the ELF file" while using Discovery Book

⚓ Rust    📅 2026-02-07    👤 surdeus    👁️ 1      

surdeus

I'm learning the basics of embedded Rust using the Discovery Book, and I'm making a program to flash onto my micro:bit V2. However, when I run cargo embed, the following error is printed:

Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.04s
     Running `probe-rs run --chip nRF52833_xxAA target/thumbv7em-none-eabihf/debug/carousel`
 WARN probe_rs::flashing::loader: No loadable segments were found in the ELF file.
Error: No loadable segments were found in the ELF file.

After much checking against the working programs in discovery-mb2/mdbook/src/*, I eventually copied one of them into my working directory. It still printed the same error, though, so there's clearly an asset in the parent directory(ies) that is essential to the flashing process. I copied my project into discovery-mb2/mdbook/src/* and it worked just fine.

Here are the config files:
Cargo.toml:

[package]
name = "carousel"
version = "0.1.0"
edition = "2024"

[dependencies]
cortex-m-rt = "0.7.5"
embedded-hal = "1.0.0"
microbit-v2 = "0.16.0"
nrf52833-hal = "0.19.0"
panic-halt = "1.0.0"

[dependencies.cortex-m]
version = "0.7.7"
features = ["inline-asm"]

Embed.toml:

[default.general]
chip = "nrf52833_xxAA"

[default.reset]
halt_afterwards = true

[default.rtt]
enabled = false

[default.gdb]
enabled = true

.cargo/config.toml:

[build]
target = "thumbv7em-none-eabihf"

[target.thumbv7em-none-eabihf]
runner = "probe-rs run --chip nRF52833_xxAA"
rustflags = [
  "-C", "linker=rust-lld",
]

memory.x:

/* Linker script for the nRF52833 */
MEMORY
{
  /* NOTE K = KiBi = 1024 bytes */
  FLASH : ORIGIN = 0x00000000, LENGTH = 512K
  RAM : ORIGIN = 0x20000000, LENGTH = 128K
}

Thanks!

1 post - 1 participant

Read full topic

🏷️ Rust_feed