2013年1月31日木曜日

今天恰好也要初始化一下系里的默认值google了一下,有就得做个拿来主,没有才自己做子滴嘛,呵呵
1开机:
  android-logo-mask.png
  android-logo-shine.png
  两个片一个在上一个在下
  ./out/target/common/obj/JAVA_LIBRARIES/android_stubs_current_intermediates/classes/assets/images/android-logo-shine.png
  ./frameworks/base/core/res/assets/images/android-logo-shine.png
  注意:如果源没有make可以直接更改frameworks里的的片就可以了
  然后直接make全更改并且不能make只能make firmwar

2
开机墙纸的位置:
  default_wallpaper.jpg
  ./out/target/common/obj/JAVA_LIBRARIES/android_stubs_current_intermediates/classes/res/drawable/default_wallpaper.jpg
  ./frameworks/base/core/res/res/drawable/default_wallpaper.jpg
  注意:置和上面的一样这俩个都不能更改文件名
  3更改PC机器除硬件的文字kernel
  drivers/usb/gadget/f_mass_storage.c
  fsg->vendor = "XXXXXXXXXXXXX";

4
更改卷:
  bootable/recovery/etc/init.rc
  setprop UserVolumeLabel "XXXXXXXXXXXXX"
  直接打包

5修改屏幕:
  (1)
  frameworks/base/packages/SettingsProvider/res/values/defaults.xml
  <integer name="def_screen_off_timeout">60000</integer>
  60000改成想要的时间如果是不锁为-1
  (2)
  frameworks/policies/base/phone/com/android/internal/policy/impl/KeyguardViewMediator.java
  private boolean mExternallyEnabled = true;
  将其修改成false
  这样更改就不会再入休眠状

6初始化:
  参考下篇文章

7定初始化主:
  package/app/Browser/res/values/String.xml
  655
  后面的应该书签里的  

8定亮度0~255:
  frameworks/base/packages/SettingsProvider/res/values/defaults.xml 
  def_screen_brightness-->初始化好像是100

9音量:
  frameworks/base/media/java/android/media/AudioManager.java
  数DEFAULT_STREAM_VOLUME4(最大我置到30但是是差2格才到最大--11
  建将数里的所有的数设为最大就OK)
  mm frameworks/base
       AudioService.java中定了每一种音流的最大音量级别
  1. /** @hide Maximum volume index values for audio streams */    
  2.     private int[] MAX_STREAM_VOLUME = new int[] {    
  3.         5,  // STREAM_VOICE_CALL    
  4.         7,  // STREAM_SYSTEM    
  5.         7,  // STREAM_RING    
  6.         15// STREAM_MUSIC    
  7.         7,  // STREAM_ALARM    
  8.         7,  // STREAM_NOTIFICATION    
  9.         15// STREAM_BLUETOOTH_SCO    
  10.         7,  // STREAM_SYSTEM_ENFORCED    
  11.         15// STREAM_DTMF    
  12.         15  // STREAM_TTS    
  13.     };    
 
10Google帐户,左上角提示"正在RK2818SDK",要求改成"正在W9":
  out\target\product\sdkDemo\root default.prop文件第13
      ro.product.model=rk2818sdk   ro.product.model=W9

11音没有小时显示。要求增加:
   packages\apps\SoundRecorder\src\com\android\soundrecorder
      1SoundRecorder.java中: private void updateTimerView() 
       String timeStr = String.format(mTimerFormat, time/60, time%60);        
       long hour=time/3600;
           String timeStr = String.format(mTimerFormat, hour, (time-hour*3600)/60, time%60); 
      (2)  \res\valuesstrings.xml
           <string name="timer_format"><xliff:g id="format">%02d:%02d:%02d</xliff:g></string>

12去掉Bluetooth:
      (主界面->添加文件->Bluetooth received)
       ic_launcher_folder_bluetooth.png72*72:
        \packages\apps\Bluetooth\res\drawable-hdpi
        解决方法:\out\target\product\sdkDemo\system\app下的Bluetooth.apk

13电锁时图片:
      
frameworks\base\core\res\res\drawable-hdpi:ic_lock_idle_charging.png

