OPENKYLIN hello world 编写
时间: 2023-10-02 22:05:59 浏览: 37
要编写OPENKYLIN hello world,您可以按照以下步骤进行操作:
1. 创建一个名为helloworld.c的文件,路径为~/openwrt/package/kernel/helloworld/src/helloworld.c。
2. 在helloworld.c文件中添加以下代码:
```c
#include <linux/init.h>
#include <linux/module.h>
static int __init helloworld_init(void) {
printk(KERN_ALERT "Hello World! My first Openwrt module!\n");
return 0;
}
static void __exit helloworld_exit(void) {
printk(KERN_ALERT "Bye, The World!\n");
}
module_init(helloworld_init);
module_exit(helloworld_exit);
MODULE_LICENSE("GPL");
MODULE_AUTHOR("SANZHOUZI");
MODULE_DESCRIPTION("Nothing");
```
3. 创建一个名为Kconfig的文件,路径为~/openwrt/package/kernel/helloworld/src/Kconfig。
4. 在Kconfig文件中添加以下文本:
```
config HELLOWORLD
tristate "helloworld"
help
nothing
```
5. 编译OPENKYLIN,将模块添加到内核中。
6. 在编译过程中,选择"Hello World! My first openwrt module"。
7. 完成编译后,您将得到一个OPENKYLIN hello world模块。
请注意,您需要确保已安装必要的开发工具和环境,以便进行编译和构建OPENKYLIN。