# jffs2文件系統掛載不上的常見原因
## 內核命令行不正確
`[ 0.000000] Kernel command line: console=ttyS0,115200 earlyprintk panic=5 rootwait mtdparts=spi32766.0:1M(uboot)ro,64k(dtb)ro,4M(kernel)ro,3008k(rootfs) root=31:03 rw rootfstype=jffs2`
內核命令行應正確顯示分區信息,如果分區信息不正確則無法正確掛載。
分區信息在include/configs/sun8i.h里修改
~~~
vi include/configs/sun8i.h
#define CONFIG_BOOTCOMMAND "sf probe 0; " \
"sf read 0x41800000 0x100000 0x10000; " \
"sf read 0x41000000 0x110000 0x400000; " \
"bootz 0x41000000 - 0x41800000"
#define CONFIG_BOOTARGS "console=ttyS0,115200 earlyprintk panic=5 rootwait " \
"mtdparts=spi32766.0:1M(uboot)ro,64k(dtb)ro,4M(kernel)ro,-(rootfs) root=31:03 rw rootfstype=jffs2"
~~~
## 識別不到分區
正常識別到分區,應該報以下信息:
~~~
[ 0.862858] m25p80 spi32766.0: w25q128 (16384 Kbytes)
[ 0.867927] in cmdline partion
[ 0.871123] p4 : size=100000
[ 0.874005] p4 : size=10000
[ 0.876796] p4 : size=400000
[ 0.879714] p4 : size=2f0000
[ 0.882596] spi32766.0: parser cmdlinepart: 4
[ 0.886949] 4 cmdlinepart partitions found on MTD device spi32766.0
[ 0.893230] Creating 4 MTD partitions on "spi32766.0":
[ 0.898374] 0x000000000000-0x000000100000 : "uboot"
[ 0.904828] 0x000000100000-0x000000110000 : "dtb"
[ 0.910973] 0x000000110000-0x000000510000 : "kernel"
[ 0.917258] 0x000000510000-0x000000800000 : "rootfs"
~~~
如果沒有顯示以上信息,則需要確認有無勾選相關驅動
進入到`Device Drivers > Memory Technology Device (MTD) support`,
確保選擇上mtd的`<*> Command line partition table parsing`支持,該項目用來解析uboot傳遞過來的flash分區信息。
以及SPI-NOR 設備的支持。
添加對jffs2文件系統的支持,路徑在`File systems > Miscellaneous filesystems-> Journalling Flash File System v2 (JFFS2) support`
## jffs2 Magic bitmask 錯誤
~~~
jffs2: Node at 0x00000f6c with length 0x00000144 would run over the end of the erase block
[ 1.133830] jffs2: Perhaps the file system was created with the wrong erase size?
[ 1.141435] jffs2: jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x00000f70: 0x0144 instead
[ 1.150994] jffs2: jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x00000f74: 0x912a instead
[ 1.160547] jffs2: jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x00000f78: 0x0002 instead
[ 1.170127] jffs2: jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x00000f7c: 0x000d instead
[ 1.180689] jffs2: jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x00000f80: 0x81a4 instead
[ 1.190183] jffs2: jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x00000f84: 0x03e8 instead
[ 1.199668] jffs2: jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x00000f88: 0x11d8 instead
[ 1.209151] jffs2: jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x00000f8c: 0xdec2 instead
[ 1.218634] jffs2: jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x00000f90: 0xdec2 instead
[ 1.228102] jffs2: jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x00000f94: 0xdec2 instead
[ 1.237581] jffs2: Further such events for this erase block will not be printed
[ 1.245110] jffs2: jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x00001000: 0x3fb1 instead
[ 1.254615] jffs2: jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x00001004: 0x1a28 instead
[ 1.264102] jffs2: jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x00001008: 0x7f01 instead
[ 1.273586] jffs2: jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x0000100c: 0x505d instead
[ 1.283098] jffs2: jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x00001010: 0x84c8 instead
[ 1.292588] jffs2: jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x00001014: 0xd8d1 instead
[ 1.302072] jffs2: jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x00001018: 0x4001 instead
[ 1.311555] jffs2: jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x0000101c: 0x8485 instead
[ 1.321033] jffs2: jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x00001020: 0x65b1 instead
[ 1.330514] jffs2: jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x00001024: 0x5d81 instead
~~~
該錯誤有若干種可能:
### jffs2鏡像生成錯誤
`mkfs.jffs2 -s 0x100 -e 0x10000 -p 0xAF0000 -d rootfs-brmin -o jffs2-brmin.img`
這里-s代表頁大小,普通spi nor flash的頁大小是256字節,即0x100
-e表示擦除的塊大小,普通spi nor flash的塊大小是64K字節,即0x10000
-p表示分區大小,在生成時會擦除分區大小的flash初始化。
這里必須和uboot里指定的分區大小一致,否則會出現臟頁。
### 內核使用了扇區擦除
mkfs.jffs2 使用的最小擦除尺寸是8KB,而spi flash的扇區大小是4KB,所以按照扇區擦除的話,會無法使用,所以必須使用塊擦除。
編譯內核前先確認下drivers/mtd/spi-nor/spi-nor.c里,自己使用的flash的相關信息
`#define SECT_4K BIT(0) /* SPINOR_OP_BE_4K works uniformly */`
如果發現信息里有SECT_4K,則會導致jffs2不能正常擦除(64KB),需要去掉該flag。
## 其它摘錄
Question1:JFFS2 error: (1) jffs2_build_inode_pass1: child dir "alsa" (ino #1159) of dir ino #1074 appears to be a hard link
JFFS2 error: (1) jffs2_build_inode_pass1: child dir "l" (ino #1170) of dir ino #1075 appears to be a hard link
原由 : flash沒有erase徹底.
VFS: Mounted root (jffs2 filesystem) on device 31:1. Freeing init memory: 136K
JFFS2 notice: (1) check_node_data: wrong data CRC in data node at 0x0f0a7f78: read 0x4462b066, calculated 0x48ea177f.
JFFS2 error: (488) jffs2_do_read_inode_internal: Argh. Special inode #139 with mode 0x61b0 had more than one node iget() failed for ino #139 mknod: /dev/null: File exists
Populating /dev using udev: udevd (499): /proc/499/oom_adj is deprecated, please use /proc/499/oom_score_adj instead.
JFFS2 error: (500) jffs2_do_read_inode_internal: Argh. Special inode #1123 with mode 0x21b0 had more than one node iget() failed for ino #1123
Question2:jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x00000024: 0x2b10 instead
mkfs.jffs2 -s 的參數問題 對照FLASH的大小再重新生成鏡像文件過即可 The answer this means that the data on your flash device is not a valid JFFS2 file system.
There is no single solution for this problem, but we will try to provide you some ideas how to fix this.
The first question you should try to answer is "why the data on my flash device is incorrect so that JFFS2 rejects to deal with it?". There are may be a plenty of reasons, e.g.:
1. you flash driver is severely buggy so it reads trash instead of valid data;
2. you flashed some trash instead of a valid JFFS2 image;
3. you did not manage to flash JFFS2 image correctly so that you ended up with
garbage on your flash, although the original image was perfectly fine;
4. you forgot to erase your flash before flashing it, etc.
Anyways, JFFS2 wouldn't complain if it was able to find correct data. As it does complain, there is something wrong with the data it reads.
One common mistake is to use /dev/mtdX or /dev/mtdblockX devices to flash JFFS2 images on NAND flashes. E.g.
cp jffs2_fs.img /dev/mtd2
This is incorrect because when dealing with NAND flashes one has to skip bad
eraseblocks and write only in NAND page size chunks. Please, use the nandwrite utility instead.
Also please, do not forget to erase your flash before flashing the image. You may use the
flash_eraseall utility for this. And it makes sense to make sure the erase functionality
actually works by reading the erased MTD device back and checking that only 0xFF bytes were read.
You may try to check if your flash driver works correctly and if you flashed the file system image correctly by means of reading the flash back after you have flashed your image, and compare the read image with the original one. Please, use the nandread utility to read from NAND flashes.
You can also do the following experiment to make sure JFFS2 works well. Erase your MTD device and mount it to JFFS2. You will end up with an empty file system. Copy some files to the JFFS2 file system and unmount it. Then mount it again and see if it mounts without problems. If it does, this is most probably not a JFFS2 bug.
Question3:Empty flash at 0xXXXXXXXX ends at 0xXXXXXXXX
This message is generated if a block of data is partially written. It is generally not a sign of any problem.
Question4:Name CRC failed on node at 0x00b620c8: Read 0x640c8ca3, calculated 0x795111fe
重啟,則不會有如上CRC錯誤信息。 問題原因:
我在燒寫jffs2 img之前,使用fis init -f 來擦除flash。fis init -f 命令執行完以后,flash空間就都是0xFF了!即使在mkfs.jffs2的時候使用'-p'參數指定最終輸出img的大小,但是超出文件系統的部分也會被填充為0xFF!但這可不是jffs2的格式!
我用fis create分了5M多(0x590000)的分區,但是jffs2fs.img只有不到3M(0x250000),那么把它燒寫到flash以后,分區中除了jffs2 img之外剩余的flash空間(大概2M)全是0xFF,這不是jffs2要求的格式,所以,會發出CRC錯誤的信息。假如有一種工具,他可以將flash format為jffs2的格式,那么就不會出現這個問題了。目前我還沒有找到這種工具,但是,可以確信的是:上面的CRC錯誤是不影響jffs2文件系統的使用
http://blog.chinaunix.net/space.php?uid=20727076&do=blog&id=1885384
Question5: VFS: Mounted root (jffs2 filesystem) readonly.
Freeing unused kernel memory: 304k freed Error -3 while decompressing! 804878c4(1884)->81200000(16384)
Failed to execute /linuxrc. Attempting defaults...
Kernel panic - not syncing: No init found. Try passing init= option to kernel.
原由 : 沒有仔細看 mkfs.jffs2 的手冊, 須要指定-b參數, 大小與PAGE_SIZE一樣 (查看.config文件 CONFIG_PAGE_SIZE_16KB=y).
Question6:
共提示以下幾種錯誤:
Empty flash at 0x00258c88 ends at 0x00258c8c
jffs2_scan_inode_node(): CRC failed on node at 0x002873f0: Read 0x50dc72ec, calculated 0xafbffd1d
jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x002d24ac: 0x000d instead JFFS2 notice: (1) jffs2_build_xattr_subsystem: complete building xattr subsystem, 0 of xdatum (0 unchecked, 0 orphan) and 0 of xref (0 dead, 0 orphan) found. VFS: Mounted root (jffs2 filesystem). Freeing init memory: 124K
JFFS2 notice: (1) check_node_data: wrong data CRC in data node at 0x00012000: read 0x1a9bfab2, calculated 0xdc27bef6.
JFFS2 notice: (728) read_dnode: wrong data CRC in data node at 0x0000e438: read 0x3dcf6001, calculated 0xcb81f1ee.
JFFS2 warning: (1) jffs2_do_read_inode_internal: no data nodes found for ino #14 JFFS2 notice: (1) jffs2_do_read_inode_internal: but it has children so we fake some modes for it
Failed to execute /linuxrc. Attempting defaults...
Kernel panic - not syncing: No init found. Try passing init= option to kernel. 分析:
記得JFFS2是采用自己的ECC算法,但是在內核中又打開了S3C2410_HARDWARE_ECC 解決方案: 去掉硬件ECC
- 前言
- 荔枝派TODO任務領取
- linux使用小貼士
- 入門篇
- 板卡介紹
- 開箱指南
- 燒錄啟動系統
- 聯網方法
- 鏡像使用
- 鏡像說明
- buildroot系統使用
- debian系統使用
- 外設操作
- 外設操作概覽
- 低速外設
- GPIO
- GPIO模擬低速接口
- UART
- PWM
- I2C
- SPI
- 高速接口
- SDIO
- USB
- EtherNet
- DVP CSI
- MIPI CSI
- 模擬外設
- CODEC
- LRADC
- 常見設備驅動
- USB攝像頭
- USB 3G/4G 網卡
- 舵機
- 開發篇
- UBOOT適配
- UBOOT編譯
- UBOOT配置
- UBOOT配置屏幕分辨率
- UBOOT配置SPI啟動
- Linux內核開發
- Linux內核編譯
- BSP Linux內核編譯.md
- Linux內核選項
- 外設驅動與設備樹
- RTL8723BS驅動
- 根文件系統定制
- buildroot定制系統
- buildroot添加軟件包
- openwrt定制系統
- emdebian定制系統
- camdriod開發
- camdriod編譯
- 主線Uboot引導Camdriod
- 系統鏡像打包
- XBOOT適配
- 荔枝運行XBOOT
- 應用篇
- 游戲機-基于EmulationStation
- 游戲機-gnuboy
- 語音識別-科大訊飛云
- GUI-QT5
- 語音識別-離線關鍵詞識別
- 路由器-Lichee Zero
- 投稿文章
- 荔枝派Zero開箱指南
- Zero i2c oled使用指南
- zero SPI LCD使用指南
- Zero u-boot編譯和使用指南
- TF WiFi使用方法
- Zero Ethernet使用指南
- Zero 移植Qt5.4.1
- ZeroSpiNorFlash啟動系統制作指南
- Visio-uboot-sunxi流程
- lichee 編譯踩坑記錄(ilichee ZERO)
- lichee_zero_外設GPIO接口
- TF WIFI 小白編
- 從零開始LicheePi Zero的開發
- 認識Zero的硬件
- 搭建Zero的開發環境
- 主線Uboot
- 主線kernel
- BSP kernel
- BSP內核啟動
- bsp內核的攝像頭使用
- BSP內核中的保留內存
- uboot啟動BSP內核常見錯誤
- BSP內核 FBTFT移植
- BSP內核啟動錯誤及警告解決
- buildroot 根文件系統
- emdebian 根文件系統
- SPI Flash 系統編譯
- sunxi-fel增加對16M 以上flash的支持
- overlayfs的使用
- jffs2系統掛載不上的常見原因
- JFFS2 文件系統簡介
- uboot對spi flash的識別
- bsp內核的SPI flash啟動
- Docker開發環境
- Docker 命令速查
- 基礎ubuntu系統配置
- docker離線鏡像
- Zero系統燒錄
- dd鏡像燒錄
- 分區鏡像燒錄
- SPI Flash系統燒錄
- 一鍵鏡像燒錄
- Zero外設把玩
- I2C操作
- PWM輸出
- CODEC的使用
- 以太網使用指南
- GPIO操作
- 文件IO方式
- C語言接口(mmap)
- Python操作GPIO
- pinctrl-sunxi介紹
- UART操作
- 點屏
- 點屏之RGB屏
- 點屏之SPI屏 ili9341
- 點屏之SPI OLED
- 點屏之I2C OLED
- 點屏之SPI屏 ili9488
- 點屏之MCU屏
- 點屏之觸摸屏驅動
- 點屏之simple-framebuffer
- 點屏之屏幕時序
- 時鐘控制器CCM
- 攝像頭
- BSP DVP攝像頭
- BSP MIPI 攝像頭
- 主線DVP攝像頭
- 主線 MIPI攝像頭
- SPI 操作
- 應用層開發
- 開機自啟動
- Segment Fault調試
- Zero通過OTG共享PC網絡
- USB攝像頭使用
- 基于QT的GUI開發
- 移植tslib
- 移植QT5.9.1
- 移植QT4.8.7
- QtCreator使用
- Qt5.x移植到Qt4.8
- Qt字體相關
- Qt移植總結
- Qt裁剪
- Qt去除鼠標指針顯示
- zero_imager使用
- 驅動開發
- 設備樹簡介
- GPU/DRM 顯示驅動
- sys下設備樹查看
- atmel觸摸屏驅動分析
- atmel觸摸屏中斷改輪詢
- uboot下gpio操作
- helloworld驅動編譯演示
- FBTFT分析
- 內核模塊靜態加載的順序
- SPI驅動分析
- SPI 驅動編寫
- Uboot開發
- 開機logo
- 看門狗的使用
- 關于系統reboot
- 內核printk等級設置