Panda ICSビルド

solaさんの追試。
ローカルのAOSPミラーを使う。

kinneko@BuildSV:~/panda$ mkdir ics
kinneko@BuildSV:~/panda$ cd ics/
kinneko@BuildSV:~/panda/ics$ ../../repo init -u /home/kinneko/AOSP/platform/manifest.git 
kinneko@BuildSV:~/panda/ics$ ../../repo sync

SGXドライバなどを追加。

kinneko@BuildSV:~/panda/ics$ wget https://dl.google.com/dl/android/aosp/imgtec-panda-itl41d-dfebf249.tgz
kinneko@BuildSV:~/panda/ics$ tar zxf imgtec-panda-itl41d-dfebf249.tgz
kinneko@BuildSV:~/panda/ics$ ./extract-imgtec-panda.sh 

ここの操作は、1つ前と同じ。


ビルド。

kinneko@BuildSV:~/panda/ics$ rm imgtec-panda-itl41d-dfebf249.tgz extract-imgtec-panda.sh 
kinneko@BuildSV:~/panda/ics$ source build/envsetup.sh
including device/samsung/maguro/vendorsetup.sh
including device/samsung/tuna/vendorsetup.sh
including device/ti/panda/vendorsetup.sh
including sdk/bash_completion/adb.bash

kinneko@BuildSV:~/panda/ics$ lunch full_panda-eng

============================================
PLATFORM_VERSION_CODENAME=REL
PLATFORM_VERSION=4.0.1
TARGET_PRODUCT=full_panda
TARGET_BUILD_VARIANT=eng
TARGET_BUILD_TYPE=release
TARGET_BUILD_APPS=
TARGET_ARCH=arm
TARGET_ARCH_VARIANT=armv7-a-neon
HOST_ARCH=x86
HOST_OS=linux
HOST_BUILD_TYPE=release
BUILD_ID=ICS_MR0
============================================

kinneko@BuildSV:~/panda/ics$ time make -j12
(略)
real	27m22.821s
user	248m39.990s
sys	14m33.140s

まぁ、速度は普通。


次はkernel。
toolchainは前から使っているものを指定。

kinneko@BuildSV:~/panda/ics$ mkdir kernel
kinneko@BuildSV:~/panda/ics$ cd kernel/
kinneko@BuildSV:~/panda/ics/kernel$ git clone https://android.googlesource.com/kernel/omap
kinneko@BuildSV:~/panda/ics/kernel$ cd omap/
kinneko@BuildSV:~/panda/ics/kernel/omap$ git checkout -b android-omap-panda-3.0 origin/android-omap-panda-3.0
Checking out files: 100% (37523/37523), done.
Branch android-omap-panda-3.0 set up to track remote branch android-omap-panda-3.0 from origin.
Switched to a new branch 'android-omap-panda-3.0'
kinneko@BuildSV:~/panda/ics/kernel/omap$ export ARCH=arm
kinneko@BuildSV:~/panda/ics/kernel/omap$ export CROSS_COMPILE=arm-none-linux-gnueabi- 
kinneko@BuildSV:~/panda/ics/kernel/omap$ export PATH=/home/kinneko/panda/L27.12.1-P2/build_tools/arm-2010q1/bin:/usr/bin:/bin
kinneko@BuildSV:~/panda/ics/kernel/omap$ make panda_defconfig
  HOSTCC  scripts/basic/fixdep
  HOSTCC  scripts/kconfig/conf.o
  SHIPPED scripts/kconfig/zconf.tab.c
  SHIPPED scripts/kconfig/lex.zconf.c
  SHIPPED scripts/kconfig/zconf.hash.c
  HOSTCC  scripts/kconfig/zconf.tab.o
  HOSTLD  scripts/kconfig/conf
#
# configuration written to .config
#
kinneko@BuildSV:~/panda/ics/kernel/omap$ time make uImage modules -j12
(略)
  Image arch/arm/boot/uImage is ready

real	1m13.291s
user	10m23.260s
sys	0m44.740s


rootfsのツリーを作る。

