rp2/rp2_flash: Add asserts for size of flash filesystem partition.

Signed-off-by: Damien George <damien@micropython.org>
This commit is contained in:
Damien George 2022-06-30 14:27:13 +10:00
parent c95f99105a
commit 7cdad05e54
1 changed files with 6 additions and 0 deletions

View File

@ -37,6 +37,7 @@
#ifndef MICROPY_HW_FLASH_STORAGE_BYTES
#define MICROPY_HW_FLASH_STORAGE_BYTES (1408 * 1024)
#endif
static_assert(MICROPY_HW_FLASH_STORAGE_BYTES % 4096 == 0, "Flash storage size must be a multiple of 4K");
#ifndef MICROPY_HW_FLASH_STORAGE_BASE
#define MICROPY_HW_FLASH_STORAGE_BASE (PICO_FLASH_SIZE_BYTES - MICROPY_HW_FLASH_STORAGE_BYTES)
@ -72,6 +73,11 @@ STATIC mp_obj_t rp2_flash_make_new(const mp_obj_type_t *type, size_t n_args, siz
// Check args.
mp_arg_check_num(n_args, n_kw, 0, 0, false);
#ifndef NDEBUG
extern char __flash_binary_end;
assert((uintptr_t)&__flash_binary_end - XIP_BASE <= MICROPY_HW_FLASH_STORAGE_BASE);
#endif
// Return singleton object.
return MP_OBJ_FROM_PTR(&rp2_flash_obj);
}