Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FlashStorage.h operates with wrong page size for GD32F130 #131

Open
mace-de opened this issue Nov 19, 2024 · 2 comments
Open

FlashStorage.h operates with wrong page size for GD32F130 #131

mace-de opened this issue Nov 19, 2024 · 2 comments
Assignees
Labels
bug Something isn't working Component: Flash

Comments

@mace-de
Copy link

mace-de commented Nov 19, 2024

GD32F130C8 has a Flash page size of 1024. FlashStorage.h operates with a page size of 4096 which messes up the commit procedure.

@maxgerhardt
Copy link
Member

I see, so these numbers

static constexpr uint32_t fmc_base_address = 0x08000000;
static constexpr uint32_t bank0_size = 512 * 1024;
static constexpr uint32_t bank0_end = fmc_base_address + bank0_size - 1;
static constexpr uint32_t fmc_end_address = fmc_base_address + _fmc_end;
static constexpr uint32_t data_area_start = fmc_end_address - _storage_size;
uint16_t pageSizeForAddress(uint32_t addr)
{
if (addr > bank0_end)
return 4096;
else
return 2048;
}

are not universally true for all GD32 chips.

@maxgerhardt maxgerhardt self-assigned this Nov 22, 2024
@maxgerhardt maxgerhardt added bug Something isn't working Component: Flash labels Nov 22, 2024
@mace-de
Copy link
Author

mace-de commented Nov 24, 2024

For my WVC project, I use a modified Version of Flashstorage.h. It don't erase the Flash page on every commit. It fills the page with committed data until the page is full and erases the page only when there isn't enough space left. The begin function searches the last valid data block before the 0xFF filled area. This will save a lot of Flash erase cycles. Maybe this is of interest for your Lib too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Component: Flash
Projects
None yet
Development

No branches or pull requests

2 participants