Skip to content

Unable to flash UF2 where flash is >512kb #213

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

Closed
tannewt opened this issue Aug 2, 2021 · 4 comments · Fixed by #214
Closed

Unable to flash UF2 where flash is >512kb #213

tannewt opened this issue Aug 2, 2021 · 4 comments · Fixed by #214
Assignees
Labels
Bug Something isn't working

Comments

@tannewt
Copy link
Member

tannewt commented Aug 2, 2021

Set up
Feather nRF52840 Express with 6.0.0 bootloader. CircuitPython e9369d50e16e557ccd1a98c06d6e36bb87b908b7 . UF2s for the opt build flash ok but DEBUG=1 builds do not.

Describe the bug

Only part of the >512k UF2 is flashed leaving the higher end of the flash incorrect. In CircuitPython this means the .data section is not correct and assertions in DEBUG=1 mode fail as a result.

To Reproduce

Steps to reproduce the behavior:

  1. Enter the bootloader
  2. Drag on
    firmware-debug.uf2.zip after unzipping.
  3. Red LED flashes quickly and board doesn't restart.
  4. Manual restart leads to CP assertion failure.

Here is an opt build that works: firmware-opt.uf2.zip

Note that the broken UF2 is >1MB in size.

@tannewt
Copy link
Member Author

tannewt commented Aug 2, 2021

Two other things:

  1. I wrote a script to compare the RAM version of .data to the flash version and they were the same. They were not the same as the .data version from the .elf file.
  2. The debug build of CircuitPython works when I flash it via pyocd instead of with the bootloader.

@dhalbert
Copy link
Contributor

dhalbert commented Aug 2, 2021

Thank you for figuring this out!

@hathach hathach self-assigned this Aug 3, 2021
@hathach
Copy link
Member

hathach commented Aug 3, 2021

yeah, I could reproduce the issue, troubleshooting on the way, will post more update when available.

@hathach
Copy link
Member

hathach commented Aug 4, 2021

Write addr = 0x000ACD00, block = 2142 (2142 of 2191)
Write addr = 0x000ACE00, block = 2143 (2143 of 2191)
Write addr = 0x000ACF00, block = 2144 (2144 of 2191)

I found the issue, the bootloader is limited its size to 512KB since it reserved the rest for internal file system ( for all boards), since the very first implementation of the bootloader.

  • For Arduino, all boards is served with 28KB for storing bonding information.
  • For Circuitpython, there seems to be 3 section FLASH_BLE_CONFIG (32KB), FLASH_NVM (8KB), FLASH_FATFS (can be 0 on qspi flash dev).

For that I think we will increase reserved size to 40KB. The overflow to fatfs should be checked by circuitpyhon linker, just try DEBUG=1 with boards internal flash, it overflows and won't linked which is good.

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

Successfully merging a pull request may close this issue.

3 participants