Skip to content

Starter project for Mbed OS with the micro:bit V2

License

Notifications You must be signed in to change notification settings

microbit-foundation/mbedos-microbit-v2-starter

Repository files navigation

Example micro:bit V2 project for Mbed OS

Table of contents

Features

This is a basic Mbed OS project for micro:bit V2.

Requirements

Building This Project

Available Targets

This project contains multiple Mbed OS "targets" for different versions of the micro:bit V2 board and for the Nordic nRF52833 DK development board.

  • nrf52_microbit_v2: Target for all production micro:bit V2 board versions.
  • nrf52833_dk: For the Nordic nRF52833 DK board (useful for testing).

Other targets are available for micro:bit V2 prototype boards, and their names can be found in the mbed_app.json file. These are essentially the same as the nrf52_microbit_v2 target, but for code to support multiple boards it is useful to have different target names to be able to do conditional compilation of pins, I2C addresses, etc, as shown in the sensors.cpp example code.

Even older prototype targets can be found in the mbedos-softdevice branch.

The version of the micro:bit V2 board can be seen on the silkscreen at the back, near the right side of the edge connector.

Interface MCU

The micro:bit V2.2 contains an nRF52 microcontroller as the Interface MCU and Mbed OS targets has been created to be able to create Mbed OS project for these microcontrollers as well.

  • nrf52_microbit_v2_if_820: Target for micro:bit V2.2 with a nRF52820 Interface MCU.
  • nrf52_microbit_v2_if_833: For a micro:bit V2.2 with a nRF52833 Interface MCU. This target is configured to be identical to the nrf52820 builds (including reduced RAM & Flash), with the only difference being some pin assignments.

Initialise the Project

Note that for the mbed target ... line you should select the right target for your board.

git clone https://github.com/microbit-foundation/mbedos-microbit-v2-starter.git
cd mbedos-microbit-v2-starter
mbed config root .
mbed target nrf52_microbit_v2
mbed toolchain GCC_ARM
mbed deploy

If it fails to install some of the Python dependencies on the last command (mbed deploy) you can try to install them manually.

Run this command in the Python environment that has mbed-cli installed:

pip install -r mbed-os/requirements.txt

Warning: Do not use mbed new . as it can update MbedOS to the latest version, and this is often unwanted.

Build

mbed compile

Or if you want to manually add the flags previously configured in the project on the "Initialise" section:

mbed compile -m nrf52_microbit_v2 -t GCC_ARM

Build output can be found in: ./BUILD/NRF52_MICROBIT_V2/GCC_ARM/mbedos-microbit-v2-starter.hex

If mbed cannot find the tools directory in mbed-os, then you may have to delete the mbed cache by removing ~/.mbed/.

Mbed OS Version

This repo is currently configured Mbed OS to version 6.13.0.