From 9c3ccbcd4bd69555e7b8aa5835e6090faab8a825 Mon Sep 17 00:00:00 2001 From: Nestor Ayuso Date: Fri, 1 Jul 2016 10:57:09 +0200 Subject: [PATCH 1/8] Update sx1276Regs-Fsk.h add modulation shaping names in RegPaRamp register and fix LOWPNTXPLL mask and default value as on SX1276 datasheet and former sx1276-Fsk.h file --- src/radio/sx1276/sx1276Regs-Fsk.h | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/radio/sx1276/sx1276Regs-Fsk.h b/src/radio/sx1276/sx1276Regs-Fsk.h index b0bf28b2e..75cc6d5a7 100644 --- a/src/radio/sx1276/sx1276Regs-Fsk.h +++ b/src/radio/sx1276/sx1276Regs-Fsk.h @@ -376,9 +376,15 @@ Maintainer: Miguel Luis and Gregory Cristian /*! * RegPaRamp */ -#define RF_PARAMP_LOWPNTXPLL_MASK 0xE0 -#define RF_PARAMP_LOWPNTXPLL_OFF 0x10 // Default -#define RF_PARAMP_LOWPNTXPLL_ON 0x00 +#define RF_PARAMP_MODULATIONSHAPING_MASK 0x9F +#define RF_PARAMP_MODULATIONSHAPING_00 0x00 // Default +#define RF_PARAMP_MODULATIONSHAPING_01 0x20 +#define RF_PARAMP_MODULATIONSHAPING_10 0x40 +#define RF_PARAMP_MODULATIONSHAPING_11 0x60 + +#define RF_PARAMP_LOWPNTXPLL_MASK 0xEF +#define RF_PARAMP_LOWPNTXPLL_OFF 0x10 +#define RF_PARAMP_LOWPNTXPLL_ON 0x00 // Default #define RF_PARAMP_MASK 0xF0 #define RF_PARAMP_3400_US 0x00 From 28ee714cecaa6e57b82c9bbefb9324ea73aa4135 Mon Sep 17 00:00:00 2001 From: Miguel Luis Date: Thu, 22 Sep 2016 17:44:55 +0200 Subject: [PATCH 2/8] Revert "Update sx1276Regs-Fsk.h add modulation shaping names in RegPaRamp register" --- src/radio/sx1276/sx1276Regs-Fsk.h | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/src/radio/sx1276/sx1276Regs-Fsk.h b/src/radio/sx1276/sx1276Regs-Fsk.h index 75cc6d5a7..b0bf28b2e 100644 --- a/src/radio/sx1276/sx1276Regs-Fsk.h +++ b/src/radio/sx1276/sx1276Regs-Fsk.h @@ -376,15 +376,9 @@ Maintainer: Miguel Luis and Gregory Cristian /*! * RegPaRamp */ -#define RF_PARAMP_MODULATIONSHAPING_MASK 0x9F -#define RF_PARAMP_MODULATIONSHAPING_00 0x00 // Default -#define RF_PARAMP_MODULATIONSHAPING_01 0x20 -#define RF_PARAMP_MODULATIONSHAPING_10 0x40 -#define RF_PARAMP_MODULATIONSHAPING_11 0x60 - -#define RF_PARAMP_LOWPNTXPLL_MASK 0xEF -#define RF_PARAMP_LOWPNTXPLL_OFF 0x10 -#define RF_PARAMP_LOWPNTXPLL_ON 0x00 // Default +#define RF_PARAMP_LOWPNTXPLL_MASK 0xE0 +#define RF_PARAMP_LOWPNTXPLL_OFF 0x10 // Default +#define RF_PARAMP_LOWPNTXPLL_ON 0x00 #define RF_PARAMP_MASK 0xF0 #define RF_PARAMP_3400_US 0x00 From d50be3a87a5292b482d2d6642ef0ee22d1bb3a0d Mon Sep 17 00:00:00 2001 From: Rainer 'rei' Schuth Date: Fri, 25 Nov 2016 10:44:23 +0100 Subject: [PATCH 3/8] Fix CMakeSources.txt file names typos. --- src/mac/CMakeSources.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mac/CMakeSources.txt b/src/mac/CMakeSources.txt index c4a423230..2ded2688b 100644 --- a/src/mac/CMakeSources.txt +++ b/src/mac/CMakeSources.txt @@ -3,5 +3,5 @@ use_c99() set(MAC_DIR ${SOURCE_DIR}/mac) include(${SOURCE_DIR}/system/crypto/CMakeSources.txt) set(SYSTEM_DIR ${SOURCE_DIR}/system) -set(MAC_SOURCES ${MAC_DIR}/LoraMac.c ${MAC_DIR}/LoraMac-api-v3.c ${MAC_DIR}/LoRaMacCrypto.c ${CRYPTO_SOURCES} ${SYSTEM_DIR}/timer.c) +set(MAC_SOURCES ${MAC_DIR}/LoRaMac.c ${MAC_DIR}/LoRaMac-api-v3.c ${MAC_DIR}/LoRaMacCrypto.c ${CRYPTO_SOURCES} ${SYSTEM_DIR}/timer.c) include_directories(${CRYPTO_DIR} ${SYSTEM_DIR}) From fd839613f48df9e3387a8cdf88898d7050d5f093 Mon Sep 17 00:00:00 2001 From: Rainer 'rei' Schuth Date: Fri, 25 Nov 2016 10:50:09 +0100 Subject: [PATCH 4/8] Fix include filename typo --- src/apps/ttnmapper/generic/main.c | 2 +- src/boards/generic/spi-board.c | 2 +- src/boards/generic/spi-board.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/apps/ttnmapper/generic/main.c b/src/apps/ttnmapper/generic/main.c index 3bdf3060d..fdd233ab4 100644 --- a/src/apps/ttnmapper/generic/main.c +++ b/src/apps/ttnmapper/generic/main.c @@ -12,7 +12,7 @@ #include "board.h" #include "LoRaMac.h" -#include "Log.h" +#include "log.h" #include "LoRaMac-api-v3.h" #define TTN_MAPPER_NWK_SKEY { 0xAE, 0x17, 0xE5, 0x67, 0xAE, 0xCC, 0x87, 0x87, 0xF7, 0x49, 0xA6, 0x2F, 0x55, 0x41, 0xD5, 0x22 } diff --git a/src/boards/generic/spi-board.c b/src/boards/generic/spi-board.c index cd3eefe54..e2a9389c9 100644 --- a/src/boards/generic/spi-board.c +++ b/src/boards/generic/spi-board.c @@ -11,7 +11,7 @@ #include "spi-board.h" #if BOARD_GPIO_RASPBERRY_PI -#include "pi/spi-board-pi.c" +#include "Pi/spi-board-pi.c" #elif BOARD_GPIO_UNDEFINED #warning "Using UNDEFINED board GPIO, link step will fail" #else diff --git a/src/boards/generic/spi-board.h b/src/boards/generic/spi-board.h index b38f9a8a5..1f5987642 100644 --- a/src/boards/generic/spi-board.h +++ b/src/boards/generic/spi-board.h @@ -9,7 +9,7 @@ #define SRC_BOARDS_GENERIC_SPI_BOARD_H_ #if BOARD_GPIO_RASPBERRY_PI -#include "pi/spi-board-pi.h" +#include "Pi/spi-board-pi.h" #elif BOARD_GPIO_UNDEFINED #warning "Using undefined GPIO, link step will fail" typedef int SPI_HandleTypeDef; From 72fdd0b3f9df9d509f2712163b29ebf1dfde8559 Mon Sep 17 00:00:00 2001 From: Rainer 'rei' Schuth Date: Fri, 25 Nov 2016 11:12:33 +0100 Subject: [PATCH 5/8] Fix more include typos --- src/boards/generic/Pi/gpio-board-pi.c | 2 +- src/boards/generic/Pi/spi-board-pi.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/boards/generic/Pi/gpio-board-pi.c b/src/boards/generic/Pi/gpio-board-pi.c index fc85f99eb..af2b47c66 100644 --- a/src/boards/generic/Pi/gpio-board-pi.c +++ b/src/boards/generic/Pi/gpio-board-pi.c @@ -9,7 +9,7 @@ #include "board.h" #include #include "gpio.h" -#include "Log.h" +#include "log.h" void GpioMcuInitialize(void) { diff --git a/src/boards/generic/Pi/spi-board-pi.c b/src/boards/generic/Pi/spi-board-pi.c index 48cf49f95..3de67e5f1 100644 --- a/src/boards/generic/Pi/spi-board-pi.c +++ b/src/boards/generic/Pi/spi-board-pi.c @@ -6,7 +6,7 @@ */ #include "board.h" -#include "Log.h" +#include "log.h" #include #include From 6339d7d48eeb6c7cd9a730cf0622864b9f7f69d8 Mon Sep 17 00:00:00 2001 From: Rainer 'rei' Schuth Date: Mon, 28 Nov 2016 10:42:40 +0100 Subject: [PATCH 6/8] Add wiringpi include dirs to search path for wiringPi.h --- cmake/modules/FindWiringPi.cmake | 1 + 1 file changed, 1 insertion(+) diff --git a/cmake/modules/FindWiringPi.cmake b/cmake/modules/FindWiringPi.cmake index 4209480d9..7114c8379 100644 --- a/cmake/modules/FindWiringPi.cmake +++ b/cmake/modules/FindWiringPi.cmake @@ -1,5 +1,6 @@ find_library(WIRINGPI_LIBRARIES NAMES wiringPi) find_path(WIRINGPI_INCLUDE_DIRS NAMES wiringPi.h) +include_directories(SYSTEM ${WIRINGPI_INCLUDE_DIRS}) include(FindPackageHandleStandardArgs) find_package_handle_standard_args(wiringPi "Could not find WiringPi. Either install it using instructions at http://wiringpi.com/download-and-install/ or specify a different BOARD_GPIO" WIRINGPI_LIBRARIES WIRINGPI_INCLUDE_DIRS) From 3ca54f68543ebebba926532234a8175ce78821c5 Mon Sep 17 00:00:00 2001 From: Rainer 'rei' Schuth Date: Mon, 28 Nov 2016 10:43:12 +0100 Subject: [PATCH 7/8] Add mirring -lrt lib for crosscompiling raspberry pi --- src/boards/generic/CMakeSources.txt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/boards/generic/CMakeSources.txt b/src/boards/generic/CMakeSources.txt index 5727de046..f49f3b6aa 100644 --- a/src/boards/generic/CMakeSources.txt +++ b/src/boards/generic/CMakeSources.txt @@ -10,5 +10,6 @@ set(BOARD_SOURCES if(BOARD_GPIO STREQUAL "RASPBERRY_PI") find_package(WiringPi REQUIRED) include_directories(${WiringPi_INCLUDE_DIRS}) -set(BOARD_LIBS ${WIRINGPI_LIBRARIES}) -endif() \ No newline at end of file +set(RPI_LIBS rt) +set(BOARD_LIBS ${WIRINGPI_LIBRARIES} ${RPI_LIBS}) +endif() From 8c614f0a91b8198d77a26bc29f1c3bc20a8dbda6 Mon Sep 17 00:00:00 2001 From: Rainer 'rei' Schuth Date: Mon, 28 Nov 2016 11:21:56 +0100 Subject: [PATCH 8/8] Add and update documentation on how to (cross) compile LoRaMac-node for the raspberry pi --- Doc/readme_generic_board.md | 163 ++++++++++++++++++++++++++++++++++-- 1 file changed, 155 insertions(+), 8 deletions(-) diff --git a/Doc/readme_generic_board.md b/Doc/readme_generic_board.md index a07ed6751..8adc47bad 100644 --- a/Doc/readme_generic_board.md +++ b/Doc/readme_generic_board.md @@ -4,16 +4,163 @@ The generic board target moves the minimum dependencies for compile and build of The project was originally created to support the Raspberry Pi target but other generic targets could be added later. -2. CMake +2. Installing Dependencies +---------------- + +### Install CMake + +Install [cmake](https://cmake.org) on your target + +``` +sudo apt-get install cmake libc6 +``` + +### Install WiringPi on the RPi + +``` +sudo apt-get install git-core +mkdir -p ~/raspberrypi +cd ~/raspberrypi +git clone git://git.drogon.net/wiringPi +cd wiringPi +git pull origin +./build #compile and install lib +``` + +3. CMake ---------------- The cmake directory can be used with the generic target for any cmake supported gcc like compile or cross complie platforms. See the cmake/CMakeLists.txt file for customizable parameters. The steps to use when building using CMake are: - 1. Install [cmake](https://cmake.org) on your target. For raspbian this is as simple as sudo apt-get install cmake - 2. Customize the cmake/CMakeLists file to specify details about your target RTC and GPIO implementations. See specific target sections below for detailed instructions about per-project configurations. Use `set(BOARD_RADIO "SX1276")` to specify the radio type used. - 3. Create a "build" directory in the cmake subdirectory and cd into this directory. - 4. Run `cmake ..` from this directory to generate makefiles - 5. Run `./make` to build the project file + 1. Customize the cmake/CMakeLists file to specify details about your target RTC and GPIO implementations. See specific target sections below for detailed instructions about per-project configurations. Use `set(BOARD_RADIO "SX1276")` to specify the radio type used. + 2. Create a "build" directory in the cmake subdirectory and cd into this directory. + ``` + mkdir -p build + cd build + ``` + 3. Run `cmake ..` from this directory to generate makefiles + 4. Run `./make` to build the project file + + +### Cross-Compile with CMake for RPi + + + 1. Add dependencies + + ``` + apt-get install git rsync cmake libc6-i386 lib32z1 lib32stdc++6 + ``` + + 2. Get the Raspberry Pi tools and toolchain + + ``` + mkdir -p ~/raspberrypi + cd ~/raspberrypi + git clone git://github.com/raspberrypi/tools.git + ``` + + 3. Add the needes paths to the ENV variables. + + ``` + echo 'export PATH=$PATH:$HOME/raspberrypi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin' >> ~/.bashrc + + source ~/.bashrc + ``` + + 4. Now, verify that you can access the compiler: + + ``` + arm-linux-gnueabihf-gcc -v + ``` + + 5. In your raspberrypi folder, make a folder called rootfs. + + ``` + mkdir -p ~/raspberrypi/rootfs + cd ~/raspberrypi/ + ``` + +6. Connect to your Raspberry Pi board and install the needed libs. In our case, we need WiringPi. + + ``` + sudo apt-get install git-core + git clone git://git.drogon.net/wiringPi + cd wiringPi + git pull origin + ./build #compile and install the lib + ``` + + 7. Now you need to copy the entire /lib and /usr directory from the Raspberry Pi to this newly created folder in our local machine. + + ``` + rsync -rlv links -e "ssh -p 22" pi@raspberry-pi.local:/{lib,usr} $HOME/raspberrypi/rootfs + ``` + + 8. Now, we need to write a cmake config file. Open **~/raspberrypi/pi.cmake** in your favorite editor and insert the following: + + ``` + SET(CMAKE_SYSTEM_NAME Linux) + SET(CMAKE_SYSTEM_VERSION 1) + SET(CMAKE_C_COMPILER $ENV{HOME}/raspberrypi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/arm-linux-gnueabihf-gcc) + SET(CMAKE_CXX_COMPILER $ENV{HOME}/raspberrypi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/arm-linux-gnueabihf-g++) + SET(CMAKE_FIND_ROOT_PATH $ENV{HOME}/raspberrypi/rootfs) + SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) + SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) + SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) + ``` + + 9. Now you should be able to compile your cmake programs simply by adding this extra flag: + + ``` + -D CMAKE_TOOLCHAIN_FILE=$HOME/raspberrypi/pi.cmake + ``` + + **Example:** + + ``` + cmake -D CMAKE_TOOLCHAIN_FILE=$HOME/raspberrypi/pi.cmake ../ && make + ``` + + 10. Demo/Example: + + ``` + cd /tmp + mkdir -p helloworld/build + cd helloworld + + cat << EOF > helloworld.cpp + #include + + int main(int argc, char *argv[]){ + std::cout << "Hello World!" << std::endl; + return 0; + } + EOF + + cat << EOF > CMakeLists.txt + cmake_minimum_required(VERSION 2.8.9) + project (hello) + add_executable(hello helloworld.cpp) + EOF + + mkdir -p build + cd build + cmake -D CMAKE_TOOLCHAIN_FILE=$HOME/raspberrypi/pi.cmake ../ + make + + scp -P 22 CMakeHelloWorld pi@raspberry-pi.local:/tmp/ + ssh pi@raspberry-pi.local -p 22 /tmp/CMakeHelloWorld + + ``` + +### Cross-Compile with Make for RPi v2,3 + + 1. Follow the steps 1. to 7. from the **Cross-Compile with CMake for RPi** instructions. + 2. To compile your C++ code run your makefile with: + + ``` + make CXX=arm-linux-gnueabihf-g++ LD=arm-linux-gnueabihf-ld + ``` -3. Apps Supporting Generic Board Targets +4. Apps Supporting Generic Board Targets ---------------- Use ``` @@ -25,7 +172,7 @@ The cmake directory can be used with the generic target for any cmake supported 1. ttnmapper An aplication used to generate coverage maps, see http://ttnmapper.org/ for project overview. Configuration and usage details are TBD. -4. Supported Target Hardware +5. Supported Target Hardware ---------------- 1. Raspberry Pi Target 1. To configure the Raspberry Pi target, ensure CMakeLists.txt uses