Unable to compile BBC micro:bit project using MBed Platform

I’m trying to create a “Hello World” project for BBC micro:bit, using MBed platform. Reference the following on MBed page:

System is Windows 10 64 bit.

I select New Project on the Home page, and select Board BBC micro:bit and Platform MBed. Using just the blank default code, when I try to build, I get the following:

Executing task: platformio.exe run <

[12/27/17 16:55:52] Processing bbcmicrobit (platform: nordicnrf51; board: bbcmicrobit; framework: mbed)

Verbose mode can be enabled via -v, --verbose option
AttributeError: ‘PlatformIOLibBuilder’ object has no attribute ‘get_inc_dirs’:
File “C:\Users\frank.platformio\penv\lib\site-packages\platformio\builder\main.py”, line 158:
File “C:\Users\frank.platformio\packages\tool-scons\script..\engine\SCons\Script\SConscript.py”, line 541:
return _SConscript(self.fs, *files, **subst_kw)
File “C:\Users\frank.platformio\packages\tool-scons\script..\engine\SCons\Script\SConscript.py”, line 250:
exec file in call_stack[-1].globals
File “C:\Users\frank.platformio\platforms\nordicnrf51\builder\main.py”, line 128:
target_elf = env.BuildProgram()
File “C:\Users\frank.platformio\packages\tool-scons\script..\engine\SCons\Environment.py”, line 224:
return self.method(*nargs, **kwargs)
File “C:\Users\frank.platformio\penv\lib\site-packages\platformio\builder\tools\platformio.py”, line 76:
File “C:\Users\frank.platformio\packages\tool-scons\script..\engine\SCons\Environment.py”, line 224:
return self.method(*nargs, **kwargs)
File “C:\Users\frank.platformio\penv\lib\site-packages\platformio\builder\tools\piolib.py”, line 785:
lib_builders = env.GetLibBuilders()
File “C:\Users\frank.platformio\packages\tool-scons\script..\engine\SCons\Environment.py”, line 224:
return self.method(*nargs, **kwargs)
File “C:\Users\frank.platformio\penv\lib\site-packages\platformio\builder\tools\piolib.py”, line 757:
env, join(libs_dir, item), verbose=verbose)
File “C:\Users\frank.platformio\penv\lib\site-packages\platformio\builder\tools\piolib.py”, line 51:
env, path, verbose=verbose)
File “C:\Users\frank.platformio\penv\lib\site-packages\platformio\builder\tools\piolib.py”, line 111:
File “C:\Users\frank.platformio\penv\lib\site-packages\platformio\builder\tools\piolib.py”, line 259:
“pio_lib_builder”: self
File “C:\Users\frank.platformio\packages\tool-scons\script..\engine\SCons\Script\SConscript.py”, line 541:
return _SConscript(self.fs, *files, **subst_kw)
File “C:\Users\frank.platformio\packages\tool-scons\script..\engine\SCons\Script\SConscript.py”, line 250:
exec file in call_stack[-1].globals
File “C:\Users\frank.platformio\lib\nrf51-sdk\platformio_extra.py”, line 4:
========================================================================================= [ERROR] Took 1.79 seconds =========================================================================================
The terminal process terminated with exit code: 1

I did have to install the tool chain manually (C:\Users\frank.platformio\packages\framework-mbed@4.50701.0). Because when it tried to download the tool chain, it produced a short progress bar and then quickly said that download had failed and it automatically tried other mirrors with the same result. I have had that problem with almost every package it has tried to install. For the other systems I worked with, I was able to get around that problem by downloading and manually un-compressing the files, as was discussed in another thread on this board. Not sure if that is related to the problem I am having here. I am able to build regular MBED (LPC1768), Arduino, and Arduino DUE despite having to do the manual downloading workaround.

Am I doing something incorrectly here?


See Redirecting...

Thanks! Fixed in Upgrade to PIO Core 3.5.0 by ivankravets · Pull Request #1 · palfrey/nrf51-sdk · GitHub

Thanks Ivan, for the quick response to my issue!

Glad to have the work-around of running PlatformIO commands in a regular command window when downloads fail. That is much easier than locating the files in question and downloading and extracting them manually. I have added .platformIO\penv\scripts to my Windows path. So if I have the issue again in the future, I will just open up a Windows command window in the project folder and run the command manually. I believe this problem only affects Windows 10 users, and in fact it may have been caused by a recent Windows 10 upgrade. I don’t see the error discussed here until relatively recently, and everyone reporting it (that I saw) is running Windows 10. The Microsoft Creator’s Update I received during the fall broke several things for me, so I’m thinking it may have broken Visual Studio Code as well.

