Hello ! This is Kite blog ,

Welcome to communicate with me .

 

Before Linux Kernel Transplant well , Just load the driver in

It turns out that :

/ # ls
bin           first_drv.ko  linuxrc       root          tmp
dev           firstdrvtest  mnt           sbin          usr
etc           lib           proc          sys
/ # insmod first_drv.ko 
first_drv: loading out-of-tree module taints kernel.
/ # lsmod
lsmod: can't open '/proc/modules': No such file or directory
/ # random: crng init done
/ # insmod first_drv.ko 
insmod: can't insert 'first_drv.ko': File exists
/ #

Good pit ,insmod Tips  loading out-of-tree module taints kernel.

and lsmod Also prompt  can't open '/proc/modules': No such file or directory...

For a long time , find Kernel It's printed out log There is a sentence :

cann't run '/etc/init.d/rcS':Permission denied.

it turns out to be the case that rcS Not running , Add the execution authority :

sudo chmod u+x /work/nfs/root/etc/init.d/rcS

such , Restart development board , After file system ,

insmod Although it will be prompted :loading out-of-tree module taints kernel.

however lsmod You will see the driver just installed .

 

loading out-of-tree module taints kernel.

This seems to be because the kernel chooses to support the kernel signature mechanism when compiling , It is said that 3.7 It is supported after the version

The module is signed . This is for the sake of Kernel Safety plus .

among , Kernel configuration item :

CONFIG_MODULE_SIG=y 
Indicates that the signature mechanism is enabled .

CONFIG_MODULE_SIG_FORCE=y 
The module must have the correct signature to work properly .

CONFIG_MODULE_SIG_ALL=y 
When the kernel is compiled , Will take the initiative to sign the module .

 

I am here Kernel Of menuconfig Have a look , my

CONFIG_MODULE_SIG yes =n Yeah . strange .

It doesn't matter , Tips taints kernel Just give me a hint , Just load the driver anyway .

estimate CONFIG_MODULE_SIG=y The driver can't be loaded normally .

Need to sign driver .

then ,insmod and lsmod It's all right , Now try it rmmod Unload drive .

Need to be in lib Create an empty folder under the directory to enable use rmmod.

 

  mkdir -p /lib/module/4.8.17
however rmmod There is also a problem : 

 

 

 

 

 

 

Unable to handle kernel paging request at virtual address fffffffc
pgd = c3b40000
This error occurred while unloading the driver , It is estimated that there is a memory access error .
Later, I was reminded by the boss , When the driver is unloaded ,device_destroy The first argument to the function is struct class * type .
The parameters of my program were passed in incorrectly , It was passed on struct class_device * Type .
This is the difference caused by the new kernel .

 

in general , Load and unload driver , Both :

init function : 1. devno register   2. class register   3. device apply
exit function : 1. device Destruction  2. class release    3. devno release

 

 

 

Technology
©2019-2020 Toolsou All rights reserved,
QQ Login interface implementation code implementation mysql Addition, deletion, modification and query of database JAVA Experiment 4 set and functional programming experiment about String How to create objects VHDL——4 choose 1 Data selector C language ( Guess numbers games ) Blue Bridge Cup MCU advanced module --NE555 I don't memorize eight part essays , You go to the interview ? Hill sorting of sorting algorithm ——c++ realization python What does built-in function mean _python What are the built-in functions