14去掉时显示充百分比在:
      
frameworks\base\core\res\res\values-zh-rCNstrings.xml lockscreen_plugged_in 括号中的内容及括号 !!

15去掉动态桌面背景选项
      
packages\wallpapers\Basic AndroidManifest.xml<service>些,如星系注掉如下些:
                 <service
                   android:label="@string/wallpaper_galaxy"
                   android:name="com.android.wallpaper.galaxy.GalaxyWallpaper"
                   android:permission="android.permission.BIND_WALLPAPER">
                    <intent-filter>
                       <action android:name="android.service.wallpaper.WallpaperService" />
                    </intent-filter>
                   <meta-data android:name="android.service.wallpaper" android:resource="@xml/galaxy" />
                  </srvice>

16更改版本号:
    build/core/Makefile 
    79
    
RK_VER := xxx
17更改界面布局
  位置
:package/app/Launcher2/res/xml/default_workspace.xml
  注意:adb shell 里当你点任意的一个apk,在后台会
  
I/ActivityManager(  728): Starting activity: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000     cmp=com.estrongs.android.pop/.view.FileExplorerActivity bnds=[294,373][393,478] }
I/WindowManager(  728): Setting rotation to 1, animFlags=0
      色的部分就可以找到/前是包名/后面是-->个是在default_workspace.xml里面需要用到的
  
launcher:packageName="com.android.browser"             
      launcher:className="com.android.browser.BrowserActivity"
18如何将pdf的文件放到桌面上
  客
要求将他自己制作的pdf帮助文档放置到桌面上使客人可以直接点浏览
    String urlString = "/system/app/Nvsbl P4Dv2 English Manual.pdf";
        Intent intent = new Intent();
        intent.setAction(android.content.Intent.ACTION_VIEW);
        intent.setDataAndType(Uri.fromFile(new File(urlString)),"application/pdf");
        startActivity(intent);
        finish();
   解:
   首先将pdf文档放到out/target/product/sdkDemo/system/app
   将固定地址
urlString,使用Intent
   intent.setAction(android.content.Intent.ACTION_VIEW);View
   intent.setDataAndType(Uri.fromFile(new File(urlString)),"application/pdf");   
   
application/pdf可以指定的格式包括音,视频,片等等但是没有试过有需要可以试试
   注意:个方法很不到如果只放置一些可以但是如果放置文件比大那么打包出来的
   
system.img文件会很大也就是占用本身的系内存----->所以不推荐使用!!!!!!!!!!!
19.发现PIN界面出5秒之后就会自动进入睡眠,之后将无法再次解。目前解决方法:
  修改文件 frameworks\policies\base\phone\com\android\internal\policy\impl\KeyguardViewMediator.java

将如下行:
protected static final int AWAKE_INTERVAL_DEFAULT_MS = 5000;
修改
protected static final int AWAKE_INTERVAL_DEFAULT_MS = 1000 * 60 * 5;
 
 
1.1        Uboot UBI的移植
关于ubootUBI的移植几乎没有明介,移植首先要保你的flash驱动跑起来,我是在nand flash 上跑的UBI开始的候我也没有什么头绪,只能ubootreadme开始找一些蛛丝马迹。
- MTD Support (mtdparts command, UBI support)
              CONFIG_MTD_DEVICE
              Adds the MTD device infrastructure from the Linux kernel.
              Needed for mtdparts command support.
              CONFIG_MTD_PARTITIONS
              Adds the MTD partitioning infrastructure from the Linux
              kernel. Needed for UBI support.
