ZzlYanG 发表于 2024-4-26 01:57:25

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

#include <linux/types.h>
#include <linux/kernel.h>
#include <linux/delay.h>
#include <linux/ide.h>
#include <linux/init.h>
#include <linux/module.h>
#include <linux/errno.h>
#include <linux/gpio.h>
#include <linux/cdev.h>
#include <linux/device.h>
#include <linux/of.h>
#include <linux/of_address.h>
#include <asm/mach/map.h>
#include <asm/uaccess.h>
#include <asm/io.h>


struct device_node *oled_device_node;
struct device_node *beep_device_node;


struct property *oled_node_property;
struct property *beep_node_property;

unsigned int size;
unsigned int out_values = {0};

static int __init hello_init(void)
{

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

    beep_device_node = of_find_node_by_path("/beep");

    if(oled_device_node == NULL){

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

      return -1;
    }
    else{
      printk(KERN_EMERG "[ KERN_EMERG ] Get Oled Node succesces!\n");
    }

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

      return -1;
    }
    else{
      printk(KERN_EMERG"[ KERN_EMERG ] Get beep Node succesces!\n");
    }

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

         return -1;
    }
    else{
          printk(KERN_EMERG"[ KERN_EMERG ] Get beep property succesces!\n");
    }

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

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

    ret = of_property_read_u32_array(beep_device_node,"reg",out_values,10);
    if(ret < 0 )
    {
      printk("of property read u32 array is error \n");
      return -1;
    }
    for(i=0;i<10;i++){
       printk("out_values is 0x%8x", out_values);
       if(i%2==0)
       {
      printk("\n");
       }
    }


    /*******************************/
    return 0;
}

static void __exit hello_exit(void)
{
    printk("[ default ]   HelloModule Exit\n");
}

module_init(hello_init);
module_exit(hello_exit);

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













おおおじ。 发表于 2024-4-27 16:30:55

这种一般都是前置驱动没开
页: [1]
查看完整版本: 内核加载设备树相关模块报错提示没有相关函数