DM8168心得之SD卡快速分区制作
/******************************************************************
* author: 卢浩
* time: 12.03.08
* environment: ubuntu10.04LTS +TI DM8186
* kernel version: linux-2.6.37
******************************************************************/
这一个星期一直在搞DM8168,虽然还有一些细节需要完善,但现在也基本从SD卡和nandflash可以正常启动起来了...
首先我们需要给SD卡分区,至于怎么分区,办法还是挺多的,我在上一家公司的时候,他们的文档里面是在linux下用sudo fdisk /dev/sdb进行分区,具体这个怎么做,我建议大家搜一下百度谷歌,我这里就不详细讲了,我下面截一张关于这个的图
大家进去之后可以按m看看具体怎么做。接下来我讲讲TI给的关于SD卡分区的资料,这个就比较方便了
首先我们看一个连接。关于TI给的SD卡分区的连接
http://processors.wiki.ti.com/index.php/How_to_Make_3_Partition_SD_Card
首先在linux主机上建立一个文件,命名为mk3PartSDCard,把下面段代码复制进去并保存
#! /bin/sh
# mk3PartSDCard.sh v0.3
# Licensed under terms of GPLv2
DRIVE=$1
dd if=/dev/zero of=$DRIVE bs=1024 count=1024
SIZE=`fdisk -l $DRIVE | grep Disk | awk '{print $5}'`
echo DISK SIZE - $SIZE bytes
CYLINDERS=`echo $SIZE/255/63/512 | bc`
sfdisk -D -H 255 -S 63 -C $CYLINDERS $DRIVE << EOF
,9,0x0C,*
10,115,,-
126,,,-
EOF
mkfs.vfat -F 32 -n "boot" ${DRIVE}1
umount ${DRIVE}1
mkfs.ext3 -L "rootfs" ${DRIVE}2
umount ${DRIVE}2
mkfs.ext3 -L "START_HERE" ${DRIVE}3
插上你的SD卡,并且让linux主机识别到改变文件的可执行属性
user@UbuntuVbox1004:~$ chmod 755 mk3PartSDCard
在命令终端输入df -hT来显示挂载分区情况
执行这个脚本之前请umount你的SD卡
user@Ubuntu1004:~$ umount /dev/sdb1 然后执行这个脚本
user@Ubuntu1004:~$ sudo ./mk3PartSDCard /dev/sdb 然后你会看到
user@UbuntuVbox1004:~$ sudo ./mk3PartSD /dev/sdb
[sudo] password for user:
1024+0 records in
1024+0 records out
1048576 bytes (1.0 MB) copied, 1.53109 s, 685 kB/s
Disk /dev/sdb doesn't contain a valid partition table
DISK SIZE - 1977614336 bytes
Checking that no-one is using this disk right now ...
OK
Disk /dev/sdb: 240 cylinders, 255 heads, 63 sectors/track
sfdisk: ERROR: sector 0 does not have an msdos signature
/dev/sdb: unrecognized partition table type
Old situation:
No partitions found
New situation:
Units = cylinders of 8225280 bytes, blocks of 1024 bytes, counting from 0
Device Boot Start End #cyls #blocks Id System
/dev/sdb1 * 0+ 8 9- 72261 c W95 FAT32 (LBA)
/dev/sdb2 10 124 115 923737+ 83 Linux
/dev/sdb3 126 239 114 915705 83 Linux
/dev/sdb4 0 - 0 0 0 Empty
Successfully wrote the new partition table
Re-reading the partition table ...
If you created or changed a DOS partition, /dev/foo7, say, then use dd(1)
to zero the first 512 bytes: dd if=/dev/zero of=/dev/foo7 bs=512 count=1
(See fdisk(8).)
mkfs.vfat 3.0.7 (24 Dec 2009)
umount: /dev/sdb1: not mounted
mke2fs 1.41.11 (14-Mar-2010)
Filesystem label=rootfs
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
57856 inodes, 230934 blocks
11546 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=239075328
8 block groups
32768 blocks per group, 32768 fragments per group
7232 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376
Writing inode tables: done
Creating journal (4096 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 20 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
umount: /dev/sdb2: not mounted
mke2fs 1.41.11 (14-Mar-2010)
Filesystem label=START_HERE
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
57232 inodes, 228926 blocks
11446 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=234881024
7 block groups
32768 blocks per group, 32768 fragments per group
8176 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840
Writing inode tables: done
Creating journal (4096 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 27 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
然后输入这些
user@Ubuntu1004:~$ umount /dev/sdb1
user@Ubuntu1004:~$ umount /dev/sdb2
user@Ubuntu1004:~$ umount /dev/sdb3
再输入df -hT查看分区情况
记住第一个分区/media/boot用来存放MLO uboot.bin uImage
第二个分区/media/rootfs用来存放你的文件系统