The filesystem is created by micropython on startup.
The file flashbdev.c is defines at which adress and how many blocks are used for the file system. (Previously it was located in the storage.c)
Code: Select all
#elif defined(STM32F429xx)
#define CACHE_MEM_START_ADDR (0x10000000) // CCM data RAM, 64k
#define FLASH_SECTOR_SIZE_MAX (0x10000) // 64k max, size of CCM
#define FLASH_MEM_SEG1_START_ADDR (0x08004000) // sector 1
#define FLASH_MEM_SEG1_NUM_BLOCKS (224) // sectors 1,2,3,4: 16k+16k+16k+64k=112k
You might have to define the flash sectors, if the predefined setup doesn't fit your MCU, or you change the nDBANK settings. This is located at the file flash.c
This is how I edited mine to fit my needs:
Code: Select all
// Added by MD
// Flash layout nDBANK = 1 - 1MB
//static const flash_layout_t flash_layout[] = {
// { 0x08000000, 0x08000, 4 },
// { 0x08020000, 0x20000, 1 },
// { 0x08040000, 0x40000, 3 },
//};
// Flash layout nDBANK = 1 - 2MB
//static const flash_layout_t flash_layout[] = {
// { 0x08000000, 0x08000, 4 },
// { 0x08020000, 0x20000, 1 },
// { 0x08040000, 0x40000, 7 },
//};
// Flash layout nDBANK = 0 - 2MB
//static const flash_layout_t flash_layout[] = {
// { 0x08000000, 0x02000, 4 },
// { 0x08010000, 0x10000, 1 },
// { 0x08020000, 0x20000, 7 },
// { 0x08100000, 0x02000, 4 },
// { 0x08110000, 0x10000, 1 },
// { 0x08120000, 0x20000, 7 },
//};
// Flash layout nDBANK = 0 - 1MB
static const flash_layout_t flash_layout[] = {
{ 0x08000000, 0x02000, 4 },
{ 0x08010000, 0x10000, 1 },
{ 0x08020000, 0x20000, 3 },
{ 0x08080000, 0x00000, 4 }, // DummyBanks to skip sectors 8 - 11 that do not exsist, because they are numbered from 1 - 7 and then 12 - 19
{ 0x08080000, 0x02000, 4 },
{ 0x08090000, 0x10000, 1 },
{ 0x080A0000, 0x20000, 3 },
{ 0x08100000, 0x00000, 4 }, // DummyBanks to skip sectors 20 - 23 that do not exsist, because they are numbered from 1 - 7 and then 12 - 19 (do we need this?)
};
The linker sript defines where the micropython firmware is located in the Flash. It also defindes a file system part ("FLASH_FS") which is not used as far as I know. But it helps to see where the firmware ends and the filesystem start so it doesn't get corrupted.
Code: Select all
MEMORY
{
FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 1024K
FLASH_ISR (rx) : ORIGIN = 0x08000000, LENGTH = 32K
FLASH_TEXT (rx) : ORIGIN = 0x08020000, LENGTH = 640K
FLASH_FS (r) : ORIGIN = 0x08008000, LENGTH = 96K
FLASH_FS2 (r) : ORIGIN = 0x080C0000, LENGTH = 256K
DTCM (xrw) : ORIGIN = 0x20000000, LENGTH = 128K
RAM (xrw) : ORIGIN = 0x20020000, LENGTH = 384K
}
When you change this, you can increase the fileystem size. When I remember correctly, micropython can use a maximum flash page size of 128 KB. So to maximze the filewsystem size I had to change the MCU nDBANK settings, which also changes the flash loayout of the device.
Do not forget to either clear the flah completly when changing the filesystem settings or reinit the filesystem of the pyboard. I made this mistake at first. (see at post
viewtopic.php?f=3&t=3702&p=22612#p22612)
Hope this helps a little.