作成日 :
最終更新日: 2022-07-18 月 16:17
ホーム | 文書トップ | 目次

ESP32 FlashROM 書き込み

Table of Contents

書き込み

Toolchain のセットアップ方法

mkdir -p ~/esp
cd ~/esp
git clone --recursive https://github.com/espressif/esp-idf.git
cd ~/esp/esp-idf
./install.sh esp32
. ./export.sh

インストール後は下記を実行すればパスが設定され esptool.py などが使えるようになる

~/esp/esp-idf$ . ./export.sh

実行例

~/esp/esp-idf$ . ./export.sh
Setting IDF_PATH to '/home/wurly/esp/esp-idf'
Detecting the Python interpreter
Checking "python3" ...
Python 3.8.10
"python3" has been detected
Checking Python compatibility
Checking other ESP-IDF version.
Adding ESP-IDF tools to PATH...
Using Python interpreter in /home/wurly/.espressif/python_env/idf5.0_py3.8_env/bin/python
Checking if Python packages are up to date...
Skipping the download of /home/wurly/.espressif/espidf.constraints.v5.0.txt because it was downloaded recently. If you believe that this is causing you trouble then remove it manually and re-run your install script.
Constraint file: /home/wurly/.espressif/espidf.constraints.v5.0.txt
Requirement files:
 - /home/wurly/esp/esp-idf/tools/requirements/requirements.core.txt
Python being checked: /home/wurly/.espressif/python_env/idf5.0_py3.8_env/bin/python
Python requirements are satisfied.
Added the following directories to PATH:
  /home/wurly/esp/esp-idf/components/esptool_py/esptool
  /home/wurly/esp/esp-idf/components/espcoredump
  /home/wurly/esp/esp-idf/components/partition_table
  /home/wurly/esp/esp-idf/components/app_update
  /home/wurly/.espressif/tools/xtensa-esp-elf-gdb/11.2_20220529/xtensa-esp-elf-gdb/bin
  /home/wurly/.espressif/tools/xtensa-esp32-elf/esp-2022r1-RC1-11.2.0/xtensa-esp32-elf/bin
  /home/wurly/.espressif/tools/esp32ulp-elf/2.28.51-esp-20191205/esp32ulp-elf-binutils/bin
  /home/wurly/.espressif/tools/openocd-esp32/v0.11.0-esp32-20220411/openocd-esp32/bin
  /home/wurly/.espressif/python_env/idf5.0_py3.8_env/bin
  /home/wurly/esp/esp-idf/tools
Done! You can now compile ESP-IDF projects.
Go to the project directory and run:

  idf.py build

書き込み実行

$ esptool.py --chip esp32 --port /dev/ttyUSB2 --baud 921600 write_flash 0x1000 ~/bootloader.bin 0x8000 ~/partitions.bin 0x10000 nuttx.bin
esptool.py v4.1
Serial port /dev/ttyUSB2
Connecting.....
Chip is ESP32-D0WD (revision 1)
Features: WiFi, BT, Dual Core, 240MHz, VRef calibration in efuse, Coding Scheme None
Crystal is 40MHz
MAC: c4:dd:57:cb:89:60
Uploading stub...
Running stub...
Stub running...
Changing baud rate to 921600
Changed.
Configuring flash size...
Flash will be erased from 0x00001000 to 0x00006fff...
Flash will be erased from 0x00008000 to 0x00008fff...
Flash will be erased from 0x00010000 to 0x0002ffff...
Compressed 23904 bytes to 14870...
Wrote 23904 bytes (14870 compressed) at 0x00001000 in 0.5 seconds (effective 414.3 kbit/s)...
Hash of data verified.
Compressed 3072 bytes to 103...
Wrote 3072 bytes (103 compressed) at 0x00008000 in 0.0 seconds (effective 564.4 kbit/s)...
Hash of data verified.
Compressed 126992 bytes to 54112...
Wrote 126992 bytes (54112 compressed) at 0x00010000 in 1.4 seconds (effective 731.2 kbit/s)...
Hash of data verified.

Leaving...
Hard resetting via RTS pin...

Windows の Python から pip で esptool をインストールすることで直接実行できた

U:\home\wurly\work\02nuttx_esp32\nuttx>esptool.py --chip esp32 --port COM5 --baud 921600 write_flash 0x1000 ../../../bootloader.bin 0x8000 ../../../partitions.bin 0x10000 nuttx.bin
esptool.py v4.1
Serial port COM5
Connecting.....................................
Chip is ESP32-D0WD (revision 1)
Features: WiFi, BT, Dual Core, 240MHz, VRef calibration in efuse, Coding Scheme None
Crystal is 40MHz
MAC: c4:dd:57:cb:89:60
Uploading stub...
Running stub...
Stub running...
Changing baud rate to 921600
Changed.
Configuring flash size...
Flash will be erased from 0x00001000 to 0x00006fff...
Flash will be erased from 0x00008000 to 0x00008fff...
Flash will be erased from 0x00010000 to 0x0002ffff...
Compressed 23904 bytes to 14870...
Wrote 23904 bytes (14870 compressed) at 0x00001000 in 0.5 seconds (effective 413.9 kbit/s)...
Hash of data verified.
Compressed 3072 bytes to 103...
Wrote 3072 bytes (103 compressed) at 0x00008000 in 0.0 seconds (effective 527.6 kbit/s)...
Hash of data verified.
Compressed 128576 bytes to 55398...
Wrote 128576 bytes (55398 compressed) at 0x00010000 in 1.5 seconds (effective 705.0 kbit/s)...
Hash of data verified.

Leaving...
Hard resetting via RTS pin...
ホーム | 文書トップ | 目次
Created by Emacs 28.1 (Org mode 9.5.2)