This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Board: nrf52dk_nrf52832 Do not work with Zephyr

I want to try Zephyr on the nrf52dk_nrf52832. (PCA10040)

I can not get it to work.

If I try to use -DBOARD=nrf52dk_nrf52810 All is OK

Here is what I do:

cd ~/zephyr_test/hello_world
mkdir _bld; cd _bld
cmake -DBOARD=nrf52dk_nrf52810 ..

The Output is:

Including boilerplate (Freestanding): /home/joe/zephyrproject/zephyr/cmake/app/boilerplate.cmake
-- Application: /home/joe/zephyr_test/hello_world
-- Zephyr version: 2.4.99 (/home/joe/zephyrproject/zephyr)
-- Found Python3: /usr/bin/python3.7 (found suitable exact version "3.7.3") found components:  Interpreter  
-- Found west (found suitable version "0.8.0", minimum required is "0.7.1")
-- Board: nrf52dk_nrf52810
-- Cache files will be written to: /home/joe/.cache/zephyr
ZEPHYR_TOOLCHAIN_VARIANT not set, trying to locate Zephyr SDK
-- Found toolchain: zephyr (/home/joe/zephyr-sdk-0.11.4)
-- Found dtc: /home/joe/zephyr-sdk-0.11.4/sysroots/x86_64-pokysdk-linux/usr/bin/dtc (found suitable version "1.5.0", minimum required is "1.4.6")
-- Found BOARD.dts: /home/joe/zephyrproject/zephyr/boards/arm/nrf52dk_nrf52810/nrf52dk_nrf52810.dts
-- Generated zephyr.dts: /home/joe/zephyr_test/hello_world/_bld/zephyr/zephyr.dts
-- Generated devicetree_unfixed.h: /home/joe/zephyr_test/hello_world/_bld/zephyr/include/generated/devicetree_unfixed.h
Parsing /home/joe/zephyrproject/zephyr/Kconfig
Loaded configuration '/home/joe/zephyrproject/zephyr/boards/arm/nrf52dk_nrf52810/nrf52dk_nrf52810_defconfig'
Merged configuration '/home/joe/zephyr_test/hello_world/prj.conf'
Configuration saved to '/home/joe/zephyr_test/hello_world/_bld/zephyr/.config'
Kconfig header saved to '/home/joe/zephyr_test/hello_world/_bld/zephyr/include/generated/autoconf.h'
-- The C compiler identification is GNU 9.2.0
-- The CXX compiler identification is GNU 9.2.0
-- The ASM compiler identification is GNU
-- Found assembler: /home/joe/zephyr-sdk-0.11.4/arm-zephyr-eabi/bin/arm-zephyr-eabi-gcc
-- Configuring done
-- Generating done
-- Build files have been written to: /home/joe/zephyr_test/hello_world/_bld

I then run make and all is OK.

Than (in another terminal window):
minicom -D /dev/ttyACM0 -b 115200

I'm Flashing the board:
nrfjprog -f nrf52 --program ./zephyr/zephyr.hex --sectorerase
And reset it:
nrfjprog -f nrf52 --reset

In minicom I get:
*** Booting Zephyr OS build zephyr-v2.4.0-1657-g5a58ad508cb3  ***
Hello World! nrf52dk_nrf52810

So far All is OK.

*****************

I then do:
rm -r *
cmake -DBOARD=nrf52dk_nrf52832 ..

And The Output is:

Including boilerplate (Freestanding): /home/joe/zephyrproject/zephyr/cmake/app/boilerplate.cmake
-- Application: /home/joe/zephyr_test/hello_world
-- Zephyr version: 2.4.99 (/home/joe/zephyrproject/zephyr)
-- Found Python3: /usr/bin/python3.7 (found suitable exact version "3.7.3") found components:  Interpreter  
-- Found west (found suitable version "0.8.0", minimum required is "0.7.1")
-- Board: nrf52dk_nrf52832
-- Cache files will be written to: /home/joe/.cache/zephyr
ZEPHYR_TOOLCHAIN_VARIANT not set, trying to locate Zephyr SDK
-- Found toolchain: zephyr (/home/joe/zephyr-sdk-0.11.4)
-- Found dtc: /home/joe/zephyr-sdk-0.11.4/sysroots/x86_64-pokysdk-linux/usr/bin/dtc (found suitable version "1.5.0", minimum required is "1.4.6")
-- Found BOARD.dts: /home/joe/zephyrproject/zephyr/boards/arm/nrf52dk_nrf52832/nrf52dk_nrf52832.dts
Error: nrf52dk_nrf52832.dts.pre.tmp:415.3-4 syntax error
FATAL ERROR: Unable to parse input tree
CMake Error at /home/joe/zephyrproject/zephyr/cmake/dts.cmake:206 (message):
 command failed with return code: 1
