android的系统存储与软件安装

2022-06-14 08:40:24 浏览数 (1)

S i.MX51制作启动SD卡及下载镜像

一、SD卡分区

1.1、分区要求

SD卡分区结构及镜像地址分配如下图

SD卡创建分区表如下表

Partition Type/Index

Device Node

File System

Content

Primary 1

/dev/sdb1

VFAT. Mount as /sdcards

Media file storage

Primary 2

/dev/sdb2

EXT3. Mount as /system

Android system bin/libs

Extended 3

/dev/sdb3

N/A. Extended partition

N/A

Logic partition in Extended

/dev/sdb5

EXT3. Mount as /data

Android data (e.g. installed app)

Logic partition in Extended

/dev/sdb6

EXT3. Mount as /cache

Android cache

Primary 4

/dev/sdb4

EXT3. Mount as / in recovery mode

Root file system for recovery mode

1.2、SD卡分区操作

将一张新的SD卡装入USB读卡器插入装有linux操作系统的PC(以下为VMware安装了ubuntu 9.10的操作记录),打开一个终端窗口,操作如下所述(注:红色字体为输入信息

nfs@ubuntu:~$ sudoumount /dev/sdb1        //取消SD卡挂载

nfs@ubuntu:~$ sudo fdisk /dev/sdb            //使用fdisk工具对SD卡分区操作

Command (m for help): p                    //列出SD卡分区信息

Disk /dev/sdb: 1015 MB, 1015808000 bytes

255 heads, 63 sectors/track, 123 cylinders

Units = cylinders of 16065 * 512 = 8225280bytes //每个cylinder(磁柱)的容量是8.225280M

Disk identifier: 0x6f20736b

  Device Boot      Start         End      Blocks  Id  System

/dev/sdb1               1         123      987966   b  W95 FAT32

Command (m for help): d                    //删除现在的分区

Selected partition 1

Command (m for help): p                    //查看是否删除成功

Disk /dev/sdb: 1015 MB, 1015808000 bytes

255 heads, 63 sectors/track, 123 cylinders

Units = cylinders of 16065 * 512 = 8225280bytes

Disk identifier: 0x6f20736b

  Device Boot      Start         End      Blocks  Id  System

Command (m for help): n                    //新建一个分区

Command action

  e   extended

  p   primary partition (1-4)

p                                        //选择主分区

Partition number (1-4): 1                     //序号为1

First cylinder (1-123, default 1): 2               //该分区开始的cylinder编号为2(不是1,因为要给uboot和kernel留足空间)

Last cylinder, cylinders or size{K,M,G}(2-123, default 123): 500M //该分区容量为500M(修改大一点,视SD卡的容量而定)

Command (m for help): p                     //查看新建分区是否成功

Disk /dev/sdb: 1015 MB, 1015808000 bytes

255 heads, 63 sectors/track, 123 cylinders

Units = cylinders of 16065 * 512 = 8225280bytes

Disk identifier: 0x6f20736b

  Device Boot      Start         End      Blocks  Id  System

/dev/sdb1               2          66      522112  83  Linux

Command (m for help): n                     //新建一个分区

Command action

  e   extended

  p   primary partition (1-4)

p                                         //选择主分区

Partition number (1-4): 2                      //序号为2

First cylinder (1-123, default 1): 67              //该分区开始的cylinder编号为67(紧跟第一个分区,以免造成磁盘空间浪费)

Last cylinder, cylinders or size{K,M,G}(67-123, default 123): 128M//该分区容量为128M

Command (m for help): p                     //查看新建分区是否成功

Disk /dev/sdb: 1015 MB, 1015808000 bytes

255 heads, 63 sectors/track, 123 cylinders

Units = cylinders of 16065 * 512 = 8225280bytes

Disk identifier: 0x6f20736b

  Device Boot      Start         End      Blocks  Id  System

/dev/sdb1               2          66      522112  83  Linux

/dev/sdb2              67          83      136552  83  Linux

Command (m for help): n                     //新建一个分区

Command action

  e   extended

  p   primary partition (1-4)

e                                         //选择扩展分区(主分区最多只能有4个,这里需要5个分区,所以需要使用扩展分区)

Partition number (1-4): 3                      //序号为3

First cylinder (1-123, default 1): 84              //该分区开始的cylinder编号为84

Last cylinder, cylinders or size{K,M,G}(84-123, default 123): 256M//该分区容量为256M

Command (m for help): p                     //查看新建分区是否成功

Disk /dev/sdb: 1015 MB, 1015808000 bytes

255 heads, 63 sectors/track, 123 cylinders

Units = cylinders of 16065 * 512 = 8225280bytes

Disk identifier: 0x6f20736b

  Device Boot      Start         End      Blocks  Id  System

/dev/sdb1               2          66      522112  83  Linux

/dev/sdb2              67          83      136552  83  Linux

/dev/sdb3              84        117      273105    5 Extended

Command (m for help): n                     //新建一个分区

Command action

  l   logical (5 or over)

  p   primary partition (1-4)

p                                         //选择主分区

Selected partition 4

First cylinder (1-123, default 1): 118              //该分区开始的cylinder编号为118

Last cylinder, cylinders or size{K,M,G}(118-123, default 123): //直接回车,使用默认值,到磁盘最后端

Using default value 123

Command (m for help): n                      //新建一个分区(主分区已使用完,这里自动为新建逻辑分区)

First cylinder (84-117, default 84):               //直接回车,使用默认值,扩展分区的开始

Using default value 84

Last cylinder, cylinders or size{K,M,G}(84-117, default 117): 128M//该分区容量为128M

Command (m for help): n                      //新建一个分区

First cylinder (101-117, default 101):             //直接回车,使用默认值,剩余空间开始处

Using default value 101

Last cylinder, cylinders or size{K,M,G}(101-117, default 117): //直接回车,使用默认值,剩余扩展分区容量

Using default value 117

Command (m for help): p                      //查看分区情况

Disk /dev/sdb: 1015 MB, 1015808000 bytes

255 heads, 63 sectors/track, 123 cylinders

Units = cylinders of 16065 * 512 = 8225280bytes

Disk identifier: 0x6f20736b

  Device Boot      Start         End      Blocks  Id  System

/dev/sdb1               2         66      522112   83 Linux

/dev/sdb2              67          83      136552  83  Linux

/dev/sdb3              84         117      273105   5  Extended

/dev/sdb4             118         123       48195  83  Linux

/dev/sdb5              84         100      136521  83  Linux

/dev/sdb6             101         117      136521  83  Linux

Command (m for help): t                      //改变分区文件系统类型

Partition number (1-6): 1                     //选择分区编号1

Hex code (type L to list codes): b                //b为FAT32类型

Changed system type of partition 1 to b(W95 FAT32)

Command (m for help): p                      //查看分区情况

Disk /dev/sdb: 1015 MB, 1015808000 bytes

255 heads, 63 sectors/track, 123 cylinders

Units = cylinders of 16065 * 512 = 8225280bytes

Disk identifier: 0x6f20736b

  Device Boot      Start         End      Blocks  Id  System

/dev/sdb1               2          66      522112   b  W95 FAT32

/dev/sdb2              67          83      136552  83  Linux

/dev/sdb3              84         117      273105   5  Extended

/dev/sdb4             118         123       48195  83  Linux

/dev/sdb5              84         100      136521  83  Linux

/dev/sdb6             101         117      136521  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 modifiedany DOS 6.x

partitions, please see the fdisk manualpage for additional

information.

Syncing disks.

nfs@ubuntu:~$ sudomkfs.vfat /dev/sdb1        //格式化分区

mkfs.vfat 3.0.3 (18 May 2009)

nfs@ubuntu:~$ sudomkfs.ext3 /dev/sdb2        //格式化分区

mke2fs 1.41.9 (22-Aug-2009)

Filesystem label=

OS type: Linux

Block size=1024 (log=0)

Fragment size=1024 (log=0)

34272 inodes, 136552 blocks

6827 blocks (5.00%) reserved for the superuser

First data block=1

Maximum filesystem blocks=67371008

17 block groups

8192 blocks per group, 8192 fragments pergroup

2016 inodes per group

Superblock backups stored on blocks:

         8193,24577, 40961, 57345, 73729

Writing inode tables: done                           

Creating journal (4096 blocks): done

Writing superblocks and filesystemaccounting information: done

This filesystem will be automaticallychecked every 30 mounts or

180 days, whichever comes first.  Use tune2fs -c or -i to override.

nfs@ubuntu:~$ sudomkfs.ext3 /dev/sdb4        //格式化分区

mke2fs 1.41.9 (22-Aug-2009)

Filesystem label=

OS type: Linux

Block size=1024 (log=0)

Fragment size=1024 (log=0)

12048 inodes, 48192 blocks

2409 blocks (5.00%) reserved for the superuser

First data block=1

Maximum filesystem blocks=49545216

6 block groups

8192 blocks per group, 8192 fragments pergroup

2008 inodes per group

Superblock backups stored on blocks:

         8193,24577, 40961

Writing inode tables: done                           

Creating journal (4096 blocks): done

Writing superblocks and filesystemaccounting information: done

This filesystem will be automaticallychecked every 22 mounts or

180 days, whichever comes first.  Use tune2fs -c or -i to override.

nfs@ubuntu:~$ sudomkfs.ext3 /dev/sdb5       //格式化分区

mke2fs 1.41.9 (22-Aug-2009)

Filesystem label=

OS type: Linux

Block size=1024 (log=0)

Fragment size=1024 (log=0)

34136 inodes, 136520 blocks

6826 blocks (5.00%) reserved for the superuser

First data block=1

Maximum filesystem blocks=67371008

17 block groups

8192 blocks per group, 8192 fragments pergroup

2008 inodes per group

Superblock backups stored on blocks:

         8193,24577, 40961, 57345, 73729

Writing inode tables: done                           

Creating journal (4096 blocks): done

Writing superblocks and filesystemaccounting information: done

This filesystem will be automaticallychecked every 31 mounts or

180 days, whichever comes first.  Use tune2fs -c or -i to override.

nfs@ubuntu:~$ sudomkfs.ext3 /dev/sdb6      //格式化分区

mke2fs 1.41.9 (22-Aug-2009)

Filesystem label=

OS type: Linux

Block size=1024 (log=0)

Fragment size=1024 (log=0)

34136 inodes, 136520 blocks

6826 blocks (5.00%) reserved for the superuser

First data block=1

Maximum filesystem blocks=67371008

17 block groups

8192 blocks per group, 8192 fragments pergroup

2008 inodes per group

Superblock backups stored on blocks:

         8193,24577, 40961, 57345, 73729

Writing inode tables: done                           

Creating journal (4096 blocks): done

Writing superblocks and filesystemaccounting information: done

This filesystem will be automaticallychecked every 26 mounts or

180 days, whichever comes first.  Use tune2fs -c or -i to override.

nfs@ubuntu:~$

分区完成

二、下载镜像

将我们所用到的镜像文件全部放在同一个目录下(这里以test为例),将做好分区的SD卡插入PC,以下为下载镜像操作

nfs@ubuntu:~$ cd/home/nfs/test/

nfs@ubuntu:~/test$sudo dd if=u-boot-no-padding.bin of=/dev/sdb bs=1K seek=1 //下载uboot

154 1 records in

154 1 records out

158652 bytes (159 kB) copied, 0.283056 s,560 kB/s

nfs@ubuntu:~/test$sudo sync

nfs@ubuntu:~/test$ sudodd if=uImage of=/dev/sdb bs=1M seek=1

2 1 records in

2 1 records out

2520588 bytes (2.5 MB) copied, 0.8403 s,3.0 MB/s

nfs@ubuntu:~/test$ sudosync

nfs@ubuntu:~/test$ sudodd if=uramdisk.img of=/dev/sdb bs=4M seek=1

0 1 records in

0 1 records out

213111 bytes (213 kB) copied, 0.16925 s,1.3 MB/s

nfs@ubuntu:~/test$ sudosync

nfs@ubuntu:~/test$ sudodd if=system.img of=/dev/sdb2

207128 0 records in

207128 0 records out

106049536 bytes (106 MB) copied, 25.4979 s,4.2 MB/s

nfs@ubuntu:~/test$sudo sync

nfs@ubuntu:~/test$sudo dd if=recovery.img of=/dev/sdb4

9200 0 records in

9200 0 records out

4710400 bytes (4.7 MB) copied, 8.25522 s,571 kB/s

nfs@ubuntu:~/test$ sudosync

nfs@ubuntu:~/test$

三、设置U-Boot变量

将下载了镜像文件的SD卡插入i.MX51 EVK ,设置拨码开关为SD卡启动,连接i.MX51 EVK于PC串口,打开超级终端设置波特率为115200,进入U-Boot命令行后输入以下命令设置启动变量

BBG U-Boot > setenv bootcmd 'runbootcmd_SD1 bootcmd_SD2'

BBG U-Boot > setenv bootcmd_SD1 'runbootargs_base bootargs_android bootargs_SD'

BBG U-Boot > setenv bootcmd_SD2 'mmcread 0 {loadaddr} {rd_loadaddr}'

BBG U-Boot > setenv bootargs_base'setenv bootargs console=ttymxc0,115200'

BBG U-Boot > setenv bootargs_SD 'setenvbootargs ${bootargs}'

BBG U-Boot > setenv bootargs_android'setenv bootargs ${bootargs} init=/init androidboot.console=ttymxc0 di1_primarycalibration ip=dhcp'

BBG U-Boot > setenv loadaddr 0x90800000

BBG U-Boot > setenv rd_loadaddr0x90B00000

BBG U-Boot > saveenv

分区要点:

1.各个区的容量,要视情况而定,而不能照搬,例如放多媒体文件的区要越大越好,安装系统文件的区也尽量大一些,以便以后安装软件

2.一个区的编号应该尽量紧挨另一个区的编号

3.以上是1G的卡的分区分配情况,其他卡的分区容量要自己根据实际情况分配好

分区步骤

1.      最windows的磁盘管理器进行格式化,和删除分区工作。

2.      到Linux下进行分区,并保存

3.      格式化

4.      烧写镜像

磁盘容量的计算

对应一个磁盘来说:有盘面(side)(也就是磁头数的个数,一个盘面有一个磁头(header)),磁道(track),扇区(sector)组成,相同的磁道数构成一个柱面(clinders),一个扇区有固定的字节组成,一个是512个字节。

联想到磁盘的物理结构可知:

磁盘的容量=512*扇区数*磁道数*盘面数=一个柱面的所含的字节数*柱面个数(也就是磁道数)

等效的关系:柱面的个数=磁道数

                            盘面数=磁头数

           一个柱面所含的字节数=512*扇区数*磁头数

对应我们8G的SD卡,卡的信息参数是

Disk /dev/sdb: 7948 MB, 7948206080 bytes

245 heads, 62 sectors/track, 1021 cylinders

Units = cylinders of 15190 * 512 = 7777280bytes

Disk identifier: 0x00000000

我们的分区情况是

1.      预留一个柱面用来存放MRB,uboot和kernel,uramdisk根文件系统。(即7M系统盘,类似于PC机的C盘,但是不对它进行分区,不存在文件系统)

2.      /dev/sdb1 基本分区用来存放多媒体文件,采用的是发热贴fat32 windows兼容的文件系统,即可以在windows里面进行访问(其他文件系统(ext3)不能再windows访问,他们是Linux特有的文件系统。我们给它分5G

3.      /dev/sdb2/ 基本分区是Android的系统文件,挂载成/system/目录,用来对存放Android的系统库,和安装.apk格式软件,我们给他分1G 128M=1128M

4.      /dev/sdb3/ 扩展分区512M

下面的逻辑分区为

/dev/sdb5/ 逻辑分区用来存放已安装的数据,如果应用程序安装过后的数据。挂载成

Mount as /data   挂载成/cache 我们分配256M

/dev/sdb5/逻辑分区  用来做Android缓存的,我们分配256M

5.      /dev/sdb4/ 基本分区  用来在恢复模式下使用,挂载成Mount as / in recovery mode。我们分配剩下的分区 (即384M,不需要我们手动设置)

四.程序的安装

Android程序的安装有两种方式:

1.      拷贝安装法:类似于PC的程序安装法

拷贝安装法又有两种方法

一.    系统安装法,

该方法就像系统附带的程序一样安装,把.apk文件直接放到/system/app/下即可,这样我们安装的程序就跟系统自带的程序放在一起,在开机时自动安装启动。注意该方法一次性只能安装一个程序,多个程序要多次安装。

二.    手动安装法

把APK安装包放在SD卡里,系统启动后进入SD卡(可以通过SD卡浏览器来进入),让后点击该.apk安装版就可以安装该程序,类似于PC机程序的安装方法

2.      使用ADB工具在线安装方法

见http://www.cxyclub.cn/n/1378/(或对应HTML文档)

0 人点赞