Skip to content

Commit 955a568

Browse files
committed
Lora Basics Modem port for ZephyrInitial commit
0 parents  commit 955a568

File tree

140 files changed

+16359
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

140 files changed

+16359
-0
lines changed

CHANGELOG

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
v0.6
2+
====
3+
4+
LoRa Basics Modem:
5+
* Fix gpio interrupt behaviour that was not left pending when disabled (Fixes WiFi/GNSS Scanning)
6+
* Properly configure the "Scanning" LED for GNSS/WiFi scanning
7+
8+
v0.5
9+
====
10+
11+
Radio drivers:
12+
* BUSY wait timeout was bumped to 10 minutes to support wifi/GNSS scanning.
13+
* Update the current shields and add new specific shields for TCXO/Crystal
14+
15+
v0.4
16+
====
17+
18+
Radio drivers:
19+
* Add complete support for SX126x
20+
* Rework drivers Kconfig settings (now only CONFIG_LORA_BASICS_MODEM_DRIVERS is required)
21+
* Rework device tree LR11xx configuration, add TX power calibration settings
22+
* Partially support MCU-controlled TCXO (properly configure the transceiver)
23+
* Support configuration of XTAL trim capacitors
24+
25+
LoRa Basics Modem:
26+
* Support Class B, Class C, and Multicast
27+
* Fix FUOTA
28+
* Fix geolocation build
29+
* Add a new optional "LBM Main Thread" that offloads LBM outside of the main thread
30+
* Coding style fixes
31+
* Rename samples
32+
* samples/hw_modem: Fix FUOTA, misc fixes
33+
* Fix some buggy logging messages
34+
* Implement crashlog storage
35+
* samples: Add LCTT certification sample

CMakeLists.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Copyright (c) 2024 Semtech Corporation - Félix Piédallu
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
cmake_minimum_required(VERSION 3.12.4)
5+
6+
add_subdirectory(drivers)
7+
add_subdirectory(subsys)
8+
9+
zephyr_include_directories(include)

Kconfig

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# General configuration options
2+
3+
# Copyright (c) 2014-2015 Wind River Systems, Inc.
4+
# Copyright (c) 2016 Intel Corporation
5+
# Copyright (c) 2023 Nordic Semiconductor ASA
6+
# SPDX-License-Identifier: Apache-2.0
7+
8+
# This Kconfig file is picked by the Zephyr build system because it is defined
9+
# as the module Kconfig entry point (see zephyr/module.yml). You can browse
10+
# module options by going to Zephyr -> Modules in Kconfig.
11+
12+
rsource "drivers/Kconfig"
13+
rsource "subsys/Kconfig"

