Custom Kernel

    內容表格
    沒有標頭

    版本為 00:11, 29 Jul 2026

    到這個版本。

    返回到 版本存檔.

    查閱目前版本

    Edit by OSSLab :thx

    本文特別感謝數位天堂 Hippo and Jserv
    本篇文章目地是讓一般用戶瞭解 一些高手怎樣始用一些原始碼 自己編寫軔體.
    網通設備的開發由來..

    運作環境 ubuntu 11.04 Desktop 版以linux-3.1.10 舉例.

     

    $ wget ftp://ftp.isu.edu.tw/Linux/kernel/linux-3.1.10.tar.xz #取得Kernel 原始碼
    $ tar -xJf linux-3.1.10.tar.xz -C Source 
    $ sudo ln -s /home/使用者/Source/linux-3.1.10 /usr/src/linux-3.1.10
    $ apt-get install uboot-mkimage  # 安裝mkimage
    

     




    2. 交叉編譯器.
    arm交叉編譯器套件., 到CodeSourcery下載現成的. 如果注意console輸出訊息, 韌體核心使用CodeSourcery ARM 2005q3-2編譯.

     

    編譯器安裝

    首先先到https://sourcery.mentor.com/GNUToolchain/release1802?lite=arm 下載

    本次使用

       

     

    wget https://sourcery.mentor.com/GNUToolchain/package8736/public/arm-none-eabi/arm-2011.03-42-arm-none-eabi.bin
    tar -xjf arm-2011.03-42-arm-none-eabi.bin
    
    chmod +x arm-2011.03-42-arm-none-eabi.bin
    接下來再執行以下指令,之後選否
    sudo dpkg-reconfigure dash
    
    .\arm-2011.03-42-arm-none-eabi.bin

    就會執行安裝了

    sudo vi /etc/profile
    在最后增加:
    PATH=$HOME/thx/CodeSourcery/Sourcery_G++_Lite/bin:$PATH

    保存退出。
    增加路径为安装路径。
    测试环境变量是否生效,重新登录后:
    arm-none-linux-gnueabi-gcc -v
    出現版本訊息就正常

     

     

    $home/CodeSourcery/Sourcery_G++_Lite/bin
    

     

    3. linux-3.2.11
    學術網路上都有原始碼. 如果使用Marvell釋出的原始碼也行, 但要搞定machine ID.
    交叉編譯環境+Linux原始碼搞定後,

    $ make ARCH=arm help ... orion5x_defconfig - Build for orion5x ...


    好, 有預設的config, 動手.

    #!/bin/sh Toolchain=arm-2005q3-2 export PATH=$HOME/bin/$Toolchain/bin:$PATH export CROSS_COMPILE=arm-none-linux-gnueabi- export ARCH=arm export CFLAGS="-mtune=arm926ej-s -march=armv5te" export INSTALL_MOD_PATH=$HOME/NAS-34 cd /usr/src/linux-3.2.11 make mrproper make orion5x_defconfig make menuconfig make -j2 uImage && \ make -j2 modules && \ make modules_install




    編譯完成後, linux-3.2.11/arch/arm/boot/目錄下, 就有uImage了.
    準備一台 Tomato TFTP server,
    NAS-34接上TTL console線, 開機後 要在 Console 下快速按下 Enter  , 中斷U-Boot.

    >> dhcp >> setenv bootargs 'console=ttyS0,115200 mem=128M' >> tftpboot 800000 uImage >> bootm 800000

    然後比對原廠韌體的console訊息, 查看自己編譯的核心是否有遺漏等等. 如果核心出錯, 回頭再重新編譯.

     

    自認核心都沒問題後, 準備rootfs. rootfs可放在硬碟或NFS server.

     

    參考linux-3.2.11/Documentation/內的文件, 修改U-Boot bootargs值, 再測試進入Linux OS.

     

    開 機到進入Linux OS都搞定後, 可準備將uImage複製到硬碟, 插入硬碟就進入Linux OS. 參考U-Boot網站文件, 撰寫自己的U-Boot參數, 設定開機啟動順序. 覆寫原廠U-Boot參數前, 先printenv, 將原廠U-Boot參數備份.

    下載至/boot, 並建立連結
    # ls -l /boot/uImage* lrwxrwxrwx 1 root root 29 Mar 25 2012 /boot/uImage -> uImage-2.6.32-5-orion5x.ts209 -rw-r--r-- 1 root root 1315904 Mar 25 2012 /boot/uImage-2.6.32-5-orion5x.ts209


    U-Boot參數

    >> ext2load ide 0:1 0x800000 /uImage >> ext2load ide 0:1 0xa00000 /initrd.img >> setenv bootargs 'console=ttyS0,115200 mem=128M root=/dev/sda2 rootfstype=ext3 initrd=0xa00000,0x8fffff' >> bootm 0x800000

     

     

     setenv serverip 192.168.7.57   # 設定 kernel nfs ip server
    setenv ipaddr 192.168.7.11      #
    printenv  #顯示設定組態
    tftpboot 800000 uImage  #
    bootm 800000#
    setenv bootargs 'console=ttyS0,115200 mem=128M'
    
    setenv bootargs 'console=ttyS0,115200 root=/dev/nfs nfsroot=192.168.7.57:/home/thx/NAS-34/rootfs ip=192.168.7.114:192.168.7.57:192.168.7.2:255.255.255.0::eth0:off noinitrd mem=128M'
    
    setenv bootargs 'console=ttyS0,115200 root=/dev/nfs nfsroot=192.168.7.57:/home/thx/NAS-34/rootfs  noinitrd mem=128M'
    
    

     

    更新apt套件庫

    apt-get -y dist-upgrade

     

    之後到ubuntu arm的資料夾下打入下列指令

    #!/bin/sh export ARCH=arm export CFLAGS="-march=armv5te -mtune=arm926ej-s" cd /usr/src/linux-3.1.10-10-ARCH make clean make menuconfig make uImage && \ make modules && \ sudo make modules_install 

    之後進入選擇選單的地方,選擇ARM晶片(基板上)的地方為 System Type --->Arm sysetem type -->Orion

     Kernel Configuration --->取消Memory Technology Device (MTD) support


    參考
    http://digiland.tw/viewtopic.php?id=1942
    http://buffalo.nas-central.org/index...M9_Kernel_Port
    http://computingplugs.com/index.php/..._custom_kernel
    http://www.nslu2-linux.org/wiki/Optware/PlugComputers
    http://plugcomputer.org/plugwiki/ind...nel_and_U-Boot
    http://linux.vbird.org/linux_basic/0...#startup_intro

    Powered by MindTouch Core