Hi,
I am fairly new to Rust and I am currently working on an assignment for my internship. I am trying to write data (text) into the memory of a NUCLEO-STM32F746 and read it afterwards. I got this far but I have no idea if I am on the right track and where I am going wrong:
#![no_std]
#![no_main]
use core::panic::PanicInfo;
use stm32f7xx_hal::{self, flash};
fn main() {
// Get access to the device peripherals
let dp = stm32f7xx_hal::pac::Peripherals::take().unwrap();
// Configure the Flash peripheral
let mut flash = stm32f7xx_hal::flash::Flash::new(dp.FLASH);
// Define the address and data to write
let address: usize = 0x0800_0000; // Start of main memory
let data = [0xAB, 0xCD, 0xEF];
let sector_number = 1;
// Unlock the flash for writing
flash.unlock();
// Erase the flash sector containing the address
flash.erase_sector(sector_number);
// Write the data to flash
flash.program(usize::from(address), &data).unwrap();
// Lock the flash
flash.lock();
// Perform a software reset
cortex_m::peripheral::SCB::sys_reset();
}
#[panic_handler]
fn panic(_panic: &PanicInfo<'_>) -> ! {
loop {}
}
Thanks in advance!!