Skip to content

Commit 209116e

Browse files
authored
fix: update ESP Self Reflasher how-to article (#613)
Update instructions for getting the component examples in order to make use of ESP-IDF Component Manager instead of cloning through Git. Signed-off-by: Almir Okato <[email protected]>
1 parent 57fc553 commit 209116e

File tree

1 file changed

+27
-14
lines changed
  • content/blog/2025/01/how-to-migrate-from-idf-bootloader-to-mcuboot-using-esp-self-reflasher

1 file changed

+27
-14
lines changed

content/blog/2025/01/how-to-migrate-from-idf-bootloader-to-mcuboot-using-esp-self-reflasher/index.md

Lines changed: 27 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
---
22
title: "How to migrate from IDF Bootloader to MCUboot using ESP Self-Reflasher"
33
date: 2025-01-16
4+
lastmod: 2025-12-09
45
showAuthor: false
56
authors:
67
- "almir-okato"
@@ -66,12 +67,22 @@ The component has examples for each way of operation. Both will be used in this
6667

6768
Besides **ESP-IDF** (see [ESP-IDF Getting Started](https://docs.espressif.com/projects/esp-idf/en/stable/esp32/get-started/index.html)), the following is required:
6869

69-
- **ESP Self-Reflasher**: clone it to `<IDF_DIR>/components` using Git:
70+
- **ESP Self-Reflasher** examples: as shown in this guide, it is possible to create local copies of the **ESP Self-Reflasher** examples:
7071

71-
```bash
72-
cd <IDF_DIR>/components
73-
git clone https://github.com/espressif/esp-self-reflasher.git
74-
```
72+
```bash
73+
idf.py create-project-from-example 'espressif/esp-self-reflasher:boot_swap_download_example'
74+
```
75+
76+
```bash
77+
idf.py create-project-from-example 'espressif/esp-self-reflasher:boot_swap_embedded_example'
78+
```
79+
80+
**ESP Self-Reflasher** component can also be installed into a project via the ESP-IDF Component Manager:
81+
82+
```bash
83+
idf.py add-dependency "espressif/esp-self-reflasher"
84+
idf.py reconfigure
85+
```
7586

7687
- **NuttX**: in order to build the application that will be migrated to, set the **NuttX** workspace. See [NuttX Getting Started](https://developer.espressif.com/blog/2020/11/nuttx-getting-started/).
7788

@@ -129,17 +140,18 @@ Besides **ESP-IDF** (see [ESP-IDF Getting Started](https://docs.espressif.com/pr
129140

130141
The **ESP Self-Reflasher** component provides the example `boot_swap_download_example`. This can be used as a starting point for the reflashing application.
131142

132-
1. Navigate to the example directory.
143+
1. Navigate to a directory of your choice and create a local copy from the `boot_swap_download_example`.
133144

134145
```bash
135-
cd <IDF_DIR>/components/esp-self-reflasher/examples/boot_swap_download_example/
146+
idf.py create-project-from-example 'espressif/esp-self-reflasher:boot_swap_download_example'
147+
cd <SAMPLE_DIR>/boot_swap_download_example/
136148
```
137149

138150
2. First, copy the *final target images* (**NuttX** and **MCUboot** binaries) to the directory that will be served for HTTP download.
139151

140152
```bash
141-
cp <NUTTX_DIR>/nuttx.bin <IDF_DIR>/components/esp-self-reflasher/examples/boot_swap_download_example/example_bin_dir/app_upd.bin
142-
cp <NUTTX_DIR>/mcuboot-esp32.bin <IDF_DIR>/components/esp-self-reflasher/examples/boot_swap_download_example/example_bin_dir/mcuboot-esp32.bin
153+
cp <NUTTX_DIR>/nuttx.bin <SAMPLE_DIR>/boot_swap_download_example/example_bin_dir/app_upd.bin
154+
cp <NUTTX_DIR>/mcuboot-esp32.bin <SAMPLE_DIR>/boot_swap_download_example/example_bin_dir/mcuboot-esp32.bin
143155
```
144156

145157
3. Configure the example:
@@ -180,16 +192,17 @@ Alternatively, **ESP Self-Reflasher** component can be used without network conn
180192

181193
If the constraint is not a problem, `boot_swap_embedded_example` can be used as start point for the reflashing application. Note that for this guide, the size of the OTA partitions on the partition table may be changed (see next section).
182194

183-
1. Navigate to the example directory.
195+
1. Navigate to a directory of your choice and create a local copy from the `boot_swap_embedded_example`.
184196

185197
```bash
186-
cd <IDF_DIR>/components/esp-self-reflasher/examples/boot_swap_embedded_example/
198+
idf.py create-project-from-example 'espressif/esp-self-reflasher:boot_swap_embedded_example'
199+
cd <SAMPLE_DIR>/boot_swap_embedded_example/
187200
```
188201

189202
2. In this example, the **MCUboot** bootloader and target reflashing image needs to be merged in one binary as it goes embedded to the application.
190203

191204
```bash
192-
esptool.py -c esp32 merge_bin --output <IDF_DIR>/components/esp-self-reflasher/examples/boot_swap_embedded_example/example_bin_dir/app_upd.merged.bin 0x0000 <NUTTX_DIR>/mcuboot-esp32.bin 0xF000 <NUTTX_DIR>/nuttx.bin
205+
esptool.py -c esp32 merge_bin --output <SAMPLE_DIR>/boot_swap_embedded_example/example_bin_dir/app_upd.merged.bin 0x0000 <NUTTX_DIR>/mcuboot-esp32.bin 0xF000 <NUTTX_DIR>/nuttx.bin
193206
```
194207

195208
>**Note:**
@@ -260,7 +273,7 @@ The **ESP-IDF**'s `simple_ota_example` will be used as the hypothetical **ESP-ID
260273
8. Copy the reflashing application binary that was build in the previous section to the directory where the HTTP server will run:
261274
262275
```bash
263-
cp <IDF_DIR>/components/esp-self-reflasher/examples/boot_swap_<MODE>_example/build/boot_swap_<MODE>_example.bin <HTTP_SERVER_DIR>
276+
cp <SAMPLE_DIR>/boot_swap_<MODE>_example/build/boot_swap_<MODE>_example.bin <HTTP_SERVER_DIR>
264277
```
265278
266279
9. Open a new bash and start the HTTP server for the OTA application. Here is a suggestion for creating the HTTP server using Python:
@@ -275,7 +288,7 @@ The **ESP-IDF**'s `simple_ota_example` will be used as the hypothetical **ESP-ID
275288
If the `boot_swap_download_example` was used, copy the target reflashing images to the <HTTP_SERVER_DIR> or open another bash and start the HTTP server from where the reflashing images will be downloaded (watch for the <PORT> that cannot be the same):
276289
277290
```bash
278-
cd <IDF_DIR>/components/esp-self-reflasher/examples/boot_swap_download_example/example_bin_dir/
291+
cd <SAMPLE_DIR>/boot_swap_download_example/example_bin_dir/
279292
sudo python -m http.server -b <HOST_IP> <HOST_PORT>
280293
# e.g. sudo python -m http.server -b 192.168.0.100 8071
281294
```

0 commit comments

Comments
 (0)