此手册介绍的是把x-loader、u-boot、kernel和android的二进制文件烧写到PandaBoard开发板的非易失存储器上,如flash。大家可用从PandaBoard官网下载的源码编译生成的二进制文件烧写,也可直接从官网下载相应的二进制文件烧写,这两种方式的烧写过程都是一样的。
作者:王键
1、文件准备
本文介绍的是从官网下载的二进制文件烧写,所要烧写的二进制文件对应为:MLO、u-boot.bin、uImage和afs文件夹。其中afs文件夹为android的文件系统对应的文件夹。
整个烧写过程是通过SD卡来完成。需先在SD卡上制作相应分区,然后把上述文件拷贝到SD卡相应分区中,开机前把SD卡插入到开发板的SD插槽中,上电启动就可以了。
2、制作SD卡
把SD卡插入到SD卡读卡器中,把读卡器插入到PC机的USB插口中,通过如下命令查看SD卡对应的Linux中的设备文件:
# fdisk –ls
在你自己的电脑上,这个SD卡对应的设备文件名可能不同。例如一个8G的SD的信息如下:Disk /dev/sde: 8011 MByte, 8011120640 Byte,这样此SD卡对应的linux下的设备文件名为/dev/sde。
以下操作假设SD卡对应的设备文件名为/dev/sdc。
运行脚本omap3-mkcard.sh对SD卡进行分区:
# omap3-mkcard.sh /dev/sdc
运行完后,会把SD卡分成两个分区boot和rootfs。boot分区的大小大概为16M,SD卡剩余空间全部为rootfs分区。在后面的操作中,需要把MLO、u-boot.bin和uImage文件拷贝到boot分区,把afs文件夹下所有内容拷贝到rootfs分区根目录下。
运行完脚本后,需把SD卡的新生成的两个分区boot和rootfs挂载到主机系统中,操作如下:
#mkdir /tmp/mmc1
#mkdir /tmp/mmc2
#mount /dev/sdc1 /tmp/mmc1
#mount /dev/sdc2 /tmp/mmc2
注意:如果挂载时报错,说要指定挂载类型,那么重新运行如下命令,然后挂载:
#mkfs.vfat -F 32 -n boot /dev/sdc1
#mkfs.ext3 -L rootfs /dev/sdc2
3、烧写
此过程就是把相应文件拷贝到SD卡的两个分区boot和rootfs中。
首先把bootloader的相关文件uboot.bin和MLO,以及kernel对应的文件u-boot.bin拷贝到SD卡的boot分区。前面的操作已经把SD卡的boot分区挂载到/tmp/mmc1目录,故只需拷贝到此目录即可,下同。操作如下:
#cp -rf /tmp/mmc1
#cp -rf /tmp/mmc1
#cp -rf /tmp/mmc1
然后把文件系统拷贝到SD卡的rootfs分区,即把afs目录下所有文件拷贝到/tmp/mmc2目录,注意不要拷贝afs文件夹,只拷贝其下的内容。操作如下:
#cp –Rfp ~/afs/* /tmp/mmc2
#chmod –R 777 /tmp/mmc2/*
然后卸载SD卡的boot和rootfs分区,操作如下:
#unmount /tmp/mmc1
#unmount /tmp/mmc2
4、启动运行
把SD卡插入到开发板的SD卡插槽中,HDMI线连接开发板和电视,上电,然后就会在电视上看到Android启动的画面。
附注:
2、 omap3-mkcard.sh本如下:
#! /bin/sh
# mkcard.sh v0.5
# (c) Copyright 2009 Graeme Gregory
# Licensed under terms of GPLv2
#
# Parts of the procudure base on the work of Denys Dmytriyenko
# http://wiki.omap.com/index.php/MMC_Boot_Format
export LC_ALL=C
if [ $# -ne 1 ]; then
echo "Usage: $0 "
exit 1;
fi
DRIVE=$1
dd if=/dev/zero of=$DRIVE bs=1024 count=1024
SIZE=`fdisk -l $DRIVE | grep Disk | grep bytes | awk '{print $5}'`
echo DISK SIZE - $SIZE bytes
CYLINDERS=`echo $SIZE/255/63/512 | bc`
echo CYLINDERS - $CYLINDERS
{
echo ,9,0x0C,*
echo ,,,-
} | sfdisk -D -H 255 -S 63 -C $CYLINDERS $DRIVE
sleep 1
if [ -x `which kpartx` ]; then
kpartx -a ${DRIVE}
fi
# handle various device names.
# note something like fdisk -l /dev/loop0 | egrep -E '^/dev' | cut -d' ' -f1
# won't work due to https://bugzilla.redhat.com/show_bug.cgi?id=649572
PARTITION1=${DRIVE}1
if [ ! -b ${PARTITION1} ]; then
PARTITION1=${DRIVE}p1
fi
DRIVE_NAME=`basename $DRIVE`
DEV_DIR=`dirname $DRIVE`
if [ ! -b ${PARTITION1} ]; then
PARTITION1=$DEV_DIR/mapper/${DRIVE_NAME}p1
fi
PARTITION2=${DRIVE}2
if [ ! -b ${PARTITION2} ]; then
PARTITION2=${DRIVE}p2
fi
if [ ! -b ${PARTITION2} ]; then
PARTITION2=$DEV_DIR/mapper/${DRIVE_NAME}p2
fi
# now make partitions.
if [ -b ${PARTITION1} ]; then
umount ${PARTITION1}
mkfs.vfat -F 32 -n "boot" ${PARTITION1}
else
echo "Cant find boot partition in /dev"
fi
if [ -b ${PARITION2} ]; then
umount ${PARTITION2}
#mke2fs -j -L "Angstrom" ${PARTITION2}
mke2fs -j -L "rootfs" ${PARTITION2}
else
echo "Cant find rootfs partition in /dev"
fi
#! /bin/sh
# mkcard.sh v0.5
# (c) Copyright 2009 Graeme Gregory
# Licensed under terms of GPLv2
#
# Parts of the procudure base on the work of Denys Dmytriyenko
# http://wiki.omap.com/index.php/MMC_Boot_Format
export LC_ALL=C
if [ $# -ne 1 ]; then
echo "Usage: $0 "
exit 1;
fi
DRIVE=$1
dd if=/dev/zero of=$DRIVE bs=1024 count=1024
SIZE=`fdisk -l $DRIVE | grep Disk | grep bytes | awk '{print $5}'`
echo DISK SIZE - $SIZE bytes
CYLINDERS=`echo $SIZE/255/63/512 | bc`
echo CYLINDERS - $CYLINDERS
{
echo ,9,0x0C,*
echo ,,,-
} | sfdisk -D -H 255 -S 63 -C $CYLINDERS $DRIVE
sleep 1
if [ -x `which kpartx` ]; then
kpartx -a ${DRIVE}
fi
# handle various device names.
# note something like fdisk -l /dev/loop0 | egrep -E '^/dev' | cut -d' ' -f1
# won't work due to https://bugzilla.redhat.com/show_bug.cgi?id=649572
PARTITION1=${DRIVE}1
if [ ! -b ${PARTITION1} ]; then
PARTITION1=${DRIVE}p1
fi
DRIVE_NAME=`basename $DRIVE`
DEV_DIR=`dirname $DRIVE`
if [ ! -b ${PARTITION1} ]; then
PARTITION1=$DEV_DIR/mapper/${DRIVE_NAME}p1
fi
PARTITION2=${DRIVE}2
if [ ! -b ${PARTITION2} ]; then
PARTITION2=${DRIVE}p2
fi
if [ ! -b ${PARTITION2} ]; then
PARTITION2=$DEV_DIR/mapper/${DRIVE_NAME}p2
fi
# now make partitions.
if [ -b ${PARTITION1} ]; then
umount ${PARTITION1}
mkfs.vfat -F 32 -n "boot" ${PARTITION1}
else
echo "Cant find boot partition in /dev"
fi
if [ -b ${PARITION2} ]; then
umount ${PARTITION2}
#mke2fs -j -L "Angstrom" ${PARTITION2}
mke2fs -j -L "rootfs" ${PARTITION2}
else
echo "Cant find rootfs partition in /dev"
fi