物聯網之系統移植四(內核移植)

內核移植筆記:https://blog.csdn.net/weixin_39148042/article/details/82494980

Linux內核移植

1、配置編譯

2、網卡移植

3、第三方驅動移植

Linux內核 配置編譯

內核移植之一   配置編譯

• 下載內核源碼  (谷歌搜索 linux-3.14.tar.xz ,會很快找到有許多內核版本的列表)

• Linux系統中解壓  (  tar -xvf  linux-3.14.tar.xz 注意不能在與window的共享目錄解壓)

• 修改Makefile指定交叉編譯工具鏈

• 導入配置  make exynos_defconfig(配置列表見 arch/arm/configs/  找最類似的)

• 配置內核 make menuconfig

• 編譯內核 make uImage

• 編譯設備樹  make dtbs

網卡移植

NFS 服務

網卡移植  平臺無關

• 配置內核支持網絡 

       $ make menuconfig

• 配置網絡協議支持TCP/IP

        [*] Networking support   --->     //注意要先輸入y  選擇該菜單,再按enter鍵,才能看到下面的選項

          Networking options  --->

                     <*> Packet socket

                     <*> Unix domain sockets

           [*] TCP/IP networking

                     [*]   IP: kernel level autoconfiguration

• 配置支持網絡文件系統 NFS

       File systems  --->   [*] Network File Systems  --->

            <*>   NFS client support

          <*>     NFS client support for NFS version 2

                                              [*]     NFS client support for NFS version 3

                                              [*]     NFS client support for the NFSv3

                                                      ACL protocol extension

                                              [*]   Root file system on NFS    

• 配置支持dm9000網卡驅動           

        Device Drivers  --->

                    [*] Network device support  --->

                    [*]   Ethernet driver support  --->

                   <*>   DM9000 support

網卡移植  平臺相關

• 配置設備樹描述網卡和CPU的鏈接情況 

       $ vim arch/arm/boot/dts/exynos4412-fs4412.dts  在 regulators 前添加下面代碼

         srom-cs1@5000000 {

compatible = "simple-bus";

#address-cells = <1>;

#size-cells = <1>;

reg = <0x5000000 0x1000000>;    對應芯片手冊 3 Memory Map 的0x0500_0000  和 16 MB ranges;

ethernet@5000000 {

    compatible = "davicom,dm9000";  內核通過該名字來匹配驅動

    reg = <0x5000000 0x2 0x5000004 0x2>;  寄存器地址和數據寬度

    interrupt-parent = <&gpx0>;   繼承於 中斷控制器gpx0

            interrupts = <6 4>; 6  對應中斷源 DM9000_IRQ -> XEINT6 。4對應 active high level-sensitive     davicom,no-eeprom;

    mac-address = [00 0a 2d a6 55 a2];

};

};

• 修改文件driver/clk/clk.c   static bool clk_ignore_unused;改爲static bool clk_ignore_unused = true;

CPU與設備連接描述  -   設備樹DeviceTree

Device Tree是描述硬件信息的數據結構

用於管理 硬件拓撲和硬件資源信息。

Device Tree由一系列被命名的結點(node)和屬性(property)組成,而結點本身可包含子結點。

所謂屬性,其實就是成對出現的name和value。

幫助

百度:linux Device Tree 詳解

官網:http://www.devicetree.org 和 http://elinux.org/Device_Tree

源碼實例:

        說明: Documentation/devicetree/bindings/arm

        源碼: arch/arm/boot/dts/exynos4412-origen.dts

CPU與設備連接描述  -   平臺設備

    在內核裏有一個結構“struct machine_desc”,內核用這個結構表示一個實際存在的板子,而針對每個板子都會有一個文件定義這個結構體,這個文件叫平臺代碼;

    如:arch/arm/mach-s5pv21/mach-smdkv210.c(新版本內核中沒有基於Exynos4412的平臺代碼,這裏以s5pv210爲例)

MACHINE_START(SMDKV210, "SMDKV210")

/* Maintainer: Kukjin Kim <[email protected]> */

.atag_offset = 0x100,

.init_irq = s5pv210_init_irq,

.map_io = smdkv210_map_io,

.init_machine = smdkv210_machine_init,

.init_time = samsung_timer_init,

.restart = s5pv210_restart,

.reserve = &smdkv210_reserve,

MACHINE_END

第三方驅動移植

第三方驅動  黑盒移植

編譯驅動進內核

   a.  選擇驅動存放目錄 (或任意目錄)

   b.  改Makefile

   c.  改Kconfig  (界面可配置)

 

編譯驅動爲獨立的模塊

   a. 配置爲模塊方式

   b. make modules 編譯爲模塊

   c. 創建設備節點(應用訪問驅動的入口

           d. 運行測試驅動的應用程序

第三方驅動  白盒移植

• 打印跟蹤 

• 驅動框架

   

字符設備框架

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章