The Semtch LoRa-node lib, that I used with some success in Test LoRaWan Thing code ported for Raspberry Pico . is deprecated. It's replaced by LoRa Basic Modem. I'm going to try and port that for the RP2040 controller. I've set ambitious goals:
- don't change Semtech's code
- port as specified by LoRa Basics Modem Porting Guide (30 pages of instructions)
- use CMake, for compatibility with the Pico C/C++ SDK. Unless I find a way to integrate the make files in the build.
- reusable for other projects

image source: Semtech Porting guide
Create a directory structure and get the LoRa Modem lib
I created a directory in the IDE workspace. I use VSCode, but the project works for any environment that can build one of Raspberry's Pico examples.
C:\Users\jancu\Documents\Pico\PicoSDKv1.5.1\workspace_1.5.1\pico_lorawan_modem
Then checked out Semtech's LoRa Modem lib:
git clone --recurse-submodules https://github.com/Lora-net/SWL2001.git
I created a main file, empty at the moment, and 2 CMake config files.
main.cpp
#include <stdio.h>
#include "pico/stdlib.h"
int main() {
stdio_init_all();
while (true) {
}
return 0;
}
CMakeList.txt
cmake_minimum_required(VERSION 3.13)
set(PICO_DEOPTIMIZED_DEBUG 1)
# Pull in SDK (must be before project)
include(pico_sdk_import.cmake)
set(PICO_BOARD seeed_xiao_rp2040)
project(pico_lorawan_modem C CXX ASM)
set(CMAKE_C_STANDARD 11)
set(CMAKE_CXX_STANDARD 20)
pico_sdk_init()
set(RADIO sx1276)
include (CMakeSWL2001.txt)
add_executable(${CMAKE_PROJECT_NAME} main.cpp )
pico_set_program_name(${CMAKE_PROJECT_NAME} ${CMAKE_PROJECT_NAME})
pico_set_program_version(${CMAKE_PROJECT_NAME} "0.1")
pico_enable_stdio_uart(${CMAKE_PROJECT_NAME} 0)
pico_enable_stdio_usb(${CMAKE_PROJECT_NAME} 1)
# Add any user requested libraries
target_link_libraries(${CMAKE_PROJECT_NAME} PRIVATE
pico_stdlib
)
pico_add_extra_outputs(${CMAKE_PROJECT_NAME})
This is a very common RP2040 file. You'll see that I only added two lines for the LoRa Modem:
set(RADIO sx1276)include (CMakeSWL2001.txt)
That's because I plan to have anything related to the Semtech lib in a separate file.
CMakeSWL2001.txt
set(LORAWAN_LIB_NAME SWL2001)
add_library(${LORAWAN_LIB_NAME} INTERFACE)
target_include_directories(${LORAWAN_LIB_NAME} INTERFACE)
set(LORAMAC_LIB_PATH ${CMAKE_CURRENT_LIST_DIR}/SWL2001/lbm_lib)
if(NOT DEFINED RADIO)
message("You must set a radio")
message("set(RADIO <semtech radio model>")
message("Valid options: (lr1110 lr1120 lr1121 sx1261 sx1262 sx1268 sx128x sx1272s) sx1276")
message(FATAL_ERROR "Fix this before continuing.")
endif()
message("Radio selected: ${RADIO}")
target_sources(${LORAWAN_LIB_NAME} INTERFACE
# ${LORAMAC_NODE_PATH}/src/peripherals/soft-se/soft-se.c
)
target_include_directories(${LORAWAN_LIB_NAME} INTERFACE
# ${LORAMAC_NODE_PATH}/src
)
You can see it's still in its infant stage. It can manage a few things that I'll need later:
- configure it so that the Pico example will see it as "one of the usual" libraries
- check if a LoRaWan radio chip is selected. Error the build if not.
- infra to collect all include and source files that 'll be required later.

-
eriklundh
-
Cancel
-
Vote Up
0
Vote Down
-
-
Sign in to reply
-
More
-
Cancel
-
Jan Cumps
in reply to eriklundh
-
Cancel
-
Vote Up
0
Vote Down
-
-
Sign in to reply
-
More
-
Cancel
-
eriklundh
in reply to Jan Cumps
-
Cancel
-
Vote Up
0
Vote Down
-
-
Sign in to reply
-
More
-
Cancel
-
Jan Cumps
in reply to eriklundh
-
Cancel
-
Vote Up
0
Vote Down
-
-
Sign in to reply
-
More
-
Cancel
Comment-
Jan Cumps
in reply to eriklundh
-
Cancel
-
Vote Up
0
Vote Down
-
-
Sign in to reply
-
More
-
Cancel
Children