Go Down

Topic: ArduinoCore-samd Bootloader on Chip Variant (Read 161 times) previous topic - next topic


Good evening,

I am designing a FlexPCB bracelet, which I would like to be Arduino-compatible. In interest of real-estate/power-consumption/cost, I am using the ATSAMD21E17A-M from the same family as the 21G18. I notice that the SAMD Bootloader GIT project contains a few files dedicated to this particular chip. I've successfully loaded the project in Atmel Studio, upgraded to Version 7, and built with the default settings. However, I cannot find an intuitive method of building for the 21E17 in particular.

Does anyone have experience building the bootloader for less common chips in the SAMD21 family?



Jun 04, 2018, 11:57 am Last Edit: Jun 04, 2018, 02:33 pm by MartinL
Hi jcloiacon,

I've used the larger SAMD21J18A with the standard Arduino Zero (SAMD21G18A) bootloader and this works just fine. I've also compiled my own Adafruit Metro M4 bootloader for a custom SAMD51 board I'm using.

However, the SAMD21E17 has half the memory of the Arduino Zero: 128KB flash and 16KB of SRAM.

You could try installing the Arduino core code on to the Arduino IDE for an exsisting SAMD21E17 development board such as Rabid Prototypes Tau board, although I don't know if this package includes the bootloader binary.

The other option is to build your own. In this case it's necessary to change the memory size definitions in the link descriptor (.ld) file and move the location of the bootloader's double tap reset address held in the last four bytes of SRAM.

I'm assuming you're using version 1.6.18 of the Arduino Zero core code.

Although I haven't used the SAMD21E17, or built a bootloader for it, I imagine the procedure is as follows:

1. Copy the "bootloader_samd21x18.ld" and rename it "bootloader_samd21x17.ld". Then on line 30 change the RAM LENGTH from 0x8000-0x0004 to 0x4000-0x0004. This accounts for the smaller SRAM size. The flash LENGTH in the line above remains unchanged as the bootloader only requires the first 8Kbytes of flash memory.

2. Copy the "board_definitions_arduino_zero.h" file and rename it "board_definitions_my_board.h", or whatever you prefer.

3. Enter the file in the "board_definitions.h" list.

4. In the "board_definitions_my_board.h" file change the BOOT_DOUBLE_TAP_ADDRESS definition to:

Code: [Select]
#define BOOT_DOUBLE_TAP_ADDRESS           (0x20003FFCul)
This places the double tap address at the back of the SAMD21E17's SRAM.

In the "board_definitions_my_board.h" file it's also possible to change other settings, such as bootloader LED output pins and the optional USART bootloader, (currently set to the USART on digtal pins 0 and 1).

5. Create a new copy of the "Makefile" and change the BOARD_ID definition on line 60 to from "arduino_zero" to "my_board". Change the compiler option on line 64 from __SAMD21G18A__ to __SAMD21E17A__. Finally change the LD_SCRIPT on line 111 from "bootloader_samd21x18.ld" to "bootloader_samd21x17.ld".

To compile and upload sketches to the E17 you'll also most likely need to create your own copy of the core code and modify the both the "variant.h/.cpp" and the "board.txt" files to account for the device's reduced memory and pin count.


Thank you for your in-depth reply!

I've just purchased the Tau board. By following the json link on their Arduino install guide, I've found their bootloader project file. Though I'm unable to build it immediately (recipe for target 'build/board_driver_led.o' failed   ?) the binaries are here.

This code seems to have followed something like your instructions, though there is only a single board_definitions.h file and the double tap address is set to 0x20003FFC.

I'll try the binaries when I get the board in. I have removed the target chip from a SAM D10 Xplained Mini, and will use the remainder as an SWD programmer.


This code seems to have followed something like your instructions, though there is only a single board_definitions.h file...
I think it's most likely that the Tau bootloader was built by modifying the Arduino Zero's code. Arduino have since added multiple board definitions to support their range of SAMD21 based MKR products.

Go Up