Skip to content

uCompute — Custom MicroPython Firmware

JPMichon edited this page Oct 31, 2026 · 3 revisions

💾 Custom MicroPython Firmware Compilation & QFlash Expansion

By default, flashing the official, "vanilla" Raspberry Pi Pico firmware limits your available Flash storage space to 2 MB, even if your custom hardware board integrates a larger 4 MB, 8 MB, or 16 MB QFlash chip.

To unlock and map the full capacity of your custom uCompute or uCompute2 boards, you must compile a custom MicroPython firmware binarie by customizing the target board definition files.


🧠 Why a Custom Firmware is Required

MicroPython targets hardware profiles during compilation using specific board definitions (mpconfigboard.h and mpconfigboard.cmake). These definitions hardcode the flash size properties:

  • MICROPY_HW_FLASH_STORAGE_BYTES: Defines the virtual filesystem space boundaries allocated for user scripts.
  • If mismatched, the system will either truncate your storage capacity to 2 MB or fail to mount the flash memory safely.

🛠️ Prerequisites & Build Environment

Before compilation, you must set up the official MicroPython cross-compiler build stack on a Linux machine (or WSL):

  1. Install Build Dependencies: Install CMake, build-essential tools, and the GNU Arm Embedded Toolchain (gcc-arm-none-eabi).
  2. Clone the MicroPython Repository: Ensure you recursively pull all submodules:
    git clone --recursive https://github.com
    cd micropython
  3. Compile the Cross-Compiler (mpy-cross): This helper framework is mandatory for completing the final firmware building stages:
    make -C mpy-cross

🚀 Step-by-Step Compilation Protocol

To create your personalized profile (e.g., creating a UCOMPUTE target for a 4 MB flash configuration):

Step 1: Navigate to the Architecture Port

Move into the RP2 microcontroller target subdirectory:

cd ports/rp2

Step 2: Create a Custom Board Profile

Generate a new board profile folder inside the hardware definitions directory:

mkdir boards/UCOMPUTE

Step 3: Populate Board Configuration Files

Populate your newly created boards/UCOMPUTE/ folder with three files:

mpconfigboard.cmake

Sets the system clock limits and adjusts the flash chip sizing configurations:

set(MICROPY_HW_BOARD_NAME "uCompute RP2040 Custom")
set(MICROPY_HW_MCU "RP2040")

# Adjust flash sizing boundaries (e.g., 4MB configuration setup)
set(MICROPY_HW_FLASH_STORAGE_BYTES (4 * 1024 * 1024)) 

mpconfigboard.h

Overrides internal C macro properties used by the kernel layer:

#define MICROPY_HW_BOARD_NAME          "uCompute Custom"
#define MICROPY_HW_MCU                 "RP2040"

// Explicitly declare target QFlash hardware metrics
#define MICROPY_HW_FLASH_STORAGE_BYTES (4 * 1024 * 1024)

pins.csv

Map your custom hardware layout references for peripheral identification.

Step 4: Run the Compilation Build

Trigger the make builder architecture while passing your explicit custom profile label:

make BOARD=UCOMPUTE

Once compilation sequences complete successfully, your flashable, expanded firmware.uf2 file will be waiting inside the compiled build-UCOMPUTE/ directory.


⚡ Flashing the Expanded Storage

  1. Press and hold the physical BOOT button on your custom board.
  2. Connect your computer interface to the board via a USB Type-C cable.
  3. Drag and drop your compiled firmware.uf2 directly into the virtual storage drive directory.

The system resets automatically, granting your custom environment immediate access to the full expanded storage capacity!


🚀 MicroPython v1.24+ Architecture Shifts: The RP2350 Case (uCompute2)

Compiling for the next-generation RP2350 (uCompute2) introduces a major structural change in the MicroPython repository layout. Starting with MicroPython v1.24+, the build system merges architecture profiles to accommodate both the ARM Cortex-M33 and the Hazard3 RISC-V cores.

🗺️ The New Repository Path

Instead of operating inside ports/rp2, the target source folder has been renamed to unify the platform:

cd ports/rp2_pico

You must place your custom board definition directory inside ports/rp2_pico/boards/UCOMPUTE2/.

🎛️ Compilation Command Shift

When compiling for the RP2350, you must explicitly pass the architecture sub-variant using CMake variables to target the correct compiler flags:

make BOARD=UCOMPUTE2 VARIANT=RP2350

⚠️ The Vanilla Firmware Fallback (Backward Compatibility)

A major strength of the uCompute hardware DNA is its resilience and backward compatibility:

  • It Will Boot: If you flash an official, "vanilla" Raspberry Pi Pico or Pico 2 firmware binary onto a custom uCompute board, the system will work perfectly fine. The microcontroller will boot, the GPIOs will map correctly, and you can run your MicroPython scripts immediately.
  • The Sizing Penalty: The only drawback is that the official binaire enforces a strict 2 MB memory cap. Any extra flash capacity soldered onto your custom board (4 MB, 8 MB, or 16 MB) will remain invisible and unallocated until you flash a dedicated, custom-compiled firmware.

🎓 Advanced Value for Educational Labs & Advanced Makers

This customization technique removes absolute dependencies on pre-assembled modules and provides an advanced pedagogical exercise for computer engineering students:

  • Teaches how memory maps (Flash Storage Layouts) partition firmware binaries from file storage environments.
  • Introduces standard hardware abstraction layering principles used throughout embedded system software stacks.

Clone this wiki locally