feature/espflash2 #1

Merged
hibas123 merged 11 commits from feature/espflash2 into main 2024-01-17 22:02:46 +00:00
3 changed files with 810 additions and 556 deletions
Showing only changes of commit c6909757ab - Show all commits

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,
} }
@ -55,11 +56,11 @@ fn index() -> content::RawHtml<&'static str> {
font-family: Arial, Helvetica, sans-serif; font-family: Arial, Helvetica, sans-serif;
color: #343434; color: #343434;
} }
h1 { h1 {
margin-left: 40px; margin-left: 40px;
} }
</style> </style>
</head> </head>
<body> <body>
<center> <center>
@ -106,89 +107,123 @@ fn manifest() -> content::RawJson<&'static str> {
"new_install_prompt_erase": true, "new_install_prompt_erase": true,
"builds": [ "builds": [
{ {
"chipFamily": "ESP32", "chipFamily": "ESP32",
"parts": [ "parts": [
{ {
"path": "bootloader.bin", "path": "bootloader.bin",
"offset": 4096 "offset": 4096
}, },
{ {
"path": "partitions.bin", "path": "partitions.bin",
"offset": 32768 "offset": 32768
}, },
{ {
"path": "firmware.bin", "path": "firmware.bin",
"offset": 65536 "offset": 65536
} }
] ]
},
{
"chipFamily": "ESP32-C3",
"parts": [
{
"path": "bootloader.bin",
"offset": 0
},
{
"path": "partitions.bin",
"offset": 32768
},
{
"path": "firmware.bin",
"offset": 65536
}
]
}, },
{ {
"chipFamily": "ESP32-C2", "chipFamily": "ESP32-C2",
"parts": [ "parts": [
{ {
"path": "bootloader.bin", "path": "bootloader.bin",
"offset": 0 "offset": 0
}, },
{ {
"path": "partitions.bin", "path": "partitions.bin",
"offset": 32768 "offset": 32768
}, },
{ {
"path": "firmware.bin", "path": "firmware.bin",
"offset": 65536 "offset": 65536
} }
] ]
},
{
"chipFamily": "ESP32-S2",
"parts": [
{
"path": "bootloader.bin",
"offset": 4096
},
{
"path": "partitions.bin",
"offset": 32768
},
{
"path": "firmware.bin",
"offset": 65536
}
]
}, },
{ {
"chipFamily": "ESP32-S3", "chipFamily": "ESP32-C3",
"parts": [ "parts": [
{ {
"path": "bootloader.bin", "path": "bootloader.bin",
"offset": 0 "offset": 0
}, },
{ {
"path": "partitions.bin", "path": "partitions.bin",
"offset": 32768 "offset": 32768
}, },
{ {
"path": "firmware.bin", "path": "firmware.bin",
"offset": 65536 "offset": 65536
} }
] ]
},
{
"chipFamily": "ESP32-C6",
"parts": [
{
"path": "bootloader.bin",
"offset": 0
},
{
"path": "partitions.bin",
"offset": 32768
},
{
"path": "firmware.bin",
"offset": 65536
}
]
},
{
"chipFamily": "ESP32-H2",
"parts": [
{
"path": "bootloader.bin",
"offset": 0
},
{
"path": "partitions.bin",
"offset": 32768
},
{
"path": "firmware.bin",
"offset": 65536
}
]
},
{
"chipFamily": "ESP32-S2",
"parts": [
{
"path": "bootloader.bin",
"offset": 4096
},
{
"path": "partitions.bin",
"offset": 32768
},
{
"path": "firmware.bin",
"offset": 65536
}
]
},
{
"chipFamily": "ESP32-S3",
"parts": [
{
"path": "bootloader.bin",
"offset": 0
},
{
"path": "partitions.bin",
"offset": 32768
},
{
"path": "firmware.bin",
"offset": 65536
}
]
} }
] ]
} }
@ -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];