-
-
Notifications
You must be signed in to change notification settings - Fork 799
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
BBC MicroBit configuration #709
Comments
I've just been digging around a bit, and this is a lot harder than it looks. Despite the addition of the Micro:bit to the supported boards list, it won't work with the out-of-the-box mbed. https://github.com/lancaster-university/microbit-dal and https://github.com/lancaster-university/microbit have the main sources to all the bits needed to properly support it, and that's not part of the main mbed github yet, so PlatformIO isn't picking that up. It almost might sense for this to be an entirely separate framework, but I can't seem to find any nice docs on building a new one... |
@palfrey please wait for the first PlatformIO 3.0 beta. It will have support for mbed modules. |
@ivankravets: Awesome! Is there any particular branch or issue I should be watching to keep up with that or be able to test development versions? |
I've jus taken a look at https://github.com/lancaster-university/microbit and I don't have good news. It depends on https://github.com/lancaster-university/microbit-dal that is written for CMake and hardcoded for yota https://github.com/lancaster-university/microbit-dal/blob/master/source/CMakeLists.txt Nevertheless, we can try together to make it working. PlatformIO 3.0 has a new refactored powerful cross platform build system that could be tuned "on-the-fly". No need to write custom frameworks (PlatformIO 2.0) or etc. If someone is ready to play with it, I can explain. |
So, I decided to have a quick bit of hacking around this morning, and have come up with https://github.com/palfrey/microbit-blink. It's meant to be a "hello world" app for Micro:bit using PlatformIO that was basically me trying to establish just how much deviation there was in the codebase from core mbed, and the short answer is "lots". Lancaster have all sorts of their own very specific versions of the various libraries that are needed, and it was kinda horrible. OTOH, the repository does compile a file that doesn't whinge for the Micro:bit, but it doesn't seem to do anything useful yet :( I'm heading out to a social event now, but would be interested in exploring this further later this week... Yes, I'm aware it does things in a really awful way by recompiling everything as it's own source code, not as libraries. It's intended mostly as a "can this be done at all" experiment before then getting into the depths of doing this with the proper PlatformIO way. |
@palfrey do you mean that our version of ARM mbed framework from https://github.com/mbedmicro/mbed is not compatible with https://github.com/lancaster-university/microbit ? |
Possibly not. I've found https://github.com/lancaster-university/mbed-classic as well, and I'm not sure how that fits in with https://github.com/mbedmicro/mbed. TBH, the entire set of repositories seems like someone's hacked something together that they know how to make work, but haven't shared with the rest of us yet... Other bits of progress made: Tried using the debugging guide at https://docs.mbed.com/docs/debugging-on-mbed/en/latest/Debugging/debugging_microbit/ and got not very far because it pretty much immediately jumps to 0xfffffffe and I'm not entirely sure why. OTOH, the HEX file I've got at the moment gets the following info out of srec_info
Note the single Data line, and the complete lack of anything at the beginning of memory. Running similar commands on known good programs (a "hello world" from elsewhere I've got for example) gets me two Data blocks, one starting at 000000 and that's also the same for the HEX files in the debug guide, which makes me think there's something missing there. Bootloader possibly? |
Hah! Some success. So having been digging around in https://github.com/lancaster-university/microbit-targets and especially https://github.com/lancaster-university/microbit-targets/blob/master/bbc-microbit-classic-gcc-nosd/ld/NRF51822.ld which is the "no softdevice" version of the code, I edited my local ~/.platformio/packages/framework-mbed/variant/NRF51_MICROBIT/mbed/TARGET_NRF51_MICROBIT/TOOLCHAIN_GCC_ARM/NRF51822.ld and changed the Flash origin to "0x00000000". This, in combination with "-DMICROBIT_DBG=1 -DMICROBIT_HEAP_DBG=1" in my build_flags got me the first indication I actually had something half-functional in the form of some heap debug on the serial port. Still not got working leds yet, but at least it's running my code :) |
This is not a big problem. We can specify custom LD script per board which will be used instead ARM mbed. When you have work "blink" project, I'll explain how to use PlatformIO 3.0 and custom build script for the specific library. |
After quite some struggling, I have a working "blink". Checkout https://github.com/palfrey/microbit-blink and do the following:
There's possibly ways to do this without SRecord, and also this gives you the all-singing all-dancing firmware with BLE support, but rather low spare RAM, so other options are wanted in the future, but this at least gets us somewhere. |
Woooow! Great result! 👍 I see that you "linked" libraries to the source code and used an extra script. How can we simplify it?
P.S: To see verbose build output in PlatformIO 3.0, please use |
So, I've just done step 1, but I'm running into issues with bits of the library support. Someone else has already made a library.json for the core microbit bits (http://platformio.org/lib/show/361/Microbit) which looks perfectly good to me, but as far as I can tell doesn't pull in any of the headers or source from the Microbit git repository referenced there. Given there's a perfectly good "module.json" in that folder with "extraIncludes" set, this is particularly confusing. Any thoughts as to why this one doesn't work? |
@palfrey I've just pushed PR to that repo rossng/microbit#1 You can copy my changes to your local |
Still no luck. https://github.com/palfrey/microbit-blink/tree/platform-3.0 has my WIP v3 version. I've copied your library.json changes into ~/.platformio/lib/Microbit_ID361 (and also https://raw.githubusercontent.com/rossng/microbit/master/module.json just for good luck) and no luck. The build flags specified are not turning up in the build of main.cpp, and so it can't find MicroBit.h |
@palfrey This is a bug... I'll fix it tomorrow and reply here. Thanks and good night! 😊 |
@palfrey I have some progress on it. I'll push modified PlatformIO later. All builds success without any hacks. The only one change is replacement with Nevertheless, I have problem with linker. Do you have any ideas?
|
@ivankravets Yeah, you're missing the little bit of assembler code from CortexContextSwitch.s. Multiple versions in https://github.com/lancaster-university/microbit-dal/tree/master/source/asm and you'll want CortexContextSwitch.s.gcc |
@ivankravets How are you getting on with this? |
This issue depends on #500 and #533. We should fix these issues before. Need to pre-built (or find somewhere) static Could you help us with this? See here examples of our packages https://bintray.com/platformio/dl-packages/tool-openocd#files |
Any examples of how the compilation is managed for existing tools? e.g. openocd? If so, I have access to all of those types of systems for making srec_cat. |
@palfrey we do that manually (download source code, install deps/libs, We would be thankful if you share somewhere these packages. |
The Library Dependency Finder has been rewritten. Now it understands nested dependencies automatically. Also, if you don't need extra scripting, just remove Please update to the latest development version. platformio.ini[env:bbcmicrobit]
platform = nordicnrf51
framework = mbed
board = bbcmicrobit
lib_install = 361 A few ARM mbed libraries require extra scripts: nrf51-sdk-2.2.0-mb4
{
"name": "nrf51-sdk",
"version": "2.2.0",
"description": "Module to contain files provided by the nordic nRF51 SDK",
"keywords": [
"nordic",
"nrf51",
"sdk"
],
"author": "",
"repository": {
"url": "[email protected]:ARMmbed/nrf51-sdk.git",
"type": "git"
},
"build":{
"flags": [
"-Isource/nordic_sdk/components/ble/ble_radio_notification",
"-Isource/nordic_sdk/components/ble/ble_services/ble_dfu",
"-Isource/nordic_sdk/components/ble/common",
"-Isource/nordic_sdk/components/ble/device_manager",
"-Isource/nordic_sdk/components/ble/device_manager/config",
"-Isource/nordic_sdk/components/ble/peer_manager",
"-Isource/nordic_sdk/components/device",
"-Isource/nordic_sdk/components/drivers_nrf/ble_flash",
"-Isource/nordic_sdk/components/drivers_nrf/delay",
"-Isource/nordic_sdk/components/drivers_nrf/hal",
"-Isource/nordic_sdk/components/drivers_nrf/pstorage",
"-Isource/nordic_sdk/components/drivers_nrf/pstorage/config",
"-Isource/nordic_sdk/components/libraries/bootloader_dfu",
"-Isource/nordic_sdk/components/libraries/bootloader_dfu/hci_transport",
"-Isource/nordic_sdk/components/libraries/crc16",
"-Isource/nordic_sdk/components/libraries/hci",
"-Isource/nordic_sdk/components/libraries/scheduler",
"-Isource/nordic_sdk/components/libraries/timer",
"-Isource/nordic_sdk/components/libraries/util",
"-Isource/nordic_sdk/components/libraries/fds",
"-Isource/nordic_sdk/components/libraries/fstorage",
"-Isource/nordic_sdk/components/libraries/experimental_section_vars",
"-Isource/nordic_sdk/components/softdevice/common/softdevice_handler",
"-Isource/nordic_sdk/components/softdevice/s130/headers",
"-Isource/nordic_sdk/components/toolchain"
],
"extraScript": "platformio_extra.py"
},
"frameworks": "mbed",
"platforms": "nordicnrf51"
}
Import("pio_lib_builder")
# skip built-in ARM mbed NRF51 SDK, place library's includes before
pio_lib_builder.env.Prepend(CPPPATH=pio_lib_builder.get_inc_dirs()) Microbit-DAL_ID360
{
"name": "Microbit-DAL",
"keywords": "microbit, framework, bbc",
"description": "The core set of drivers, mechanisms and types that make up the micro:bit runtime.",
"repository":
{
"type": "git",
"url": "https://github.com/rossng/microbit-dal.git"
},
"build":
{
"flags": [
"-Iinc/core",
"-Iinc/types",
"-Iinc/drivers",
"-Iinc/bluetooth",
"-Iinc/platform"
],
"extraScript": "platformio_extra.py"
},
"url": "https://github.com/lancaster-university/microbit-dal",
"frameworks": "mbed",
"platforms": "nordicnrf51"
}
from os import unlink
from os.path import isfile, join
from shutil import copy
Import("pio_lib_builder")
# enable GCC ASM
if isfile(
join(pio_lib_builder.path, "source", "asm",
"CortexContextSwitch.s.gcc")):
if isfile(
join(pio_lib_builder.path, "source", "asm",
"CortexContextSwitch.s")):
unlink(
join(pio_lib_builder.path, "source", "asm",
"CortexContextSwitch.s"))
copy(
join(pio_lib_builder.path, "source", "asm",
"CortexContextSwitch.s.gcc"),
join(pio_lib_builder.path, "source", "asm", "CortexContextSwitch.S"))
# fix TWI API
twi_file_path = join(pio_lib_builder.path, "source", "drivers",
"MicroBitI2C.cpp")
if isfile(twi_file_path):
content = ""
with open(twi_file_path) as fp:
content = fp.read()
if "twi_master_init_and_clear()" in content:
with open(twi_file_path, "w") as fp:
fp.write(
content.replace("twi_master_init_and_clear()",
"twi_master_init_and_clear(NRF_TWI1)")) Here is the your project with the fixes. P.S: I'm working on the improved library manager. It'll allow to install library directly from the repository. Please play with the project locally. When all works well, we can create forks of the dependent packages and update with extra scripts and manifests. |
I have 1 error. See my log http://pastebin.com/Qc6nGQ1T I hope you will fix it. |
Will hopefully have a better look at this at the weekend, but meanwhile, to solve the createBLEInstance issue you'll need https://github.com/lancaster-university/nRF51822/blob/master/source/nRF5xn.cpp. The commit in my code that fixed this for me was palfrey/microbit-blink@c40f903 |
@palfrey it has not been merged yet. PlatformIO 3.0 has decentralized architecture with development platforms. See https://github.com/platformio?utf8=✓&query=platform- I'm working on the merging. Give me a few minutes. I'll reply here. |
Please upgrade to the latest PlatformIO 3.0 dev, remove |
Would be good to run |
Did that, got the following (from
I think it's still missing the softdevice firmware judging from the srec_info output (also that lines up with a missing argument before the first "-Intel") |
Hi @palfrey ! |
Ah... Was missing the target.json entirely from there. Ran |
@palfrey what is your |
3.0.0.dev19 |
Thanks, that is strange. I'll take a look. The last thing that we need is to create Microbit dependencies and register with http://platformio.org/lib I'll do that when fix #413 |
Now that #413 is merged, I've got a new version of my blink project (which I've added a few bells and whistles to along the way...) at https://github.com/palfrey/microbit-blink/tree/platform-3.0. At the moment however the platformio.ini has all of the dependencies listed, as without that it doesn't appear to be able to locate the others, when I think that all should be needed is the "Microbit" one. Given that one has a library.json with what looks like a perfectly good Microbit-DAL dependency, I think there's either a bug or some part of the library dependency code is missing? |
The ideal solution is when all dependencies are located in PlatformIO Library Registry. In this case, Library Manager will use prepared archives by Library Crawler. In any case, I updated 2 manifests and now it should work with a simple [env:bbcmicrobit]
platform = nordicnrf51
framework = mbed
board = bbcmicrobit
lib_deps = microbit@~2.0.0-rc4 |
Tried that, got the following. This is using current develop branch of PlatformIO
|
Please remove |
Nice! Confirmed clean build with 3.0.0a3. I don't have my Micro:bit to hand to test, but will test this evening. |
Should we improve here something? P.S: Thanks a lot for the great help on this issue! 👍 |
Couple of things still outstanding:
Overall, very happy. Will be doing a blog post on the matter in the nearby future, and will send you a link when done. |
|
|
FYI, there's now a blog post up about all of this http://www.lshift.net/blog/2016/08/28/using-the-bbc-microbit-with-platformio/ |
@palfrey Thanks for a blog post, but big THANKS A LOT for the help on this issue :) |
* develop: Fix incorrect line order when converting from INO to CPP and pointer is used Fix unit test Notify about `version` field when creating library Add support for SparkFun Blynk Board Return valid exit code from ``plaformio test`` command Disable SSL Server-Name-Indication for Python < 2.7.9 Version bump to 3.0.1 (issue #772) Disable temporary SSL for PlatformIO services // Resolve #772 Version bump to 3.0.0 (issues #770, #766, #747, #730, #765, #640, #659, #742, #459, #542, #763, #759, #753, #757, #749, #748, #745, #519, #709, #743, #413, #498, #410, #740, #361, #414, #554, #732, #588, #475, #461, #101, #719, #721, #537, #415, #522, #289, #556, #570, #456, #617, #432, #408, #479, #667, #510) Fix menu height for docs Fix issue with multiple archives when linking firmware Add migration guide for PIO2 to PIO3 Search libraries by headers/includes with ``platformio lib search --header`` option Update pio run command examples Add Unit Testing Demo Update PIO Plus badge title and link Add PlatformIO Plus badge Add links to PlatformIO Plus
Hello! I'm using platformIO, IDE 1.7.2 | Core 3.2.1
The example code is this:
The example compiles fine and uploads to the microbit. But the pinout configuration seems to be somewhat off, as the led matrix doesn't display any sensible text. I've tried to use the equivalent example in the mbed-online-compiler, and the display scrolls HELLO WORLD as expected. |
@Dealerpriest please file an issue here https://github.com/platformio/platform-nordicnrf51/issues It seems that previous Microbit integration doesn't work with our latest mbed SDK |
Example
Configuration
Operating system: macOS Sierra (10.12)
PlatformIO Version (
platformio --version
): 2.11.0Hello there, I was trying to use platformIO with the microbit board (bbcmicrobit), however, even the simplest program fails to compile because it misses the main file. I have also tried to add the main source code of the framework to the lib, but as it is compiled by
yotta
the structure is not the same, has anyone used the microbit with PlatformIO before?If problems with PlatformIO Build System:
The content of
platformio.ini
:Source file to reproduce issue:
Additional info
Run output:
The text was updated successfully, but these errors were encountered: