Error building with Custom board

Hello 

I get the following error code, when I try to build the button sample with my custom board. I try to build and flash via RTT Hello World with my  custom board and it works. However the button sample doesnt work. I think there is something wrong with my devicetree of the customboard. But Hello World works with it.

You have an idea?

FAILED: CMakeFiles/app.dir/src/main.c.obj 
C:\Users\dkahya\nordic\ncs\toolchains\31f4403e35\opt\zephyr-sdk\arm-zephyr-eabi\bin\arm-zephyr-eabi-gcc.exe -DKERNEL -DNRF52832_XXAA -DUSE_PARTITION_MANAGER=0 -D__PROGRAM_START -D__ZEPHYR__=1 -IC:/Users/dkahya/nordic/ncs/v2.4.0/zephyr/include -Izephyr/include/generated -IC:/Users/dkahya/nordic/ncs/v2.4.0/zephyr/soc/arm/nordic_nrf/nrf52 -IC:/Users/dkahya/nordic/ncs/v2.4.0/zephyr/soc/arm/nordic_nrf/common/. -IC:/Users/dkahya/nordic/ncs/v2.4.0/nrf/include -IC:/Users/dkahya/nordic/ncs/v2.4.0/nrf/tests/include -IC:/Users/dkahya/nordic/ncs/v2.4.0/modules/hal/cmsis/CMSIS/Core/Include -IC:/Users/dkahya/nordic/ncs/v2.4.0/modules/hal/nordic/nrfx -IC:/Users/dkahya/nordic/ncs/v2.4.0/modules/hal/nordic/nrfx/drivers/include -IC:/Users/dkahya/nordic/ncs/v2.4.0/modules/hal/nordic/nrfx/mdk -IC:/Users/dkahya/nordic/ncs/v2.4.0/zephyr/modules/hal_nordic/nrfx/. -IC:/Users/dkahya/nordic/ncs/v2.4.0/modules/debug/segger/SEGGER -IC:/Users/dkahya/nordic/ncs/v2.4.0/modules/debug/segger/Config -IC:/Users/dkahya/nordic/ncs/v2.4.0/zephyr/modules/segger/. -isystem C:/Users/dkahya/nordic/ncs/v2.4.0/zephyr/lib/libc/minimal/include -isystem c:/users/dkahya/nordic/ncs/toolchains/31f4403e35/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/include -isystem c:/users/dkahya/nordic/ncs/toolchains/31f4403e35/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/include-fixed -fno-strict-aliasing -Os -imacros C:/Users/dkahya/nordic/myapps/I_Ansteuern_Leds/build_1/zephyr/include/generated/autoconf.h -ffreestanding -fno-common -g -gdwarf-4 -fdiagnostics-color=always -mcpu=cortex-m4 -mthumb -mabi=aapcs --sysroot=C:/Users/dkahya/nordic/ncs/toolchains/31f4403e35/opt/zephyr-sdk/arm-zephyr-eabi/arm-zephyr-eabi -imacros C:/Users/dkahya/nordic/ncs/v2.4.0/zephyr/include/zephyr/toolchain/zephyr_stdint.h -Wall -Wformat -Wformat-security -Wno-format-zero-length -Wno-pointer-sign -Wpointer-arith -Wexpansion-to-defined -Wno-unused-but-set-variable -Werror=implicit-int -fno-pic -fno-pie -fno-asynchronous-unwind-tables -fno-reorder-functions --param=min-pagesize=0 -fno-defer-pop -fmacro-prefix-map=C:/Users/dkahya/nordic/myapps/I_Ansteuern_Leds=CMAKE_SOURCE_DIR -fmacro-prefix-map=C:/Users/dkahya/nordic/ncs/v2.4.0/zephyr=ZEPHYR_BASE -fmacro-prefix-map=C:/Users/dkahya/nordic/ncs/v2.4.0=WEST_TOPDIR -ffunction-sections -fdata-sections -std=c99 -nostdinc -MD -MT CMakeFiles/app.dir/src/main.c.obj -MF CMakeFiles\app.dir\src\main.c.obj.d -o CMakeFiles/app.dir/src/main.c.obj -c ../src/main.c
In file included from C:\Users\dkahya\nordic\ncs\v2.4.0\zephyr\include\zephyr\toolchain\gcc.h:92,
                 from C:\Users\dkahya\nordic\ncs\v2.4.0\zephyr\include\zephyr\toolchain.h:50,
                 from C:\Users\dkahya\nordic\ncs\v2.4.0\zephyr\include\zephyr\kernel_includes.h:19,
                 from C:\Users\dkahya\nordic\ncs\v2.4.0\zephyr\include\zephyr\kernel.h:17,
                 from c:\Users\dkahya\nordic\myapps\I_Ansteuern_Leds\src\main.c:7:
