ESP32 LoRa for dummys - Firmware backup & restore
Un BACKUP (download) consiste en hacer una copia de seguridad de datos o programas y un RESTORE (upload) consiste en recuperarlos.
Una de las utilidades para hacer backups y restores de un ESP32 es el programa ESPTOLL escrito en Pytom.
Para poderlo usar necesitamos:
- Descargar e instalar el interprete de Python dpara nuestro sistema operativo esde https://www.python.org, en caso de que no lo tengamos ya instalado. (Python es un lenguaje de programación muy sencillo que se ha hecho muy popular para escribir programas y utilidades)
- Descargar los programas desde las librerias correspondientes, que con Python es muy sencillo pues basta con colocarnos en un terminal y ejecutar el comando PIP de Pythom
- Version de Python
- python3 --version
Python 3.12.3
- Actualizar el programa PIP:
- python3 -m pip install --upgrade pip
- Descargar el programa ESPTOOL :
- python3 -m pip install esptool
- Instalar el programa ESPTOOL :
- python3 -m esptool
- Actualizar el programa ESPTOOL
- python3 -m pip install --upgrade esptool
- Comprobar versión
- python3 esptool.py version
- esptool.py v4.8.1
- Comprobar el chip
- python3 esptool.py chip_id
esptool.py v4.8.1Found 2 serial portsSerial port /dev/cu.wchusbserialXXXXXXXXXXXConnecting.........Detecting chip type... Unsupported detection protocol, switching and trying again...Connecting....Detecting chip type... ESP32Chip is ESP32-PICO-D4 (revision v1.1)Features: WiFi, BT, Dual Core, 240MHz, Embedded Flash, VRef calibration in efuse, Coding Scheme NoneCrystal is 40MHzMAC: XX:XX:XX:XX:XX:XXUploading stub...Running stub...Stub running...Warning: ESP32 has no Chip ID. Reading MAC instead.MAC: XX:XX:XX:XX:XX:XXHard resetting via RTS pin...
- Descargar / Hacer Backup o volcado de la memoria flash de 4M del ESP32 (Para ello hay que cambiar el parámetro --port del comando por el que vemos en Arduino IDE, atención que cambia cada vez que conectamos una placa distinta):
- python3 esptool.py -b 115200 --port /dev/cu.wchusbseriaXXXXXXXXXXXX read_flash 0x00000 0x400000 flash_4M.bin
- Antes hacer un restore o de cargar hay que borrar la meoria flash previamente:
- python3 esptool.py --port /dev/cu.wchusbserialXXXXXXXXXXXX erase_flash
esptool.py v4.8.1Serial port /dev/cu.wchusbseriaXXXXXXXXXXXXConnecting....Detecting chip type... Unsupported detection protocol, switching and trying again...Connecting....Detecting chip type... ESP32Chip is ESP32-PICO-D4 (revision v1.1)Features: WiFi, BT, Dual Core, 240MHz, Embedded Flash, VRef calibration in efuse, Coding Scheme NoneCrystal is 40MHzMAC: XX:XX:XX:XX:XX:XXUploading stub...Running stub...Stub running...Erasing flash (this may take a while)...Chip erase completed successfully in 3.5sHard resetting via RTS pin...
- Hacer restore o cargar 4M:
python3 esptool.py --port /dev/cu.wchusbserial58741248741 write_flash 0x00000 flash_4M.bin
esptool.py v4.8.1Serial port /dev/cu.wchusbseriaXXXXXXXXXXXXConnecting.........Detecting chip type... Unsupported detection protocol, switching and trying again...Connecting....Detecting chip type... ESP32Chip is ESP32-PICO-D4 (revision v1.1)Features: WiFi, BT, Dual Core, 240MHz, Embedded Flash, VRef calibration in efuse, Coding Scheme NoneCrystal is 40MHzMAC: XX:XX:XX:XX:XX:XXUploading stub...Running stub...Stub running...Configuring flash size...Flash will be erased from 0x00000000 to 0x003fffff...Compressed 4194304 bytes to 836827...Wrote 4194304 bytes (836827 compressed) at 0x00000000 in 79.7 seconds (effective 421.0 kbit/s)...Hash of data verified.Leaving...Hard resetting via RTS pin...
Comandos de ESPTOOL
Run esptool.py {command} -h for additional help
load_ram Download an image to RAM and execute
dump_mem Dump arbitrary memory to disk
read_mem Read arbitrary memory location
write_mem Read-modify-write to arbitrary memory location
write_flash Write a binary blob to flash
run Run application code in flash
image_info Dump headers from a binary file (bootloader or application)
make_image Create an application image from binary files
elf2image Create an application image from ELF file
read_mac Read MAC address from OTP ROM
chip_id Read Chip ID from OTP ROM
flash_id Read SPI flash manufacturer and device ID
read_flash_status Read SPI flash status register
write_flash_status Write SPI flash status register
read_flash Read SPI flash content
verify_flash Verify a binary blob against flash
erase_flash Perform Chip Erase on SPI flash
erase_region Erase a region of the flash
read_flash_sfdp Read SPI flash SFDP (Serial Flash Discoverable Parameters)
merge_bin Merge multiple raw binary files into a single file for later flashing
get_security_info Get some security-related data
version Print esptool version
Prohibida la reproducción parcial o total de este artículo sin permiso previo del autor
Comentarios
Publicar un comentario