add flash storage

This commit is contained in:
Edward Emelianov
2026-07-29 21:01:01 +03:00
parent 2b4a9cbd84
commit 940b60df99
15 changed files with 352 additions and 70 deletions

View File

@@ -81,7 +81,7 @@ static int binarySearch(int r, const uint8_t *start, int stor_size){
*/
void flashstorage_init(){
if(FLASH_SIZE > 0 && FLASH_SIZE < 20000){
uint32_t flsz = FLASH_SIZE * blocksize; // size in bytes
uint32_t flsz = FLASH_SIZE * 1024; // size in bytes
flsz -= (uint32_t)(&__varsstart) - FLASH_BASE;
maxCnum = flsz / sizeof(user_conf);
}
@@ -149,7 +149,7 @@ static int erase_flash(const void *start, const void *end){
if(!start) return 1;
uint32_t startb = (((uint32_t)start - FLASH_BASE) + blocksize - 1) / blocksize, endb;
if(!end){ // erase all remaining
endb = FLASH_SIZE / blocksize;
endb = FLASH_SIZE * 1024 / blocksize;
}else{ // erase a part
endb = (((uint32_t)end - FLASH_BASE) + blocksize - 1) / blocksize;
}