mirror of
https://github.com/esp-rs/espflash.git
synced 2026-03-29 18:50:52 +00:00
Add a test for the Direct Boot image format
This commit is contained in:
committed by
Jesse Braham
parent
d3e3426600
commit
fbaca200d6
@@ -57,3 +57,27 @@ impl<'a> ImageFormat<'a> for DirectBootFormat<'a> {
|
||||
Box::new(once(self.segment.borrow()))
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
pub mod tests {
|
||||
use std::fs;
|
||||
|
||||
use super::*;
|
||||
use crate::elf::ElfFirmwareImage;
|
||||
|
||||
#[test]
|
||||
fn test_direct_boot_format() {
|
||||
let input_bytes = fs::read("tests/resources/esp32c3_hal_blinky_db").unwrap();
|
||||
let expected_bin = fs::read("tests/resources/esp32c3_hal_blinky_db.bin").unwrap();
|
||||
|
||||
let image = ElfFirmwareImage::try_from(input_bytes.as_slice()).unwrap();
|
||||
let flash_image = DirectBootFormat::new(&image, 0).unwrap();
|
||||
|
||||
let segments = flash_image.flash_segments().collect::<Vec<_>>();
|
||||
assert_eq!(segments.len(), 1);
|
||||
|
||||
let buf = segments[0].data.as_ref();
|
||||
assert_eq!(expected_bin.len(), buf.len());
|
||||
assert_eq!(expected_bin.as_slice(), buf);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,20 @@
|
||||
|
||||
This document describes how the test files under `tests/resources` were generated, so that they can be re-generated in the future if needed.
|
||||
|
||||
## Direct Boot
|
||||
|
||||
```bash
|
||||
$ git clone https://github.com/esp-rs/esp-hal
|
||||
$ cd esp-hal/esp32c3-hal/
|
||||
$ cargo build --release --features=direct-boot --example=blinky
|
||||
```
|
||||
|
||||
The ELF file is located at `target/riscv32imc-unknown-none-elf/examples/blinky`
|
||||
|
||||
```bash
|
||||
$ espflash save-image --format=direct-boot --chip=esp32c3 esp32c3_hal_blinky_db.bin esp32c3_hal_blinky_db
|
||||
```
|
||||
|
||||
## IDF Bootloader
|
||||
|
||||
```bash
|
||||
|
||||
BIN
espflash/tests/resources/esp32c3_hal_blinky_db
Executable file
BIN
espflash/tests/resources/esp32c3_hal_blinky_db
Executable file
Binary file not shown.
BIN
espflash/tests/resources/esp32c3_hal_blinky_db.bin
Normal file
BIN
espflash/tests/resources/esp32c3_hal_blinky_db.bin
Normal file
Binary file not shown.
Reference in New Issue
Block a user