1. 程式人生 > >deepin15.5 建立核心原始碼樹

deepin15.5 建立核心原始碼樹

簡要說明

系統環境: deepin-15.5-amd64
deepin在安裝系統時,已經有有核心原始碼樹可直接使用:

# cd /lib/modules/4.9.0-deepin13-amd64/build

根據網上其他部落格的整理,在自己電腦上按照如下步驟,重新完成新的原始碼樹建立,步驟如下。

重新建立原始碼樹

下面主要介紹重新建立新的原始碼樹的過程
1.檢視當前執行的核心版本

skyeworld@skyeworld-PC:~/Desktop$ uname -r
4.9.0-deepin13-amd64

2.查詢可用的原始碼包

skyeworld@skyeworld-PC:~/Desktop$ sudo apt-cache search linux-source
[sudo] skyeworld 的密碼:
linux-source - Linux kernel source (meta-package)
linux-source-4.1 - Linux kernel source for version 4.1 with Debian patches
linux-source-4.11 - Linux kernel source for version 4.11 with Debian patches
linux-source-4.2 - Linux kernel source for version 4.2 with Debian patches
linux-source-4.3 - Linux kernel source for version 4.3 with Debian patches
linux-source-4.4 - Linux kernel source for version 4.4 with Debian patches
linux-source-4.4-deepin - Linux kernel source for version 4.4-deepin with Debian patches
linux-source-4.5 - Linux kernel source for version 4.5 with Debian patches
linux-source-4.6 - Linux kernel source for version 4.6 with Debian patches
linux-source-4.7 - Linux kernel source for version 4.7 with Debian patches
linux-source-4.8 - Linux kernel source for version 4.8 with Debian patches
linux-source-4.9 - Linux kernel source for version 4.9 with Debian patches
linux-source-deepin - Linux kernel source (meta-package)

3.下載安裝包

skyeworld@skyeworld-PC:~/Desktop$ sudo apt-get install linux-source-4.9
linux-source-4.1         linux-source-4.3         linux-source-4.5         linux-source-4.8         
linux-source-4.11        linux-source-4.4         linux-source-4.6         linux-source-4.9         
linux-source-4.2         linux-source-4.4-deepin  linux-source-4.7    

4.解壓

cd  /usr/src
sudo tar -Jvxf linux-source-4.9.tar.xz 

5.編譯核心

cd linux-source-4.9/
sudo make oldconfig    /*會給出提示,一隻回車就行了,具體什麼設定暫未了解 */
sudo make bzImage   /*  執行時間較長 ,慢慢等待,執行完成後,執行完成後,會在目錄中多一個vxlinux檔案 */

6.編譯模組

sudo make modules /* 執行時間較長,請慢慢等待*/

7. 安裝模組

sudo make modules_install

hello模組編寫執行

hello.c原始碼如下

Makefile原始碼如下

hello模組裝載域解除安裝
裝載:insmod hello.ko
檢視是否裝載:lsmod |grep hello.ko
檢視列印: dmesg /* deepin 訊息不會在控制檯列印,需要使用dmesg命令檢視最後輸出*/
解除安裝:rmmod hello.ko