How to flash my program without erasing bootloader? (SAMD21)

1 post / 0 new
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0



I have a SAMD1 custom board I'm trying to program, but I have some doubts regarding the bootloader and the BOOTPROT fuse


Firstly, is it correct that the bootloader is placed at 0x00000000? I've seen there exists several different bootloaders (Arduino bootloader, uf2, etc). Which one is the most lightweight? I would like to not use the Arduino framework to build the program themselves, but I wonder if I can still use their bootloader.


Secondly, and regarding the same Arduino bootloader, I have tried to reverse-engineer the arduino IDE to see how it was using openOCD to 1. flash the bootloader and 2. flash the program. These are the commands the IDE Executes:


Burning the bootloader

openocd -d2 -s /home/reneman/.arduino15/packages/arduino/tools/openocd/0.10.0-arduino7/share/openocd/scripts/ -f /home/reneman/.arduino15/packages/arduino/hardware/samd/1.8.10/variants/mkrzero/openocd_scripts/arduino_zero.cfg -c telnet_port disabled; init; halt; at91samd bootloader 0; program {/home/reneman/.arduino15/packages/arduino/hardware/samd/1.8.10/bootloaders/mkrzero/samd21_sam_ba_arduino_mkrzero.bin} verify reset; shutdown 


Flashing the program using a programmer (I Use Atmel ICE-SAM)

/home/reneman/.arduino15/packages/arduino/tools/openocd/0.10.0-arduino7/bin/openocd -d2 -s /home/reneman/.arduino15/packages/arduino/tools/openocd/0.10.0-arduino7/share/openocd/scripts/ -f /home/reneman/.arduino15/packages/arduino/hardware/samd/1.8.10/variants/mkrzero/openocd_scripts/arduino_zero.cfg -c telnet_port disabled; program {/tmp/arduino_build_915819/Test.ino.hex} verify reset; shutdown


This works fine and my sketch executes. However, if I copy and execute the same commands manually using openOCD, the sketch won't run and the bootloader seems to be erased.


Where does the Arduino bootloader load the sketch from, what address? I assume it has to be after the bootloader, but can it be changed?


Thank you,

> Reneman
> Learning and working with embedded devices!