kinneko@BuildSV:~/panda/ics/kernel$ cd ../out/target/product/panda/
kinneko@BuildSV:~/panda/ics/out/target/product/panda$ cp -a root/* rootfs/
kinneko@BuildSV:~/panda/ics/out/target/product/panda$ cp -a system rootfs/
kinneko@BuildSV:~/panda/ics/out/target/product/panda$ vi rootfs/init.rc

以下をコメントアウト

on fs
# mount mtd partitions
    # Mount /system rw first to give the filesystem a chance to save a checkpoint
    mount yaffs2 mtd@system /system
    mount yaffs2 mtd@system /system ro remount
    mount yaffs2 mtd@userdata /data nosuid nodev
    mount yaffs2 mtd@cache /cache nosuid nodev
#on fs
# mount mtd partitions
    # Mount /system rw first to give the filesystem a chance to save a checkpoint
#    mount yaffs2 mtd@system /system
#    mount yaffs2 mtd@system /system ro remount
#    mount yaffs2 mtd@userdata /data nosuid nodev
#    mount yaffs2 mtd@cache /cache nosuid nodev

以下変更。

on post-fs
    # once everything is setup, no need to modify /
    mount rootfs rootfs / ro remount
    mount rootfs rootfs / rw remount

以下をコメントアウト

service console /system/bin/sh
    class core
    console
    disabled
    user shell
    group log
    #user shell
    #group log
kinneko@BuildSV:~/panda/ics/out/target/product/panda$ vi rootfs/init.omap4pandaboard.rc 

以下をコメントアウト

on fs
        mount ext4 /dev/block/platform/omap/omap_hsmmc.0/by-name/system /system wait ro
        mount ext4 /dev/block/platform/omap/omap_hsmmc.0/by-name/userdata /data wait noatime nosuid nodev
        mount ext4 /dev/block/platform/omap/omap_hsmmc.0/by-name/cache /cache wait noatime nosuid nodev
#on fs
#       mount ext4 /dev/block/platform/omap/omap_hsmmc.0/by-name/system /system wait ro
#       mount ext4 /dev/block/platform/omap/omap_hsmmc.0/by-name/userdata /data wait noatime nosuid nodev
#       mount ext4 /dev/block/platform/omap/omap_hsmmc.0/by-name/cache /cache wait noatime nosuid nodev


ubootをビルド。

kinneko@BuildSV:~/panda/ics/out/target/product/panda$ cd ../../../../..
kinneko@BuildSV:~/panda$ git clone git://git.omapzoom.org/repo/u-boot.git u-boot 
Cloning into u-boot...
fatal: read error: Connection reset by peer

をい。

kinneko@BuildSV:~/panda$ git clone git://git.omapzoom.org/repo/u-boot.git      
Cloning into u-boot...
remote: Counting objects: 140837, done.
remote: Compressing objects: 100% (25115/25115), done.
remote: Total 140837 (delta 114484), reused 140801 (delta 114455)
Receiving objects: 100% (140837/140837), 42.50 MiB | 388 KiB/s, done.
Resolving deltas: 100% (114484/114484), done.
kinneko@BuildSV:~/panda$ cd u-boot/
kinneko@BuildSV:~/panda/u-boot$ git checkout 601ff71c8d46b5e90e13613974a16d10f2006bb3
Note: checking out '601ff71c8d46b5e90e13613974a16d10f2006bb3'.
(略)
kinneko@BuildSV:~/panda/u-boot$ wget http://android-development-environment.googlecode.com/files/uboot.patch

パッチの内容は、CONFIG_BOOTDELAYを1にして何箇所かに追記していること、CONFIG_BOOTARGSの埋め込み、CONFIG_BOOTCOMMANDの埋め込み。

kinneko@BuildSV:~/panda/u-boot$ patch -p1 < uboot.patch
patching file include/configs/omap4430panda.h
kinneko@BuildSV:~/panda/u-boot$ make omap4430panda_config
Configuring for omap4430panda board...
kinneko@BuildSV:~/panda/u-boot$ time make -j12
(略)
real	0m3.185s
user	0m10.200s
sys	0m1.720s


xloaderをビルド。

kinneko@BuildSV:~/panda/u-boot$ cd ..
kinneko@BuildSV:~/panda$ git clone git://git.omapzoom.org/repo/x-loader.git
Cloning into x-loader...
remote: Counting objects: 1593, done.
remote: Compressing objects: 100% (407/407), done.
remote: Total 1593 (delta 1174), reused 1565 (delta 1163)
Receiving objects: 100% (1593/1593), 457.30 KiB | 76 KiB/s, done.
Resolving deltas: 100% (1174/1174), done.
kinneko@BuildSV:~/panda$ cd x-loader/
kinneko@BuildSV:~/panda/x-loader$ git checkout c8855fa6b85bd44073bd1b25dbffa99f02cbeeed
Note: checking out 'c8855fa6b85bd44073bd1b25dbffa99f02cbeeed'.
kinneko@BuildSV:~/panda/x-loader$ make omap4430panda_config
rm -f include/config.h include/config.mk
Configuring for omap4430panda board...
echo "/* Generarated file. Do not edit */" >./include/config.h
echo "#include <configs/omap4430panda.h>" >>./include/config.h
MPU at 1GHz revision..
kinneko@BuildSV:~/panda/x-loader$ time make ift
real	0m2.383s
user	0m0.830s
sys	0m0.060s

kinneko@BuildSV:~/panda/x-loader$ cd ..


できたファイルをSDCardにコピーする。
カードリーダーに2GBのSDCard挿す。
認識されたデバイス名を探す。

kinneko@BuildSV:~/panda$ dmesg 
[29960.845516]  sdb: sdb1

sdbのようだ。
メディアのパーティション情報を削除。
全部消えるので注意。

kinneko@BuildSV:~/panda$ sudo dd if=/dev/zero of=/dev/sdb bs=1 count=1024
[sudo] password for kinneko: 
1024+0 records in
1024+0 records out
1024 bytes (1.0 kB) copied, 0.00346839 s, 295 kB/s

