Skip to content

Make universal blink example work with W boards#746

Merged
will-v-pi merged 6 commits into
developfrom
universal-w-blink
May 14, 2026
Merged

Make universal blink example work with W boards#746
will-v-pi merged 6 commits into
developfrom
universal-w-blink

Conversation

@will-v-pi
Copy link
Copy Markdown
Contributor

This detects between W and non-W boards using the ADC, as described in "Connecting to the Internet with Raspberry Pi Pico W-series"

This method should work for all boards powered from VSYS, which should cover all standard use cases for the blink example

This does increase the UF2 file size from 96KB to 1,023KB, as the combined UF2 contains 2 copies of the wifi firmware, but in flash it is still only half that size

Detects between W and non-W boards using the ADC, as described in "Connecting to the Internet with
Raspberry Pi Pico W-series"

This method should work for all boards powered from VSYS, which should cover all standard use cases for the blink example
Halves the size of the UF2 file, and halves the size in flash
Comment thread universal/blink_universal/blink_universal.c Outdated
Comment thread universal/blink_universal/blink_universal.c
Comment thread universal/blink_universal/blink_universal.c Outdated
Comment thread universal/CMakeLists.txt Outdated
@lurch
Copy link
Copy Markdown
Contributor

lurch commented Mar 23, 2026

I guess the universal.h is only designed to run on the official Raspberry Pi microcontroller boards (Pico, Pico W, Pico WH, Pico 2, Pico 2 W) rather than on any 3rd-party RP2040 or RP2350 boards, so perhaps it ought to be named something like pico_universal.h ?

@will-v-pi
Copy link
Copy Markdown
Contributor Author

I guess the universal.h is only designed to run on the official Raspberry Pi microcontroller boards (Pico, Pico W, Pico WH, Pico 2, Pico 2 W) rather than on any 3rd-party RP2040 or RP2350 boards, so perhaps it ought to be named something like pico_universal.h ?

It does run on quite a few 3rd-party boards - as long as they use the same LED and VSYS pins it will work (which applies to most of the boards on my desk)

@lurch
Copy link
Copy Markdown
Contributor

lurch commented Mar 23, 2026

It does run on quite a few 3rd-party boards - as long as they use the same LED and VSYS pins it will work (which applies to most of the boards on my desk)

Oh, neat!

Comment thread universal/blink_universal/blink_universal.c Outdated
@peterharperuk
Copy link
Copy Markdown
Contributor

Could we add an example partition json for this? And maybe a readme for how to run the universal examples on a blank Pico 2 board?

peterh@rpi5-peterh-dev2:~ $ picotool load blink_universal.uf2
WARNING: Multiple family IDs in a single UF2 file - only using first one
Family ID 'rp2040' cannot be downloaded anywhere
ERROR: This file cannot be loaded onto a device with no partition table

@will-v-pi
Copy link
Copy Markdown
Contributor Author

Could we add an example partition json for this? And maybe a readme for how to run the universal examples on a blank Pico 2 board?

peterh@rpi5-peterh-dev2:~ $ picotool load blink_universal.uf2
WARNING: Multiple family IDs in a single UF2 file - only using first one
Family ID 'rp2040' cannot be downloaded anywhere
ERROR: This file cannot be loaded onto a device with no partition table

This doesn't use partitions - the error you're getting is because when picotool sees two UF2s concatenated (which is what a universal UF2 is), it only uses the first file, which is the RP2040 one. That could be fixed, but this is an existing issue for all universal UF2s.

These universal UF2s are designed for drag & drop instead

@peterharperuk
Copy link
Copy Markdown
Contributor

These universal UF2s are designed for drag & drop instead

Ok, understood. It does work if you drag and drop. Maybe we should say this in the readme.

Also switch to board_type instead of is_w so the functions are clearer
peterharperuk
peterharperuk previously approved these changes Mar 25, 2026
Comment thread universal/README.md Outdated
Comment thread universal/README.md Outdated
Comment thread universal/README.md
Comment thread universal/blink_universal/blink_universal.c
Comment thread universal/blink_universal/blink_universal.c
Comment thread universal/README.md Outdated
Comment thread universal/README.md Outdated
Comment thread universal/README.md
Comment thread universal/README.md Outdated
Co-authored-by: Andrew Scheller <lurch@durge.org>
Co-authored-by: will-v-pi <108662275+will-v-pi@users.noreply.github.com>
peterharperuk
peterharperuk previously approved these changes May 13, 2026
Copy link
Copy Markdown
Contributor

@peterharperuk peterharperuk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It works. I seem to be getting an interesting copy error from windows (I don't remember getting this before?) with pico1 devices , presumably because the device has rebooted before the whole uf2 has been written? It still works despite this although it's a bit disconcerting.

@will-v-pi
Copy link
Copy Markdown
Contributor Author

It works. I seem to be getting an interesting copy error from windows (I don't remember getting this before?) with pico1 devices , presumably because the device has rebooted before the whole uf2 has been written? It still works despite this although it's a bit disconcerting.

Yes, I get that too - I think it doesn't occur for the smaller universal binaries because the device doesn't disappear until after Windows thinks it's loaded the whole file, but this one is larger so you get this error when the device disappears

Put last RP2040 UF2 block at the end of the file, so the transfer doesn't complete before the RP2350 UF2 has been fully copied (and ignored)
@will-v-pi
Copy link
Copy Markdown
Contributor Author

@peterharperuk I think I've fixed it with that latest commit - it now puts the last RP2040 UF2 block at the end of the file, so the RP2040 doesn't reboot until it has the whole file

The fix is gated to only run when compiling on Unix-like OSes, as it requires tail and truncate which may not be available on others. At some point this functionality could be added into picotool, but that can happen later.

Comment thread universal/CMakeLists.txt Outdated
@will-v-pi will-v-pi merged commit 41a1b48 into develop May 14, 2026
4 checks passed
@will-v-pi will-v-pi deleted the universal-w-blink branch May 14, 2026 16:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants