[core] Provide entire flash as "root" partition

This commit is contained in:
Kuba Szczodrzyński
2022-06-19 14:18:13 +02:00
parent cae03d54d6
commit 272b033253
3 changed files with 23 additions and 0 deletions

View File

@@ -5,6 +5,11 @@
using namespace arduino;
extern "C" {
#include <fal.h>
fal_partition_t fal_root_part = NULL;
}
// Weak empty variant initialization function.
// May be redefined by variant files.
void initVariant() __attribute__((weak));
@@ -32,6 +37,10 @@ int main(void) {
__libc_init_array();
// optionally initialize per-variant code
initVariant();
// initialize FAL
fal_init();
// provide root partition
fal_root_part = (fal_partition_t)fal_partition_find("root");
// start the main task and OS kernel
startMainTask();

View File

@@ -2,6 +2,8 @@
#pragma once
#include <fal_def.h>
// Flash device configuration
extern const struct fal_flash_dev flash0;
@@ -23,3 +25,8 @@ extern const struct fal_flash_dev flash0;
.offset = FLASH_##part_upper##_OFFSET, /* partition offset macro as uppercase string */ \
.len = FLASH_##part_upper##_LENGTH, /* partition length macro as uppercase string */ \
},
/**
* @brief Root partition table, representing the entire flash.
*/
extern fal_partition_t fal_root_part;

View File

@@ -11,6 +11,9 @@ def env_add_flash_layout(env, board):
defines = {}
flash_size = 0
fal_items = ""
# add "root" partition
fal_items += "FAL_PART_TABLE_ITEM(root, ROOT)"
# add all partitions
for name, layout in flash_layout.items():
name = name.upper()
(offset, _, length) = layout.partition("+")
@@ -19,6 +22,10 @@ def env_add_flash_layout(env, board):
fal_items += f"FAL_PART_TABLE_ITEM({name.lower()}, {name})"
flash_size = max(flash_size, int(offset, 16) + int(length, 16))
defines["FLASH_LENGTH"] = flash_size
# for "root" partition
defines["FLASH_ROOT_OFFSET"] = 0
defines["FLASH_ROOT_LENGTH"] = flash_size
# add partition table array
defines["FAL_PART_TABLE"] = "{" + fal_items + "}"
env.Append(CPPDEFINES=list(defines.items()))
env.Replace(**defines)