3つパーティションを作成。
起動用のbootと、Android動いた時にsdcardとして認識されるmediaと、Androidのシステムが入るrootfs。

kinneko@BuildSV:~/panda$ sudo fdisk /dev/sdb
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0xdf7c7ae8.
Changes will remain in memory only, until you decide to write them.
After that, of course, the previous content won't be recoverable.

Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
         switch off the mode (command 'c') and change display units to
         sectors (command 'u').

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-1015, default 1): 
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-1015, default 1015): +64M

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 2
First cylinder (37-1015, default 37): 
Using default value 37
Last cylinder, +cylinders or +size{K,M,G} (37-1015, default 1015): +1024M

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 3
First cylinder (593-1015, default 593): 
Using default value 593
Last cylinder, +cylinders or +size{K,M,G} (593-1015, default 1015): 
Using default value 1015

Command (m for help): t
Partition number (1-4): 1
Hex code (type L to list codes): c
Changed system type of partition 1 to c (W95 FAT32 (LBA))

Command (m for help): a
Partition number (1-4): 1

Command (m for help): p

Disk /dev/sdb: 1967 MB, 1967128576 bytes
61 heads, 62 sectors/track, 1015 cylinders
Units = cylinders of 3782 * 512 = 1936384 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xdf7c7ae8

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1   *           1          36       68045    c  W95 FAT32 (LBA)
/dev/sdb2              37         592     1051396   83  Linux
/dev/sdb3             593        1015      799893   83  Linux

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.

WARNING: If you have created or modified any DOS 6.x
partitions, please see the fdisk manual page for additional
information.
Syncing disks.

とこんな感じ。
パーティションをフォーマット。

kinneko@BuildSV:~/panda$ sudo mkfs.vfat -F 32 -n "boot" /dev/sdb1
mkfs.vfat 3.0.9 (31 Jan 2010)
kinneko@BuildSV:~/panda$ sudo mkfs.vfat -F 32 -n "media" /dev/sdb2
mkfs.vfat 3.0.9 (31 Jan 2010)
kinneko@BuildSV:~/panda$ sudo mkfs.ext4 -j -L "rootfs" /dev/sdb3
mke2fs 1.41.14 (22-Dec-2010)
Filesystem label=rootfs
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
50064 inodes, 199973 blocks
9998 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=205520896
7 block groups
32768 blocks per group, 32768 fragments per group
7152 inodes per group
Superblock backups stored on blocks: 
	32768, 98304, 163840

Writing inode tables: done                            
Creating journal (4096 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 29 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.

フォーマットしたのをマウントしてファイルをコピー。

kinneko@BuildSV:~/panda$ sudo mount /dev/sdb1 /media/
kinneko@BuildSV:~/panda$ sudo cp -a x-loader/MLO /media/
cp: failed to preserve ownership for `/media/MLO': Operation not permitted

うぐ。権限保護ができなかっただけで、コピーはできているので気にしない。

kinneko@BuildSV:~/panda$ sudo cp -a u-boot/u-boot.bin /media/
cp: failed to preserve ownership for `/media/u-boot.bin': Operation not permitted
kinneko@BuildSV:~/panda$ sudo cp -a ics/kernel/omap/arch/arm/boot/uImage /media/
cp: failed to preserve ownership for `/media/uImage': Operation not permitted
kinneko@BuildSV:~/panda$ ls -al /media/
total 4043
drwxr-xr-x  2 root root     512 Nov 21 18:24 .
drwxr-xr-x 24 root root    4096 Sep  6 19:03 ..
-rwxr-xr-x  1 root root   21604 Nov 21 17:54 MLO
-rwxr-xr-x  1 root root  160528 Nov 21 17:52 u-boot.bin
-rwxr-xr-x  1 root root 3951668 Nov 21 17:16 uImage
kinneko@BuildSV:~/panda$ sudo umount /media/
kinneko@BuildSV:~/panda$ sudo mount /dev/sdb3 /media
kinneko@BuildSV:~/panda$ sudo cp -a ics/out/target/product/panda/rootfs/* /media/
kinneko@BuildSV:~/panda$ sudo chmod 777 -R /media/
kinneko@BuildSV:~/panda$ sudo umount /media 

出来上がり。
でも、テストするpandaが手元にない(^^;。


んー、実機では、kernelまで上がるけど、rootfsが来ない。
シェルに落ちて操作はできるな。


どこがマズいかな...


ディスプレイ変更したら普通に出た。

[    4.125762] Waiting 2sec before mounting root device...                      

のとこで、5秒くらい待っている感じがするけど。
HDMIなのに出力を選ぶのか?
あ、DVI側につないでたんだった(^^;。それは選ぶかも。
スクエアなモニタなので、表示が歪んでいる。


英語版書いた。
http://kinneko-android.blogspot.com/2011/11/how-to-make-ics-self-bootable-sd-card.html