How to use "nRF LED Matrix" sample and library from Zephyr with nRF Connect SDK 1.9.1 and SES for use in an app on Micro:Bit V2?

Kind folks,

I have used the nRF Connect app on my MacBook Pro to (carefully!) install the new 1.9.1 SDK and the Nordic version of the SEGGER Embedded Studio.  Using this environment I can build, load and run various sample apps from the SDK on an nRF52840 DK.  Further, by loading Segger's J-Link OB code for the Micro:Bit on that board (and with a fair degree of care about board & peripheral configurations), I can build, load and run some sample apps on the Micro:Bit V2 board (based on the nRF52833) as well.

So far, so good.  But now I want to use the 5x5 LED matrix on the Micro:Bit, instead of the one or two single LEDs typically found on Nordic dev boards.  Interestingly, there's even sample code in the Zephyr system to support this task, explicitly labeled nRF LED Matrix,, which purports to what I want and it's even included in the Zephyr repo in the nRF SDK!  But, alas, it doesn't seem to be accessible to me from the SES "Open nRF Connect SDK Project..." path.  Using that wizard, the Projects selector (slow, unresponsive, prone to crashing!) doesn't allow me to get at the requisite "nRF LED Matrix" sample app.  (Trying to install a separate Zephyr build environment off to the side for experimentation is its own tar pit, e.g., involving all kinds of Python version conflicts and west problems, at least in macOS).  And the sample code and this part of the Zephyr library(?) may not be directly useful, since it's C++ code and dependent on Zephyr low-level support. a different build model, etc..

Can anyone point me at an "nRF LED Matrix" library in C (not C++) that would integrate with the other, documented nRF libraries in the nRF 1.9.1 SDK?  Other approaches?

TIA,

Mike

  • Hi Mike, 

    I opened the nRF LED Matrix sample from zephyr\samples\boards\nrf\nrf_led_matrix to use with zephyr\boards\arm\bbc_microbit_v2

    And building the sample seems to work as intended as well. 

    I don't have the Microbit available at the moment, but assume it will work as expected.

    Kind regards,
    Øyvind

  • Øyvind,

    Many thanks. Yes, the sample did build, compile, and load onto my Micro:Bit V2 and execute correctly (at least with lots of flashing LED patterns :-)

    The critical issue for me was that I was being too restrictive in following the instructions for specifying a project in the "File → Open nRF Connect SDK Project" wizard.  I was only using the triangle selector to look for available project, thus not finding "nrf_led_matrix".  I didn't realize that the additional projects in the zephyr repo were available as Custom" projects and could be accessed via the normal  ... file browser.

    Suggestion: Perhaps the documentation in the "Toolchain Manager | First steps | Building with SEGGER Embedded Studio | 3. | Projects" could be clarified to include two facts.

    1. The projects in the Zephyr repo are accessible as "custom" projects using the file finder.
    2. To be considered a custom project, the project must conform to the rules proscribed in the Zephyr docs for project structure (or whatever the defining documentation is).

    Remaining Problem: Having said all of this, I'm still left with a problem.  Prior to receiving your reply, I went ahead and took code snippets from the Zephyr nrf_led_sample and incorporated them into one of your working samples.  All went well until some calls to the display.c/h library which led to the following error:

    1> Linking ‘zephyr_pre0.elf’
    1> /opt/nordic/ncs/v1.9.1/toolchain/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld.bfd: app/libapp.a(main.c.obj): in function `main':
    1> /opt/nordic/ncs/v1.9.1/nrf/samples/bluetooth/nrf_dm_microbit/src/main.c:473: undefined reference to `__device_dts_ord_10'
    

    But this is triggered by code which works in the running nrf_led_matrix sample.  I strongly suspect that the dts files for the bbc_microbit_v2 device are different in the nRF SDK than in the lower-level Zephyr repo.  Will check this out ASAP.  Or something is different in the two code generating environments.

    Any suggestions?

    Thanks again,

    Mike

  • A bit of Google searching on the undefined reference in my prior reply leads to the following in the Zephyr docs:

    DEVICE_DT_GET
    ...
    If no such device was allocated, this will fail at linker time. If you get 
    an error that looks like undefined reference to __device_dts_ord_<N>, that 
    is what happened. Check to make sure your device driver is being compiled, 
    usually by enabling the Kconfig options it requires.
    

    This refers to Kconfig settings, which are part of the build files generated by the code generation wizard (I presume).  How do I fix this?  

    Mike

  • Øyvind,

    OK, did a bit more investigation tonight.  Yes, indeed, my problem is related to dts and Kconfig files.  The net effect is that the following project (highlighted in yellow) is included in the zephyr sample project, nrf_led_marix, but not in my nRF sample project:

    One curiosity here is that the output file for the project is named "libdrivers__display.a", not the same as the c file with an o or a extension.

    As verification that this is the solution for the undefined symbol  "__device_dts_ord_10" during linking, if you look at the binary inside the libdrivers__display.a, the first bit of it contains a string with the requisite symbol:

    In any case, I tried to manually add this project to the solution for my nRF sample solution.  (Not an SES expert.) The proper question is probably how to modify my nRF sample so that, with BBC_microbit_v2 as board, the nRF project wizard will include the nrf_led_matrix project automatically when generating the full solution.

    Hope this helps,

    Mike

  • Hi Mike, 

    Yes, you seem to have encountered a Devicetree error, indicating that you have configured something incorrectly. I would recommend going through the Devicetree Guide, and have a look at this YouTube video from the Zephyr Community on the Device Model.

    Can you share your project in a .zip file?

    Kind regards,
    Øyvind

Related