Figure-1:
Referring to Fig-1 and the title, the following Zephyr API–based sketch fails to compile. The AI generated the required .overlay and .conf files for the Devicetree structure, which I have placed in the App Lab sketch folder.
I would appreciate help to resolve the issues.
Error Message:
/home/arduino/ArduinoApps/zephyrled3dpin3/sketch/sketch.ino:10:2: error: #error "Devicetree alias 'dpin3' is not defined. Make sure app.overlay is included."
10 | #error "Devicetree alias 'dpin3' is not defined. Make sure app.overlay is included."
| ^~~~~
exit status 1
Sketch:
#include <zephyr/kernel.h>
#include <zephyr/drivers/gpio.h>
#define SLEEP_TIME_MS 1000
/* Define node alias matching app.overlay */
#define LED3_NODE DT_ALIAS(dpin3)
#if !DT_NODE_HAS_STATUS(LED3_NODE, okay)
#error "Devicetree alias 'dpin3' is not defined. Make sure app.overlay is included."
#endif
static const struct gpio_dt_spec led = GPIO_DT_SPEC_GET(LED3_NODE, gpios);
void setup()
{
Serial.begin(115200);
/* Verify hardware device readiness */
if (!gpio_is_ready_dt(&led))
{
Serial.println("LED3 hardware device not ready!");
return;
}
/* Configure pin as output */
if (gpio_pin_configure_dt(&led, GPIO_OUTPUT_ACTIVE) < 0) {
Serial.println("Failed to configure GPIO pin!");
}
}
void loop() {
gpio_pin_toggle_dt(&led);
k_msleep(SLEEP_TIME_MS);
}
app.overlay
/ {
aliases {
dpin3 = &my_led3;
};
leds {
compatible = "gpio-leds";
my_led3: dpin_3_led {
/* Pin 3 on the Arduino header (arduino_header 3 0) */
gpios = <&arduino_header 3 GPIO_ACTIVE_HIGH>;
label = "LED3 on DPin-3";
};
};
};
prj.conf
# Enable GPIO Driver Support
CONFIG_GPIO=y
# Enable Devicetree Overlay Parsing Support
CONFIG_DEVICETREE_BOARD_MERGE=y
