Build platform under Ubuntu(一)

在Ubuntu下編譯linux2.6內核for OMAP5912。
結果:
1. Kernel image編譯成功,both 2.6.8-rc3 & 2.6.20;
2. Download到板子上都在Uncompress kernel image之後就沒反應了;
3. u-boot1.1.6編譯成功,down到板子上也可以使用;
TODO:
嘗試通過換平臺,換搭配來找到可以正常編譯的方法。
Echo確認fc6+2.6.20是可以的。

1. 串口支持
NB上不帶串口,使用USB2Serial線,發現可以自動識別爲/dev/ttyUSB0。用dmesg查看信息:
[ 3436.024000] usb 2-2: new full speed USB device using uhci_hcd and address 5
[ 3436.188000] usb 2-2: configuration #1 chosen from 1 choice
[ 3436.192000] cp2101 2-2:1.0: cp2101 converter detected
[ 3436.304000] usb 2-2: reset full speed USB device using uhci_hcd and address 5
[ 3436.452000] usb 2-2: cp2101 converter now attached to ttyUSB0
可以知道,我的這根USB轉串口線的芯片是cp2101。

2. 串口終端程序minicom配置
>Ubuntu默認沒有minicom,需要安裝一個先,我安裝的是v2.2;
>設置參數:
>> Select ‘Modem and Dialing’ and ensure that ‘Init string’ (A) is clear.
>> Use /dev/ttyUSB0 at 115,200 baud, 8Bps, no parity, 1 stop bit, and no flow control.

3. 重新燒寫uboot if needs
如果原來板子上的uboot被破壞,需要重新燒寫uboot。具體的燒寫方法,請參考《MDK5912 User Guide 3.3.2》 by Peter HE。
注意:
我在仿照文檔上的step時候,一旦執行到“Download binary image(osk5912boot.bin ) to address 0x11fc0000”,AXD就會報錯:“... re-enter debug ...”。
後來我直接
step 1. run romprog.axf;
step 2. Download binary image(osk5912boot.bin ) to address 0x11fc0000;
step 3. ... ...
這樣走下來後,再把AXD暫停,看起來好像系統跑飛了一樣。但是如果reboot board,居然燒成功了-_-!

4. 安裝tftp支持
Ubuntu默認沒有安裝tftp以及tftp必須的inetd/xinetd/inetd-hpa支持,需要自己安裝。
我基本按照參考文檔1安裝步驟來,卻沒那麼好運,盡是問題-_-!
1. 安裝tftp&tftpd;
2. 裝netkit-inetd時候提示:需要卸載tftpd&另外一個tftpd需要的package;
3. ps -e|grep inet發現系統根本沒跑inetd,倒是xinetd已經有了;
3. 仿照其它文檔配置/etc/xinetd.conf(osk newbie guider中也是用它,不過配置文件位置不一樣)之後,測試get file,不能通過;
4. 反覆裝了幾次tftpd&inetd後,發現居然某次沒要求必須卸載對方了-_-!;
5. 但是inetd reload還是不能啓動起來;
6. 第二天早上開機,ps -e發現inetd/xinetd都在run了;
7. 參考文檔上都說測試的時候連10.0.0.1,我實際試的時候tftp 127.0.0.1才OK(想想也是阿),真不知道是我和別人都不一樣還是很多人都沒自己試過?
8. 測試通過,看來還是inetd起的作用。昨天關鍵是不知道爲何,inetd一直沒run起來,rp阿rp。
參考文檔:
--------------------------------------------------
1. Ubuntu配置tftp服務
http://my.opera.com/volans/blog/show.dml/680197
2. 開發板實務(2)——配置宿主機服務: NFS, tftp
http://www.cublog.cn/u/13991/showart_108131.html
3. kubutu tftp配置
http://www.akae.cn/space/html/24/t-1324.html
4. Ubuntu Linux發行版新手應用指南[二]
http://www.enet.com.cn/article/2007/0509/A20070509577608_6.shtml
--------------------------------------------------

5. 配置網絡連接

1. 設置mac地址:
    OMAP #setenv ethaddr 00:0E:99:02:07:1C
2. 設置ip等:
    OMAP # setenv ipaddr 138.198.177.250
    OMAP # setenv serverip 138.198.177.80
    OMAP # setenv netmask 255.255.252.0
    OMAP # setenv gatewayip 138.198.179.254
Note:
直接執行dhcp來代替上面步驟,如果你的host pc支持的話。
3. 保存參數
    OMAP # saveenv

6. 燒寫kernel image
1. Send your ‘uImage.cc’ file to the ‘/tftpboot/’ directory on PC;
2. 下載kernel iamge到板子上:
    OMAP # tftpboot 0x10000000 uImage.cc
    得到結果,記錄kernel image size爲Bytes transferred = 1229199 (12c18f hex);