Call Stack (most recent call first):
 /home/joe/zephyrproject/zephyr/cmake/app/boilerplate.cmake:589 (include)
 /home/joe/zephyrproject/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:24 (include)
 /home/joe/zephyrproject/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:102 (include_boilerplate)
 CMakeLists.txt:5 (find_package)


****** And this is the end of the show ******

What is wrong?

Same Error with samples/basic/blinky   and   samples/bluetooth/beacon (the one I tested).
Guess it is the same with ALL "samples" that use "nrf52dk_nrf52832",
When I test with "nrf52dk_nrf52810", it is OK

Parents
  • Hi Jan Ove,

    I will be looking into your case this afternoon.

    Best regards,

    Håkon

  • Hi Jan Ove,

    Sorry for keeping you waiting. Is it possible that you have several versions of Zephyr installed, and that some of the tools are referencing one version and some are referencing another version. Are you able to install Toolchain Manager? If so, and you then run into problems, it will be easier for us to reproduce the error.

    Building for both nrf52dk_nrf52832 and nrf52_nrf52832 works here.

    Håkon

  • After a break during the Christmas and New Year weekend, I have now managed to compile the loramac-node sample, library and drivers for the nRF52832 chip. This library is missing in the "nrfconnect" repo, so I did it in the original Zephyr repo. After my latest update of the Zephyr repo, I noticed a new board, "b_l072z_lrwan1", that work together with the LoRaWan sample.
    By "analyzing" the board files for the two
    STM32 lora boards and the board files for nrf52dk_nrf52832, I managed to make board files for all off my nRF52832 boards, including nrf52dk_nrf52832 with the SX1276MB1MAS shield.
    I have NOT tested if the code run properly, but I think it is only a matter of getting the signals to the
    SX1276 radio right. The different boards use different ways of handling pa_boost and antenna switches. So after a closer look at the drivers I hope it should be a manageable task to get the code run on the nRF52832 target.

  • The nrf52dk_nrf52832 board with the SX1276MB1MAS shield, join the LoRaWan network and send data to the TTN server.
    The only thing needed is the board definition files that describe the nrf52dk_nrf52832 with the SX1276MB1MAS shield.

  • Hi Jan Ove. Would you be able to share your project? I could create an internal request to have the board definition files created. However, I do not promise if or when they would be ready.

  • It is not much to share.

    If you modify the "~/zephyrproject/zephyr/boards/arm/nrf52dk_nrf52832/nrf52dk_nrf52832.dts" file like this:

    Add this line to the alias section (around line 124):

    		lora0 = &lora;

    And replace the definition of "&spi1 {....." with the following:

    &spi1 {
    	compatible = "nordic,nrf-spi";
    	status = "okay";
    	sck-pin = <25>;
    	mosi-pin = <23>;
    	miso-pin = <24>;
    	cs-gpios = <&gpio0 22 GPIO_ACTIVE_LOW>;
    
    	lora: sx1276@0 {
    		compatible = "semtech,sx1276";
    		reg = <0>;
    		label = "sx1276";
    
    		dio-gpios = <&gpio0 13 (GPIO_PULL_DOWN | GPIO_ACTIVE_HIGH)>,
    					<&gpio0 14 (GPIO_PULL_DOWN | GPIO_ACTIVE_HIGH)>,
    					<&gpio0 15 (GPIO_PULL_DOWN | GPIO_ACTIVE_HIGH)>,
    					<&gpio0 16 (GPIO_PULL_DOWN | GPIO_ACTIVE_HIGH)>,
    					<&gpio0 29 (GPIO_PULL_DOWN | GPIO_ACTIVE_HIGH)>;
    		reset-gpios = <&gpio0 3 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>;
    		rfo-enable-gpios		 = 	<&gpio0 30 GPIO_ACTIVE_HIGH>;
    		spi-max-frequency		 = 	<1000000>;
    		power-amplifier-output	 = "rfo";
    
    /*
    		rfi-enable-gpios			= <&gpio0 xx GPIO_ACTIVE_HIGH>;
    		power-amplifier-output		= "pa-boost";
    		pa-boost-enable-gpios		= <&gpio0 xx GPIO_ACTIVE_HIGH>;
    		antenna-enable-gpios		= <&gpio0 xx GPIO_ACTIVE_HIGH>;
    		tcxo-power-gpios			= <&gpio0 xx GPIO_ACTIVE_HIGH>;
    		tcxo-power-startup-delay-ms	= <5>;
    */
    	};
    };
    

    The "~/zephyrproject/zephyr/samples/lorawan/class_a/" should compile for the nrf52dk_nrf52832 board, with the SX1276MB1MAS shield.
    The SX1276MB1MAS need a small modification as described in my "pca_10040_mas_h" file at line 147, earlier in this tread.

    I run the commands:
    rm -r *; cmake -DBOARD=nrf52dk_nrf52832   ..
    make

    nrfjprog -f nrf52 --program ./zephyr/zephyr.hex --sectorerase
    nrfjprog -f nrf52 --reset

    And the board start sending data to the LoRaWan network.

    I modified the sample main.c file a little bit, mine is like this:

    /*
     * Class A LoRaWAN sample application
     *
     * Copyright (c) 2020 Manivannan Sadhasivam <[email protected]>
     *
     * SPDX-License-Identifier: Apache-2.0
     */
    
    #include <device.h>
    #include <lorawan/lorawan.h>
    #include <../../modules/lib/loramac-node/src/mac/LoRaMacTest.h>
    #include <zephyr.h>
    #include <stdio.h>
    
    #define DEFAULT_RADIO_NODE DT_ALIAS(lora0)
    BUILD_ASSERT(DT_NODE_HAS_STATUS(DEFAULT_RADIO_NODE, okay),
    	     "No default LoRa radio specified in DT");
    #define DEFAULT_RADIO DT_LABEL(DEFAULT_RADIO_NODE)
    
    /* Customize based on network configuration */
    // 				https://console.thethingsnetwork.org/applications/n2_tst/devices/tr_5
    // Device ID				tr_5
    // Activation Method		OTAA
    // Device EUI				00AD427217B6132A	msb{ 0x00, 0xAD, 0x42, 0x72, 0x17, 0xB6, 0x13, 0x2A }
    // Application EUI			70B3D57ED0036F9B	msb{ 0x70, 0xB3, 0xD5, 0x7E, 0xD0, 0x03, 0x6F, 0x9B }		// Application ID	n2_tst
    // 
    // App Key					733D08BD55DBE0643D1E3BC6A7C73B44	msb{ 0x73, 0x3D, 0x08, 0xBD, 0x55, 0xDB, 0xE0, 0x64, 0x3D, 0x1E, 0x3B, 0xC6, 0xA7, 0xC7, 0x3B, 0x44 }
    // 
    // Example Code
    // const char *appEui = "70B3D57ED001230C";
    // const char *appKey = "733D08BD55DBE0643D1E3BC6A7C73B44";
    
    // #define LORAWAN_DEV_EUI		{ 0xDD, 0xEE, 0xAA, 0xDD, 0xBB, 0xEE, 0xEE, 0xFF }
    // #define LORAWAN_JOIN_EUI		{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }
    // #define LORAWAN_APP_KEY		{ 0x2B, 0x7E, 0x15, 0x16, 0x28, 0xAE, 0xD2, 0xA6, 0xAB, 0xF7, 0x15, 0x88, 0x09, 0xCF, 0x4F, 0x3C }
    #define LORAWAN_DEV_EUI			{ 0x00, 0xAD, 0x42, 0x72, 0x17, 0xB6, 0x13, 0x2A }
    #define LORAWAN_JOIN_EUI		{ 0x70, 0xB3, 0xD5, 0x7E, 0xD0, 0x03, 0x6F, 0x9B }
    #define LORAWAN_APP_KEY			{ 0x73, 0x3D, 0x08, 0xBD, 0x55, 0xDB, 0xE0, 0x64, 0x3D, 0x1E, 0x3B, 0xC6, 0xA7, 0xC7, 0x3B, 0x44 }
    
    
    #define DELAY K_MSEC(30000)
    
    #define LOG_LEVEL CONFIG_LOG_DEFAULT_LEVEL
    #include <logging/log.h>
    LOG_MODULE_REGISTER(lorawan_class_a);
    
    // char data[] = {'h', 'e', 'l', 'l', 'o', 'w', 'o', 'r', 'l', 'd'};
    char data[100];
    
    void main(void)
    {
    	const struct device *lora_dev;
    	struct lorawan_join_config join_cfg;
    	
    	uint8_t dev_eui[]	= LORAWAN_DEV_EUI;
    	uint8_t join_eui[]	= LORAWAN_JOIN_EUI;
    	uint8_t app_key[]	= LORAWAN_APP_KEY;
    	int ret, loop_cnt, err_cnt;
    
    	LOG_INF("***** Starting LoRaWan Sample *****\n");
    	
    	if( !(lora_dev = device_get_binding(DEFAULT_RADIO)) ){
    		LOG_ERR("%s Device not found", DEFAULT_RADIO);	return;
    	}
    
    	if((ret = lorawan_start()) < 0){
    		LOG_ERR("lorawan_start failed: %d", ret);	return;
    	}
    
    	join_cfg.mode			= LORAWAN_ACT_OTAA;
    	join_cfg.dev_eui		= dev_eui;
    	join_cfg.otaa.join_eui	= join_eui;
    	join_cfg.otaa.app_key	= app_key;
    	join_cfg.otaa.nwk_key	= app_key;
    
    // 	lorawan_enable_adr(0);				// Turn ADR off
    	lorawan_enable_adr(1);				// Turn ADR on
        LoRaMacTestSetDutyCycleOn(0);		// Turn DutyCycle Restrictions off, For testing purposes onely (must #include <../../modules/lib/loramac-node/src/mac/LoRaMacTest.h>)
    
    	LOG_INF("Joining network over OTAA");
    	if((ret = lorawan_join(&join_cfg)) < 0) {
    		LOG_ERR("\tlorawan_join_network failed: %d", ret);	return;
    	}
    
    	err_cnt = loop_cnt = 0;
    	while(1) {
    		loop_cnt++;
    		LOG_INF("Sending data %d %d ...", loop_cnt, err_cnt);
    // 		ret = lorawan_send(2, data, sizeof(data), LORAWAN_MSG_CONFIRMED);
    		sprintf(data, "Hello %d %d", loop_cnt, err_cnt);
    
    		/*
    		 * Note: The stack may return -EAGAIN if the provided data
    		 * length exceeds the maximum possible one for the region and
    		 * datarate. But since we are just sending the same data here,
    		 * we'll just continue.
    		 */
    		if( ((ret = lorawan_send(2, data, strlen(data), 0)) == -EAGAIN) || ret < 0){
    			LOG_ERR("\tlorawan_send failed: %d %d %d. Continuing...", ret, loop_cnt, err_cnt);
    			if(err_cnt++ > 8){
    				LOG_ERR("\tError End %d %d %d", ret, loop_cnt, err_cnt);
    				return;
    			}
    			k_sleep(DELAY);	continue;
    		}
    
    		LOG_INF("\tData sent! %d %d %d", ret, loop_cnt, err_cnt);
    		k_sleep(DELAY);
    	}
    }
    

    But, of cause, you need a LoRaWan gateway and an account at TTN server and a registered device, for the example to do something meaningful.

    And, the lorawan stack is experimental and need some improvements, I fond some problems with the antenna switch logic, not all combinations work and it can not receive data from the network. But for me, this is a starting point, and, as I'm new to Zephyr, I need to learn more about Zephyr.

  • Thank you for sharing your work. I will keep you updated regarding adding support for nRF52 DK for the SX1276MB1MAS shield.

Reply Children
No Data
Related