Skip to content

Conversation

@hmaerki
Copy link

@hmaerki hmaerki commented Nov 20, 2025

Fix

This PR allows NVM to be bigger than 64kBytes.

Bug

Assume mpconfigboard.h specifies: #define CIRCUITPY_INTERNAL_NVM_SIZE (136*1024).

But len(microcontroller.nvm) will return 8192 as the uint16_t wraps.

# Wrap uint16_t (wrong)
>>> (136*1024)%(2**16)
8192
# No wrap uin32_t (correct, this PR)
>>> (136*1024)%(2**32)
139264

With this PR applied, len(microcontroller.nvm) will return 139264 which is, as expected, 136*1024.

Test

I tested this PR on a nordic pca10059 using #define CIRCUITPY_INTERNAL_NVM_SIZE (136*1024).

Signed-off-by: Hans Maerki <buhtig.hans.maerki@ergoinfo.ch>
@hmaerki hmaerki changed the title Allow microcontroller.nvm to be bigger than 8k Allow microcontroller.nvm to be bigger than 64k Nov 20, 2025
Copy link
Member

@tannewt tannewt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@tannewt tannewt merged commit f6f52ad into adafruit:main Nov 20, 2025
579 checks passed
@hmaerki hmaerki deleted the allow_nvm_bigger_8k branch November 21, 2025 08:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants