From 055a66281baf1191adc39801a1e4a4cd83ab7d38 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 6 Oct 2025 19:25:44 +0200 Subject: [PATCH] first successful run of flasher program --- Cargo.toml | 3 ++- zedboard-qspi-flasher/Cargo.toml | 1 + zedboard-qspi-flasher/src/main.rs | 18 +++++++++++------- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 5c9db71..ee2aab8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,7 +11,8 @@ members = [ "zynq-mmu", "zedboard-fsbl", "zedboard-bsp", - "zynq-boot-image", "zedboard-qspi-flasher", + "zynq-boot-image", + "zedboard-qspi-flasher", ] exclude = [ diff --git a/zedboard-qspi-flasher/Cargo.toml b/zedboard-qspi-flasher/Cargo.toml index aa9a498..d15b5f6 100644 --- a/zedboard-qspi-flasher/Cargo.toml +++ b/zedboard-qspi-flasher/Cargo.toml @@ -13,3 +13,4 @@ zedboard-bsp = { path = "../zedboard-bsp" } embedded-io = "0.7" embedded-hal = "1" log = "0.4" +libm = "0.2" diff --git a/zedboard-qspi-flasher/src/main.rs b/zedboard-qspi-flasher/src/main.rs index f063de4..6723b31 100644 --- a/zedboard-qspi-flasher/src/main.rs +++ b/zedboard-qspi-flasher/src/main.rs @@ -77,7 +77,7 @@ pub fn main() -> ! { unsafe { zynq7000_hal::log::uart_blocking::init_unsafe_single_core( uart, - log::LevelFilter::Trace, + log::LevelFilter::Info, false, ) }; @@ -85,7 +85,6 @@ pub fn main() -> ! { let boot_mode = BootMode::new_from_regs(); info!("Boot mode: {:?}", boot_mode); - /* let qspi_clock_config = qspi::ClockConfig::calculate_with_loopback(qspi::SrcSelIo::IoPll, &clocks, 100.MHz()) .expect("QSPI clock calculation failed"); @@ -132,9 +131,10 @@ pub fn main() -> ! { let mut current_addr = 0; let mut read_buf = [0u8; 256]; + let mut next_checkpoint = 0.05; while current_addr < boot_bin_size { if current_addr % 0x10000 == 0 { - info!("Erasing sector at address {:#x}", current_addr); + log::debug!("Erasing sector at address {:#x}", current_addr); match spansion_qspi.erase_sector(current_addr as u32) { Ok(()) => {} Err(e) => { @@ -148,13 +148,14 @@ pub fn main() -> ! { } let write_size = core::cmp::min(256, boot_bin_size - current_addr); let write_slice = &boot_bin_slice[current_addr..current_addr + write_size]; - info!("Programming address {:#x}", current_addr); + log::debug!("Programming address {:#x}", current_addr); match spansion_qspi.program_page(current_addr as u32, write_slice) { Ok(()) => {} Err(e) => { - error!( + log::error!( "failed to write data to QSPI at address {:#x}: {:?}", - current_addr, e + current_addr, + e ); panic!("QSPI write failed"); } @@ -176,9 +177,12 @@ pub fn main() -> ! { } } current_addr += write_size; + if current_addr as f32 / boot_bin_size as f32 >= next_checkpoint { + log::info!("Write progress {} %", libm::roundf(next_checkpoint * 100.0)); + next_checkpoint += 0.05; + } } info!("flashing done"); - */ let mut mio_led = gpio::Output::new_for_mio(gpio_pins.mio.mio7, gpio::PinState::Low); loop {