Was this page helpful?

STLinux Linux kernel (sh4-linux) Cross-Compile

    編譯 sh linuk 的 kernel (vmlinux.ub)

    注意:編譯環境不可使用 Ubuntu 8.04

    更多文章

    下載 kernel 的完整原始檔

    http://code.google.com/p/nexttv-mod/downloads/list

    Kernel 版本:linux-sh4-2.6.23.17_stm23_A18B

    編譯 vmlinux

    將檔案解壓縮後,進入編譯的主目錄內

    將附檔區的編譯設定檔更名為 .config,並且複製到主目錄內

    交叉編譯指令

    cd /home/alang/STLinux/build_source/linux-sh4-2.6.23.17_stm23_A18B/linux-sh4-2.6.23.17_stm23_A18B
    make ARCH=sh CROSS_COMPILE=sh4-linux- pdk7105_defconfig
    make ARCH=sh CROSS_COMPILE=sh4-linux- vmlinux
    

    TIPs:

    - 使用原始目錄內的 .config 這是網樂通的原始編譯設定檔

    - 如果編譯的主機有四核心,可以加上 -j4,會加快編譯速度

    - 重複編譯前,先執行  (注意:不可執行 make distclean,否則 .config* 檔案都會被移除)
    make clean
    rm vmlinux.*

    - 要修改編譯的參數,不可直接使用 make menuconfig 來產生 .config,而是必須手動編輯 .config 檔

    - 如果無法確定編譯參數的內容,參考下述步驟:
    1. 備份 .config
    2. 執行 make menuconfig,找到要編譯的項目後儲存
    3. 檢查 .config 用關鍵字搜尋找出實際的編譯參數內容
    4. 復原 .config 檔案,手動加上編譯參數

    編譯模組

    make ARCH=sh CROSS_COMPILE=sh4-linux- modules
    make ARCH=sh CROSS_COMPILE=sh4-linux- modules_install INSTALL_MOD_PATH=./modules_install
    

    TIPs:

    INSTALL_MOD_PATH 編譯後模組的安裝目錄

    製作 vmlinux.ub

    官方教學:http://www.stlinux.com/u-boot/mkimage/kernel-images

    sh4-linux-objcopy -O binary vmlinux vmlinux.bin
    gzip --best --force vmlinux.bin
    mkimage -A sh -O linux -T kernel -C gzip -a 0x80800000 -e 0x80801000 -n "Linux 2.6" -d vmlinux.bin.gz vmlinux.ub
    

    TIPs:

    如果系統沒有 gzip, mkimage 指令,可以使用 apt-get 安裝
    注意:Ubuntu 8.04 不支援 uboot-mkimage 的安裝  

    Q&A

    Q: 在網樂通上編譯 APP 時需要 kernel source,怎辦?

    如果要將 kernel source 複製到網樂通上使用,必須在網樂通上重新編譯過,並且相關目錄的路徑為:

    • kernel-source
      • /usr/src/2.6.23.17_stm23_A18B-PDK7105-32BITS-A18B
    • kernel-modules
      • /lib/modules/2.6.23.17_stm23_A18B-PDK7105-32BITS-A18B
      • /lib/modules/2.6.23.17_stm23_A18B-PDK7105-32BITS-A18B/build -> /usr/src/2.6.23.17_stm23_A18B-PDK7105-32BITS-A18B
      • /lib/modules/2.6.23.17_stm23_A18B-PDK7105-32BITS-A18B/source -> /usr/src/2.6.23.17_stm23_A18B-PDK7105-32BITS-A18B
    Q: 強制使用 /dev/sda3 做 rootfs
    1. 編譯 kernel 必須在 .config 加上
      CONFIG_CMDLINE_OVERWRITE=y
      CONFIG_CMDLINE="console=ttyAS0,115200 root=/dev/sda3  rootfstype=ext3 rw  nwhwconf=device:eth0"
    2. 由於 U-Boot 指定了 /dev/sda2 為 rootfs,要覆蓋 U-Boot 的設定,必須將 vmlinux.ub 放置 /dev/sda2 與 /dev/sda3。
    3. nwhwconf 若不加,會無法驅動網路卡
    4. 網卡的 MAC address 只要重開機就會自動變更另一組,若網路設定為 DHCP 時,這會造成每次重開機後,取得 IP 都會不同。
    Q: 支援 256 MB Memory

    System type -> Memory management options ->

    • Physical memory size = 0x20000000
    Q: CPU 低耗電

    System type -> CPU Frequency scaling ->

    • 'conservative' cpufreq governor
       

    檢查目前時脈

    cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq
    

    啟用

    echo "conservative" > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
    
    Was this page helpful?
    標籤 (Edit tags)
    • No tags

    文件 2

    文件大小日期附件上傳者 
     config.256M_iptables_openvpn
    無描述
    33.68 KB14:40, 7 May 2013alang動作
     config_v2.256M_iptables
    v2, 支援 256MBRAM,iptables 及相關模組
    33.69 KB14:22, 14 Jan 2013alang動作
    您必須 登入 才能發佈評論。
    Powered by MindTouch Core