Adds a 12K OTA stub 3rd stage bootloader, which reads new firmware from the LittleFS filesystem and flashes on reboot. By storing the OTA commands in a file in flash, it is possible to recover from a power failure during OTA programming. On power resume, the OTA block will simply re-program from the beginning. Support cryptographic signed OTA updates, if desired. Includes host-side signing logic via openssl. Add PicoOTA library which encapsulates the file format for the updater, including CRC32 checking. Add LEAmDNS support to allow Arduino IDE discovery Add ArduinoOTA class for IDE uploads Add MD5Builder class Add Updater class which supports writing and validating cryptographically signed binaries from any source (http, Ethernet, WiFi, Serial, etc.) Add documentation and readmes.
50 lines
1.5 KiB
C
50 lines
1.5 KiB
C
/*
|
|
ota_command.h - OTA stub that copies from LittleFS to flash
|
|
Copyright (c) 2022 Earle F. Philhower, III. All rights reserved.
|
|
|
|
This library is free software; you can redistribute it and/or
|
|
modify it under the terms of the GNU Lesser General Public
|
|
License as published by the Free Software Foundation; either
|
|
version 2.1 of the License, or (at your option) any later version.
|
|
|
|
This library is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Lesser General Public License for more details.
|
|
|
|
You should have received a copy of the GNU Lesser General Public
|
|
License along with this library; if not, write to the Free Software
|
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <stdint.h>
|
|
|
|
#define _OTA_WRITE 1
|
|
#define _OTA_VERIFY 1
|
|
|
|
typedef struct {
|
|
uint32_t command;
|
|
union {
|
|
struct {
|
|
char filename[64];
|
|
uint32_t fileOffset;
|
|
uint32_t fileLength;
|
|
uint32_t flashAddress; // Normally XIP_BASE
|
|
} write;
|
|
};
|
|
} commandEntry;
|
|
|
|
// Must fit within 4K page
|
|
typedef struct {
|
|
uint8_t sign[8]; // "Pico OTA"
|
|
|
|
// List of operations
|
|
uint32_t count;
|
|
commandEntry cmd[8];
|
|
|
|
uint32_t crc32; // CRC32 over just the contents of this struct, up until just before this value
|
|
} OTACmdPage;
|
|
|
|
#define _OTA_COMMAND_FILE "otacommand.bin"
|