I ran PIO update, and was able to get this to run successfully from a Windows command prompt. Quite a few updates came down, but I am still having the issue with AttributeError. It looks like your updates have not been merged into the main source code yet. If there is a way I can tell PlatformIO to get your pull version let me know and I will test now. Otherwise, I will wait until the fix is merged in and then will report back.


I see that PR has not been merged yet. You can patch own version following Upgrade to PIO Core 3.5.0 by ivankravets · Pull Request #1 · palfrey/nrf51-sdk · GitHub

Check .piolibdeps folder in a project.

After manually patching the code, I am able to compile. However, I still note several issues.

I get a bunch of compile warnings. Some of them look serious. Here are some examples; there are many pages full of similar errors:
Compiling .pioenvs\bbcmicrobit\lib229\nrf51-sdk\source\nordic_sdk\components\ble\peer_manager\peer_data_storage.o
C:\Users\frank.platformio\lib\nrf51-sdk\source\nordic_sdk\components\ble\device_manager\device_manager_peripheral.c: In function ‘address_to_device_id’:
C:\Users\frank.platformio\lib\nrf51-sdk\source\nordic_sdk\components\ble\device_manager\device_manager_peripheral.c:2546:12: warning: implicit declaration of function ‘im_address_resolve’ [-Wimplicit-function-declaration]
iif(im_address_resolve(p_addr, &m_peer_table[peer_iterator].peer_id.id_info))
Compiling .pioenvs\bbcmicrobit\lib229\nrf51-sdk\source\nordic_sdk\components\libraries\fstorage\fstorage_nosd.o
C:\Users\frank.platformio\lib\nrf51-sdk\source\nordic_sdk\components\libraries\fds\fds.c: In function ‘address_within_page_bounds’:
C:\Users\frank.platformio\lib\nrf51-sdk\source\nordic_sdk\components\libraries\fds\fds.c:161:29: warning: passing argument 1 of ‘is_word_aligned’ discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
Compiling .pioenvs\bbcmicrobit\lib1d5\microbit-dal_ID360\source\core\MicroBitListener.o
C:\Users\frank.platformio\lib\microbit-dal_ID360\source\core\MicroBitFiber.cpp: In function ‘void scheduler_init(EventModel&)’:
C:\Users\frank.platformio\lib\microbit-dal_ID360\source\core\MicroBitFiber.cpp:189:5: warning: this ‘if’ clause does not guard… [-Wmisleading-indentation]
if (fiber_scheduler_running())
CC:\Users\frank.platformio\lib\microbit-dal_ID360\source\core\MicroBitFiber.cpp:194:2: note: …this statement, but the latter is misleadingly indented as if it is guarded by the 'if’
messageBus = &_messageBus;
C:\Users\frank.platformio\lib\microbit-dal_ID360\source\core\MicroBitFiber.cpp: In function ‘int fiber_wait_for_event(uint16_t, uint16_t)’:
C:\Users\frank.platformio\lib\microbit-dal_ID360\source\core\MicroBitFiber.cpp:388:5: warning: this ‘if’ clause does not guard… [-Wmisleading-indentation]
if(ret == MICROBIT_OK)
C:\Users\frank.platformio\lib\microbit-dal_ID360\source\core\MicroBitFiber.cpp:391:2: note: …this statement, but the latter is misleadingly indented as if it is guarded by the 'if’
return ret;

After successful compilation, I plug in my the micro:bit and attempt to upload using the PlatformIO:Upload selection of the Tasks menu. This results in the following error:
Configuring upload protocol…
Available: cmsis-dap
Selected: cmsis-dap
Looking for upload disk…
Auto-detected: COM18
Uploading .pioenvs\bbcmicrobit\firmware.hex
*** [upload] COM18\firmware.hex: No such file or directory

I manually located the firmware.hex file in C:\Users\frank\Documents\PlatformIO\Projects\180125-165619-bbcmicrobit.pioenvs\bbcmicrobit, and copied it to the Microbit drive. At that point, something does scroll on the LEDs. However, it is not the expected message. It is a random-appearing selection of flashing LEDs. I noted that no LEDs in the bottom row ever light. I thought maybe my board had become defective, but when I create a scrollling message using the microbit online tools and upload it works fine.

Let me know if you want me to do any more tests.


this issue was fixed in the latest PIO Core. Please run pio upgrade --dev.