因此,要UBI支持首先得要MTD支持,因此在配置文件中要添加以上两的定
要移植UBI要添加:
#define CONFIG_CMD_UBIFS           
#define CONFIG_CMD_UBI         
的关于UBI的部分是以下几个宏:
#define CONFIG_CMD_UBI
#define CONFIG_CMD_UBIFS
#define CONFIG_CMD_MTDPARTS
#define CONFIG_MTD_DEVICE
#define CONFIG_MTD_PARTITIONS
#define CONFIG_RBTREE
#define CONFIG_LZO 
NAND建立个默的分区,方便以后操作。分区如下:
#define MTDIDS_DEFAULT "nand0=nand0"
#define MTDPARTS_DEFAULT "mtdparts=nand0:0x100000@0x0(u-boot),0x300000@0x120000(kernel),0x7b00000@0x420000(rootfs),-(reserved)"
#define MTD_ACTIVE_PART "nand0,2"
以上的配置都在uboot_imx/include/configs/mx51_vdphone.h文件中行配置。
需要注意的是增加UBI的支持之后uboot会增大到300KB,在NAND中启,需要修改以下文件uboot-imx\cpu\arm_cortexa8\mx51\mxc_nand_load.S 
      add r6, r0, #0x1E00
      ldr r5, =_end              /* Try get right image size */
      add r5, r2, #0x00060000 /* Fixme to get actual image size */ 
里使用0x60000384K)大小,已,如果实际化,可以行相应调节。如果uboot传给Copy_Good_Blk uboot的大小小于uboot度的uboot跑不起来,移植的候被问题注意。
候就可以make 了,行以下命令:
make clean
make mx51_vdphone_config
make all
如果正常的编译u-boot.bin在根目下。
1.2       u-boot ubi的使用
1.2.1        配置u-boot nand 分区
mtdpart命令配置u-boot下的nand 分区,本目已在配置文件里面置了默nand 分区,
#define MTDPARTS_DEFAULT "mtdparts=nand0:0x100000@0x0(u-boot),0x300000@0x120000(kernel),0x7b00000@0x420000(rootfs),-(reserved)"
如果需要修改,可以通修改默分区列表,也可以通命令mtdpart行重新分区。里使用默分区,通以下命令使默分区生效:
       mtdpart default       //置默分区
       saveevn             //保存分区信息
 
 
1.2.2        nand u-boot 
以上的配置编译,如果成功生成u-boot.bin,那就可以通SD卡启,直接u-boot.binnand flash了。操作步如下:
1)         u-boot.bin 到内存
tftp 0x90800000 /tftpboot/mx51/u-boot.bin
2)         擦除u-boot分区
nand erase u-boot
3)         u-bootnand flash分区
nand write 0x90800000 u-boot 0x60000
1.2.3        内核的
 内核的写和平常写方式一,只需用nand 命令写入nand 即可,操作步如下:
1)       擦除kernel分区
nand erase kernel
2)       kernel到内存
tftp 0x90800000 /tftpboot/mx51/uImage  将内核通tftp到内存中
3)       kernel nand kernel分区
nand write 0x90800000 kernel 0x300000 
1.2.4        UBI文件系
目使用的文件系将根文件系system文件系整合在一起。所以,只需要写整合后的文件系即可。如果要使用ubifs文件系根文件系,在写之前必mkfs.ubifs工具将做好的文件系制作像文件。mkfs.ubifs 工具是通过编译mtd-utils工具下的mkfs.ubifs即可生成的PCUBIFS文件系统镜像制作工具。操作步如下:
1)       制作根文件系
mkfs.ubifs -r root/ -m 2048 -e 129024 -c 2364 -o root-fs.img
root录为整合android rootsystem文件系后的目当能NFS
2)       擦除root分区
 nand erase root
3)      激活root 分区UBI格式
 ubi part root
 
             4)    root分区
ubi create root
 
5)       将文件系到内存
 tftp 0x90800000 root-fs.img
6)       将文件系统烧写到rootfs 
ubi write 0x90800000 rootfs 0x339600//0x339600tftp 到的root-fs.img像大小,
1.2.5         置启参数
bootargs
setenv bootargs ubi.mtd=2 root=ubi0:rootfs rootfstype=ubifs console=ttymxc0,115200 wvga calibration init=/init rw
动拨码开关5,8位置ON,上重新启,即可从Nand flash 
 
               1.3       android FLASH UBI文件系的制作和
android编译为UBI文件系 式,生成的system.img,userdata.img,recover.img就可以直接在u-boot中通ubi write 命令写,前提条件是uboot支持或完成ubiUBIFS的移植工作,并且linux kernel也要支持UBIFS文件系
              1.3.1   mtdpart分区
             1)    U-Boot中配置默分区参数,路径如下:
 
