mirror of
https://github.com/esp-rs/espflash.git
synced 2026-03-27 09:41:37 +00:00
Fix imports and build errors, some simplification
This commit is contained in:
8
Cargo.lock
generated
8
Cargo.lock
generated
@@ -619,7 +619,6 @@ dependencies = [
|
||||
"flate2",
|
||||
"indicatif",
|
||||
"log",
|
||||
"maplit",
|
||||
"miette",
|
||||
"parse_int",
|
||||
"rppal",
|
||||
@@ -630,7 +629,6 @@ dependencies = [
|
||||
"sha2",
|
||||
"slip-codec",
|
||||
"strum",
|
||||
"strum_macros",
|
||||
"thiserror",
|
||||
"toml",
|
||||
"update-informer",
|
||||
@@ -913,12 +911,6 @@ dependencies = [
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "maplit"
|
||||
version = "1.0.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3e2e65a1a2e43cfcb47a895c4c8b10d1f4a61097f9f254f183aee60cad9c651d"
|
||||
|
||||
[[package]]
|
||||
name = "maybe-uninit"
|
||||
version = "2.0.0"
|
||||
|
||||
@@ -3,7 +3,7 @@ use std::{
|
||||
iter::once,
|
||||
};
|
||||
|
||||
use espflash::Chip;
|
||||
use espflash::targets::Chip;
|
||||
use miette::{Diagnostic, LabeledSpan, SourceCode, SourceOffset};
|
||||
use thiserror::Error;
|
||||
|
||||
@@ -141,7 +141,7 @@ impl UnsupportedTargetError {
|
||||
|
||||
impl UnsupportedTargetError {
|
||||
fn supported_targets(&self) -> String {
|
||||
self.chip.supported_targets().join(", ")
|
||||
self.chip.into_target().supported_build_targets().join(", ")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -164,7 +164,11 @@ impl Diagnostic for NoTargetError {
|
||||
|
||||
fn help<'a>(&'a self) -> Option<Box<dyn Display + 'a>> {
|
||||
Some(Box::new(match &self.chip {
|
||||
Some(chip) => format!("Specify the target in `.cargo/config.toml`, the {} support the following targets: {}", chip, chip.supported_targets().join(", ")),
|
||||
Some(chip) => format!(
|
||||
"Specify the target in `.cargo/config.toml`, the {} support the following targets: {}",
|
||||
chip,
|
||||
chip.into_target().supported_build_targets().join(", ")
|
||||
),
|
||||
None => "Specify the target in `.cargo/config.toml`".into(),
|
||||
}
|
||||
))
|
||||
|
||||
@@ -9,14 +9,14 @@ use cargo_metadata::Message;
|
||||
use clap::{Args, Parser, Subcommand};
|
||||
use espflash::{
|
||||
cli::{
|
||||
board_info, connect, flash_elf_image, monitor::monitor, partition_table, save_elf_as_image,
|
||||
serial_monitor, ConnectArgs, FlashArgs as BaseFlashArgs, FlashConfigArgs,
|
||||
PartitionTableArgs, SaveImageArgs as BaseSaveImageArgs,
|
||||
board_info, config::Config, connect, flash_elf_image, monitor::monitor, partition_table,
|
||||
save_elf_as_image, serial_monitor, ConnectArgs, FlashArgs as BaseFlashArgs,
|
||||
FlashConfigArgs, PartitionTableArgs, SaveImageArgs as BaseSaveImageArgs,
|
||||
},
|
||||
image_format::ImageFormatType,
|
||||
image_format::{ImageFormatId, ImageFormatType},
|
||||
logging::initialize_logger,
|
||||
targets::Chip,
|
||||
update::check_for_update,
|
||||
Chip, Config, ImageFormatId,
|
||||
};
|
||||
use log::{debug, LevelFilter};
|
||||
use miette::{IntoDiagnostic, Result, WrapErr};
|
||||
@@ -244,7 +244,7 @@ fn build(
|
||||
.or_else(|| cargo_config.target())
|
||||
.ok_or_else(|| NoTargetError::new(Some(chip)))?;
|
||||
|
||||
if !chip.supports_target(target) {
|
||||
if !chip.into_target().supports_build_target(target) {
|
||||
return Err(Error::UnsupportedTarget(UnsupportedTargetError::new(target, chip)).into());
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ use std::{
|
||||
};
|
||||
|
||||
use cargo_toml::Manifest;
|
||||
use espflash::ImageFormatId;
|
||||
use espflash::image_format::ImageFormatId;
|
||||
use miette::{IntoDiagnostic, Result, WrapErr};
|
||||
use serde::Deserialize;
|
||||
|
||||
|
||||
@@ -48,7 +48,6 @@ env_logger = "0.9.0"
|
||||
flate2 = "1.0.24"
|
||||
indicatif = "0.17.1"
|
||||
log = "0.4.17"
|
||||
maplit = "1.0.2"
|
||||
miette = { version = "5.3.0", features = ["fancy"] }
|
||||
parse_int = "0.6.0"
|
||||
rppal = { version = "0.13", optional = true }
|
||||
@@ -58,8 +57,7 @@ serde_json = "1.0.85"
|
||||
serialport = "4.2.0"
|
||||
sha2 = "0.10.6"
|
||||
slip-codec = "0.3.3"
|
||||
strum = "0.24.1"
|
||||
strum_macros = "0.24.3"
|
||||
strum = { version = "0.24.1", features = ["derive"] }
|
||||
thiserror = "1.0.35"
|
||||
toml = "0.5.9"
|
||||
update-informer = { version = "0.5.0", optional = true }
|
||||
|
||||
@@ -9,14 +9,13 @@ use std::{
|
||||
use clap::{Args, Parser, Subcommand};
|
||||
use espflash::{
|
||||
cli::{
|
||||
board_info, connect, flash_elf_image, monitor::monitor, partition_table, save_elf_as_image,
|
||||
serial_monitor, ConnectArgs, FlashArgs as BaseFlashArgs, FlashConfigArgs,
|
||||
PartitionTableArgs, SaveImageArgs as BaseSaveImageArgs,
|
||||
board_info, config::Config, connect, flash_elf_image, monitor::monitor, partition_table,
|
||||
save_elf_as_image, serial_monitor, ConnectArgs, FlashArgs as BaseFlashArgs,
|
||||
FlashConfigArgs, PartitionTableArgs, SaveImageArgs as BaseSaveImageArgs,
|
||||
},
|
||||
image_format::{ImageFormatId, ImageFormatType},
|
||||
logging::initialize_logger,
|
||||
update::check_for_update,
|
||||
Config,
|
||||
};
|
||||
use log::{debug, LevelFilter};
|
||||
use miette::{IntoDiagnostic, Result, WrapErr};
|
||||
|
||||
@@ -18,11 +18,11 @@ use strum::VariantNames;
|
||||
use self::{config::Config, monitor::monitor, serial::get_serial_port_info};
|
||||
use crate::{
|
||||
elf::ElfFirmwareImage,
|
||||
error::NoOtadataError,
|
||||
flasher::{FlashFrequency, FlashMode, FlashSize},
|
||||
image_format::ImageFormatType,
|
||||
error::{MissingPartitionTable, NoOtadataError},
|
||||
flasher::{FlashFrequency, FlashMode, FlashSize, Flasher},
|
||||
image_format::{ImageFormatId, ImageFormatType},
|
||||
interface::Interface,
|
||||
Chip, Flasher, ImageFormatId, MissingPartitionTable,
|
||||
targets::Chip,
|
||||
};
|
||||
|
||||
pub mod config;
|
||||
@@ -237,7 +237,7 @@ pub fn save_elf_as_image(
|
||||
|
||||
// To get a chip revision, the connection is needed
|
||||
// For simplicity, the revision None is used
|
||||
let image = chip.get_flash_image(
|
||||
let image = chip.into_target().get_flash_image(
|
||||
&image,
|
||||
bootloader,
|
||||
partition_table,
|
||||
@@ -275,7 +275,7 @@ pub fn save_elf_as_image(
|
||||
file.write_all(&padding_bytes).into_diagnostic()?;
|
||||
}
|
||||
} else {
|
||||
let flash_image = chip.get_flash_image(
|
||||
let flash_image = chip.into_target().get_flash_image(
|
||||
&image,
|
||||
None,
|
||||
None,
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
use crate::flasher::{checksum, SpiAttachParams, CHECKSUM_INIT};
|
||||
use std::{io::Write, mem::size_of, time::Duration};
|
||||
|
||||
use bytemuck::{bytes_of, Pod, Zeroable};
|
||||
use std::io::Write;
|
||||
use std::mem::size_of;
|
||||
use std::time::Duration;
|
||||
use strum_macros::Display;
|
||||
use strum::Display;
|
||||
|
||||
use crate::flasher::{checksum, SpiAttachParams, CHECKSUM_INIT};
|
||||
|
||||
const DEFAULT_TIMEOUT: Duration = Duration::from_secs(3);
|
||||
const ERASE_REGION_TIMEOUT_PER_MB: Duration = Duration::from_secs(30);
|
||||
|
||||
@@ -13,8 +13,8 @@ use xmas_elf::{
|
||||
};
|
||||
|
||||
use crate::{
|
||||
chip::Chip,
|
||||
error::{ElfError, Error},
|
||||
targets::Chip,
|
||||
};
|
||||
|
||||
pub const ESP_CHECKSUM_MAGIC: u8 = 0xef;
|
||||
@@ -27,14 +27,14 @@ pub trait FirmwareImage<'a> {
|
||||
fn rom_segments(&'a self, chip: Chip) -> Box<dyn Iterator<Item = CodeSegment<'a>> + 'a> {
|
||||
Box::new(
|
||||
self.segments()
|
||||
.filter(move |segment| chip.addr_is_flash(segment.addr)),
|
||||
.filter(move |segment| chip.into_target().addr_is_flash(segment.addr)),
|
||||
)
|
||||
}
|
||||
|
||||
fn ram_segments(&'a self, chip: Chip) -> Box<dyn Iterator<Item = CodeSegment<'a>> + 'a> {
|
||||
Box::new(
|
||||
self.segments()
|
||||
.filter(move |segment| !chip.addr_is_flash(segment.addr)),
|
||||
.filter(move |segment| !chip.into_target().addr_is_flash(segment.addr)),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ use crate::{
|
||||
flasher::{FlashFrequency, FlashMode, FlashSize},
|
||||
image_format::ImageFormatId,
|
||||
interface::SerialConfigError,
|
||||
Chip,
|
||||
targets::Chip,
|
||||
};
|
||||
|
||||
#[derive(Error, Debug, Diagnostic)]
|
||||
@@ -450,6 +450,7 @@ impl UnsupportedImageFormatError {
|
||||
|
||||
fn supported_formats(&self) -> String {
|
||||
self.chip
|
||||
.into_target()
|
||||
.supported_image_formats()
|
||||
.iter()
|
||||
.map(|format| format.into())
|
||||
|
||||
@@ -4,18 +4,17 @@ use bytemuck::{Pod, Zeroable, __core::time::Duration};
|
||||
use esp_idf_part::PartitionTable;
|
||||
use log::debug;
|
||||
use serialport::UsbPortInfo;
|
||||
use strum_macros::{Display, EnumVariantNames};
|
||||
use strum::{Display, EnumVariantNames};
|
||||
|
||||
use self::stubs::FlashStub;
|
||||
use crate::{
|
||||
chip::Chip,
|
||||
command::{Command, CommandType},
|
||||
connection::Connection,
|
||||
elf::{ElfFirmwareImage, FirmwareImage, RomSegment},
|
||||
error::{ConnectionError, FlashDetectError, ResultExt},
|
||||
error::{ConnectionError, Error, FlashDetectError, ResultExt},
|
||||
image_format::ImageFormatId,
|
||||
interface::Interface,
|
||||
Error,
|
||||
targets::Chip,
|
||||
};
|
||||
|
||||
mod stubs;
|
||||
@@ -338,7 +337,9 @@ impl Flasher {
|
||||
|
||||
let mut ram_target = self.chip.ram_target(
|
||||
Some(stub.entry()),
|
||||
self.chip.max_ram_block_size(&mut self.connection)?,
|
||||
self.chip
|
||||
.into_target()
|
||||
.max_ram_block_size(&mut self.connection)?,
|
||||
);
|
||||
ram_target.begin(&mut self.connection).flashing()?;
|
||||
|
||||
@@ -478,7 +479,7 @@ impl Flasher {
|
||||
assert!(read_bits < 32);
|
||||
assert!(data.len() < 64);
|
||||
|
||||
let spi_registers = self.chip.spi_registers();
|
||||
let spi_registers = self.chip.into_target().spi_registers();
|
||||
|
||||
let old_spi_usr = self.connection.read_reg(spi_registers.usr())?;
|
||||
let old_spi_usr2 = self.connection.read_reg(spi_registers.usr2())?;
|
||||
@@ -571,10 +572,11 @@ impl Flasher {
|
||||
pub fn board_info(&mut self) -> Result<(), Error> {
|
||||
let chip = self.chip();
|
||||
|
||||
let maybe_revision = chip.chip_revision(self.connection())?;
|
||||
let features = chip.chip_features(self.connection())?;
|
||||
let freq = chip.crystal_freq(self.connection())?;
|
||||
let mac = chip.mac_address(self.connection())?;
|
||||
let target = chip.into_target();
|
||||
let maybe_revision = target.chip_revision(self.connection())?;
|
||||
let features = target.chip_features(self.connection())?;
|
||||
let freq = target.crystal_freq(self.connection())?;
|
||||
let mac = target.mac_address(self.connection())?;
|
||||
|
||||
print!("Chip type: {}", chip);
|
||||
match maybe_revision {
|
||||
@@ -597,7 +599,9 @@ impl Flasher {
|
||||
|
||||
let mut target = self.chip.ram_target(
|
||||
Some(image.entry()),
|
||||
self.chip.max_ram_block_size(&mut self.connection)?,
|
||||
self.chip
|
||||
.into_target()
|
||||
.max_ram_block_size(&mut self.connection)?,
|
||||
);
|
||||
target.begin(&mut self.connection).flashing()?;
|
||||
|
||||
@@ -636,12 +640,14 @@ impl Flasher {
|
||||
let mut target = self.chip.flash_target(self.spi_params, self.use_stub);
|
||||
target.begin(&mut self.connection).flashing()?;
|
||||
|
||||
let flash_image = self.chip.get_flash_image(
|
||||
let flash_image = self.chip.into_target().get_flash_image(
|
||||
&image,
|
||||
bootloader,
|
||||
partition_table,
|
||||
image_format,
|
||||
self.chip.chip_revision(&mut self.connection)?,
|
||||
self.chip
|
||||
.into_target()
|
||||
.chip_revision(&mut self.connection)?,
|
||||
flash_mode,
|
||||
flash_size.or(Some(self.flash_size)),
|
||||
flash_freq,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::Chip;
|
||||
use crate::targets::Chip;
|
||||
|
||||
/// Flash stub object (deserialized from json as used by `esptool.py`)
|
||||
#[derive(Clone, PartialEq, Eq, Debug, Serialize, Deserialize)]
|
||||
@@ -66,7 +66,7 @@ mod tests {
|
||||
use strum::IntoEnumIterator;
|
||||
|
||||
use super::FlashStub;
|
||||
use crate::Chip;
|
||||
use crate::targets::Chip;
|
||||
|
||||
#[test]
|
||||
fn check_stub_encodings() {
|
||||
|
||||
@@ -6,7 +6,6 @@ use sha2::{Digest, Sha256};
|
||||
|
||||
use super::encode_flash_frequency;
|
||||
use crate::{
|
||||
chip::Esp32Params,
|
||||
elf::{
|
||||
merge_adjacent_segments, update_checksum, CodeSegment, FirmwareImage, RomSegment,
|
||||
ESP_CHECKSUM_MAGIC,
|
||||
@@ -14,7 +13,7 @@ use crate::{
|
||||
error::{Error, FlashDetectError},
|
||||
flasher::{FlashFrequency, FlashMode, FlashSize},
|
||||
image_format::{EspCommonHeader, ImageFormat, SegmentHeader, ESP_MAGIC, WP_PIN_DISABLED},
|
||||
Chip,
|
||||
targets::{Chip, Esp32Params},
|
||||
};
|
||||
|
||||
/// Image format for esp32 family chips using a 2nd stage bootloader
|
||||
|
||||
@@ -6,9 +6,9 @@ use super::encode_flash_frequency;
|
||||
use crate::{
|
||||
elf::{update_checksum, CodeSegment, FirmwareImage, RomSegment, ESP_CHECKSUM_MAGIC},
|
||||
error::{Error, FlashDetectError},
|
||||
flasher::FlashSize,
|
||||
flasher::{FlashFrequency, FlashMode, FlashSize},
|
||||
image_format::{EspCommonHeader, ImageFormat, SegmentHeader, ESP_MAGIC},
|
||||
Chip, FlashFrequency, FlashMode,
|
||||
targets::Chip,
|
||||
};
|
||||
|
||||
/// Image format for flashing to esp8266 chips
|
||||
|
||||
@@ -2,10 +2,10 @@ use std::str::FromStr;
|
||||
|
||||
use bytemuck::{Pod, Zeroable};
|
||||
use serde::Deserialize;
|
||||
use strum_macros::{Display, EnumVariantNames, IntoStaticStr};
|
||||
use strum::{Display, EnumVariantNames, IntoStaticStr};
|
||||
|
||||
pub use self::{esp32bootloader::*, esp32directboot::*, esp8266::*};
|
||||
use crate::{chip::Chip, elf::RomSegment, error::Error, flasher::FlashFrequency};
|
||||
use crate::{elf::RomSegment, error::Error, flasher::FlashFrequency, targets::Chip};
|
||||
|
||||
mod esp32bootloader;
|
||||
mod esp32directboot;
|
||||
@@ -92,7 +92,7 @@ impl FromStr for ImageFormatId {
|
||||
}
|
||||
|
||||
pub(crate) fn encode_flash_frequency(chip: Chip, frequency: FlashFrequency) -> Result<u8, Error> {
|
||||
let encodings = chip.flash_frequency_encodings();
|
||||
let encodings = chip.into_target().flash_frequency_encodings();
|
||||
if let Some(&f) = encodings.get(&frequency) {
|
||||
Ok(f)
|
||||
} else {
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
use std::io::Read;
|
||||
|
||||
use crate::{cli::ConnectArgs, Config, Error};
|
||||
use miette::{Context, Result};
|
||||
use serialport::{FlowControl, SerialPort, SerialPortInfo};
|
||||
|
||||
#[cfg(feature = "raspberry")]
|
||||
use rppal::gpio::{Gpio, OutputPin};
|
||||
use serialport::{FlowControl, SerialPort, SerialPortInfo};
|
||||
|
||||
use crate::{
|
||||
cli::{config::Config, ConnectArgs},
|
||||
error::Error,
|
||||
};
|
||||
|
||||
#[derive(thiserror::Error, Debug)]
|
||||
pub enum SerialConfigError {
|
||||
@@ -18,7 +21,8 @@ pub enum SerialConfigError {
|
||||
GpioUnavailable(u8),
|
||||
}
|
||||
|
||||
/// Wrapper around SerialPort where platform-specific modifications can be implemented.
|
||||
/// Wrapper around SerialPort where platform-specific modifications can be
|
||||
/// implemented.
|
||||
pub struct Interface {
|
||||
pub serial_port: Box<dyn SerialPort>,
|
||||
#[cfg(feature = "raspberry")]
|
||||
@@ -132,8 +136,8 @@ impl Interface {
|
||||
}
|
||||
}
|
||||
|
||||
// Note(dbuga): this impl is necessary because using `dyn SerialPort` as `dyn Read`
|
||||
// requires trait_upcasting which isn't stable yet.
|
||||
// Note(dbuga): this impl is necessary because using `dyn SerialPort` as `dyn
|
||||
// Read` requires trait_upcasting which isn't stable yet.
|
||||
impl Read for Interface {
|
||||
fn read(&mut self, buf: &mut [u8]) -> std::io::Result<usize> {
|
||||
self.serial_port.read(buf)
|
||||
|
||||
@@ -1,23 +1,13 @@
|
||||
#[cfg(feature = "cli")]
|
||||
pub use self::cli::config::Config;
|
||||
pub use self::{
|
||||
chip::Chip,
|
||||
error::{Error, MissingPartitionTable},
|
||||
flasher::{FlashFrequency, FlashMode, FlashSize, Flasher},
|
||||
image_format::ImageFormatId,
|
||||
};
|
||||
|
||||
pub mod chip;
|
||||
#[cfg(feature = "cli")]
|
||||
pub mod cli;
|
||||
pub mod command;
|
||||
pub mod connection;
|
||||
pub mod elf;
|
||||
pub mod error;
|
||||
pub mod flash_target;
|
||||
pub mod flasher;
|
||||
pub mod image_format;
|
||||
pub mod interface;
|
||||
pub mod targets;
|
||||
|
||||
pub mod logging {
|
||||
use env_logger::Env;
|
||||
|
||||
@@ -2,14 +2,12 @@ use std::ops::Range;
|
||||
|
||||
use esp_idf_part::PartitionTable;
|
||||
|
||||
use super::{
|
||||
bytes_to_mac_addr, Chip, Esp32Params, Esp32Target, FlashTarget, ReadEFuse, SpiRegisters, Target,
|
||||
};
|
||||
use super::{bytes_to_mac_addr, Chip, Esp32Params, ReadEFuse, SpiRegisters, Target};
|
||||
use crate::{
|
||||
connection::Connection,
|
||||
elf::FirmwareImage,
|
||||
error::{Error, UnsupportedImageFormatError},
|
||||
flasher::{FlashFrequency, FlashMode, FlashSize, SpiAttachParams},
|
||||
flasher::{FlashFrequency, FlashMode, FlashSize},
|
||||
image_format::{Esp32BootloaderFormat, ImageFormat, ImageFormatId},
|
||||
};
|
||||
|
||||
@@ -147,10 +145,6 @@ impl Target for Esp32 {
|
||||
Ok(norm_xtal)
|
||||
}
|
||||
|
||||
fn flash_target(&self, spi_params: SpiAttachParams, use_stub: bool) -> Box<dyn FlashTarget> {
|
||||
Box::new(Esp32Target::new(Chip::Esp32, spi_params, use_stub))
|
||||
}
|
||||
|
||||
fn get_flash_image<'a>(
|
||||
&self,
|
||||
image: &'a dyn FirmwareImage<'a>,
|
||||
@@ -202,7 +196,7 @@ impl Target for Esp32 {
|
||||
}
|
||||
}
|
||||
|
||||
fn supported_targets(&self) -> &[&str] {
|
||||
fn supported_build_targets(&self) -> &[&str] {
|
||||
&["xtensa-esp32-none-elf", "xtensa-esp32-espidf"]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,12 +2,12 @@ use std::{collections::HashMap, ops::Range};
|
||||
|
||||
use esp_idf_part::PartitionTable;
|
||||
|
||||
use super::{Chip, Esp32Params, Esp32Target, FlashTarget, ReadEFuse, SpiRegisters, Target};
|
||||
use super::{Chip, Esp32Params, ReadEFuse, SpiRegisters, Target};
|
||||
use crate::{
|
||||
connection::Connection,
|
||||
elf::FirmwareImage,
|
||||
error::Error,
|
||||
flasher::{FlashFrequency, FlashMode, FlashSize, SpiAttachParams},
|
||||
flasher::{FlashFrequency, FlashMode, FlashSize},
|
||||
image_format::{Esp32BootloaderFormat, Esp32DirectBootFormat, ImageFormat, ImageFormatId},
|
||||
};
|
||||
|
||||
@@ -81,10 +81,6 @@ impl Target for Esp32c2 {
|
||||
HashMap::from(encodings)
|
||||
}
|
||||
|
||||
fn flash_target(&self, spi_params: SpiAttachParams, use_stub: bool) -> Box<dyn FlashTarget> {
|
||||
Box::new(Esp32Target::new(Chip::Esp32c2, spi_params, use_stub))
|
||||
}
|
||||
|
||||
fn get_flash_image<'a>(
|
||||
&self,
|
||||
image: &'a dyn FirmwareImage<'a>,
|
||||
@@ -129,7 +125,7 @@ impl Target for Esp32c2 {
|
||||
&[ImageFormatId::Bootloader, ImageFormatId::DirectBoot]
|
||||
}
|
||||
|
||||
fn supported_targets(&self) -> &[&str] {
|
||||
fn supported_build_targets(&self) -> &[&str] {
|
||||
&[
|
||||
"riscv32imac-unknown-none-elf",
|
||||
"riscv32imc-esp-espidf",
|
||||
|
||||
@@ -2,12 +2,12 @@ use std::ops::Range;
|
||||
|
||||
use esp_idf_part::PartitionTable;
|
||||
|
||||
use super::{Chip, Esp32Params, Esp32Target, FlashTarget, ReadEFuse, SpiRegisters, Target};
|
||||
use super::{Chip, Esp32Params, ReadEFuse, SpiRegisters, Target};
|
||||
use crate::{
|
||||
connection::Connection,
|
||||
elf::FirmwareImage,
|
||||
error::{Error, UnsupportedImageFormatError},
|
||||
flasher::{FlashFrequency, FlashMode, FlashSize, SpiAttachParams},
|
||||
flasher::{FlashFrequency, FlashMode, FlashSize},
|
||||
image_format::{Esp32BootloaderFormat, Esp32DirectBootFormat, ImageFormat, ImageFormatId},
|
||||
};
|
||||
|
||||
@@ -68,10 +68,6 @@ impl Target for Esp32c3 {
|
||||
Ok(40)
|
||||
}
|
||||
|
||||
fn flash_target(&self, spi_params: SpiAttachParams, use_stub: bool) -> Box<dyn FlashTarget> {
|
||||
Box::new(Esp32Target::new(Chip::Esp32c3, spi_params, use_stub))
|
||||
}
|
||||
|
||||
fn get_flash_image<'a>(
|
||||
&self,
|
||||
image: &'a dyn FirmwareImage<'a>,
|
||||
@@ -121,7 +117,7 @@ impl Target for Esp32c3 {
|
||||
&[ImageFormatId::Bootloader, ImageFormatId::DirectBoot]
|
||||
}
|
||||
|
||||
fn supported_targets(&self) -> &[&str] {
|
||||
fn supported_build_targets(&self) -> &[&str] {
|
||||
&[
|
||||
"riscv32imac-unknown-none-elf",
|
||||
"riscv32imc-esp-espidf",
|
||||
|
||||
@@ -2,15 +2,12 @@ use std::ops::Range;
|
||||
|
||||
use esp_idf_part::PartitionTable;
|
||||
|
||||
use super::{
|
||||
Chip, Esp32Params, Esp32Target, FlashTarget, ReadEFuse, SpiRegisters, Target,
|
||||
MAX_RAM_BLOCK_SIZE,
|
||||
};
|
||||
use super::{Chip, Esp32Params, ReadEFuse, SpiRegisters, Target, MAX_RAM_BLOCK_SIZE};
|
||||
use crate::{
|
||||
connection::Connection,
|
||||
elf::FirmwareImage,
|
||||
error::{Error, UnsupportedImageFormatError},
|
||||
flasher::{FlashFrequency, FlashMode, FlashSize, SpiAttachParams, FLASH_WRITE_SIZE},
|
||||
flasher::{FlashFrequency, FlashMode, FlashSize, FLASH_WRITE_SIZE},
|
||||
image_format::{Esp32BootloaderFormat, ImageFormat, ImageFormatId},
|
||||
};
|
||||
|
||||
@@ -113,10 +110,6 @@ impl Target for Esp32s2 {
|
||||
Ok(40)
|
||||
}
|
||||
|
||||
fn flash_target(&self, spi_params: SpiAttachParams, use_stub: bool) -> Box<dyn FlashTarget> {
|
||||
Box::new(Esp32Target::new(Chip::Esp32s2, spi_params, use_stub))
|
||||
}
|
||||
|
||||
fn flash_write_size(&self, connection: &mut Connection) -> Result<usize, Error> {
|
||||
Ok(if self.connection_is_usb_otg(connection)? {
|
||||
MAX_USB_BLOCK_SIZE
|
||||
@@ -173,7 +166,7 @@ impl Target for Esp32s2 {
|
||||
}
|
||||
}
|
||||
|
||||
fn supported_targets(&self) -> &[&str] {
|
||||
fn supported_build_targets(&self) -> &[&str] {
|
||||
&["xtensa-esp32s2-none-elf", "xtensa-esp32s2-espidf"]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,14 +2,12 @@ use std::ops::Range;
|
||||
|
||||
use esp_idf_part::PartitionTable;
|
||||
|
||||
use super::{
|
||||
bytes_to_mac_addr, Chip, Esp32Params, Esp32Target, FlashTarget, ReadEFuse, SpiRegisters, Target,
|
||||
};
|
||||
use super::{bytes_to_mac_addr, Chip, Esp32Params, ReadEFuse, SpiRegisters, Target};
|
||||
use crate::{
|
||||
connection::Connection,
|
||||
elf::FirmwareImage,
|
||||
error::Error,
|
||||
flasher::{FlashFrequency, FlashMode, FlashSize, SpiAttachParams},
|
||||
flasher::{FlashFrequency, FlashMode, FlashSize},
|
||||
image_format::{Esp32BootloaderFormat, Esp32DirectBootFormat, ImageFormat, ImageFormatId},
|
||||
};
|
||||
|
||||
@@ -56,10 +54,6 @@ impl Target for Esp32s3 {
|
||||
Ok(40)
|
||||
}
|
||||
|
||||
fn flash_target(&self, spi_params: SpiAttachParams, use_stub: bool) -> Box<dyn FlashTarget> {
|
||||
Box::new(Esp32Target::new(Chip::Esp32s3, spi_params, use_stub))
|
||||
}
|
||||
|
||||
fn get_flash_image<'a>(
|
||||
&self,
|
||||
image: &'a dyn FirmwareImage<'a>,
|
||||
@@ -115,7 +109,7 @@ impl Target for Esp32s3 {
|
||||
&[ImageFormatId::Bootloader, ImageFormatId::DirectBoot]
|
||||
}
|
||||
|
||||
fn supported_targets(&self) -> &[&str] {
|
||||
fn supported_build_targets(&self) -> &[&str] {
|
||||
&["xtensa-esp32s3-none-elf", "xtensa-esp32s3-espidf"]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,12 +2,12 @@ use std::ops::Range;
|
||||
|
||||
use esp_idf_part::PartitionTable;
|
||||
|
||||
use super::{bytes_to_mac_addr, Chip, Esp8266Target, FlashTarget, ReadEFuse, SpiRegisters, Target};
|
||||
use super::{bytes_to_mac_addr, Chip, ReadEFuse, SpiRegisters, Target};
|
||||
use crate::{
|
||||
connection::Connection,
|
||||
elf::FirmwareImage,
|
||||
error::{Error, UnsupportedImageFormatError},
|
||||
flasher::{FlashFrequency, FlashMode, FlashSize, SpiAttachParams},
|
||||
flasher::{FlashFrequency, FlashMode, FlashSize},
|
||||
image_format::{Esp8266Format, ImageFormat, ImageFormatId},
|
||||
};
|
||||
|
||||
@@ -53,10 +53,6 @@ impl Target for Esp8266 {
|
||||
Ok(norm_xtal)
|
||||
}
|
||||
|
||||
fn flash_target(&self, _spi_params: SpiAttachParams, _use_stub: bool) -> Box<dyn FlashTarget> {
|
||||
Box::new(Esp8266Target::new())
|
||||
}
|
||||
|
||||
fn get_flash_image<'a>(
|
||||
&self,
|
||||
image: &'a dyn FirmwareImage<'a>,
|
||||
@@ -116,7 +112,7 @@ impl Target for Esp8266 {
|
||||
}
|
||||
}
|
||||
|
||||
fn supported_targets(&self) -> &[&str] {
|
||||
fn supported_build_targets(&self) -> &[&str] {
|
||||
&["xtensa-esp8266-none-elf"]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -103,6 +103,14 @@ impl Chip {
|
||||
_ => Box::new(Esp32Target::new(*self, spi_params, use_stub)),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn ram_target(
|
||||
&self,
|
||||
entry: Option<u32>,
|
||||
max_ram_block_size: usize,
|
||||
) -> Box<dyn FlashTarget> {
|
||||
Box::new(RamTarget::new(entry, max_ram_block_size))
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
@@ -250,12 +258,6 @@ pub trait Target: ReadEFuse {
|
||||
HashMap::from(encodings)
|
||||
}
|
||||
|
||||
fn ram_target(&self, entry: Option<u32>, max_ram_block_size: usize) -> Box<dyn FlashTarget> {
|
||||
Box::new(RamTarget::new(entry, max_ram_block_size))
|
||||
}
|
||||
|
||||
fn flash_target(&self, spi_params: SpiAttachParams, use_stub: bool) -> Box<dyn FlashTarget>;
|
||||
|
||||
fn flash_write_size(&self, _connection: &mut Connection) -> Result<usize, Error> {
|
||||
Ok(FLASH_WRITE_SIZE)
|
||||
}
|
||||
@@ -293,10 +295,10 @@ pub trait Target: ReadEFuse {
|
||||
&[ImageFormatId::Bootloader]
|
||||
}
|
||||
|
||||
fn supported_targets(&self) -> &[&str];
|
||||
fn supported_build_targets(&self) -> &[&str];
|
||||
|
||||
fn supports_target(&self, target: &str) -> bool {
|
||||
self.supported_targets().contains(&target)
|
||||
fn supports_build_target(&self, target: &str) -> bool {
|
||||
self.supported_build_targets().contains(&target)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user