From bb633942f132a660af63373cc5db1fd2252285c0 Mon Sep 17 00:00:00 2001 From: Alistair Francis Date: Thu, 2 May 2024 18:22:06 +1000 Subject: [PATCH 01/12] lora: Build lora examples for RISC-V Signed-off-by: Alistair Francis --- wip/lora/RadioLib | 2 +- wip/lora/build-RadioLib.sh | 19 ++++++++++++++++--- wip/lora/sensor-receive/Makefile | 23 +++++++++++++---------- wip/lora/sensor-transmit/Makefile | 18 +++++++++--------- 4 files changed, 39 insertions(+), 23 deletions(-) diff --git a/wip/lora/RadioLib b/wip/lora/RadioLib index 0ef554c6c..7209690bf 160000 --- a/wip/lora/RadioLib +++ b/wip/lora/RadioLib @@ -1 +1 @@ -Subproject commit 0ef554c6c874407034290c88275b108a9ca265cb +Subproject commit 7209690bf6aa92fcc6a17e3d08ab486cdbf0ddaa diff --git a/wip/lora/build-RadioLib.sh b/wip/lora/build-RadioLib.sh index 4a60cebb9..c7613cdea 100755 --- a/wip/lora/build-RadioLib.sh +++ b/wip/lora/build-RadioLib.sh @@ -2,7 +2,7 @@ pushd RadioLib/examples/NonArduino/Tock/ -rm -rf build +rm -rf build-* # Change the source to point to the current libtock-c directory # Note, x-platform `sed -i` has odd, but particular syntax @@ -12,8 +12,8 @@ sed -i._SED_HACK 's|target_include_directories(${PROJECT_NAME} PUBLIC|target_inc find . -name '*._SED_HACK' -delete -mkdir -p build -cd build +mkdir -p build-arm +cd build-arm cmake -G "CodeBlocks - Unix Makefiles" .. @@ -22,5 +22,18 @@ cmake -G "CodeBlocks - Unix Makefiles" .. # That's fine for us though, as we just need to build the RadioLib # library, not the entire example application make -j4 2> /dev/null +cd ../ + +mkdir -p build-riscv +cd build-riscv + +cmake -G "CodeBlocks - Unix Makefiles" -DRISCV_BUILD=1 .. + +# Build the Tock example application +# This will fail to link, as it can't find the libtock-c libraries +# That's fine for us though, as we just need to build the RadioLib +# library, not the entire example application +make -j4 2> /dev/null +cd ../ popd diff --git a/wip/lora/sensor-receive/Makefile b/wip/lora/sensor-receive/Makefile index 01e36e661..b3554b7b1 100644 --- a/wip/lora/sensor-receive/Makefile +++ b/wip/lora/sensor-receive/Makefile @@ -3,10 +3,6 @@ # Specify this directory relative to the current application. TOCK_USERLAND_BASE_DIR = ../../../ -# We only compile this for Cortex-M platforms because we only have -# libraries for Cortex-M. -TOCK_TARGETS := cortex-m0 cortex-m3 cortex-m4 cortex-m7 - # Which files to compile. CXX_SRCS := $(wildcard *.cc) @@ -19,15 +15,22 @@ override CPPFLAGS += -isystem ../RadioLib/examples/NonArduino/Tock # Include the base of libtock-c to fix the libtock/ includes from RadioLib override CPPFLAGS += -I$(TOCK_USERLAND_BASE_DIR)/ -LIBS_cortex-m += ../RadioLib/examples/NonArduino/Tock/build/RadioLib/libRadioLib.a -LIBS_cortex-m0 += ../RadioLib/examples/NonArduino/Tock/build/RadioLib/libRadioLib.a -LIBS_cortex-m3 += ../RadioLib/examples/NonArduino/Tock/build/RadioLib/libRadioLib.a -LIBS_cortex-m4 += ../RadioLib/examples/NonArduino/Tock/build/RadioLib/libRadioLib.a -LIBS_cortex-m7 += ../RadioLib/examples/NonArduino/Tock/build/RadioLib/libRadioLib.a +LIBS_cortex-m += ../RadioLib/examples/NonArduino/Tock/build-arm/RadioLib/libRadioLib.a +LIBS_cortex-m0 += ../RadioLib/examples/NonArduino/Tock/build-arm/RadioLib/libRadioLib.a +LIBS_cortex-m3 += ../RadioLib/examples/NonArduino/Tock/build-arm/RadioLib/libRadioLib.a +LIBS_cortex-m4 += ../RadioLib/examples/NonArduino/Tock/build-arm/RadioLib/libRadioLib.a +LIBS_cortex-m7 += ../RadioLib/examples/NonArduino/Tock/build-arm/RadioLib/libRadioLib.a + +LIBS_rv32i += ../RadioLib/examples/NonArduino/Tock/build-riscv/RadioLib/libRadioLib.a +LIBS_rv32imc += ../RadioLib/examples/NonArduino/Tock/build-riscv/RadioLib/libRadioLib.a +LIBS_rv32imac += ../RadioLib/examples/NonArduino/Tock/build-riscv/RadioLib/libRadioLib.a # Include userland master makefile. Contains rules and flags for actually # building the application. include $(TOCK_USERLAND_BASE_DIR)/AppMakefile.mk -../RadioLib/examples/NonArduino/Tock/build/RadioLib/libRadioLib.a: +../RadioLib/examples/NonArduino/Tock/build-arm/RadioLib/libRadioLib.a: + cd ../ && ./build-RadioLib.sh + +../RadioLib/examples/NonArduino/Tock/build-riscv/RadioLib/libRadioLib.a: cd ../ && ./build-RadioLib.sh diff --git a/wip/lora/sensor-transmit/Makefile b/wip/lora/sensor-transmit/Makefile index 01e36e661..e9b947278 100644 --- a/wip/lora/sensor-transmit/Makefile +++ b/wip/lora/sensor-transmit/Makefile @@ -3,10 +3,6 @@ # Specify this directory relative to the current application. TOCK_USERLAND_BASE_DIR = ../../../ -# We only compile this for Cortex-M platforms because we only have -# libraries for Cortex-M. -TOCK_TARGETS := cortex-m0 cortex-m3 cortex-m4 cortex-m7 - # Which files to compile. CXX_SRCS := $(wildcard *.cc) @@ -19,11 +15,15 @@ override CPPFLAGS += -isystem ../RadioLib/examples/NonArduino/Tock # Include the base of libtock-c to fix the libtock/ includes from RadioLib override CPPFLAGS += -I$(TOCK_USERLAND_BASE_DIR)/ -LIBS_cortex-m += ../RadioLib/examples/NonArduino/Tock/build/RadioLib/libRadioLib.a -LIBS_cortex-m0 += ../RadioLib/examples/NonArduino/Tock/build/RadioLib/libRadioLib.a -LIBS_cortex-m3 += ../RadioLib/examples/NonArduino/Tock/build/RadioLib/libRadioLib.a -LIBS_cortex-m4 += ../RadioLib/examples/NonArduino/Tock/build/RadioLib/libRadioLib.a -LIBS_cortex-m7 += ../RadioLib/examples/NonArduino/Tock/build/RadioLib/libRadioLib.a +LIBS_cortex-m += ../RadioLib/examples/NonArduino/Tock/build-arm/RadioLib/libRadioLib.a +LIBS_cortex-m0 += ../RadioLib/examples/NonArduino/Tock/build-arm/RadioLib/libRadioLib.a +LIBS_cortex-m3 += ../RadioLib/examples/NonArduino/Tock/build-arm/RadioLib/libRadioLib.a +LIBS_cortex-m4 += ../RadioLib/examples/NonArduino/Tock/build-arm/RadioLib/libRadioLib.a +LIBS_cortex-m7 += ../RadioLib/examples/NonArduino/Tock/build-arm/RadioLib/libRadioLib.a + +LIBS_rv32i += ../RadioLib/examples/NonArduino/Tock/build-riscv/RadioLib/libRadioLib.a +LIBS_rv32imc += ../RadioLib/examples/NonArduino/Tock/build-riscv/RadioLib/libRadioLib.a +LIBS_rv32imac += ../RadioLib/examples/NonArduino/Tock/build-riscv/RadioLib/libRadioLib.a # Include userland master makefile. Contains rules and flags for actually # building the application. From 06e56cfe89cf4268024ad15388cd295fe6247a87 Mon Sep 17 00:00:00 2001 From: Pat Pannuto Date: Thu, 9 May 2024 21:24:40 -0700 Subject: [PATCH 02/12] lora: be more conservative in build script avoid a wildcard with `rm -rf` in a script, and set the script to error out if it's somehow not in the directory we expect before `rm`'ing --- wip/lora/build-RadioLib.sh | 10 +++++++--- wip/lora/sensor-receive/Makefile | 5 +---- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/wip/lora/build-RadioLib.sh b/wip/lora/build-RadioLib.sh index c7613cdea..19cb5ef56 100755 --- a/wip/lora/build-RadioLib.sh +++ b/wip/lora/build-RadioLib.sh @@ -1,8 +1,10 @@ #!/usr/bin/env bash +set -e + pushd RadioLib/examples/NonArduino/Tock/ -rm -rf build-* +rm -rf build-arm build-riscv # Change the source to point to the current libtock-c directory # Note, x-platform `sed -i` has odd, but particular syntax @@ -21,7 +23,8 @@ cmake -G "CodeBlocks - Unix Makefiles" .. # This will fail to link, as it can't find the libtock-c libraries # That's fine for us though, as we just need to build the RadioLib # library, not the entire example application -make -j4 2> /dev/null +make -j4 2> /dev/null || true +test -f RadioLib/libRadioLib.a || make cd ../ mkdir -p build-riscv @@ -33,7 +36,8 @@ cmake -G "CodeBlocks - Unix Makefiles" -DRISCV_BUILD=1 .. # This will fail to link, as it can't find the libtock-c libraries # That's fine for us though, as we just need to build the RadioLib # library, not the entire example application -make -j4 2> /dev/null +make -j4 2> /dev/null || true +test -f RadioLib/libRadioLib.a || make cd ../ popd diff --git a/wip/lora/sensor-receive/Makefile b/wip/lora/sensor-receive/Makefile index b3554b7b1..d3675cb17 100644 --- a/wip/lora/sensor-receive/Makefile +++ b/wip/lora/sensor-receive/Makefile @@ -29,8 +29,5 @@ LIBS_rv32imac += ../RadioLib/examples/NonArduino/Tock/build-riscv/RadioLib/libRa # building the application. include $(TOCK_USERLAND_BASE_DIR)/AppMakefile.mk -../RadioLib/examples/NonArduino/Tock/build-arm/RadioLib/libRadioLib.a: - cd ../ && ./build-RadioLib.sh - -../RadioLib/examples/NonArduino/Tock/build-riscv/RadioLib/libRadioLib.a: +../RadioLib/examples/NonArduino/Tock/build-arm/RadioLib/libRadioLib.a ../RadioLib/examples/NonArduino/Tock/build-riscv/RadioLib/libRadioLib.a: cd ../ && ./build-RadioLib.sh From 4f71dec491eafb15a67e3e583defd4d0828415b3 Mon Sep 17 00:00:00 2001 From: Alistair Francis Date: Thu, 16 May 2024 19:40:30 +1000 Subject: [PATCH 03/12] lora: Update to use the new libtock-c layout Signed-off-by: Alistair Francis --- wip/lora/RadioLib | 2 +- wip/lora/build-RadioLib.sh | 43 ------------------------------- wip/lora/sensor-receive/Makefile | 10 ++++++- wip/lora/sensor-transmit/Makefile | 12 +++++++-- wip/lora/sensor-transmit/main.cc | 12 ++++----- 5 files changed, 26 insertions(+), 53 deletions(-) delete mode 100755 wip/lora/build-RadioLib.sh diff --git a/wip/lora/RadioLib b/wip/lora/RadioLib index 7209690bf..47f5569e7 160000 --- a/wip/lora/RadioLib +++ b/wip/lora/RadioLib @@ -1 +1 @@ -Subproject commit 7209690bf6aa92fcc6a17e3d08ab486cdbf0ddaa +Subproject commit 47f5569e7f5ece58d6730165744ea73305e65c85 diff --git a/wip/lora/build-RadioLib.sh b/wip/lora/build-RadioLib.sh deleted file mode 100755 index 19cb5ef56..000000000 --- a/wip/lora/build-RadioLib.sh +++ /dev/null @@ -1,43 +0,0 @@ -#!/usr/bin/env bash - -set -e - -pushd RadioLib/examples/NonArduino/Tock/ - -rm -rf build-arm build-riscv - -# Change the source to point to the current libtock-c directory -# Note, x-platform `sed -i` has odd, but particular syntax -# https://stackoverflow.com/questions/5694228/sed-in-place-flag-that-works-both-on-mac-bsd-and-linux -sed -i._SED_HACK 's|${CMAKE_CURRENT_SOURCE_DIR}/libtock-c|../../../../../../../|g' CMakeLists.txt -sed -i._SED_HACK 's|target_include_directories(${PROJECT_NAME} PUBLIC|target_include_directories(\${PROJECT_NAME}\n PUBLIC ../../../../../../|g' CMakeLists.txt - -find . -name '*._SED_HACK' -delete - -mkdir -p build-arm -cd build-arm - -cmake -G "CodeBlocks - Unix Makefiles" .. - -# Build the Tock example application -# This will fail to link, as it can't find the libtock-c libraries -# That's fine for us though, as we just need to build the RadioLib -# library, not the entire example application -make -j4 2> /dev/null || true -test -f RadioLib/libRadioLib.a || make -cd ../ - -mkdir -p build-riscv -cd build-riscv - -cmake -G "CodeBlocks - Unix Makefiles" -DRISCV_BUILD=1 .. - -# Build the Tock example application -# This will fail to link, as it can't find the libtock-c libraries -# That's fine for us though, as we just need to build the RadioLib -# library, not the entire example application -make -j4 2> /dev/null || true -test -f RadioLib/libRadioLib.a || make -cd ../ - -popd diff --git a/wip/lora/sensor-receive/Makefile b/wip/lora/sensor-receive/Makefile index d3675cb17..a102cf8ee 100644 --- a/wip/lora/sensor-receive/Makefile +++ b/wip/lora/sensor-receive/Makefile @@ -30,4 +30,12 @@ LIBS_rv32imac += ../RadioLib/examples/NonArduino/Tock/build-riscv/RadioLib/libRa include $(TOCK_USERLAND_BASE_DIR)/AppMakefile.mk ../RadioLib/examples/NonArduino/Tock/build-arm/RadioLib/libRadioLib.a ../RadioLib/examples/NonArduino/Tock/build-riscv/RadioLib/libRadioLib.a: - cd ../ && ./build-RadioLib.sh + cd ../RadioLib/examples/NonArduino/Tock/ && \ + rm -rf build-arm build-riscv && \ + mkdir -p build-arm && cd build-arm && \ + LIBTOCK_C_DIRECTORY="$(TOCK_USERLAND_BASE_DIR)/../../../../" cmake -G "CodeBlocks - Unix Makefiles" .. && \ + $(MAKE) -j4 2> /dev/null || \ + cd ../ && \ + mkdir -p build-riscv && cd build-riscv && \ + LIBTOCK_C_DIRECTORY="$(TOCK_USERLAND_BASE_DIR)/../../../../" cmake -G "CodeBlocks - Unix Makefiles" -DRISCV_BUILD=1 .. && \ + $(MAKE) -j4 2> /dev/null || true diff --git a/wip/lora/sensor-transmit/Makefile b/wip/lora/sensor-transmit/Makefile index e9b947278..a102cf8ee 100644 --- a/wip/lora/sensor-transmit/Makefile +++ b/wip/lora/sensor-transmit/Makefile @@ -29,5 +29,13 @@ LIBS_rv32imac += ../RadioLib/examples/NonArduino/Tock/build-riscv/RadioLib/libRa # building the application. include $(TOCK_USERLAND_BASE_DIR)/AppMakefile.mk -../RadioLib/examples/NonArduino/Tock/build/RadioLib/libRadioLib.a: - cd ../ && ./build-RadioLib.sh +../RadioLib/examples/NonArduino/Tock/build-arm/RadioLib/libRadioLib.a ../RadioLib/examples/NonArduino/Tock/build-riscv/RadioLib/libRadioLib.a: + cd ../RadioLib/examples/NonArduino/Tock/ && \ + rm -rf build-arm build-riscv && \ + mkdir -p build-arm && cd build-arm && \ + LIBTOCK_C_DIRECTORY="$(TOCK_USERLAND_BASE_DIR)/../../../../" cmake -G "CodeBlocks - Unix Makefiles" .. && \ + $(MAKE) -j4 2> /dev/null || \ + cd ../ && \ + mkdir -p build-riscv && cd build-riscv && \ + LIBTOCK_C_DIRECTORY="$(TOCK_USERLAND_BASE_DIR)/../../../../" cmake -G "CodeBlocks - Unix Makefiles" -DRISCV_BUILD=1 .. && \ + $(MAKE) -j4 2> /dev/null || true diff --git a/wip/lora/sensor-transmit/main.cc b/wip/lora/sensor-transmit/main.cc index 1319099e7..a5312f242 100644 --- a/wip/lora/sensor-transmit/main.cc +++ b/wip/lora/sensor-transmit/main.cc @@ -13,8 +13,8 @@ #include "libtockHal.h" // Include some libtock-c helpers -#include -#include +#include +#include #define BUFFER_LEN 64 @@ -47,8 +47,8 @@ int main(void) { } printf("success!\r\n"); - int temp = 0; - unsigned humi = 0; + int temp = 0; + int humi = 0; // loop forever for ( ;;) { @@ -56,8 +56,8 @@ int main(void) { yield_no_wait(); // Read some sensor data from the board - temperature_read_sync(&temp); - humidity_read_sync(&humi); + libtocksync_temperature_read(&temp); + libtocksync_humidity_read(&humi); snprintf(buffer, BUFFER_LEN, "Temp: %d, Hum: %u", temp, humi); From 0d001a77e04e7de8c3e3df9b68ab10596d197dd0 Mon Sep 17 00:00:00 2001 From: Alistair Francis Date: Thu, 16 May 2024 19:43:18 +1000 Subject: [PATCH 04/12] lora: Move from wip to examples Signed-off-by: Alistair Francis --- .gitmodules | 2 +- {wip => examples}/lora/README.md | 0 {wip => examples}/lora/RadioLib | 0 {wip => examples}/lora/sensor-receive/Makefile | 15 +++++++++------ {wip => examples}/lora/sensor-receive/README.md | 0 {wip => examples}/lora/sensor-receive/main.cc | 0 {wip => examples}/lora/sensor-transmit/Makefile | 15 +++++++++------ {wip => examples}/lora/sensor-transmit/README.md | 0 {wip => examples}/lora/sensor-transmit/main.cc | 0 9 files changed, 19 insertions(+), 13 deletions(-) rename {wip => examples}/lora/README.md (100%) rename {wip => examples}/lora/RadioLib (100%) rename {wip => examples}/lora/sensor-receive/Makefile (78%) rename {wip => examples}/lora/sensor-receive/README.md (100%) rename {wip => examples}/lora/sensor-receive/main.cc (100%) rename {wip => examples}/lora/sensor-transmit/Makefile (78%) rename {wip => examples}/lora/sensor-transmit/README.md (100%) rename {wip => examples}/lora/sensor-transmit/main.cc (100%) diff --git a/.gitmodules b/.gitmodules index b185c0fc4..080e15161 100644 --- a/.gitmodules +++ b/.gitmodules @@ -5,7 +5,7 @@ path = lvgl/lvgl url = https://github.com/littlevgl/lvgl.git [submodule "examples/lora/RadioLib"] - path = wip/lora/RadioLib + path = examples/lora/RadioLib url = https://github.com/jgromes/RadioLib.git [submodule "libopenthread/openthread"] path = libopenthread/openthread diff --git a/wip/lora/README.md b/examples/lora/README.md similarity index 100% rename from wip/lora/README.md rename to examples/lora/README.md diff --git a/wip/lora/RadioLib b/examples/lora/RadioLib similarity index 100% rename from wip/lora/RadioLib rename to examples/lora/RadioLib diff --git a/wip/lora/sensor-receive/Makefile b/examples/lora/sensor-receive/Makefile similarity index 78% rename from wip/lora/sensor-receive/Makefile rename to examples/lora/sensor-receive/Makefile index a102cf8ee..9c2b4c573 100644 --- a/wip/lora/sensor-receive/Makefile +++ b/examples/lora/sensor-receive/Makefile @@ -29,13 +29,16 @@ LIBS_rv32imac += ../RadioLib/examples/NonArduino/Tock/build-riscv/RadioLib/libRa # building the application. include $(TOCK_USERLAND_BASE_DIR)/AppMakefile.mk -../RadioLib/examples/NonArduino/Tock/build-arm/RadioLib/libRadioLib.a ../RadioLib/examples/NonArduino/Tock/build-riscv/RadioLib/libRadioLib.a: +../RadioLib/examples/NonArduino/Tock/build-arm/RadioLib/libRadioLib.a: cd ../RadioLib/examples/NonArduino/Tock/ && \ - rm -rf build-arm build-riscv && \ + rm -rf build-arm && \ mkdir -p build-arm && cd build-arm && \ - LIBTOCK_C_DIRECTORY="$(TOCK_USERLAND_BASE_DIR)/../../../../" cmake -G "CodeBlocks - Unix Makefiles" .. && \ - $(MAKE) -j4 2> /dev/null || \ - cd ../ && \ + LIBTOCK_C_DIRECTORY="$(TOCK_USERLAND_BASE_DIR)/../../../" cmake -G "CodeBlocks - Unix Makefiles" .. && \ + $(MAKE) -j4 2> /dev/null || true + +../RadioLib/examples/NonArduino/Tock/build-riscv/RadioLib/libRadioLib.a: + cd ../RadioLib/examples/NonArduino/Tock/ && \ + rm -rf build-riscv && \ mkdir -p build-riscv && cd build-riscv && \ - LIBTOCK_C_DIRECTORY="$(TOCK_USERLAND_BASE_DIR)/../../../../" cmake -G "CodeBlocks - Unix Makefiles" -DRISCV_BUILD=1 .. && \ + LIBTOCK_C_DIRECTORY="$(TOCK_USERLAND_BASE_DIR)/../../../" cmake -G "CodeBlocks - Unix Makefiles" -DRISCV_BUILD=1 .. && \ $(MAKE) -j4 2> /dev/null || true diff --git a/wip/lora/sensor-receive/README.md b/examples/lora/sensor-receive/README.md similarity index 100% rename from wip/lora/sensor-receive/README.md rename to examples/lora/sensor-receive/README.md diff --git a/wip/lora/sensor-receive/main.cc b/examples/lora/sensor-receive/main.cc similarity index 100% rename from wip/lora/sensor-receive/main.cc rename to examples/lora/sensor-receive/main.cc diff --git a/wip/lora/sensor-transmit/Makefile b/examples/lora/sensor-transmit/Makefile similarity index 78% rename from wip/lora/sensor-transmit/Makefile rename to examples/lora/sensor-transmit/Makefile index a102cf8ee..9c2b4c573 100644 --- a/wip/lora/sensor-transmit/Makefile +++ b/examples/lora/sensor-transmit/Makefile @@ -29,13 +29,16 @@ LIBS_rv32imac += ../RadioLib/examples/NonArduino/Tock/build-riscv/RadioLib/libRa # building the application. include $(TOCK_USERLAND_BASE_DIR)/AppMakefile.mk -../RadioLib/examples/NonArduino/Tock/build-arm/RadioLib/libRadioLib.a ../RadioLib/examples/NonArduino/Tock/build-riscv/RadioLib/libRadioLib.a: +../RadioLib/examples/NonArduino/Tock/build-arm/RadioLib/libRadioLib.a: cd ../RadioLib/examples/NonArduino/Tock/ && \ - rm -rf build-arm build-riscv && \ + rm -rf build-arm && \ mkdir -p build-arm && cd build-arm && \ - LIBTOCK_C_DIRECTORY="$(TOCK_USERLAND_BASE_DIR)/../../../../" cmake -G "CodeBlocks - Unix Makefiles" .. && \ - $(MAKE) -j4 2> /dev/null || \ - cd ../ && \ + LIBTOCK_C_DIRECTORY="$(TOCK_USERLAND_BASE_DIR)/../../../" cmake -G "CodeBlocks - Unix Makefiles" .. && \ + $(MAKE) -j4 2> /dev/null || true + +../RadioLib/examples/NonArduino/Tock/build-riscv/RadioLib/libRadioLib.a: + cd ../RadioLib/examples/NonArduino/Tock/ && \ + rm -rf build-riscv && \ mkdir -p build-riscv && cd build-riscv && \ - LIBTOCK_C_DIRECTORY="$(TOCK_USERLAND_BASE_DIR)/../../../../" cmake -G "CodeBlocks - Unix Makefiles" -DRISCV_BUILD=1 .. && \ + LIBTOCK_C_DIRECTORY="$(TOCK_USERLAND_BASE_DIR)/../../../" cmake -G "CodeBlocks - Unix Makefiles" -DRISCV_BUILD=1 .. && \ $(MAKE) -j4 2> /dev/null || true diff --git a/wip/lora/sensor-transmit/README.md b/examples/lora/sensor-transmit/README.md similarity index 100% rename from wip/lora/sensor-transmit/README.md rename to examples/lora/sensor-transmit/README.md diff --git a/wip/lora/sensor-transmit/main.cc b/examples/lora/sensor-transmit/main.cc similarity index 100% rename from wip/lora/sensor-transmit/main.cc rename to examples/lora/sensor-transmit/main.cc From a49f39417f51fae1603fdd086390574d6160fffd Mon Sep 17 00:00:00 2001 From: Alistair Francis Date: Mon, 17 Jun 2024 19:25:20 +1000 Subject: [PATCH 05/12] examples: lora: Use TockLibrary.mk Signed-off-by: Alistair Francis --- examples/lora/README.md | 18 ++++++++++++++++++ examples/lora/sensor-receive/Makefile | 25 +++++++++++++++++++++++++ examples/lora/sensor-transmit/Makefile | 25 +++++++++++++++++++++++++ 3 files changed, 68 insertions(+) diff --git a/examples/lora/README.md b/examples/lora/README.md index f77d6f0c0..327181733 100644 --- a/examples/lora/README.md +++ b/examples/lora/README.md @@ -23,3 +23,21 @@ RadioLib. Note that the Makefiles will do this automatically when you run `make` in a subdirectory, but if you want to do it manually you can run the `build-RadioLib.sh` script. + +### Building + +To bulid any example just enter the directory and type + +```shell +make +``` + +This will build RadioLib and then the example application for +both ARM and RISC-V architectures. + +If you wish to use the RadioLib build infrastructure to build +RadioLib (instead of the libtock-c system) you can also use + +```shell +CMAKE=1 make +``` diff --git a/examples/lora/sensor-receive/Makefile b/examples/lora/sensor-receive/Makefile index 9c2b4c573..c858844bb 100644 --- a/examples/lora/sensor-receive/Makefile +++ b/examples/lora/sensor-receive/Makefile @@ -15,6 +15,8 @@ override CPPFLAGS += -isystem ../RadioLib/examples/NonArduino/Tock # Include the base of libtock-c to fix the libtock/ includes from RadioLib override CPPFLAGS += -I$(TOCK_USERLAND_BASE_DIR)/ +ifeq ($(CMAKE),1) +# Use the RadioLib cmake build infrastructure LIBS_cortex-m += ../RadioLib/examples/NonArduino/Tock/build-arm/RadioLib/libRadioLib.a LIBS_cortex-m0 += ../RadioLib/examples/NonArduino/Tock/build-arm/RadioLib/libRadioLib.a LIBS_cortex-m3 += ../RadioLib/examples/NonArduino/Tock/build-arm/RadioLib/libRadioLib.a @@ -42,3 +44,26 @@ include $(TOCK_USERLAND_BASE_DIR)/AppMakefile.mk mkdir -p build-riscv && cd build-riscv && \ LIBTOCK_C_DIRECTORY="$(TOCK_USERLAND_BASE_DIR)/../../../" cmake -G "CodeBlocks - Unix Makefiles" -DRISCV_BUILD=1 .. && \ $(MAKE) -j4 2> /dev/null || true +else +# Use the libtock-c Make system +LIBS_cortex-m0 += $(TOCK_USERLAND_BASE_DIR)/examples/lora/RadioLib/build/cortex-m0/RadioLib.a +LIBS_cortex-m3 += $(TOCK_USERLAND_BASE_DIR)/examples/lora/RadioLib/build/cortex-m3/RadioLib.a +LIBS_cortex-m4 += $(TOCK_USERLAND_BASE_DIR)/examples/lora/RadioLib/build/cortex-m4/RadioLib.a +LIBS_cortex-m7 += $(TOCK_USERLAND_BASE_DIR)/examples/lora/RadioLib/build/cortex-m7/RadioLib.a + +LIBS_rv32imc += $(TOCK_USERLAND_BASE_DIR)/examples/lora/RadioLib/build/rv32imc/RadioLib.a +LIBS_rv32imac += $(TOCK_USERLAND_BASE_DIR)/examples/lora/RadioLib/build/rv32imac/RadioLib.a + +include $(TOCK_USERLAND_BASE_DIR)/AppMakefile.mk + +LIBNAME := RadioLib + +$(LIBNAME)_DIR := $(TOCK_USERLAND_BASE_DIR)/examples/lora/$(LIBNAME) + +$(LIBNAME)_SRCS := \ + $(wildcard $($(LIBNAME)_DIR)/src/*.cpp) \ + $(wildcard $($(LIBNAME)_DIR)/src/*/*.cpp) \ + $(wildcard $($(LIBNAME)_DIR)/src/*/*/*.cpp) + +include $(TOCK_USERLAND_BASE_DIR)/TockLibrary.mk +endif diff --git a/examples/lora/sensor-transmit/Makefile b/examples/lora/sensor-transmit/Makefile index 9c2b4c573..c858844bb 100644 --- a/examples/lora/sensor-transmit/Makefile +++ b/examples/lora/sensor-transmit/Makefile @@ -15,6 +15,8 @@ override CPPFLAGS += -isystem ../RadioLib/examples/NonArduino/Tock # Include the base of libtock-c to fix the libtock/ includes from RadioLib override CPPFLAGS += -I$(TOCK_USERLAND_BASE_DIR)/ +ifeq ($(CMAKE),1) +# Use the RadioLib cmake build infrastructure LIBS_cortex-m += ../RadioLib/examples/NonArduino/Tock/build-arm/RadioLib/libRadioLib.a LIBS_cortex-m0 += ../RadioLib/examples/NonArduino/Tock/build-arm/RadioLib/libRadioLib.a LIBS_cortex-m3 += ../RadioLib/examples/NonArduino/Tock/build-arm/RadioLib/libRadioLib.a @@ -42,3 +44,26 @@ include $(TOCK_USERLAND_BASE_DIR)/AppMakefile.mk mkdir -p build-riscv && cd build-riscv && \ LIBTOCK_C_DIRECTORY="$(TOCK_USERLAND_BASE_DIR)/../../../" cmake -G "CodeBlocks - Unix Makefiles" -DRISCV_BUILD=1 .. && \ $(MAKE) -j4 2> /dev/null || true +else +# Use the libtock-c Make system +LIBS_cortex-m0 += $(TOCK_USERLAND_BASE_DIR)/examples/lora/RadioLib/build/cortex-m0/RadioLib.a +LIBS_cortex-m3 += $(TOCK_USERLAND_BASE_DIR)/examples/lora/RadioLib/build/cortex-m3/RadioLib.a +LIBS_cortex-m4 += $(TOCK_USERLAND_BASE_DIR)/examples/lora/RadioLib/build/cortex-m4/RadioLib.a +LIBS_cortex-m7 += $(TOCK_USERLAND_BASE_DIR)/examples/lora/RadioLib/build/cortex-m7/RadioLib.a + +LIBS_rv32imc += $(TOCK_USERLAND_BASE_DIR)/examples/lora/RadioLib/build/rv32imc/RadioLib.a +LIBS_rv32imac += $(TOCK_USERLAND_BASE_DIR)/examples/lora/RadioLib/build/rv32imac/RadioLib.a + +include $(TOCK_USERLAND_BASE_DIR)/AppMakefile.mk + +LIBNAME := RadioLib + +$(LIBNAME)_DIR := $(TOCK_USERLAND_BASE_DIR)/examples/lora/$(LIBNAME) + +$(LIBNAME)_SRCS := \ + $(wildcard $($(LIBNAME)_DIR)/src/*.cpp) \ + $(wildcard $($(LIBNAME)_DIR)/src/*/*.cpp) \ + $(wildcard $($(LIBNAME)_DIR)/src/*/*/*.cpp) + +include $(TOCK_USERLAND_BASE_DIR)/TockLibrary.mk +endif From 7c7eece29e54674f129c8eebd3915faaf673533a Mon Sep 17 00:00:00 2001 From: Alistair Francis Date: Tue, 18 Jun 2024 10:41:38 +1000 Subject: [PATCH 06/12] RadioLib: Move to top level Signed-off-by: Alistair Francis --- .gitmodules | 6 +-- examples/lora/RadioLib | 1 - examples/lora/sensor-receive/Makefile | 58 +++++++++++--------------- examples/lora/sensor-transmit/Makefile | 58 +++++++++++--------------- libradio/Makefile | 10 +++++ libradio/RadioLib | 1 + 6 files changed, 64 insertions(+), 70 deletions(-) delete mode 160000 examples/lora/RadioLib create mode 100644 libradio/Makefile create mode 160000 libradio/RadioLib diff --git a/.gitmodules b/.gitmodules index 080e15161..67c693075 100644 --- a/.gitmodules +++ b/.gitmodules @@ -4,9 +4,9 @@ [submodule "lvgl/lvgl"] path = lvgl/lvgl url = https://github.com/littlevgl/lvgl.git -[submodule "examples/lora/RadioLib"] - path = examples/lora/RadioLib - url = https://github.com/jgromes/RadioLib.git [submodule "libopenthread/openthread"] path = libopenthread/openthread url = https://github.com/openthread/openthread.git +[submodule "libradio/RadioLib"] + path = libradio/RadioLib + url = https://github.com/jgromes/RadioLib.git diff --git a/examples/lora/RadioLib b/examples/lora/RadioLib deleted file mode 160000 index 47f5569e7..000000000 --- a/examples/lora/RadioLib +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 47f5569e7f5ece58d6730165744ea73305e65c85 diff --git a/examples/lora/sensor-receive/Makefile b/examples/lora/sensor-receive/Makefile index c858844bb..395197b5c 100644 --- a/examples/lora/sensor-receive/Makefile +++ b/examples/lora/sensor-receive/Makefile @@ -7,63 +7,55 @@ TOCK_USERLAND_BASE_DIR = ../../../ CXX_SRCS := $(wildcard *.cc) # Include the core RadioLib headers -override CPPFLAGS += -isystem ../RadioLib/src +override CPPFLAGS += -isystem $(TOCK_USERLAND_BASE_DIR)/libradio/RadioLib/src # Include the Tock specific headers -override CPPFLAGS += -isystem ../RadioLib/examples/NonArduino/Tock +override CPPFLAGS += -isystem $(TOCK_USERLAND_BASE_DIR)/libradio/RadioLib/examples/NonArduino/Tock # Include the base of libtock-c to fix the libtock/ includes from RadioLib override CPPFLAGS += -I$(TOCK_USERLAND_BASE_DIR)/ ifeq ($(CMAKE),1) # Use the RadioLib cmake build infrastructure -LIBS_cortex-m += ../RadioLib/examples/NonArduino/Tock/build-arm/RadioLib/libRadioLib.a -LIBS_cortex-m0 += ../RadioLib/examples/NonArduino/Tock/build-arm/RadioLib/libRadioLib.a -LIBS_cortex-m3 += ../RadioLib/examples/NonArduino/Tock/build-arm/RadioLib/libRadioLib.a -LIBS_cortex-m4 += ../RadioLib/examples/NonArduino/Tock/build-arm/RadioLib/libRadioLib.a -LIBS_cortex-m7 += ../RadioLib/examples/NonArduino/Tock/build-arm/RadioLib/libRadioLib.a +LIBS_cortex-m += $(TOCK_USERLAND_BASE_DIR)/libradio/RadioLib/examples/NonArduino/Tock/build-arm/RadioLib/libRadioLib.a +LIBS_cortex-m0 += $(TOCK_USERLAND_BASE_DIR)/libradio/RadioLib/examples/NonArduino/Tock/build-arm/RadioLib/libRadioLib.a +LIBS_cortex-m3 += $(TOCK_USERLAND_BASE_DIR)/libradio/RadioLib/examples/NonArduino/Tock/build-arm/RadioLib/libRadioLib.a +LIBS_cortex-m4 += $(TOCK_USERLAND_BASE_DIR)/libradio/RadioLib/examples/NonArduino/Tock/build-arm/RadioLib/libRadioLib.a +LIBS_cortex-m7 += $(TOCK_USERLAND_BASE_DIR)/libradio/RadioLib/examples/NonArduino/Tock/build-arm/RadioLib/libRadioLib.a -LIBS_rv32i += ../RadioLib/examples/NonArduino/Tock/build-riscv/RadioLib/libRadioLib.a -LIBS_rv32imc += ../RadioLib/examples/NonArduino/Tock/build-riscv/RadioLib/libRadioLib.a -LIBS_rv32imac += ../RadioLib/examples/NonArduino/Tock/build-riscv/RadioLib/libRadioLib.a +LIBS_rv32i += $(TOCK_USERLAND_BASE_DIR)/libradio/RadioLib/examples/NonArduino/Tock/build-riscv/RadioLib/libRadioLib.a +LIBS_rv32imc += $(TOCK_USERLAND_BASE_DIR)/libradio/RadioLib/examples/NonArduino/Tock/build-riscv/RadioLib/libRadioLib.a +LIBS_rv32imac += $(TOCK_USERLAND_BASE_DIR)/libradio/RadioLib/examples/NonArduino/Tock/build-riscv/RadioLib/libRadioLib.a # Include userland master makefile. Contains rules and flags for actually # building the application. include $(TOCK_USERLAND_BASE_DIR)/AppMakefile.mk -../RadioLib/examples/NonArduino/Tock/build-arm/RadioLib/libRadioLib.a: - cd ../RadioLib/examples/NonArduino/Tock/ && \ +$(TOCK_USERLAND_BASE_DIR)/libradio/RadioLib/examples/NonArduino/Tock/build-arm/RadioLib/libRadioLib.a: + cd $(TOCK_USERLAND_BASE_DIR)/libradio/RadioLib/examples/NonArduino/Tock/ && \ rm -rf build-arm && \ mkdir -p build-arm && cd build-arm && \ - LIBTOCK_C_DIRECTORY="$(TOCK_USERLAND_BASE_DIR)/../../../" cmake -G "CodeBlocks - Unix Makefiles" .. && \ + LIBTOCK_C_DIRECTORY="$(TOCK_USERLAND_BASE_DIR)" cmake -G "CodeBlocks - Unix Makefiles" .. && \ $(MAKE) -j4 2> /dev/null || true -../RadioLib/examples/NonArduino/Tock/build-riscv/RadioLib/libRadioLib.a: - cd ../RadioLib/examples/NonArduino/Tock/ && \ +$(TOCK_USERLAND_BASE_DIR)/libradio/RadioLib/examples/NonArduino/Tock/build-riscv/RadioLib/libRadioLib.a: + cd $(TOCK_USERLAND_BASE_DIR)/libradio/RadioLib/examples/NonArduino/Tock/ && \ rm -rf build-riscv && \ mkdir -p build-riscv && cd build-riscv && \ - LIBTOCK_C_DIRECTORY="$(TOCK_USERLAND_BASE_DIR)/../../../" cmake -G "CodeBlocks - Unix Makefiles" -DRISCV_BUILD=1 .. && \ + LIBTOCK_C_DIRECTORY="$(TOCK_USERLAND_BASE_DIR)" cmake -G "CodeBlocks - Unix Makefiles" -DRISCV_BUILD=1 .. && \ $(MAKE) -j4 2> /dev/null || true else # Use the libtock-c Make system -LIBS_cortex-m0 += $(TOCK_USERLAND_BASE_DIR)/examples/lora/RadioLib/build/cortex-m0/RadioLib.a -LIBS_cortex-m3 += $(TOCK_USERLAND_BASE_DIR)/examples/lora/RadioLib/build/cortex-m3/RadioLib.a -LIBS_cortex-m4 += $(TOCK_USERLAND_BASE_DIR)/examples/lora/RadioLib/build/cortex-m4/RadioLib.a -LIBS_cortex-m7 += $(TOCK_USERLAND_BASE_DIR)/examples/lora/RadioLib/build/cortex-m7/RadioLib.a +LIBS_cortex-m0 += $(TOCK_USERLAND_BASE_DIR)/libradio/RadioLib/build/cortex-m0/RadioLib.a +LIBS_cortex-m3 += $(TOCK_USERLAND_BASE_DIR)/libradio/RadioLib/build/cortex-m3/RadioLib.a +LIBS_cortex-m4 += $(TOCK_USERLAND_BASE_DIR)/libradio/RadioLib/build/cortex-m4/RadioLib.a +LIBS_cortex-m7 += $(TOCK_USERLAND_BASE_DIR)/libradio/RadioLib/build/cortex-m7/RadioLib.a -LIBS_rv32imc += $(TOCK_USERLAND_BASE_DIR)/examples/lora/RadioLib/build/rv32imc/RadioLib.a -LIBS_rv32imac += $(TOCK_USERLAND_BASE_DIR)/examples/lora/RadioLib/build/rv32imac/RadioLib.a +LIBS_rv32imc += $(TOCK_USERLAND_BASE_DIR)/libradio/RadioLib/build/rv32imc/RadioLib.a +LIBS_rv32imac += $(TOCK_USERLAND_BASE_DIR)/libradio/RadioLib/build/rv32imac/RadioLib.a -include $(TOCK_USERLAND_BASE_DIR)/AppMakefile.mk - -LIBNAME := RadioLib - -$(LIBNAME)_DIR := $(TOCK_USERLAND_BASE_DIR)/examples/lora/$(LIBNAME) +EXTERN_LIBS := $(TOCK_USERLAND_BASE_DIR)/libradio/RadioLib +include $(TOCK_USERLAND_BASE_DIR)/libradio/Makefile -$(LIBNAME)_SRCS := \ - $(wildcard $($(LIBNAME)_DIR)/src/*.cpp) \ - $(wildcard $($(LIBNAME)_DIR)/src/*/*.cpp) \ - $(wildcard $($(LIBNAME)_DIR)/src/*/*/*.cpp) - -include $(TOCK_USERLAND_BASE_DIR)/TockLibrary.mk +include $(TOCK_USERLAND_BASE_DIR)/AppMakefile.mk endif diff --git a/examples/lora/sensor-transmit/Makefile b/examples/lora/sensor-transmit/Makefile index c858844bb..395197b5c 100644 --- a/examples/lora/sensor-transmit/Makefile +++ b/examples/lora/sensor-transmit/Makefile @@ -7,63 +7,55 @@ TOCK_USERLAND_BASE_DIR = ../../../ CXX_SRCS := $(wildcard *.cc) # Include the core RadioLib headers -override CPPFLAGS += -isystem ../RadioLib/src +override CPPFLAGS += -isystem $(TOCK_USERLAND_BASE_DIR)/libradio/RadioLib/src # Include the Tock specific headers -override CPPFLAGS += -isystem ../RadioLib/examples/NonArduino/Tock +override CPPFLAGS += -isystem $(TOCK_USERLAND_BASE_DIR)/libradio/RadioLib/examples/NonArduino/Tock # Include the base of libtock-c to fix the libtock/ includes from RadioLib override CPPFLAGS += -I$(TOCK_USERLAND_BASE_DIR)/ ifeq ($(CMAKE),1) # Use the RadioLib cmake build infrastructure -LIBS_cortex-m += ../RadioLib/examples/NonArduino/Tock/build-arm/RadioLib/libRadioLib.a -LIBS_cortex-m0 += ../RadioLib/examples/NonArduino/Tock/build-arm/RadioLib/libRadioLib.a -LIBS_cortex-m3 += ../RadioLib/examples/NonArduino/Tock/build-arm/RadioLib/libRadioLib.a -LIBS_cortex-m4 += ../RadioLib/examples/NonArduino/Tock/build-arm/RadioLib/libRadioLib.a -LIBS_cortex-m7 += ../RadioLib/examples/NonArduino/Tock/build-arm/RadioLib/libRadioLib.a +LIBS_cortex-m += $(TOCK_USERLAND_BASE_DIR)/libradio/RadioLib/examples/NonArduino/Tock/build-arm/RadioLib/libRadioLib.a +LIBS_cortex-m0 += $(TOCK_USERLAND_BASE_DIR)/libradio/RadioLib/examples/NonArduino/Tock/build-arm/RadioLib/libRadioLib.a +LIBS_cortex-m3 += $(TOCK_USERLAND_BASE_DIR)/libradio/RadioLib/examples/NonArduino/Tock/build-arm/RadioLib/libRadioLib.a +LIBS_cortex-m4 += $(TOCK_USERLAND_BASE_DIR)/libradio/RadioLib/examples/NonArduino/Tock/build-arm/RadioLib/libRadioLib.a +LIBS_cortex-m7 += $(TOCK_USERLAND_BASE_DIR)/libradio/RadioLib/examples/NonArduino/Tock/build-arm/RadioLib/libRadioLib.a -LIBS_rv32i += ../RadioLib/examples/NonArduino/Tock/build-riscv/RadioLib/libRadioLib.a -LIBS_rv32imc += ../RadioLib/examples/NonArduino/Tock/build-riscv/RadioLib/libRadioLib.a -LIBS_rv32imac += ../RadioLib/examples/NonArduino/Tock/build-riscv/RadioLib/libRadioLib.a +LIBS_rv32i += $(TOCK_USERLAND_BASE_DIR)/libradio/RadioLib/examples/NonArduino/Tock/build-riscv/RadioLib/libRadioLib.a +LIBS_rv32imc += $(TOCK_USERLAND_BASE_DIR)/libradio/RadioLib/examples/NonArduino/Tock/build-riscv/RadioLib/libRadioLib.a +LIBS_rv32imac += $(TOCK_USERLAND_BASE_DIR)/libradio/RadioLib/examples/NonArduino/Tock/build-riscv/RadioLib/libRadioLib.a # Include userland master makefile. Contains rules and flags for actually # building the application. include $(TOCK_USERLAND_BASE_DIR)/AppMakefile.mk -../RadioLib/examples/NonArduino/Tock/build-arm/RadioLib/libRadioLib.a: - cd ../RadioLib/examples/NonArduino/Tock/ && \ +$(TOCK_USERLAND_BASE_DIR)/libradio/RadioLib/examples/NonArduino/Tock/build-arm/RadioLib/libRadioLib.a: + cd $(TOCK_USERLAND_BASE_DIR)/libradio/RadioLib/examples/NonArduino/Tock/ && \ rm -rf build-arm && \ mkdir -p build-arm && cd build-arm && \ - LIBTOCK_C_DIRECTORY="$(TOCK_USERLAND_BASE_DIR)/../../../" cmake -G "CodeBlocks - Unix Makefiles" .. && \ + LIBTOCK_C_DIRECTORY="$(TOCK_USERLAND_BASE_DIR)" cmake -G "CodeBlocks - Unix Makefiles" .. && \ $(MAKE) -j4 2> /dev/null || true -../RadioLib/examples/NonArduino/Tock/build-riscv/RadioLib/libRadioLib.a: - cd ../RadioLib/examples/NonArduino/Tock/ && \ +$(TOCK_USERLAND_BASE_DIR)/libradio/RadioLib/examples/NonArduino/Tock/build-riscv/RadioLib/libRadioLib.a: + cd $(TOCK_USERLAND_BASE_DIR)/libradio/RadioLib/examples/NonArduino/Tock/ && \ rm -rf build-riscv && \ mkdir -p build-riscv && cd build-riscv && \ - LIBTOCK_C_DIRECTORY="$(TOCK_USERLAND_BASE_DIR)/../../../" cmake -G "CodeBlocks - Unix Makefiles" -DRISCV_BUILD=1 .. && \ + LIBTOCK_C_DIRECTORY="$(TOCK_USERLAND_BASE_DIR)" cmake -G "CodeBlocks - Unix Makefiles" -DRISCV_BUILD=1 .. && \ $(MAKE) -j4 2> /dev/null || true else # Use the libtock-c Make system -LIBS_cortex-m0 += $(TOCK_USERLAND_BASE_DIR)/examples/lora/RadioLib/build/cortex-m0/RadioLib.a -LIBS_cortex-m3 += $(TOCK_USERLAND_BASE_DIR)/examples/lora/RadioLib/build/cortex-m3/RadioLib.a -LIBS_cortex-m4 += $(TOCK_USERLAND_BASE_DIR)/examples/lora/RadioLib/build/cortex-m4/RadioLib.a -LIBS_cortex-m7 += $(TOCK_USERLAND_BASE_DIR)/examples/lora/RadioLib/build/cortex-m7/RadioLib.a +LIBS_cortex-m0 += $(TOCK_USERLAND_BASE_DIR)/libradio/RadioLib/build/cortex-m0/RadioLib.a +LIBS_cortex-m3 += $(TOCK_USERLAND_BASE_DIR)/libradio/RadioLib/build/cortex-m3/RadioLib.a +LIBS_cortex-m4 += $(TOCK_USERLAND_BASE_DIR)/libradio/RadioLib/build/cortex-m4/RadioLib.a +LIBS_cortex-m7 += $(TOCK_USERLAND_BASE_DIR)/libradio/RadioLib/build/cortex-m7/RadioLib.a -LIBS_rv32imc += $(TOCK_USERLAND_BASE_DIR)/examples/lora/RadioLib/build/rv32imc/RadioLib.a -LIBS_rv32imac += $(TOCK_USERLAND_BASE_DIR)/examples/lora/RadioLib/build/rv32imac/RadioLib.a +LIBS_rv32imc += $(TOCK_USERLAND_BASE_DIR)/libradio/RadioLib/build/rv32imc/RadioLib.a +LIBS_rv32imac += $(TOCK_USERLAND_BASE_DIR)/libradio/RadioLib/build/rv32imac/RadioLib.a -include $(TOCK_USERLAND_BASE_DIR)/AppMakefile.mk - -LIBNAME := RadioLib - -$(LIBNAME)_DIR := $(TOCK_USERLAND_BASE_DIR)/examples/lora/$(LIBNAME) +EXTERN_LIBS := $(TOCK_USERLAND_BASE_DIR)/libradio/RadioLib +include $(TOCK_USERLAND_BASE_DIR)/libradio/Makefile -$(LIBNAME)_SRCS := \ - $(wildcard $($(LIBNAME)_DIR)/src/*.cpp) \ - $(wildcard $($(LIBNAME)_DIR)/src/*/*.cpp) \ - $(wildcard $($(LIBNAME)_DIR)/src/*/*/*.cpp) - -include $(TOCK_USERLAND_BASE_DIR)/TockLibrary.mk +include $(TOCK_USERLAND_BASE_DIR)/AppMakefile.mk endif diff --git a/libradio/Makefile b/libradio/Makefile new file mode 100644 index 000000000..7bafe372c --- /dev/null +++ b/libradio/Makefile @@ -0,0 +1,10 @@ +LIBNAME := RadioLib + +$(LIBNAME)_DIR := $(TOCK_USERLAND_BASE_DIR)/libradio/$(LIBNAME) + +$(LIBNAME)_SRCS := \ + $(wildcard $($(LIBNAME)_DIR)/src/*.cpp) \ + $(wildcard $($(LIBNAME)_DIR)/src/*/*.cpp) \ + $(wildcard $($(LIBNAME)_DIR)/src/*/*/*.cpp) + +include $(TOCK_USERLAND_BASE_DIR)/TockLibrary.mk diff --git a/libradio/RadioLib b/libradio/RadioLib new file mode 160000 index 000000000..954477b0c --- /dev/null +++ b/libradio/RadioLib @@ -0,0 +1 @@ +Subproject commit 954477b0c0589e6373692ce569ca117191667c30 From add52ff68f85da6b943173ddf83af00a911968c1 Mon Sep 17 00:00:00 2001 From: Alistair Francis Date: Tue, 18 Jun 2024 11:12:08 +1000 Subject: [PATCH 07/12] RadioLib: Work around GCC bug Signed-off-by: Alistair Francis --- libradio/Makefile | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/libradio/Makefile b/libradio/Makefile index 7bafe372c..961b5b30a 100644 --- a/libradio/Makefile +++ b/libradio/Makefile @@ -1,10 +1,39 @@ LIBNAME := RadioLib +TOCK_USERLAND_BASE_DIR ?= ../ + $(LIBNAME)_DIR := $(TOCK_USERLAND_BASE_DIR)/libradio/$(LIBNAME) +# We ideally want this: +# $(LIBNAME)_SRCS := \ +# $($(LIBNAME)_DIR)/src/Module.cpp \ +# $(wildcard $($(LIBNAME)_DIR)/src/*.cpp) \ +# $(wildcard $($(LIBNAME)_DIR)/src/*/*.cpp) \ +# $(wildcard $($(LIBNAME)_DIR)/src/*/*/*.cpp) +# +# But due to this in the GCC arm binary in the CI: +# +# ``` +# (insn 179 178 46 8 (set (reg:SI 3 r3 [168]) +# (mem/u/c:SI (plus:SI (reg:SI 12 ip [169]) +# (unspec:SI [ +# (symbol_ref/u:SI ("*.LC1") [flags 0x2]) +# ] UNSPEC_PIC_SYM)) [0 S4 A32])) "../../../RadioLib/src/modules/LR11x0/LR11x0.cpp":638:16 929 {*thumb1_movsi_insn} +# (expr_list:REG_EQUAL (symbol_ref/u:SI ("*.LC1") [flags 0x2]) +# (nil))) +# during RTL pass: postreload +# ../../../RadioLib/src/modules/LR11x0/LR11x0.cpp:650:1: internal compiler error: in extract_constrain_insn, at recog.c:2195 +# ``` +# +# we need to drop LR11x0 $(LIBNAME)_SRCS := \ $(wildcard $($(LIBNAME)_DIR)/src/*.cpp) \ - $(wildcard $($(LIBNAME)_DIR)/src/*/*.cpp) \ - $(wildcard $($(LIBNAME)_DIR)/src/*/*/*.cpp) + $(wildcard $($(LIBNAME)_DIR)/src/utils/*.cpp) \ + $(wildcard $($(LIBNAME)_DIR)/src/modules/C*/.cpp) \ + $(wildcard $($(LIBNAME)_DIR)/src/modules/LL*/*.cpp) \ + $(wildcard $($(LIBNAME)_DIR)/src/modules/RF*/*.cpp) \ + $(wildcard $($(LIBNAME)_DIR)/src/modules/S*/*.cpp) \ + $(wildcard $($(LIBNAME)_DIR)/src/modules/n*/*.cpp) \ + $(wildcard $($(LIBNAME)_DIR)/src/protocols/*/*.cpp) \ include $(TOCK_USERLAND_BASE_DIR)/TockLibrary.mk From 352656982dec386424602f152029edcd6223ef24 Mon Sep 17 00:00:00 2001 From: Alistair Francis Date: Tue, 18 Jun 2024 11:20:01 +1000 Subject: [PATCH 08/12] TockLibrary.mk: Fixup formatting failures for RadioLib Signed-off-by: Alistair Francis --- TockLibrary.mk | 4 ---- 1 file changed, 4 deletions(-) diff --git a/TockLibrary.mk b/TockLibrary.mk index 7c04e3191..79af90804 100644 --- a/TockLibrary.mk +++ b/TockLibrary.mk @@ -29,10 +29,6 @@ $(call check_defined, LIBNAME) $(call check_defined, $(LIBNAME)_DIR) $(call check_defined, $(LIBNAME)_SRCS) -ifeq ($(strip $($(LIBNAME)_SRCS)),) - $(error Library "$(LIBNAME)" has no SRCS?) -endif - # directory for built output $(LIBNAME)_BUILDDIR := $($(LIBNAME)_DIR)/build From 06c64b0181e56bbe93d4e554fc87939e03d226ef Mon Sep 17 00:00:00 2001 From: Alistair Francis Date: Tue, 30 Jul 2024 19:29:07 +1000 Subject: [PATCH 09/12] examples: lora: Remove cmake build option Signed-off-by: Alistair Francis --- examples/lora/README.md | 7 ---- examples/lora/sensor-receive/Makefile | 53 ++------------------------ examples/lora/sensor-transmit/Makefile | 53 ++------------------------ libradio/Makefile | 2 +- libradio/Makefile.app | 5 +++ 5 files changed, 12 insertions(+), 108 deletions(-) create mode 100644 libradio/Makefile.app diff --git a/examples/lora/README.md b/examples/lora/README.md index 327181733..e3f0e9d4c 100644 --- a/examples/lora/README.md +++ b/examples/lora/README.md @@ -34,10 +34,3 @@ make This will build RadioLib and then the example application for both ARM and RISC-V architectures. - -If you wish to use the RadioLib build infrastructure to build -RadioLib (instead of the libtock-c system) you can also use - -```shell -CMAKE=1 make -``` diff --git a/examples/lora/sensor-receive/Makefile b/examples/lora/sensor-receive/Makefile index 395197b5c..99027b730 100644 --- a/examples/lora/sensor-receive/Makefile +++ b/examples/lora/sensor-receive/Makefile @@ -1,61 +1,14 @@ # Makefile for user application # Specify this directory relative to the current application. -TOCK_USERLAND_BASE_DIR = ../../../ +TOCK_USERLAND_BASE_DIR = ../../.. # Which files to compile. CXX_SRCS := $(wildcard *.cc) -# Include the core RadioLib headers -override CPPFLAGS += -isystem $(TOCK_USERLAND_BASE_DIR)/libradio/RadioLib/src - -# Include the Tock specific headers -override CPPFLAGS += -isystem $(TOCK_USERLAND_BASE_DIR)/libradio/RadioLib/examples/NonArduino/Tock - -# Include the base of libtock-c to fix the libtock/ includes from RadioLib -override CPPFLAGS += -I$(TOCK_USERLAND_BASE_DIR)/ - -ifeq ($(CMAKE),1) -# Use the RadioLib cmake build infrastructure -LIBS_cortex-m += $(TOCK_USERLAND_BASE_DIR)/libradio/RadioLib/examples/NonArduino/Tock/build-arm/RadioLib/libRadioLib.a -LIBS_cortex-m0 += $(TOCK_USERLAND_BASE_DIR)/libradio/RadioLib/examples/NonArduino/Tock/build-arm/RadioLib/libRadioLib.a -LIBS_cortex-m3 += $(TOCK_USERLAND_BASE_DIR)/libradio/RadioLib/examples/NonArduino/Tock/build-arm/RadioLib/libRadioLib.a -LIBS_cortex-m4 += $(TOCK_USERLAND_BASE_DIR)/libradio/RadioLib/examples/NonArduino/Tock/build-arm/RadioLib/libRadioLib.a -LIBS_cortex-m7 += $(TOCK_USERLAND_BASE_DIR)/libradio/RadioLib/examples/NonArduino/Tock/build-arm/RadioLib/libRadioLib.a - -LIBS_rv32i += $(TOCK_USERLAND_BASE_DIR)/libradio/RadioLib/examples/NonArduino/Tock/build-riscv/RadioLib/libRadioLib.a -LIBS_rv32imc += $(TOCK_USERLAND_BASE_DIR)/libradio/RadioLib/examples/NonArduino/Tock/build-riscv/RadioLib/libRadioLib.a -LIBS_rv32imac += $(TOCK_USERLAND_BASE_DIR)/libradio/RadioLib/examples/NonArduino/Tock/build-riscv/RadioLib/libRadioLib.a - -# Include userland master makefile. Contains rules and flags for actually -# building the application. -include $(TOCK_USERLAND_BASE_DIR)/AppMakefile.mk - -$(TOCK_USERLAND_BASE_DIR)/libradio/RadioLib/examples/NonArduino/Tock/build-arm/RadioLib/libRadioLib.a: - cd $(TOCK_USERLAND_BASE_DIR)/libradio/RadioLib/examples/NonArduino/Tock/ && \ - rm -rf build-arm && \ - mkdir -p build-arm && cd build-arm && \ - LIBTOCK_C_DIRECTORY="$(TOCK_USERLAND_BASE_DIR)" cmake -G "CodeBlocks - Unix Makefiles" .. && \ - $(MAKE) -j4 2> /dev/null || true - -$(TOCK_USERLAND_BASE_DIR)/libradio/RadioLib/examples/NonArduino/Tock/build-riscv/RadioLib/libRadioLib.a: - cd $(TOCK_USERLAND_BASE_DIR)/libradio/RadioLib/examples/NonArduino/Tock/ && \ - rm -rf build-riscv && \ - mkdir -p build-riscv && cd build-riscv && \ - LIBTOCK_C_DIRECTORY="$(TOCK_USERLAND_BASE_DIR)" cmake -G "CodeBlocks - Unix Makefiles" -DRISCV_BUILD=1 .. && \ - $(MAKE) -j4 2> /dev/null || true -else # Use the libtock-c Make system -LIBS_cortex-m0 += $(TOCK_USERLAND_BASE_DIR)/libradio/RadioLib/build/cortex-m0/RadioLib.a -LIBS_cortex-m3 += $(TOCK_USERLAND_BASE_DIR)/libradio/RadioLib/build/cortex-m3/RadioLib.a -LIBS_cortex-m4 += $(TOCK_USERLAND_BASE_DIR)/libradio/RadioLib/build/cortex-m4/RadioLib.a -LIBS_cortex-m7 += $(TOCK_USERLAND_BASE_DIR)/libradio/RadioLib/build/cortex-m7/RadioLib.a - -LIBS_rv32imc += $(TOCK_USERLAND_BASE_DIR)/libradio/RadioLib/build/rv32imc/RadioLib.a -LIBS_rv32imac += $(TOCK_USERLAND_BASE_DIR)/libradio/RadioLib/build/rv32imac/RadioLib.a - -EXTERN_LIBS := $(TOCK_USERLAND_BASE_DIR)/libradio/RadioLib include $(TOCK_USERLAND_BASE_DIR)/libradio/Makefile +include $(TOCK_USERLAND_BASE_DIR)/libradio/Makefile.app + include $(TOCK_USERLAND_BASE_DIR)/AppMakefile.mk -endif diff --git a/examples/lora/sensor-transmit/Makefile b/examples/lora/sensor-transmit/Makefile index 395197b5c..99027b730 100644 --- a/examples/lora/sensor-transmit/Makefile +++ b/examples/lora/sensor-transmit/Makefile @@ -1,61 +1,14 @@ # Makefile for user application # Specify this directory relative to the current application. -TOCK_USERLAND_BASE_DIR = ../../../ +TOCK_USERLAND_BASE_DIR = ../../.. # Which files to compile. CXX_SRCS := $(wildcard *.cc) -# Include the core RadioLib headers -override CPPFLAGS += -isystem $(TOCK_USERLAND_BASE_DIR)/libradio/RadioLib/src - -# Include the Tock specific headers -override CPPFLAGS += -isystem $(TOCK_USERLAND_BASE_DIR)/libradio/RadioLib/examples/NonArduino/Tock - -# Include the base of libtock-c to fix the libtock/ includes from RadioLib -override CPPFLAGS += -I$(TOCK_USERLAND_BASE_DIR)/ - -ifeq ($(CMAKE),1) -# Use the RadioLib cmake build infrastructure -LIBS_cortex-m += $(TOCK_USERLAND_BASE_DIR)/libradio/RadioLib/examples/NonArduino/Tock/build-arm/RadioLib/libRadioLib.a -LIBS_cortex-m0 += $(TOCK_USERLAND_BASE_DIR)/libradio/RadioLib/examples/NonArduino/Tock/build-arm/RadioLib/libRadioLib.a -LIBS_cortex-m3 += $(TOCK_USERLAND_BASE_DIR)/libradio/RadioLib/examples/NonArduino/Tock/build-arm/RadioLib/libRadioLib.a -LIBS_cortex-m4 += $(TOCK_USERLAND_BASE_DIR)/libradio/RadioLib/examples/NonArduino/Tock/build-arm/RadioLib/libRadioLib.a -LIBS_cortex-m7 += $(TOCK_USERLAND_BASE_DIR)/libradio/RadioLib/examples/NonArduino/Tock/build-arm/RadioLib/libRadioLib.a - -LIBS_rv32i += $(TOCK_USERLAND_BASE_DIR)/libradio/RadioLib/examples/NonArduino/Tock/build-riscv/RadioLib/libRadioLib.a -LIBS_rv32imc += $(TOCK_USERLAND_BASE_DIR)/libradio/RadioLib/examples/NonArduino/Tock/build-riscv/RadioLib/libRadioLib.a -LIBS_rv32imac += $(TOCK_USERLAND_BASE_DIR)/libradio/RadioLib/examples/NonArduino/Tock/build-riscv/RadioLib/libRadioLib.a - -# Include userland master makefile. Contains rules and flags for actually -# building the application. -include $(TOCK_USERLAND_BASE_DIR)/AppMakefile.mk - -$(TOCK_USERLAND_BASE_DIR)/libradio/RadioLib/examples/NonArduino/Tock/build-arm/RadioLib/libRadioLib.a: - cd $(TOCK_USERLAND_BASE_DIR)/libradio/RadioLib/examples/NonArduino/Tock/ && \ - rm -rf build-arm && \ - mkdir -p build-arm && cd build-arm && \ - LIBTOCK_C_DIRECTORY="$(TOCK_USERLAND_BASE_DIR)" cmake -G "CodeBlocks - Unix Makefiles" .. && \ - $(MAKE) -j4 2> /dev/null || true - -$(TOCK_USERLAND_BASE_DIR)/libradio/RadioLib/examples/NonArduino/Tock/build-riscv/RadioLib/libRadioLib.a: - cd $(TOCK_USERLAND_BASE_DIR)/libradio/RadioLib/examples/NonArduino/Tock/ && \ - rm -rf build-riscv && \ - mkdir -p build-riscv && cd build-riscv && \ - LIBTOCK_C_DIRECTORY="$(TOCK_USERLAND_BASE_DIR)" cmake -G "CodeBlocks - Unix Makefiles" -DRISCV_BUILD=1 .. && \ - $(MAKE) -j4 2> /dev/null || true -else # Use the libtock-c Make system -LIBS_cortex-m0 += $(TOCK_USERLAND_BASE_DIR)/libradio/RadioLib/build/cortex-m0/RadioLib.a -LIBS_cortex-m3 += $(TOCK_USERLAND_BASE_DIR)/libradio/RadioLib/build/cortex-m3/RadioLib.a -LIBS_cortex-m4 += $(TOCK_USERLAND_BASE_DIR)/libradio/RadioLib/build/cortex-m4/RadioLib.a -LIBS_cortex-m7 += $(TOCK_USERLAND_BASE_DIR)/libradio/RadioLib/build/cortex-m7/RadioLib.a - -LIBS_rv32imc += $(TOCK_USERLAND_BASE_DIR)/libradio/RadioLib/build/rv32imc/RadioLib.a -LIBS_rv32imac += $(TOCK_USERLAND_BASE_DIR)/libradio/RadioLib/build/rv32imac/RadioLib.a - -EXTERN_LIBS := $(TOCK_USERLAND_BASE_DIR)/libradio/RadioLib include $(TOCK_USERLAND_BASE_DIR)/libradio/Makefile +include $(TOCK_USERLAND_BASE_DIR)/libradio/Makefile.app + include $(TOCK_USERLAND_BASE_DIR)/AppMakefile.mk -endif diff --git a/libradio/Makefile b/libradio/Makefile index 961b5b30a..7d95e0e60 100644 --- a/libradio/Makefile +++ b/libradio/Makefile @@ -1,6 +1,6 @@ LIBNAME := RadioLib -TOCK_USERLAND_BASE_DIR ?= ../ +TOCK_USERLAND_BASE_DIR ?= .. $(LIBNAME)_DIR := $(TOCK_USERLAND_BASE_DIR)/libradio/$(LIBNAME) diff --git a/libradio/Makefile.app b/libradio/Makefile.app new file mode 100644 index 000000000..ea7b5db32 --- /dev/null +++ b/libradio/Makefile.app @@ -0,0 +1,5 @@ +# Include the core RadioLib headers +override CPPFLAGS += -isystem $(TOCK_USERLAND_BASE_DIR)/libradio/RadioLib/src + +# Include the Tock specific headers +override CPPFLAGS += -isystem $(TOCK_USERLAND_BASE_DIR)/libradio/RadioLib/examples/NonArduino/Tock From a2ec25e63947e4d7e1c4d06378d4f1f0532e3f08 Mon Sep 17 00:00:00 2001 From: Alistair Francis Date: Wed, 2 Oct 2024 11:34:17 +1000 Subject: [PATCH 10/12] examples: lora: Add example output Signed-off-by: Alistair Francis --- examples/lora/sensor-receive/README.md | 32 +++++++++++++++++++++++++ examples/lora/sensor-transmit/README.md | 15 ++++++++++++ 2 files changed, 47 insertions(+) diff --git a/examples/lora/sensor-receive/README.md b/examples/lora/sensor-receive/README.md index f76c80b59..6c8a13e2a 100644 --- a/examples/lora/sensor-receive/README.md +++ b/examples/lora/sensor-receive/README.md @@ -2,3 +2,35 @@ Sensor Receive ============== This example builds an application to receiver sensor data. + +## Example Output + +The output should look something like this. + +Note that if the receive example is started before the transmit you will get +-6 errors (RX_TIMEOUT) like below, as there is nothing to receive. + +``` +Apollo3 chip revision: B +Initialization complete. Entering main loop +[SX1261] Initialising Radio ... +success! +[SX1261] Receiving... +failed, code -6 +failed, code -6 +failed, code -6 +failed, code -6 +failed, code -6 +failed, code -6 +failed, code -6 +failed, code -6 +failed, code -6 +failed, code -6 +failed, code -6 +failed, code -6 +success!: Temp: 24047, Hum: 5966 +success!: Temp: 24047, Hum: 5966 +success!: Temp: 24047, Hum: 5966 +success!: Temp: 24047, Hum: 5966 +success!: Temp: 24047, Hum: 5966 +``` \ No newline at end of file diff --git a/examples/lora/sensor-transmit/README.md b/examples/lora/sensor-transmit/README.md index cad1c16ee..d6f97d095 100644 --- a/examples/lora/sensor-transmit/README.md +++ b/examples/lora/sensor-transmit/README.md @@ -2,3 +2,18 @@ Sensor Transmitter ================== This example builds an application to transmit sensor data. + +## Example Output + +The output should look something like this + +``` +Apollo3 chip revision: B +Initialization complete. Entering main loop +[SX1261] Initialising Radio ... +success! +[SX1261] Transmitting 'Temp: 24047, Hum: 5966' +success! +[SX1261] Transmitting 'Temp: 24047, Hum: 5966' +success! +``` \ No newline at end of file From 207aba9c1f43a10ed2cc2c7369d81d3ba05f07a6 Mon Sep 17 00:00:00 2001 From: Alistair Francis Date: Thu, 3 Oct 2024 08:41:39 +1000 Subject: [PATCH 11/12] RadioLib: Use EXTERN_LIBS instead of Makefile paths Signed-off-by: Alistair Francis --- .gitmodules | 4 +-- RadioLib/Makefile | 39 ++++++++++++++++++++++++++ RadioLib/Makefile.app | 5 ++++ RadioLib/Makefile.setup | 14 +++++++++ {libradio => RadioLib}/RadioLib | 0 examples/lora/sensor-receive/Makefile | 4 +-- examples/lora/sensor-transmit/Makefile | 4 +-- libradio/Makefile | 39 -------------------------- libradio/Makefile.app | 5 ---- 9 files changed, 62 insertions(+), 52 deletions(-) create mode 100644 RadioLib/Makefile create mode 100644 RadioLib/Makefile.app create mode 100644 RadioLib/Makefile.setup rename {libradio => RadioLib}/RadioLib (100%) delete mode 100644 libradio/Makefile delete mode 100644 libradio/Makefile.app diff --git a/.gitmodules b/.gitmodules index 67c693075..748d052c7 100644 --- a/.gitmodules +++ b/.gitmodules @@ -7,6 +7,6 @@ [submodule "libopenthread/openthread"] path = libopenthread/openthread url = https://github.com/openthread/openthread.git -[submodule "libradio/RadioLib"] - path = libradio/RadioLib +[submodule "RadioLib/RadioLib"] + path = RadioLib/RadioLib url = https://github.com/jgromes/RadioLib.git diff --git a/RadioLib/Makefile b/RadioLib/Makefile new file mode 100644 index 000000000..da13c350b --- /dev/null +++ b/RadioLib/Makefile @@ -0,0 +1,39 @@ +LIBNAME := RadioLib + +TOCK_USERLAND_BASE_DIR ?= .. + +$(LIBNAME)_DIR := $(TOCK_USERLAND_BASE_DIR)/$(LIBNAME) + +# We ideally want this: +# $(LIBNAME)_SRCS := \ +# $($(LIBNAME)_DIR)/$(LIBNAME)/src/Module.cpp \ +# $(wildcard $($(LIBNAME)_DIR)/$(LIBNAME)/src/*.cpp) \ +# $(wildcard $($(LIBNAME)_DIR)/$(LIBNAME)/src/*/*.cpp) \ +# $(wildcard $($(LIBNAME)_DIR)/$(LIBNAME)/src/*/*/*.cpp) +# +# But due to this in the GCC arm binary in the CI: +# +# ``` +# (insn 179 178 46 8 (set (reg:SI 3 r3 [168]) +# (mem/u/c:SI (plus:SI (reg:SI 12 ip [169]) +# (unspec:SI [ +# (symbol_ref/u:SI ("*.LC1") [flags 0x2]) +# ] UNSPEC_PIC_SYM)) [0 S4 A32])) "../../../RadioLib/src/modules/LR11x0/LR11x0.cpp":638:16 929 {*thumb1_movsi_insn} +# (expr_list:REG_EQUAL (symbol_ref/u:SI ("*.LC1") [flags 0x2]) +# (nil))) +# during RTL pass: postreload +# ../../../RadioLib/src/modules/LR11x0/LR11x0.cpp:650:1: internal compiler error: in extract_constrain_insn, at recog.c:2195 +# ``` +# +# we need to drop LR11x0 +$(LIBNAME)_SRCS := \ + $(wildcard $($(LIBNAME)_DIR)/$(LIBNAME)/src/*.cpp) \ + $(wildcard $($(LIBNAME)_DIR)/$(LIBNAME)/src/utils/*.cpp) \ + $(wildcard $($(LIBNAME)_DIR)/$(LIBNAME)/src/modules/C*/.cpp) \ + $(wildcard $($(LIBNAME)_DIR)/$(LIBNAME)/src/modules/LL*/*.cpp) \ + $(wildcard $($(LIBNAME)_DIR)/$(LIBNAME)/src/modules/RF*/*.cpp) \ + $(wildcard $($(LIBNAME)_DIR)/$(LIBNAME)/src/modules/S*/*.cpp) \ + $(wildcard $($(LIBNAME)_DIR)/$(LIBNAME)/src/modules/n*/*.cpp) \ + $(wildcard $($(LIBNAME)_DIR)/$(LIBNAME)/src/protocols/*/*.cpp) \ + +include $(TOCK_USERLAND_BASE_DIR)/TockLibrary.mk diff --git a/RadioLib/Makefile.app b/RadioLib/Makefile.app new file mode 100644 index 000000000..6f1ecb693 --- /dev/null +++ b/RadioLib/Makefile.app @@ -0,0 +1,5 @@ +# Include the core RadioLib headers +override CPPFLAGS += -I$(TOCK_USERLAND_BASE_DIR)/RadioLib/RadioLib/src + +# Include the Tock specific headers +override CPPFLAGS += -I$(TOCK_USERLAND_BASE_DIR)/RadioLib/RadioLib/examples/NonArduino/Tock diff --git a/RadioLib/Makefile.setup b/RadioLib/Makefile.setup new file mode 100644 index 000000000..1f614c947 --- /dev/null +++ b/RadioLib/Makefile.setup @@ -0,0 +1,14 @@ +.PHONY: clean + +TOCK_USERLAND_BASE_DIR ?= ../ + + +all: $(TOCK_USERLAND_BASE_DIR)/RadioLib/RadioLib/README.md + +clean:: + rm -rf build + +# confirm RadioLib git submodule is checked out. +$(TOCK_USERLAND_BASE_DIR)/RadioLib/RadioLib/README.md: + git submodule update --init -- $(TOCK_USERLAND_BASE_DIR)/RadioLib/RadioLib + diff --git a/libradio/RadioLib b/RadioLib/RadioLib similarity index 100% rename from libradio/RadioLib rename to RadioLib/RadioLib diff --git a/examples/lora/sensor-receive/Makefile b/examples/lora/sensor-receive/Makefile index 99027b730..072a73732 100644 --- a/examples/lora/sensor-receive/Makefile +++ b/examples/lora/sensor-receive/Makefile @@ -7,8 +7,6 @@ TOCK_USERLAND_BASE_DIR = ../../.. CXX_SRCS := $(wildcard *.cc) # Use the libtock-c Make system -include $(TOCK_USERLAND_BASE_DIR)/libradio/Makefile - -include $(TOCK_USERLAND_BASE_DIR)/libradio/Makefile.app +EXTERN_LIBS += $(TOCK_USERLAND_BASE_DIR)/RadioLib include $(TOCK_USERLAND_BASE_DIR)/AppMakefile.mk diff --git a/examples/lora/sensor-transmit/Makefile b/examples/lora/sensor-transmit/Makefile index 99027b730..072a73732 100644 --- a/examples/lora/sensor-transmit/Makefile +++ b/examples/lora/sensor-transmit/Makefile @@ -7,8 +7,6 @@ TOCK_USERLAND_BASE_DIR = ../../.. CXX_SRCS := $(wildcard *.cc) # Use the libtock-c Make system -include $(TOCK_USERLAND_BASE_DIR)/libradio/Makefile - -include $(TOCK_USERLAND_BASE_DIR)/libradio/Makefile.app +EXTERN_LIBS += $(TOCK_USERLAND_BASE_DIR)/RadioLib include $(TOCK_USERLAND_BASE_DIR)/AppMakefile.mk diff --git a/libradio/Makefile b/libradio/Makefile deleted file mode 100644 index 7d95e0e60..000000000 --- a/libradio/Makefile +++ /dev/null @@ -1,39 +0,0 @@ -LIBNAME := RadioLib - -TOCK_USERLAND_BASE_DIR ?= .. - -$(LIBNAME)_DIR := $(TOCK_USERLAND_BASE_DIR)/libradio/$(LIBNAME) - -# We ideally want this: -# $(LIBNAME)_SRCS := \ -# $($(LIBNAME)_DIR)/src/Module.cpp \ -# $(wildcard $($(LIBNAME)_DIR)/src/*.cpp) \ -# $(wildcard $($(LIBNAME)_DIR)/src/*/*.cpp) \ -# $(wildcard $($(LIBNAME)_DIR)/src/*/*/*.cpp) -# -# But due to this in the GCC arm binary in the CI: -# -# ``` -# (insn 179 178 46 8 (set (reg:SI 3 r3 [168]) -# (mem/u/c:SI (plus:SI (reg:SI 12 ip [169]) -# (unspec:SI [ -# (symbol_ref/u:SI ("*.LC1") [flags 0x2]) -# ] UNSPEC_PIC_SYM)) [0 S4 A32])) "../../../RadioLib/src/modules/LR11x0/LR11x0.cpp":638:16 929 {*thumb1_movsi_insn} -# (expr_list:REG_EQUAL (symbol_ref/u:SI ("*.LC1") [flags 0x2]) -# (nil))) -# during RTL pass: postreload -# ../../../RadioLib/src/modules/LR11x0/LR11x0.cpp:650:1: internal compiler error: in extract_constrain_insn, at recog.c:2195 -# ``` -# -# we need to drop LR11x0 -$(LIBNAME)_SRCS := \ - $(wildcard $($(LIBNAME)_DIR)/src/*.cpp) \ - $(wildcard $($(LIBNAME)_DIR)/src/utils/*.cpp) \ - $(wildcard $($(LIBNAME)_DIR)/src/modules/C*/.cpp) \ - $(wildcard $($(LIBNAME)_DIR)/src/modules/LL*/*.cpp) \ - $(wildcard $($(LIBNAME)_DIR)/src/modules/RF*/*.cpp) \ - $(wildcard $($(LIBNAME)_DIR)/src/modules/S*/*.cpp) \ - $(wildcard $($(LIBNAME)_DIR)/src/modules/n*/*.cpp) \ - $(wildcard $($(LIBNAME)_DIR)/src/protocols/*/*.cpp) \ - -include $(TOCK_USERLAND_BASE_DIR)/TockLibrary.mk diff --git a/libradio/Makefile.app b/libradio/Makefile.app deleted file mode 100644 index ea7b5db32..000000000 --- a/libradio/Makefile.app +++ /dev/null @@ -1,5 +0,0 @@ -# Include the core RadioLib headers -override CPPFLAGS += -isystem $(TOCK_USERLAND_BASE_DIR)/libradio/RadioLib/src - -# Include the Tock specific headers -override CPPFLAGS += -isystem $(TOCK_USERLAND_BASE_DIR)/libradio/RadioLib/examples/NonArduino/Tock From b8ab66dd879b0fdbdae336f38cd4b7cc4f15f7ce Mon Sep 17 00:00:00 2001 From: Alistair Francis Date: Wed, 23 Oct 2024 10:24:08 +1000 Subject: [PATCH 12/12] examples: lora: Use C++ reinterpret_cast Signed-off-by: Alistair Francis --- examples/lora/sensor-receive/main.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/lora/sensor-receive/main.cc b/examples/lora/sensor-receive/main.cc index 96139ec8b..a64046104 100644 --- a/examples/lora/sensor-receive/main.cc +++ b/examples/lora/sensor-receive/main.cc @@ -50,7 +50,7 @@ int main(void) { // Ensure there are no pending callbacks yield_no_wait(); - state = radio->receive((uint8_t*)buffer, BUFFER_LEN); + state = radio->receive(reinterpret_cast (buffer), BUFFER_LEN); if (state == RADIOLIB_ERR_NONE) { // the packet was successfully transmitted