To use a prebuilt firmware, you can just use What that does is:
uflash
, tested on Ubuntu 22.04:git clone https://github.com/bbcmicrobit/micropython
cd micropython
git checkout 7fc33d13b31a915cbe90dc5d515c6337b5fa1660
uflash examples/led_dance.py
- convert the MicroPython code to bytecode
- join it up with a prebuilt firmware that ships with uflash which contains the MicroPython interpreter
- flashes that
To build your own firmware see:
Microbit simulator using some Microsoft framework.
TODO the Python code from there does not seem to run on the microbit via
uflash
, because it is not MicroPython.support.microbit.org/support/solutions/articles/19000111744-makecode-python-and-micropython explains.
forum.makecode.com/t/help-understanding-local-build-options/6130 asks how to compile locally and suggests it is possible. Seems to require Yotta, so presumably compiles?
Presumably this is because Microsoft ported their MakeCode thing to the MicroBit, and the Micro Bit foundation accepted them.
E.g. there toggling a LED:but the code that works locally is a completely differently named API Microsoft going all in on adopt extend extinguish from an early age!
led.toggle(0, 0)
set_pixel
:microbit.display.set_pixel(0, 0, )
Official support is abysmal, very focused on MicroPython and their graphical UI.
The setup impossible to achieve as it requires setting up the Yotta, just like the impossible to setup Compile MicroPython code for Micro Bit locally on Ubuntu 22.04 with your own firmware setup.
So we just use github.com/lancaster-university/microbit-samples + github.com/carlosperate/docker-microbit-toolchain:.hex file size for the hello world was 447 kB, much better than the MicroPython hello world downloaded from the website which was about 1.8 MB!
docker pull ghcr.io/carlosperate/microbit-toolchain:latest
git clone https://github.com/lancaster-university/microbit-samples
cd microbit-samples
git checkout 285f9acfb54fce2381339164b6fe5c1a7ebd39d5
# Select a sample, builds one at a time. The default one is the hello world.
cp source/examples/hello-world/* source
# Build and flash.
docker run -v $(pwd):/home --rm ghcr.io/carlosperate/microbit-toolchain:latest yotta build
cp build/bbc-microbit-classic-gcc/source/microbit-samples-combined.hex "/media/$USER/MICROBIT/"
If you try it again for a second time from a clean tree, it fails with:presumably because after Yotta died it started using GitHub as a registry... sad. When will people learn. Apparently we were at 5000 API calls per hour. But if you don't clean the tree, you will be just fine.
warning: github rate limit for anonymous requests exceeded: you must log in