C:\Users\dkahya\nordic\ncs\v2.4.0\zephyr\include\zephyr\device.h:84:41: error: '__device_dts_ord_DT_N_S_leds_S_led_1_P_gpios_IDX_0_PH_ORD' undeclared here (not in a function)
   84 | #define DEVICE_NAME_GET(dev_id) _CONCAT(__device_, dev_id)
      |                                         ^~~~~~~~~
C:\Users\dkahya\nordic\ncs\v2.4.0\zephyr\include\zephyr\toolchain\common.h:132:26: note: in definition of macro '_DO_CONCAT'
  132 | #define _DO_CONCAT(x, y) x ## y
      |                          ^
C:\Users\dkahya\nordic\ncs\v2.4.0\zephyr\include\zephyr\device.h:84:33: note: in expansion of macro '_CONCAT'
   84 | #define DEVICE_NAME_GET(dev_id) _CONCAT(__device_, dev_id)
      |                                 ^~~~~~~
C:\Users\dkahya\nordic\ncs\v2.4.0\zephyr\include\zephyr\device.h:210:37: note: in expansion of macro 'DEVICE_NAME_GET'
  210 | #define DEVICE_DT_NAME_GET(node_id) DEVICE_NAME_GET(Z_DEVICE_DT_DEV_ID(node_id))
      |                                     ^~~~~~~~~~~~~~~
C:\Users\dkahya\nordic\ncs\v2.4.0\zephyr\include\zephyr\device.h:227:34: note: in expansion of macro 'DEVICE_DT_NAME_GET'
  227 | #define DEVICE_DT_GET(node_id) (&DEVICE_DT_NAME_GET(node_id))
      |                                  ^~~~~~~~~~~~~~~~~~
C:\Users\dkahya\nordic\ncs\v2.4.0\zephyr\include\zephyr\drivers\gpio.h:331:25: note: in expansion of macro 'DEVICE_DT_GET'
  331 |                 .port = DEVICE_DT_GET(DT_GPIO_CTLR_BY_IDX(node_id, prop, idx)),\
      |                         ^~~~~~~~~~~~~
C:\Users\dkahya\nordic\ncs\v2.4.0\zephyr\include\zephyr\drivers\gpio.h:367:9: note: in expansion of macro 'GPIO_DT_SPEC_GET_BY_IDX'
  367 |         GPIO_DT_SPEC_GET_BY_IDX(node_id, prop, 0)
      |         ^~~~~~~~~~~~~~~~~~~~~~~
c:\Users\dkahya\nordic\myapps\I_Ansteuern_Leds\src\main.c:17:41: note: in expansion of macro 'GPIO_DT_SPEC_GET'
   17 | static const struct gpio_dt_spec led0 = GPIO_DT_SPEC_GET(LED0_NODE, gpios);
      |                                         ^~~~~~~~~~~~~~~~
In file included from C:\Users\dkahya\nordic\ncs\v2.4.0\zephyr\include\zephyr\arch\arm\aarch32\arch.h:20,
                 from C:\Users\dkahya\nordic\ncs\v2.4.0\zephyr\include\zephyr\arch\cpu.h:19,
                 from C:\Users\dkahya\nordic\ncs\v2.4.0\zephyr\include\zephyr\kernel_includes.h:33:
