# Thing Plus bootloader source?

**URL:** <https://community.sparkfun.com/t/thing-plus-bootloader-source/42820>\
**Category:** Development Boards\
**Tags:** samd\
**Created:** [September 30, 2021, 5:59am UTC](https://community.sparkfun.com/t/thing-plus-bootloader-source/42820 "2021-09-30T05:59:51Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![vynce](https://yyz1.discourse-cdn.com/sparkfun/user_avatar/community.sparkfun.com/vynce/32/6135_2.png) [@vynce](https://community.sparkfun.com/u/vynce)\
**Post date:** [September 30, 2021, 5:59am UTC](https://community.sparkfun.com/t/thing-plus-bootloader-source/42820/1 "2021-09-30T05:59:51Z")

</div>

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](https://github.com/sparkfun/Arduino_Boards/tree/master/sparkfun/samd/bootloaders/SAMD51)

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

and Adafruit has a fork with a lot of changes here: [https://github.com/adafruit/uf2-samdx1](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](https://forum.sparkfun.com/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://github.com/adafruit/uf2-samdx1/pull/111)

[https://blog.adafruit.com/2020/04/13/uf … m4-boards/](https://blog.adafruit.com/2020/04/13/uf2-bootloader-news-downloads-in-circuitpython-org-new-version-for-samd51-m4-boards/)

[https://learn.adafruit.com/adafruit-fea … bootloader](https://learn.adafruit.com/adafruit-feather-m4-express-atsamd51/update-the-uf2-bootloader)

---

<div class="post-metadata">

**Author:** ![wonder\_boom](https://yyz1.discourse-cdn.com/sparkfun/user_avatar/community.sparkfun.com/wonder_boom/32/6096_2.png) [@wonder\_boom](https://community.sparkfun.com/u/wonder_boom)\
**Post date:** [September 30, 2021, 7:38pm UTC](https://community.sparkfun.com/t/thing-plus-bootloader-source/42820/2 "2021-09-30T19:38:24Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![wonder\_boom](https://yyz1.discourse-cdn.com/sparkfun/user_avatar/community.sparkfun.com/wonder_boom/32/6096_2.png) [@wonder\_boom](https://community.sparkfun.com/u/wonder_boom)\
**Post date:** [October 1, 2021, 3:19pm UTC](https://community.sparkfun.com/t/thing-plus-bootloader-source/42820/3 "2021-10-01T15:19:19Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![vynce](https://yyz1.discourse-cdn.com/sparkfun/user_avatar/community.sparkfun.com/vynce/32/6135_2.png) [@vynce](https://community.sparkfun.com/u/vynce)\
**Post date:** [October 4, 2021, 12:07am UTC](https://community.sparkfun.com/t/thing-plus-bootloader-source/42820/4 "2021-10-04T00:07:54Z")

</div>

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**

```auto
CHIP_FAMILY = samd51
CHIP_VARIANT = SAMD51J20A

```

**board\_config.h**

```auto
#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](https://community.sparkfun.com/uploads/short-url/odsiLRDYBtzaqcijJTjSlknIJ1.zip) (700 Bytes)

---

<div class="post-metadata">

**Author:** ![vynce](https://yyz1.discourse-cdn.com/sparkfun/user_avatar/community.sparkfun.com/vynce/32/6135_2.png) [@vynce](https://community.sparkfun.com/u/vynce)\
**Post date:** [October 4, 2021, 12:35am UTC](https://community.sparkfun.com/t/thing-plus-bootloader-source/42820/5 "2021-10-04T00:35:07Z")

</div>

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](https://forum.sparkfun.com/download/file.php?id=6893)

 ![uf2-samdx1_ms_vs_adafruit.png](https://canada1.discourse-cdn.com/sparkfun/original/3X/5/3/535905abb06d28275440b9050c0ad994a97f304f.png)

---

<div class="post-metadata">

**Author:** ![vynce](https://yyz1.discourse-cdn.com/sparkfun/user_avatar/community.sparkfun.com/vynce/32/6135_2.png) [@vynce](https://community.sparkfun.com/u/vynce)\
**Post date:** [October 4, 2021, 12:53am UTC](https://community.sparkfun.com/t/thing-plus-bootloader-source/42820/6 "2021-10-04T00:53:00Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![wonder\_boom](https://yyz1.discourse-cdn.com/sparkfun/user_avatar/community.sparkfun.com/wonder_boom/32/6096_2.png) [@wonder\_boom](https://community.sparkfun.com/u/wonder_boom)\
**Post date:** [October 4, 2021, 5:51pm UTC](https://community.sparkfun.com/t/thing-plus-bootloader-source/42820/7 "2021-10-04T17:51:55Z")

</div>

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](https://github.com/sparkfun/SAMD51_Thing_Plus)

Thanks!

---

<div class="post-metadata">

**Author:** ![vynce](https://yyz1.discourse-cdn.com/sparkfun/user_avatar/community.sparkfun.com/vynce/32/6135_2.png) [@vynce](https://community.sparkfun.com/u/vynce)\
**Post date:** [October 5, 2021, 5:19am UTC](https://community.sparkfun.com/t/thing-plus-bootloader-source/42820/8 "2021-10-05T05:19:54Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![vynce](https://yyz1.discourse-cdn.com/sparkfun/user_avatar/community.sparkfun.com/vynce/32/6135_2.png) [@vynce](https://community.sparkfun.com/u/vynce)\
**Post date:** [October 6, 2021, 5:01am UTC](https://community.sparkfun.com/t/thing-plus-bootloader-source/42820/9 "2021-10-06T05:01:53Z")

</div>

[https://github.com/sparkfun/SAMD51\_Thing\_Plus/pull/2](https://github.com/sparkfun/SAMD51_Thing_Plus/pull/2)

---

<div class="post-metadata">

**Author:** ![x130844](https://avatars.discourse-cdn.com/v4/letter/x/3bc359/32.png) [@x130844](https://community.sparkfun.com/u/x130844)\
**Post date:** [February 12, 2022, 7:44am UTC](https://community.sparkfun.com/t/thing-plus-bootloader-source/42820/10 "2022-02-12T07:44:43Z")

</div>

> 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!

---

<div class="post-metadata">

**Author:** ![vynce](https://yyz1.discourse-cdn.com/sparkfun/user_avatar/community.sparkfun.com/vynce/32/6135_2.png) [@vynce](https://community.sparkfun.com/u/vynce)\
**Post date:** [February 12, 2022, 7:09pm UTC](https://community.sparkfun.com/t/thing-plus-bootloader-source/42820/11 "2022-02-12T19:09:26Z")

</div>

> 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](https://github.com/sparkfun/SAMD51_Thing_Plus/pull/2/commits/4b5b61ea15a099e99139af206e16e3b233d59143), which is part of the [[pending PR](https://github.com/sparkfun/SAMD51_Thing_Plus/pull/2).

To update, double-tap the reset button on the board and copy [[update-bootloader-sparkfun-samd51-thingplus-v3.13.0.uf2](https://github.com/sparkfun/SAMD51_Thing_Plus/raw/4b5b61ea15a099e99139af206e16e3b233d59143/uf2-bootloader/uf2_bin/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](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](https://github.com/sparkfun/SAMD51_Thing_Plus/pull/2))]([Add uf2-samdx1 board config and updated bootloader by Vynce · Pull Request #2 · sparkfun/SAMD51\_Thing\_Plus · GitHub](https://github.com/sparkfun/SAMD51_Thing_Plus/pull/2/commits/4b5b61ea15a099e99139af206e16e3b233d59143))

---

<div class="post-metadata">

**Author:** ![wonder\_boom](https://yyz1.discourse-cdn.com/sparkfun/user_avatar/community.sparkfun.com/wonder_boom/32/6096_2.png) [@wonder\_boom](https://community.sparkfun.com/u/wonder_boom)\
**Post date:** [March 22, 2024, 7:25pm UTC](https://community.sparkfun.com/t/thing-plus-bootloader-source/42820/12 "2024-03-22T19:25:14Z")

</div>

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.
