Hi Team,
I am trying to run a LED blink program on the STM32F410RBT6 board. The compilation is successful, but the program is not flashing. The next issue is that the ELF file is not showing up properly, and there seems to be a linking issue. I need some guidance on this. I have attached the program and documentation for reference.
main.rs file
#![no_std]
#![no_main]
use cortex_m_rt::entry;
use stm32f4::stm32f410;
use stm32f4xx_hal::{prelude::*, delay::Delay};
use cortex_m::peripheral::Peripherals; // Correct import for Peripherals
// Panic handler: loops forever on panic
#[panic_handler]
fn panic(_info: &core::panic::PanicInfo) -> ! {
loop {
// Stay here in case of panic
}
}
#[entry]
fn main() -> ! {
// Take ownership of the STM32F4 peripherals
let dp = stm32f410::Peripherals::take().unwrap();
// Take ownership of the core peripherals (SYST, NVIC, etc.)
let cp = Peripherals::take().unwrap();
// Configure and freeze system clocks
let clocks = dp.RCC.constrain().cfgr.freeze();
// Initialize delay provider using the system timer (SYST)
let mut delay = Delay::new(cp.SYST, &clocks);
// Set up GPIO pin for LED (assuming LED is connected to a pin)
let gpioa = dp.GPIOA.split();
let mut led = gpioa.pa5.into_push_pull_output(); // Assuming LED is on pin PA5
loop {
// Toggle LED every second
led.toggle();
delay.delay_ms(1_000_u16); // 1-second delay
}
}
Cargo.toml file
[package]
name = "stm32_led_blink"
version = "0.1.0"
edition = "2021"
[dependencies]
cortex-m-rtic = "1.1"
cortex-m-rt = "0.7"
cortex-m = "0.7"
panic-halt = "0.2"
stm32f4xx-hal = { version = "0.11", features = ["stm32f410"] }
stm32f4 = { version = "0.14.0", features = ["stm32f410"] }
memory.x file
MEMORY
{
FLASH : ORIGIN = 0x08000000, LENGTH = 128K
RAM : ORIGIN = 0x20000000, LENGTH = 32K
}
SECTIONS
{
.text : { (.text) } > FLASH
.bss : { (.bss) } > RAM
.data : { (.data) } > RAM
}
config.toml file
[target.thumbv7em-none-eabihf]
runner = "probe-rs run --chip STM32F410RBT6 --gdb-port 3333"