Skip to content

Multiple bin/elf files to single UF2 file #277

@maxgerhardt

Description

@maxgerhardt

In reference to maxgerhardt/platform-raspberrypi#108.

Currently, the picotool does not support giving it multiple input files (and input filetypes and possible offsets) in the picotool convert convert command, only a single one.

I have the situation that I build a firmware.elf (firmware code) and a littelfs.bin (filesystem to be placed at 0x1037f000 in flash). I would like to combine both of those into a single UF2 image.

The tool does not support that.

However, in reference to the UF2 filesystem specification (https://github.com/microsoft/uf2/tree/d03b585ed780ed51bb0d1e6e8cf233aacb408305?tab=readme-ov-file#file-format), a UF2 file is simple a concatination of 512 byte blocks, each block having its target flash addresses embedded. As thus, I would expect if I concatenate two UF2 files, it will simply write all blocks of that UF2 file.

But, when I try to use

picotool uf2 convert "firmware.elf" "firmware.uf2"
picotool uf2 convert "littlefs.bin" "littlefs.uf2" --offset 0x1037f000
copy /b firmware.uf2+littlefs.uf2 firmware_with_fs.uf2

And I drag and drop that UF2 file to the pico's boot drive, the file copy simply stops after a short while (I assume after it copied the firmware part) and then resets, not accepting the filesystem part. An error about copying to a non-existing device occurs.

Image

When I upload the file via picotool, it uploads and works, showing two loading processes.

picotool.exe load -v -x "C:\Users\Max\.platformio\platforms\raspberrypi\examples\arduino-littlefs\.pio\build\rpipico2\firmware_with_fs.uf2"
Family id 'rp2350-arm-s' can be downloaded in absolute space:
  00000000->02000000
Loading into Flash: [==============================]  100%
Loading into Flash: [==============================]  100%
Verifying Flash:    [==============================]  100%
  OK
Verifying Flash:    [==============================]  100%
  OK

The device was rebooted to start the application.

The application then works.

------ Reading file1.txt -------
Hello!

Welcome to the Raspberry Pi Pico using arduino-pico!
------ file read successfully -------

How can I create a UF2 using picotool that is accepted by the BOOTSEL drive / MSC loader of a RP2350 and RP2040?

uf2_examples.zip

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions