diff --git a/examples/NonArduino/Tock/CMakeLists.txt b/examples/NonArduino/Tock/CMakeLists.txt index 8801d3194..eed0d0862 100644 --- a/examples/NonArduino/Tock/CMakeLists.txt +++ b/examples/NonArduino/Tock/CMakeLists.txt @@ -47,26 +47,61 @@ add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/../../../../RadioLib" "${CMAKE_CUR add_executable(${PROJECT_NAME} main.cpp) # link with RadioLib and libtock-c +# The build system for libtock-c is a bit odd and the version of libraries +# built changes based on compiler version. if (RISCV_BUILD) - target_link_libraries(${PROJECT_NAME} PUBLIC - RadioLib - ${CMAKE_CURRENT_SOURCE_DIR}/libtock-c/libtock/build/rv32imc/libtock.a - ${CMAKE_CURRENT_SOURCE_DIR}/libtock-c/newlib/rv32/rv32i/libc.a - ${CMAKE_CURRENT_SOURCE_DIR}/libtock-c/newlib/rv32/rv32i/libm.a - ) + if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/libtock-c/lib/libtock-libc++-13.2.0") + target_link_libraries(${PROJECT_NAME} PUBLIC + RadioLib + ${CMAKE_CURRENT_SOURCE_DIR}/libtock-c/libtock/build/rv32imc/libtock.a + ${CMAKE_CURRENT_SOURCE_DIR}/libtock-c/lib/libtock-libc++-13.2.0/riscv/lib/gcc/riscv64-unknown-elf/13.2.0/rv32i/ilp32/libgcc.a + ${CMAKE_CURRENT_SOURCE_DIR}/libtock-c/lib/libtock-libc++-13.2.0/riscv/riscv64-unknown-elf/lib/rv32i/ilp32/libstdc++.a + ${CMAKE_CURRENT_SOURCE_DIR}/libtock-c/lib/libtock-newlib-4.3.0.20230120/riscv/riscv64-unknown-elf/lib/rv32i/ilp32/libc.a + ${CMAKE_CURRENT_SOURCE_DIR}/libtock-c/lib/libtock-newlib-4.3.0.20230120/riscv/riscv64-unknown-elf/lib/rv32i/ilp32/libm.a + ) + + target_include_directories(RadioLib AFTER PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR}/libtock-c/lib/libtock-newlib-4.3.0.20230120/riscv/riscv64-unknown-elf/include/ + ) + else() + target_link_libraries(${PROJECT_NAME} PUBLIC + RadioLib + ${CMAKE_CURRENT_SOURCE_DIR}/libtock-c/libtock/build/rv32imc/libtock.a + ${CMAKE_CURRENT_SOURCE_DIR}/libtock-c/lib/libtock-libc++-10.5.0/riscv/lib/gcc/riscv64-unknown-elf/10.5.0/rv32i/ilp32/libgcc.a + ${CMAKE_CURRENT_SOURCE_DIR}/libtock-c/lib/libtock-libc++-10.5.0/riscv/riscv64-unknown-elf/lib/rv32i/ilp32/libstdc++.a + ${CMAKE_CURRENT_SOURCE_DIR}/libtock-c/lib/libtock-newlib-4.2.0.20211231/riscv/riscv64-unknown-elf/lib/rv32i/ilp32/libc.a + ${CMAKE_CURRENT_SOURCE_DIR}/libtock-c/lib/libtock-newlib-4.2.0.20211231/riscv/riscv64-unknown-elf/lib/rv32i/ilp32/libm.a + ) + + target_include_directories(RadioLib AFTER PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR}/libtock-c/lib/libtock-newlib-4.2.0.20211231/riscv/riscv64-unknown-elf/include/ + ) + endif() else() - target_link_libraries(${PROJECT_NAME} PUBLIC - RadioLib - ${CMAKE_CURRENT_SOURCE_DIR}/libtock-c/libtock/build/cortex-m4/libtock.a - ${CMAKE_CURRENT_SOURCE_DIR}/libtock-c/libc++/cortex-m/libgcc.a - ${CMAKE_CURRENT_SOURCE_DIR}/libtock-c/libc++/cortex-m/libstdc++.a - ${CMAKE_CURRENT_SOURCE_DIR}/libtock-c/newlib/cortex-m/v7-m/libc.a - ${CMAKE_CURRENT_SOURCE_DIR}/libtock-c/newlib/cortex-m/v7-m/libm.a - ) + if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/libtock-c/lib/libtock-libc++-13.2.0") + target_link_libraries(${PROJECT_NAME} PUBLIC + RadioLib + ${CMAKE_CURRENT_SOURCE_DIR}/libtock-c/libtock/build/cortex-m4/libtock.a + ${CMAKE_CURRENT_SOURCE_DIR}/libtock-c/lib/libtock-libc++-13.2.0/arm/lib/gcc/arm-none-eabi/13.2.0/libgcc.a + ${CMAKE_CURRENT_SOURCE_DIR}/libtock-c/lib/libtock-libc++-13.2.0/arm/arm-none-eabi/lib/libstdc++.a + ${CMAKE_CURRENT_SOURCE_DIR}/libtock-c/lib/libtock-newlib-4.3.0.20230120/arm/arm-none-eabi/lib/libc.a + ${CMAKE_CURRENT_SOURCE_DIR}/libtock-c/lib/libtock-newlib-4.3.0.20230120/arm/arm-none-eabi/lib/libm.a + ) + else() + target_link_libraries(${PROJECT_NAME} PUBLIC + RadioLib + ${CMAKE_CURRENT_SOURCE_DIR}/libtock-c/libtock/build/cortex-m4/libtock.a + ${CMAKE_CURRENT_SOURCE_DIR}/libtock-c/lib/libtock-libc++-10.5.0/arm/lib/gcc/arm-none-eabi/10.5.0/libgcc.a + ${CMAKE_CURRENT_SOURCE_DIR}/libtock-c/lib/libtock-libc++-10.5.0/arm/arm-none-eabi/lib/libstdc++.a + ${CMAKE_CURRENT_SOURCE_DIR}/libtock-c/lib/libtock-newlib-4.2.0.20211231/arm/arm-none-eabi/lib/libc.a + ${CMAKE_CURRENT_SOURCE_DIR}/libtock-c/lib/libtock-newlib-4.2.0.20211231/arm/arm-none-eabi/lib/libm.a + ) + endif() endif() target_include_directories(${PROJECT_NAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/../../../src/ ${CMAKE_CURRENT_SOURCE_DIR}/libtock-c ) diff --git a/examples/NonArduino/Tock/README.md b/examples/NonArduino/Tock/README.md index 6589f4791..77ee19b76 100644 --- a/examples/NonArduino/Tock/README.md +++ b/examples/NonArduino/Tock/README.md @@ -13,6 +13,10 @@ This has been tested on the but will work on any LoRa compatible Tock board (currently only the expLoRaBLE board). +libtock-c by default is bulit for RISC-V and ARM. RadioLib is also built +for both architectures by default. You can skip the RISC-V RadioLib build +by setting the `SKIP_RISCV` varaible. + The RadioLib example can be built with: ```shell diff --git a/examples/NonArduino/Tock/build.sh b/examples/NonArduino/Tock/build.sh index b3db89fc7..4f53d3849 100755 --- a/examples/NonArduino/Tock/build.sh +++ b/examples/NonArduino/Tock/build.sh @@ -3,9 +3,9 @@ set -e rm -rf ./build-* -cd libtock-c/libtock -make RISCV=1 -j4 -cd ../../ +cd libtock-c/examples/cxx_hello +make -j4 +cd ../../../ mkdir -p build-arm cd build-arm @@ -15,13 +15,15 @@ make -j4 cd .. -mkdir -p build-riscv -cd build-riscv +if ! env | grep SKIP_RISCV; then + mkdir -p build-riscv + cd build-riscv -cmake -G "CodeBlocks - Unix Makefiles" -DRISCV_BUILD=1 .. -make -j4 + cmake -G "CodeBlocks - Unix Makefiles" -DRISCV_BUILD=1 .. + make -j4 VERBOSE=1 -cd .. + cd .. +fi elf2tab -n radio-lib --stack 4096 --app-heap 2048 --kernel-heap 2048 \ --kernel-major 2 --kernel-minor 1 \ diff --git a/examples/NonArduino/Tock/libtock-c b/examples/NonArduino/Tock/libtock-c index 1c1f4c081..44bf89c54 160000 --- a/examples/NonArduino/Tock/libtock-c +++ b/examples/NonArduino/Tock/libtock-c @@ -1 +1 @@ -Subproject commit 1c1f4c0810aa0fbd50aa91a11aaa7c05d2abb1bc +Subproject commit 44bf89c545953d8859faf101d4b4a4b6a151fe6c diff --git a/src/protocols/FSK4/FSK4.cpp b/src/protocols/FSK4/FSK4.cpp index 4fd267e66..785961dfe 100644 --- a/src/protocols/FSK4/FSK4.cpp +++ b/src/protocols/FSK4/FSK4.cpp @@ -1,4 +1,5 @@ #include "FSK4.h" +#include #include #if !RADIOLIB_EXCLUDE_FSK4