Skip to content

Commit 8814e83

Browse files
authored
Remove direct boot (#577)
* Remove the `DirectBoot` image format * Refactor the `ImageFormat` trait out of existence * Update `README.md` * Update `CHANGELOG.md` * Remove test binaries for direct boot and ESP8266
1 parent 1cde4fc commit 8814e83

23 files changed

+233
-682
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
4444
### Removed
4545

4646
- Remove support for the ESP8266 (#576)
47+
- Remove the direct boot image format (#577)
4748

4849
## [2.1.0] - 2023-10-03
4950

cargo-espflash/src/main.rs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ use espflash::{
1616
},
1717
error::Error as EspflashError,
1818
flasher::{parse_partition_table, FlashData, FlashSettings},
19-
image_format::ImageFormatKind,
2019
logging::initialize_logger,
2120
targets::{Chip, XtalFrequency},
2221
update::check_for_update,
@@ -185,9 +184,6 @@ struct FlashArgs {
185184
#[derive(Debug, Args)]
186185
#[non_exhaustive]
187186
struct SaveImageArgs {
188-
/// Image format to flash
189-
#[arg(long, value_enum)]
190-
pub format: Option<ImageFormatKind>,
191187
#[clap(flatten)]
192188
build_args: BuildArgs,
193189
#[clap(flatten)]
@@ -327,7 +323,6 @@ fn flash(args: FlashArgs, config: &Config) -> Result<()> {
327323
bootloader,
328324
partition_table,
329325
args.flash_args.partition_table_offset,
330-
args.flash_args.format,
331326
args.flash_args.target_app_partition,
332327
flash_settings,
333328
args.flash_args.min_chip_rev,
@@ -557,9 +552,6 @@ fn save_image(args: SaveImageArgs, config: &Config) -> Result<()> {
557552
// Since we have no `Flasher` instance and as such cannot print the board
558553
// information, we will print whatever information we _do_ have.
559554
println!("Chip type: {}", args.save_image_args.chip);
560-
if let Some(format) = args.format {
561-
println!("Image format: {:?}", format);
562-
}
563555
println!("Merge: {}", args.save_image_args.merge);
564556
println!("Skip padding: {}", args.save_image_args.skip_padding);
565557
if let Some(path) = &args.save_image_args.bootloader {
@@ -579,7 +571,6 @@ fn save_image(args: SaveImageArgs, config: &Config) -> Result<()> {
579571
bootloader.as_deref(),
580572
partition_table.as_deref(),
581573
args.save_image_args.partition_table_offset,
582-
args.format,
583574
args.save_image_args.target_app_partition,
584575
flash_settings,
585576
args.save_image_args.min_chip_rev,

espflash/src/bin/espflash.rs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ use espflash::{
1515
},
1616
error::Error,
1717
flasher::{parse_partition_table, FlashData, FlashSettings},
18-
image_format::ImageFormatKind,
1918
logging::initialize_logger,
2019
targets::{Chip, XtalFrequency},
2120
update::check_for_update,
@@ -126,9 +125,6 @@ struct FlashArgs {
126125
struct SaveImageArgs {
127126
/// ELF image to flash
128127
image: PathBuf,
129-
/// Image format to flash
130-
#[arg(long, value_enum)]
131-
format: Option<ImageFormatKind>,
132128
/// Flashing configuration
133129
#[clap(flatten)]
134130
pub flash_config_args: FlashConfigArgs,
@@ -262,7 +258,6 @@ fn flash(args: FlashArgs, config: &Config) -> Result<()> {
262258
bootloader,
263259
partition_table,
264260
args.flash_args.partition_table_offset,
265-
args.flash_args.format,
266261
args.flash_args.target_app_partition,
267262
flash_settings,
268263
args.flash_args.min_chip_rev,
@@ -324,9 +319,6 @@ fn save_image(args: SaveImageArgs, config: &Config) -> Result<()> {
324319
// Since we have no `Flasher` instance and as such cannot print the board
325320
// information, we will print whatever information we _do_ have.
326321
println!("Chip type: {}", args.save_image_args.chip);
327-
if let Some(format) = args.format {
328-
println!("Image format: {:?}", format);
329-
}
330322
println!("Merge: {}", args.save_image_args.merge);
331323
println!("Skip padding: {}", args.save_image_args.skip_padding);
332324
if let Some(path) = &bootloader {
@@ -346,7 +338,6 @@ fn save_image(args: SaveImageArgs, config: &Config) -> Result<()> {
346338
bootloader,
347339
partition_table,
348340
args.save_image_args.partition_table_offset,
349-
args.format,
350341
args.save_image_args.target_app_partition,
351342
flash_settings,
352343
args.save_image_args.min_chip_rev,

espflash/src/cli/mod.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ use crate::{
3434
parse_partition_table, FlashData, FlashFrequency, FlashMode, FlashSize, Flasher,
3535
ProgressCallbacks,
3636
},
37-
image_format::ImageFormatKind,
3837
interface::Interface,
3938
targets::{Chip, XtalFrequency},
4039
};
@@ -140,9 +139,6 @@ pub struct FlashArgs {
140139
/// Erase specified data partitions
141140
#[arg(long, value_name = "PARTS", value_enum, value_delimiter = ',')]
142141
pub erase_data_parts: Option<Vec<DataType>>,
143-
/// Image format to flash
144-
#[arg(long, value_enum)]
145-
pub format: Option<ImageFormatKind>,
146142
/// Logging format.
147143
#[arg(long, short = 'L', default_value = "serial", requires = "monitor")]
148144
pub log_format: LogFormat,

espflash/src/error.rs

Lines changed: 5 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,21 @@ use std::{
55
io,
66
};
77

8+
use miette::Diagnostic;
9+
use slip_codec::SlipError;
10+
use strum::{FromRepr, VariantNames};
11+
use thiserror::Error;
12+
813
#[cfg(feature = "cli")]
914
use crate::cli::monitor::parser::esp_defmt::DefmtError;
1015
#[cfg(feature = "serialport")]
1116
use crate::interface::SerialConfigError;
1217
use crate::{
1318
command::CommandType,
1419
flasher::{FlashFrequency, FlashSize},
15-
image_format::ImageFormatKind,
1620
targets::Chip,
1721
};
1822

19-
use miette::Diagnostic;
20-
use slip_codec::SlipError;
21-
use strum::{FromRepr, VariantNames};
22-
use thiserror::Error;
23-
2423
/// All possible errors returned by espflash
2524
#[derive(Debug, Diagnostic, Error)]
2625
#[non_exhaustive]
@@ -107,16 +106,6 @@ pub enum Error {
107106
#[diagnostic(code(espflash::invalid_bootloader_path))]
108107
InvalidBootloaderPath,
109108

110-
#[error("Binary is not set up correctly to support direct boot")]
111-
#[diagnostic(
112-
code(espflash::invalid_direct_boot),
113-
help(
114-
"See the following page for documentation on how to set up your binary for direct boot:\
115-
https://github.com/espressif/esp32c3-direct-boot-example"
116-
)
117-
)]
118-
InvalidDirectBootBinary,
119-
120109
#[error("The flash size '{0}' is invalid")]
121110
#[diagnostic(
122111
code(espflash::invalid_flash_size),
@@ -165,13 +154,6 @@ pub enum Error {
165154
)]
166155
SerialNotFound(String),
167156

168-
#[error("Unrecognized image format '{0}'")]
169-
#[diagnostic(
170-
code(espflash::unknown_format),
171-
help("The following image formats are supported: {}", ImageFormatKind::VARIANTS.join(", "))
172-
)]
173-
UnknownImageFormat(String),
174-
175157
#[error("The {chip} does not support {feature}")]
176158
#[diagnostic(code(espflash::unsupported_feature))]
177159
UnsupportedFeature { chip: Chip, feature: String },
@@ -221,10 +203,6 @@ pub enum Error {
221203
#[diagnostic(transparent)]
222204
RomError(#[from] RomError),
223205

224-
#[error(transparent)]
225-
#[diagnostic(transparent)]
226-
UnsupportedImageFormat(#[from] UnsupportedImageFormatError),
227-
228206
#[cfg(feature = "serialport")]
229207
#[error(transparent)]
230208
#[diagnostic(transparent)]
@@ -517,80 +495,6 @@ impl From<&'static str> for ElfError {
517495
}
518496
}
519497

520-
/// Unsupported image format error
521-
#[derive(Debug)]
522-
pub struct UnsupportedImageFormatError {
523-
format: ImageFormatKind,
524-
chip: Chip,
525-
revision: Option<(u32, u32)>,
526-
context: Option<String>,
527-
}
528-
529-
impl UnsupportedImageFormatError {
530-
pub fn new(format: ImageFormatKind, chip: Chip, revision: Option<(u32, u32)>) -> Self {
531-
Self {
532-
format,
533-
chip,
534-
revision,
535-
context: None,
536-
}
537-
}
538-
539-
/// Return a comma-separated list of supported image formats
540-
fn supported_formats(&self) -> String {
541-
self.chip
542-
.into_target()
543-
.supported_image_formats()
544-
.iter()
545-
.map(|format| format.into())
546-
.collect::<Vec<&'static str>>()
547-
.join(", ")
548-
}
549-
550-
/// Update the context of the unsupported image format error
551-
pub fn with_context(mut self, ctx: String) -> Self {
552-
self.context.replace(ctx);
553-
554-
self
555-
}
556-
}
557-
558-
impl std::error::Error for UnsupportedImageFormatError {}
559-
560-
impl Display for UnsupportedImageFormatError {
561-
fn fmt(&self, f: &mut Formatter) -> std::fmt::Result {
562-
write!(
563-
f,
564-
"Image format {} is not supported by the {}",
565-
self.format, self.chip
566-
)?;
567-
568-
if let Some((major, minor)) = self.revision {
569-
write!(f, " revision v{major}.{minor}")?;
570-
}
571-
572-
Ok(())
573-
}
574-
}
575-
576-
impl Diagnostic for UnsupportedImageFormatError {
577-
fn code<'a>(&'a self) -> Option<Box<dyn Display + 'a>> {
578-
Some(Box::new("espflash::unsupported_image_format"))
579-
}
580-
581-
fn help<'a>(&'a self) -> Option<Box<dyn Display + 'a>> {
582-
if let Some(ref ctx) = self.context {
583-
Some(Box::new(ctx))
584-
} else {
585-
Some(Box::new(format!(
586-
"The following image formats are supported by the {}: {}",
587-
self.chip,
588-
self.supported_formats()
589-
)))
590-
}
591-
}
592-
}
593-
594498
pub(crate) trait ResultExt {
595499
/// Mark an error as having occurred during the flashing stage
596500
fn flashing(self) -> Self;

espflash/src/flasher/mod.rs

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ use crate::{
2828
command::{Command, CommandType},
2929
elf::{ElfFirmwareImage, FirmwareImage, RomSegment},
3030
error::{ConnectionError, Error, ResultExt},
31-
image_format::ImageFormatKind,
3231
targets::{Chip, XtalFrequency},
3332
};
3433
#[cfg(feature = "serialport")]
@@ -285,7 +284,6 @@ pub struct FlashDataBuilder<'a> {
285284
bootloader_path: Option<&'a Path>,
286285
partition_table_path: Option<&'a Path>,
287286
partition_table_offset: Option<u32>,
288-
image_format: Option<ImageFormatKind>,
289287
target_app_partition: Option<String>,
290288
flash_settings: FlashSettings,
291289
min_chip_rev: u16,
@@ -297,7 +295,6 @@ impl<'a> Default for FlashDataBuilder<'a> {
297295
bootloader_path: Default::default(),
298296
partition_table_path: Default::default(),
299297
partition_table_offset: Default::default(),
300-
image_format: Default::default(),
301298
target_app_partition: Default::default(),
302299
flash_settings: FlashSettings::default(),
303300
min_chip_rev: Default::default(),
@@ -329,12 +326,6 @@ impl<'a> FlashDataBuilder<'a> {
329326
self
330327
}
331328

332-
/// Sets the image format.
333-
pub fn with_image_format(mut self, image_format: ImageFormatKind) -> Self {
334-
self.image_format = Some(image_format);
335-
self
336-
}
337-
338329
/// Sets the label of the target app partition.
339330
pub fn with_target_app_partition(mut self, target_app_partition: String) -> Self {
340331
self.target_app_partition = Some(target_app_partition);
@@ -359,7 +350,6 @@ impl<'a> FlashDataBuilder<'a> {
359350
self.bootloader_path,
360351
self.partition_table_path,
361352
self.partition_table_offset,
362-
self.image_format,
363353
self.target_app_partition,
364354
self.flash_settings,
365355
self.min_chip_rev,
@@ -374,7 +364,6 @@ pub struct FlashData {
374364
pub bootloader: Option<Vec<u8>>,
375365
pub partition_table: Option<PartitionTable>,
376366
pub partition_table_offset: Option<u32>,
377-
pub image_format: Option<ImageFormatKind>,
378367
pub target_app_partition: Option<String>,
379368
pub flash_settings: FlashSettings,
380369
pub min_chip_rev: u16,
@@ -385,7 +374,6 @@ impl FlashData {
385374
bootloader: Option<&Path>,
386375
partition_table: Option<&Path>,
387376
partition_table_offset: Option<u32>,
388-
image_format: Option<ImageFormatKind>,
389377
target_app_partition: Option<String>,
390378
flash_settings: FlashSettings,
391379
min_chip_rev: u16,
@@ -412,7 +400,6 @@ impl FlashData {
412400
bootloader,
413401
partition_table,
414402
partition_table_offset,
415-
image_format,
416403
target_app_partition,
417404
flash_settings,
418405
min_chip_rev,

0 commit comments

Comments
 (0)