blob: e391627bf3b174d03f8266f6ab8b8a34ddb8a224 [file] [log] [blame] [view]
Almir Okato428e2e72021-08-11 10:52:10 -03001# Building and using MCUboot with Espressif's chips
2
3The Espressif port is build on top of ESP-IDF HAL, therefore it is required in order to build MCUboot for Espressif SoCs.
4
5Documentation about the MCUboot bootloader design, operation and features can be found in the [design document](design.md).
6
7## SoC support availability
8
9The current port is available for use in the following SoCs within the OSes:
10- ESP32
11 - Zephyr RTOS - _WIP_
12 - NuttX
13- ESP32-S2
14 - Zephyr RTOS - _WIP_
15 - NuttX - _WIP_
16
Francesco Servidio5bc98322021-11-03 13:19:22 +010017## Installing requirements and dependencies
Almir Okato428e2e72021-08-11 10:52:10 -030018
191. Install additional packages required for development with MCUboot:
20
21```
Francesco Servidio4ff0c182021-10-20 15:27:16 +020022 cd ~/mcuboot # or to your directory where MCUboot is cloned
Almir Okato428e2e72021-08-11 10:52:10 -030023 pip3 install --user -r scripts/requirements.txt
24```
25
262. Update the submodules needed by the Espressif port. This may take a while.
27
28```
29git submodule update --init --recursive --checkout boot/espressif/hal/esp-idf
30```
31
Francesco Servidio582367c2021-10-20 15:36:45 +0200323. Next, get the Mbed TLS submodule required by MCUboot.
Almir Okato428e2e72021-08-11 10:52:10 -030033```
34git submodule update --init --recursive ext/mbedtls
35```
36
374. Now we need to install IDF dependencies and set environment variables. This step may take some time:
38```
39cd boot/espressif/hal/esp-idf
40./install.sh
41. ./export.sh
42cd ../..
43```
44
45## Building the bootloader itself
46
47The MCUboot Espressif port bootloader is built using the toolchain and tools provided by ESP-IDF. Additional configuration related to MCUboot features and slot partitioning may be made using the `bootloader.conf`.
48
49**Note:** Replace `<target>` with the target ESP32 family (like `esp32`, `esp32s2` and others).
50
511. Compile and generate the ELF:
52
53```
54cmake -DCMAKE_TOOLCHAIN_FILE=tools/toolchain-<target>.cmake -DMCUBOOT_TARGET=<target> -B build -GNinja
55cmake --build build/
56```
57
582. Convert the ELF to the final bootloader image, ready to be flashed:
59
60```
61esptool.py --chip <target> elf2image --flash_mode dio --flash_freq 40m -o build/mcuboot_<target>.bin build/mcuboot_<target>.elf
62```
63
643. Flash MCUboot in your board:
65
66```
67esptool.py -p <PORT> -b <BAUD> --before default_reset --after hard_reset --chip <target> write_flash --flash_mode dio --flash_size detect --flash_freq 40m 0x1000 build/mcuboot_<target>.bin
68```
69
70You may adjust the port `<PORT>` (like `/dev/ttyUSB0`) and baud rate `<BAUD>` (like `2000000`) according to the connection with your board.