OK335xS-Android pack-ubi-256M.sh hacking

 1 #/*******************************************************************************
 2 # *                  OK335xS-Android pack-ubi-256M.sh hacking
 3 # *  声明:
 4 # *      1. 本文解析仅仅是为了知道pack-ubi-256M.sh自动生成ubi文件系统的原理
 5 # *      2. 本文在网页上可能不好阅读,最好cp一份在其他文本编辑器中阅读
 6 # *                                    2015-6-4 晴 深圳 南山平山村 曾剑锋
 7 # ******************************************************************************/
 8 
 9 
10 # /bin/sh
11 
12 ANDROID_PATH=`pwd`                                   # get android root path
13 KERNEL_PATH=$ANDROID_PATH/kernel                     # get android kernel path
14 UBOOT_PATH=$ANDROID_PATH/u-boot                      # get android u-boot path
15 echo "start make rootfs.tar.bz2......"               # show start message
16 cd $ANDROID_PATH/out/target/product/am335xevm        # change directory to out path
17 rm -rf android_rootfs                                # remove android_rootfs directory
18 mkdir android_rootfs                                 # make directory for android_rootfs
19 cp -rf root/* android_rootfs                         # cp all file to android_rootfs directory from root directory
20 cp -rf data android_rootfs/                          # cp data directory to android_rootfs directory
21 cp -rf system android_rootfs/                        # cp system directory to android_rootfs directory
22 cp -rf $ANDROID_PATH/vendor/busybox android_rootfs/system/bin                         # cp busybox as a shell command
23 cp -rf $ANDROID_PATH/RowboPerf/RowboPerf_libs/armeabi/* android_rootfs/system/lib     # cp RowboPerf armeabi lib as system lib
24 cp -rf $ANDROID_PATH/RowboPerf/Zeroxbench_bins/armeabi/* android_rootfs/system/bin    # cp RowboPerf armeabi bin as system bin
25 cp -rf $ANDROID_PATH/RowboPerf/*.apk android_rootfs/data/app                          # cp RowboPerf apk as data spp
26 cd android_rootfs/data                               # change directory to android_rootfs/data
27 mkdir data                                           # make directory for data
28 cd $ANDROID_PATH/out/target/product/am335xevm        # change directory to out path
29 chown 1000:1000 android_rootfs/data/app -R           # change file own
30 chmod 775 android_rootfs/data/app                    # change file mode of app
31 chmod 777 android_rootfs/data/data                   # change file mode of data 
32 ../../../../build/tools/mktarball.sh ../../../host/linux-x86/bin/fs_get_stats android_rootfs . rootfs rootfs.tar.bz2 # create a tar file
33 sleep 2
34 cp -rf rootfs.tar.bz2 $ANDROID_PATH/mkubifs                         # cp rootfs.tar.bz2 to mkubifs directory
35 cd  $ANDROID_PATH/mkubifs                                           # go to mkubifs directory
36 rm -rf rootfs                                                       # rm -rf rootfs directory
37 mkdir rootfs                                                        # make rootfs directory
38 tar -jxvf rootfs.tar.bz2 -C rootfs                                  # use tar with -jxvf argument extract files from rootfs.tar.bz2 
39 ./mkfs.ubifs -F -r rootfs -m 2048 -e 126976 -c 1866 -o ubifs.img    # create the ubifs image
40 # ubinize.cfg                                              |
41 #     [ubifs]                                              |
42 #     mode=ubi                                             |
43 #     image=ubifs.img    <---------------------------------+
44 #     vol_id=0        
45 #     vol_size=220MiB
46 #     vol_type=dynamic
47 #     vol_name=rootfs
48 #     vol_flags=autoresize
49 ./ubinize -o ubi.img -O 2048 -m 2048 -p 128KiB -s 2048 ubinize.cfg    # create the ubi image
50 sleep 2                                    
51 echo " make end"                                                      # show work end
52 
53 cd  $ANDROID_PATH                                                     # goto android root path
54 cp $KERNEL_PATH/arch/arm/boot/uImage temp                             # cp uImage to temp directory
55 #cp $UBOOT_PATH/MLO temp                                              # cp MLO to temp directory
56 #cp $UBOOT_PATH/u-boot.img temp                                       # cp u-boot.img to temp directory
57 cp $ANDROID_PATH/mkubifs/ubi.img temp                                 # cp ubi.img to temp directory
58 
59 cp $KERNEL_PATH/arch/arm/boot/uImage mmc-android-ubifs/Boot_Images    # cp uImage to mmc-android-ubifs/Boot_Images
60 #cp $UBOOT_PATH/MLO mmc-android-ubifs/Boot_Images                     # cp MLO to temp directory
61 #cp $UBOOT_PATH/u-boot.img mmc-android-ubifs/Boot_Images              # cp u-boot.img to temp directory
62 cp $ANDROID_PATH/mkubifs/ubi.img mmc-android-ubifs/Filesystem         # cp ubi.img to temp directory
63 echo "pack complete"
原文地址:https://www.cnblogs.com/zengjfgit/p/4551300.html