1. 程式人生 > >移植ubuntu core到Arm開發板

移植ubuntu core到Arm開發板

最初是想把整個ubuntu移植到MX51開發板,因為專案不需要執行桌面系統,所以只移植了一個基本的ubuntu core系統

 1. 下載ubuntu core rootfs,關於ubuntu core參考https://wiki.ubuntu.com/Core

http://cdimage.ubuntu.com/ubuntu-core/releases/12.04/release/ubuntu-core-12.04.3-core-armhf.tar.gz

這個映象就是一個rootfs,可以作為根檔案系統使用。

2. 把映象燒寫到開發板的一個分割槽上

  • adb shell進入開發板,busybox mkfs.ext2 /dev/block/mmcblk0p1
  • adb shell進入開發板,mount -t ext2 /dev/block/mmcblk0p1 /mnt
  • adb push ubuntu-core-12.04.3-core-armhf.tar.gz /mnt/
  • adb shell進入開發板,cd /mnt; busybox tar ubuntu-core-12.04.3-core-armhf.tar.gz. 在/dev/block/mmcblk0p1這個分割槽上建立了一個完整的rootfs,檔案系統型別為ext2

3. 我的arm開發板是mx51,修改uboot啟動引數如下:

set bootargs_android 'setenv bootargs ${bootargs_base} init=/init rdinit=asdf root=b301 rootfs=ext2

di0_primary video=mxcdi0fb:RGB24,CLAA-WVGA'

粗體是我增加的引數,解釋下增加的幾個引數:

  • rdinit=asdf,rdinit=後的asdf是胡亂寫的,這樣會設定ramdisk_execute_command為asdf,就導致核心程式碼
    if (sys_access((const char __user *) ramdisk_execute_command, 0) != 0) {
    sys_access訪問失敗,呼叫prepare_namespace 從mmcblk0p1安裝根檔案系統
  • root=b301,是/dev/block/mmcblk0p1的16進位制主裝置號b3和從裝置號01
  • rootfs=ext2,檔案系統型別

4. 啟動開發板,會打印出如下資訊:

VFS: Mounted root (ext2 filesystem) on device 179:1.

表示已經mount 根檔案系統成功。

這一步可能會出現如下錯誤:

udevd[123]: unable to receive ctrl connection: Function not implemented
udevd[123]: unable to receive ctrl connection: Function not implemented
udevd[123]: unable to receive ctrl connection: Function not implemented
udevd[123]: unable to receive ctrl connection: Function not implemented
udevd[123]: unable to receive ctrl connection: Function not implemented
udevd[123]: unable to receive ctrl connection: Function not implemented
如果你出現了,那麼執行第5步

5. 按連結給的patch, 修改核心

https://github.com/genesi/linux-legacy/commit/a84fac75f38de592e530a2f9f982d7aafec6c288

6. 編譯核心並燒寫到開發板上,重啟系統後,不會再列印step4的錯誤

7. 支援LCD console,修改核心配置檔案如下

@@ -1228,8 +1228,14 @@ CONFIG_FB_MXC_SYNC_PANEL=y
 # Console display driver support
 #
 # CONFIG_VGA_CONSOLE is not set
+# CONFIG_VGACON_SOFT_SCROLLBACK is not set
 CONFIG_DUMMY_CONSOLE=y
-# CONFIG_FRAMEBUFFER_CONSOLE is not set
+CONFIG_FRAMEBUFFER_CONSOLE=y
+# CONFIG_FRAMEBUFFER_CONSOLE_DETECT_PRIMARY is not set
+# CONFIG_FRAMEBUFFER_CONSOLE_ROTATION is not set
+# CONFIG_FONTS is not set
+CONFIG_FONT_8x8=y
+CONFIG_FONT_8x16=y

重新編譯核心,重啟系統後,可在LCD看到ubuntu的登入console

8 支援serial console,我的開發板沒有usbhost,不能接usb鍵盤,所以需要用serial console控制

  • 在/etc/init.d增加檔案/etc/init/ttymxc.conf
  • # console - getty
    #
    # This service maintains a getty on console from the point the system is
    # started until it is shut down again.
    
    start on stopped rc RUNLEVEL=[2345] and container CONTAINER=lxc
    
    stop on runlevel [!2345]
    
    respawn
    exec /sbin/getty -L 115200 ttymxc0 vt102
    

  • 修改rootfs的檔案/etc/rc.local,如下
  • #!/bin/sh -e
    #
    # rc.local
    #
    # This script is executed at the end of each multiuser runlevel.
    # Make sure that the script will "exit 0" on success or any other
    # value on error.
    #
    # In order to enable or disable this script just change the execution
    # bits.
    #
    # By default this script does nothing.
    start ttymxc0
    exit 0
    

重新啟動後,即可在串列埠得到控制檯資訊。