bootloader works
All checks were successful
Rust/va108xx-rs/pipeline/pr-main This commit looks good

This commit is contained in:
2024-09-30 10:58:32 +02:00
parent 2b6c013241
commit 7603185156
14 changed files with 54 additions and 50 deletions

View File

@ -100,10 +100,6 @@ fn main() -> ! {
let mut dp = pac::Peripherals::take().unwrap();
let cp = cortex_m::Peripherals::take().unwrap();
let vect_tbl = unsafe {
core::slice::from_raw_parts(APP_A_START_ADDR as *const u8, VECTOR_TABLE_LEN as usize)
};
rprintln!("vector table app A: 0x{:x?}", &vect_tbl[0..32]);
let mut nvm = M95M01::new(&mut dp.sysconfig, CLOCK_FREQ, dp.spic);
if FLASH_SELF {
@ -272,20 +268,18 @@ fn boot_app(syscfg: &pac::Sysconfig, cp: &cortex_m::Peripherals, app_sel: AppSel
unsafe {
// First 4 bytes done with inline assembly, writing to the physical address 0x0 can not
// be done without it. See https://users.rust-lang.org/t/reading-from-physical-address-0x0/117408/2.
//let first_four_bytes = core::ptr::read(base_addr as *const u32);
let first_four_bytes = core::ptr::read(base_addr as *const u32);
core::arch::asm!(
"ldr r0, [{0}]", // Load 4 bytes from src into r0 register
"str r0, [{1}]", // Store r0 register into first_four_bytes
//"str {0}, [{1}]",
in(reg) base_addr as *const u32, // Input: App vector table.
"str {0}, [{1}]",
in(reg) first_four_bytes, // Input: App vector table.
in(reg) BOOTLOADER_START_ADDR as *mut u32, // Input: destination pointer
);
core::slice::from_raw_parts_mut(
(BOOTLOADER_START_ADDR + 4) as *mut u32,
(BOOTLOADER_START_ADDR + 4) as *mut u8,
(VECTOR_TABLE_LEN - 4) as usize,
)
.copy_from_slice(core::slice::from_raw_parts(
(base_addr + 4) as *const u32,
(base_addr + 4) as *const u8,
(VECTOR_TABLE_LEN - 4) as usize,
));
}
@ -308,6 +302,10 @@ fn soft_reset(cp: &cortex_m::Peripherals) -> ! {
}
// Ensure completion of memory access.
cortex_m::asm::dsb();
rprintln!("soft reset done");
unreachable!();
// Loop until the reset occurs.
loop {
cortex_m::asm::nop();
}
}