embassy-rs / nrf-softdevice

Apache License 2.0
254 stars 74 forks source link

Flash Capacity Definition Discrepancy for nRF52832 and nRF52833 Chips #246

Closed lonesometraveler closed 2 months ago

lonesometraveler commented 3 months ago

Thank you for maintaining this project.

I wanted to reach out to share an observation I made while using the flash module. It seems there might be an oversight in how the flash memory capacity is defined.

https://github.com/embassy-rs/nrf-softdevice/blob/e769274bf6812c55fb7e9d9f9e87b23a141b8b7a/nrf-softdevice/src/flash.rs#L87C1-L89C6

The library identifies the flash capacity as 1MB (256 * 4096), which is correct for nRF52840. However, for nRF52832 and nRF52833, the flash size is 512KB. Shouldn't it return different values based on the chip to accurately reflect their flash capacities?

alexmoon commented 3 months ago

Yes, that's just an oversight. PR to fix would be welcome. Though I would note that capacity is not a terribly useful figure for the internal flash since you can't use it all without nuking your firmware.

plaes commented 3 months ago

Not only flash sizes, but also page size of flash. And to make things complicated, nrf52832 has actually two variants: 512KB and 256KB variant. So, while I'm at it here's a list of NRF devices and their flash sizes:

Unfortunately I didn't find a definition for flash page size from SDK at quick glance.

alexmoon commented 3 months ago

I believe they all have 4k pages, with the exception of the 5340 network core which has 2k pages.