分区及其大小可以在bootargs里面指定,比如我们128M的spi nand falsh的分区及其大小
1M(boot),3M(kernel),24M(rootfs),4M(config),32M(user),4M(ini),12M(log),48M(upgrade)
bootargs=mem=128M console=ttyAMA0,115200 root=/dev/mtdblock2 rootfstype=yaffs2 mtdparts=hinand:1M(boot),3M(kernel),24M(rootfs),4M(config),32M(user),4M(ini),12M(log),48M(upgrade)
bootcmd=nand read 0x82000000 0x100000 0x300000;bootm 0x82000000
在osdrv下的Makefile中有制作jffs2、yaffs2等根文件系统镜像的制作方法
hirootfs_build: hirootfs_prepare hibusybox hiboardtools hipctools hirootfs_notools_build
hirootfs_notools_build:
@echo "---------task [7] build rootfs"
chmod 777 $(OSDRV_DIR)/pub/bin/$(PUB_BOARD)/*
chmod 777 $(OSDRV_DIR)/pub/bin/pc/*
rm $(OSDRV_DIR)/pub/$(PUB_ROOTFS)/dev/* -rf
pushd $(OSDRV_DIR)/pub/$(PUB_ROOTFS);ln -s sbin/init init;popd
ifeq ($(BOOT_MEDIA),spi)
pushd $(OSDRV_DIR)/pub/bin/pc;./mkfs.jffs2 -d $(OSDRV_DIR)/pub/$(PUB_ROOTFS) -l -e 0x40000 -o $(OSDRV_DIR)/pub/$(PUB_IMAGE)/$(JFFS2_IMAGE_BIN_256K);popd
pushd $(OSDRV_DIR)/pub/bin/pc;./mkfs.jffs2 -d $(OSDRV_DIR)/pub/$(PUB_ROOTFS) -l -e 0x20000 -o $(OSDRV_DIR)/pub/$(PUB_IMAGE)/$(JFFS2_IMAGE_BIN_128K);popd
pushd $(OSDRV_DIR)/pub/bin/pc;./mkfs.jffs2 -d $(OSDRV_DIR)/pub/$(PUB_ROOTFS) -l -e 0x10000 -o $(OSDRV_DIR)/pub/$(PUB_IMAGE)/$(JFFS2_IMAGE_BIN_64K);popd
cp $(OSDRV_DIR)/tools/pc/ubi_sh/mkubiimg.sh $(OSDRV_DIR)/pub/$(PUB_IMAGE)
chmod +x $(OSDRV_DIR)/pub/$(PUB_IMAGE)/mkubiimg.sh
# build the pagesize = 2k, blocksize = 128k, part_size = 32M #
pushd $(OSDRV_DIR)/pub/$(PUB_IMAGE);./mkubiimg.sh $(CHIP) 2k 128k $(OSDRV_DIR)/pub/$(PUB_ROOTFS) 32M $(OSDRV_DIR)/pub/bin/pc;popd
# build the pagesize = 4k, blocksize = 256k, part_size = 50M #
pushd $(OSDRV_DIR)/pub/$(PUB_IMAGE);./mkubiimg.sh $(CHIP) 4k 256k $(OSDRV_DIR)/pub/$(PUB_ROOTFS) 50M $(OSDRV_DIR)/pub/bin/pc;popd
rm $(OSDRV_DIR)/pub/$(PUB_IMAGE)/mkubiimg.sh
endif
ifeq ($(BOOT_MEDIA),emmc)
pushd $(OSDRV_DIR)/pub/bin/pc;./$(EXT4_TOOL) -l 96M -s $(OSDRV_DIR)/pub/$(PUB_IMAGE)/$(EXT4_IMAGE_BIN) $(OSDRV_DIR)/pub/$(PUB_ROOTFS);popd
endif
ifeq ($(BOOT_MEDIA),spi)
pushd $(OSDRV_DIR)/pub/bin/pc;./$(YAFFS_TOOL) $(OSDRV_DIR)/pub/$(PUB_ROOTFS)/ $(OSDRV_DIR)/pub/$(PUB_IMAGE)/$(YAFFS2_IMAGE_BIN_2K_4BIT) 1 2;popd
chmod 644 $(OSDRV_DIR)/pub/$(PUB_IMAGE)/$(YAFFS2_IMAGE_BIN_2K_4BIT)
pushd $(OSDRV_DIR)/pub/bin/pc;./$(YAFFS_TOOL) $(OSDRV_DIR)/pub/$(PUB_ROOTFS)/ $(OSDRV_DIR)/pub/$(PUB_IMAGE)/$(YAFFS2_IMAGE_BIN_2K_24BIT) 1 4;popd
chmod 644 $(OSDRV_DIR)/pub/$(PUB_IMAGE)/$(YAFFS2_IMAGE_BIN_2K_24BIT)
pushd $(OSDRV_DIR)/pub/bin/pc;./$(YAFFS_TOOL) $(OSDRV_DIR)/pub/$(PUB_ROOTFS)/ $(OSDRV_DIR)/pub/$(PUB_IMAGE)/$(YAFFS2_IMAGE_BIN_4K_4BIT) 2 2;popd
chmod 644 $(OSDRV_DIR)/pub/$(PUB_IMAGE)/$(YAFFS2_IMAGE_BIN_4K_4BIT)
pushd $(OSDRV_DIR)/pub/bin/pc;./$(YAFFS_TOOL) $(OSDRV_DIR)/pub/$(PUB_ROOTFS)/ $(OSDRV_DIR)/pub/$(PUB_IMAGE)/$(YAFFS2_IMAGE_BIN_4K_24BIT) 2 4;popd
chmod 644 $(OSDRV_DIR)/pub/$(PUB_IMAGE)/$(YAFFS2_IMAGE_BIN_4K_24BIT)
find $(OSDRV_DIR)/pub/$(PUB_ROOTFS)/ -name '*svn' | xargs rm -rf
pushd $(OSDRV_DIR)/pub;tar czf $(PUB_ROOTFS).tgz $(PUB_ROOTFS);rm $(PUB_ROOTFS) -rf;popd
# pushd $(OSDRV_DIR)/pub;tar czf $(PUB_ROOTFS).tgz $(PUB_ROOTFS);popd
@echo "---------finish osdrv work"
$(PUB_ROOTFS) 这个文件是busybox基础上,拷贝了一些hisi的runtimming lib生成的,在第一次执行make的时候就会生成。然后你可以将上段代码修改一下
hirootfs_build: hirootfs_prepare hirootfs_notools_build
然后执行:make BOOT_MEDIA=spi CHIP=hi3516dv300 hirootfs_build ,可以直接去编译生成文件系统的镜像了。
如果需要制作分区的镜像,根据你的flash类型,选择你说需要的文件系统格式,制作分区的镜像即可。
比如,如果我选用的是spi nor flash,需要创建一个user分区的镜像,那么选择jssf2的文件系统
pushd $(OSDRV_DIR)/pub/bin/pc;./mkfs.jffs2 -d $(OSDRV_DIR)/pub/user -l -e 0x10000 -o $(OSDRV_DIR)/pub/$(PUB_IMAGE)/user.bin;popd
-d 文件系统镜像的源文件
-e, --eraseblock=SIZE 设定擦除块的大小为(默认: 64KiB)
-l, --little-endian 指定使用小端格式
-o, --output=FILE 指定輸出image檔案的文件名.(default: stdout)
在对应的分区的镜像生成后,烧录到对应地址的分区上,对应于bootargs上的分区,user分区是在/dev/mtdblock4上,开机的时候挂上此分区就行了
mount -t jffs2 /dev/mtdblock4 /mnt/user
查看各分区大小和挂载的情况
/#cat /proc/mtd
Creating 8 MTD partitions on "hinand":
0x000000000000-0x000000100000 : "boot"
0x000000100000-0x000000400000 : "kernel"
0x000000400000-0x000001c00000 : "rootfs"
0x000001c00000-0x000002000000 : "config"
0x000002000000-0x000004000000 : "user"
0x000004000000-0x000004400000 : "ini"
0x000004400000-0x000005000000 : "log"
0x000005000000-0x000008000000 : "upgrade"
/ # mount
rootfs on / type rootfs (rw)
/dev/root on / type yaffs2 (rw,relatime)
proc on /proc type proc (rw,relatime)
sysfs on /sys type sysfs (rw,relatime)
tmpfs on /dev type tmpfs (rw,relatime)
devpts on /dev/pts type devpts (rw,relatime,mode=600)
/dev/mtdblock4 on /mnt/user type yaffs2 (rw,relatime)
/dev/mtdblock5 on /mnt/ini type yaffs2 (rw,relatime)
/dev/mtdblock6 on /mnt/log type yaffs2 (rw,relatime)
/dev/mtdblock7 on /mnt/upgrade type yaffs2 (rw,relatime)
/dev/shm/ on /tmp type tmpfs (rw,relatime)
/dev/mtdblock3 on /jb_config/jb_rootfs type yaffs2 (rw,relatime)
/dev/root on /data/image type yaffs2 (rw,relatime)
/dev/mtdblock6