简体   繁体   English

我在覆盖文件中的 GPIO 未在 devicetree_generated.h 中定义,zephyr 失败

[英]My GPIOs in the overlay file are not defined in devicetree_generated.h, zephyr fails

I am trying to use Zephyr (v.3.2.99) for a small application on the nRF52840 Dev Kit.我正在尝试将 Zephyr (v.3.2.99) 用于 nRF52840 开发套件上的一个小应用程序。 I set up an overlay file nrf52840dk_nrf52840.overlay that is being read and processed by cmake. I get the devicetree_generated.h but it lacks the definition of the nodes.我设置了一个覆盖文件 nrf52840dk_nrf52840.overlay 正在被 cmake 读取和处理。我得到了 devicetree_generated.h 但它缺少节点的定义。

Here is my overlay:这是我的覆盖图:

/ {
    aliases {
        pwr0 = &pinpwr0;
        eu0  = &pineu0;
        psw0 = &pinsw0;
     };
    pinpwr0: pin_pwr_0 {
        gpios = <&gpio1 10 GPIO_ACTIVE_HIGH>;
        label = "power";
    };

    pineu0: pin_eu_0 {
        gpios = <&gpio1 11 GPIO_ACTIVE_HIGH>;
        label = "eu";
    };

    pinsw0: pin_sw_0 {
        gpios = <&gpio1 12 GPIO_ACTIVE_HIGH>;
        label = "switch";
    };

    chosen {
            nordic,nus-uart = &uart0;
    };

};

My c file:我的 c 文件:

... ...

#define PWR_IO DT_ALIAS(pwr0)
#if DT_NODE_HAS_STATUS(PWR_IO, okay)
#define PWR_IO_PIN DT_GPIO_PIN(PWR_IO, gpios)
#else
#error "Cannot find the board"
#define PWR_IO_PIN 0
#endif

static const struct gpio_dt_spec pwr = GPIO_DT_SPEC_GET(PWR_IO, gpios);

... ...

The error:错误:

zephyr/include/generated/devicetree_generated.h:701:32: error: 'DT_N_S_pin_pwr_0_P_gpios_IDX_0_VAL_pin' undeclared here (not in a function); zephyr/include/generated/devicetree_generated.h:701:32: 错误:'DT_N_S_pin_pwr_0_P_gpios_IDX_0_VAL_pin' 未在此处声明(不在函数中); did you mean 'DT_N_S_leds_S_led_0_P_gpios_IDX_0_VAL_pin'?您是说“DT_N_S_leds_S_led_0_P_gpios_IDX_0_VAL_pin”吗?
701 | 701 | #define DT_N_ALIAS_pwr0 DT_N_S_pin_pwr_0 | #define DT_N_ALIAS_pwr0 DT_N_S_pin_pwr_0 | ^~~~~~~~~~~~~~~~ F:/ncs/v2.2.0/zephyr/include/zephyr/devicetree.h:3901:9: note: in definition of macro 'DT_CAT7' 3901 | ^~~~~~~~~~~~~~~~ F:/ncs/v2.2.0/zephyr/include/zephyr/devicetree.h:3901:9: 注意:在宏 'DT_CAT7' 3901 的定义中 | a1 ## a2 ## a3 ## a4 ## a5 ## a6 ## a7 | a1 ## a2 ## a3 ## a4 ## a5 ## a6 ## a7 | ^~ F:/ncs/v2.2.0/zephyr/include/zephyr/devicetree/gpio.h:164:9: note: in expansion of macro 'DT_PHA_BY_IDX' 164 | ^~ F:/ncs/v2.2.0/zephyr/include/zephyr/devicetree/gpio.h:164:9: 注意:在宏 'DT_PHA_BY_IDX' 164 的扩展中 |
DT_PHA_BY_IDX(node_id, gpio_pha, idx, pin) | DT_PHA_BY_IDX(node_id,gpio_pha,idx,pin)| ^~~~~~~~~~~~~ F:/ncs/v2.2.0/zephyr/include/zephyr/drivers/gpio.h:341:24: note: in expansion of macro 'DT_GPIO_PIN_BY_IDX' 341 |.pin = DT_GPIO_PIN_BY_IDX(node_id, prop, idx), ^~~~~~~~~~~~~ F:/ncs/v2.2.0/zephyr/include/zephyr/drivers/gpio.h:341:24:注意:在宏“DT_GPIO_PIN_BY_IDX”341 | 的扩展中。 pin = DT_GPIO_PIN_BY_IDX(node_id, prop, idx),
| | ^~~~~~~~~~~~~~~~~~ F:/ncs/v2.2.0/zephyr/include/zephyr/drivers/gpio.h:376:9: note: in expansion of macro 'GPIO_DT_SPEC_GET_BY_IDX' 376 | ^~~~~~~~~~~~~~~~~~ F:/ncs/v2.2.0/zephyr/include/zephyr/drivers/gpio.h:376:9: 注意:在宏扩展中 ' GPIO_DT_SPEC_GET_BY_IDX' 376 |
GPIO_DT_SPEC_GET_BY_IDX(node_id, prop, 0) | GPIO_DT_SPEC_GET_BY_IDX(node_id,prop,0)| ^~~~~~~~~~~~~~~~~~~~~~~../src/tvunit.c:25:40: note: in expansion of macro 'GPIO_DT_SPEC_GET' 25 | ^~~~~~~~~~~~~~~~~~~~~~~../src/tvunit.c:25:40:注意:在宏“GPIO_DT_SPEC_GET”的扩展中 25 | static const struct gpio_dt_spec pwr = GPIO_DT_SPEC_GET(PWR_IO, gpios); static const struct gpio_dt_spec pwr = GPIO_DT_SPEC_GET(PWR_IO, gpios);

If I look into the file devicetree_generated.h, the token DT_N_S_pin_pwr_0 is never defined (only referred to in the comments).如果我查看文件 devicetree_generated.h,则从未定义令牌 DT_N_S_pin_pwr_0(仅在注释中提及)。

What am I doing wrong?我究竟做错了什么?

Zephyr's build system is not properly processing the pin_pwr_0 and like nodes as they don't have bindings. Zephyr 的构建系统没有正确处理pin_pwr_0和 like 节点,因为它们没有绑定。 Generally, nodes in the devicetree also need bindings to be processed correctly.通常,devicetree 中的节点也需要绑定才能正确处理。 Since the nodes you are using are just pins/buttons;由于您使用的节点只是引脚/按钮; you should be able to use the generic gpio-keys compatible by adding this to each node: compatible = "gpio-keys";您应该能够通过将此添加到每个节点来使用通用的gpio-keys兼容: compatible = "gpio-keys"; More on Zephyr's devicetree binding rules can be found here: https://docs.zephyrproject.org/3.2.0/build/dts/bindings.html更多关于 Zephyr 的 devicetree 绑定规则可以在这里找到: https://docs.zephyrproject.org/3.2.0/build/dts/bindings.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM