Compile micropython from source for Badger 2040W and inky frame 4.0

I’ve been working on projects using the Raspberry PI Pico W and ran into some bugs in the CYW43 driver.
There are pull requests not yet closed in the micropython github.

I just received a Bader 2040W and an Inky Frame 4.0 in the post.
In the micropython github I do not see directories in ports/rp2/boards for either.

How can I build my own micropython interpreter for these boards?

Update:
I found a little bit about compiling micropython here: pimoroni-pico/setting-up-the-pico-sdk.md at main · pimoroni/pimoroni-pico · GitHub

Step 4 and step 5 seem prerequisites to compiling my own micropython.

But clearly there are files in pimoroni-pico/micropython that need to be copied into the official micropython source tree.
I see a shell script pimoroni-pico/micropython/_board/board-fixup.sh that copies files into the ports/rp2/boards directory in the official micropython source tree.
I did figure out how to run this script.

After that I could compile using:

make BOARD=PIMORONI_BADGER2040W

The resulting firmware.uf2 runs on the badger just fine.
But it does not have any pimoroni specific content like the picographics library.

I think, the contents of pimoroni-pico/micropython/modules and pimoroni-pico/micropython/modules_py need to be copied into official micropython source tree and then referenced from PIMORONI_BADGER2040W/manifest.py.
I’m not sure how to do this.

Pimoroni folks, your products are FOSS.
To meet that standard you need to provide the source code in a manner that your customers can compile it themselves.

Hello! Support have pointed me in the direction of this post.

There’s some info about the build process for our custom MicroPython in this issue. I’m not too well versed in the details of how it all hangs together so if you need to to know more about the nitty gritty you’re probably best posting on Github so you can talk to the software folks directly.

Alternatively, it is possible to get GitHub to do the building for you (easy mode!) by forking the repo for yourself, making your changes and then letting GitHub actions provide you with the builds under the actions tab, without having to worry about what files go where. Yezzer did a great post about how to do this for Galactic Unicorn that might be helpful: Galactic Unicorns and Custom Pimoroni Pico Firmware | by Iestyn Lloyd | Medium

To make things even more fun, we’ve just started the process of splitting the Badger / Badger W firmware off into its own repo which should (eventually!) help make the build process less opaque. If you want to take a look at the new repo you can find it here (not much in the way of documentation yet though).

2 Likes

Thanks, the issue you point to was helpful.
I can now build micropython for both the badger2040w and inky_frame.

2 Likes

I needed to pickup some recent changes to fix a problem using hershey fonts on my inky 4.0.

I tried to follow my (undocumented) recipe to build micropython from earlier.
Things have changed significantly.

My pimoroni-pico git repo is at commit 7b735213.
The file pimoroni-pico/micropython/_board/board-fixup.sh does not exist anymore.

There is a new file pimoroni-pico/micropython/board/pico-sdk-patch.sh which is only related to the C SDK.

I was able to compile for my inky 4.0 using:

make USER_C_MODULES=../../../pimoroni-pico/micropython/modules/micropython-inky_frame.cmake BOARD=PICO_W

The resulting firmware.uf2 file runs fine on my inky 4.0 and hershey fonts work fine.

I looked for a cmake file of C modules for badger2040w in pimoroni-pico/micropython/modules.
I don’t see one.

So, at this point I don’t know how to compile micropython for badger2040w.

Have you spotted that there’s a dedicated repo for Badger 2040 and Badger 2040 W now?

It looks like the cmake stuff that produces the MicroPython builds lives here.

I don’t know too much about how the nitty gritty of this stuff works - for more detailed info it might be best to open an issue on the new repo so you can talk to our software folks?

Alternatively, you could make a custom MicroPython build by forking the repo for yourself, committing your changes and then grabbing an auto-generated MicroPython build from the actions tab.

Your alternative suggestion does not work for me because I want to compile with changes to the main micropython repo.
The github build uses a fixed version of the micropython repo and a fixed version of pimoroni-pico repo.

I will open an issue in the github repo.

1 Like