PowerPC 衝吧!

jollen 發表於 September 16, 2006 1:02 AM

這星期四五都在把玩公司的 PowerPC 板子,目標是 build BIOS (U-Boot)、kernel (2.6) 與基本的 root filesystem。因此就來把這二天建立 root filesystem 的心得簡單整理一下與大家分享。

PowerPC 是定義在 large-scale 的嵌入式系統,因此與一般的 small-scale embedded system 有幾個技術面的差異,若以 embedded Linux 的角度來看,幾點主要差異是:

(1) large-scale ES 通常都有 mass storage (eg. HD) 或利用 NFS/BOOTP/PXE 來開機後由 NFS server mount 完整系統,所以開機時只要先提供 NFS root filesystem 即可。
(2) 由 (1),因此可以「灌」完整的 Linux distribution 在「NFS server」上,以 PowerPC 來講的話,可以選擇 Yellow Dog Linux、Red Hat Linux for PowerPC 與 Debian PPC (或 Ubuntu PPC);Jollen 的話是選擇用 Debian PPC。
(3) NFS root filesystem 可以用 busybox,不過建議是 porting 完整的 init 與 mount,因此需要下載 sysvinit 與 util-linux 二個套件。
(4) 要 mount NFS 的話,target 端最好要有 portmap daemon,以加速 NFS mount,也才不會出現「portmap: NFS server local not responding」之類的訊息。(建議是一定要裝啦)

其它該注意的小地方也給大家分享一下:

(1) 網路上可以教到 NFS mount 的做法有二種,一種是傳遞 "nfsroot" 參數給 kernel,由 kernel 去 mount,另一種是 build 一個 "NFS root filesystem",然後用 fstab (也就是 mount) 去做,不過 Jollen 的建議是後者。有一些網路的文件也是建議後者。
(2) portmap 需要 tcp_wrapper 套件,記得一併下載。
(3) IP 的設定建議在開機時由 kernel 去做,不要開完機後再用 ifconfig 去設定。

提供這二天建的 NFS root filesystem for PowerPC 給大家參考,檔案要由 forum 下載。基本上,使用下列套件來 build root filesystem 就能做出一個簡單的 NFS rootfs 了 (這是 Jollen 使用的套件版本):

* busybox 1.1.3 (關掉內建的 mount / unmount)
* util-linux 2.12r
* tcp_wrapper 7.6 (for NFS mount)
* portmap_4 (for NFS mount)

我們的板子採用 U-Boot 來做開機程式。記得要在 U-Boot 下設定 kernel command line,把 NFS 的設定加上去才行。以下 Jollen 設定 kernel 的開機參數('ip='用來做Kernel Mode IP Configuration):

u-boot> set bootargs console=ttyS0,115200 root=/dev/ram0 ramdisk=8192 netconsole=6665@10.100.10.12/eth0,6666@10.100.10.20/
ip=10.100.10.12:10.100.10.20:10.100.10.254:255.0.0.0:ppc:eth0

'netconsole=' 的話可有可無,加上去的話可以配合 netcat 來看到 "console" 畫面。這是我們的 PowerPC 板子用的開機指令:

u-boot> tftp 1000000 uImage; tftp 1200000 urootfs_ppc.img; bootm 1000000 1200000

開機後進入 Linux 命令模式後,再用 mount 把 NFS server 的目錄 mount 即可,由於我們用的 kernel 是 2.6,因此是用 'switch_root' 指令來變更 root 目錄,而不是用 "chroot"。

Jollen's Blog 使用 Github issues 與讀者交流討論。請點擊上方的文章專屬 issue,或 open a new issue

您可透過電子郵件 jollen@jollen.org,或是 Linkedin 與我連絡。更歡迎使用微信,請搜尋 WeChat ID:jollentw