UBIFS file system has been designed for raw flash裸的 没有controller,当然也就没有了FTL firmware. It doesn't work with block devices and it assumes the raw flash device model. In other words, it assumes the device has eraseblocks, 他无法工作在block device之上。换句话说,它认为设备有很多eraseblocks。 which may be written to, read from, or erased. UBIFS takes care of writing all data out-of-place, doing garbage-collection and so on. UBIFS utilizes UBI, which is doing stuff like wear-leveling and bad eraseblock handling. All these things are not normally needed for block devices.
Very often people ask questions like \why not just use eMMC, or something like this?\Well, there is no simple answer, and the following is what UBIFS developers think. Please, take into account the date of this writing (3 May 2009). The answer is given in form of a list of non-structured items, and the reader should structure it in a way which is appropriate for his system. And because mass storage systems mostly use NAND flash (modern FTL devices also have NAND flash arrays inside), we talk
specifically about NAND flashes. Also, we'd like to emphasize that we do not give general recommendations and everything depends on system requirements.
1.裸NAND 芯片更简单 更便宜,虽然,随着业界推动FTL设备,情况似乎在发生变化。 2.you should stick with an FTL device 3....
一、准备
1、内核 配置的时候选上
1)Device Drivers --->Memory Technology Device (MTD) support --->UBI - Unsorted block images --->Enable UBI
2)File systems --->Miscellaneous filesystems --->UBIFS file system support
2、mtd-utils工具(flash_eraseall、ubiattach、ubimkvol)准备
1)下载(mtd-utils、zlib、lzo)源码
wget http://debian.mirror.inra.fr/debian/pool/main/m/mtd-utils/mtd-utils_20080508.orig.tar.gz wget http://www.zlib.net/zlib-1.2.3.tar.gz
wget http://www.oberhumer.com/opensource/lzo/download/lzo-2.03.tar.gz
2)编译安装zlib
tar xzvf zlib-1.2.3.tar.gz
cd zlib-1.2.3
CC=arm-linux-gcc ./configure --shared --prefix=/usr/local/arm/3.4.5/arm-linux
make
make install cd ..
3)编译安装lzo tar xzvf lzo-2.03.tar.gz cd lzo-2.03
CC=arm-linux-gcc ./configure --host=arm-linux --prefix=/usr/local/arm/3.4.5/arm-linux make make install
cd ..
4)编译mtd-utils
tar xzvf mtd-utils_20080508.orig.tar.gz cd mtd-utils-20080508
修改Makefile文件: #CROSS=arm-linux-
修改为 CROSS=arm-linux- BUILDDIR := $(CROSS:-=) 修改为 BUILDDIR := .
修改ubi-utils/Makefile文件: 添加 CROSS=arm-linux-
修改 ubi-utils/new-utils/Makefile文件: 添加 CROSS=arm-linux-
make WITHOUT_XATTR=1
ubi-utils子目录下生成我们需要的ubiattach、ubimkvol等文件(请确保是交叉编译所得)
3、mtd-utils工具(mkfs.ubifs、ubinize)准备 git-clone git://git.infradead.org/mtd-utils.git cd mtd-utils/ make
mkfs.ubifs子目录下生成我们需要的mkfs.ubifs工具 ubi-utils/new-utils子目录下生成我们需要的ubinize工具
ubifs文件系统构建 (2012-02-11 02:25) 标签: ubi ubifs busybox 分类: 嵌入式
=====================阶段一:创建根文件系统所需文件====================== 一、构建busybox并make install
然后修改_install/bin/busybox权限: chmod 4755 _install/bin/busybox
(给予busybox任何人可读可执行,所有者可读可写可执行,4读,2写,1执行,7=4+2+1,5=4+1,三者分别是所有者,所有者组,其他组。最前面的4表示其他用户执行该文件时,权限同所有者)
进入到_install目录创建linux需要的一些目录:
mkdir -p dev etc home lib mnt proc root sys tmp usr var/lib/misc var/lock var/log var/run var/tmp 并修改权限: chmod 1777 tmp
chmod 1777 var/tmp
(最前面1防止被其他用户删除)
在dev下创建console和null设备: mknod -m 660 console c 5 1 mknod -m 660 null c 1 3
mknod -m 660 ttySAC0 c 204 64 mknod -m 660 ttySAC1 c 204 65 mknod -m 660 ttySAC2 c 204 66
(这两个设备用来供init启动时调用)
看busybox依赖那些so库
/develop/crosstools/arm-dhole-linux-gnueabi/bin/arm-linux-readelf -a busybox | grep Shared 显示结果
0x00000001 (NEEDED) Shared library: [libm.so.6] 0x00000001 (NEEDED) Shared library: [libc.so.6] 说明依赖libm.so.6和libc.so.6
把交叉编译器里的library拷贝到_install/lib目录下, 我做的交叉编译器lib库是在
/develop/crosstools/arm-dhole-linux-gnueabi/arm-dhole-linux-gnueabi/sysroot/lib/
目录下,鉴于以后的应用程序可能会用到除libm.so.6和libc.so.6外的这些库,因此全部拷过去,
在_install下执行如下命令: cp
/develop/crosstools/arm-dhole-linux-gnueabi/arm-dhole-linux-gnueabi/sysroot/lib/*.so* lib -a
然后在_install/etc下创建一些配置文件: 文件fstab: 内容如下:
-----------------------------------------------------------------> # /etc/fstab: static file system information. # # #
# file system mount type options dump pass #for mdev
proc /proc proc defaults 0 0 sysfs /sys sysfs defaults 0 0
#make sure /dev /tmp /var are tmpfs(tmpfs use ram as media) thus can be r/w tmpfs /tmp tmpfs defaults 0 0 tmpfs /dev tmpfs defaults 0 0 tmpfs /var tmpfs defaults 0 0 #usbfs /proc/bus/usb usbfs defaults 0 0 -----------------------------------------------------------------< 说明: fstab中的文件系统会被mount -a挂载。
文件inittab: 内容如下:
-----------------------------------------------------------------> # see busybox/examples/inittab
# Boot-time system configuration/initialization script.
# This is run first except when booting in single-user mode. ::sysinit:/etc/init.d/rcS
#Start an \#use respawn instead askfirst to make sure console always active ::respawn:-bin/sh
# Stuff to do when restarting the init process ::restart:/sbin/init
# Stuff to do before rebooting ::ctrlaltdel:/sbin/reboot ::shutdown:/bin/umount -a -r
::shutdown:/sbin/swapoff -a
-----------------------------------------------------------------< 说明: inittab会被init执行
文件init.d/rcS:(mkdir init.d;cd init.d) 内容如下:
-----------------------------------------------------------------> #!/bin/sh
#add setting here for auto start program PATH=/sbin:/bin:/usr/sbin:/usr/bin runlevel=S prevlevel=N umask 022
export PATH runlevel prevlevel
#See docs/mdev.txt
#mount all fs in fstab,proc and sysfs are must for mdev mount -a
#create device nodes
echo /sbin/mdev > /proc/sys/kernel/hotplug
#seed all device nodes mdev -s
#create pts directory for remote login such as SSH and telnet mkdir -p /dev/pts
mount -t devpts devpts /dev/pts
if [ -f /etc/hostname ]; then /bin/hostname -F /etc/hostname fi
if [ -e /sys/class/net/eth0 ]; then ifconfig eth0 192.168.1.15 fi
echo \
-----------------------------------------------------------------< 说明: init.d/rcS会在开机时自动执行。
更改rcS和inittab的权限为777: chmod 777 init.d/rcS