Internal flash capacity

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
Post Reply
nelfata
Posts: 74
Joined: Wed Apr 30, 2014 10:50 pm

Internal flash capacity

Post by nelfata » Sun Oct 26, 2014 2:23 am

Hi,
the internal flash capacity of the microcontroller is 1MB.
Checking the linker file 512K are allocated for text (code). So we should expect to have 512KB for file space onto the internal flash, but effectively the flash is becoming full after hitting a limit of about 90KB or so.

Can someone provide any input?

User avatar
dhylands
Posts: 3211
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada
Contact:

Re: Internal flash capacity

Post by dhylands » Sun Oct 26, 2014 2:38 am

Currently, the internal flash size is 112K.

This number is based on the nature of flash and the block sizes available.

The flash is laid out as:

4 x 16K blocks
1 x 64K block
7 x 128K blocks

The first of the 16K blocks is where the reset and interrupt vectors are located. The remaining 3 x 16 and 1 x 64K = 48 + 64 = 112K is used for the file system.

The way that the internal flash works, is that you have to erase an entire block to 1's, and then you can change bits to zeros.

Which means that if you want to write a single 512 byte sector, then you need to read the entire flash block into RAM, modify the RAM, erase the block, and write the whole block back out. This essentially makes the 128K blocks unusable.

So, if you need more storage, you should use an sdcard, or some other type of storage (perhaps a serial EEPROM, or something like that).

nelfata
Posts: 74
Joined: Wed Apr 30, 2014 10:50 pm

Re: Internal flash capacity

Post by nelfata » Sun Oct 26, 2014 3:18 am

Thank you for your prompt response.

I am currently having issues with corrupt SD Cards due to occasional power interruptions (will have an eventual solution), so I was trying to reduce that by moving some files into the flash (to store files) used only for reading.

Looking again at the linker file here is what I see:

FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 0x100000 /* entire flash, 1 MiB */
FLASH_ISR (rx) : ORIGIN = 0x08000000, LENGTH = 0x004000 /* sector 0, 16 KiB */
FLASH_TEXT (rx) : ORIGIN = 0x08020000, LENGTH = 0x080000 /* sectors 5,6,7,8, 4*128KiB = 512 KiB (could increase it more) */
CCMRAM (xrw) : ORIGIN = 0x10000000, LENGTH = 0x010000 /* 64 KiB */
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 0x020000 /* 128 KiB */


There seems to be a lot of free space at the end of the TEXT section, can we use this for additional files space?
OR can we easily move the the file section?

User avatar
dhylands
Posts: 3211
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada
Contact:

Re: Internal flash capacity

Post by dhylands » Sun Oct 26, 2014 3:28 am

It would probably be possible to put a read-only filesystem at the end of flash (or somewhere in flash).

We can't make it writable since we don't have enough RAM to rewrite the flash pages.

nelfata
Posts: 74
Joined: Wed Apr 30, 2014 10:50 pm

Re: Internal flash capacity

Post by nelfata » Sun Oct 26, 2014 3:52 am

That could be a good solution. I think it would a useful option in general due to the high potential of SD Card failures.

Thanks.

Post Reply