Go to file
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
.github Update PlatformIO CI script (#4307) 2020-08-31 18:06:34 +03:00
cores/esp32 Use esp_partition_* functions in Updater.cpp (#3898) 2020-09-30 15:06:19 +03:00
docs Added documentation regarding delay() resolution in esp-idf component (#3014) 2020-09-30 14:17:53 +03:00
libraries Use esp_partition_* functions in Updater.cpp (#3898) 2020-09-30 15:06:19 +03:00
package Add ARM toolchain 2019-10-01 21:48:03 +03:00
tools Allow using custom linker scripts (#3735) 2020-05-04 16:47:14 +03:00
variants added new board Logsens V1p1 (#3880) 2020-09-30 15:01:51 +03:00
.gitignore M5Stack's product offering includes various ESP32-based camera devices. (#4030) 2020-06-01 01:41:56 +03:00
.gitmodules Set ESP-IDF to 3.2 (#2662) 2019-04-12 15:43:53 +02:00
.travis.yml Use Github Actions for release (#3309) 2019-10-01 10:44:04 +03:00
boards.txt added new board Logsens V1p1 (#3880) 2020-09-30 15:01:51 +03:00
CMakeLists.txt Add OTA update feature 2020-08-25 11:01:58 +03:00
component.mk Fix compilation errors when used as IDF component 2019-01-26 21:37:03 +01:00
Kconfig.projbuild Make a selective menuconfig option for FFat (#2966) 2019-07-09 19:14:53 +03:00
LICENSE.md Add LGPL 2.1 License 2019-04-16 03:08:50 +02:00
Makefile.projbuild Remove duplicate ota_data flashing under IDF 2018-08-16 13:34:47 +02:00
package.json Initial version of build script for @PlatformIO; CI integration for Linux, macOS and Windows (#153) 2017-01-28 14:19:56 +02:00
platform.txt Process compiler.libraries.ldflags (#3783) 2020-09-30 14:42:04 +03:00
programmers.txt initial import 2016-10-06 07:09:44 -06:00
README.md Update README.md (#3353) 2019-10-14 20:38:04 +03:00

Arduino core for the ESP32

Build Status

Need help or have a question? Join the chat at https://gitter.im/espressif/arduino-esp32

Contents

Development Status

Latest stable release Release Version Release Date Downloads

Latest development release Development Version Development Date Downloads

Installation Instructions

Decoding exceptions

You can use EspExceptionDecoder to get meaningful call trace.

Issue/Bug report template

Before reporting an issue, make sure you've searched for similar one that was already created. Also make sure to go through all the issues labelled as for reference.

Finally, if you are sure no one else had the issue, follow the ISSUE_TEMPLATE while reporting any issue.

ESP32Dev Board PINMAP

Pin Functions

Tip

Sometimes to program ESP32 via serial you must keep GPIO0 LOW during the programming process