Hardware Abstraction nRF52840-dongle nRF52840-DK

I have a sample program, threads, that I have working on the dongle, however, when I try and build it for the DK, it fails. The program has the following statements in it:

#define LED0_NODE DT_ALIAS(led0)
#define LED1_RED_NODE DT_ALIAS(led1_red)
#define LED1_GREEN_NODE DT_ALIAS(led1_green)
#define LED1_BLUE_NODE DT_ALIAS(led1_blue)

...

static const struct led led0 = {
.spec = GPIO_DT_SPEC_GET_OR(LED0_NODE, gpios, {0}),
.num = 0,
};

static const struct led led1_red = {
.spec = GPIO_DT_SPEC_GET_OR(LED1_RED_NODE, gpios, {0}),
.num = 1,
};

static const struct led led1_green = {
.spec = GPIO_DT_SPEC_GET_OR(LED1_GREEN_NODE, gpios, {0}),
.num = 2,
};

static const struct led led1_blue = {
.spec = GPIO_DT_SPEC_GET_OR(LED1_BLUE_NODE, gpios, {0}),
.num = 3,
};

#if !DT_NODE_HAS_STATUS(LED0_NODE, okay)
#error "Unsupported board: led0 devicetree alias is not defined"
#endif

I have no idea where LED0_NODE is defined; the string does not appear in any of my application directories. But clearly is defined somewhere because the build process finds it when I build it for the dongle but doesn't when I build for the DK.

I assume this is some kind of hardware abstraction but I don't understand how it works; can anyone of you help?

Parents
  • Hi Jerry,

    Thank you for contacting DevZone at NordicSemi.

    It is good to see that you are starting using Nordic SoC and NCS.

    I have also seen your other questions, so as such, I understand that starting with new H/W and SDK could be demanding, and therefore I would highly recommend you go through Nordic DevAcademy NRF Connect SDK Fundamentals course. It will not only clarify most of your questions, but will also provide you with understanding to start developing with NCS+NRF-chips. 

    Regarding your question:

    If you are using a sample from NCS, then please note that all boards are not supported, and list of supported boards or required changes are listed on the sample read-me / info page.

    This also applies to any project designed for specific hardware / board.

    The reason is that all boards are not same, and that is exactly the problem you are facing.

    In the Dongle DTS (Device tree structure), we have definitions of green, red, blue leds:

    So if your code (C program) is referring to any of these colored leds, then these nodes need to be present on the hardware (in the DTS files).

    As your code is using these leds, and these leds are defined for the Dongle, but not for the DK, that's why you are getting error while building for the DK.

    I recommend you do the following:

    Create a new application in NCS 2.3.0
    Choose blinky_pwm sample
    Build it for the dongle
        see compiled DTS (/build/zephyr/zephyr.dts)
        see definition of leds
    Build it for the DK
        see compiled DTS
        see definition of leds
    

    Hope it helps

    Regards,

    Naeem

Reply
  • Hi Jerry,

    Thank you for contacting DevZone at NordicSemi.

    It is good to see that you are starting using Nordic SoC and NCS.

    I have also seen your other questions, so as such, I understand that starting with new H/W and SDK could be demanding, and therefore I would highly recommend you go through Nordic DevAcademy NRF Connect SDK Fundamentals course. It will not only clarify most of your questions, but will also provide you with understanding to start developing with NCS+NRF-chips. 

    Regarding your question:

    If you are using a sample from NCS, then please note that all boards are not supported, and list of supported boards or required changes are listed on the sample read-me / info page.

    This also applies to any project designed for specific hardware / board.

    The reason is that all boards are not same, and that is exactly the problem you are facing.

    In the Dongle DTS (Device tree structure), we have definitions of green, red, blue leds:

    So if your code (C program) is referring to any of these colored leds, then these nodes need to be present on the hardware (in the DTS files).

    As your code is using these leds, and these leds are defined for the Dongle, but not for the DK, that's why you are getting error while building for the DK.

    I recommend you do the following:

    Create a new application in NCS 2.3.0
    Choose blinky_pwm sample
    Build it for the dongle
        see compiled DTS (/build/zephyr/zephyr.dts)
        see definition of leds
    Build it for the DK
        see compiled DTS
        see definition of leds
    

    Hope it helps

    Regards,

    Naeem

Children
No Data
Related