-
Notifications
You must be signed in to change notification settings - Fork 6.6k
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
[RFC][DNM] Porting LoRaMAC-node project to zephyr #5764
Conversation
All files are copy from LoRaWAN project. Signed-off-by: Ding Tao <[email protected]>
All files are copy from LoRaWAN-node project. Signed-off-by: Ding Tao <[email protected]>
All files are copy from LoRaMAC-node project. Signed-off-by: Ding Tao <[email protected]>
We implement them at one single file to port to zephyr. Signed-off-by: Ding Tao <[email protected]>
We implement them at one single file to port to zephyr. Signed-off-by: Ding Tao <[email protected]>
Unfinished, this file is the driver of sx1276. Signed-off-by: Ding Tao <[email protected]>
Unfinished, this file is the driver of sx1272. Signed-off-by: Ding Tao <[email protected]>
This commit is only for test purpose. Signed-off-by: Ding Tao <[email protected]>
Codecov Report
@@ Coverage Diff @@
## master #5764 +/- ##
=========================================
+ Coverage 51.29% 51.3% +<.01%
=========================================
Files 441 441
Lines 42268 42268
Branches 8063 8063
=========================================
+ Hits 21683 21685 +2
+ Misses 20066 20064 -2
Partials 519 519
Continue to review full report at Codecov.
|
@miyatsu since you don´t want to contribute this work to Zephyr community, I will try to start with a different approach, an easier one. My start point will be to make a driver for the RFM95 and port the LoRaWAN (AKA LoraMac) as a library only. After that, I will try to make LoRaWAN part of the kernel itself. I think this is a more smooth/natural way to get deep into Zephyr. Let´s begin with a more realistic goal for me. Thank you for your help. |
@rodrigopex Do you got any idea of how to make the LoRaMAC as a library ? I'm try to make the LoRaMAC run like fs in zephyr, that can linked with the kernel, rather than compile the hole LoRaMAC with kernel to zephyr output file. I find the cmake command add_library() via subsys/bluetooth/CMakeLists.txt .. But don't know how to use it. |
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.
For the source code you wrote yourself, check the style:
- 80 chars limit
- '{' is on the same line as if (), for (), while ()...
Rest looks fine to me. Looks like you just need to finish the Kconfig/CMakeLists.txt stuff.
|
||
menu "LoRaWAN" | ||
|
||
config LORAWAN |
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.
Merge this line with line 8:
menuconfig LORAWAN
....
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.
Write this as you suggested, this menu will not be shown in a single page.
@@ -0,0 +1,2 @@ | |||
zephyr_sources_ifdef(CONFIG_SX1272 sx1272.c) |
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 think you need a CMakeLists.txt here, as all the source code is in ext/...
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.
Are you suggested, I should move all imp func to ext/ dir ?
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.
@miyatsu Sorry I got confused with the patches. Actually the driver function implementation (sx1272.c and sx1276.c), should go in drivers/lora with this CMakeLists.txt and the radio Kconfig part. Looks like it only needs to be moved, content seems fine to me. Maybe change the Kconfig first config option to:
menuconfig LORA
bool "LoRa Radio chip support"
default n
select
if LORA
... the config option for the 2 radio chip (the separation in dedicated Kconfig.sx--- as you did is nice. Maybe add the prefix LORA_ to all these options though. This is usually how we do, so it tells to which part the config option belongs to.
endfi #LORA
|
||
int bus_spi_init(void) | ||
{ | ||
spi_cs.gpio_dev = device_get_binding("GPIOA"); |
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.
Ok, so here you will have to use your Kconfig options you declare in the last patch
@miyatsu If you are posting a PR here I assume that you actually do want to make this available to Zephyr in general, so we need to follow the rules. Let's start by cleaning up the import to First, the commit messages when importing into
Then you need to import a specific version of the LoraWan-node repository, untouched from the upstream version. |
sorry, I'm confused - will this ever be merged? I'm starting to work with it and add RN2483... and it would be great if I knew how to prepare to contribute it later |
@derchrismakaio : Unfortunately the author of this PR did not update it and closed it. Nothing prevents you to take over the work already done, apply the requested changes above, and create a new PR from it. Would be nice to get that into zephyr. |
@derchrismakaio as @tbursztyka mentions, you can pull this PR and create a new one from it that you can submit later. |
Hi @derchrismakaio , I'm no longer contribute LoRaWan to zephyr any more, due to some reasons. I'm sorry to confirm that this PR will never be merged. But you can create a new PR from this or write it from scratch to contribute to zephyr as @carlescufi mentioned, that would be very nice. |
Alright, I‘ll give it a try.
What should happen to the LoRaWan-node repo?
Should I fork it with our company account to be used with zephyr? How to link our repo then?
And the commit message: should it really look like a readme?
|
@derchrismakaio
Brilliant!
I believe that the repo is 3-clause BSD, and so it can only live in Zephyr's EDIT: We are currently working towards supporting external repositories in Zephyr without having to copy their contents in the |
I tried to put it in ext/ but problem is that I have to override the CMakeLists.txt. add_subdirectory_ifdef(CONFIG_LORAWAN ${PROJECT_SOURCE_DIR}/ext/lorawan) but that would require a binary_dir Alternative - if good practice: I could restructure the directories like this... ext/lorawan/
ext/lorawan/LoRaMac-node
|
@SebastianBoe would you mind replying to this comment |
@derchrismakaio I would probably go with the alternative you mention, seems cleaner to me. |
@derchrismakaio Don't know if it is of any help but cmake has support to import external projects and it is already used in zephyr (e.g. zephyr/subsys/net/lib/openthread/CMakeLists.txt) |
See ext/lib/ipc/open-amp for how this has been done before. Seems that it the second alternative that has worked well before.
ExternalProject (recursively invoking build systems) should only be done when it is infeasible to integrate/port the build system. I'm not familiar with LoRaMac so I can't speak to what should be done with it. |
@SebastianBoe this is actually what I did when I started to work yesterday ;) What's the best way to post code excerpts here? |
urgh, okay, I've built the skeleton but it lacks implementation, of course. So here's my concept: Interfaces I recommend moving from lorawan dir to lora (because that was what was really confusing me). As most LoRaWAN devices (like the RN2483) bring both layers, I'd try to implement both but with focus on LoRaWAN. Drivers Shell Setup And another question: |
If the activation is done through Kconfig, and not DT, then yes. It sounds like you would need a choice statement. If the activation is not available in Kconfig you would need to duplicate the information in Kconfig, this is a workaround to #7302 See #9499 (comment) for how to have a selection of options with the default selection being affected by the board choice. EDIT: I can't speak of how to organize the system into drivers and subsystems as I am not an expert in that area. |
This is an old PR. What I would suggest is that you create a new PR with a basic proof-of-concept and then people will be able to comment inline. |
@derchrismakaio Would you mind loop me in when you create an new PR of this? |
@miyatsu of course I'll do, but keep in mind that I won't focus on the MAC layer (which I think you need) |
@chris-makaio Did you get time to create a new PR out of this? I'm also working on LoRa node for one of our 96Boards and might get along with you. Please let me know! |
@Mani-Sadhasivam I didn't create a new PR on this yet because I'm working on different drivers currently, but will need LoRa modem drivers in future. I'm happy to discuss things |
Recently, I'm try to use Semtech SX1278 radio chip to do something. But zephyr didn't support LoRaWAN so far.
So, I'm trying to porting the LoRaMac-node project (https://github.com/Lora-net/LoRaMac-node) to zephyr just for my self use ONLY, but no plan to contribute this work to zephyr community.
Here are some previous conversations #4569 . I took
suggestions from @tbursztyka , try to make this patch easy to somebody else to finish this work.
And LoRaWAN may will be zephyr's major components in the future, see #5436
I decide to open this PR so every body can see it, may helpful for zephyr feature development on LoRaWAN support.