adafruit / uf2-samdx1

MSC bootloader (based on UF2) for SAMD21
Other
210 stars 182 forks source link

Building an "unlocked" (no flash write protection) bootloader? #200

Closed vkottler closed 1 year ago

vkottler commented 1 year ago

Hello, from what I can gather from the "Fuses" section of the README: https://github.com/adafruit/uf2-samdx1#fuses

It requires some off-roading for a SWD programmer/debugger to directly write flash (especially/specifically the beginning of flash, where exception vectors and startup code lives by default).

The one-liner solution suggestion for modifying register(s) while in GDB is handy, but it does make some assumptions about certain symbols being loaded (e.g. a Nvmctrl struct definition).

I'm probably going to do this for my own needs, but a #define-able feature flag to not write protect flash, just to eliminate a step in the SWD-debug + gdb load program.elf workflow would be handy.

vkottler commented 1 year ago

After looking at the implementation, specifically check_start_application (https://github.com/adafruit/uf2-samdx1/blob/master/src/main.c#L98), I tried just moving my application base to 0x4000 in my build and that worked just fine.

Going to close this issue - it's straight-forward enough to create an arbitrary application that can be co-located with the bootloader.. if you just put it in the correct location!