c:\Users\dkahya\nordic\myapps\I_Ansteuern_Leds\build_1\zephyr\include\generated\devicetree_generated.h:2469:29: error: 'DT_N_S_leds_S_led_1_P_gpios_IDX_0_VAL_pin' undeclared here (not in a function); did you mean 'DT_N_S_buttons_S_btn_con_P_gpios_IDX_0_VAL_pin'?
 2469 | #define DT_N_ALIAS_led1     DT_N_S_leds_S_led_1
      |                             ^~~~~~~~~~~~~~~~~~~
C:\Users\dkahya\nordic\ncs\v2.4.0\zephyr\include\zephyr\devicetree.h:4060:9: note: in definition of macro 'DT_CAT7'
 4060 |         a1 ## a2 ## a3 ## a4 ## a5 ## a6 ## a7
      |         ^~
C:\Users\dkahya\nordic\ncs\v2.4.0\zephyr\include\zephyr\devicetree\gpio.h:164:9: note: in expansion of macro 'DT_PHA_BY_IDX'
  164 |         DT_PHA_BY_IDX(node_id, gpio_pha, idx, pin)
      |         ^~~~~~~~~~~~~
C:\Users\dkahya\nordic\ncs\v2.4.0\zephyr\include\zephyr\drivers\gpio.h:332:24: note: in expansion of macro 'DT_GPIO_PIN_BY_IDX'
  332 |                 .pin = DT_GPIO_PIN_BY_IDX(node_id, prop, idx),                 \
      |                        ^~~~~~~~~~~~~~~~~~
C:\Users\dkahya\nordic\ncs\v2.4.0\zephyr\include\zephyr\drivers\gpio.h:367:9: note: in expansion of macro 'GPIO_DT_SPEC_GET_BY_IDX'
  367 |         GPIO_DT_SPEC_GET_BY_IDX(node_id, prop, 0)
      |         ^~~~~~~~~~~~~~~~~~~~~~~
c:\Users\dkahya\nordic\myapps\I_Ansteuern_Leds\src\main.c:17:41: note: in expansion of macro 'GPIO_DT_SPEC_GET'
   17 | static const struct gpio_dt_spec led0 = GPIO_DT_SPEC_GET(LED0_NODE, gpios);
      |                                         ^~~~~~~~~~~~~~~~
C:\Users\dkahya\nordic\ncs\v2.4.0\zephyr\include\zephyr\devicetree.h:4049:24: note: in expansion of macro 'DT_N_ALIAS_led1'
 4049 | #define DT_CAT(a1, a2) a1 ## a2
      |                        ^~
C:\Users\dkahya\nordic\ncs\v2.4.0\zephyr\include\zephyr\devicetree.h:232:25: note: in expansion of macro 'DT_CAT'
  232 | #define DT_ALIAS(alias) DT_CAT(DT_N_ALIAS_, alias)
      |                         ^~~~~~
c:\Users\dkahya\nordic\myapps\I_Ansteuern_Leds\src\main.c:14:19: note: in expansion of macro 'DT_ALIAS'
   14 | #define LED0_NODE DT_ALIAS(led1)
      |                   ^~~~~~~~
c:\Users\dkahya\nordic\myapps\I_Ansteuern_Leds\src\main.c:17:58: note: in expansion of macro 'LED0_NODE'
   17 | static const struct gpio_dt_spec led0 = GPIO_DT_SPEC_GET(LED0_NODE, gpios);
      |                                                          ^~~~~~~~~
[8/148] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/sem.c.obj
[9/148] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/printk.c.obj
[10/148] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/cbprintf_packaged.c.obj
[11/148] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/fdtable.c.obj
[12/148] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/heap-validate.c.obj
[13/148] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/timeutil.c.obj
[14/148] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/rb.c.obj
[15/148] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/heap.c.obj
[16/148] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/bitarray.c.obj
ninja: build stopped: subcommand failed.
FATAL ERROR: command exited with status 1: 'c:\Users\dkahya\nordic\ncs\toolchains\31f4403e35\opt\bin\cmake.EXE' --build 'c:\Users\dkahya\nordic\myapps\I_Ansteuern_Leds\build_1'

I debug it with RTT.

