本来想到ubuntu 模拟 jffs2 文件操作, 但是发现按照网上的操作流程缺mtdchar.ko,请问有没有高手碰到过?
http://blog.csdn.net/u014780165/article/details/43192663
一. 挂载操作
1. sudo modprobe mtdram total_size=16384
2. sudo modprobe mtdchar
3. sudo dd if=mtd.jffs2 of=/dev/mtd0
4. sudo modprobe mtdblock
5. sudo modprobe jffs2
6. sudo mount -t jffs2 -o rw /dev/mtdblock0 jffs2_dir
二. 卸载操作
1. sudo umount jffs2_dir
2. sudo rmmod jffs2 mtdblock mtdchar mtdram mtd_blkdevs mtd
三. 说明
1. mtd.jffs2为打包的jffs2文件
2. jffs2_dir为要挂载的目录
我的操作系统是Ubuntu 14.04LTS
[ 0.000000] Linux version 4.2.0-42-generic (buildd@lgw01-55) (gcc version 4.8.4 (Ubuntu 4.8.4-2ubuntu1~14.04.3) ) #49~14.04.1-Ubuntu SMP Wed Jun 29
20:22:11 UTC 2016 (Ubuntu 4.2.0-42.49~14.04.1-generic 4.2.8-ckt12)
这两个命令也执行了
sudo apt-get install mtd-utils
sudo apt-get install mtd-tools
xxx@ubuntu:/tmp$ sudo modprobe mtdchar
modprobe: FATAL: Module mtdchar not found.
离线
/lib/modules/4.2.0-42-generic/kernel/drivers/mtd/
这个目录下面也确实有mtdchar.ko的文件,
肿么办?
离线
为了跟踪这个问题, 我特意去 kernel.org 下载了最新版本的Linux,
wget https://www.kernel.org/pub/linux/kernel/v4.x/linux-4.13.11.tar.xz
准备配置编译make menuconfig,
可是怎么样也找不到MTD CHAR的相关选项,
然后我打开 drivers/mtd/Makefile drivers/mtd/Kconfig
#
# Makefile for the memory technology device drivers.
## Core functionality.
obj-$(CONFIG_MTD) += mtd.o
mtd-y := mtdcore.o mtdsuper.o mtdconcat.o mtdpart.o mtdchar.oobj-$(CONFIG_MTD_OF_PARTS) += ofpart.o
obj-$(CONFIG_MTD_REDBOOT_PARTS) += redboot.o
obj-$(CONFIG_MTD_CMDLINE_PARTS) += cmdlinepart.o
obj-$(CONFIG_MTD_AFS_PARTS) += afs.o
obj-$(CONFIG_MTD_AR7_PARTS) += ar7part.o
obj-$(CONFIG_MTD_BCM63XX_PARTS) += bcm63xxpart.o
obj-$(CONFIG_MTD_BCM47XX_PARTS) += bcm47xxpart.o
obj-y += parsers/
发现 mtdchar根本不是单独编译的, 而是和其他一起打包成 *.ko,
看起来就是 mtd.ko 了
所以我们只需要 modprobe mtd 就可以达到 sudo modprobe mtdchar 一样的效果,
所以不要纠结 sudo modprobe mtdchar 的问题了。
离线
然后一步一步创建 jffs2.img 文件, 挂载, 成功!
感谢,真的可以了。
sudo modprobe mtd
sudo modprobe mtdblock
sudo modprobe jffs2
sudo modprobe mtdram total_size=25536
sudo dd if=jffs2.img of=/dev/mtd0
最后
cityf@ubuntu:/disk4$ ls /tmp/ccc/
bin dev lib linuxrc mnt proc sbin sys tmp usr
离线
cityf@ubuntu:/disk4$ sudo rmmod mtdram
cityf@ubuntu:/disk4$ sudo modprobe mtdram total_size=25536 erase_size=4
cityf@ubuntu:/disk4$ sudo dd if=jffs2.img of=/dev/mtd0
51072+0 records in
51072+0 records out
26148864 bytes (26 MB) copied, 0.0904095 s, 289 MB/s
cityf@ubuntu:/disk4$ sudo mount -t jffs2 -o rw /dev/mtdblock0 /tmp/ccc/
cityf@ubuntu:/disk4$ cat /proc/mtd
dev: size erasesize name
mtd0: 018f0000 00001000 "mtdram test device"
离线
我把上面这种方法再试了一次,
发现烧到V3s的spi flash之后
sudo rmmod mtdram
sudo modprobe mtd
sudo modprobe mtdblock
sudo modprobe jffs2
sudo modprobe mtdram total_size=20480 erase_size=4
sudo dd if=jffs2.bin of=/dev/mtd0
mkdir /tmp/ccc/
sudo mount -t jffs2 -o rw /dev/mtdblock0 /tmp/ccc/
###在/tmp/ccc 这里编辑修改文件哦###
sudo umount /tmp/ccc###生成jffs2镜像文件
sudo dd if=/dev/mtd0 of=jffs2_1.bin
dd conv=notrunc if=jffs2_1.bin of=image1.bin bs=$((0xC00000)) seek=1
cp image1.bin /mnt/hgfs/F/
[ 47.725265] jffs2: Header CRC failed on REF_PRISTINE node at 0x00880ff8: Read 0x20011904, calculated 0x3481ff1c
[ 48.215271] jffs2: Data CRC failed on REF_PRISTINE data node at 0x00881ed4: Read 0x98083a15, calculated 0x06eaab93
[ 48.705294] jffs2: Data CRC failed on REF_PRISTINE data node at 0x00882ef8: Read 0x169b0f33, calculated 0xdfd649b9
[ 49.075311] jffs2: Data CRC failed on REF_PRISTINE data node at 0x00883f48: Read 0x1f0b0e43, calculated 0xf8136e0e
[ 49.385349] jffs2: Data CRC failed on REF_PRISTINE data node at 0x00884e38: Read 0x3e9cb261, calculated 0xfb37277c
[ 49.575365] jffs2: Data CRC failed on REF_PRISTINE data node at 0x00885ce4: Read 0xf1a86ad1, calculated 0xa59e13ee
[ 49.765426] jffs2: Data CRC failed on REF_PRISTINE data node at 0x00886c20: Read 0xa9890ad3, calculated 0x2b6a90ca
[ 49.955485] jffs2: Node CRC failed on REF_PRISTINE data node at 0x00887fdc: Read 0x192297f7, calculated 0x977e8568
[ 50.025579] jffs2: Data CRC failed on REF_PRISTINE data node at 0x008887d4: Read 0x8a599699, calculated 0xa81f0dbb
[ 50.158858] jffs2: Data CRC failed on REF_PRISTINE data node at 0x008898f4: Read 0x2d8cd776, calculated 0x2a6686fe
[ 50.465276] jffs2: Data CRC failed on REF_PRISTINE data node at 0x0088af30: Read 0x08f81c8f, calculated 0xc9a3c5d6
[ 51.555257] jffs2: Node CRC failed on REF_PRISTINE data node at 0x0088bfe8: Read 0xc1e0d851, calculated 0x049ccfa7
[ 52.705568] jffs2: Data CRC failed on REF_PRISTINE data node at 0x0088c858: Read 0xc3eaed7a, calculated 0x9eac2cf3
[ 52.716774] jffs2: Data CRC failed on REF_PRISTINE data node at 0x0088c858: Read 0xc3eaed7a, calculated 0x9eac2cf3
[ 52.727688] jffs2: Data CRC c3eaed7a != calculated CRC 9eac2cf3 for node at 0088c858
[ 52.735464] jffs2: read_cache_page() returned error: -5
[ 52.740688] jffs2: Error garbage collecting node at 0088c858!
[ 52.746442] jffs2: No space for garbage collection. Aborting GC thread
文件系统出现这种问题,
运行根本不正常,
所以这种方法用电脑读jffs2的镜像文件尚可,
但是要回写还是算了吧.
离线