# 相关的配置文件include/configs/mx51/xxxx.h 
mtdparts: mtdparts=nand0:0x100000@0x0(u-boot),0x300000@0x120000(kernel),0x100000@0x420000(ramdisk),0x4B00000@0x520000(system),0x1E00000@0x5020000(userdata),0xD00000@0x6E20000(cache),-(reserved)
            2)     第一次写完boot后,mtdpart分区:
BBG U-Boot > mtdparts default # 分区配置
BBG U-Boot > save # 保存配置
BBG U-Boot > mtdpart # 看分区配置
device nand0 <nand0>, # parts = 7
 #: name                size            offset          mask_flags
 0: u-boot              0x00100000      0x00000000      0
 1: kernel              0x00300000      0x00120000      0
 2: ramdisk             0x00100000      0x00420000      0
 3: system              0x04b00000      0x00520000      0
 4: userdata            0x01e00000      0x05020000      0
 5: cache               0x00d00000      0x06e20000      0
 6: reserved            0x004e0000      0x07b20000      0
active partition: nand0,0 - (u-boot) 0x00100000 @ 0x00000000
defaults:
mtdids  : nand0=nand0
 
               3)    U-BootFLASH
BBG U-Boot > tftp 0x90800000 u-boot.bin # U-Boot到内存
BBG U-Boot > nand erase u-boot # 格式化u-boot分区
BBG U-Boot > nand write 0x90800000 u-boot 0x100000 # u-boot对应分区
              4)    Linux内核到FLASH
BBG U-Boot > tftp 0x90800000 uImage # 取内核到内存
BBG U-Boot > nand erase kernel # 格式化内存分区
BBG U-Boot > nand write 0x90800000 kernel 0x300000 # 写内核到对应分区
              5)    RamdiskFLASH
BBG U-Boot > tftp 0x90800000 uramdisk.img # uramdisk到内存
BBG U-Boot > nand erase ramdisk # 格式化uramdisk分区
BBG U-Boot > nand write 0x90800000 ramdisk 0x100000 # uramdisk对应分区          
              6)    SystemFLASH
BBG U-Boot > nand erase system # 擦除system分区
BBG U-Boot > tftp 0x90800000 system.img # system到内存
BBG U-Boot > ubi part system # 激活system分区ubi格式
Creating 1 MTD partitions on "nand0":
0x000097855f98-0x000000520000 : "<NULL>"
UBI: attaching mtd1 to ubi0
UBI: physical eraseblock size:   131072 bytes (128 KiB)
UBI: logical eraseblock size:    129024 bytes
UBI: smallest flash I/O unit:    2048
UBI: sub-page size:              512
UBI: VID header offset:          512 (aligned 512)
UBI: data offset:                2048
UBI: attached mtd1 to ubi0
UBI: MTD device name:            "mtd=3"
UBI: MTD device size:            78643200 MiB
UBI: number of good PEBs:        600
UBI: number of bad PEBs:         0
UBI: max. allowed volumes:       128
UBI: wear-leveling threshold:    4096
UBI: number of internal volumes: 1
UBI: number of user volumes:     0
UBI: available PEBs:             590
UBI: total number of reserved PEBs: 10
UBI: number of PEBs reserved for bad PEB handling: 6
UBI: max/mean erase counter: 1/1
BBG U-Boot > ubi create system # system分区
Creating dynamic volume system of size 76124160
 
# sytem分区,大小tftp完成后提示的大小
BBG U-Boot > ubi write 0x90800000 system 0x3ca9800
Volume "system" found at volume id 0
 
               7)     userdataFLASH
