SAMD21 Custom Board Trouble with Bootloader Modifications to Load over UART

I can't seem to figure out what I'm doing wrong here. I have a custom SAMD21 board. I tried to modify the standard samd21_sam_ba.hex bootloader to match my board. I have modified the board_definitions_boardID.h file to change the pins to what I am using. So far I have modified the LED pins and that part worked. I can still upload via USB using the command:

...\AppData\Local\Arduino15\packages\arduino\tools\bossac\1.7.0/bossac.exe -i -d --port=COM81 -U true -i -e -w -v ...\Documents\Arduino\ProgrammingScripts\AT_8.ino.at_board5.bin -R

But if I try to do upload over UART with a USB-UART converter using the same command, I get:

Set binary mode
Send auto-baud
Set binary mode
No device found on COMXX

I use PA17 for my RX pin, and PA16 for my TX pin. This works fine in the application. It is set up on SERCOM1 with PA17 being pad 1 and PA16 pad 0. In my board_definition file I have this defined as follows:

#define BOOT_USART_MODULE SERCOM1
#define BOOT_USART_BUS_CLOCK_INDEX PM_APBCMASK_SERCOM1
#define BOOT_USART_PER_CLOCK_INDEX GCLK_CLKCTRL_ID_SERCOM1_CORE_Val
#define BOOT_USART_PAD_SETTINGS UART_RX_PAD1_TX_PAD0
#define BOOT_USART_PAD3 PINMUX_UNUSED
#define BOOT_USART_PAD2 PINMUX_UNUSED
#define BOOT_USART_PAD1 PINMUX_PA17C_SERCOM1_PAD1
#define BOOT_USART_PAD0 PINMUX_PA16C_SERCOM1_PAD0

I believe these settings are correct, but I can't figure out the issue. I believe I am building the bootloader correctly because the LEDs have changed and I can still program via USB. Any help would be very much appreciated because I'm running out of ideas.

I’m no expert with SAMD21. I think you have to compile the bootloader with the options you want.

which looks like an Atmel Studio project at a glance but the readme says you can get the toolchain and run the Makefile. I would like to know how it goes (e.g. post the build text please), I have been wanting to do a SAMD21 (or maybe 51) board for a while, unfortunately, have not really done anything.

Also, do you have a way to upload the bootloader?

Hi jamesod,

Have you double tapped the reset button before uploading?

To use the SAMD21's bootloader UART, it's necessary to put the processor into bootloader mode first.

So, I slept on it, and I figured out the issue. I was powering the board through USB, and apparently the UART bootloader does not work if USB is plugged in.

Ron

I started with these instructions here: Compile | Compiling ATSAMD21 Bootloader | Adafruit Learning System

For this I had to modify the board_definitions.h file to add a case for my board, and I added a board_definitions_myboard.h file that I modified from the board_definitions_genuino_zero.h file that is given in the ArduinoCore-samd.

I also modified the makefile. The ReadMe is a little out of date. Its 2 years old, but the makefile is a month old, so the instructions don't match perfectly.

Assuming you have the Arduino IDE and the SAMD21 toolchain installed in the default locations, you only have to modify the BOARD_ID?= and NAME?= lines of the makefile.

Next challenge is a bootloader for my other board. That one will have to boot from USB or spi flash. I expect that to be more of a challenge, but I'm looking at this example to start:

jamesod:
Assuming you have the Arduino IDE and the SAMD21 toolchain installed in the default locations, you only have to modify the BOARD_ID?= and NAME?= lines of the makefile.

Hi sorry for digging up this thread, but maybe you can help me. I am trying to compile a custom bootloader and have done what you have posted here, ie create a board definition, include it in board_definitions.h, and mod the Makefile. I call make from the command prompt of Cygwin64. It compiles up to where something #includes <sam.h> then it throws an error… board_driver_i2c.h:23:17: fatal error: sam.h: No such file or directory

I have latest SAMD package 1.6.20 installed on IDE 1.8.8

How did you get arround this?

Thx

Problem solved. I was trying to make a boolader form the Sparkfun Dev board package, which is out of date. When I tried it from the Zero package it worked.