Add delay to flash test to allow time to parse RTT header

This commit is contained in:
Mathias 2022-10-27 12:41:06 +02:00
parent a7b90c7fb6
commit bc21b6efaf

View File

@ -5,6 +5,7 @@
use defmt::*;
use embassy_executor::Spawner;
use embassy_rp::flash::{ERASE_SIZE, FLASH_BASE};
use embassy_time::{Duration, Timer};
use {defmt_rtt as _, panic_probe as _};
const ADDR_OFFSET: u32 = 0x4000;
@ -14,6 +15,12 @@ async fn main(_spawner: Spawner) {
let p = embassy_rp::init(Default::default());
info!("Hello World!");
// add some delay to give an attached debug probe time to parse the
// defmt RTT header. Reading that header might touch flash memory, which
// interferes with flash write operations.
// https://github.com/knurling-rs/defmt/pull/683
Timer::after(Duration::from_millis(10)).await;
let mut flash = embassy_rp::flash::Flash::<_, { 2 * 1024 * 1024 }>::new(p.FLASH);
let mut buf = [0u8; ERASE_SIZE];