UP | HOME

ESP 8266

Table of Contents

Premessa

  1. Board : AZ-Delivery D1 R32 con chip ESP32 WROOM-32 con schema elettrico
  2. Schema
  3. file json delle specifiche delle schede:
    1. http://arduino.esp8266.com/stable/package_esp8266com_index.json;
    2. https://dl.espressif.com/dl/package_esp32_index.json
  4. Board specifica : ESP32 Arduino -> ESP32 Dev Module;
    1. per compilare con arduino-cli : arduino-cli compile –fqbn esp32:esp32:esp32 … , arduino-cli upload -p /dev/ttyUSB0 –fqbn esp32:esp32:esp32 …
  5. specifiche schede
  6. Riscontrato problema con la porta seriale:
    1. verificare che sia installato il modulo python pyserial :sudo pip3 list | grep serial
    2. Se il modulo pyserial non è installato scaricare quello per la versione corrente di python;
    3. Installare il pacchetto python-is-python3 che serve a creare symlink in /usr/bin/python in quanto alcuni software hanno come path di ricerca la predetta cartella come i tools delle board di Arduino : sudo apt install python-is-python3
  7. Note of Board
  8. Forum for ESP 32
  9. ESP8266 Arduino Core’s documentation contiene una descrizione delle librerire;
  10. Arduino Cli
  11. Expressif
  12. Introduzione Platformio ambiente di sviluppo
  13. Esempi Platformio github PlatformIO
    1. new project : create path ; cd path; pio init –ide emacs –board esp32dev
    2. Build project : platformio run
    3. Upload code : platformio run –target upload
    4. Build specific environment :platformio run -e uno
    5. Upload firmware for the specific environment : platformio run -e uno –target upload
    6. Clean build files : platformio run –target clean
    7. device monitor: pio device monitor

Utility

Init

Qui una breve introduzione su schede di tipo ESP32 e sul loro sistema operativo e di come e' organizza la memoria del deispositivo

esp-flash04.jpg

Figure 1: Organizzazione della memoria

dump partition table

# Modificato
# Name,     Type, SubType, Offset,   Size, Flags
# nvs,      data, nvs,     0x9000,   0x5000,
# otadata,  data, ota,     0xe000,   0x2000,
# app0,     app,  ota_0,   0x10000,  0x1E0000,    # Aumentato da 0x140000 a 0x1E0000
# app1,     app,  ota_1,   0x1F0000, 0x1E0000,    # Aumentato da 0x140000 a 0x1E0000
# spiffs,   data, spiffs,  0x3D0000, 0x230000,

#
# Schema grafico della flash
#
#     5000      2000     1E0000    1E0000 
#     __^__   ___^___   ___^___   ___^___   ___^___
#    /     \ /       \ /       \ /       \ /       \
#   |-------|---------|---------|---------|---------|
# 9000    E000      10000     1F0000    3D0000
#    \__ __/\____ ___/ \___ ___/ \___ ___/ \___ ___/
#       v        v         v         v         v
#      nvs     tadata     app0      app1     spiffs
#
# In questo schema grafico e' inserita la partizione ota_1 che viene utilizzata come backup della
# partizione ota_0
#
# La dimensione dello spazio e' la differenza degli offset di due partizioni adiacenti, ad esempio lo spazio di ota_0 e' la
# differenza tra gli offset di ota_1-ota
#

# Modificato
# Name,   Type, SubType, Offset,   Size,      Flags
nvs,      data, nvs,     0x9000,   0x5000,
otadata,  data, ota,     0xe000,   0x2000,
app0,     app,  ota_0,   0x10000,  0x3C0000,
spiffs,   data, spiffs,  0x3D0000, 0x5000,    


#
# Schema grafico della flash
#
#      5000      2000     3C0000      5000 minore della dimensione max che e' 0x230000
#     ___^___   ___^___   ___^___   ___^___  
#    /       \ /       \ /       \ /       \ 
#   |---------|---------|---------|---------|
# 9000      E000      10000     3D0000    
#    \___ ___/ \___ ___/ \___ ___/ \___ ___/ 
#        V         V         V         V        
#       nvs     otadata     app0      spiffs
#
# In questo schema invece la partizione ota_1 e' stata eleminitata per aumetare lo spazio per il codice
# compilato. 

Per caricare una configurazione e' necessario salvarla in un file con estensione cvs e utilizzare la direttiva boardbuild.partitions del file di configurazione di platformio.ini, ad esempio se la configurazione e memorizzata nel file defaultFS.csv un esempio di platformio.ini

