arduino-esp32/libraries
robertpoll c18d50cb91
Use esp_partition_* functions in Updater.cpp (#3898)
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.
2020-09-30 15:06:19 +03:00
..
ArduinoOTA Extend logging of ArduinoOTA (#3217) 2019-09-16 19:54:21 +03:00
AsyncUDP Update AsyncUDP library.json (#2837) 2019-06-05 13:43:15 +02:00
AzureIoT@67dfa4f31e Add submodule of Azure IoT library (#1448) 2018-05-31 14:52:02 +02:00
BLE Fix BLEClient disconnect bug (#3876) 2020-09-30 15:01:02 +03:00
BluetoothSerial Fix SerialBT.flush (#3579) 2020-01-20 22:34:57 +02:00
DNSServer Update CaptivePortal.ino (#3628) 2020-01-20 16:04:21 +02:00
EEPROM fix EEPROM class example (#3786) 2020-09-30 14:43:05 +03:00
ESP32 ESP.getChipModel() and ESP.getChipCores() (#3847) 2020-09-30 14:57:36 +03:00
ESPmDNS fix empty reply from server error (#2903) 2019-07-09 19:39:12 +03:00
FFat Added file.close to examples (#3611) 2020-01-20 16:47:40 +02:00
FS workaround for FS implementations that do not support fflush() (#2596) 2019-04-09 21:15:21 +02:00
HTTPClient Set TLS cert options before calling connect on client, so verify works (#3774) 2020-09-30 14:41:03 +03:00
HTTPUpdate Fix Timeout Bug in WebServer (#2938) 2019-07-09 19:27:24 +03:00
NetBIOS Update IDF to aaf1239 (#1539) 2018-06-27 09:01:06 +02:00
Preferences Refactored use of LOG_X(LOG_TAG, ...) to log_x(...) (#2672) 2019-04-15 17:26:35 +02:00
SD Added a parameter for max files in SD (#2563) 2019-04-09 21:07:25 +02:00
SD_MMC Update SD_MMC.cpp (#4020) 2020-05-22 11:07:40 +03:00
SimpleBLE Update IDF to aaf1239 (#1539) 2018-06-27 09:01:06 +02:00
SPI Update SPI.h 2020-09-30 14:34:37 +03:00
SPIFFS Added file.close to examples (#3611) 2020-01-20 16:47:40 +02:00
Ticker Fix long Ticker period conversion: cast ms to uint64_t when calculating us (#3175) 2019-09-05 10:34:47 +03:00
Update Use esp_partition_* functions in Updater.cpp (#3898) 2020-09-30 15:06:19 +03:00
WebServer Add Uri with support for regexUri and globUri (#3441) 2020-01-20 15:21:01 +02:00
WiFi fix typo in WiFiMulti (#3737) 2020-09-30 14:37:21 +03:00
WiFiClientSecure Update README.md (#3653) 2020-01-21 12:35:05 +02:00
Wire Add Wire:setPins(sda, scl) 2020-07-19 02:21:15 +03:00
README.md Added a description README.md for libraries (#3349) 2019-10-14 20:37:09 +03:00

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)