c18d50cb91
Background The current implementation of Update() uses the spi_flash_* api to write and read from flash. These functions ignore the partition->encrypted flag and always write raw data to flash even if the partition is marked as encrypted. Changes in this PR Update() now uses the esp_partition_* api. Wrapper functions for esp_partition_* added to ESP.cpp. This was done to maintain a consistent approach to the way the spi_flash_* functions were used. I note though that not all of the esp-idf functions are used are wrapped, for example esp_ota_get_next_update_partition() so it may be that these should not be added? The current implementation of Update() changes the first (magic) byte of firmware to 0xFF on write, and then when the firmware is completely written changes it back to ESP_IMAGE_HEADER_MAGIC. This works without erasing the sector because flash bits can be changed from 1->0 (but not 0->1). If the flash is encrypted then the actual data written to flash will not be all ones, so this approach will not work. In addition, encrypted flash must be written in 16 byte blocks. So, instead of changing the first byte the changed code stashes the first 16 bytes, and starts writing at the 17th byte, leaving the first 16 bytes as 0xFF. Then, in _enablePartition() the stashed bytes can be successfully written. Benefits Whilst it's not possible to use encrypted flash directly from either the Arduino IDE or PIO it's reasonably straightforward to compile and flash a bootloader with the necessary support from a simple esp-idf project and then use ArduinoOTA for subsequent updates. This PR enables the use of this workflow until such time as encrypted flash is supported, and is a first (small) step toward adding support. Regardless of the above, the esp_partition_* api is recommended over the api_flash_* api. Application code should mostly use these esp_partition_* API functions instead of lower level spi_flash_* API functions. Partition table API functions do bounds checking and calculate correct offsets in flash, based on data stored in a partition table. |
||
---|---|---|
.. | ||
ArduinoOTA | ||
AsyncUDP | ||
AzureIoT@67dfa4f31e | ||
BLE | ||
BluetoothSerial | ||
DNSServer | ||
EEPROM | ||
ESP32 | ||
ESPmDNS | ||
FFat | ||
FS | ||
HTTPClient | ||
HTTPUpdate | ||
NetBIOS | ||
Preferences | ||
SD | ||
SD_MMC | ||
SimpleBLE | ||
SPI | ||
SPIFFS | ||
Ticker | ||
Update | ||
WebServer | ||
WiFi | ||
WiFiClientSecure | ||
Wire | ||
README.md |
ESP32 Libraries
arduino-esp32 includes libraries for Arduino compatibility along with some object wrappers around hardware specific devices. Examples are included in the examples folder under each library folder. The ESP32 includes additional examples which need no special drivers.
ArduinoOTA
Over The Air firmware update daemon. Use espota.py to upload to the device.
AsyncUDP
Asynchronous task driven UDP datagram client/server
AzureIoT
Library to interact with Microsoft Azure IoT services
BLE
Bluetooth Low Energy v4.2 client/server framework
BluetoothSerial
Serial to Bluetooth redirection server
DNSServer
A basic UDP DNS daemon (includes captive portal demo)
EEPROM
Arduino compatibility for EEPROM (using flash)
ESP32
Additional examples
- AnalogOut
- Camera
- ChipID
- DeepSleep
- ESPNow
- FreeRTOS
- GPIO
- HallSensor
- I2S
- ResetReason
- RMT
- Time
- Timer
- Touch
ESPmDNS
mDNS service advertising
FFat
FAT indexed filesystem on SPI flash
FS
Filesystem virtualization framework
HTTPClient
A simple HTTP client, compatible with WiFiClientSecure
HTTPUpdate
Download a firmware update from HTTPd and apply it using Update
NetBIOS
NetBIOS name advertiser
Preferences
Flash keystore using ESP32 NVS
SD
Secure Digital card filesystem using SPI access
SD_MMC
Secure Digital card filesystem using 4-lane access
SimpleBLE
Minimal BLE advertiser
SPI
Arduino compatible Serial Peripheral Interface driver (master only)
SPIFFS
SPI Flash Filesystem (see spiffs-plugin to upload to device)
Ticker
A timer to call functions on an interval
Update
Sketch Update using ESP32 OTA functionality
WebServer
A simple HTTP daemon
WiFi
Arduino compatible WiFi driver (includes Ethernet driver)
WiFiClientSecure
Arduino compatible WiFi client object using embedded encryption
Wire
Arduino compatible I2C driver (master only)