For those of you wanting to build MicroPython with Zephyr; this is my "worked for me" guide using a Raspberry Pi Pico (RP2040).
No guarantees, E&OE, but fingers crossed, and hopefully it may help others, especially those not having the first idea as to where to start.
You may need to adjust the paths to match where your top-level 'zephyrproject' directory is and maybe its name, and the same goes for 'micropython'.
You will want to remove the two in-line environment variable definitions before the "west build" and the last "-DSYSROOT_DIR=" line if not wanting to use the 'apt' installed 'arm-none-eabi' compiler.
These instructions should be usable in any directory and building shouldn't create any output in that directory. It will however create a 'zephyrproject/zephyr/build-micropython_pico' sub-directory where the UF2 is placed.
The build takes about 2 minutes on a Pi 4B 1GB, Bookworm 32-bit. The UF2 (235KB) is considerably smaller than an RP2 build for the Pico (310KB) - I am not sure what the Zephyr build has dropped and isn't available from the REPL.
Put your Pico into BOOTSEL mode then upload the MicroPython UF2, using 'picotool' or some other means -Ctrl-A then X to exit.
And for those curious -
No guarantees, E&OE, but fingers crossed, and hopefully it may help others, especially those not having the first idea as to where to start.
You may need to adjust the paths to match where your top-level 'zephyrproject' directory is and maybe its name, and the same goes for 'micropython'.
You will want to remove the two in-line environment variable definitions before the "west build" and the last "-DSYSROOT_DIR=" line if not wanting to use the 'apt' installed 'arm-none-eabi' compiler.
These instructions should be usable in any directory and building shouldn't create any output in that directory. It will however create a 'zephyrproject/zephyr/build-micropython_pico' sub-directory where the UF2 is placed.
The build takes about 2 minutes on a Pi 4B 1GB, Bookworm 32-bit. The UF2 (235KB) is considerably smaller than an RP2 build for the Pico (310KB) - I am not sure what the Zephyr build has dropped and isn't available from the REPL.
Code:
source ~/pico/zephyrproject/.venv/bin/activatecd ~/pico/zephyrproject/zephyrZEPHYR_TOOLCHAIN_VARIANT=cross-compile \CROSS_COMPILE=/usr/bin/arm-none-eabi- \west build \ -p always \ -d build-micropython_pico \ -b rpi_pico \ ~/pico/micropython/ports/zephyr \ -- \ -DSYSROOT_DIR=/usr/lib/arm-none-eabi/newlibCode:
picotool load -x ~/pico/zephyrproject/zephyr/build-micropython_pico/zephyr/zephyr.uf2Code:
pi@Pi4B:~ $ minicom -D /dev/ttyACM0*** Booting Zephyr OS build v4.2.0-3647-g67f246477f93 ***MicroPython v1.27.0-preview.128.gd441788975.dirty on 2025-09-16; zephyr-rpi_pico with rp2040Type "help()" for more information.>>> print("Yay!")Yay!>>>And for those curious -
Code:
pi@Pi4B:~ $ lsusbBus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hubBus 001 Device 058: ID 2fe3:0001 NordicSemiconductor Micropython on Zephyr RTOS <---Bus 001 Device 002: ID 2109:3431 VIA Labs, Inc. HubBus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hubCode:
pi@Pi4B:~ $ dmesg...[683934.690459] usb 1-1.4: new full-speed USB device number 58 using xhci_hcd[683934.789795] usb 1-1.4: New USB device found, idVendor=2fe3, idProduct=0001, bcdDevice= 4.02[683934.789809] usb 1-1.4: New USB device strings: Mfr=1, Product=2, SerialNumber=3[683934.789815] usb 1-1.4: Product: Micropython on Zephyr RTOS[683934.789819] usb 1-1.4: Manufacturer: Zephyr Project[683934.789824] usb 1-1.4: SerialNumber: E660583883278628[683934.797418] cdc_acm 1-1.4:1.0: ttyACM0: USB ACM deviceStatistics: Posted by hippy — Tue Sep 16, 2025 1:59 am