基于RK3288平台的第一个hello word程序

rk3288\kernel\drivers下建一个helloword文件
基于RK3288平台的第一个hello word程序_第1张图片

在此文件夹编写:helloword.c,Makefile,Kconfig

helloword.c的内容:

#include 
#include 
#include 

static int __init helloword_init(void)   
{                             
   printk("helloword!!\n");
return 0;
}
static void __exit helloword_exit(void)
{
   printk("helloword goodbye!!\n");
}
module_init(helloword_init);
module_exit(helloword_exit);
MODULE_LICENSE("GPL");

Makefile的内容

  obj-m		:= helloword.o

Kconfig的内容

 config HELLOWORD
	 tristate "HELLOWORD for the ARM Versatile and RealView"
	        help
            NO !!!!!!!!!!!!!!!!!!!!!!!!

返回上一级目录
Kconfig 添加 source "drivers/helloword/Kconfig"
在这里插入图片描述

Makefile添加 obj-y += helloword/
基于RK3288平台的第一个hello word程序_第2张图片
rk3288\kernel\arch\arm\configs路径下打开:rockchip_defconfig

基于RK3288平台的第一个hello word程序_第3张图片
添加:CONFIG_HELLOWORD=y

在这里插入图片描述
写到这里已经把Linux系统的helloword驱动已经下好了。
接下来就是查看helloword驱动打印的信息了

首先进入到kernel 执行语句: make menuconfig
基于RK3288平台的第一个hello word程序_第4张图片
选择: Device Drivers--->
找到如下选项,在左边的<>中,空格选择她出现 :<*>
基于RK3288平台的第一个hello word程序_第5张图片
选择之后,基于RK3288平台的第一个hello word程序_第6张图片
保存好配置,退出。
然后编译kernel:./build.sh kernel,将新生成的固件下载到板子上。
打开串口,查看打印信息:
在这里插入图片描述
后面补充:

ADBhelloword.ko这个文件pushsystem里面(RK里面是可以的)
然后:

cd system

执行加载命令和卸载命令

rk3326_m2g:/system # insmod helloword.ko                                       
[ 1118.018223] helloword!!
rk3326_m2g:/system # rmmod helloword.ko                                        
[ 1120.212505] helloword goodbye!!
rk3326_m2g:/system # 

你可能感兴趣的:(helloword)