CONFIG_NET_L2_OPENTHREAD=y leads to failure in gpio pins.

Hi,

I noticed an issue with CONFIG_NET_L2_OPENTHREAD=y in my project, and I prepared a newer, simpler project to investigate in the issue.

The new program simply sets pins to high and low. After flashing it onto an external module and plugging the external module onto a baseboard, all of the LEDs on the base board should be flashing one by one in a cycle..

As I slowly add more configurations to prj.conf, I realize that adding CONFIG_NET_L2_OPENTHREAD=y when CONFIG_NETWORKING=y will lead to all the external module pins behaving unexpectedly. None of the LEDs on the base board will turn on. What does CONFIG_NET_L2_OPENTHREAD do exactly? How does it interfere with the gpio pins? 

Parents Reply Children
  • Hi Maria,

    Thank you, I have read over the documentations, but I don't think they provide enough information as they're supposed to be abstract; 

    On the 54L15, the pins are fine if I have CONFIG_NET_L2_OPENTHREAD, everything works out. 

    The simple program was built on top of the blinky sample.

    Here is the modified main.c:

    #include <stdio.h>
    #include <zephyr/kernel.h>
    #include <zephyr/device.h>
    #include <zephyr/devicetree.h>
    #include <zephyr/drivers/gpio.h>
    #include <nrf.h>
    
    
    // /* 1000 msec = 1 sec */
    #define SLEEP_TIME_MS   500
    #define LED_COUNT 16
    
    #define PIN_NODE(n) DT_ALIAS(pind##n)
    #define PIN_SPEC(n) GPIO_DT_SPEC_GET(PIN_NODE(n),gpios)
    
    static const struct gpio_dt_spec testleds[LED_COUNT] = {
    	PIN_SPEC(1),PIN_SPEC(2),PIN_SPEC(8),PIN_SPEC(7),
    	PIN_SPEC(6),PIN_SPEC(5),PIN_SPEC(4),PIN_SPEC(3),
    	PIN_SPEC(16),PIN_SPEC(15),PIN_SPEC(14),PIN_SPEC(13),
    	PIN_SPEC(12),PIN_SPEC(11),PIN_SPEC(9),PIN_SPEC(10)
    };
    
    void disableNFC(void){
    	NRF_NFCT->PADCONFIG = 0;
    }
    
    int main(void)
    {
    	int ret;
    	disableNFC();
    	//static const struct device *gpio2_dev;  // Declare the GPIO device
    	//gpio2_dev = DEVICE_DT_GET(DT_NODELABEL(gpio2));
    
    	for(int i = 0; i<LED_COUNT;i++) {
    		if(!device_is_ready(testleds[i].port)) {
    			return 0;
    		}
    		ret = gpio_pin_configure_dt(&testleds[i],GPIO_OUTPUT_ACTIVE);
    		if(ret < 0) printf("pin setting error\n");
    	}
    
    	for(int i = 0; i< LED_COUNT;i++) {
    		if(i<8)	gpio_pin_set_dt(&testleds[i],1);
    		else gpio_pin_set_dt(&testleds[i],0);
    	}
    //gpio_pin_configure(gpio2_dev, GPIO5_PIN, GPIO_OUTPUT);
    //gpio_pin_configure_dt(&pinD1,GPIO_OUTPUT_ACTIVE);
    
    	while (1) {
    		for(int i=0;i<LED_COUNT;i++) {
    			if(i<8)	gpio_pin_set_dt(&testleds[i],0);
    			else gpio_pin_set_dt(&testleds[i],1);
    			k_msleep(SLEEP_TIME_MS);
    			printk("Pin level: %d\n", gpio_pin_get_dt(&testleds[i]));
    			if(i<8) gpio_pin_set_dt(&testleds[i],1);
    			else gpio_pin_set_dt(&testleds[i],0);
    			k_msleep(SLEEP_TIME_MS);
    			printk("Pin level: %d\n", gpio_pin_get_dt(&testleds[i]));
    		}
    	}
    }

    overlay file:

    // &spi00 {
    //     status = "disabled";  // Force disable SPI1 so its pins become GPIO
    // };
    
    // &uart20 {
    // 	status = "disabled";
    // };
    
    // &uart30 {
    // 	status = "disabled";
    // };
    
    // &pwm20 {
    // 	status = "disabled";
    // };
    
    // &button0 {
    // 	status = "disabled";
    // };
    
    // &button1 {
    // 	status = "disabled";
    // };
    
    // &button2 {
    // 	status = "disabled";
    // };
    
    // &led0 {
    // 	status = "disabled";
    // };
    
    // &led1 {
    // 	status = "disabled";
    // };
    // &led2 {
    // 	status = "disabled";
    // };
    
    &gpio0 {
    	status = "okay";
    };
    
    &nfct {
    	status = "disabled";
    };
    
    &gpio1 {
    	status = "okay";
    };
    
    &gpio2 {
    	status = "okay";
    };
    
    
    /{
    custom_gpios {
    	compatible = "gpio-keys";
    
    	pin_D1: pin_p2_05 {	gpios = <&gpio2 5 GPIO_ACTIVE_HIGH>;};	//no
    	pin_D2: pin_p2_03 {	gpios = <&gpio2 3 GPIO_ACTIVE_HIGH>;};	//no
    	pin_D8: pin_p1_06 {	gpios = <&gpio1 6 GPIO_ACTIVE_HIGH>;};	
    	pin_D7: pin_p1_07 {	gpios = <&gpio1 7 GPIO_ACTIVE_HIGH>;};
    	pin_D6: pin_p1_08 {	gpios = <&gpio1 8 GPIO_ACTIVE_HIGH>;};
    	pin_D10: pin_p2_09 {gpios = <&gpio2 9 GPIO_ACTIVE_HIGH>;};
    	pin_D9: pin_p2_10 {	gpios = <&gpio2 10 GPIO_ACTIVE_HIGH>;};
    	pin_D5: pin_p1_11 {	gpios = <&gpio1 11 GPIO_ACTIVE_HIGH>;};
    	pin_D4: pin_p1_10 {	gpios = <&gpio1 10 GPIO_ACTIVE_HIGH>;};
    	pin_D3: pin_p1_09 {	gpios = <&gpio1 9 GPIO_ACTIVE_HIGH>;};
    	pin_D11: pin_p1_04 {gpios = <&gpio1 4 GPIO_ACTIVE_HIGH>;};
    	pin_D12: pin_p1_03 {gpios = <&gpio1 3 GPIO_ACTIVE_HIGH>;};//no
    	pin_D13: pin_p1_02 {gpios = <&gpio1 2 GPIO_ACTIVE_HIGH>;};//no
    	pin_D14: pin_p2_00 {gpios = <&gpio2 0 GPIO_ACTIVE_HIGH>;};//no
    	pin_D15: pin_p2_01 {gpios = <&gpio2 1 GPIO_ACTIVE_HIGH>;};//no
    	pin_D16: pin_p1_13 {gpios = <&gpio1 13 GPIO_ACTIVE_HIGH>;};
    };
    
    // Aliases for easy access to GPIOs
    aliases {
    	pind1 = &pin_D1;
    	pind2 = &pin_D2;
    	pind3 = &pin_D3;
    	pind4 = &pin_D4;
    	pind5 = &pin_D5;
    	pind6 = &pin_D6;
    	pind7 = &pin_D7;
    	pind8 = &pin_D8;
    	pind9 = &pin_D9;
    	pind10 = &pin_D10;
    	pind11 = &pin_D11;
    	pind12 = &pin_D12;
    	pind13 = &pin_D13;
    	pind14 = &pin_D14;
    	pind15 = &pin_D15;
    	pind16 = &pin_D16;
    };
    };

    prj.conf (with CONFIG_NETWORKING and CONFIG_NET_L2_OPENTHREAD):

    CONFIG_GPIO=y
    CONFIG_LOG=y
    CONFIG_USE_SEGGER_RTT=y
    CONFIG_RTT_CONSOLE=y
    CONFIG_LOG_BACKEND_RTT=y
    CONFIG_UART_CONSOLE=n
    CONFIG_SERIAL=n
    CONFIG_STDOUT_CONSOLE=y
    CONFIG_PRINTK=y
    CONFIG_GPIO_INIT_PRIORITY=40
    CONFIG_NETWORKING=y
    CONFIG_NET_L2_OPENTHREAD=y

    If we simply take out CONFIG_NET_L2_OPENTHREAD from prj.conf, my external module will successfully blink the LEDs on the base board one by one in a cycle. However, adding it back in, nothing lights up. 

    Best regards,

    Allan

  • Hi Maria, 

    Just an update, I updated my project to an even simpler one, it will just print Hello World + iteration number over and over again. I can view the message through RTT when CONFIG_NET_L2_OPENTHREAD is not enabled. However, I tried enabling the configuration, I can no longer view the messages. Thus, this might be something more significant than just having a conflict with the GPIO pins, as RTTs will not even display any messages. 

    #include <stdio.h>
    #include <zephyr/kernel.h>
    int main() {
    	int i = 0;
    	while (1) {
    		printk("Hello World! %d\n", i++);
    		k_msleep(1000);
    	}
    	return 1;
    }

Related