Issue porting Qorvo Apple NI embedded application demo over to Nordic NCS (Zephyr)

I’ve been working at porting the Qorvo Apple NI embedded application demo over from the nRF SDK 16.0.0 platform (as provided by the example) to nRF NCS 2.2.0 (Zephyr based). I have been able to get the project to build and somewhat function. The Qorvo iOS app is able to connect to the dev board, successfully use the niq library, however ranging fails to start due to a mutex_unlock issue when uwbmac_init() is called from fira_app_process_init(). The log message I get is:

assertion “lock && lock->mtx != NULL” failed: file “/builds/uwb-stack/uwb-stack/embedded/compat/include/linux/mutex.h”, line 42, function: mutex_unlock
exit

First off, has anyone had success porting over to NCS? Secondly, does anyone know what could be going on to cause this assertion? Without being able to see the library source code, my ability to troubleshoot is severely limited.

Hi tritcs,

I have not tried to port the project into a different platform but I tried to port it into an existing project on the same platform. I was unsuccessful in getting the niq static libraries to work entirely and had to abandon it. However my time spent was not entirely lost.

Make sure you are pointing to the static libraries in your makefile and that they are getting compiled. The second thing is to make sure that you are adding the right memory location into the linker script to accommodate for the functions in the static libraries. I was unsuccessful on that last part because I had completely screwed with the memory layout. Checkout the linker script in the original project if you haven’t already tried this.

Best of luck

Hi Jenna,

I believe the static libraries are pointed to correctly. In fact, the the niq library is working since it is able to successfully initialize and call the resume and stop UWB tasks. The other libraries seem to work (at least what I’m able to test up until the issue), however there is an internal assertion which happens when uwbmac_init() is called (as pointed out in my initial post). This leads me to believe the mutex has not been initialized or has not been locked by the time uwbmac_init() is called. I’m wondering if there is an issue with how the application interacts with Zephyr and the static libraries allowing this condition exists. Perhaps I’m missing something related to initializing the uwb stack? Something that should differ from how things were done in SDK?

FYI, I was able to get the reference project working (using nRF SDK and SES). My new NCS based code strictly adheres to the reference project, only that it was Zephyrized.

Can you see what error code uwbmac_init is returning? If it gets an error code I would imagine something in the UWB stack is not initialized properly like you mentioned. If you don’t get an error code and it asserts for a different reason then it sounds like the static libraries aren’t being compiled correctly.

If you ported the project exactly as is then I’m leaning toward the idea that it’s something about how Zephyr is reading the files.

uwb_mac_init() doesn’t return. An assertion is happening within the library during a call to mutex_unlock():

assertion “lock && lock->mtx != NULL” failed: file “/builds/uwb-stack/uwb-stack/embedded/compat/include/linux/mutex.h”, line 42, function: mutex_unlock
exit

It seems that the mutex resource has not been initialized.

Hey Tristen,

Were you able to get the port to work? I have been trying to port this and have been running into NULL pointer issues with the uwbmac library. Any and all help of yours will be significantly appreciated!

I was not and ended up having to revert back to the stock FreeRTOS version. The libraries do not seem to be portable enough, or I’m not understanding the correct API hooks. If only there were more documentation for the Qorvo’s precompiled libraries. I abandoned this effort since any major updates with the libraries will likely cause more porting headaches in the future.