当前位置:网站首页>Raspberry pie 4B compiling kernel module
Raspberry pie 4B compiling kernel module
2022-06-10 05:47:00 【weixin_ forty-five million ninety thousand seven hundred and tw】
Raspberry pie 4B Compiling kernel modules
Implement simple kernel module compilation and testing on raspberry pie
Download source code and compile
- Environmental preparation
sudo apt install git bc bison flex libssl-dev make
- github Download the source code
git clone --depth=1 https://github.com/raspberrypi/linux
This command will only download the latest version , There will be no history , It is recommended to use the following command to download the same kernel version as the system .
Download the specified version of the source code , With 5.10 For example :
sudo git clone --depth=1 https://github.com/raspberrypi/linux --branch rpi-5.10.y
- compile
For raspberry pie 4B 64 position , Use the following commands to configure :
cd linux
KERNEL=kernel8
sudo make bcm2711_defconfig
compile :
sudo make -j4 Image.gz modules dtbs
If you need to update the raspberry pie kernel , You can use the following command :
sudo make modules_install
sudo cp arch/arm64/boot/dts/broadcom/*.dtb /boot/
sudo cp arch/arm64/boot/dts/overlays/*.dtb* /boot/overlays/
sudo cp arch/arm64/boot/dts/overlays/README /boot/overlays/
sudo cp arch/arm64/boot/Image.gz /boot/$KERNEL.img
The update here should be the boot time kernel image 、 Update the device tree , At the same time, some modules are placed in the file system .
Kernel module testing
- Writing kernel module code hello_kernel and Makefile.
hello_kernel.c
#include <linux/module.h>
static int __init my_init(void)
{
printk(KERN_INFO"Hello kernel!\n");
return 0;
}
static void __exit my_exit(void)
{
printk(KERN_INFO"Good bye!\n");
return ;
}
module_init(my_init);
module_exit(my_exit);
MODULE_LICENSE("GPL");
Makefile as follows :
KERNELDIR ?=
PWD :=$(shell pwd)
obj-m := hello_kernel.o
all:
make -C $(KERNELDIR) M=$(PWD) modules
clean:
rm -rf *.o *.ko *.mod.c *.mod *.order *.symvers
- compile
sudo make KERNELDIR=/usr/src/linux
- test

Use dmesg View kernel information :
Error log
- insmod: ERROR: could not insert module hello_kernel.ko: Invalid module format

dmesg -c View log information , It is found that there is a problem with the version .
see linux Source code and raspberry pie version , Find inconsistencies , Download the source code consistent with the kernel version .
Reference article
边栏推荐
- 向 CODING 推送代码出现 Permission denied 的解决方法
- [understanding of opportunity -20]: Guiguzi - reaction chapter - the art of movement and stillness, the combination of speaking and listening, silence is golden
- The first BMW I brand exclusive experience store was opened to fully demonstrate the charm of BMW electric products
- 生成boot_para.img
- Golang中结构体Struct
- Thesis reading (53):universal advantageous perturbations
- Curator - implement service registration and discovery
- Flink 系例 之 CountWindow
- Crash usage
- MYSQL第一篇(基础知识)
猜你喜欢

Hevc HM learning 01

Flutter file operation

MYSQL第二篇(核心技术)

Transformer-XL 模型详解

Jifeng lighting | the spotlight without secondary light spot is perfect. The hill is perfect

Generate boot_ para. img

Idea cancels data simplification

Model Lightweight - cutting distillation Series yolov5 nonestructive Cutting (attached source)

Recursive function Hanoi Tower

Five best! Ant group passed the highest level evaluation of the "stability Assurance Plan" of the ICT Institute
随机推荐
Flutter DIO example
Unable to enter the ArrayList underlying solution during debug
Compilation error in multithreading
The R language catools package divides the data, randomforest package constructs the random forest model, and views the basic information output by the model (number of trees, estimation error outside
MTK基于GAT工具和SpOffineDebugSuite工具 dump 抓取和解析
QT配置OpenCV-4.5.1并运行程序
Builder pattern
MySQL advanced CRUD
MySQL-进阶CRUD
Understand ant bizstack cloud native development and governance platform
R language party package ctree function builds conditional inference decision trees, and uses plot function to visualize the trained conditional inference decision trees
自注意力机制中的位置编码
Display常用英文缩写
How to ensure system stability and achieve emission reduction? Ant group has these key technologies
Flink 系例 之 Watermarks
How to spread the whole page evenly in word
刃 7000P 内存频率限制 2400 的解决方法
An analysis of DuPont analysis: the financial situation of East China Construction Group Co., Ltd
idea 远程调试代码
Flutter file operation