Please note: Friday June 18 is a holiday celebrating Juneteenth, please allow extra time for your order to arrive and plan accordingly.
0

How to build a UF2 file for Clue?
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

How to build a UF2 file for Clue?

by jmaloney on Sat Jul 25, 2020 10:09 am

I use PlatformIO to compile the MicroBlocks firmware for all the boards we support, including the Circuit Playground Express, Circuit Playground Bluefruit, and Clue. For Adafruit boards, I use uf2conv.py to convert the .hex file to a .uf2 that users can install by dropping it onto the USB drive for the board. The process works great for all the other AdaFruit boards we support but for some reason it is not working for the Clue.

I can copy the .uf2 to the board, but the board does not recognize and install it.

That board *does* install adafruit-circuitpython-clue_nrf52840_express-en_US-5.3.0.uf2 by drag-and-drop, so the hardware and bootloader are okay.

I grabbed the latest uf2conv.py from https://github.com/microsoft/uf2/blob/m ... uf2conv.py but that did not help.

Is there another place where I should get uf2conv.py? Does AdaFruit have a customized version of that tool?

Thanks!

jmaloney
 
Posts: 46
Joined: Fri Apr 27, 2018 8:33 am

Re: How to build a UF2 file for Clue?

by adafruit2 on Thu Aug 20, 2020 12:11 pm

if you upload that code directly from platformio does it work then?

adafruit2
Site Admin
 
Posts: 20054
Joined: Fri Mar 11, 2005 7:36 pm

Re: How to build a UF2 file for Clue?

by jmaloney on Thu Aug 20, 2020 12:52 pm

Yes, the MicroBlocks firmware (virtual machine) runs fine when installed with PlatformIO. That's how I've been testing it. I haven't tried compiling and installing with the Arduino IDE but could do so if that information would be helpful.

jmaloney
 
Posts: 46
Joined: Fri Apr 27, 2018 8:33 am

Re: How to build a UF2 file for Clue?

by adafruit2 on Thu Aug 20, 2020 12:56 pm

double click to enter bootloader, remove the working CURRENT.UF2 - that is an image of the current firmware you can distrivbute

adafruit2
Site Admin
 
Posts: 20054
Joined: Fri Mar 11, 2005 7:36 pm

Re: How to build a UF2 file for Clue?

by jmaloney on Thu Aug 20, 2020 1:16 pm

I just verified that that works, and it is a clever workaround for the short term!

Longer term, it would be great to way to be able to automate production of the uf2 file with some command-line too since our entire build and release process is automated on a server using git hooks.

How is CURRENT.UF2 created? I don't see it in the .pio build folder. Is there a way to focus PlatformIO to generate a uf2 file?

jmaloney
 
Posts: 46
Joined: Fri Apr 27, 2018 8:33 am

Re: How to build a UF2 file for Clue?

by adafruit2 on Thu Aug 20, 2020 1:18 pm

we've never used platformio so we dont know. we only use arduino and it works for sure there

adafruit2
Site Admin
 
Posts: 20054
Joined: Fri Mar 11, 2005 7:36 pm

Re: How to build a UF2 file for Clue?

by jmaloney on Thu Aug 20, 2020 1:52 pm

I just tried compiling with the Arduino IDE, which generates a .hex file, then converting that into a .uf2 file. The resulting file also does not load and is clearly different from CURRENT.UF2. wc reports:

1703 4362 251392 clue.uf2
1613 7649 250880 CURRENT.UF2

It looks as though the problem is with the .hex -> .uf2 conversion process but, strangely, only for the Clue. We're using that process successfully for the micro:bit, Calliope mini, CIrcuit Playgroud Express, ItsyBitsy M0, and CIrcuit Playground Bluefruit. What's so special about the Clue? It is the largest binary in that set so that could be a clue. (ha!)

I was hoping you might have run into this issue yourselves and would know a solution. But no worries; I will take this up with the uf2 team at Microsoft.

Thanks for the tip about grabbing CURRENT.UF2 from the board. That's good to know about.

jmaloney
 
Posts: 46
Joined: Fri Apr 27, 2018 8:33 am

Re: How to build a UF2 file for Clue?

by jmaloney on Fri Aug 21, 2020 5:48 pm

Mystery solved!

Apparently the boot loader on the Clue only loads a uf2 file if it has the correct family ID. The boot loaders on all the other AdaFruit boards we support apparently don't care, so we hadn't been supplying any family ID to uf2conv.py. That just leaves the ID field in the uf2 file blank, which the other boot loaders accept.

The fix is simple: just add "-f 0xada52840" to the uf2conv.py command when converting a .hex or .bin file to a .uf2 file for the Clue.

For those who run into this issue other boards, a list of family ID's is here:

https://github.com/Microsoft/uf2

Note that the uf2conv.py source hasn't been updated to include the most recent list of family names (including the Clue's NRF52840). But that doesn't matter if you supply the family ID number (vs. its name) to the -f argument.

jmaloney
 
Posts: 46
Joined: Fri Apr 27, 2018 8:33 am

Please be positive and constructive with your questions and comments.