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

Remove support for the ESP8266 #576

Merged
merged 3 commits into from
Feb 5, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Windows: Update RST/DTR order to avoid issues.

### Changed

- Created `FlashData`, `FlashDataBuilder` and `FlashSettings` structs to reduce number of input arguments in some functions (#512, #566)
- `espflash` will now exit with an error if `defmt` is selected but not usable (#524)
- Unify configuration methods (#551)

### Removed

- Remove support for the ESP8266 (#576)

## [2.1.0] - 2023-10-03

### Added
Expand Down
13 changes: 7 additions & 6 deletions cargo-espflash/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,8 @@ pub struct ErasePartsArgs {
/// Input partition table
#[arg(long, value_name = "FILE")]
pub partition_table: Option<PathBuf>,
/// Specify a (binary) package within a workspace which may provide a partition table
/// Specify a (binary) package within a workspace which may provide a
/// partition table
#[arg(long)]
pub package: Option<String>,
}
Expand Down Expand Up @@ -244,18 +245,18 @@ pub fn erase_parts(args: ErasePartsArgs, config: &Config) -> Result<()> {
.as_deref()
.or(config.partition_table.as_deref());

let mut flash = connect(&args.connect_args, config, false, false)?;
let mut flasher = connect(&args.connect_args, config, false, false)?;
let partition_table = match partition_table {
Some(path) => Some(parse_partition_table(path)?),
None => None,
};

info!("Erasing the following partitions: {:?}", args.erase_parts);
let chip: Chip = flash.chip();
erase_partitions(&mut flash, partition_table, Some(args.erase_parts), None)?;
flash

erase_partitions(&mut flasher, partition_table, Some(args.erase_parts), None)?;
flasher
.connection()
.reset_after(!args.connect_args.no_stub, chip)?;
.reset_after(!args.connect_args.no_stub)?;

Ok(())
}
Expand Down
5 changes: 0 additions & 5 deletions espflash/resources/stubs/stub_flasher_8266.toml

This file was deleted.

10 changes: 5 additions & 5 deletions espflash/src/bin/espflash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,18 +191,18 @@ pub fn erase_parts(args: ErasePartsArgs, config: &Config) -> Result<()> {
return Err(Error::StubRequired.into());
}

let mut flash = connect(&args.connect_args, config, false, false)?;
let mut flasher = connect(&args.connect_args, config, false, false)?;
let partition_table = match args.partition_table {
Some(path) => Some(parse_partition_table(&path)?),
None => None,
};

info!("Erasing the following partitions: {:?}", args.erase_parts);
let chip = flash.chip();
erase_partitions(&mut flash, partition_table, Some(args.erase_parts), None)?;
flash

erase_partitions(&mut flasher, partition_table, Some(args.erase_parts), None)?;
flasher
.connection()
.reset_after(!args.connect_args.no_stub, chip)?;
.reset_after(!args.connect_args.no_stub)?;

Ok(())
}
Expand Down
19 changes: 8 additions & 11 deletions espflash/src/cli/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@
//! [cargo-espflash]: https://crates.io/crates/cargo-espflash
//! [espflash]: https://crates.io/crates/espflash

use std::num::ParseIntError;
use std::{collections::HashMap, fs, io::Write, path::PathBuf};
use std::{collections::HashMap, fs, io::Write, num::ParseIntError, path::PathBuf};

use clap::Args;
use clap_complete::Shell;
Expand Down Expand Up @@ -590,11 +589,9 @@ pub fn erase_flash(args: EraseFlashArgs, config: &Config) -> Result<()> {
let mut flash = connect(&args.connect_args, config, true, true)?;

info!("Erasing Flash...");

flash.erase_flash()?;
let chip = flash.chip();
flash
.connection()
.reset_after(!args.connect_args.no_stub, chip)?;
flash.connection().reset_after(!args.connect_args.no_stub)?;

Ok(())
}
Expand All @@ -604,17 +601,17 @@ pub fn erase_region(args: EraseRegionArgs, config: &Config) -> Result<()> {
return Err(Error::StubRequired).into_diagnostic();
}

let mut flash = connect(&args.connect_args, config, true, true)?;
let mut flasher = connect(&args.connect_args, config, true, true)?;

info!(
"Erasing region at 0x{:08x} ({} bytes)",
args.addr, args.size
);
flash.erase_region(args.addr, args.size)?;
let chip = flash.chip();
flash

flasher.erase_region(args.addr, args.size)?;
flasher
.connection()
.reset_after(!args.connect_args.no_stub, chip)?;
.reset_after(!args.connect_args.no_stub)?;

Ok(())
}
Expand Down
4 changes: 2 additions & 2 deletions espflash/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const SYNC_FRAME: [u8; 36] = [
#[repr(u8)]
pub enum CommandType {
Unknown = 0,
// Commands supported by the ESP8266 & ESP32s bootloaders
// Commands supported by the ESP32's bootloaders
FlashBegin = 0x02,
FlashData = 0x03,
FlashEnd = 0x04,
Expand Down Expand Up @@ -461,7 +461,7 @@ fn begin_command<W: Write>(

let bytes = bytes_of(&params);
let data = if !supports_encryption {
// The ESP32 and ESP8266 do not take the `encrypted` field, so truncate the last
// The ESP32 does not take the `encrypted` field, so truncate the last
// 4 bytes of the slice where it resides.
let end = bytes.len() - 4;
&bytes[0..end]
Expand Down
10 changes: 2 additions & 8 deletions espflash/src/connection/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ use crate::{
connection::reset::soft_reset,
error::{ConnectionError, Error, ResultExt, RomError, RomErrorKind},
interface::Interface,
targets::Chip,
};

pub mod reset;
Expand Down Expand Up @@ -257,17 +256,12 @@ impl Connection {
}

// Reset the device taking into account the reset after argument
pub fn reset_after(&mut self, is_stub: bool, chip: Chip) -> Result<(), Error> {
pub fn reset_after(&mut self, is_stub: bool) -> Result<(), Error> {
match self.after_operation {
ResetAfterOperation::HardReset => HardReset.reset(&mut self.serial),
ResetAfterOperation::SoftReset => {
info!("Soft resetting");
soft_reset(self, false, is_stub, chip)?;
Ok(())
}
ResetAfterOperation::NoReset => {
info!("Staying in bootloader");
soft_reset(self, true, is_stub, chip)?;
soft_reset(self, true, is_stub)?;

Ok(())
}
Expand Down
Loading
Loading