3. Then we erase the old kernel and put the new one on:
    OMAP # erase 1:8-15
    OMAP # cp.b 0x10000000 0x100000 12c18f (note: 12c18f is what you get above)
TIP: If you receive an error like this:
--------------------------------------------------
       Copy to Flash...not erased at xxxxxxxx (xxxx)
       Flash not Erased
--------------------------------------------------
You will need to erase more than the 8-15 range (我這裏需要erase到17).
4. Finally, we set some boot parameters for the kernel:
    OMAP # setenv bootargs console=ttyUSB0,115200n8 noinitrd ip=138.198.177.250:138.198.177.80:138.198.179.254:255.255.252.0:osk:eth0:off root=/dev/nfs rw nfsroot=138.198.177.80:/data/rootfs2.6,nolock mem=32M
    OMAP # saveenv
5. You are now ready to start the kernel:
    OMAP # bootm 0x100000
Bug Report:
此時走到“Uncompressing Linux...... done, booting the kernel.”就停住了。根據OSK newbie guider的說法,這是factory u-boot的bug,可以通過
> 升級u-boot;
>修改linux kernel file
中的一種方法解決。
6. 選擇5中的第二種方法解決,需要重新build kernel image。這次build kernel時候,與第一次不同的是:
> 修改osk newbie guider文檔中提到的源碼內容;
重新生成的kernel image保存爲doc/OMAP/**.20070608,uboot中生成的工具mkimage也保留了下來。
    --------------------------------------------------
    TIPS:
    mkimage參數中,-a和-e參數的關係:
    http://www.linuxforum.net/forum/printthread.php?Cat=&Board=embedded&main=555581&type=thread

    mkimage ... -a 0xa0008000 -e 0xa0008040 ...
    剛纔大致看了一下,如果你用壓縮的方式,應該 -a -e是一樣的。
    -a 指定的地址,是解壓之後存放的地址,也應該是執行的地址。
    而對於非壓縮的方式來說,就需要+0x40了。
    --------------------------------------------------
7. 最後生成的image還是在booting the kernel時候停下來沒有相應了。打算重新編譯一個新版本的u-boot試試看。

7. 編譯安裝新的u-boot
用arm-linux-3.3.4編譯u-boot-1.1.6成功pass,生成的u-boot保存爲doc/OMAP/u-boot.bin.20070608。
1. 下載arm-linux-gcc-3.3.4
http://www.handhelds.org/download/projects/toolchain/
2. 解壓到/usr/local/arm/3.3.4下,更改$PATH,編譯uboot——步驟參考osk newbie guider即可;
3. 在當前u-boot目錄下生成u-boot.bin;
4. 按照osk newbie guider步驟重新燒寫u-boot,重啓後看到u-boot版本信息爲1.1.6;
Note:啓動時候提示“*** Warning - bad CRC, using default environment”
    參考《U-Boot for the OMAP16xx GSM/GPRS Software Development Platform》的解釋:
    --------------------------------------------------
    This is harmless and will go away as soon as you have initialized and saved the environment
    variables. This indicates that the environment variables are not stored in flash. After the
    environment variables are saved using saveenv command, this warning will disappear.
    --------------------------------------------------
5. 重新boot Linux,還是老樣子!

8. 用omap官方提供的uboot image: osk-u-boot_8_11_05_RevD.bin替換自己生成的u-boot,無效。

9. 重新做一個非壓縮的uImage,重新嘗試,無效:
    # arm-linux-objcopy -O binary -R .note -R .comment -S arch/arm/boot/compressed/vmlinux linux.bin
    # mkimage -A arm -O linux -T kernel -C none -a 0x10c08000 -e 0x10c08000 -n 'Linux Kernel Image' -d linux.bin uImage.cc

10. 直接從ram中boot,無效:
    OMAP5912 OSK # tftp 0x10000000 uImage.cc
    OMAP5912 OSK # bootm 0x10000000

11. 編譯2.6.8-rc3:
按照《omap5912osk_2.6》來編譯linux 2.6.8-rc3,希望能pass。
1. Download source from OMAP官方網站;
2. 注意這次是用arm-gcc-3.3.4編譯的;
3. make omap5912osk_deconfig時候報錯:
    --------------------------------------------------
    scripts/kconfig/mconf.c:91: error: static declaration of 'current_menu'
    non-static declaration
    scripts/kconfig/lkc.h:63: error: previous declaration of 'current_menu'
    make[1]: *** [scripts/kconfig/mconf.o] Error 1
    --------------------------------------------------
    據說是2.6.8(or lower version)和Ubuntu的gcc-4.*的衝突造成。一個簡單的辦法就是把出錯地方的static聲明去掉。
4. 結果還是無效!
5. 編譯的uImage.cc保存爲uImage.cc.20070608_2。
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章