BBG U-Boot > nand erase userdata # 擦除userdata分区
BBG U-Boot > ubi part userdata # 激活userdata分区ubi格式
UBI: mtd1 is detached from ubi0
Creating 1 MTD partitions on "nand0":
0x000097855f98-0x000005020000 : "<NULL>"
UBI: attaching mtd1 to ubi0
UBI: physical eraseblock size:   131072 bytes (128 KiB)
UBI: logical eraseblock size:    129024 bytes
UBI: smallest flash I/O unit:    2048
UBI: sub-page size:              512
UBI: VID header offset:          512 (aligned 512)
UBI: data offset:                2048
UBI: empty MTD device detected
UBI: create volume table (copy #1)
UBI: create volume table (copy #2)
UBI: attached mtd1 to ubi0
UBI: MTD device name:            "mtd=4"
UBI: MTD device size:            31457280 MiB
UBI: number of good PEBs:        240
UBI: number of bad PEBs:         0
UBI: max. allowed volumes:       128
UBI: wear-leveling threshold:    4096
UBI: number of internal volumes: 1
UBI: number of user volumes:     0
UBI: available PEBs:             234
UBI: total number of reserved PEBs: 6
UBI: number of PEBs reserved for bad PEB handling: 2
UBI: max/mean erase counter: 0/0
BBG U-Boot > ubi create userdata # userdata分区
Creating dynamic volume userdata of size 30191616
BBG U-Boot > tftp 0x90800000 userdata.img # userdata到内存
 
# userdata分区,大小tftp完成后提示的大小
BBG U-Boot > ubi write 0x90800000 userdata 0x979800
Volume "userdata" found at volume id 0
 
              8)    初始化Cache分区
BBG U-Boot > ubi part cache # 激活cache分区ubi格式
UBI: mtd1 is detached from ubi0
Creating 1 MTD partitions on "nand0":
0x000097855f98-0x000006e20000 : "<NULL>"
UBI: attaching mtd1 to ubi0
UBI: physical eraseblock size:   131072 bytes (128 KiB)
UBI: logical eraseblock size:    129024 bytes
UBI: smallest flash I/O unit:    2048
UBI: sub-page size:              512
UBI: VID header offset:          512 (aligned 512)
UBI: data offset:                2048
UBI: empty MTD device detected
UBI: create volume table (copy #1)
UBI: create volume table (copy #2)
UBI: attached mtd1 to ubi0
UBI: MTD device name:            "mtd=5"
UBI: MTD device size:            13631488 MiB
UBI: number of good PEBs:        104
UBI: number of bad PEBs:         0
UBI: max. allowed volumes:       128
UBI: wear-leveling threshold:    4096
UBI: number of internal volumes: 1
UBI: number of user volumes:     0
UBI: available PEBs:             98
UBI: total number of reserved PEBs: 6
UBI: number of PEBs reserved for bad PEB handling: 2
UBI: max/mean erase counter: 0/0
BBG U-Boot > ubi create cache   # cache分区
                9)     FLASHAndroid的加与启
置启参数
setenv bootcmd_nand 'run bootargs_nand;nand read ${loadaddr} kernel; nand read ${rd_loadaddr} ramdisk; bootm ${loadaddr} ${rd_loadaddr}'
setenv bootargs_nand 'setenv bootargs ubi.mtd=3 ubi.mtd=4 ubi.mtd=5 console=ttymxc0,115200 androidboot.console=ttymxc0 wvga calibration init=/init rw'
setenv bootcmd 'run bootcmd_nand'
saveenv
重启即可从nand flash 动烧写的ubi文件系
 
 
为方便android调试的脚本,如出现:/bin/bash^M:损坏的解释器: 没有该文件或目录,问题多半是因为windows和linux的换行符不一样造成,可以用vim中的用:set ff=unix来解决,vim真强大
#!/bin/bash
PRODUCTDIR="/media/UBUNTU/work-ubuntu/s5pc110/hardkernel/android"
MKBOOTFS="$PRODUCTDIR/out/host/linux-x86/bin/mkbootfs"
MINIGZIP="$PRODUCTDIR/out/host/linux-x86/bin/minigzip"
ROOT="./root"
CMD="mkimage -A arm -O linux -T ramdisk -C none -a 0x30800000 -n "ramdisk" -d ramdisk.img ramdisk-uboot.img"
function extract-ramdisk-uboot(){
dd if=ramdisk-uboot.img of=ramdisk.img.gz bs=1 skip=64 
gunzip -.gz ramdisk.img.gz
rm -rf ./root
mkdir root
cd root
cpio --../ramdisk.img
cd ..
rm ramdisk.img
}
function generate-ramdisk-uboot(){
$MKBOOTFS $ROOT | $MINIGZIP > ./ramdisk.img 
$CMD
rm ramdisk.img
}
#MAIN fucntion
echo "To extract-ramdisk-uboot, enter 'e'."
echo "To generate-ramdisk-uboot enter 'g'."
echo -"Enter e or g:"
read answer
case "$answer" in
e) extract-ramdisk-uboot; exit;;
g) generate-ramdisk-uboot; exit ;;
*) echo "Not a valid option. Exiting"; exit ;
 