README.md

Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
# LoRa Basics Modem on Zephyr
2+
3+
This repository aims to make LoRa Basics Modem available in Zephyr. It wraps the existing
4+
SWL2001 repository from Semtech.
5+
6+
At term, this repository might be merged into the upstream Zephyr project.
7+
8+
This is an experimental release of demo projects of LBM on Zephyr, tested on LR11xxMB1LxKS shields
9+
10+
## Zephyr module
11+
12+
You can use this module either as your "west manifest project", or include it in
13+
another project. In that case you need to add `import: true` to the caller configuration, as this:
14+
15+
```yaml
16+
projects:
17+
- name: lora_lbm
18+
path: modules/lora_lbm
19+
remote: lora-net
20+
repo-path: lora_lbm_zephyr
21+
revision: zephyr
22+
import: true
23+
```
24+
25+
## Requirements
26+
27+
You need a recent Linux distribution (Python >= 3.10, CMake >= 3.20.5).
28+
29+
### Install west and Zephyr SDK
30+
31+
You need to install the Zephyr SDK (compiler and flashing tools) and west (the build system tool).
32+
33+
Please follow instructions at <https://docs.zephyrproject.org/latest/develop/getting_started/index.html>.
34+
You will only need to follow this step only once for all your Zephyr projects.
35+
36+
### Activate the Zephyr virtual environment (if not already activated)
37+
38+
If it's not installed in your system, you need to load the Zephyr SDK environment each time you open a new terminal:
39+
40+
```bash
41+
source ~/zephyrproject/.venv/bin/activate
42+
```
43+
44+
## Download code
45+
46+
This repository only contains specific LBM port code and the samples. We also need to download Zephyr itself, LBM, and associated HAL modules.
47+
48+
You need to create an empty directory, let's name it `lbm_zephyr_workspace`, and clone the current repository inside it.
49+
50+
```bash
51+
mkdir lbm_zephyr_workspace
52+
cd lbm_zephyr_workspace
53+
git clone git@github.com:lora-net-private/SWL2001_Zephyr.git lora_lbm
54+
```
55+
56+
The `SWL2001_Manifest` repository will be automatically downloaded, you don't need to clone it yourself.
57+
58+
### Configure the SSH command (only needed if external to lora-net-private)
59+
60+
If you need Git to use a custom SSH key to access the private repositories, you can either
61+
configure it in your `~/.ssh/config` file or specify it in your terminal's environment:
62+
63+
```bash
64+
export GIT_SSH_COMMAND="/usr/bin/ssh -i <path>/60093279.SWL2001SSHKEYMFAS.key"
65+
```
66+
67+
### Download Zephyr and its modules
68+
69+
Then, initialize West (the build tool):
70+
Multiple repositories will be automatically downloaded inside the workspace directory.
71+
72+
```bash
73+
west init -l lora_lbm
74+
west update
75+
```
76+
77+
It will take 3-10 minutes to run depending on your network connection.
78+
79+
You will need to run this step for every project you download.
80+
81+
If major updates to `lora_lbm` are provided, you might need to run `west update` again.
82+
83+
## The samples
84+
85+
Samples are in the `lora_lbm/samples` directory, split in two classes:
86+
87+
* lora_drivers: Samples only using the low level LoRa drivers
88+
* ping_pong : Flash this sample to two boards to see them talk.
89+
* ping_shell : Same as ping_pong, but manually, using the Zephyr shell ! run `lorademo ping` in one board to ping the other flashed board.
90+
* lora_basics_modem: Samples leveraging the LBM stack to communicate with LoRaWAN networks.
91+
* app_demo_periodical_uplink: This sample joins a network and periodically sends packets.
92+
You can also send a packet manually by pressing the button (on nRF52840dk it's BUTTON 1).
93+
Please configure your device EUIs/App keys in `src/example_options.h`
94+
* app_lbm_hw_modem: used for continuous integration tests. It expects serial communication on an UART port.
95+
Read `src/hw_modem/cmd_parser.c` for explanations.
96+
97+
98+
## Build the code
99+
100+
You need to inform Zephyr which board and shield you want to use. Shields are in the `lora_lbm/boards/shields/*` directories as `.overlay` files.
101+
They describe which transceiver model you are using. For example, `semtech_lr1110mb1xxs`.
102+
103+
Go into a sample's directory, then run:
104+
105+
```bash
106+
west build --board nrf52840dk/nrf52840 -- -DSHIELD=semtech_lr1110mb1xxs
107+
# or
108+
west build --board nucleo_l476rg --build-dir build_nucleo -- -DSHIELD=semtech_lr1110mb1xxs
109+
```
110+
111+
It will build your project in the `build` subdirectory (can be configured by `--build-dir`).
112+
You can pass `--pristine` to ensure the build directory is clean.
113+
114+
The boards are expected to have a `lora0` node label. The shield `semtech_lr1110mb1xxs` provides it.
115+
116+
You might want to customize the LoRa transceiver configuration by adding a file in the `boards` subdirectory or via `app.overlay`.
117+
For example, to set a TCXO instead of the default XTAL:
118+
119+
```dts
120+
&lora_semtech_lr11xxmb1xis {
121+
tcxo-wakeup-time = <7>;
122+
};
123+
```
124+
125+
## Flash the board
126+
127+
```bash
128+
west flash
129+
# or
130+
west flash --build-dir build_nucleo
131+
```
132+
133+
For the nRF52840-DK board, you don't need to close open serial ports during flash.
134+
135+
## Open the serial port
136+
137+
You can use minicom, picocom, tio,…
138+
139+
```bash
140+
tio /dev/serial/by-id/usb-SEGGER_J-Link_*-if00
141+
```
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Copyright (c) 2024 Semtech Corporation
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
config SHIELD_SEMTECH_LR1110MB1xxS
5+
def_bool $(shields_list_contains,semtech_lr1110mb1xxs)
6+
7+
config SHIELD_SEMTECH_LR1120MB1xxS
8+
def_bool $(shields_list_contains,semtech_lr1120mb1xxs)
9+
10+
config SHIELD_SEMTECH_LR1121MB1xxS
11+
def_bool $(shields_list_contains,semtech_lr1121mb1xxs)
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
.. semtech_lr11xxmb1xxs:
2+
3+
Semtech LR11xxMB1xxS LoRa Shields
4+
#################################
5+
6+
Overview
7+
********
8+
9+
Semtech provides a series of Arduino compatible shields based on their LoRa
10+
transceivers LR1110, LR1120, and LR1121.
11+
Those shields are mostly similar and include a LIS2DE12 3-axis i2c accelerometer
12+
from STMicroelectronics.
13+
14+
More information about the shield can be found at the `mbed LR1110MB1xxS
15+
website`_.
16+
17+
Pins Assignment of the Semtech LR1110MB1xxS LoRa Shield
18+
=======================================================
19+
20+
+-------------+---------------------+
21+
| Shield Pin | Function |
22+
+=============+=====================+
23+
| A0 | LR1110 NRESET |
24+
+-------------+---------------------+
25+
| A1 | 32kHz Osc out |
26+
+-------------+---------------------+
27+
| A2 | LR111x / LR1110 |
28+
+-------------+---------------------+
29+
| A3 | LNA Control |
30+
+-------------+---------------------+
31+
| A4 | LED TX |
32+
+-------------+---------------------+
33+
| A5 | LED RX |
34+
+-------------+---------------------+
35+
| D2 | To Display Shield |
36+
+-------------+---------------------+
37+
| D3 | LR1110 DIO0 (BUSY) |
38+
+-------------+---------------------+
39+
| D4 | LED Sniffing |
40+
+-------------+---------------------+
41+
| D5 | LR1110 DIO9 |
42+
+-------------+---------------------+
43+
| D7 | LR1110 SPI NSS |
44+
+-------------+---------------------+
45+
| D8 | MEMS Accel INT1 |
46+
+-------------+---------------------+
47+
| D9 | Display D/C |
48+
+-------------+---------------------+
49+
| D10 | Display CS |
50+
+-------------+---------------------+
51+
| D11 | LR1110 SPI MOSI |
52+
+-------------+---------------------+
53+
| D12 | LR1110 SPI MISO |
54+
+-------------+---------------------+
55+
| D13 | LR1110 SPI SCK |
56+
+-------------+---------------------+
57+
| D14 | MEMS+EEPROM i2c SDA |
58+
+-------------+---------------------+
59+
| D15 | MEMS+EEPROM i2c SCL |
60+
+-------------+---------------------+
61+
62+
LR1110 and LR1120 based shields use a TCXO and LR1121 based shields use a crystal.
63+
64+
Requirements
65+
************
66+
67+
This shield can only be used with a board which provides a configuration for
68+
Arduino connectors and defines node aliases for SPI and GPIO interfaces (see
69+
:ref:`shields` for more details).
70+
71+
Programming
72+
***********
73+
74+
Set ``-DSHIELD=semtech_lr1110mb1xxs`` when you invoke ``west build``. For
75+
example:
76+
77+
.. zephyr-app-commands::
78+
:zephyr-app: samples/subsys/lorawan/class_a
79+
:board: nucleo_l073rz
80+
:shield: semtech_lr1110mb1xxs
81+
:goals: build
82+
83+
References
84+
**********
85+
86+
.. target-notes::
87+
88+
.. _mbed LR1110MB1xxS website:
89+
https://os.mbed.com/components/LR1110MB1xxS/
90+
91+
92+
License
93+
*******
94+
95+
This document Copyright (c) 2024 Semtech Corporation
96+
97+
SPDX-License-Identifier: Apache-2.0
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/*
2+
* Copyright (c) 2024 Semtech Corporation
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
#include "semtech_lr11xxmb1xxs_common.dtsi"
8+
9+
lora_semtech_lr1110mb1xxs: &lora_semtech_lr11xxmb1xxs {
10+
compatible = "semtech,lr1110";
11+
12+
tcxo-wakeup-time = <8>;
13+
};
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/*
2+
* Copyright (c) 2024 Semtech Corporation
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
#include "semtech_lr11xxmb1xxs_common.dtsi"
8+
9+
lora_semtech_lr1120mb1xxs: &lora_semtech_lr11xxmb1xxs {
10+
compatible = "semtech,lr1120";
11+
12+
tcxo-wakeup-time = <8>;
13+
};
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/*
2+
* Copyright (c) 2024 Semtech Corporation
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
#include "semtech_lr11xxmb1xxs_common.dtsi"
8+
9+
lora_semtech_lr1121mb1xxs: &lora_semtech_lr11xxmb1xxs {
10+
compatible = "semtech,lr1121";
11+
12+
/* LR1121 shields all have XTAL */
13+
};

0 commit comments

Comments
 (0)