Unable to build & debug BBC micro:bit v2 using PlatformIO with Zephyr 2.5.0

The bbcmicrobit_v2 board support for Zephyr is coming up as unrecognized.

PlatformIO Zephyr (and mbed) support for BBC micro:bit v1 (bbcmicrobit) exists but support for micro:bit v2 is currently missing.

Hopefully we’ll have PlatformIO Zephyr support for the updated micro:bit v2 soon.

Could you please try the following

  • go into C:\Users\<user>\.platformio\platforms\nordicnrf52\boards\bbcmicrobit_v2.json
  • replace the file fully with the content
{
  "build": {
    "arduino":{
      "ldscript": "nrf52833_xxaa.ld"
    },
    "core": "nRF5",
    "cpu": "cortex-m4",
    "extra_flags": "-DARDUINO_BBC_MICROBIT_V2 -DNRF52833_XXAA",
    "f_cpu": "64000000L",
    "mcu": "nrf52833",
    "variant": "BBCmicrobitV2",
    "zephyr": {
      "variant": "bbc_microbit_v2"
    }
  },
  "connectivity": [
    "bluetooth"
  ],
  "debug": {
    "onboard_tools": [
      "cmsis-dap"
    ],
    "svd_path": "nrf52.svd",
    "openocd_extra_args": [
      "-c",
      "transport select swd;"
    ],
    "jlink_device": "nRF52833_xxAA"
  },
  "frameworks": [
    "arduino",
    "zephyr"
  ],
  "name": "BBC micro:bit V2",
  "upload": {
    "maximum_ram_size": 65536,
    "maximum_size": 524288,
    "protocol": "cmsis-dap",
    "protocols": [
      "jlink",
      "nrfjprog",
      "stlink",
      "blackmagic",
      "cmsis-dap",
      "mbed"
    ]
  },
  "url": "https://microbit.org/new-microbit/",
  "vendor": "BBC"
}
  • try recreating a Zephyr project for the board
1 Like

Neat stuff! Thank you.

I added the Zephyr framework support in bbcmicrobit_v2.json, as per your instructions.

I’m now able to upload and run/debug code to the micro:bit v2 using PlatformIO and the Zephyr framework.

I’ve tested a couple of projects in both debug & release. Upload and debug via cmsis-dap (micro:bit v2 default) and jlink (micro:bit v2 flashed with Segger J-Link OB firmware) work fine.

The straight forward changes to add support for the Zephyr framework shows the power of PlatformIO. It’s a pleasure to use PlatformIO!

What is the process to get the changes into the next nRF52 update? Do you want me to notify the appropriate person(s) or group?

I’ve just PRed into the repo where the board definition file is (Add Zephyr build info to BBC Microbit V2 by maxgerhardt · Pull Request #107 · platformio/platform-nordicnrf52 · GitHub), if accepted they hopefully do a re-release soon (or one can use the upstream version after the merge to get these changes without local modifications)

Linked PR was merged and usable per instructions above; Will automatically be in next release.

Great! Good to understand the process.

Yesterday, whilst building a bbc_microbit_v2 PlatformIO project, I noticed that the RAM size specified in \Users\<user>\.platformio\platforms\nordicnrf52\boards\bbcmicrobit_v2.json

is incorrect.

Processing microbit (platform: nordicnrf52; board: bbcmicrobit_v2; framework: zephyr)
--------------------------------------------------------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/nordicnrf52/bbcmicrobit_v2.html
PLATFORM: Nordic nRF52 (7.0.0) > BBC micro:bit V2
HARDWARE: NRF52833 64MHz, 64KB RAM, 512KB Flash
DEBUG: Current (jlink) On-board (cmsis-dap) External (blackmagic, jlink, stlink)
PACKAGES: 
 - framework-zephyr 2.20500.210226 (2.5.0) 
 - framework-zephyr-canopennode 0.0.0-alpha+sha.468d350028 
 - framework-zephyr-civetweb 0.0.0-alpha+sha.e6903b80c0 
 - framework-zephyr-cmsis 0.0.0-alpha+sha.c3bd2094f9 
..
...
...

The BBC micro:bit v2 has 128K of RAM.

maximum_ram_size in

\Users\<user>\.platformio\platforms\nordicnrf52\boards\bbcmicrobit_v2.json should be set to the following:

"maximum_ram_size": 131,072

I have build and debugged quite a few projects with the board bbcmicrobit_v2. json and I have had no issues.

Please notify the relevant developers to update the json. Thanks.

I PRed per Correct RAM size for BBC Micro:Bit v2 by maxgerhardt · Pull Request #108 · platformio/platform-nordicnrf52 · GitHub to have this fixed.

EDIT: PR is merged and can thus be included via the upstream.

Thanks for raising the PR.

1 Like