野火电子论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 217|回复: 1

[求助] 内核加载设备树相关模块报错提示没有相关函数

[复制链接]
发表于 2024-4-26 01:57:25 | 显示全部楼层 |阅读模式
  1. #include <linux/types.h>
  2. #include <linux/kernel.h>
  3. #include <linux/delay.h>
  4. #include <linux/ide.h>
  5. #include <linux/init.h>
  6. #include <linux/module.h>
  7. #include <linux/errno.h>
  8. #include <linux/gpio.h>
  9. #include <linux/cdev.h>
  10. #include <linux/device.h>
  11. #include <linux/of.h>
  12. #include <linux/of_address.h>
  13. #include <asm/mach/map.h>
  14. #include <asm/uaccess.h>
  15. #include <asm/io.h>


  16. struct device_node *oled_device_node;
  17. struct device_node *beep_device_node;


  18. struct property *oled_node_property;
  19. struct property *beep_node_property;

  20. unsigned int size;
  21. unsigned int out_values[10] = {0};

  22. static int __init hello_init(void)
  23. {

  24.     int ret=0;
  25.     int i=0;
  26.     printk(KERN_EMERG"[ KERN_EMERG ] hello DTS!\n");
  27.     // 得到节点
  28.     oled_device_node = of_find_node_by_path("/oled");

  29.     beep_device_node = of_find_node_by_path("/beep");

  30.     if(oled_device_node == NULL){

  31.         printk(KERN_EMERG "of find node by path for oled faild!\n");

  32.         return -1;
  33.     }
  34.     else{
  35.         printk(KERN_EMERG "[ KERN_EMERG ] Get Oled Node succesces!\n");
  36.     }

  37.     if(beep_device_node == NULL){
  38.         printk(KERN_EMERG "of find node by path for beep faild!\n");

  39.         return -1;
  40.     }
  41.     else{
  42.         printk(KERN_EMERG"[ KERN_EMERG ] Get beep Node succesces!\n");
  43.     }

  44.     /*
  45.        2. 从节点中获取属性
  46.     */
  47.     beep_node_property= of_find_property(beep_device_node,"compatible",&size);
  48.     if(beep_node_property == NULL){
  49.          printk(KERN_EMERG"[ KERN_EMERG ] Get beep property faild!\n");

  50.          return -1;
  51.     }
  52.     else{
  53.           printk(KERN_EMERG"[ KERN_EMERG ] Get beep property succesces!\n");
  54.     }

  55.     //打印节点属性名称和值 key-value
  56.     printk("beepNodeName is:%s\n",beep_node_property->name);
  57.     printk("beepNodeValue is:%s\n",(char*)beep_node_property->value);

  58.     /************获取reg中的值*******************/

  59.     ret = of_property_read_u32_array(beep_device_node,"reg",out_values,10);
  60.     if(ret < 0 )
  61.     {
  62.         printk("of property read u32 array is error \n");
  63.         return -1;
  64.     }
  65.     for(i=0;i<10;i++){
  66.        printk("out_values[0] is 0x%8x", out_values[i]);
  67.        if(i%2==0)
  68.        {
  69.         printk("\n");
  70.        }
  71.     }


  72.     /*******************************/
  73.     return 0;
  74. }

  75. static void __exit hello_exit(void)
  76. {
  77.     printk("[ default ]   Hello  Module Exit\n");
  78. }

  79. module_init(hello_init);
  80. module_exit(hello_exit);

  81. //MODULE_LICENSE("GPL2");
  82. MODULE_AUTHOR("embedfire ");
  83. MODULE_DESCRIPTION("hello world module");
  84. MODULE_ALIAS("test_module");
复制代码
内核加载的时候提示无法识别of_property_read_u32_array()函数
相关错误图片

野火论坛202404260155117059..png


野火论坛202404260156284177..png








回复

使用道具 举报

发表于 2024-4-27 16:30:55 | 显示全部楼层
这种一般都是前置驱动没开
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

联系站长|手机版|野火电子官网|野火淘宝店铺|野火电子论坛 ( 粤ICP备14069197号 ) 大学生ARM嵌入式2群

GMT+8, 2024-5-6 20:51 , Processed in 0.132510 second(s), 27 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表