Hello,这个单词能组成哪些?

摘要:Linux驱动程序的分类 字符设备驱动、块设备驱动和网络设备驱动。 Linux驱动程序运行方式 把驱动程序编译进内核里面,这样内核启动后就会自动运行驱动程序了; 把驱动程序编译成以.ko为后缀的模块文件,然后在Linux启动后,我们自己手动
Linux驱动程序的分类 字符设备驱动、块设备驱动和网络设备驱动。 Linux驱动程序运行方式 把驱动程序编译进内核里面,这样内核启动后就会自动运行驱动程序了; 把驱动程序编译成以.ko为后缀的模块文件,然后在Linux启动后,我们自己手动安装驱动程序。 驱动程序 #include <linux/module.h> //包含初始化加载模块的头文件 #include <linux/init.h> //包含宏定义的头文件 static int hello_init(void) { printk("hello_init\n"); return 0; } static void hello_exit(void) { printk("hello_exit\n"); } module_init(hello_init); //驱动入口 module_exit(hello_exit); //驱动出口 MODULE_LICENSE("GPL"); //许可声明 MODULE_AUTHOR("CMF"); //作者 MODULE_VERSION("V1.0"); //版本 Makefile ARCH ?= arm64 CROSS_COMPILE ?= /home/cmf/debian/LubanCat_SDK/prebuilts/gcc/linux-x86/aarch64/gcc-linaro-6.3.1-2017.05-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu- export ARCH export CROSS_COMPILE # -m表示编译成模块 obj-m += hello.o KDIR:=/home/cmf/debian/LubanCat_SDK/kernel PWD?=$(shell pwd) all: make -C $(KDIR) M=$(PWD) modules #make modules 使用来编译成内核模块的 echo $(PWD) clean: rm -f *.ko *.o *.mod.o *.mod.c *.symvers *.order 编译 这里我们使用把驱动程序编译成以.ko为后缀的模块文件的方式,首先要保证kernel已经被成功编译过的。再修改Makefile,其中CROSS_COMPILE,KDIR使用自己的目录。编译成功后会生成hello.ko文件。 把ko文件拷贝到开发板 scp hello.ko cat@192.168.31.110: (省略远程目录默认为主机的家目录即: ~) 安装驱动模块 # 打印驱动模块信息 cat@lubancat:~$ modinfo hello.ko filename: /home/cat/hello.ko version: V1.0 author: CMF license: GPL srcversion: AABA8E17AB5E10CE104D4C1 depends: name: hello vermagic: 4.19.232 SMP mod_unload aarch64’ # 安装驱动模块 cat@lubancat:~$ sudo insmod hello.ko [ 4616.557876] hello_init # 查看已安装的驱动模块 cat@lubancat:~$ lsmod Module Size Used by hello 16384 0 iwlmvm 368640 0 iwlwifi 270336 1 iwlmvm r8125 143360 0 cat@lubancat:~$ cat /proc/modules hello 16384 0 - Live 0x0000000000000000 (O) iwlmvm 368640 0 - Live 0x0000000000000000 iwlwifi 270336 1 iwlmvm, Live 0x0000000000000000 r8125 143360 0 - Live 0x0000000000000000 # 卸载驱动模块 cat@lubancat:~$ sudo rmmod hello [ 4634.443350] hello_exit