OpenEdv-开源电子网

 找回密码
 立即注册
正点原子全套STM32/Linux/FPGA开发资料,上千讲STM32视频教程免费下载...
查看: 138|回复: 3

imx6ull的字符设备驱动实验使用make编译出错

[复制链接]

0

主题

3

帖子

0

精华

新手入门

积分
10
金钱
10
注册时间
2023-12-19
在线时间
2 小时
发表于 2024-4-16 22:05:27 | 显示全部楼层 |阅读模式
3金钱

最佳答案

查看完整内容[请看2#楼]

问题已解决,需要将chrdevbase.c文件中的init和exit的宏名写为__init和__exit,并且在模块的入口和出口函数中加入chrdevbase_init和chrdevbase_exit参数,该问题解决的前提是Linux内核没有任何问题的前提下,如果linux内核的顶层Makefile有问题还需要进行修改和编译,还需要注意在文件中的各个字母的书写,以及Makefile文件的M要大写
正点原子逻辑分析仪DL16劲爆上市
回复

使用道具 举报

0

主题

3

帖子

0

精华

新手入门

积分
10
金钱
10
注册时间
2023-12-19
在线时间
2 小时
 楼主| 发表于 2024-4-16 22:05:28 | 显示全部楼层
问题已解决,需要将chrdevbase.c文件中的init和exit的宏名写为__init和__exit,并且在模块的入口和出口函数中加入chrdevbase_init和chrdevbase_exit参数,该问题解决的前提是Linux内核没有任何问题的前提下,如果linux内核的顶层Makefile有问题还需要进行修改和编译,还需要注意在文件中的各个字母的书写,以及Makefile文件的M要大写
回复

使用道具 举报

0

主题

3

帖子

0

精华

新手入门

积分
10
金钱
10
注册时间
2023-12-19
在线时间
2 小时
 楼主| 发表于 2024-4-17 16:49:23 | 显示全部楼层
本帖最后由 starkli 于 2024-4-17 16:52 编辑

解决问题的修改点:
#include <linux/module.h> //#include <linux/types.h>  static int __init chrdevbase_int(void) {     return 0; }  static void _exit chrdevbase__exit(void) {  }  /* 模块入口与出口 */  module_init(chrdevbase_init); /*入口*/ module_exit(chrdevbase_exit); /*出口*/
回复

使用道具 举报

0

主题

3

帖子

0

精华

新手入门

积分
10
金钱
10
注册时间
2023-12-19
在线时间
2 小时
 楼主| 发表于 2024-4-17 16:52:25 | 显示全部楼层
问题未解决前的报错信息:
make -C /home/lingling/linux/imx6ull/linux-imx-rel_imx_4.1.15_2.1.0_ga M=/home/lingling/linux/Linux_Drivers/1_chrdevbase modules
make[1]: Entering directory '/home/lingling/linux/imx6ull/linux-imx-rel_imx_4.1.15_2.1.0_ga'
  CC [M]  /home/lingling/linux/Linux_Drivers/1_chrdevbase/chrdevbase.o
/home/lingling/linux/Linux_Drivers/1_chrdevbase/chrdevbase.c:4:18: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘chrdevbase_int’
static int _init chrdevbase_int(void)
                  ^
/home/lingling/linux/Linux_Drivers/1_chrdevbase/chrdevbase.c:9:19: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘chrdevbase_exit’
static void _exit chrdevbase_exit(void)
                   ^
In file included from include/linux/printk.h:5:0,
                 from include/linux/kernel.h:13,
                 from include/linux/list.h:8,
                 from include/linux/module.h:9,
                 from /home/lingling/linux/Linux_Drivers/1_chrdevbase/chrdevbase.c:1:
/home/lingling/linux/Linux_Drivers/1_chrdevbase/chrdevbase.c: In function ‘__inittest’:
include/linux/init.h:349:4: warning: ‘return’ with no value, in function returning non-void [-Wreturn-type]
  { return initfn; }     \
    ^
/home/lingling/linux/Linux_Drivers/1_chrdevbase/chrdevbase.c:21:1: note: in expansion of macro ‘module_init’
module_init(); /*入口*/
^
/home/lingling/linux/Linux_Drivers/1_chrdevbase/chrdevbase.c: In function ‘__exittest’:
include/linux/init.h:355:4: warning: ‘return’ with no value, in function returning non-void [-Wreturn-type]
  { return exitfn; }     \
    ^
/home/lingling/linux/Linux_Drivers/1_chrdevbase/chrdevbase.c:22:1: note: in expansion of macro ‘module_exit’
module_exit(); /*出口*/
^
/home/lingling/linux/Linux_Drivers/1_chrdevbase/chrdevbase.c: At top level:
include/linux/init.h:350:6: error: ‘init_module’ aliased to undefined symbol ‘’
  int init_module(void) __attribute__((alias(#initfn)));
      ^
/home/lingling/linux/Linux_Drivers/1_chrdevbase/chrdevbase.c:21:1: note: in expansion of macro ‘module_init’
module_init(); /*入口*/
^
include/linux/init.h:356:7: error: ‘cleanup_module’ aliased to undefined symbol ‘’
  void cleanup_module(void) __attribute__((alias(#exitfn)));
       ^
/home/lingling/linux/Linux_Drivers/1_chrdevbase/chrdevbase.c:22:1: note: in expansion of macro ‘module_exit’
module_exit(); /*出口*/
^
scripts/Makefile.build:264: recipe for target '/home/lingling/linux/Linux_Drivers/1_chrdevbase/chrdevbase.o' failed
make[2]: *** [/home/lingling/linux/Linux_Drivers/1_chrdevbase/chrdevbase.o] Error 1
Makefile:1384: recipe for target '_module_/home/lingling/linux/Linux_Drivers/1_chrdevbase' failed
make[1]: *** [_module_/home/lingling/linux/Linux_Drivers/1_chrdevbase] Error 2
make[1]: Leaving directory '/home/lingling/linux/imx6ull/linux-imx-rel_imx_4.1.15_2.1.0_ga'
Makefile:11: recipe for target 'kernel_modules' failed
make: *** [kernel_modules] Error 2
回复

使用道具 举报

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

本版积分规则



关闭

原子哥极力推荐上一条 /2 下一条

正点原子公众号

QQ|手机版|OpenEdv-开源电子网 ( 粤ICP备12000418号-1 )

GMT+8, 2024-5-15 09:11

Powered by OpenEdv-开源电子网

© 2001-2030 OpenEdv-开源电子网

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