@@ -6,27 +6,29 @@ To build the flash loader:
66
77``` bash
88$ cargo build --release --feature $( CHIP_NAME) --target $( RUST_TARGET) # builds the flashing stub
9- $ target-gen elf target/$( RUST_TARGET) /release/esp-flashloader output/esp32 .yaml --update --name $( CHIP_NAME) -flashloader
9+ $ target-gen elf target/$( RUST_TARGET) /release/esp-flashloader output/$( CHIP_NAME ) .yaml --update --name $( CHIP_NAME) -flashloader
1010```
1111
1212Example for the updating the ` esp32c3 ` flash algorithm.
1313
1414``` bash
1515$ cargo build --release --features esp32c3 --target riscv32imc-unknown-none-elf
16- $ target-gen elf target/riscv32imc-unknown-none-elf/release/esp-flashloader output/esp32 .yaml --update --name esp32c3-flashloader
16+ $ target-gen elf target/riscv32imc-unknown-none-elf/release/esp-flashloader output/esp32c3 .yaml --update --name esp32c3-flashloader
1717```
1818
1919## Chip support
2020
21- | name | supported|
22- | -------| ---------|
23- | esp32c3| Y |
24- | esp32c6| Y |
21+ | name | supported |
22+ | ------- | --------- |
23+ | esp32c2 | Y |
24+ | esp32c3 | Y |
25+ | esp32c6 | Y |
26+ | esp32h2 | Y |
2527
2628## Adding new chips
2729
28301 . Add a feature for the chip inside ` Cargo.toml `
29- 2 . Add the ROM API linker script inside the ` ld ` directory.
31+ 2 . Add the [ ROM API linker script] ( https://github.com/search?q=repo%3Aespressif%2Fesp-idf++path%3A*rom.api.ld&type=code ) inside the ` ld ` directory.
30323 . Inside the ROM API linker script, add a memory section detailing where the program will be loaded.
3133 ``` c
3234 MEMORY {
@@ -35,16 +37,28 @@ $ target-gen elf target/riscv32imc-unknown-none-elf/release/esp-flashloader outp
3537 }
3638 ```
3739 It's important to note that the algorithm cannot be loaded at the start of RAM, because probe-rs has a header it loads prior to the algo hence the 64K offset.
38- 4 . Add the following snippet to the bottom of the ` main() ` function inside ` build.rs ` , adapting it for the new chip name.
40+ IRAM origin and length can be obtained from esp-hal. Eg: [ESP32-C3 memory map](https://github.com/esp-rs/esp-hal/blob/ff80b69183739d04d1cb154b8232be01c0b26fd9/esp32c3-hal/ld/db-esp32c3-memory.x#L5-L22)
41+ 4 . Add the following snippet to the ` main() ` function inside ` build.rs ` , adapting it for the new chip name.
3942 ``` rust
4043 #[cfg(feature = " esp32c3" )]
41- {
42- fs :: copy (" ld/esp32c3.x" , out_dir . join (" esp32c3.x" )). unwrap ();
43- println! (" cargo:rerun-if-changed=ld/esp32c3.x" );
44- println! (" cargo:rustc-link-arg=-Tld/esp32c3.x" );
45- }
44+ let chip = " esp32c3" ;
4645 ```
47- 5 . Follow the instructions above for building
48- 6 . Use `target - gen ` _without_ the `update ` flag to generate a new yaml algorithm .
49- 7 . merge the new flash algorithm into the the main `esp32 . yaml`
50- 8 . Upstream the new updates to probe - rs .
46+ 5 . [Define `spiconfig ` for your the target in `main . rs`](https : // github.com/search?q=repo%3Aespressif%2Fesp-idf+ets_efuse_get_spiconfig+path%3A*c3*&type=code)
47+ 6 . Follow the instructions above for building
48+ - It may fail with : `rust - lld : error : undefined symbol : <symbol >`
49+ - In this case , you need to add the missing method in the ROM API linker script .
50+ - Eg . ESP32 - C2 is missing `esp_rom_spiflash_attach `:
51+ 1 . [Search the symbol in esp - idf ](https : // github.com/search?q=repo%3Aespressif%2Fesp-idf+esp_rom_spiflash_attach+path%3A*c2*&type=code)
52+ 2 . Add it to the ROM API linker script : `PROVIDE (esp_rom_spiflash_attach = spi_flash_attach );`
53+ 7 . Use `target - gen ` _without_ the `update ` flag to generate a new yaml algorithm .
54+ 8 . Update the resulting yaml file
55+ 1 . Update `name `
56+ 2 . Update variants `name `, `type `, `core_access_options ` and `memory_map `
57+ - The first `! Nvm ` block represents the raw flash starting at 0 and up to the maximum supported external flash (check TRM for this , usually in " System and Memory/Features" )
58+ - Next `! Ram ` block corresponds to instruction bus for internal SRAM , see Internal Memory Address Mapping of TRM
59+ - Next `! Ram ` block corresponds to data bus for internal SRAM , see Internal Memory Address Mapping of TRM
60+ - Next `! Nvm ` corresponds to instruction bus for external memory , see External Memory Address Mapping of TRM
61+ - Next `! Nvm ` corresponds to data bus for external memory , see External Memory Address Mapping of TRM
62+ 3 . Add `load_address ` under `flash_algorithms ` and assing the IRAM `ORIGIN ` value (step 3 ).
63+ 9 . Merge the new flash algorithm into the the main `esp32c3 . yaml`
64+ 10 . Upstream the new updates to probe - rs .
0 commit comments