Unsupported Pin GPIO error with SDK 2.6.0

Hi,

We have developed our code against SDK 2.3.0 and I wanted to try to upgrade the SDK to 2.6.0. I had to remove CONFIG_OPENTHREAD_CHILD_SUPERVISION from my prj.conf, but after that the project was build. But when I flashed the new hex, it seems just hanged. There are no other code changes.

I tried debugging from the start to see where this happens. It occurs from the call to dk_leds_init (). 

I can trace the execution path down to 

static inline int z_impl_gpio_pin_configure(const struct device *port,
                        gpio_pin_t pin,
                        gpio_flags_t flags)
in gpio.h.
The error occurs in the line 1001.
__ASSERT((cfg->port_pin_mask & (gpio_port_pins_t)BIT(pin)) != 0U"Unsupported pin");
There are no changes to the device tree. 
This is what I have in leds section of my device tree overlay. 
	leds {
		compatible = "gpio-leds";
		led0: led_0 {
			gpios = <&gpio0 23 GPIO_ACTIVE_HIGH>;  // Rev1.0 	0.16-Blue
			label = "Blue LED";
			status = "okay";
		};
		led1: led_1 {
			gpios = <&gpio0 21 GPIO_ACTIVE_HIGH>;	// Rev1.0 	0.20-Red
			label = "RED LED";
			status = "okay";
		};
		led2: led_2 {
			gpios = <&gpio0 26  GPIO_ACTIVE_HIGH>;	// Rev1.0 	0.17-GREEN
			label = "Green LED";
			status = "okay";
		};
		led3: led_3 {
			gpios = <&gpio0 12 GPIO_ACTIVE_HIGH>;	// NTC_EN	Rev 1.0 - 1.9
			label = "NTC_EN";
			status = "okay";
		};
		led4: led_4 {
			gpios = <&gpio0 22 GPIO_ACTIVE_HIGH>;  // This is to compansate for Rev 1.2 with Minew and without Minew designs
			label = "Blue1 LED";
			status = "okay";
		};
		led5: led_5 {
			gpios = <&gpio0 24 GPIO_ACTIVE_HIGH>;	// This is to compansate for Rev 1.2 with Minew and without Minew designs
			label = "RED1 LED";
			status = "okay";
		};
	};
What could be going wrong here?
Cheers,
Kaushalya
  • What was the pin number that is giving the error? 

    Can you show the code snippet of how you call this? or maybe step to see if port_pin_mask have value different in v2.6.0 than in v2.3.0? If So, then maybe the GPIO driver configuration is not set correctly. Are you sure that CONFIG_GPIO_NRFX is set in your prj.conf? check the ".config" file in your build folder to see if this is set to y.

  • Hi Susheel,

    What was the pin number that is giving the error?

    Thanks for your reply. The error comes from the first, GPIO_0, Pin 23. 

    Can you show the code snippet of how you call this?

    In my code it starts with

    ret = dk_leds_init();

    dk_leds_init () function is defined in dk)buttons_and_leds.c. It defines leds [] as

    #define GPIO_SPEC_AND_COMMA(button_or_led) GPIO_DT_SPEC_GET(button_or_led, gpios),
    
    static const struct gpio_dt_spec leds[] = {
    #if DT_NODE_EXISTS(LEDS_NODE)
    	DT_FOREACH_CHILD(LEDS_NODE, GPIO_SPEC_AND_COMMA)
    #endif
    };

    in dk_leds_init () function 

    err = gpio_pin_configure_dt(&leds[i], GPIO_OUTPUT);

    gpio_pin_configure_dt (...) is defined in gpio.h.

    maybe step to see if port_pin_mask have value different in v2.6.0 than in v2.3.0

    Yes they are different!! In 2.3.0 it is 0xffffffff and in 2.6.0 it is 0xff01f8bc. I previously didnt have the CONFIG_GPIO_NRFX enabled in my prj.conf. But even with that enabled, no difference to end result. Following are two screen shots of the debug window highlighting the differences.

    Only other difference I did between the two builds is enabling/disabling  CONFIG_OPENTHREAD_CHILD_SUPERVISION, which I doubt has any influence.

    Whats going on here?

    Cheers,

    Kaushalya

  • I can reproduce this on the DK.

    diving more in, it goes into the definition of the &gpio0 in ncs\v2.6.1\zephyr\boards\arm\nrf52840dk_nrf52840\nrf52840dk_nrf52840.dts. If you look into this

    &gpio0 {
    	status = "okay";
    	gpio-reserved-ranges = <0 2>, <6 1>, <8 3>, <17 7>;

    You see that set <17 7> meaning gpio pin number from 17-23 are reserved. If you look in the back of the nRF52830 DK, you can see that this pins are connected to different things and hence not usable for anything else on the DK. If you have a custom board and if you are sure that these pins are free to use for the application, then you need to change the gpio-reserved-ranges in your overlay file.

  • Hi Susheel,

    Thanks. When I upgrade my 2.3.0 project to 2.6.0, what I did was 

    1. From NRF CONNECT ->Welcome->Manage toolchains, pick 2.6.0 toolchain and set as active

    2. From NRF CONNECT ->Welcome->Manage SDKs, pick 2.6.0 SDK and set as active

    I can see from bottom right corner that 2.6.0 toolchain and SDK are active. But when I check nrf52840dk_nrf52840.dts path from the Devicetree node, it points to my old dts file from 2.3.0 SDK. How can I fix this?

    Another thing I noted is that my project pane shows an error in my kconfig. The error seems to be in 

    source "Kconfig.zephyr"
    and higlighted error shows "couldn't parse 'default $(dt_gpio_hogs_enabled)': macro expanded to blank string" But the project can be built successfully.

    Cheers,

    Kaushalya

  • Ok I managed to fix the first issue of dts file path. I rerun the build configurations and reselect the board again. Then the path get set to SDK 2.6.0.

    The second issue still remains, the kconfig file error. This is the kconfig file in my project root. 

Related