Firefly3288入门之第一个helloworld

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

#include<linux/kernel.h>
#include<linux/init.h>
#include<linux/module.h>
#include<linux/delay.h>
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、编译烧录运行

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容