blob: fa72fb3085af626eb1bdb1f214725ec393bca7ca [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
17## Installing Requirements and Dependencies
18
191. Install additional packages required for development with MCUboot:
20
21```
22 cd ~/mcuboot # or to your directory where mcuboot is cloned
23 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
323. Next, get the mbedtls submodule required by MCUboot.
33```
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.