Expand ESP32 OTA partition migration across infrastructure roles
This commit is contained in:
1 parent
d68601b358
commit
e7f6d529a0
11 files changed
+651
-101
No files matched your search
@@ -12,6 +12,7 @@ namespace esp32_partition_migration {
|
||||
|
||||
constexpr uint32_t kRequiredFlashBytes = 16U * 1024U * 1024U;
|
||||
constexpr uint32_t kXiaoRequiredFlashBytes = 8U * 1024U * 1024U;
|
||||
constexpr uint32_t kSmallRequiredFlashBytes = 4U * 1024U * 1024U;
|
||||
constexpr uint32_t kPartitionTableAddress = 0x8000;
|
||||
constexpr uint32_t kPartitionTableBytes = 0x1000;
|
||||
constexpr uint32_t kSectorBytes = 0x1000;
|
||||
@@ -59,6 +60,17 @@ constexpr PartitionGeometry kExpanded8MBLayout = {
|
||||
0x670000, 0x180000,
|
||||
};
|
||||
|
||||
// variants/dual_ota_full_4MB.csv. This is the largest practical dual-OTA
|
||||
// layout on a 4 MiB board. It preserves only a 64 KiB SPIFFS region, so the
|
||||
// private identity must be staged in stable NVS before the table is changed.
|
||||
constexpr PartitionGeometry kExpanded4MBLayout = {
|
||||
0x9000, 0x5000,
|
||||
0xE000, 0x2000,
|
||||
0x10000, 0x1F0000,
|
||||
0x200000, 0x1F0000,
|
||||
0x3F0000, 0x10000,
|
||||
};
|
||||
|
||||
constexpr bool sameGeometry(const PartitionGeometry& left,
|
||||
const PartitionGeometry& right) {
|
||||
return left.nvs_address == right.nvs_address
|
||||
@@ -83,7 +95,10 @@ constexpr bool isExpandedLayout(const PartitionGeometry& geometry) {
|
||||
|
||||
constexpr bool canMigrate(uint32_t flash_bytes,
|
||||
const PartitionGeometry& geometry) {
|
||||
return flash_bytes >= kRequiredFlashBytes && isLegacyLayout(geometry);
|
||||
return (flash_bytes == kSmallRequiredFlashBytes
|
||||
|| flash_bytes == kXiaoRequiredFlashBytes
|
||||
|| flash_bytes == kRequiredFlashBytes)
|
||||
&& isLegacyLayout(geometry);
|
||||
}
|
||||
|
||||
// Binary prefix generated from Arduino-ESP32's default_16MB.csv by
|
||||
@@ -160,6 +175,29 @@ constexpr uint8_t kExpanded8MBPartitionTablePrefix[] = {
|
||||
constexpr size_t kExpanded8MBPartitionTablePrefixBytes =
|
||||
sizeof(kExpanded8MBPartitionTablePrefix);
|
||||
|
||||
// Generated from variants/dual_ota_full_4MB.csv with gen_esp32part.py.
|
||||
constexpr uint8_t kExpanded4MBPartitionTablePrefix[] = {
|
||||
0xAA, 0x50, 0x01, 0x02, 0x00, 0x90, 0x00, 0x00, 0x00, 0x50, 0x00, 0x00,
|
||||
0x6E, 0x76, 0x73, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xAA, 0x50, 0x01, 0x00,
|
||||
0x00, 0xE0, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x6F, 0x74, 0x61, 0x64,
|
||||
0x61, 0x74, 0x61, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0xAA, 0x50, 0x00, 0x10, 0x00, 0x00, 0x01, 0x00,
|
||||
0x00, 0x00, 0x1F, 0x00, 0x61, 0x70, 0x70, 0x30, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0xAA, 0x50, 0x00, 0x11, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x1F, 0x00,
|
||||
0x61, 0x70, 0x70, 0x31, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xAA, 0x50, 0x01, 0x82,
|
||||
0x00, 0x00, 0x3F, 0x00, 0x00, 0x00, 0x01, 0x00, 0x73, 0x70, 0x69, 0x66,
|
||||
0x66, 0x73, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0xEB, 0xEB, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x80, 0xC5, 0x69, 0x36,
|
||||
0x65, 0xF8, 0xAB, 0x77, 0x12, 0x5A, 0xB8, 0x36, 0xBD, 0x27, 0xF1, 0x1F,
|
||||
};
|
||||
|
||||
constexpr size_t kExpanded4MBPartitionTablePrefixBytes =
|
||||
sizeof(kExpanded4MBPartitionTablePrefix);
|
||||
|
||||
struct TargetPlan {
|
||||
uint32_t flash_bytes;
|
||||
const char* name;
|
||||
@@ -174,6 +212,12 @@ constexpr TargetPlan kTarget8MB = {
|
||||
kExpanded8MBPartitionTablePrefixBytes,
|
||||
};
|
||||
|
||||
constexpr TargetPlan kTarget4MB = {
|
||||
kSmallRequiredFlashBytes, "MeshCore dual_ota_full_4MB",
|
||||
kExpanded4MBLayout, kExpanded4MBPartitionTablePrefix,
|
||||
kExpanded4MBPartitionTablePrefixBytes,
|
||||
};
|
||||
|
||||
constexpr TargetPlan kTarget16MB = {
|
||||
kRequiredFlashBytes, "Arduino default_16MB",
|
||||
kExpandedLayout, kExpandedPartitionTablePrefix,
|
||||
@@ -181,7 +225,8 @@ constexpr TargetPlan kTarget16MB = {
|
||||
};
|
||||
|
||||
constexpr const TargetPlan* targetForFlash(uint32_t flash_bytes) {
|
||||
return flash_bytes == kXiaoRequiredFlashBytes ? &kTarget8MB
|
||||
return flash_bytes == kSmallRequiredFlashBytes ? &kTarget4MB
|
||||
: flash_bytes == kXiaoRequiredFlashBytes ? &kTarget8MB
|
||||
: flash_bytes == kRequiredFlashBytes ? &kTarget16MB
|
||||
: nullptr;
|
||||
}
|
||||
@@ -273,9 +318,21 @@ static_assert(kExpanded8MBLayout.app0_address + kExpanded8MBLayout.app0_size
|
||||
static_assert(kExpanded8MBLayout.app1_address + kExpanded8MBLayout.app1_size
|
||||
== kExpanded8MBLayout.spiffs_address,
|
||||
"8 MiB expanded SPIFFS must follow both OTA slots");
|
||||
static_assert(kExpanded4MBLayout.app0_address + kExpanded4MBLayout.app0_size
|
||||
== kExpanded4MBLayout.app1_address,
|
||||
"4 MiB expanded OTA slots must be adjacent");
|
||||
static_assert(kExpanded4MBLayout.app1_address + kExpanded4MBLayout.app1_size
|
||||
== kExpanded4MBLayout.spiffs_address,
|
||||
"4 MiB expanded SPIFFS must follow both OTA slots");
|
||||
static_assert(kExpanded4MBLayout.spiffs_address + kExpanded4MBLayout.spiffs_size
|
||||
== kSmallRequiredFlashBytes,
|
||||
"4 MiB target partitions must fit physical flash");
|
||||
static_assert(kExpandedPartitionTablePrefixBytes
|
||||
== kExpanded8MBPartitionTablePrefixBytes,
|
||||
"target table buffers share one fixed DRAM size");
|
||||
static_assert(kExpanded4MBPartitionTablePrefixBytes
|
||||
<= kExpandedPartitionTablePrefixBytes,
|
||||
"4 MiB partition table must fit the shared DRAM buffer");
|
||||
|
||||
} // namespace esp32_partition_migration
|
||||
} // namespace mesh
|
||||
Reference in new issue
Block a user