
helloworld驱动实验
大约 1 分钟STM32开发环境介绍
hello_word.c
程序
#include<linux/module.h>
#include<linux/kernel.h>
static int hello_world_init(void)
{
printk(KERN_ALERT "Hello world!\n");
return 0;
}
static void hello_world_exit(void)
{
printk(KERN_ALERT "Goodbye world!\n");
}
module_init(hello_world_init);
module_exit(hello_world_exit);
MODULE_LICENSE("GPL");
MODULE_AUTHOR("Sebastian");
介绍
Makefile
程序
export ARCH=arm64
export CROSS_COMPILE=aarch64-none-linux-gnu-
obj-m += hello_world.o
KDIR := /home/zkb/RK3588/rk3588-linux/kernel
PWD := $(shell pwd)
all:
make -C $(KDIR) M=$(PWD) modules
clean:
make -C $(KDIR) M=$(PWD) clean
介绍
- 设置平台架构
export ARCH=arm64
- 交叉编译器前缀
export CROSS_COMPILE=aarch64-none-linux-gnu-
- 此处要和你的驱动源文件同名
obj-m += parameter.o
- 这里是你的内核目录
KDIR :=/home/topeet/Linux/linux_sdk/kernel
- make 操作
make -C $(KDIR) M=$(PWD) modules
- make clean 操作
clean: make -C $(KDIR) M=$(PWD) clean