Thing Plus bootloader source?

Are Sparkfun’s samd UF2 bootloader source modifications published anywhere?

There are bootloader binaries for Sparkfun’s samd boards here: https://github.com/sparkfun/Arduino_Boa … ers/SAMD51

The original samd UF2 bootloader source is here: https://github.com/microsoft/uf2-samdx1

and Adafruit has a fork with a lot of changes here: https://github.com/adafruit/uf2-samdx1

I can find some Sparkfun modifications in those repos, but they’re for older samd21 products – I can’t find anything for the samd51 products.

I’m specifically interested in building a new bootloader for the SAMD51 Thing Plus to address this issue with resetting into the bootloader from application code: viewtopic.php?f=145&t=55574

Adafruit also fixed this obscure issue with spurious flash corruption in their samd bootloader. Seems like something that may also need to be addressed in the Sparkfun samd bootloaders (unless it’s not problem on those (?)).

https://github.com/adafruit/uf2-samdx1/pull/111

https://blog.adafruit.com/2020/04/13/uf … m4-boards/

https://learn.adafruit.com/adafruit-fea … bootloader

Hi thanks for your interest in getting a fix for that issue. I had been following that thread but I have not had the time to look into it. As for the files, I’m not sure where they are unfortunately. That particular engineer is no longer at SparkFun. I, at first, thought you were asking about the MicroMod SAMD51 Processor Board and was going to point you that repository. Let me know if there’s some other way I might be able to help.

After some though it was most likely built using Microsoft’s repository, let me know if there’d be a better reason to use Adafruit’s. Also, please let me know if you still have interest in doing it now knowing that there isn’t source files for it. I’ll be happy to look into it when I have more time (not likely this month), if you decide you’re no longer interested.

Thanks for the reply!

Here’s my attempt at reconstructing the UF2 bootloader board config files for the SAMD51 Thing Plus. I’m pretty sure that the first half is correct, but much less sure about the USART config at the bottom – not sure if the USART config is even used since USE_UART is disabled by default. In theory I routed the USART to the pins broken out as D0 and D1. Note that this config corrects the chip variant.

board.mk

CHIP_FAMILY = samd51
CHIP_VARIANT = SAMD51J20A

board_config.h

#ifndef BOARD_CONFIG_H
#define BOARD_CONFIG_H

#define VENDOR_NAME "SparkFun Electronics"
#define PRODUCT_NAME "SparkFun SAMD51 Thing+"
#define VOLUME_LABEL "51THINGBOOT"
#define INDEX_URL "https://www.sparkfun.com/products/14713"
#define BOARD_ID "SAMD51J20A-SparkFun-Thing-v0"

#define USB_VID 0x1B4F
#define USB_PID 0x0016

#define LED_PIN PIN_PA17

#define BOOT_USART_MODULE                 SERCOM2
#define BOOT_USART_MASK                   APBBMASK
#define BOOT_USART_BUS_CLOCK_INDEX        MCLK_APBBMASK_SERCOM2
#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_PA13C_SERCOM2_PAD1
#define BOOT_USART_PAD0                   PINMUX_PA12C_SERCOM2_PAD0
#define BOOT_GCLK_ID_CORE                 SERCOM2_GCLK_ID_CORE
#define BOOT_GCLK_ID_SLOW                 SERCOM2_GCLK_ID_SLOW

#endif

sparkfun-samd51-thingplus.zip (700 Bytes)

As for using the Microsoft or Adafruit fork of the uf2-samdx1 repo, I don’t know, I think Sparkfun will need to take a look at them and decide which way to go. Cloning both of them into the same repo as remotes and then looking at the changes in the core bootloader source with gitk adafruit/master microsoft/master src scripts &, you can see where the repos diverged about 2 years ago. The Adafruit fork clearly has more changes – whether those are all good and relevant, I don’t know, but they look useful at first glance. The fix for spurious flash writes (highlighted in the screenshot below) hasn’t been ported/merged back to the Microsoft repo.

download/file.php?id=6893

I built a bootloader from the Adafruit uf2-samdx1 repo at the v3.13.0 tag with the board config attached to my earlier comment and flashed it to one of my SAMD51 Thing Plus boards using the uf2 updater. It updated successfully and seems to be working well so far.

I’m looking over it this afternoon, any chance you’d want to do a pull request on the hardware repository? You can put the files within a folder titled uf2 bootloader. This will help give credit where credit’s due and document its’ progress.

https://github.com/sparkfun/SAMD51_Thing_Plus

Thanks!

Yeah, definitely! I have something in the works and will submit a PR tomorrow.

https://github.com/sparkfun/SAMD51_Thing_Plus/pull/2

vynce:
I built a bootloader from the Adafruit uf2-samdx1 repo at the v3.13.0 tag with the board config attached to my earlier comment and flashed it to one of my SAMD51 Thing Plus boards using the uf2 updater. It updated successfully and seems to be working well so far.

Hello,

would it be possible to get a copy of your uf2 for the samd51 thing plus?

Thank you!

x130844:
would it be possible to get a copy of your uf2 for the samd51 thing plus?

Hi, the bootloader binaries I built are included in [this commit, which is part of the [pending PR.

To update, double-tap the reset button on the board and copy [update-bootloader-sparkfun-samd51-thingplus-v3.13.0.uf2 to the mass-storage device that appears. The board will reset and the INFO_UF2.TXT file in the bootloader mass-storage device should display the new version number.](https://github.com/sparkfun/SAMD51_Thing_Plus/raw/4b5b61ea15a099e99139af206e16e3b233d59143/uf2-bootloader/uf2_bin/update-bootloader-sparkfun-samd51-thingplus-v3.13.0.uf2)](Add uf2-samdx1 board config and updated bootloader by Vynce · Pull Request #2 · sparkfun/SAMD51_Thing_Plus · GitHub)](Add uf2-samdx1 board config and updated bootloader by Vynce · Pull Request #2 · sparkfun/SAMD51_Thing_Plus · GitHub)

So Vynce’s work on fixing that value has finally been pulled into the main branch, which now includes the uf2 bootloader directly. I have also included the new uf2 folder with the reset fix in our SparkFun SAMD Arduino Board release v1.8.13.