I am currently porting micropython to a custom board using a STM32F412RG.
the reason of using this chip is the larger flash and ram capacity compared to the STM32F411RE.
I have gotten so far as succesfully flashing a build to the board but now i am running into problems with the storage.
the board keeps crashing every time i am writing data to the internal flash past the 46KB of used storage.
My suspicion is I somehow have the file system wrongly defined.
what i have in my stm32f412.ld file
Code: Select all
MEMORY
{
FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 1024K /* entire flash */
FLASH_ISR (rx) : ORIGIN = 0x08000000, LENGTH = 16K /* sector 0 */
FLASH_FS (rx) : ORIGIN = 0x08004000, LENGTH = 112K /* sectors 1,2,3 are 16K, 4 is 64K, 5 is 128K (64K used) for filesystem */
FLASH_TEXT (rx) : ORIGIN = 0x08020000, LENGTH = 896K /* sectors 7,8,9,10,11 are 128K*/
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 256K
}
/* produce a link error if there is not this amount of RAM for these sections */
_minimum_stack_size = 2K;
_minimum_heap_size = 16K;
/* Define tho top end of the stack. The stack is full descending so begins just
above last byte of RAM. Note that EABI requires the stack to be 8-byte
aligned for a call. */
_estack = ORIGIN(RAM) + LENGTH(RAM);
/* RAM extents for the garbage collector */
_ram_start = ORIGIN(RAM);
_ram_end = ORIGIN(RAM) + LENGTH(RAM);
_heap_start = _ebss; /* heap starts just after statically allocated memory */
_heap_end = _ram_end - 16K; /* 240K, tunable */
Code: Select all
#elif defined(STM32F412Rx)
STATIC byte flash_cache_mem[0x4000] __attribute__((aligned(4))); // 16k
#define CACHE_MEM_START_ADDR (&flash_cache_mem[0])
#define FLASH_SECTOR_SIZE_MAX (0x4000) // 16k max due to size of cache buffer
#define FLASH_MEM_SEG1_START_ADDR (0x08004000) // sector 1
#define FLASH_MEM_SEG1_NUM_BLOCKS (224) // sectors 1,2,3,4,5: 16k+16k+16k+64k+64k(of 128k)=176k
Code: Select all
MCU_SERIES = f4
CMSIS_MCU = STM32F412Rx
AF_FILE = boards/stm32f412_af.csv
LD_FILES = boards/stm32f412.ld boards/common_ifs.ld
TEXT0_ADDR = 0x08000000
TEXT1_ADDR = 0x08020000