Firefly3288入门之第一个helloworld

目标:创建一个hello的驱动,在开机的时候加载,并打印“hello world”
步骤:
1、kernel/drivers下新建sai文件夹,增加驱动文件hello.c和对应的Makefile、Kconfig
hello.c:

#include
#include
#include
#include
static int __init hello_init(void){
int i;
for (i=0;i<9;i++){
printk("Hello world\n",i);
mdelay(1000);
}
return 0;
}
subsys_initcall(hello_init);
module_exit(hello_exit);

Makefile:

#LED Core
obj-$(CONFIG_HELLO)        += hello.o

Kconfig:

config HELLO
tristate "Hello world for Filefly"
help
hello for Firefly

2、修改上一级的Makefile和Kconfig
Makefile新增一行:

source "drivers/sai/Kconfig"

Kconfig新增一行:

obj-y                      += sai/

3、使用Make menuconfig进行配置
Device Drivers->Hello world for Firefly选中编译
4、编译烧录运行

你可能感兴趣的:(Firefly3288入门之第一个helloworld)