Reputation: 31
I Installed zephyr rtos first time. I ran example code and i got following error. The example run with some boards but not with all listed borads in zephyer. I want to know how to solve this error.
west build -p auto -b qemu_x86 samples/basic/blinky
/zephyrproject/zephyr/samples/basic/blinky/src/main.c:24:2: error: #error "Unsupported board: led0 devicetree alias is not defined" 24 | #error "Unsupported board: led0 devicetree alias is not defined" | ^~~~~ [17/118] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/cbprintf_packaged.c.obj ninja: build stopped: subcommand failed.
Upvotes: 0
Views: 2357
Reputation: 1
create a overlay file at samples/basic/blinky. pasted the content below (it will blink pin 25)
/ {
aliases {
led0 = &led0;
};
leds {
compatible = "gpio-leds";
led0: led_0 {
gpios = <&gpio0 25 GPIO_ACTIVE_HIGH>;
label = "LED 0";
};
};
};
Ref - https://github.com/zephyrproject-rtos/zephyr/issues/36412
Upvotes: 0
Reputation: 475
The quemu board is not a real board, rather a virtual one, because quemu is an emulator. LED doesn't have much sense on a virtual board, because only there is software that "imitates" the hardware - and in many cases, this is limited to CPU and memory emulation.
The direct reason this doesn't compile is the lack of the LED node's definition in the device tree.
Compare an excerpt from the device tree of quemu and a Nucleo board.
\zephyr\boards\x86\qemu_x86\qemu_x86.dts
aliases {
uart-0 = &uart0;
uart-1 = &uart1;
eeprom-0 = &eeprom0;
eeprom-1 = &eeprom1;
};
\zephyr\boards\arm\nucleo_g071rb\nucleo_g071rb.dts
leds {
compatible = "gpio-leds";
green_led_1: led_4 {
gpios = <&gpioa 5 GPIO_ACTIVE_HIGH>;
label = "User LD4";
};
};
aliases {
led0 = &green_led_1;
sw0 = &user_button;
};
As you can see, the quemu board defines peripherals like a console(uart) and memory(eeprom) only.
In the meantime, the blinky example source code tries to find out if LED is defined in the chosen board with the lines below, (DT stands for Device Tree)
#define LED0_NODE DT_ALIAS(led0)
#if DT_NODE_HAS_STATUS(LED0_NODE, okay)
//...
#else
/* A build error here means your board isn't set up to blink an LED. */
#error "Unsupported board: led0 devicetree alias is not defined"
Upvotes: 1