Open exor2008 opened 1 year ago
Hi, I had the same issue, it is caused by the watchdog, if you flash many data, as you have to do with wifi-blinky sample, the watchdog will reboot the pico as it takes too much time. So remove watchdog code from all the samples and all your flashes with probe-run will work fine !
Use Flash instead of WatchdogFlash in the bootloader and remove Watchdog in a.rs
It is a real issue as probe-run does not disable Watchdog.
The watchdog is also not enabled when in USB bootloader mode, so if your application needs the watchdog and is too big to flash before it resets, this is a viable, if annoying, workaround.
I'm wondering: would it be better if we disable the watchdog and instead make it some opt-in compile option? Although it's generally a 'good thing to do', I've seen multiple users hitting this.
Watchdog is only useful when the pico is not plugged to a debug probe. With a debug probe, I can restart anytime I want.
If you know nothing about the watchdog, you think it is a random bug while flashing, as I did. This stucks many beginners.
@Athorus @lulf @CBJamo thanks for your responses.
But I thought I figured it out with watchdog. I made it 8 sec and was feeding him during the flashing. And according to my observations an execution was never stuck for at least a single second. But I still getting those errors.
pub async fn update_firmware<'a>(
firmware: &'static Channel<ThreadModeRawMutex, Vec<u8, 4096>, 1>,
watchdog: WATCHDOG,
flash: FLASH,
) {
//Override bootloader watchdog
let mut watchdog = Watchdog::new(watchdog);
watchdog.start(Duration::from_secs(8));
let flash: Flash<_, FLASH_SIZE> = Flash::new(flash);
let flash = Mutex::new(RefCell::new(flash));
let config = FirmwareUpdaterConfig::from_linkerfile_blocking(&flash);
let mut updater = BlockingFirmwareUpdater::new(config);
watchdog.feed();
let mut offset = 0;
let mut buf: AlignedBuffer<4096> = AlignedBuffer([0; 4096]);
defmt::info!("preparing update");
let state = updater
.get_state(&mut buf.0[..1])
.map_err(|e| defmt::warn!("E: {:?}", defmt::Debug2Format(&e)))
.unwrap();
let writer = updater
.prepare_update(&mut buf.0[..1])
.map_err(|e| defmt::warn!("E: {:?}", defmt::Debug2Format(&e)))
.unwrap();
defmt::info!("writer created, starting write");
let mut chunk = firmware.recv().await;
while !chunk.is_empty() {
buf.0[..chunk.len()].copy_from_slice(&chunk.as_slice());
defmt::info!("writing block at offset {}", offset);
writer.write(offset, &buf.0[..chunk.len()]).unwrap();
offset += chunk.len() as u32;
watchdog.feed();
}
watchdog.feed();
defmt::info!("firmware written ({} bytes), marking update", offset);
updater.mark_updated(&mut buf.0[..1]).unwrap();
Timer::after(Duration::from_secs(2)).await;
defmt::info!("update marked, resetting");
cortex_m::peripheral::SCB::sys_reset();
loop {}
}
What confuses me is that sometimes an error occurs during the erasure of memory, and sometimes during the writing of a new one.
I’m not sure of what I’m saying, but I think during flashing your soft is stopped but not the watchdog, that is was why you don’t know when the reset will happen. As I said, without watchdog in all the code (bootloader + soft), no issue while flashing.
Hi, I'am trying to implement firmware update for my RP Pi Pico W via Wi-Fi and I ran into a problem. So I tried to run the boot example from https://github.com/embassy-rs/embassy/tree/main/examples/boot/bootloader/rp and https://github.com/embassy-rs/embassy/tree/main/examples/boot/application/rp
This example compiling and flashing just fine, but I can't see the result, because https://github.com/embassy-rs/embassy/blob/main/examples/boot/application/rp/src/bin/b.rs is designed for RP Pico, not RP Pico W.
Commands I'am using to flash bootloader example:
So I built https://github.com/embassy-rs/embassy/blob/main/examples/rp/src/bin/wifi_blinky.rs to binary and used it as b.bin for bootloading example. I used the same memory layout as in examples:
After
cargo flash --release --bin a --chip RP2040
I start to getting errors:or