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

+3-3
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

+39
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

+5
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

+14
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

-4
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

+11
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

+12
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
+36
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

+1-1
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
+12
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
+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
Sensor Transmitter
2+
==================
3+
4+
This example builds an application to transmit sensor data.
5+
6+
## Example Output
7+
8+
The output should look something like this
9+
10+
```
11+
Apollo3 chip revision: B
12+
Initialization complete. Entering main loop
13+
[SX1261] Initialising Radio ...
14+
success!
15+
[SX1261] Transmitting 'Temp: 24047, Hum: 5966'
16+
success!
17+
[SX1261] Transmitting 'Temp: 24047, Hum: 5966'
18+
success!
19+
```

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

+6-6
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
#include "libtockHal.h"
1414

1515
// Include some libtock-c helpers
16-
#include <sensors/humidity.h>
17-
#include <sensors/temperature.h>
16+
#include <libtock-sync/sensors/humidity.h>
17+
#include <libtock-sync/sensors/temperature.h>
1818

1919
#define BUFFER_LEN 64
2020

@@ -47,17 +47,17 @@ int main(void) {
4747
}
4848
printf("success!\r\n");
4949

50-
int temp = 0;
51-
unsigned humi = 0;
50+
int temp = 0;
51+
int humi = 0;
5252

5353
// loop forever
5454
for ( ;;) {
5555
// Ensure there are no pending callbacks
5656
yield_no_wait();
5757

5858
// Read some sensor data from the board
59-
temperature_read_sync(&temp);
60-
humidity_read_sync(&humi);
59+
libtocksync_temperature_read(&temp);
60+
libtocksync_humidity_read(&humi);
6161

6262
snprintf(buffer, BUFFER_LEN, "Temp: %d, Hum: %u", temp, humi);
6363

wip/lora/RadioLib

-1
This file was deleted.

wip/lora/build-RadioLib.sh

-26
This file was deleted.

wip/lora/sensor-receive/Makefile

-33
This file was deleted.

wip/lora/sensor-receive/README.md

-4
This file was deleted.

wip/lora/sensor-transmit/Makefile

-33
This file was deleted.

wip/lora/sensor-transmit/README.md

-4
This file was deleted.

0 commit comments

Comments
 (0)