Skip to content

Commit 25a49c4

Browse files
authored
Merge pull request #432 from alistair23/alistair/lora-example
lora: Support RISC-V build, update to latest libtock-c and move to examples
2 parents 7dbbc27 + b8ab66d commit 25a49c4

File tree

19 files changed

+159
-115
lines changed

19 files changed

+159
-115
lines changed

.gitmodules

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
[submodule "lvgl/lvgl"]
55
path = lvgl/lvgl
66
url = https://github.com/littlevgl/lvgl.git
7-
[submodule "examples/lora/RadioLib"]
8-
path = wip/lora/RadioLib
9-
url = https://github.com/jgromes/RadioLib.git
107
[submodule "libopenthread/openthread"]
118
path = libopenthread/openthread
129
url = https://github.com/openthread/openthread.git
10+
[submodule "RadioLib/RadioLib"]
11+
path = RadioLib/RadioLib
12+
url = https://github.com/jgromes/RadioLib.git

RadioLib/Makefile

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
LIBNAME := RadioLib
2+
3+
TOCK_USERLAND_BASE_DIR ?= ..
4+
5+
$(LIBNAME)_DIR := $(TOCK_USERLAND_BASE_DIR)/$(LIBNAME)
6+
7+
# We ideally want this:
8+
# $(LIBNAME)_SRCS := \
9+
# $($(LIBNAME)_DIR)/$(LIBNAME)/src/Module.cpp \
10+
# $(wildcard $($(LIBNAME)_DIR)/$(LIBNAME)/src/*.cpp) \
11+
# $(wildcard $($(LIBNAME)_DIR)/$(LIBNAME)/src/*/*.cpp) \
12+
# $(wildcard $($(LIBNAME)_DIR)/$(LIBNAME)/src/*/*/*.cpp)
13+
#
14+
# But due to this in the GCC arm binary in the CI:
15+
#
16+
# ```
17+
# (insn 179 178 46 8 (set (reg:SI 3 r3 [168])
18+
# (mem/u/c:SI (plus:SI (reg:SI 12 ip [169])
19+
# (unspec:SI [
20+
# (symbol_ref/u:SI ("*.LC1") [flags 0x2])
21+
# ] UNSPEC_PIC_SYM)) [0 S4 A32])) "../../../RadioLib/src/modules/LR11x0/LR11x0.cpp":638:16 929 {*thumb1_movsi_insn}
22+
# (expr_list:REG_EQUAL (symbol_ref/u:SI ("*.LC1") [flags 0x2])
23+
# (nil)))
24+
# during RTL pass: postreload
25+
# ../../../RadioLib/src/modules/LR11x0/LR11x0.cpp:650:1: internal compiler error: in extract_constrain_insn, at recog.c:2195
26+
# ```
27+
#
28+
# we need to drop LR11x0
29+
$(LIBNAME)_SRCS := \
30+
$(wildcard $($(LIBNAME)_DIR)/$(LIBNAME)/src/*.cpp) \
31+
$(wildcard $($(LIBNAME)_DIR)/$(LIBNAME)/src/utils/*.cpp) \
32+
$(wildcard $($(LIBNAME)_DIR)/$(LIBNAME)/src/modules/C*/.cpp) \
33+
$(wildcard $($(LIBNAME)_DIR)/$(LIBNAME)/src/modules/LL*/*.cpp) \
34+
$(wildcard $($(LIBNAME)_DIR)/$(LIBNAME)/src/modules/RF*/*.cpp) \
35+
$(wildcard $($(LIBNAME)_DIR)/$(LIBNAME)/src/modules/S*/*.cpp) \
36+
$(wildcard $($(LIBNAME)_DIR)/$(LIBNAME)/src/modules/n*/*.cpp) \
37+
$(wildcard $($(LIBNAME)_DIR)/$(LIBNAME)/src/protocols/*/*.cpp) \
38+
39+
include $(TOCK_USERLAND_BASE_DIR)/TockLibrary.mk

RadioLib/Makefile.app

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Include the core RadioLib headers
2+
override CPPFLAGS += -I$(TOCK_USERLAND_BASE_DIR)/RadioLib/RadioLib/src
3+
4+
# Include the Tock specific headers
5+
override CPPFLAGS += -I$(TOCK_USERLAND_BASE_DIR)/RadioLib/RadioLib/examples/NonArduino/Tock

RadioLib/Makefile.setup

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
.PHONY: clean
2+
3+
TOCK_USERLAND_BASE_DIR ?= ../
4+
5+
6+
all: $(TOCK_USERLAND_BASE_DIR)/RadioLib/RadioLib/README.md
7+
8+
clean::
9+
rm -rf build
10+
11+
# confirm RadioLib git submodule is checked out.
12+
$(TOCK_USERLAND_BASE_DIR)/RadioLib/RadioLib/README.md:
13+
git submodule update --init -- $(TOCK_USERLAND_BASE_DIR)/RadioLib/RadioLib
14+

RadioLib/RadioLib

Submodule RadioLib added at 954477b

TockLibrary.mk

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,6 @@ $(call check_defined, LIBNAME)
2929
$(call check_defined, $(LIBNAME)_DIR)
3030
$(call check_defined, $(LIBNAME)_SRCS)
3131

32-
ifeq ($(strip $($(LIBNAME)_SRCS)),)
33-
$(error Library "$(LIBNAME)" has no SRCS?)
34-
endif
35-
3632
# directory for built output
3733
$(LIBNAME)_BUILDDIR := $($(LIBNAME)_DIR)/build
3834

wip/lora/README.md renamed to examples/lora/README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,14 @@ RadioLib.
2323
Note that the Makefiles will do this automatically when
2424
you run `make` in a subdirectory, but if you want to do
2525
it manually you can run the `build-RadioLib.sh` script.
26+
27+
### Building
28+
29+
To bulid any example just enter the directory and type
30+
31+
```shell
32+
make
33+
```
34+
35+
This will build RadioLib and then the example application for
36+
both ARM and RISC-V architectures.

examples/lora/sensor-receive/Makefile

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Makefile for user application
2+
3+
# Specify this directory relative to the current application.
4+
TOCK_USERLAND_BASE_DIR = ../../..
5+
6+
# Which files to compile.
7+
CXX_SRCS := $(wildcard *.cc)
8+
9+
# Use the libtock-c Make system
10+
EXTERN_LIBS += $(TOCK_USERLAND_BASE_DIR)/RadioLib
11+
12+
include $(TOCK_USERLAND_BASE_DIR)/AppMakefile.mk
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
Sensor Receive
2+
==============
3+
4+
This example builds an application to receiver sensor data.
5+
6+
## Example Output
7+
8+
The output should look something like this.
9+
10+
Note that if the receive example is started before the transmit you will get
11+
-6 errors (RX_TIMEOUT) like below, as there is nothing to receive.
12+
13+
```
14+
Apollo3 chip revision: B
15+
Initialization complete. Entering main loop
16+
[SX1261] Initialising Radio ...
17+
success!
18+
[SX1261] Receiving...
19+
failed, code -6
20+
failed, code -6
21+
failed, code -6
22+
failed, code -6
23+
failed, code -6
24+
failed, code -6
25+
failed, code -6
26+
failed, code -6
27+
failed, code -6
28+
failed, code -6
29+
failed, code -6
30+
failed, code -6
31+
success!: Temp: 24047, Hum: 5966
32+
success!: Temp: 24047, Hum: 5966
33+
success!: Temp: 24047, Hum: 5966
34+
success!: Temp: 24047, Hum: 5966
35+
success!: Temp: 24047, Hum: 5966
36+
```

wip/lora/sensor-receive/main.cc renamed to examples/lora/sensor-receive/main.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ int main(void) {
5050
// Ensure there are no pending callbacks
5151
yield_no_wait();
5252

53-
state = radio->receive((uint8_t*)buffer, BUFFER_LEN);
53+
state = radio->receive(reinterpret_cast<uint8_t*> (buffer), BUFFER_LEN);
5454

5555
if (state == RADIOLIB_ERR_NONE) {
5656
// the packet was successfully transmitted

0 commit comments

Comments
 (0)