參考:
https://coldnew.github.io/f5873b3f/
https://shumeipai.nxez.com/2020/10/18/compile-raspberry-pi-4b-linux-5-9-kernel.html
我的樹莓派版本為:
>uname -a
Linux raspberrypi 5.10.11-v7+ #1399 SMP Thu Jan 28 12:06:05 GMT 2021 armv7l GNU/Linux
這裡直接在樹莓派機器上編譯5.9,不需要下載下傳cross-compile 編譯器
源碼下載下傳
>git clone --depth=1 --branch rpi-5.9.y https://github.com/raspberrypi/linux
>git branch -a
* rpi-5.9.y
remotes/origin/rpi-5.9.y
tools下載下傳:
>git clone git://github.com/raspberrypi/tools.git
下載下傳依賴項
apt install git bc bison flex libssl-dev make libc6-dev libncurses5-dev
編譯:
/home/pi/myrasp/linux>make -j4 &
/home/pi/myrasp/linux>make bcmrpi_defconfig
/home/pi/myrasp/linux>make menuconfig
生成kernel.img
/home/pi/myrasp/tools> ./imagetool-uncompressed.py ../../linux/arch/arm/boot/Image
安裝 kernel module 到臨時目錄
/home/pi/myrasp> mkdir modules_build
/home/pi/myrasp>cd linux/
/home/pi/myrasp/linux> INSTALL_MOD_PATH="../modules_build" make modules_install