bbcmicrobit / bbcmicrobit/micropython
Setup Guide for build environment on Debian 8 (Jessie)
- Dominant language
- C
- Stars
- 646
- Forks
- 290
- PR merge metrics
- No merged PRs in 30d
Description
I had to jump around the docs and ask others for help, and from this experience, I produced the following guide. The existing "Debian and Ubuntu" section of the installation guide specifies adding new APT repositories but I found this wasn't necessary for Debian, everything is in stable/main.
I feel there is no problem keeping a set of distro-specific setup guides, as long as someone is willing to maintain each guide, which I'm happy to do for Debian. I would break up the "Debian and Ubuntu" section of the installation docs into a separate section for each distro. (I would also work some of this into flashfirmware.rst and other docs.)
What do others think, would these contributions be welcome?
---
# Setup Guide: micro:bit MicroPython build environment on Debian 8 (Jessie)
This will allow you to build your own firmware and play with new features (like the radio module) which aren't in the official firmware yet. You don't need to do this if you only want to run Python code using the official firmware - you can just use Mu or uflash.
## APT Packages
All packages should be available in the Jessie/stable main repository. Open `/etc/apt/sources.list` and ensure that you have entries for the `jessie main` or `stable main` APT repository per Debian's [instructions](https://wiki.debian.org/SourcesList#Example_sources.list_for_Debian_8_.22Jessie.22).
Acquire root privileges with `su`, or install sudo and pre-pend `sudo` and a space to all of the following `apt-get` commands.
Run `apt-get update`, then install these packages by running `apt-get install`.
- binutils-arm-none-eabi
- gcc-arm-none-eabi
- libnewlib-arm-none-eabi
- libnewlib-dev
- libstdc++-arm-none-eabi-newlib
- srecord
- cmake
- ninja-build
- python-virtualenv
- python-dev
- libffi-dev
- libssl-dev
- git
Or, in one line:
```
apt-get install binutils-arm-none-eabi gcc-arm-none-eabi libnewlib-arm-none-eabi libnewlib-dev libstdc++-arm-none-eabi-newlib srecord cmake ninja-build python-virtualenv python-dev libffi-dev libssl-dev git
```
## Python Environment
Give up your root privileges (either stop using `sudo` or run `exit` if you used `su`). You shouldn't need them for the rest of the setup.
Create a virtualenv and activate it:
```
virtualenv microbit-venv
source microbit-venv/bin/activate
```
Install yotta, markupsafe (required by yotta), and uflash inside your virtualenv:
```
pip install yotta markupsafe uflash
```
## Get Repository
If you want to start with the official bbcmicrobit repo:
`git clone https://github.com/bbcmicrobit/micropython.git`
If you want to try the experimental radio module:
`git clone https://github.com/dpgeorge/bbcmicrobit-micropython.git`
## Building firmware
`cd` into the root of the repository and run `yt target bbc-microbit-classic-gcc-nosd`. This will prompt you to sign up for an ARM mbed account, and you will need to confirm your email address. After you sign up, run `yt target bbc-microbit-classic-gcc-nosd` again, log in with your browser when prompted. You may need to run the command a third time after logging in, it should eventually execute with no errors.
Update yotta and run the build:
```
yt up
yt build
```
If all goes well, your firmware .hex file will be saved to `build/bbc-microbit-classic-gcc-nosd/source/microbit-micropython.hex`.
## Flashing firmware
Plug in your micro:bit. It should be mounted as a mass storage device.
You can flash your new firmware either using uflash or by copying the .hex file. uflash allows you to flash with a Python script of your choosing, while copying the .hex file will just flash the firmware and the micro:bit will boot to the REPL. Whether you use uflash or copy a .hex file, the firmware will flash to the microbit, yellow LED will blink for a few seconds, and then the micro:bit will boot.
### Using uflash
General usage:
```
uflash -r [path to firmware] [path to Python file] [path to micro:bit mass storage volume]
```
Example:
```
uflash -r build/bbc-microbit-classic-gcc-nosd/source/microbit-micropython.hex examples/space_shoot_multiplayer.py /home/yourname/media/MICROBIT
```
### By copying a .hex file
Simply copy `build/bbc-microbit-classic-gcc-nosd/source/microbit-micropython.hex` from the repository to the root directory of the MICROBIT volume (probably at `/media/yourname/MICROBIT`).
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.