Rust Programming2026-03-04 01:00

Pi Pico Embedded Rust Always elf2uf2-r Always Produces Error: "Unrecognized ABI"

rustfan
rustfan
Author

I’ve been trying unsuccessfully to get a simple embedded Rust program to build and run on a Pi Pico. Here is my project: .cargo/config.toml:

[build]
target = "thumbv6m-none-eabi"

[target.thumbv6m-none-eabi]
rustflags = [
    "-C", "link-arg=-Tlink.x",
    "-C", "link-arg=--nmagic",
    # This line is the magic bullet:
    "-C", "link-arg=-z", "-C", "link-arg=keep-section=.boot2",
]

src/main.rs:

”` #![no_std] #![no_main]

// FORCE the bootloader into the binary #[link_section = “.boot2”] #[used] pub static BOOT2: [u8; 256] = rp2040_boot2::BOOT_LOADER_W25Q080;

use panic_halt as _;

// Use the entry macro from the HAL, not cortex_m_rt // This ensures the bootloader is linked correctly use rp_pico::entry; use core::fmt::Write; use embedded_hal::digital::OutputPin;

use rp_pico::hal::{

clocks::{init_clocks_and_plls, Clock},
fugit::RateExtU32,
pac,
sio::Sio,
uart::{DataBits, StopBits, UartConfig, UartPeripheral},
watchdog::Watchdog,

};

const XTAL_FREQ_HZ: u32 = 12_000_000;

#[entry] fn main() -> ! {

let mut pac = pac::Peripherals::take().unwrap();
let core = pac::CorePeripherals::take().unwrap();

let mut watchdog = Watchdog::new(pac.WATCHDOG);
let sio = Sio::new(pac.SIO);

let clocks = init_clocks_and_plls(
    XTAL_FREQ_HZ,
    pac.XOSC,
    pac.CLOCKS,
    pac.PLL_SYS,
    pac.PLL_USB,
    &mut pac.RESETS,
    &mut watchdog,
)
.ok()
.unwrap();

let pins = rp_pico::Pins::new(
    pac.IO_BANK0,
    pac.PADS_BANK0,
    sio.gpio_bank0,
    &mut pac.RESETS,
);

let uart_pins = (
    pins.gpio0.into_function(),
    pins.gpio1.into_function(),
);

let mut uart = UartPeripheral::new(pac.UART0, uart_pins, &mut pac.RESETS)
    .enable(
        UartConfig::new(
            115200.Hz(),
            DataBits::Eight,
            None,
            StopBits::One,
        ),
        clocks.peripheral_clock.f
56

Comments (0)

Login to comment

Login Now

Loading comments...