I am having issues getting the main program to run after flashing via BOSSA with a bootloader. Jump to the bottom for my question and TL;DR.
Here is my current situation:
- UF2 bootloader successfully compiled for SAMD21G18A
- Bootloader flashed with ATMEL ICE and runs correctly upon reset
- Device shows up as external storage and also as a CDC device in BOSSA
- Flashed a hex file successfully in BOSSA (with offset applied) and then reset device
- Program on hex file doesn't ever run
The program is just the Arduino "Blink" example, converted to an AtmelStudio solution. The linker script has been modified to have the origin at 0x2000 (as expected by the bootloader).
Other things I've tried to no avail:
- a variety of offsets
- many different bootloaders of CDC and MSD variants
- uploading the compiled program with the Arduino IDE, BOSSA, AtmelStudio etc
Other points worth noting:
- The AtmelStudio solution contains two projects as is standard when importing an Arduino sketch. 1)
- LEDs on my board work as expected (breathing to indicate in the bootloader)
- When I import the Arduino sketch into AtmelStudio and flash it to the device the device mounts as a CDC device (via the native USB port) to my computer. I don't know why this is happening as the linker script doesn't include any provisions for a bootloader and the program itself doesn't instruct the hardware to enable the USB port. I have no idea why this is happening.
- it seems like the bootloader never detects a program as it always runs upon startup. This is the behaviour when a program cannot be found.
- The .hex file generated by the Arduino IDE doesn't ever launch either
- If flashed from Arduino IDE or AtmelStudio directly the program does run
TL;DR: Known working main program/sketch never gets run with bootloader on SAMD21G18A.
My question: What would cause the bootloader to not find the main program and hence never run it?
Any other insights as to why I have not had any success here would be greatly appreciated too. My suspicions are that this has something to do with the way the main program is being compiled and linked.