Hi,
I am trying to configure GPIOs with a custom DTS file, for initial bring-up and testing of the PCBA prior to higher-level development. During compile, I am getting a message "FATAL ERROR: command exited with status 1: 'c:\ncs\toolchains\v2.0.0\opt\bin\cmake.EXE' --build 'c:\nordic\V1_man-in-middle_new\build'", but there I am not seeing any issues in the 'problems' tab of VS code.
If I comment out line 42, the compile executes cleanly.
if (!device_is_ready(led0.port)) { return; }
Do you have any recommendations of where to start looking to debug this?
/* * Copyright (c) 2012-2014 Wind River Systems, Inc. * * SPDX-License-Identifier: Apache-2.0 */ #include <zephyr.h> #include <sys/printk.h> #include <device.h> #include <drivers/pwm.h> #include <drivers/gpio.h> // Define the pins in the Nordic connection // Bar Light #define LED0_NODE DT_ALIAS(ledbar0) #define LED1_NODE DT_ALIAS(ledbar1) #define LED2_NODE DT_ALIAS(ledbar2) #define LED3_NODE DT_ALIAS(ledbar3) // Button lights #define LEDBL_NODE DT_ALIAS(ledbuttonl) #define LEDBR_NODE DT_ALIAS(ledbuttonr) // Generate structs for LEDs static const struct gpio_dt_spec led0 = GPIO_DT_SPEC_GET(LED0_NODE, gpios); static const struct gpio_dt_spec led1 = GPIO_DT_SPEC_GET(LED1_NODE, gpios); static const struct gpio_dt_spec led2 = GPIO_DT_SPEC_GET(LED2_NODE, gpios); static const struct gpio_dt_spec led3 = GPIO_DT_SPEC_GET(LED3_NODE, gpios); static const struct gpio_dt_spec ledBL = GPIO_DT_SPEC_GET(LEDBL_NODE, gpios); static const struct gpio_dt_spec ledBR = GPIO_DT_SPEC_GET(LEDBR_NODE, gpios); // // switches // #define SW0_NODE DT_ALIAS(buttonl) // #define SW1_NODE DT_ALIAS(buttonr) // static const struct gpio_dt_spec button0 = GPIO_DT_SPEC_GET(SW0_NODE, gpios); // static const struct gpio_dt_spec button1 = GPIO_DT_SPEC_GET(SW1_NODE, gpios); void main(void) { int ret; if (!device_is_ready(led0.port)) { return; } // /* // Verify that the device is ready for use // if (!device_is_ready(button0.port)) { // return; // } */ // ret = gpio_pin_configure_dt(&led0, GPIO_OUTPUT_ACTIVE); // ret += gpio_pin_configure_dt(&led1, GPIO_OUTPUT_ACTIVE); // ret += gpio_pin_configure_dt(&led2, GPIO_OUTPUT_ACTIVE); // ret += gpio_pin_configure_dt(&led3, GPIO_OUTPUT_ACTIVE); // if (ret < 0) { // return; // } // ret = gpio_pin_configure_dt(&button0, GPIO_INPUT); while(1){ /* Read the status of the button and store it */ // bool val = gpio_pin_get_dt(&button0); /* STEP 6.2 - Update the LED to the status of the button */ // gpio_pin_toggle_dt(&led0); // gpio_pin_toggle_dt(&led1); // gpio_pin_toggle_dt(&led2); // gpio_pin_toggle_dt(&led3); k_msleep(1000); // Put the main thread to sleep for 100ms for power optimization } }
DTS file:
// Copyright (c) 2022 Nordic Semiconductor ASA // SPDX-License-Identifier: Apache-2.0 /dts-v1/; #include <nordic/nrf52840_qiaa.dtsi> / { model = "10_000010_00_Throttle_Splitter"; compatible = "fifteen-motors,10-000010-00-throttle-splitter"; chosen { zephyr,sram = &sram0; zephyr,flash = &flash0; zephyr,code-partition = &slot0_partition; }; leds { compatible = "gpio-leds"; ledbar0: led_0 { gpios = <&gpio0 14 GPIO_ACTIVE_LOW>; label = "LED Bar 0"; }; ledbar1: led_1 { gpios = <&gpio0 15 GPIO_ACTIVE_LOW>; label = "LED Bar 1"; }; ledbar2: led_2 { gpios = <&gpio0 16 GPIO_ACTIVE_LOW>; label = "LED Bar 2"; }; ledbar3: led_3 { gpios = <&gpio0 17 GPIO_ACTIVE_LOW>; label = "LED Bar 3"; }; ledbuttonl: led_l { gpios = <&gpio0 24 GPIO_ACTIVE_LOW>; label = "LED Button Left"; }; ledbuttonr: led_r { gpios = <&gpio0 25 GPIO_ACTIVE_LOW>; label = "LED Button Right"; }; }; /* These aliases are provided for compatibility with samples */ aliases { // buttonl = &buttonl; // buttonr = &buttonr; ledbar0 = &ledbar0; ledbar1 = &ledbar1; ledbar2 = &ledbar2; ledbar3 = &ledbar3; ledbuttonl = &ledbuttonl; ledbuttonr = &ledbuttonr; }; }; &gpiote { status = "okay"; }; &gpio0 { status = "okay"; }; &gpio1 { status = "okay"; }; &flash0 { partitions { compatible = "fixed-partitions"; #address-cells = <1>; #size-cells = <1>; boot_partition: partition@0 { label = "mcuboot"; reg = <0x0 0xc000>; }; slot0_partition: partition@c000 { label = "image-0"; reg = <0xc000 0x72000>; }; slot1_partition: partition@7e000 { label = "image-1"; reg = <0x7e000 0x72000>; }; scratch_partition: partition@f0000 { label = "image-scratch"; reg = <0xf0000 0xa000>; }; storage_partition: partition@fa000 { label = "storage"; reg = <0xfa000 0x6000>; }; }; };