Through the tenth chapter, the debugging technology of embedded Linux driver development has been learned.
Knowledge Learned:
First, print kernel debug information: PRINTK
the PRINTK function is prototyped as follows:
asmlinkage int PRINTK (const char * fmt, ...)
The PRINTK file is a simple 4 -digit text file with the following default values:6 4 1 7
6: Output the message to the level of the console.
4: The default message log level.
1: Minimum value that can be set for the console log level
7: Default value for console log level.
Second, prevent PRINTK function to reduce Linux drive performance
1. variable-parameter macros
2.do{...} while (O)
Third, the data interaction through the virtual file system
Proc_mkdir
Name: virtual directory names.
Parent: Proc_dir_entry struct pointerto the parent directory of the virtual directory .
Create_proc_enttry
Name: Virtual file names.
Mode: Access permissions for virtual files
Parent: The proc_dir_entry struct pointer to the parent directory of the virtual file .
Create_proc_read_entty
Name: Virtual file names.
Mode: Access permissions for virtual files
Base: proc_dir_entry struct pointerto the parent directory of the virtual file .
Read_proc: A function pointer that handles read actions.
data: Used for the virtual file system.
Remove_proc_entry
Name: The names of the virtual files to be deleted.
Parent: The proc_dir_entry struct pointer to the parent directory of the virtual file .
Four, Debugging Tools
1. debugging the user-space program with gdb
2. remote debugging of user space programs with gdbserver
3. Remote Debug Kernel program with kgdb
Tenth Chapter Experience