hippy
Posts: 9664
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

[SOLVED] UF2 file specification

Mon Apr 12, 2021 8:06 pm

Does anyone know, have a link to, or know where to find, the full requirements for a .uf2 file which can be loaded to a Pico when in BOOTSEL mode ?

Currently I can copy my .uf2 to the RPI-RP2 drive using my Pi but it just sits there, presumably because the Boot Rom did not like it.

'Picotool reports "UF2 file does not contain a valid RP2 executable image" though other UF2 utilities I have report it as correct. I have looked at the Boot Rom source code but couldn't see anything there which helps me.
Last edited by hippy on Tue Apr 13, 2021 2:11 pm, edited 1 time in total.

kilograham
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 472
Joined: Fri Apr 12, 2019 11:00 am
Location: austin tx

Re: UF2 file specification

Mon Apr 12, 2021 9:20 pm

https://datasheets.raspberrypi.org/rp20 ... asheet.pdf section 2.8.3.2

spec is at https://github.com/microsoft/uf2

and yes, the set of UF2s that may be installed on your RP2040 is a subset of all valid UF2 files.

hippy
Posts: 9664
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

Re: UF2 file specification

Mon Apr 12, 2021 10:21 pm

kilograham wrote:
Mon Apr 12, 2021 9:20 pm
https://datasheets.raspberrypi.org/rp20 ... asheet.pdf section 2.8.3.2

spec is at https://github.com/microsoft/uf2

and yes, the set of UF2s that may be installed on your RP2040 is a subset of all valid UF2 files.
The picotool "not valid" issue has gone away - not entirely sure what I did to fix that - but the .uf2 still won't load.

Everything seems compliant with the RP2040 datasheet, all blocks have correct head, tail, flags and family, sequence numbers increment consecutively, all 'total blocks' are right, all data is in the Flash address space ( less, because below 1MB ), all blocks are 256 bytes, start on 256 byte boundaries, are consecutive. I also have the checksum as the last 4 bytes loaded and that matches what's in a .uf2 which does work for a same first 252 byes of image.

I'm guessing the Boot Rom itself has 'uf2_debug' disabled and there's no way to enable those reports.

Any suggestions on going about finding out how what I have it diverges from what the Boot Rom loader expects ?

kilograham
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 472
Joined: Fri Apr 12, 2019 11:00 am
Location: austin tx

Re: UF2 file specification

Mon Apr 12, 2021 11:11 pm

hippy wrote:
Mon Apr 12, 2021 10:21 pm

I'm guessing the Boot Rom itself has 'uf2_debug' disabled and there's no way to enable those reports.
indeed nothing you can do there!
Any suggestions on going about finding out how what I have it diverges from what the Boot Rom loader expects ?
You can see what picotool load -x foo.uf2 says. that performs some similar checks; I'm guessing you may not have address 10000000 included/mapped at all which is required?

hippy
Posts: 9664
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

Re: UF2 file specification

Mon Apr 12, 2021 11:25 pm

kilograham wrote:
Mon Apr 12, 2021 11:11 pm
You can see what picotool load -x foo.uf2 says. that performs some similar checks; I'm guessing you may not have address 10000000 included/mapped at all which is required?
Thanks but ...

Code: Select all

No accessible RP2040 devices in BOOTSEL mode were found.

but:

Device at bus 1, address 26 appears to be a RP2040 device in BOOTSEL mode, but picotool was unable to connect
Not sure what that means, or how to fix it, but I have refactored the code and now it's working - Not sure what actually fixed things. 0x10000000 was there and the rest ascending.

I'm wondering if it was because I didn't cycle it back into BOOTSEL mode and, having failed the first time, wouldn't work later. It was only another 'black screen of death' and 'File Manager has stopped responding' which had me reboot and do that. Who knows, but it's working now.

Now all I have to do is figure out why my code can read the data I add if I make it contiguous with what was in the original executable, but not when I align it to a later 4K page boundary.

kilograham
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 472
Joined: Fri Apr 12, 2019 11:00 am
Location: austin tx

Re: UF2 file specification

Tue Apr 13, 2021 12:10 am

hippy wrote:
Mon Apr 12, 2021 11:25 pm
Thanks but ...

Code: Select all

No accessible RP2040 devices in BOOTSEL mode were found.

but:

Device at bus 1, address 26 appears to be a RP2040 device in BOOTSEL mode, but picotool was unable to connect
Not sure what that means, or how to fix it, but I have refactored the code and now it's working - Not sure what actually fixed things. 0x10000000 was there and the rest ascending.
Likely caused on Windows by not having installed a USB driver. Use https://zadig.akeo.ie/ if you for picotool to be able to talk to connect to the device (same as picoprobe)
Now all I have to do is figure out why my code can read the data I add if I make it contiguous with what was in the original executable, but not when I align it to a later 4K page boundary.
No idea, what you are trying to do, so i'll leave you to it.

hippy
Posts: 9664
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

Re: UF2 file specification

Tue Apr 13, 2021 12:32 am

kilograham wrote:
Tue Apr 13, 2021 12:10 am
Likely caused on Windows by not having installed a USB driver.
Unlikely when using a Pi 3B :D

kilograham
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 472
Joined: Fri Apr 12, 2019 11:00 am
Location: austin tx

Re: UF2 file specification

Tue Apr 13, 2021 3:08 am

ah then you need to sudo or add a udev rule to give yourself access to the VID/PID

hippy
Posts: 9664
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

Re: UF2 file specification

Tue Apr 13, 2021 11:33 am

Yes, it was forgetting to ask "please, pretty please", not using 'sudo'.

Return to “General”