2012/10/20

nextvod - compile kernel

[2014/03/23更新]

程式碼來源(擇一)

1. 建立交互編譯環境

有幾種方法(擇一即可):

  1. 安裝 docker 運用之前幫你包好的套件環境
    1. docker run -t -i dlin/ubuntu-stlinux24 /bin/bash
      1. export PATH=$PATH:/opt/STM/STLinux-2.4/host/bin:/opt/STM/STLinux-2.4/devkit/sh4/bin
      2. apt-get update -y && stmyum update -y  # 更新到最新版
  2. 安裝 sudo debian 環境
  3. 使用 shpkg 安裝到 Arch Linux 系統(缺點:更新會比 STLinux 網站慢)
    1. 安裝 shpkg 20131029-1 之後的版本到 PC 上的 Linux.
    2. shpkg -Syu
    3. shpkg -S sh4twbox-hello
    4. cd /sh4twbox-hello
    5. ./inst_st24_dev.sh cross

2. 編譯步驟如下:

make.sh all

以下為 make.sh 概略邏輯
  1. 編譯 u-boot 裏面的 mkimage 工具
  2. 編輯設定檔(.config)編譯 kernel,使用來源2,可忽略此步驟, 指令如下 make mrproper make ARCH=sh CROSS_COMPILE=sh4-linux- help # choose method 1 or 2 # method 1 make ARCH=sh CROSS_COMPILE=sh4-linux- pdk7105se_defconfig # failed # method 2 make ARCH=sh CROSS_COMPILE=sh4-linux- pdk7105_defconfig make ARCH=sh CROSS_COMPILE=sh4-linux- menuconfig
    1. System type/Memory management options/Physical memory size:
      1. 調成 0x10000000 可支援 256M 記憶體
    2. General Option/Support for paging of anonymous memory (swap):
      1. 支援 swap (不過若swap到慢速DOM,可能導致系統變慢)
    3. 參考這兩篇作效能調整
      1. http://oranqe.wordpress.com/2013/03/06/nextvod-kernel-compile/
      2. http://oranqe.wordpress.com/2013/03/07/save-energy-for-sh4twbox/
      3. make 加上選項 CFLAGS="-m4a -pipe -O3 -ffast-math"
  3. ref: http://blog.csdn.net/lqrensn/article/details/5533613
  4. 編譯 make -j5 ARCH=sh CROSS_COMPILE=sh4-linux- vmlinux
  5. 編譯若不通過修改 Makefile add -I to CFLAGS & CPPFLAGS
  6. 產生 vmlinux.ub 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
編譯出現警告訊息,不知道是否有問題,如 log
  • 2012/10/20 依照公佈的原始程式,編譯成功,  加上uboot的mkimage 才能變成uboot可用格式, 實機測試, /dev/sdb4 全刪去, 放入 kernel 到 sdb4, 並且以之前編的 busybox 放進去, 失敗, log 如附 (失敗原因為 busybox 需要搭配的 lib/* 檔案)
  • 2012/11/05 直接使用 來源2 編譯即可,裏面有現成的 .config, 可省略 menuconfig 動作
  • 2013/01/06 改 .config 設定 CONFIG_MEMORY_SIZE=0x10000000 支援 256M 記憶體(需搭配 boot 參數 mem=256M)
  • 2013/10/30 新增 sh4twbox 0.9.2 之後 kernel 編譯方式

沒有留言: