File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed
features/storage/kvstore/conf Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -547,6 +547,27 @@ int _storage_config_TDB_INTERNAL()
547
547
return MBED_ERROR_FAILED_OPERATION;
548
548
}
549
549
internal_start_address = align_up (FLASHIAP_APP_ROM_END_ADDR, flash.get_sector_size (FLASHIAP_APP_ROM_END_ADDR));
550
+
551
+ // Give the application a couple of spare sectors to grow (if there are such)
552
+ bd_size_t spare_size_for_app = 0 ;
553
+ bd_addr_t curr_addr = internal_start_address;
554
+ bd_addr_t flash_end_address = flash.get_flash_start () + flash.get_flash_size ();
555
+
556
+ int spare_sectors_for_app = 2 ;
557
+ int min_sectors_for_storage = 2 ;
558
+ for (int i = 0 ; i < spare_sectors_for_app + min_sectors_for_storage - 1 ; i++) {
559
+ bd_size_t sector_size = flash.get_sector_size (curr_addr);
560
+ curr_addr += sector_size;
561
+ if (curr_addr >= flash_end_address) {
562
+ spare_size_for_app = 0 ;
563
+ break ;
564
+ }
565
+ if (i < spare_sectors_for_app) {
566
+ spare_size_for_app += sector_size;
567
+ }
568
+ }
569
+ internal_start_address += spare_size_for_app;
570
+
550
571
flash.deinit ();
551
572
}
552
573
You can’t perform that action at this time.
0 commit comments