Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable watchdog timer before build. #363

Merged
merged 4 commits into from
Mar 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ target/
.vscode/
.DS_Store
*.swp
.idea/
1 change: 1 addition & 0 deletions cargo-espflash/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ fn flash(args: FlashArgs, config: &Config) -> Result<()> {
let chip = flasher.chip();
let target = chip.into_target();
let target_xtal_freq = target.crystal_freq(flasher.connection())?;
flasher.disable_watchdog()?;

let build_ctx =
build(&args.build_args, &cargo_config, chip).wrap_err("Failed to build project")?;
Expand Down
6 changes: 6 additions & 0 deletions espflash/src/flasher/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,12 @@ impl Flasher {
Ok(flasher)
}

pub fn disable_watchdog(&mut self) -> Result<(), Error> {
let mut target = self.chip.flash_target(self.spi_params, self.use_stub);
target.begin(&mut self.connection).flashing()?;
Ok(())
}

/// Load flash stub
fn load_stub(&mut self) -> Result<(), Error> {
debug!("Loading flash stub for chip: {:?}", self.chip);
Expand Down
4 changes: 3 additions & 1 deletion espflash/src/targets/flash_target/esp32.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ impl FlashTarget for Esp32Target {

// The stub usually disables these watchdog timers, however if we're not using the stub
// we need to disable them before flashing begins
if !self.use_stub && connection.get_usb_pid()? == USB_SERIAL_JTAG_PID {
// TODO: the stub doesn't appear to disable the watchdog on ESP32-S3, so we explicitly
// disable the watchdog here.
if connection.get_usb_pid()? == USB_SERIAL_JTAG_PID {
match self.chip {
Chip::Esp32c3 => {
connection.command(Command::WriteReg {
Expand Down