State of bare metal micropython on Broadcom devices, ie Pi Zero 2? #16074
-
I've been googling for an hour trying to find someone who has done a project with bare metal micropython on Broadcom. |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments
-
The Pico 2 support has recently been merged so builds for it are available already on the downloads page: https://micropython.org/download/RPI_PICO2/ Note that the rp2040 and rp2350 (Pico 2) are both designed and built by the raspberry pi foundation, not Broadcom. While there is some level of support from Broadcom, they do not own / design these chips. Edit: oh sorry I misread your title and thought you were asking about Pico 2, rather than "full size" raspberry pi. |
Beta Was this translation helpful? Give feedback.
-
There is no official baremetal support for the Pi Zero 2. There may be unofficial ports. |
Beta Was this translation helpful? Give feedback.
-
In response to your other post I did some experiments. I could read x, y, and z acceleration values (from MPU9250) at 1KHz via a timer interrupt with a reasonable margin and no data loss. But writing to SD card failed to keep up. Hardware was STM32. While I haven't done detailed measurements it looks as if the application is I/O bound rather than CPU bound. I would concentrate on finding a faster mass storage device. Re implementation you might like to look at the new RingIO device. The ISR would fill it, and an [EDIT] import asyncio
from machine import Timer
from mpu9250 import MPU9250
import micropython
from time import ticks_diff, ticks_us
micropython.alloc_emergency_exception_buf(100)
imu = MPU9250('X')
FRAMESIZE = 8 # Count, x, y, z accel
BUFSIZE = 200 # No. of records
rio = micropython.RingIO(FRAMESIZE* BUFSIZE + 1)
count = 0x4000 # Start of frame marker in bit 14, frame count in lower bits
dtmax = 0
def cb(_):
global count, dtmax
t = ticks_us()
imu.get_accel_irq()
rio.write(int.to_bytes(count, 2, 'big'))
rio.write(int.to_bytes(imu.accel.ix, 2, 'big'))
rio.write(int.to_bytes(imu.accel.iy, 2, 'big'))
rio.write(int.to_bytes(imu.accel.iz, 2, 'big'))
count += 1
dtmax = max(dtmax, ticks_diff(ticks_us(), t))
async def main(nrecs):
t = Timer(freq=1000, callback=cb)
sreader = asyncio.StreamReader(rio)
rpb = 100 # Records per block
blocksize = FRAMESIZE * rpb
with open('/sd/imudata', 'wb') as f:
swriter = asyncio.StreamWriter(f, {})
while nrecs:
data = await sreader.readexactly(blocksize)
swriter.write(data)
await swriter.drain()
nrecs -= rpb
t.deinit()
print(f"dtmax: {dtmax}")
asyncio.run(main(1_000)) This runs here without data loss. The ISR takes ~600μs on a Pyboard 1.1. I used the driver I had: clearly ISR efficiency could be improved - my driver converts bytes to Another option if storage speed is an issue would be to shovel the bytes into a UART at 1Mbps and use a Raspberry Pi with fast storage to dump them to disk. |
Beta Was this translation helpful? Give feedback.
-
Zephyr has some support for the Broadcom SOCs in RPI4 and 5. https://docs.zephyrproject.org/latest/boards/raspberrypi/rpi_4b/doc/index.html |
Beta Was this translation helpful? Give feedback.
-
https://github.com/adafruit/circuitpython/tree/main/ports/broadcom is an alpha port to Broadcom that was done for CircuitPython. The lower levels of that might be interesting to you. On some of the boards, the flash writing to the filesystem is flaky. We are not really maintaining this port actively right now. |
Beta Was this translation helpful? Give feedback.
There is no official baremetal support for the Pi Zero 2. There may be unofficial ports.