Almir Okato | 428e2e7 | 2021-08-11 10:52:10 -0300 | [diff] [blame] | 1 | # Building and using MCUboot with Espressif's chips |
| 2 | |
| 3 | The Espressif port is build on top of ESP-IDF HAL, therefore it is required in order to build MCUboot for Espressif SoCs. |
| 4 | |
| 5 | Documentation about the MCUboot bootloader design, operation and features can be found in the [design document](design.md). |
| 6 | |
| 7 | ## SoC support availability |
| 8 | |
| 9 | The 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 Servidio | 5bc9832 | 2021-11-03 13:19:22 +0100 | [diff] [blame^] | 17 | ## Installing requirements and dependencies |
Almir Okato | 428e2e7 | 2021-08-11 10:52:10 -0300 | [diff] [blame] | 18 | |
| 19 | 1. Install additional packages required for development with MCUboot: |
| 20 | |
| 21 | ``` |
Francesco Servidio | 4ff0c18 | 2021-10-20 15:27:16 +0200 | [diff] [blame] | 22 | cd ~/mcuboot # or to your directory where MCUboot is cloned |
Almir Okato | 428e2e7 | 2021-08-11 10:52:10 -0300 | [diff] [blame] | 23 | pip3 install --user -r scripts/requirements.txt |
| 24 | ``` |
| 25 | |
| 26 | 2. Update the submodules needed by the Espressif port. This may take a while. |
| 27 | |
| 28 | ``` |
| 29 | git submodule update --init --recursive --checkout boot/espressif/hal/esp-idf |
| 30 | ``` |
| 31 | |
Francesco Servidio | 582367c | 2021-10-20 15:36:45 +0200 | [diff] [blame] | 32 | 3. Next, get the Mbed TLS submodule required by MCUboot. |
Almir Okato | 428e2e7 | 2021-08-11 10:52:10 -0300 | [diff] [blame] | 33 | ``` |
| 34 | git submodule update --init --recursive ext/mbedtls |
| 35 | ``` |
| 36 | |
| 37 | 4. Now we need to install IDF dependencies and set environment variables. This step may take some time: |
| 38 | ``` |
| 39 | cd boot/espressif/hal/esp-idf |
| 40 | ./install.sh |
| 41 | . ./export.sh |
| 42 | cd ../.. |
| 43 | ``` |
| 44 | |
| 45 | ## Building the bootloader itself |
| 46 | |
| 47 | The 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 | |
| 51 | 1. Compile and generate the ELF: |
| 52 | |
| 53 | ``` |
| 54 | cmake -DCMAKE_TOOLCHAIN_FILE=tools/toolchain-<target>.cmake -DMCUBOOT_TARGET=<target> -B build -GNinja |
| 55 | cmake --build build/ |
| 56 | ``` |
| 57 | |
| 58 | 2. Convert the ELF to the final bootloader image, ready to be flashed: |
| 59 | |
| 60 | ``` |
| 61 | esptool.py --chip <target> elf2image --flash_mode dio --flash_freq 40m -o build/mcuboot_<target>.bin build/mcuboot_<target>.elf |
| 62 | ``` |
| 63 | |
| 64 | 3. Flash MCUboot in your board: |
| 65 | |
| 66 | ``` |
| 67 | esptool.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 | |
| 70 | You may adjust the port `<PORT>` (like `/dev/ttyUSB0`) and baud rate `<BAUD>` (like `2000000`) according to the connection with your board. |