diff --git a/ports/rp2/rp2_flash.c b/ports/rp2/rp2_flash.c index 80bc1dc1df12..db6b9f3bfe75 100644 --- a/ports/rp2/rp2_flash.c +++ b/ports/rp2/rp2_flash.c @@ -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); }