上篇博客介绍过SD卡启动android的脚本的大致情况,此脚本是在上一篇的基础上有所改过,它是支持s5pv210的,相关烧写参数发生了改变,这个脚本要把android的system目录data目录和cache目录都挂到root根目录下,与上一篇有点差别。
- #! /bin/bash
- export LC_ALL=C
- if [ $# -ne 1 ]; then
- echo "Usage: $0 "
- exit 1;
- fi
- DRIVE=$1
- SKIPMEDIA=0
- OUT_READY=0
- ROOT_DIR=$(pwd)
- PRODUCT='s5pv210'
- #OFFSET_AUTHKEY=1
- #OFFSET_BL1=9
- #OFFSET_BL2=57
- bl1_position=1
- uboot_position=49
- OFFSET_KERNEL=1073
- OFFSET_ROOTFS=9265
- SIZE_AUTHKEY=8
- SIZE_UBOOT=1072
- SIZE_KERNEL=8192
- SIZE_ROOTFS=6142
- if [ -e "$ROOT_DIR/out/target/product/$PRODUCT" ] ; then
- OUT_DIR="$ROOT_DIR/out/target/product/$PRODUCT"
- elif [ -e "$PRODUCT" ] ; then
- OUT_DIR="$PRODUCT"
- else
- echo "At least one out dir needed."
- OUT_DIR=""
- exit 1
- fi
- function format_drive (){
- echo "Formatting boot drive"
- if [ -b ${DRIVE}2 ]; then
- umount ${DRIVE}2
- mkfs.ext4 -L "sys_uw" ${DRIVE}2
- else
- if [ -b ${DRIVE}p2 ]; then
- umount ${DRIVE}p2
- mkfs.ext4 -L "sys_uw" ${DRIVE}p2
- else
- echo "Can't find boot partition in /dev"
- fi
- fi
- }
- function format_vfat () {
- echo "Formatting vfat data partition"
- if [ -b ${DRIVE}1 ]; then
- umount ${DRIVE}1
- mkfs.vfat -F 32 -n "fat_uw" ${DRIVE}1
- else
- if [ -b ${DRIVE}p1 ]; then
- umount ${DRIVE}p1
- mkfs.vfat -F 32 -n "fat_uw" ${DRIVE}p1
- else
- echo "Can't find boot partition in /dev"
- fi
- fi
- }
- function write_disk (){
- echo "Writing android images into disck"
- if [ -b ${DRIVE} ]; then
- ./${OUT_DIR}/mkbl1 ${OUT_DIR}/u-boot.bin SD-bl1-8k.bin 8192
- dd iflag=dsync oflag=dsync if=SD-bl1-8k.bin of=${DRIVE} seek=$bl1_position
- rm SD-bl1-8k.bin
- # dd of=${DRIVE} if=${OUT_DIR}/u-boot.bin seek=$OFFSET_AUTHKEY count=$SIZE_AUTHKEY bs=512
- # dd of=${DRIVE} if=${OUT_DIR}/u-boot.bin seek=$OFFSET_BL1 count=$SIZE_UBOOT bs=512
- dd iflag=dsync oflag=dsync of=${DRIVE} if=${OUT_DIR}/u-boot.bin seek=$uboot_position bs=512
- dd iflag=dsync oflag=dsync of=${DRIVE} if=${OUT_DIR}/zImage seek=$OFFSET_KERNEL count=$SIZE_KERNEL bs=512
- # dd iflag=dsync oflag=dsync of=${DRIVE} if=${OUT_DIR}/ramdisk-uboot.img skip=$OFFSET_ROOTFS count=$SIZE_ROOTFS bs=512
- else
- echo "Can't write boot sectors into ${DRIVE}"
- fi
- }
- function cp_root (){
- mkdir ${OUT_DIR}/tmp
- if [ -b ${DRIVE}2 ]; then
- umount ${DRIVE}2
- mount -t ext4 ${DRIVE}2 ${OUT_DIR}/tmp
- else
- if [ -b ${DRIVE}p2 ]; then
- umount ${DRIVE}p2
- mount -t ext4 ${DRIVE}p2 ${OUT_DIR}/tmp
- else
- echo "Can't find root partition in ${DRIVE}"
- fi
- fi
- if [ "$?" -eq 0 ] ; then
- echo "No root partition found, quit."
- fi
- cp -rp ${OUT_DIR}/root/* ${OUT_DIR}/tmp
- umount ${OUT_DIR}/tmp
- rm -rf ${OUT_DIR}/tmp
- echo "Writing root files finished."
- return $?
- }
- function wite_image (){
- echo "Writing kernrl images into disck"
- ./${OUT_DIR}/mkbl1 ${OUT_DIR}/u-boot.bin SD-bl1-8k.bin 8192
- dd iflag=dsync oflag=dsync if=SD-bl1-8k.bin of=${DRIVE} seek=$bl1_position
- rm SD-bl1-8k.bin
- # dd of=${DRIVE} if=${OUT_DIR}/u-boot.bin seek=$OFFSET_AUTHKEY count=$SIZE_AUTHKEY bs=512
- # dd of=${DRIVE} if=${OUT_DIR}/u-boot.bin seek=$OFFSET_BL1 count=$SIZE_UBOOT bs=512
- dd iflag=dsync oflag=dsync of=${DRIVE} if=${OUT_DIR}/u-boot.bin seek=$uboot_position bs=512
- dd iflag=dsync oflag=dsync of=${DRIVE} if=${OUT_DIR}/zImage seek=$OFFSET_KERNEL count=$SIZE_KERNEL bs=512
- }
- function create_drives(){
- if [ -b ${DRIVE}1 ]; then
- umount ${DRIVE}1
- umount ${DRIVE}2
- else
- if [ -b ${DRIVE}p1 ]; then
- umount ${DRIVE}p1
- umount ${DRIVE}p2
- else
- echo "Can't find boot partition in /dev"
- fi
- fi
- 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 203,,0x0C,-
- echo 9,191,0x83,-
- } | sfdisk -D -H 255 -S 63 -C $CYLINDERS $DRIVE
- sleep 1
- }
- #MAIN fucntion
- echo "To Writing uboot kernrl images into disck, enter 'k'."
- echo "To create a new drive, and fill it with android image enter 'c'."
- echo "To Exit, enter 'r'."
- echo -n "Enter k , c or r:"
- read answer
- case "$answer" in
- k) format_drive; wite_image; exit;;
- c) create_drives; format_drive; format_vfat; write_disk; cp_root; exit ;;
- r) exit;;
- *) echo "Not a valid option. Exiting"; exit ;;
- esac
- eject ${DRIVE}
阅读(2829) | 评论(0) | 转发(1) |