File Exchange

image thumbnail

Simulink Coder Support Package for BBC micro:bit Board

Tech Preview that generates and deploys code for BBC micro:bit


Updated 21 Oct 2019

Simulink® Coder™ Support Package for BBC micro:bit enables you to design Simulink models and run them on the BBC micro:bit. The support package includes a library of Simulink blocks giving access to on-chip and on-board peripherals like accelerometer, magnetometer, 5x5 LED Matrix, IO pins etc. The model can be deployed to the hardware in one click including automatic flashing of the hardware. The support package also supports signal logging and parameter tuning while the code runs in real-time via External mode.
Note: This support package is a Technology Preview. Technology Previews provide advanced access to potential new product features. This gives you an opportunity to test out the functionality and provide feedback. As it is a Technology Preview, there may be functional limitations. Some features may change in future versions.

This support package is functional for releases from R2016b onwards.
Platforms support : Windows 64-bit and Mac

Check out the getting started video for the support package here:


This video shows you how to install the Simulink Coder™ Support Package for BBC micro:bit and how to update the firmware on the BBC micro:bit board to fully take advantage of all the capabilities of the support package


This video shows you how to create a Simulink® model to display a happy face on the 5x5 LED matrix present on the BBC micro:bit board. It also goes through the list of Simulink blocks allowing you to access peripherals on the board like ADC, PWM, Accelerometer, Magnetometer, GPIO, LED, I²C, SPI, Radio communications, etc


This video shows you how to create a Simulink® model that reacts on the accelerometer data to display different patterns on the 5x5 LED matrix present on the BBC micro:bit board. You will learn how to visualize signals and tune the parameters while the model is running in real-time on the hardware.

If you have download or installation issues, please contact Technical Support:

Comments and Ratings (14)


Hi Benoit,

I'm speculating that you don't have background time left for External mode to run.
External mode needs to run in the background and needs time left by the regular periodic loops to execute.
Make sure that your model allows that. For instance if you create a while loop waiting for an I2C message and that message never comes, you will kill external mode by not leaving background time.
You should also check which micro:bit board you are using.
I encourage you to use the scani2cbus function in MATLAB IO mode ( to check the I2C slave addresses present on the board.
That may be helpful to debug your code.
I hope it helps,

Hello everyone,
I need help ...
I'm unable to use simulink I2C Master Write or Master Read. The block give a status error code : 4.
Accellerometer and Magnetomer don't work in external mode :
Error occurred while executing External Mode MEX-file 'ext_comm':
ExtSetTargetPkt() call failed on CLOSE.
Ensure target is still running

I use simulink 9.0 (R2018b) 24-May-2018 with a micro:bit with 0253_kl26z_microbit_0x8000.hex firmware

Hmmm and it works now... I dont know why... but it works :)


Hi Martin,
Sorry, we are aware of this issue and we are trying to resolve it as fast as possible.
We should have it resolved by tomorrow.
I hope it helps,

I have some issue (R2018b, macOS Mojave 10.14.1).

Download Error

Failed to download the third-party software:
Mbed Library

This is required by:
Simulink Coder Support Package for BBC microbit Board


Hi Aswad,

Looks like there is an issue with the download of the Support Package. Could you please follow the steps to re-install the support package:
(If the Simulink Coder Support Package for BBC micro:bit Board is the only Support Package you have)
1) Uninstall the support package from Manage add-ons.
2) Go to the support package installation area are delete the remaining files and folders:
- In the MATLAB command window type: cd (matlabshared.supportpkg.getSupportPackageRoot)
- Delete the entire contents of the current MATLAB folder.
3) Go to downloads folder and delete the folder named MathWorks.
4) In the MATLAB command window type cd (tempdir) and hit enter. Delete the folders starting with 3p (ex: 3p.instrset_downloads4257019114058623838)
5) Re-install the Support Package from Add-ons.

In case you have more Support Packages installed, please share you email ID and I'll provide clear instructions to re-install the Support Package.

Aswad Akram

Hi Everyone,

Please help me as I am getting the following error while deploying to the Microbit:
### Build procedure for model: 'untitled' aborted due to an error.
Error Report: Command "matlabshared.toolchain.gnu_gcc_arm.setup();" threw an error: The path 'C:\ProgramData\MATLAB\SupportPackages\R2017a\3P.instrset\gnuarm-armcortex.instrset\bin' does not exist.
Caused by:
Validation error(s):
Command "matlabshared.toolchain.gnu_gcc_arm.setup();" threw an error: The path 'C:\ProgramData\MATLAB\SupportPackages\R2017a\3P.instrset\gnuarm-armcortex.instrset\bin' does not exist.


Hi Everyone,
The R2018a version of MATLAB is live now. We added two new Simulink Audio Blocks (Note Generator and Play Note) to the support package.
For more examples, please refer the following link:

You can also write MATLAB scripts to program your BBC Micro:bit board.
For more information, please refer the link :

The Support package is now available with R2017a and You can now install on the R2017a. The 17a version comes up with fast external mode.

Hi, I seem to be unable to use this support package with R2017a! Is this not anymore compatible with the latest Matlab release or is there a further update to this package?

MATLAB Release Compatibility
Created with R2016b
Compatible with R2016b to R2019b
Platform Compatibility
Windows macOS Linux