CommunityGD32Cores / ArduinoCore-GD32

Arduino core for GD32 devices, community developed, based on original GigaDevice's core
Other
86 stars 33 forks source link

Enforce page-sized FlashStorage sizes #60

Closed algernon closed 2 years ago

algernon commented 2 years ago

FlashStorage must be both page aligned, and span full pages. We can't erase and rewrite partial pages, and we must not touch the area outside of the reserved one. If we try to erase and then rewrite partial pages, the whole partial page operation will fail. Therefore, we need to ensure that the storage size is a multiple of our page size.

This patchset does just that, with the caveat that we enforce the size as if all pages were 4k, even if our storage is (at least partially) in bank0. This is to make the implementation trivial and not require complex computations at compile-time.