Tiny storage(file) system on MCU internal flash memory for Nucleo F4xx. The purpose of SOFBlock class is to provide a way to write data on flash memory in the same way of file handling class in the file system.
Dependents: storage_on_flash_demo mbed_controller_demo mbed-os-example-blinky-2
March 26, 2015
Seeed Arch Max platform which is based on STM32-F407 is supported.
Revision 3:2bb58064d0a2, committed 2015-03-25
- Comitter:
- hillkim7
- Date:
- Wed Mar 25 05:46:25 2015 +0000
- Parent:
- 2:e79a9cb05801
- Commit message:
- Fix comment.
Changed in this revision
SOFBlock.h | Show annotated file Show diff for this revision Revisions of this file |
diff -r e79a9cb05801 -r 2bb58064d0a2 SOFBlock.h --- a/SOFBlock.h Wed Mar 25 05:27:59 2015 +0000 +++ b/SOFBlock.h Wed Mar 25 05:46:25 2015 +0000 @@ -25,7 +25,7 @@ * The base physical address of STM32 flash is 0x08000000. * * There may be inefficiency in this flash usage scenario when size of data is too small compared with sector size. - * The size of sectors from #5 to #7 of STM32 401RE Flash 128KB. For example, if I only need to maintain 1KB data, + * The size of sectors from #5 to #7 of STM32-F4xx Flash is 128KB. For example, if I only need to maintain 1KB data, * whenever I need to update data I need to erase whole 128KB of sector. * This produces two problems. * One is time consumption of the erase operation. The operation of ERASE128KB takes 1~4 seconds long. @@ -33,9 +33,11 @@ * More you erase and write and lifetime of flash is shorter. * * To overcome such problems, here simple flash management algorithm is used for. - * By tracking data offset and size it can hold multiple data in a sector. Bear in mind that is impossible rewriting data on Flash. - * Keeping tracking data along with data itself is crucial without frequent erase operation. - * To do this, data itself is growing from low address. On the other hand tracking data is growing down from high address. + * By tracking data offset and size it can hold multiple data in a sector. + * Bear in mind that is impossible rewriting data on Flash. + * Keeping tracking data along with data itself without frequent erase operation is crucial. + * To do this, data itself is growing from low address. + * On the other hand tracking data is growing down from high address. * Let's assume the size of data is 1KB and store it in sector #6 which address range is from 0x08040000 to 0x0805ffff. * +-------------+----------------------------------------------------------------------+-----+ * <data> <tracking data> @@ -78,10 +80,10 @@ * // "First Data" printed * reader.close(); * - * SOF_Statics_t statics; - * if (!SOFBlock(sector_index, statics) || statics.free_size < 11) { // check available byte + * SOF_Statics_t statics; + * if (!SOFBlock(sector_index, statics) || statics.free_size < 11) { // check available byte * SOFBlock::format(sector_index); - * } + * } * writer.open(sector_index); * // Overwrite previous data without erasing flash. * writer.write_data((uint8_t*)"Second Data", 11);