Sunday, 18 December 2011

How to make ICS self bootable SD Card for Pandaboard



If you want to build ICS for Pandaboard, You must use master branch.
I used AOSP local mirror.

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

Ordinary, you can use AOSP directry, like this.

~/panda/ics$ repo init -u https://android.googlesource.com/platform/manifest.git 

And add binary video drivers.

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

Read license, and type "I ACCEPT".

Delete disused files.

~/panda/ics$ rm imgtec-panda-itl41d-dfebf249.tgz extract-imgtec-panda.sh 


Build ICS.

~/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

~/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
============================================

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

The value of "-j" option that may be the number of CPU in your build environment.

Download kernel.

~/panda/ics$ mkdir kernel
~/panda/ics$ cd kernel/
~/panda/ics/kernel$ git clone https://android.googlesource.com/kernel/omap
~/panda/ics/kernel$ cd omap/
~/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'

and build it.
You must add your path of the cross toolchain.

~/panda/ics/kernel/omap$ export ARCH=arm
~/panda/ics/kernel/omap$ export CROSS_COMPILE=arm-none-linux-gnueabi-
~/panda/ics/kernel/omap$ export PATH=/home/kinneko/panda/L27.12.1-P2/build_tools/arm-2010q1/bin:/usr/bin:/bin
~/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
#
~/panda/ics/kernel/omap$ time make uImage modules -j12
(snip)
  Image arch/arm/boot/uImage is ready
real 1m13.291s
user 10m23.260s
sys 0m44.740s

make rootfs tree.

~/panda/ics/kernel$ cd ../out/target/product/panda/
~/panda/ics/out/target/product/panda$ cp -a root/* rootfs/
~/panda/ics/out/target/product/panda$ cp -a system rootfs/

edit init.rc.

~/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

and

    mount rootfs rootfs / rw remount


service console /system/bin/sh
    class core
    console
    disabled
    #user shell
    #group log

edit init.omap4pandaboard.rc.

~/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

download uboot source codes.

~/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.

and build it.

~/panda$ cd u-boot/
~/panda/u-boot$ git checkout 601ff71c8d46b5e90e13613974a16d10f2006bb3
Note: checking out '601ff71c8d46b5e90e13613974a16d10f2006bb3'.
(snip)

You must add some short patches.

~/panda$ diff -Naur u-boot.org/include/configs/omap4430panda.h u-boot/include/configs/omap4430panda.h
--- u-boot.org/include/configs/omap4430panda.h 2011-11-22 16:05:02.384622136 +0900
+++ u-boot/include/configs/omap4430panda.h 2011-11-21 17:52:16.169639483 +0900
@@ -133,11 +133,11 @@
 /* Environment information */
 #if defined(CONFIG_4430ZEBU) && !defined(CONFIG_4430ES2)
 /* Give the standard Kernel jump command as boot cmd and without any delay */
-#define CONFIG_BOOTDELAY         0
+#define CONFIG_BOOTDELAY         1
 #define CONFIG_EXTRA_ENV_SETTINGS \
  "bootcmd=go 0x80008000\0"
 #else
-#define CONFIG_BOOTDELAY         0
+#define CONFIG_BOOTDELAY         1

 #endif /*CONFIG_4430ZEBU */

@@ -147,10 +147,9 @@
  " ip=dhcp"
 #else

-#define CONFIG_BOOTARGS "console=ttyO2,115200n8 mem=512M" \
- " init=/init vram=32M omapfb.vram=0:16M androidboot.console=ttyO2"
+#define CONFIG_BOOTARGS "console=ttyO2,115200n8 mem=1G androidboot.console=ttyO2 console=ttyO2,115200n8 mem=512M root=/dev/mmcblk0p3 rw rootdelay=2 init=/init vram=32M omapfb.vram=0:16M androidboot.console=ttyO2"

-#define CONFIG_BOOTCOMMAND "booti mmc0"
+#define CONFIG_BOOTCOMMAND "mmcinit 0;fatload mmc 0 0x80000000 uImage; bootm 0x80000000"

 #endif

Save this to "uboot.patch", and patch it.

~/panda/u-boot$ patch -p1 < uboot.patch
patching file include/configs/omap4430panda.h

Build it.

~/panda/u-boot$ make omap4430panda_config
Configuring for omap4430panda board...
~/panda/u-boot$ make
~/panda/u-boot$ cd ..

Get xloader.

~/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.
~/panda$ cd x-loader/
~/panda/x-loader$ git checkout c8855fa6b85bd44073bd1b25dbffa99f02cbeeed
Note: checking out 'c8855fa6b85bd44073bd1b25dbffa99f02cbeeed'.

And build it.

~/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..
~/panda/x-loader$ make ift
~/panda/x-loader$ cd ..

Fromat SD Card.
I used 2GB Card.
Inceart SD Card to build PC, and seek for device name.

~/panda$ dmesg
[29960.845516]  sdb: sdb1

Delete partitoins.

~/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

Add three new partitions.
boot, media, rootfs.
"boot" include xloader, uboot and kernel.
"media" is android user space.
"rootfs "include android systems.

~/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.


Format partitions.

~/panda$ sudo mkfs.vfat -F 32 -n "boot" /dev/sdb1
mkfs.vfat 3.0.9 (31 Jan 2010)

~/panda$ sudo mkfs.vfat -F 32 -n "media" /dev/sdb2
mkfs.vfat 3.0.9 (31 Jan 2010)

~/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.

Mount and copy files.

~/panda$ sudo mount /dev/sdb1 /media/
~/panda$ sudo cp -r x-loader/MLO /media/
~/panda$ sudo cp -r u-boot/u-boot.bin /media/
~/panda$ sudo cp -r ics/kernel/omap/arch/arm/boot/uImage /media/
~/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
~/panda$ sudo umount /media/

~/panda$ sudo mount /dev/sdb3 /media
~/panda$ sudo cp -a ics/out/target/product/panda/rootfs/* /media/
~/panda$ sudo chmod 777 -R /media/
~/panda$ sudo umount /media

2 comments:

  1. Hi..
    Can you tell me the details about the SD card you are using... which class and which company ?

    ReplyDelete
  2. hi..
    I just wonder if Video playback and WiFi still working. In my case, the kernel could not load ducati-m3.bin and wl12721's nvs file.
    Thease you solve this?

    ReplyDelete