Bootloader Issues SAMD21G15B Custom Board Continued

I can see "maybe" support by selecting "Xeno Mini" as the board, and "SAMD21G15A" from the "microprocessor" sub-menu that appears.

Alas, I don't have anything with that chip to do testing with.

Looked really hopeful! Unfortunately, I ran into the same roadblock. It's stalling out during programming with the arduino IDE over USB. Do you think I'd have any better luck exporting the binary from the arduino IDE and uploading it directly using Atmel Studio and my jlink? I'm a bit fuzzy with that whole process. Here are some of my questions:

  1. Do I need the bootloader for my arduino sketch to work if I'm uploading the code with a programmer?

  2. What is the process with uploading a compiled binary onto an arduino with atmel studio? I know how to export a bin file. Do I need to set fuses? Do I need to set them back before or after I upload code? What are the settings in each case?

  3. Do I need to erase the chip before uploading the binary or should I leave that option empty so I keep the bootloader on the chip?

I know I could do a lot of trial and error, but there are a bunch of different combinations here. Any tips would be awesome. Thanks again.

Hmm. I'm not sure. You wouldn't with an AVR, but I think the SAMD sketches are normally compiled to load at an address AFTER the bootloader, which would cause problems if the bootloader is not present. You could theoretically change all of that, so that your sketch is compiled for non-bootloader use and always expects to be uploaded with a programmer. I'm not sure how that compares in difficulty with getting the bootloader working.

Not sure. :frowning:

Are you planning on just uploading YOUR code to your custom board, or do you want to allow others to load a board package and be able to upload sketches as well? (assuming they have appropriate equipment.)

since the SAMD starts at address 0x0000 and the bootloader is at 0x0000, it doesn't have fuses for bootloader location. but without bootloader the sketch must be compiled to address 0x0000.

definition of M0 without bootloader
https://github.com/JAndrassy/my_boards/tree/eafadaecc15585537cfa05806856c4bc9ac2d8fe/samd/variants/arduino_mzero

Hi @jbeck01

There are three separate issues that need to be addressed:

  1. Bootloader - the bootloader code isn't particularly fussy about which chip variant the code is compiled for (usually the orginal SAMD21G18A), but the does require that the linker scripts are changed to reflect the SAMD21G15B's smaller memory footprint. It also requires the address of the magic number that's used to implement the bootloader's double tap reset is changed to occupy the last four bytes of RAM. It's also possible to specify that the bootloader is to run crystalless in the board configuration file, (like the Arduino Nano 33 IoT, which runs crystalless).

  2. Bossa - this is the application that the Arduino IDE uses to upload a sketch to the target microcontroller via its native USB port. By contrast, each implementation is very specific about which devices it supports, since it verifies the microcontroller's device ID. The path of least resistance is to find a pre-compiled executable on Github that supports your target microcontroller and swap out the Arduino IDE's "bossac.exe" file for the new one.

  3. Arduino IDE - Create an entry for your new board in the Arduino IDE. It's also necessary to specify that the board is running crystalless using the -DCRYSTALLESS flag "boards.txt" file, otherwise the sketch will stall after upload. For example the Nano 33 IoT:

nano_33_iot.build.extra_flags=-DCRYSTALLESS -D__SAMD21G18A__ {build.usb_flags}

This is a super useful summary. I'm still a little fuzzy, does programming without the bootloader save me any trouble?

1.) I have been testing the SAMD21G15B bootloader that westfw made me and the one I created myself and I get the same outcomes. The arduino IDE stalls out during the write of a program.

2.) Given your advice and what I've read on the forums, I'm thinking I need to focus on finding another bossa. I only know of the MattairTech Xeno Mini that's in version: 1.6.18 beta 0 and beta 1 that supports the SAMD21G15B. Programming stalls on both of these versions when I try to write to the chip. Any other thoughts on a Bossa version that might work or know of someone who might be able to create one for me?

3.) My board has a crystall, so I've been testing it with the default crystal setting.

Thanks again!

Hi @jbeck01

Here's a pre-compiled version of Bossa that supports the SAMD21G15B on Github:

Once the "bossac.exe" file has been extracted, swap the Arduino IDE's version for the new one detailed here: https://forum.arduino.cc/t/lower-memory-samd21-variant/890009/37.

If your board already has an external crystal then the bootloader should work as normal, irrespective of whether its configured for crystal or crystalless operation.

The essential thing is that the bootloader code and linker script have been configured and compiled for the microcontroller's smaller memory footprint, since this allows its double tap functionality to operate correctly.

A very warm thank you to all that have helped on this thread. No luck so far and I ran out of time and needed to do a work around to meet my deadline. I may need to take a second look in a while. If anyone is personally curious and wants to try with an actual board, I'd be happy to mail one out.

Best,
Josh