介绍SD卡启动android的脚本的大致情况,此它是支持s5pv210的,相关烧写参数发生了改变,这个脚本要把android的system目录data目录和cache目录都挂到root根目录下
 
  1. #! /bin/bash
  2. export LC_ALL=C
  3. if [ $# -ne 1 ]; then
  4.         echo "Usage: $0 <drive>"
  5.         exit 1;
  6. fi
  7. DRIVE=$1
  8. SKIPMEDIA=0
  9. OUT_READY=
  10. ROOT_DIR=$(pwd)
  11. PRODUCT='s5pv210'
  12. #OFFSET_AUTHKEY=1
  13. #OFFSET_BL1=9
  14. #OFFSET_BL2=57
  15. bl1_position=1
  16. uboot_position=49
  17. OFFSET_KERNEL=1073
  18. OFFSET_ROOTFS=9265
  19. SIZE_AUTHKEY=8
  20. SIZE_UBOOT=1072
  21. SIZE_KERNEL=8192
  22. SIZE_ROOTFS=6142 
  23. if [ -"$ROOT_DIR/out/target/product/$PRODUCT" ] ; then
  24. OUT_DIR="$ROOT_DIR/out/target/product/$PRODUCT"
  25. elif [ -"$PRODUCT" ] ; then
  26. OUT_DIR="$PRODUCT"
  27. else
  28.     echo "At least one out dir needed."
  29.     OUT_DIR=""
  30.     exit 1
  31. fi
  32. function format_drive (){
  33. echo "Formatting boot drive"
  34. if [ -b ${DRIVE}]; then
  35.     umount ${DRIVE}2
  36.         mkfs.ext4 -"sys_uw" ${DRIVE}2
  37. else
  38.         if [ -b ${DRIVE}p2 ]; then
  39.         umount ${DRIVE}p2
  40.             mkfs.ext4 -"sys_uw" ${DRIVE}p2
  41.         else
  42.                 echo "Can't find boot partition in /dev"
  43.         fi
  44. fi
  45. }
  46. function format_vfat () {
  47. echo "Formatting vfat data partition"
  48. if [ -b ${DRIVE}]; then
  49.     umount ${DRIVE}1
  50.         mkfs.vfat -F 32 -"fat_uw" ${DRIVE}1
  51. else
  52.         if [ -b ${DRIVE}p1 ]; then
  53.         umount ${DRIVE}p1
  54.             mkfs.vfat -F 32 -"fat_uw" ${DRIVE}p1
  55.         else
  56.                 echo "Can't find boot partition in /dev"
  57.         fi
  58. fi
  59. }
  60. function write_disk (){
  61. echo "Writing android images into disck"
  62. if [ -b ${DRIVE} ]; then
  63.     ./${OUT_DIR}/mkbl1 ${OUT_DIR}/u-boot.bin SD-bl1-8k.bin 8192
  64.     dd iflag=dsync oflag=dsync if=SD-bl1-8k.bin of=${DRIVE} seek=$bl1_position
  65.     rm SD-bl1-8k.bin
  66. #    dd of=${DRIVE} if=${OUT_DIR}/u-boot.bin seek=$OFFSET_AUTHKEY count=$SIZE_AUTHKEY bs=512
  67. #    dd of=${DRIVE} if=${OUT_DIR}/u-boot.bin seek=$OFFSET_BL1 count=$SIZE_UBOOT bs=512
  68.     dd iflag=dsync oflag=dsync of=${DRIVE} if=${OUT_DIR}/u-boot.bin seek=$uboot_position bs=512
  69.     dd iflag=dsync oflag=dsync of=${DRIVE} if=${OUT_DIR}/zImage seek=$OFFSET_KERNEL count=$SIZE_KERNEL bs=512
  70. #    dd iflag=dsync oflag=dsync of=${DRIVE} if=${OUT_DIR}/ramdisk-uboot.img skip=$OFFSET_ROOTFS count=$SIZE_ROOTFS bs=512
  71. else
  72.     echo "Can't write boot sectors into ${DRIVE}"
  73. fi
  74. }
  75. function cp_root (){
  76. mkdir ${OUT_DIR}/tmp
  77. if [ -b ${DRIVE}]; then
  78.     umount ${DRIVE}2
  79.     mount -t ext4 ${DRIVE}2 ${OUT_DIR}/tmp
  80. else
  81.         if [ -b ${DRIVE}p2 ]; then
  82.         umount ${DRIVE}p2
  83.             mount -t ext4 ${DRIVE}p2 ${OUT_DIR}/tmp
  84.         else
  85.                 echo "Can't find root partition in ${DRIVE}"
  86.         fi
  87. fi
  88. if [ "$?" -eq 0 ] ; then
  89.     echo "No root partition found, quit."
  90. fi
  91.     cp -rp ${OUT_DIR}/root/* ${OUT_DIR}/tmp
  92.     umount ${OUT_DIR}/tmp
  93.     rm -rf ${OUT_DIR}/tmp
  94.     echo "Writing root files finished."
  95.     return $?
  96. }
  97. function wite_image (){
  98.     echo "Writing kernrl images into disck"
  99.     ./${OUT_DIR}/mkbl1 ${OUT_DIR}/u-boot.bin SD-bl1-8k.bin 8192
  100.     dd iflag=dsync oflag=dsync if=SD-bl1-8k.bin of=${DRIVE} seek=$bl1_position
  101.     rm SD-bl1-8k.bin
  102. #    dd of=${DRIVE} if=${OUT_DIR}/u-boot.bin seek=$OFFSET_AUTHKEY count=$SIZE_AUTHKEY bs=512
  103. #    dd of=${DRIVE} if=${OUT_DIR}/u-boot.bin seek=$OFFSET_BL1 count=$SIZE_UBOOT bs=512
  104.     dd iflag=dsync oflag=dsync of=${DRIVE} if=${OUT_DIR}/u-boot.bin seek=$uboot_position bs=512
  105.     dd iflag=dsync oflag=dsync of=${DRIVE} if=${OUT_DIR}/zImage seek=$OFFSET_KERNEL count=$SIZE_KERNEL bs=512
  106. }
  107. function create_drives(){
  108. if [ -b ${DRIVE}]; then
  109.         umount ${DRIVE}1
  110.     umount ${DRIVE}2
  111. else
  112.         if [ -b ${DRIVE}p1 ]; then
  113.             umount ${DRIVE}p1
  114.         umount ${DRIVE}p2
  115.         else
  116.                 echo "Can't find boot partition in /dev"
  117.         fi
  118. fi
  119. dd if=/dev/zero of=$DRIVE bs=1024 count=1024
  120. SIZE=`fdisk -l $DRIVE | grep Disk | grep bytes | awk '{print $5}'`
  121. echo DISK SIZE - $SIZE bytes
  122. CYLINDERS=`echo $SIZE/255/63/512 | bc`
  123. echo CYLINDERS - $CYLINDERS
  124. {
  125. echo 203,,0x0C,-
  126. echo 9,191,0x83,-
  127. } | sfdisk --H 255 -S 63 -C $CYLINDERS $DRIVE
  128. sleep 1
  129. }
  130. #MAIN fucntion
  131. echo "To Writing uboot kernrl images into disck, enter 'k'."
  132. echo "To create a new drive, and fill it with android image enter 'c'."
  133. echo "To Exit, enter 'r'."
  134. echo -"Enter k , c or r:"
  135. read answer
  136. case "$answer" in
  137. k) format_drive; wite_image; exit;;
  138. c) create_drives; format_drive; format_vfat; write_disk; cp_root; exit ;;
  139. r) exit;;
  140. *) echo "Not a valid option. Exiting"; exit ;;
  141. esac
  142. eject ${DRIVE}