From 3781777138c8160e78f808aab7c663ca9ff08bb4 Mon Sep 17 00:00:00 2001 From: Pol Henarejos Date: Mon, 11 Apr 2022 11:37:41 +0200 Subject: [PATCH] Adding some kind of permanent flash memory that does not wipe out when initializing. Signed-off-by: Pol Henarejos --- src/fs/flash.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/fs/flash.c b/src/fs/flash.c index 4895eb2..569b275 100644 --- a/src/fs/flash.c +++ b/src/fs/flash.c @@ -35,11 +35,12 @@ */ #define FLASH_TARGET_OFFSET (PICO_FLASH_SIZE_BYTES >> 1) // DATA starts at the mid of flash #define FLASH_DATA_HEADER_SIZE (sizeof(uintptr_t)+sizeof(uint32_t)) +#define FLASH_PERMANENT_REGION (4*FLASH_SECTOR_SIZE) // 4 sectors (16kb) of permanent memory //To avoid possible future allocations, data region starts at the end of flash and goes upwards to the center region const uintptr_t start_data_pool = (XIP_BASE + FLASH_TARGET_OFFSET); -const uintptr_t end_data_pool = (XIP_BASE + PICO_FLASH_SIZE_BYTES)-FLASH_DATA_HEADER_SIZE; //This is a fixed value. DO NOT CHANGE +const uintptr_t end_data_pool = (XIP_BASE + PICO_FLASH_SIZE_BYTES)-FLASH_DATA_HEADER_SIZE-FLASH_PERMANENT_REGION; //This is a fixed value. DO NOT CHANGE #define FLASH_ADDR_DATA_STORAGE_START start_data_pool extern int flash_program_block(uintptr_t addr, const uint8_t *data, size_t len);