arduino-esp32/cores/esp32
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
..
apps/sntp Update IDF to 3.2-3276a13 and esptool.py to 2.5.0 (#1878) 2018-09-21 08:39:36 +02:00
libb64 use libbase64 macro to calculate base64 length (#2007) 2018-11-19 17:01:38 +01:00
Arduino.h Use std::abs for a float-compatible abs() function (#2738) 2019-05-11 11:18:39 +03:00
base64.cpp Base64::encode : const correctness / String by reference passing (#3314) 2019-10-02 14:29:24 +03:00
base64.h Base64::encode : const correctness / String by reference passing (#3314) 2019-10-02 14:29:24 +03:00
binary.h initial import 2016-10-06 07:09:44 -06:00
cbuf.cpp Fix cbuf not being able to hold the full length 2017-01-24 17:57:44 +02:00
cbuf.h initial import 2016-10-06 07:09:44 -06:00
Client.h Remove extra connects from Client.h (#3191) 2019-09-09 09:36:22 +03:00
esp32-hal-adc.c Use IDF's ADC Driver and Add analogReadMilliVolts (#3377) 2020-01-20 15:18:56 +02:00
esp32-hal-adc.h Use IDF's ADC Driver and Add analogReadMilliVolts (#3377) 2020-01-20 15:18:56 +02:00
esp32-hal-bt.c Fix BluetoothSerial crash when restart (#3471) 2019-11-11 18:31:09 +01:00
esp32-hal-bt.h BT define the hal methods even if BT is disabled (but return false) 2017-05-06 18:50:20 +03:00
esp32-hal-cpu.c Fix Memory leak in addApbChangeCallback() (#3560) 2019-12-30 21:35:29 +02:00
esp32-hal-cpu.h Handle APB frequency change (#2250) 2019-01-09 10:07:54 +01:00
esp32-hal-dac.c Add analogRead, touchRead, dacWrite and updated esp-idf 2016-12-08 23:43:41 +02:00
esp32-hal-dac.h Missing include gpio.h in esp32-hal-dac.h (#1512) 2018-06-19 11:33:17 +03:00
esp32-hal-gpio.c bugfix(touchpad):swap touch8 and touch9 #3584 (#3620) 2020-01-09 08:11:40 +02:00
esp32-hal-gpio.h InterruptArg should take voidFuncPtrArg as argument (#1776) 2018-09-17 23:10:13 +02:00
esp32-hal-i2c.c Fix Unused Variable Warning (#2940) 2019-07-09 19:24:35 +03:00
esp32-hal-i2c.h Wire ReSTART fix, with others (#1717) 2018-08-14 11:51:15 +02:00
esp32-hal-ledc.c Fix Memory leak in addApbChangeCallback() (#3560) 2019-12-30 21:35:29 +02:00
esp32-hal-ledc.h LEDC Driver Update 2017-01-09 18:05:30 +02:00
esp32-hal-log.h Update IDF to 3.2-3276a13 and esptool.py to 2.5.0 (#1878) 2018-09-21 08:39:36 +02:00
esp32-hal-matrix.c initial import 2016-10-06 07:09:44 -06:00
esp32-hal-matrix.h initial import 2016-10-06 07:09:44 -06:00
esp32-hal-misc.c Make yield() overridable (#2991) 2019-10-04 12:49:39 +03:00
esp32-hal-psram.c Update IDF to abea9e4c0 (#2458) 2019-02-14 16:49:30 +01:00
esp32-hal-psram.h Add Wrover Support and Option to enable SPIRAM 2018-07-03 23:03:50 +02:00
esp32-hal-rmt.c Implement rmtLoop to be able to continuously send pulses (#3650) 2020-01-20 19:43:13 +02:00
esp32-hal-rmt.h Implement rmtLoop to be able to continuously send pulses (#3650) 2020-01-20 19:43:13 +02:00
esp32-hal-sigmadelta.c Handle APB frequency change (#2250) 2019-01-09 10:07:54 +01:00
esp32-hal-sigmadelta.h fix renamed method names for SigmaDelta 2017-01-09 21:55:37 +02:00
esp32-hal-spi.c fix removeApbChangeCallback() error in spiStopBus() (#3675) 2020-01-27 00:20:19 +02:00
esp32-hal-spi.h SPI: Ensure all read-only data pointers are marked as const (#3356) 2019-10-14 20:39:27 +03:00
esp32-hal-time.c Fixed so configTime will not crash if tcpip is not initialized (#3470) 2019-11-11 15:50:56 +01:00
esp32-hal-timer.c Fix timerRestart 2019-09-24 19:25:27 +03:00
esp32-hal-timer.h Initial Timers driver 2016-12-09 17:47:30 +02:00
esp32-hal-touch.c Change Touch interrupt allocator 2017-09-28 16:44:47 +08:00
esp32-hal-touch.h Add analogRead, touchRead, dacWrite and updated esp-idf 2016-12-08 23:43:41 +02:00
esp32-hal-uart.c Fixes UART detach. Fixes #3878 (#3894) 2020-09-30 15:04:18 +03:00
esp32-hal-uart.h Fixes UART detach. Fixes #3878 (#3894) 2020-09-30 15:04:18 +03:00
esp32-hal.h Allow selecting in IDF the running core for Arduino's core tasks 2019-04-13 17:13:13 +02:00
esp8266-compat.h Convert the few remaining cr/lf files to use lf for eol. (#1316) 2018-04-16 16:34:39 +02:00
Esp.cpp Use esp_partition_* functions in Updater.cpp (#3898) 2020-09-30 15:06:19 +03:00
Esp.h Use esp_partition_* functions in Updater.cpp (#3898) 2020-09-30 15:06:19 +03:00
FunctionalInterrupt.cpp Functional interrupt (#1728) 2018-09-17 23:13:58 +02:00
FunctionalInterrupt.h Functional interrupt (#1728) 2018-09-17 23:13:58 +02:00
HardwareSerial.cpp Fixes UART detach. Fixes #3878 (#3894) 2020-09-30 15:04:18 +03:00
HardwareSerial.h Fixes UART detach. Fixes #3878 (#3894) 2020-09-30 15:04:18 +03:00
IPAddress.cpp const correctness (#89) 2016-12-12 01:32:55 +02:00
IPAddress.h const correctness (#89) 2016-12-12 01:32:55 +02:00
IPv6Address.cpp Add initial IPv6 Support 2017-01-06 00:54:50 +02:00
IPv6Address.h Add initial IPv6 Support 2017-01-06 00:54:50 +02:00
main.cpp Make yield() overridable (#2991) 2019-10-04 12:49:39 +03:00
MD5Builder.cpp initial import 2016-10-06 07:09:44 -06:00
MD5Builder.h initial import 2016-10-06 07:09:44 -06:00
pgmspace.h Fix incorrect definition of FPSTR() and move from pgmspace.h to WString.h (#1371) (#2961) 2019-07-17 10:16:47 +03:00
Print.cpp Extend Print class for 64bit integers. (#3688) 2020-09-30 14:31:36 +03:00
Print.h Extend Print class for 64bit integers. (#3688) 2020-09-30 14:31:36 +03:00
Printable.h initial import 2016-10-06 07:09:44 -06:00
Server.h Update IDF to aaf1239 (#1539) 2018-06-27 09:01:06 +02:00
stdlib_noniso.c include stdlib_noniso in Arduino.h 2016-10-26 02:13:00 +03:00
stdlib_noniso.h initial import 2016-10-06 07:09:44 -06:00
Stream.cpp Alternative Improve _uploadReadByte (#2656) 2019-04-12 12:45:35 +02:00
Stream.h Portability from ESP8266, virtual Stream member functions. (#2701) 2019-04-23 17:56:49 +03:00
StreamString.cpp StreamString SSO fix (#2736) 2019-05-11 11:16:05 +03:00
StreamString.h Convert the few remaining cr/lf files to use lf for eol. (#1316) 2018-04-16 16:34:39 +02:00
Udp.h initial import 2016-10-06 07:09:44 -06:00
WCharacter.h Wiring.h -> Arduino.h 2016-10-06 07:09:45 -06:00
wiring_private.h Do not include file that does not exist 2016-11-13 13:26:49 +02:00
wiring_pulse.c Enable pulseIn() (#140) 2017-01-20 21:49:17 +02:00
wiring_shift.c fix missing the first bit in HC589 shift in (#2448) 2019-02-14 13:11:08 +01:00
WMath.cpp Greatly reduces error rate (half, or 0 zero errors, depends on in/out ranges) for round-trip mapping at the same performance. (#3655) 2020-09-30 14:28:51 +03:00
WString.cpp Pull in ESP8266 String::replace() fixes, others (#3143) 2019-08-27 20:05:36 +03:00
WString.h WString explicit converters to reduce Flash size (#3497) 2020-01-20 15:29:16 +02:00