How to set mbed build profile

Hi, I am trying to debug an mbed os crash, and from what I understand it should print to serial out.

I believe I need to compile using the correct build profile:

Board: Arduino Nano 33 BLE

Running on mbed 6.2 with the Ardunio-mbed package 1.3.2 as described here.

any insights are much appreciated.

The Arduino-mbed core comes with a precompiled version of mbed (sourced from here). Even if we would set the the appropriate flags (as documented for normal mbed-os, via build_flags = -D MBED_BUILD_PROFILE_DEBUG), it wouldn’t work, since the actual mbed-os sources aren’t recompiled. The original mbed-os settings can be found here.

It seems to me like that they’ve extended their base mbed-os version (which is mbed-os 6.2.0) with the necessary target files and use this script to create an mbed-os program, apply their patches and create the binaries. Specifically, their readme states how to build the mbed-os base libraries in debug mode.

I see 3 pathways here:

  • try and analyze the crash dump output that you’re currently getting without more debug info
    • if you post the crash output (there should be at least some output, even in release mode) along with some code, we might figure out why it crashes
    • if there are addresses where it crashes you can still use normal arm-none-eabi-addr2line tools together with the generated firmware.elf to pin down the location of the crash
  • use the README above to recreate the mbed-os libraries in debug mode, then use the results of that and overwrite the existing ones in the lib folder of the variant as I’ve linked above
    • might be feasable if the script works without problems
  • add full native framework = mbed support for the Nano 33 BLE with the modified mbed-os package that they’re using
    • might be a little bit more complicated with board manifest changes (and python logic changes?)
    • has the advantage of only building mbed-os and it becoming fully modifyable, instead of working with one precompiled version

Ah, this makes a lot more sense now.

As for each of the 3 paths

  1. I don’t have a cash dump output to analyze, this is what I would like to get my hands on, nothing is output when mbed crashes and the onboard LED goes into its crash sequence. Is there anything I can do to diagnose the lack of output?
  2. I could re-compile the Arduino-mbed, I believe however their script is not compatible with macOS – and that’s what I’m running.
  3. This would be the most ideal, I’ve tried running with framework = mbed but there’s clearly more work to be done to make that happen. I’m not experienced enough with the details of mbed/platformio/embedded build chains to know where to start on this path. Do you have an guidance on what would need to be done?

Hmm. That means either

  • the crash happened in a global constructor or somewhere so low-level that it didn’t output anything
  • or the crash output is not being sent over the USB-Serial, but the STDIO UART. (This also makes sense since you want to output a crash output not through complicated USB protocols but as reliably and quickly as possible)

Per pin definition code and schematics, mbed-os’s standard IO is output is configured to be on the “TX” pin, P1.03, which is labeled “TX1”.

Do you have a USB-UART converter to hook up its RX to the TX of the Nano 33 BLE board, plus GND to GND? (You can also use an Arduino Uno or similiar as a USB-UART bridge).

Ah it’s a bash script and mac-OS should be able to handle it. I can also use a VM to attempt recompilation. But if the output per above doesn’t appear on the USB Serial anyways, it wouldn’t make a difference in that case.

This is likely the case, I’ll have to break out my soldering iron and find an old arduino to build that bridge.

The Arduino Nano 33 BLE has an operating voltage of 3.3v, and the other boards mentioned are all 5v, if I’m not mistaken, this will cause problems correct? Scatch that, I have a Arduino Zero which is 3.3v

I don’t really want to re-build the mbed os library if I don’t need to, would rather spend effort on path 3 as mentioned.

I’d be curious if there was a path to skip the Arduino-mbed library entirely and load mbed directly to the Nano 33 BLE. I may be completely mis-understanding the ecosystem though.

Turns out you cannot use an Arduino Zero – you need an Arduino that has the dedicated UART to USB chip on it (I also had an UNO lying around, ironically fried and useless – other than for this chip).

Anyways that solves my problem and makes developing much much easier! I now have crash logs. Thanks again.

@maxgerhardt any thoughts on using mbed directly onto the Nano 33 BLE? or using framework = mbed to skip arduino?

Actually looks pretty promising – using the script and some tweaks I was able to get an mbed-os 6.2.0 core, apply the patches and compile an application. With a small modified board JSON file to declare mbed-os framework compatibility and build information and packaging the mbed-os core in some repo, it should be pretty straight-forward to set up.

It’s also interesting that mbed-os since 6.2.0, all up to the the latest version 6.8.0 has the code for the TARGET_ARDUINO_NANO33BLE board, but maybe not all the patches – so I’ll stick with with the core that Arduino is using and their specific patches. Or both for fun.

Very interesting, it looks like the wall between Arduino and mbed is being push down on multiple fronts then. Well, thank you for all the help, it is 10x easier to debug with proper mbed output.

Ah, I’ve also noticed that the Zephyr framework in version 2.5.0 (which PIO also supports) has support for the Nano 33 BLE: zephyr/boards/arm/arduino_nano_33_ble at zephyr-v2.5.0 · zephyrproject-rtos/zephyr · GitHub

So I’ll see to it that the board manifest file and the packages are expanded to support building for standard mbed-os, mbed-os with Arduino patches and Zephyr. All but the “mbed-os with Arduino patches” package already exist within the PlatformIO repos, so it should be straightforward.

Ah very nice! thank you so much. All this help allowed me to make quick progress on my project this weekend :slight_smile: will be interested to see the implementation afterwards.

@maxgerhardt is native mbed support (without Arduino) being tracked anywhere? Running into more issues where custom builds would give more diagnostic information.

Attempting to build Ardunio-mbed diretly but running into other issues.

The PR Enable mbed-os support for Nano 33 BLE by maxgerhardt · Pull Request #113 · platformio/platform-nordicnrf52 · GitHub is open but the open question in there plus me (or the developer it seems) having a board (and a SWD adapter in case the bootloader is overwritten) makes it difficult to progress atm.

What SWD adapter would be compatible with the Nano 33 BLE?

Maybe I can assist in testing :slight_smile:

Any SWD probes should work, like e.g. very cheap ST-Link V2 clone dongles, or the ST-Link section of a STM Nucleo board (then configured with upload_protocol = cmsis-dap in the platformio.ini). A JLink or Blackmagic probe works too.

Note that you would also need to solder the two SWDIO+SWCLK wires to the board which are exposed on the back to be able to connect it to the SWD probe, as shown e.g. here.

Ah right, I didn’t realize I’d need a debugger as well, but that makes sense. I may consider this in the near future. Thanks!