This repository provides a simple script to flash a micro:bit board, automatically archiving downloaded MakeCode hex files.
Plug in your micro:bit normally (no special buttons), then run:
scripts/flash.shIt will find the latest MakeCode .hex in your Downloads folder, flash it, and you're ready to go!
To see detailed logs and archive previous builds, use:
scripts/flash_dbg.shThe script will:
- Find the newest downloaded
microbit-*.hexfile in$HOME/Downloads. - Archive it to
archive/with a timestamp prefix. - Copy it as
microbit.hexto the connected micro:bit. - Compare SHA-1 checksums before and after flashing.
- Unmount the device and show kernel messages.
To update the DAPLink interface firmware on a micro:bit in maintenance mode, follow these steps:
- Unplug the micro:bit, then press and hold the reset button while plugging it back in to enter maintenance mode. It will mount as a drive labeled
MAINTENANCE. - (Optional) Verify the maintenance-mode drive is mounted:
lsblk -o LABEL,MOUNTPOINT | grep MAINTENANCE - Run the firmware update script:
scripts/flash_fw.sh
For Python-based micro:bit projects (for advanced users), we've included a template and VSCode setup to make editing and flashing easy.
- Python 3
- Install the
uflashtool:pip install uflash
- VSCode with the Python extension
- Open this folder in VSCode:
code . - Create (if needed) and edit a per-child Python file under
python/(for examplepython/axel/main.py) instead of the defaultpython/main.pyto organize code per kid. - Press
Ctrl+Shift+B(orCmd+Shift+Bon macOS) to run the Flash to micro:bit task, which will also archive your source to prevent accidental loss.
Behind the scenes this will call scripts/flash_py.sh, which:
- Converts the active
.pyfile to a.hexusingpy2hex(via the uflash package) and saves it to./build/. - Archives your
.pysource underpython/archive/orpython/<kid>/archive/with a timestamp. - Copies the
.hexto the connected micro:bit drive. - Syncs/unmounts the drive and checks for
FAIL.TXTso you get immediate feedback if something went wrong.
When everything is fine you will see a green “Flash successful!” message in the VS Code terminal and your Python program will start running on the board within a couple of seconds.
Want to see print() output or REPL messages? Run the Open serial console task:
- Press
F1→ Tasks: Run Task → Open serial console, or - Use the dedicated keybinding you may assign in VS Code.
This opens a miniterm session at 115200 baud on /dev/ttyACM0. Close it with Ctrl-] then Ctrl-D.
If you need to retrieve a MakeCode or previously flashed Python .hex file from the board, use the scripts/save_hex.sh helper:
scripts/save_hex.sh <kid_name> [dest_base_dir]This will copy microbit.hex from the connected micro:bit drive into a timestamped file under programs/<kid_name>/ by default (or the specified destination directory), making it easy to keep each child's programs organized.