How to build a UF2 file for Clue?

For CircuitPython issues, ask in the Adafruit CircuitPython forum.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
jmaloney
 
Posts: 49
Joined: Fri Apr 27, 2018 8:33 am

How to build a UF2 file for Clue?

Post by jmaloney »

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!

User avatar
adafruit2
 
Posts: 22144
Joined: Fri Mar 11, 2005 7:36 pm

Re: How to build a UF2 file for Clue?

Post by adafruit2 »

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

User avatar
jmaloney
 
Posts: 49
Joined: Fri Apr 27, 2018 8:33 am

Re: How to build a UF2 file for Clue?

Post by jmaloney »

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.

User avatar
adafruit2
 
Posts: 22144
Joined: Fri Mar 11, 2005 7:36 pm

Re: How to build a UF2 file for Clue?

Post by adafruit2 »

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

User avatar
jmaloney
 
Posts: 49
Joined: Fri Apr 27, 2018 8:33 am

Re: How to build a UF2 file for Clue?

Post by jmaloney »

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?

User avatar
adafruit2
 
Posts: 22144
Joined: Fri Mar 11, 2005 7:36 pm

Re: How to build a UF2 file for Clue?

Post by adafruit2 »

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

User avatar
jmaloney
 
Posts: 49
Joined: Fri Apr 27, 2018 8:33 am

Re: How to build a UF2 file for Clue?

Post by jmaloney »

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.

User avatar
jmaloney
 
Posts: 49
Joined: Fri Apr 27, 2018 8:33 am

Re: How to build a UF2 file for Clue?

Post by jmaloney »

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.

Locked
Please be positive and constructive with your questions and comments.

Return to “CLUE Board”