Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

microbit DAL doesn't build on mbed 5 #224

jaustin opened this issue Oct 11, 2016 · 5 comments

microbit DAL doesn't build on mbed 5 #224

jaustin opened this issue Oct 11, 2016 · 5 comments


Copy link

jaustin commented Oct 11, 2016

By default, the DAL doesn't build on mbed 5- there are a small number of API changes and build system changes that need to be accommodated

Some of these have been made by @tyomitch here:

It is possible to use mbed 5 without the whole of mbed OS, and this would be a good step for micro:bit

Copy link
Contributor Author

jaustin commented Oct 11, 2016

@RidaJichi is also looking at aspects of this

Copy link

RidaJichi commented Oct 11, 2016

Right @jaustin
I managed to build a micro:bit Hello World for mbed os 5 by resorting to space optimization with using newlib-nano in mbed-os, beside the microbit-DAL changes introduced by @tyomitch in to make it compatible with mbed os 5.
Before this 'nano' optimization, 'mbed compile' showed that libc occupied ~2k of memory space. After the optimization, memory space occupied drops to less than half k.
Still, the stack size must be decreased below the default of 2k (1k is good), and BLE must be disabled as it is very memory hungry. BLE-specific code can also be hacked out of microbit ( as it can save ~1k for heap.

In conclusion, here is the recipe for bringing micro:bit Hello World (or another uBit app) to life on mbed-os 5 for now:
1- Copy application main.cpp file (from, or any of and add libraries to your mbed project
mbed add
mbed add
mbed add
2- Add the linker option "--specs=nano.specs" in mbed-os/tools/profiles/default.json (under "GCC_ARM" ["ld"] assuming gcc_arm toolchain)
3- Some adjustments:
mkdir microbit-dal/source/asm/TOOLCHAIN_ARM/
mkdir microbit-dal/source/asm/TOOLCHAIN_GCC_ARM/
mv microbit-dal/source/asm/CortexContextSwitch.s.armcc microbit-dal/source/asm/TOOLCHAIN_ARM/CortexContextSwitch.s
mv microbit-dal/source/asm/CortexContextSwitch.s.gcc microbit-dal/source/asm/TOOLCHAIN_GCC_ARM/CortexContextSwitch.s
4- Change the stack size from 2k (default) to 1k, specify ISR_STACK_SIZE, and disable BLE when compiling:
BLE can also be disabled by hard-resetting MICROBIT_BLE_ENABLED to 0 in microbit-dal/inc/core/MicroBitConfig.h
5- Flash the generated hex file in BUILD/NRF51_MICROBIT/GCC_ARM/.hex to the micro:bit

If the microbit application is single-threaded, the option "-DMBED_RTOS_SINGLE_THREAD" can be added in mbed-os/tools/profiles/default.json (under "GCC_ARM" ["common"] assuming gcc_arm toolchain).
If not, using newlib-nano can have implications on the microbit as it uses fibers rather than threads (still under investigation).

It is also possible to eliminate some parts of the mbed os while building the DAL, keeping the mbed SDK. This can be done by creating a .mbedignore file containing paths to the parts to be eliminated. The DAL can still be safely built after listing the following in the .mbedignore:

EDIT: step 2 could be omitted, but the stack size will have to decrease to around 0.5k to allow having heap space sufficient for the microbit demands (at least 1214 bytes of heap to init uBit resources) (all this with BLE still removed).

Copy link

finneyj commented Oct 19, 2016

Thanks @jaustin @RidaJichi

I'm very supportive of getting microbit-dal building against mainstream mbed, and resolving the issues we had to address in our local forks of the mbed repos along the way.

If I understand correctly, there are two aspects to mbed 5. There's mbed os proper, which includes your RTOS scheduler etc. Then there's the SDK, which is pretty much similar to the mbed 2.0 HAL? Are we looking to support both these builds?

For the SDK builds, we should be looking to have an equivalent (or ideally better!) build than we currently have against mbed classic.

For mbed-os proper, I presume you do want to support BLE though? This will be quite a significant aspect for your partners/customers won't it? So some thought required there methinks... Probably starting with an analysis of where the memory use is, and then perhaps a tweaked configuration of both mbed-os and microbit-dal to suit?

Copy link

OwenBrotherwood commented Jan 20, 2017

Is there a summary of WIP (Work In Progress or Who In Progress)?

Copy link

zerog2k commented Jan 1, 2018

Any progress on this? Also +1 on wanting mbedOS 5 support.
As I understand it, the hardware decision to use 16k nrf51822 severely limits available ram after the ble softdevice (s110? s130?) is using something like at least 9k+. But even without BLE support, keeping just the proprietary 2.4 GHz radio support (esb w/ gazell ?), seems still quite useful.

Is there any feature bounty on this which we could pitch in to?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet

No branches or pull requests

5 participants