feat: Update dependencies and adapt code

This commit is contained in:
Sergio Gasquez 2023-06-20 21:38:39 +02:00
parent 22cfebecfb
commit c6909757ab
3 changed files with 810 additions and 556 deletions

1125
Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -2,12 +2,30 @@
name = "web-flash" name = "web-flash"
version = "0.2.1" version = "0.2.1"
edition = "2021" edition = "2021"
authors = [
"Björn Quentin <bjoern.quentin@mobile-j.de>",
"Sergio Gasquez Arcos <sergio.gasquez@gmail.com>",
]
license = "MIT OR Apache-2.0"
readme = "README.md"
repository = "https://github.com/esp-rs/esp-web-flash-server"
keywords = [
"cli",
"embedded",
"esp",
]
categories = [
"command-line-utilities",
"development-tools",
"embedded",
]
[dependencies] [dependencies]
rocket = "0.5.0-rc.2" rocket = "0.5.0-rc.3"
espflash = "2.0.0-rc.1" espflash = "2.0.0"
esp-idf-part = "0.1.1" esp-idf-part = "0.4.1"
clap = { version = "3.1.18", features=["env", "derive"] } clap = { version = "4.3.5", features=["env", "derive"] }
opener = "0.5.0" opener = "0.6.1"
anyhow = "1.0.57" anyhow = "1.0.71"
xmas-elf = "0.8.0" xmas-elf = "0.9.0"

View File

@ -4,7 +4,7 @@ use std::{path::PathBuf, time::Duration};
use clap::Parser; use clap::Parser;
use esp_idf_part::PartitionTable; use esp_idf_part::PartitionTable;
use espflash::{elf::ElfFirmwareImage, flasher::FlashSize::Flash4Mb, targets::Chip}; use espflash::{elf::ElfFirmwareImage, flasher::FlashSize::_4Mb, targets::Chip};
use rocket::{response::content, State}; use rocket::{response::content, State};
#[macro_use] #[macro_use]
@ -13,18 +13,19 @@ extern crate rocket;
#[derive(Parser, Debug, Clone)] #[derive(Parser, Debug, Clone)]
#[command(author, version, about, long_about = None)] #[command(author, version, about, long_about = None)]
struct Args { struct Args {
/// chip name /// Chip name
#[arg(short, long)] #[clap(short, long)]
chip: Chip, chip: Chip,
/// path to bootloader /// Path to bootloader
#[arg(short, long)] #[clap(short, long)]
bootloader: Option<PathBuf>, bootloader: Option<PathBuf>,
/// path to partition table csv /// Path to partition table CSV
#[arg(short, long)] #[clap(short, long)]
partition_table: Option<PathBuf>, partition_table: Option<PathBuf>,
/// Path to the ELF file
elf: PathBuf, elf: PathBuf,
} }
@ -122,6 +123,23 @@ fn manifest() -> content::RawJson<&'static str> {
} }
] ]
}, },
{
"chipFamily": "ESP32-C2",
"parts": [
{
"path": "bootloader.bin",
"offset": 0
},
{
"path": "partitions.bin",
"offset": 32768
},
{
"path": "firmware.bin",
"offset": 65536
}
]
},
{ {
"chipFamily": "ESP32-C3", "chipFamily": "ESP32-C3",
"parts": [ "parts": [
@ -140,7 +158,24 @@ fn manifest() -> content::RawJson<&'static str> {
] ]
}, },
{ {
"chipFamily": "ESP32-C2", "chipFamily": "ESP32-C6",
"parts": [
{
"path": "bootloader.bin",
"offset": 0
},
{
"path": "partitions.bin",
"offset": 32768
},
{
"path": "firmware.bin",
"offset": 65536
}
]
},
{
"chipFamily": "ESP32-H2",
"parts": [ "parts": [
{ {
"path": "bootloader.bin", "path": "bootloader.bin",
@ -231,18 +266,14 @@ fn prepare() -> Result<PartsData> {
Chip::Esp32s3 => "ESP32-S3", Chip::Esp32s3 => "ESP32-S3",
Chip::Esp8266 => "ESP8266", Chip::Esp8266 => "ESP8266",
Chip::Esp32c2 => "ESP32-C2", Chip::Esp32c2 => "ESP32-C2",
Chip::Esp32c6 => "ESP32-C6",
Chip::Esp32h2 => "ESP32-H2",
_ => panic!("Unsupported chip"),
}; };
let image = chip.into_target().get_flash_image( let image =
&firmware, chip.into_target()
b, .get_flash_image(&firmware, b, p, None, None, None, Some(_4Mb), None)?;
p,
None,
None,
None,
Some(Flash4Mb),
None,
)?;
let parts: Vec<_> = image.flash_segments().collect(); let parts: Vec<_> = image.flash_segments().collect();
let bootloader = &parts[0]; let bootloader = &parts[0];
let partitions = &parts[1]; let partitions = &parts[1];