; PlatformIO Project Configuration File
;
;   Build options: build flags, source filter
;   Upload options: custom upload port, speed and extra flags
;   Library options: dependencies, extra library storages
;   Advanced options: extra scripting
;
; Please visit documentation for the other options and examples
; https://docs.platformio.org/page/projectconf.html

[env:esp32dev]

; esempio di inclusione del file di configurazione della flash
board_build.partitions = default_FS.csv



platform = espressif32
board = esp32dev
framework = arduino
monitor_speed = 9600
upload_port = /dev/ttyUSB0
monitor_port = /dev/ttyUSB0
debug_tool = esp-prog
debug_init_break = tbreak setup
lib_deps = 
	xreef/EByte LoRa E220 library@^1.0.8
	plerup/EspSoftwareSerial@^8.0.3
	adafruit/Adafruit Unified Sensor@^1.1.13
	beegee-tokyo/DHT sensor library for ESPx@^1.19
	adafruit/DHT sensor library@^1.4.4
	me-no-dev/ESP Async WebServer@^1.2.3
	ottowinter/ESPAsyncWebServer-esphome@^3.1.0
	mobizt/Firebase Arduino Client Library for ESP8266 and ESP32@^4.4.8




esptool --port "/dev/ttyUSB0" dump_mem 0x8000 0xc00 ptable.img
python /home/n3og3o/.platformio/packages/framework-arduinoespressif32/tools/gen_esp32part.py ptable.img mem.csv

genesp32part.py

$ ~/.platformio/packages/tool-esptoolpy/esptool.py 

esptool.py v3.3
usage: esptool [-h] [--chip {auto,esp8266,esp32,esp32s2,esp32s3beta2,esp32s3,esp32c3,esp32c6beta,esp32h2beta1,esp32h2beta2,esp32c2}] [--port PORT] [--baud BAUD]
[--before {default_reset,usb_reset,no_reset,no_reset_no_sync}] [--after {hard_reset,soft_reset,no_reset,no_reset_stub}] [--no-stub] [--trace]
[--override-vddsdio [{1.8V,1.9V,OFF}]] [--connect-attempts CONNECT_ATTEMPTS]
{load_ram,dump_mem,read_mem,write_mem,write_flash,run,image_info,make_image,elf2image,read_mac,chip_id,flash_id,read_flash_status,write_flash_status,read_flash,verify_flash,erase_flash,erase_region,merge_bin,get_security_info,version}
...

esptool.py v3.3 - Espressif chips ROM Bootloader Utility

positional arguments:
{load_ram,dump_mem,read_mem,write_mem,write_flash,run,image_info,make_image,elf2image,read_mac,chip_id,flash_id,read_flash_status,write_flash_status,read_flash,verify_flash,erase_flash,erase_region,merge_bin,get_security_info,version}
Run esptool {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 an application image
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
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

options:
-h, --help            show this help message and exit
--chip {auto,esp8266,esp32,esp32s2,esp32s3beta2,esp32s3,esp32c3,esp32c6beta,esp32h2beta1,esp32h2beta2,esp32c2}, -c {auto,esp8266,esp32,esp32s2,esp32s3beta2,esp32s3,esp32c3,esp32c6beta,esp32h2beta1,esp32h2beta2,esp32c2}
Target chip type
--port PORT, -p PORT  Serial port device
--baud BAUD, -b BAUD  Serial port baud rate used when flashing/reading
--before {default_reset,usb_reset,no_reset,no_reset_no_sync}
What to do before connecting to the chip
--after {hard_reset,soft_reset,no_reset,no_reset_stub}, -a {hard_reset,soft_reset,no_reset,no_reset_stub}
What to do after esptool.py is finished
--no-stub             Disable launching the flasher stub, only talk to ROM bootloader. Some features will not be available.
--trace, -t           Enable trace-level output of esptool.py interactions.
--override-vddsdio [{1.8V,1.9V,OFF}]
Override ESP32 VDDSDIO internal voltage regulator (use with care)
--connect-attempts CONNECT_ATTEMPTS
Number of attempts to connect, negative or 0 for infinite. Default: 7.

Read partition table

python /home/n3og3o/.platformio/packages/tool-esptoolpy/esptool.py read_flash 0x8000 0xc00 ptable.img
python gen_esp32part.py ptable.bin ptable.csv

Platformio

load file on SPIFFS

make folder "data" in a root directory
adding file in "data" folder

type pio run -t uploadfs

cancellare file : pio run -t erase

Link Utili

BLOG Sezione ARI Montecatini Terme

ARI ( Associazione Radioamatori Italiani)

PTLUG ( Linux User Group Pistoia )

ARAL ( Associazione Radiamatori Monte Amiata / Monte Labbro )

Author: ARI people

Created: 2023-10-26 gio 12:41

Validate