-
Notifications
You must be signed in to change notification settings - Fork 2.1k
pkg/nrf_modem: add initial modem support with gnss service #17032
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
For reference, here's the output of the test application:
|
736ea9f
to
b39d4cc
Compare
@leandrolanzieri Could you take a look at this one ? Just rebased to lastest master |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some initial comments, I'll try to test this on hardware during this week.
makefiles/tools/nrfjprog.inc.mk
Outdated
# Give the possibility to user to flash nRF modem firmware | ||
# To do so, use make nrf_mode/flash_firmware | ||
ifneq (,$(filter nrf_modem, $(USEPKG))) | ||
include $(RIOTMAKE)/nrf_modem_fw.inc.mk |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This does not exist in this commit yet. You probably will need to split differently.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll change it (and mark it as resolved so I won't forget) when this PR will be squashed.
pkg/nrf_modem/Makefile
Outdated
@@ -0,0 +1,19 @@ | |||
PKG_NAME=nrf_modem |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we better have this package as sdk_nrfxlib
? With pseudomodules we could choose what to compile and we could reuse it (thinking about crypto here ;)
pkg/nrf_modem/contrib/nrf_modem_os.c
Outdated
return sema_wait_timed_ztimer(sema, ZTIMER_MSEC, 0); | ||
} | ||
else if (timeout == NRF_MODEM_OS_FOREVER) { | ||
return sema_wait_timed_ztimer(sema, ZTIMER_MSEC, UINT32_MAX); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't we loop here until success?
@@ -0,0 +1,106 @@ | |||
/* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't fully understand what this layer is doing. The documentation mentions only the implementation of nrf_modem_os.c
based on nrf_modem_os.h
, why do we need this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because the libmodem.a call these functions. Unfortunately, it seems that this library relies (without any mention in the doc as far as I can tell) on nordic sdk for using the IPC peripheral which is needed for proper operations. I had to reimplement these functions using Nordic terminology so I could successfully link the lib against my code as I don't want to pull their whole SDK into RIOT...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see. So you took the implementation from this library? Wouldn't it be cheaper to add it as a package? I think it may turn to be an overhead to maintain a driver that is basically what they already have upstream. Or is there maybe some advantage other than not pulling the package once, which I fail to see here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So you took the implementation from this library?
Yes.
Wouldn't it be cheaper to add it as a package?
I don't think so. This can be done but at first I wanted to avoid all the pain adding such a big pkg for a single file in one PR.
Thanks for the review ! I'll try to fix everything by the end of the week. |
makefiles/nrf_modem_fw.inc.mk
Outdated
@@ -0,0 +1,14 @@ | |||
#include download firmware information from nrf_modem pkg |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should make this independent of the package. I'd move it to its dedicated directory in dist/tools
, as it really does not need the package, it downloads the firmware independently. What do you think?
makefiles/tools/nrfjprog.inc.mk
Outdated
|
||
# Give the possibility to user to flash nRF modem firmware | ||
# To do so, use make nrf_mode/flash_firmware | ||
ifneq (,$(filter nrf_modem, $(USEPKG))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, we could make this independent of the package being required right? It's just flashing the modem firmware
tests/pkg_nrf_modem/Makefile
Outdated
@@ -0,0 +1,12 @@ | |||
include ../Makefile.tests_common | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BOARD ?= nrf9160dk |
Sadly I can't get this to work yet :( I'm hitting two issues:
Note that this not happen in |
That's weird, did you flash successfully the modem firmware before flashing the app ? |
I did, the process seemed fine.
I tried that but the application does not find my device, so I can't update the firmware with it |
I've almost done all the required changes, I'll retry the whole process on my hardware, squash and push ASAP. |
As this firmware is needed for proper nrf_modem operations, add it as pkg in dist/tools and provide a easy way to users for flashing it through nrfjprog as this is the only PROGRAMMER that can flash it.
As this package contains several features, currently limit it to nrf_modem as of now. Adding new features support can be made by create the appropriate Makefile and a pseudomodule.
This auto_init is board specific as some parameters pass through AT commands depends on hardware capabilities, thus this init should be at board level
84917bb
to
ac5ca06
Compare
@leandrolanzieri I've updated and squashed this PR, ready for second round of review. |
needs rebase |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you want me to ignore this issue, please mark it with the "State: don't stale" label. Thank you for your contributions. |
Hey hey, @dylad can you do a rebase? |
I took a quick glance at nrfxlib. |
Contribution description
This PR adds initial support for nRF9160 modem library as a RIOT pkg.
The modem library (and the modem firmware) allow to use NB-IoT, LTE-M and GNSS features for nRF9160 MCUs.
In the current state, only the GNSS service is added. (NB-IoT and LTE-M can be added in a followup PR).
MCU and modem can communicate through the device's RAM and is managed by the Inter-Processor Communication peripheral (IPC).
Unfortunately, the modem library relies on Nordic drivers SDK for handling IPC stuff, thus I add to "emulate" somehow some functions of the Nordic SDK to make the modem library happy.
I think some discussions are needed for specific like the malloc management because some malloc() are made from ISR context by the modem library which is troublesome.
Testing procedure
Run
tests/pkg_nrf_modem
onnRF9160DK
, connect your terminal and go for a quick walk outside.Please make sure the nRF modem firmware is flashed before testing the application.
You can flash it through nrfconnect application or you can use
make nrf_modem/flash_firmware
which will usenrfjprog
tool.(This PR also adds nrfjprog as PROGRAMMER).
The application will initialize the GNSS service and will wait for a GPS fix event. Once GPS fix is made, NMEA frame will be displayed on the shell with your current location.
Issues/PRs references
None.