wokwi / rp2040js

A Raspberry Pi Pico Emulator in JavaScript
MIT License
410 stars 46 forks source link

Create CircuitPython storage disk on macOS #138

Closed rgov closed 9 months ago

rgov commented 9 months ago

Just contributing some knowledge about how to create the CircuitPython storage volume on macOS:

$ truncate -s 1M fat12.img 
$ DEVICE=$(hdiutil attach -nomount -imagekey diskimage-class=CRawDiskImage fat12.img | awk '{print $1}')
$ diskutil info "$DEVICE" | grep -q "no file system" || echo "STOP NOW AVOID DATA LOSS"
$ sudo newfs_msdos -F 12 -S 512 "$DEVICE"
$ hdiutil detach "$DEVICE"

The resulting fat12.img can be mounted like any other disk image. Unmount when you're done populating it, then run the simulator:

$ npm run start:circuitpython                                                                    

> rp2040js@0.19.3 start:circuitpython
> tsx demo/micropython-run.ts --circuitpython

Loading uf2 image adafruit-circuitpython-raspberry_pi_pico-en_US-8.0.2.uf2
Auto-reload is on. Simply save files over USB to run them or enter REPL to disable.

Press any key to enter the REPL. Use CTRL-D to reload.

Adafruit CircuitPython 8.0.2 on 2023-02-14; Raspberry Pi Pico with rp2040
>>> import os
>>> os.listdir()
['hello_world.txt']
urish commented 9 months ago

Thank you!