###加载根文件系统
./kernel/uClinux/linux-4.4.x/init/initramfs.c:449:static char * __init unpack_to_rootfs(char *buf, unsigned long len)
./kernel/uClinux/linux-4.4.x/init/initramfs.c:610: char *err = unpack_to_rootfs(__initramfs_start, __initramfs_size);
./kernel/uClinux/linux-4.4.x/init/initramfs.c:617: err = unpack_to_rootfs((char *)initrd_start,
./kernel/uClinux/linux-4.4.x/init/initramfs.c:624: unpack_to_rootfs(__initramfs_start, __initramfs_size);
./kernel/uClinux/linux-4.4.x/init/initramfs.c:644: err = unpack_to_rootfs((char *)initrd_start,
# mount -t jffs2 -o rw,sync /dev/mtdblock3 /mnt > /dev/null
# ls
tmp bin lib sbin etc
mnt var usr dev logmemtst.txt
home init proc sys
# df
Filesystem 1k-blocks Used Available Use% Mounted on
/dev/mtdblock3 1024 64 960 6% /mnt //1M, 后期如果使用nor-
flash,此空间需要扩大
#
/dev/mtdblock3 指实际的flash分区,要以实际flash的支持的类型,选择文件系统格式挂载到用户空间;
供用户使用存放用户自己定义的文件,设备断电重启文件仍然存在。用户在/mnt目录下创建文件,保存文件,实
际写到实际的物理存储介质上flash上面。为了防止uboot、kernel、不被重写,故不允许挂载到用户空间,导
致数据异常板子死掉。
#
# cd /mnt
# ls
# touch test-nor-flash-reboot.c
# touch aaa
# reboot
The system is going down NOW !!
The system is going down NOW !!
----->welcome to XXXXXXX switch sdk config loading stopping ----->
RTK.0> exit
RTK.0>
Starting pid 77, console /dev/ttyS0: '/bin/sh'
BusyBox v1.00 (2022.01.21-02:32+0000) Built-in shell (msh)
Enter 'help' for a list of built-in commands.
# mount -t jffs2 -o rw,sync /dev/mtdblock3 /mnt > /dev/null
# cd /mnt
# ls
test-nor-flash-reboot.c aaa
#
//内核make menuconfig配置支持jffs2 filesystem
Linux/mips 4.4.153 Kernel Configuration
Device Drivers --->
<*> Memory Technology Device (MTD) support --->
<*> SPI-NOR device support ---> //for nor-flash driver
<*> Enable UBI - Unsorted block images ---> //for nand-flash driver tools
<*> NAND Device Support ---> //for nand-flash driver
File systems --->
[*] Miscellaneous filesystems --->
<*> Journalling Flash File System v2 (JFFS2) support //for nor-flash file-system
<*> UBIFS file system support //for nand-flash file-system tools
//uboot配置
U-Boot v Configuration
Board --->
(SPI-NAND) Boot Type
SDK Options --->
BSP Option --->
(SPI_NAND_Boot) Device Boot Type
//sdk配置
Realtek SDK 3.6.7.55090 Configuration
(1) BDINFO MTD Index
[*
linux中mtd设备jffs2 for nor-flash文件系统、flash领悟
于 2022-01-19 18:24:11 首次发布
本文探讨Linux系统下针对Nor-Flash的MTD(Memory Technology Device)设备层和JFFS2文件系统。通过理解这两者在Linux中的作用,可以深入了解服务器与嵌入式系统的存储管理。内容包括Linux文件系统框架和流程图。
摘要由CSDN通过智能技术生成