Best regards

  • #include <zephyr/kernel.h>
    #include <zephyr/device.h>
    #include <zephyr/devicetree.h>
    #include <zephyr/drivers/gpio.h>
    
    #define SLEEP_TIME_MS   10*60*1000
    
    /* SW0_NODE is the devicetree node identifier for the node with alias "sw0" */
    #define SW0_NODE	DT_ALIAS(btn-mode) 
    static const struct gpio_dt_spec button = GPIO_DT_SPEC_GET(SW0_NODE, gpios);
    
    /* LED0_NODE is the devicetree node identifier for the node with alias "led0". */
    #define LED1_NODE	DT_ALIAS(led1)
    static const struct gpio_dt_spec led1 = GPIO_DT_SPEC_GET(LED1_NODE, gpios);
    
    
    //Define the callback function */
    void button_pressed(const struct device *dev, struct gpio_callback *cb, uint32_t pins)
    {
    	gpio_pin_toggle_dt(&led1);
    	printk("Button pressed!");
    }
    
    
    /*  Define a variable of type static struct gpio_callback */
    static struct gpio_callback button_cb_data;
    
    void main(void)
    {
    	int ret;
    
    	
    
    	if (!device_is_ready(led1.port)) {
    		return;
    	}
    
    	if (!device_is_ready(button.port)) {
    		return;
    	}
    
    	
    
    	ret = gpio_pin_configure_dt(&led1, GPIO_OUTPUT_ACTIVE);
    	if (ret < 0) {
    		return;
    	}
    
    
    	ret = gpio_pin_configure_dt(&button, GPIO_INPUT);
    	if (ret < 0) {
    		return;
    	}
    	/*  Configure the interrupt on the button's pin */
    	ret = gpio_pin_interrupt_configure_dt(&button, GPIO_INT_EDGE_TO_ACTIVE );
    
    	/*  Initialize the static struct gpio_callback variable   */
        gpio_init_callback(&button_cb_data, button_pressed, BIT(button.pin)); 	
    	
    	/*  Add the callback function by calling gpio_add_callback()   */
    	 gpio_add_callback(button.port, &button_cb_data);
    	 
    	while (1) {
    		/* Remove the polling code */
    
            k_msleep(SLEEP_TIME_MS);
    	}
    }

    and I forget to add my devicetree files and source code

    // Copyright (c) 2023 Nordic Semiconductor ASA
    // SPDX-License-Identifier: Apache-2.0
    
    /dts-v1/;
    #include <nordic/nrf52832_qfaa.dtsi>
    
    / {
    	model = "test_LED";
    	compatible = "test-led";
    
    	chosen {
    		zephyr,sram = &sram0;
    		zephyr,flash = &flash0;
    		zephyr,code-partition = &slot0_partition;
    	};
    
    	leds {
    		compatible = "gpio-leds";
    		//LED_CON_B: Bluetooth Blau
    		led1: led_1 {
    			gpios = <&gpio0 7 GPIO_ACTIVE_HIGH>;
    			label = "LED_CON_B";
    		};
    	};
    
    
    	buttons {
    		compatible = "gpio-keys";
    		//Button Mode
    		button1: button_1 {
    			gpios = <&gpio0 30 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>;
    			label = "BTN_MODE ";
    		};
    };
    
    
    	aliases {
    
    		led1 = &led1;
    		btn-mode = &button1;
    	};
    
    };
    
    &gpio0 {
    	status = "okay";
    };
    
    &gpiote {
    	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 0x32000>;
    		};
    		slot1_partition: partition@3e000 {
    			label = "image-1";
    			reg = <0x3e000 0x32000>;
    		};
    		scratch_partition: partition@70000 {
    			label = "image-scratch";
    			reg = <0x70000 0xa000>;
    		};
    		storage_partition: partition@7a000 {
    			label = "storage";
    			reg = <0x7a000 0x6000>;
    		};
    	};
    };
    
    

  • Hi,

    Could you try deleting the build folder and rebuilding? A pristine build is required when changes are made to the devicetree or configs.

  • Hey, thank you for your answer. However, It doesnt work this way.

  •  I am trying to build zephyr for a custom soc+board,I have followed the steps as in the main website.Now 

    papa's games

  • Hi again sorry for the delay, are you still having this issue?

Related