xively / xively-client-c

The official and highly portable Xively C Client designed for embedded platforms.
Other
18 stars 22 forks source link

Feature/ESP32 Over The Air firmware updates #160

Closed Palantir555 closed 6 years ago

Palantir555 commented 7 years ago

[ Description ]

Fix SFT use-after-free bug. A file was being closed before its read buffer was copied, which caused occasional buffer corruptions.

Working OTA firmware updates for the ESP32:

  1. Implemented the ESP32's file and fwu BSPs
  2. Implement sdkconfig.defaults with default project configuration
  3. Create a partition for a FAT Filesystem, to be consumed by the SFT logic
  4. Updated the example to use OTA firmware updates
  5. Updated ESP32 preset to enable the control topic and SFT
  6. Updated the example to initialize the Xively Client after the device is connected to WiFi, so the SNTP process isn't started any earlier
  7. Improve timing of the GPIO button debouncer
  8. Fixed an 'unused variable' warning in the protobuf code that caused the libxively.a build to fail

[ JIRA ] ESP32 SFT Implementation https://jira.3amlabs.net/browse/XCL-3080

[ Reviewer ] @atigyi

[ QA ] My device successfully updates its firmware. I've tried multiple times, disconnected the device while it downloaded the new image, and other manual testing. Everything seems to be working correctly.

Sometimes, the ESP32's API fails to write the last chunk in a firmware update. The issue can be resolved running make flash_erase and re-flashing the device.

[ Release Notes ] ESP32 now supports firmware updates over MQTT using Xively's Secure File Transfer protocol.

atigyi commented 6 years ago

I see three .bin files in the PR:

I think I know what the 2nd and 3rd is, but what is 1st? Bootloader? I ask this because I don't see what doest bootloader do on ESP32 if not the FW rollback. But FW rollback is not there, so why is there a bootloader.bin file?

Palantir555 commented 6 years ago

@atigyi I think the bootloader's build configuration can be easily modified with the SDK's configuration tool. That means we can't rely on other users' bootloaders being built with compatible settings, or flashed to the same address as specified by our partition table.

This is the command used to flash the device -- It includes the bootloader's binary and address.

You reminded me to add the compiled partitions table to the repo, though. Forgot that one 😅

Palantir555 commented 6 years ago

@atigyi I've implemented the changes you suggested. Please, approve for release

atigyi commented 6 years ago

approved!! 👍 great job!!