Tuesday, November 26, 2019

Building Bluetooth Mesh example for nRF52840 Dongle on a Mac

Continuing my story of getting started developing for the nRF52840 on my Mac.

I'm trying to follow instructions here, but they don't cover the Mac specifically, just Linux and Windows and say "The steps should be similar for other platforms". Disappointing.

First attempt at generating build files with cmake used (in the newly manually created build directory under the mesh SDK):


cmake -DTOOLCHAIN=gccarmemb -DPLATFORM=nrf52840_xxAA -DSDK_ROOT= ..

It worked, but generated files for the 10056 board instead of the 10059 board which is the dongle. Unfortunately there doesn't seem to be a board file for the 10059 board in the mesh SDK directory CMake/board

I copied the pca10056.board file there to pca10059.board, replacing the strings 10056 to 10059 in it. I also edited the nrf52840 section of the CMake/Board.cmake file to be:


elseif (PLATFORM STREQUAL "nrf52840_xxAA")
    set(BOARD "pca10056" CACHE STRING "Board to build examples for.")
    set_property(CACHE BOARD PROPERTY STRINGS "pca10056" "pca10059")

and then reran cmake thus (in the newly created build directory):


cmake -DTOOLCHAIN=gccarmemb -DPLATFORM=nrf52840_xxAA -DSDK_ROOT=/SDK16 -DBOARD=pca10059 ..

Looks good. It says it's using SDK15 even though I gave it the path to SDK16, but I'll try it this way.

I then run make in the build directory.

I get errors related to LED_START and LED_STOP.  Seems board related.

See my posting on the Nordic forum about this with a fix.

I got further in the compilation, now got an issue about missing symbols.
I added the path to nrfjprog and mergehex to my path, and reran cmake. Note that you need to add the subdirectories for nrfjprog and mergehex separately.

I still get a warning during build:

warning: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: warning for library: librtt_nrf52840_xxAA.a the table of contents is empty (no object file members in the library define global symbols)

and then later errors starting with:
/usr/local/gcc-arm-none-eabi-9-2019-q4-major/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld: CMakeFiles/beaconing_nrf52840_xxAA_s140_6.1.1.dir/__/__/mesh/prov/src/prov_utils.c.obj: in function `prov_utils_keys_generate':/<...>/mesh_3.2.0/mesh/prov/src/prov_utils.c:230: undefined reference to `uECC_secp256r1'
and later also complaining about missing
/<...>/mesh_3.2.0/mesh/core/src/log.c:63: undefined reference to `SEGGER_RTT_printf'
I believe I need to link with $(SDK_ROOT)/external/nrf_cc310_bl/lib/cortex-m4/hard-float/libnrf_cc310_bl_0.9.12.a
(found this out from examples/crypto/nrf_cc310_bl/pca10056/blank/armgcc/Makefile)

The mesh SDK also built build/external/micro-ecc/libuECC_nrf52840_xxAA.a
...and it's on the build line. Don't know why it isn't working. Ask Nordic?

The trick was to surround the linked archives for uECC and RTT with 
-Wl,--whole-archive and -Wl,--no-whole-archive



No comments: