移植UBI文件系统出现UBIFS error (pid 1): ubifs_get_sb: cannot open "/dev/root", error -22

jackxmhu 2015-02-03 04:46:12
最近在整9331平台NOR flash(16MB),由于squashfs是个只读文件系统,现在想更改为UBI可读写根文件系统。

1.UBOOT中的更改squashfs为ubifs:
原:
#define CONFIG_BOOTARGS "console=ttyS0,115200 root=31:02 rootfstype=squashfs init=/sbin/init mtdparts=ar7240-nor0:64k(u-boot),1536k(uImage),14656k(rootfs),64k(NVRAM),64k(ART)"
现:
#define CONFIG_BOOTARGS "console=ttyS0,115200 root=31:02 rootfstype=ubifs init=/sbin/init mtdparts=ar7240-nor0:64k(u-boot),1536k(uImage),14656k(rootfs),64k(NVRAM),64k(ART)"

2.kernel中增加对UBI文件系统的支持:
a.Device Drivers --->Memory Technology Device (MTD) support --->UBI - Unsorted block images --->Enable UBI
b.File systems --->Miscellaneous filesystems --->UBIFS file system support

3.得到NOR flash UBI参数:
ubiattach /dev/ubi_ctrl -m 3
UBI: attaching mtd3 to ubi0
UBI: physical eraseblock size: 65536 bytes (64 KiB)
UBI: logical eraseblock size: 65408 bytes
UBI: smallest flash I/O unit: 1
UBI: VID header offset: 64 (aligned 64)
UBI: data offset: 128
UBI: empty MTD device detected
UBI: create volume table (copy #1)
UBI: create volume table (copy #2)
UBI error: ubi_scan_get_free_peb: no eraseblocks found
UBI error: ubi_attach_mtd_dev: failed to attach by scanning, error -28
ubiattach: error!: cannot attach mtd3
error 28 (No space left on device)

4.制作ubifs格式的根文件系统镜像
a).mkfs.ubifs --root=$(IMAGE_ROOT) -m 1 -e 65408 -c 220 --devtable=$(TOPDIR)/build/scripts/$(BOARD_TYPE)/dev_$(BOARD_TYPE).txt -o ubifs.img
b).ubinize.config内容:
[ubifs]
mode=ubi
image=ubifs.img
vol_id=0
vol_name=rootfs
vol_size=112MiB
vol_type=dynamic
vol_flags=autoresize
vol_alignment=1
c).ubinize -p 64KiB -m 1 -O 64 -o ubi.img ubinize.config

5.下载uboot,kernel,ubi.img到板子中,出现以下错误
U-Boot 1.1.4-g548e981d-dirty (Feb 3 2015 - 14:48:31)

AP121 (ar9331) U-boot

DRAM: 64 MB
Top of RAM usable for U-Boot at: 84000000
Reserving 155k for U-Boot at: 83fd8000
Reserving 192k for malloc() at: 83fa8000
Reserving 44 Bytes for Board Info at: 83fa7fd4
Reserving 36 Bytes for Global Data at: 83fa7fb0
Reserving 128k for boot params() at: 83f87fb0
Stack Pointer at: 83f87f98
Now running in RAM - U-Boot at: 83fd8000
Flash Manuf Id 0xef, DeviceId0 0x40, DeviceId1 0x18
flash size 16777216, sector count = 256
Flash: 16 MB
Using default environment

In: serial
Out: serial
Err: serial
Net: ag7240_enet_initialize...
Fetching MAC Address from 0x83ff2ae8
Fetching MAC Address from 0x83ff2ae8
: cfg1 0x5 cfg2 0x7114
eth0: 00:03:7f:11:4d:c3
eth0 up
: cfg1 0xf cfg2 0x7214
eth1: 00:03:7f:11:4d:c4
athrs26_reg_init_lan
ATHRS26: resetting s26
ATHRS26: s26 reset done
eth1 up
eth0, eth1
Hit any key to stop autoboot: 0
## Booting image at 9f010000 ...
Image Name: Linux Kernel Image
Created: 2015-02-03 6:52:54 UTC
Image Type: MIPS Linux Kernel Image (lzma compressed)
Data Size: 1162184 Bytes = 1.1 MB
Load Address: 80002000
Entry Point: 8026c1d0
Verifying Checksum at 0x9f010040 ...OK
Uncompressing Kernel Image ... OK
No initrd
## Transferring control to Linux (at address 8026c1d0) ...
## Giving linux memsize in bytes, 67108864

Starting kernel ...

Booting AR9330(Hornet)...
CPU 400000000 Hz
AHB 200000000 Hz
DDR 400000000 Hz
Linux version 2.6.31--LSDK-9.2.0_U11.14 (hxm@ubuntu-fw) (gcc version 4.3.3 (GCC) ) #2 Tue Feb 3 14:52:39 CST 2015
flash_size passed from bootloader = 16
arg 1: console=ttyS0,115200
arg 2: root=31:02
arg 3: rootfstype=ubifs
arg 4: init=/sbin/init
arg 5: mtdparts=ar7240-nor0:64k(u-boot),1536k(uImage),14656k(rootfs),64k(NVRAM),64k(ART)
arg 6: mem=64M
CPU revision is: 00019374 (MIPS 24Kc)
Determined physical RAM map:
memory: 02000000 @ 00000000 (usable)
User-defined physical RAM map:
memory: 04000000 @ 00000000 (usable)
Zone PFN ranges:
Normal 0x00000000 -> 0x00004000
Movable zone start PFN for each node
early_node_map[1] active PFN ranges
0: 0x00000000 -> 0x00004000
Built 1 zonelists in Zone order, mobility grouping on. Total pages: 16256
Kernel command line: console=ttyS0,115200 root=31:02 rootfstype=ubifs init=/sbin/init mtdparts=ar7240-nor0:64k(u-boot),1536k(uImage),14656k(rootfs),64k(NVRAM),64k(ART) mem=64M
PID hash table entries: 256 (order: 8, 1024 bytes)
Dentry cache hash table entries: 8192 (order: 3, 32768 bytes)
Inode-cache hash table entries: 4096 (order: 2, 16384 bytes)
Primary instruction cache 64kB, VIPT, 4-way, linesize 32 bytes.
Primary data cache 32kB, 4-way, VIPT, cache aliases, linesize 32 bytes
Writing ErrCtl register=00000000
Readback ErrCtl register=00000000
Memory: 61436k/65536k available (2486k kernel code, 4028k reserved, 714k data, 120k init, 0k highmem)
NR_IRQS:128
plat_time_init: plat time init done
Calibrating delay loop... 266.24 BogoMIPS (lpj=532480)
Mount-cache hash table entries: 512
NET: Registered protocol family 16
===== ar7240_platform_init: 0
bio: create slab <bio-0> at 0
SCSI subsystem initialized
usbcore: registered new interface driver usbfs
usbcore: registered new interface driver hub
usbcore: registered new device driver usb
NET: Registered protocol family 2
IP route cache hash table entries: 1024 (order: 0, 4096 bytes)
TCP established hash table entries: 2048 (order: 2, 16384 bytes)
TCP bind hash table entries: 2048 (order: 1, 8192 bytes)
TCP: Hash tables configured (established 2048 bind 2048)
TCP reno registered
NET: Registered protocol family 1
AR7240 GPIOC major 0
squashfs: version 4.0 (2009/01/31) Phillip Lougher
msgmni has been set to 120
alg: No test for lzma (lzma-generic)
alg: No test for stdrng (krng)
io scheduler noop registered (default)
Serial: 8250/16550 driver, 1 ports, IRQ sharing disabled
ttyS0: detected caps 00000000 should be 00000100
serial8250.0: ttyS0 at MMIO 0xb8020000 (irq = 19) is a 16550A
console [ttyS0] enabled
brd: module loaded
5 cmdlinepart partitions found on MTD device ar7240-nor0
Creating 5 MTD partitions on "ar7240-nor0":
0x000000000000-0x000000010000 : "u-boot"
0x000000010000-0x000000190000 : "uImage"
0x000000190000-0x000000fe0000 : "rootfs"
0x000000fe0000-0x000000ff0000 : "NVRAM"
0x000000ff0000-0x000001000000 : "ART"
usbmon: debugfs is not available
ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
Port Status 1c000004
ar7240-ehci ar7240-ehci.0: ATH EHCI
ar7240-ehci ar7240-ehci.0: new USB bus registered, assigned bus number 1
ehci_reset Intialize USB CONTROLLER in host mode: 3
ehci_reset Port Status 1c000000
ar7240-ehci ar7240-ehci.0: irq 3, io mem 0x1b000000
ehci_reset Intialize USB CONTROLLER in host mode: 3
ehci_reset Port Status 1c000000
ar7240-ehci ar7240-ehci.0: USB 2.0 started, EHCI 1.00
usb usb1: New USB device found, idVendor=1d6b, idProduct=0002
usb usb1: New USB device strings: Mfr=3, Product=2, SerialNumber=1
usb usb1: Product: ATH EHCI
usb usb1: Manufacturer: Linux 2.6.31--LSDK-9.2.0_U11.14 ehci_hcd
usb usb1: SerialNumber: platform
usb usb1: configuration #1 chosen from 1 choice
hub 1-0:1.0: USB hub found
hub 1-0:1.0: 1 port detected
Initializing USB Mass Storage driver...
usbcore: registered new interface driver usb-storage
USB Mass Storage support registered.
usbcore: registered new interface driver usbhid
usbhid: v2.6:USB HID core driver
TCP cubic registered
NET: Registered protocol family 17
RPC: Registered udp transport module.
RPC: Registered tcp transport module.
arch/mips/ar7240/gpio.c (ar7240_simple_config_init) AP_RESET_GPIO: 12
arch/mips/ar7240/gpio.c (ar7240_simple_config_init) JUMPSTART_GPIO: 11

ar7240: reset callback..sc 1, irq 0, ignorepb 0, jiffies 4294892431

ar7240: calling reset callback.. push dur in sec 0

ar7240: reset callback..sc 1, irq 0, ignorepb 1, jiffies 4294892434
ar7240wdt_init: Registering WDT success
input: gpio_misc as /devices/virtual/input/input0
gpio_misc loaded!
UBIFS error (pid 1): ubifs_get_sb: cannot open "/dev/root", error -22
List of all partitions:
1f00 64 mtdblock0 (driver?)
1f01 1536 mtdblock1 (driver?)
1f02 14656 mtdblock2 (driver?)
1f03 64 mtdblock3 (driver?)
1f04 64 mtdblock4 (driver?)
No filesystem could mount root, tried: ubifs
Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(31,2)
...全文
1524 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
hjc1109 2015-02-06
  • 打赏
  • 举报
回复
这样会不会导致mount ubi为只读呢?建议打可读写
jackxmhu 2015-02-06
  • 打赏
  • 举报
回复
vol_size=112MiB更改为vol_size=12MiB
jackxmhu 2015-02-06
  • 打赏
  • 举报
回复
问题解决,更改CONFIG_BOOTARGS,root=ubi0:rootfs,ubi.mtd=2
jackxmhu 2015-02-03
  • 打赏
  • 举报
回复
希望牛人指点一下,多谢

4,436

社区成员

发帖
与我相关
我的任务
社区描述
Linux/Unix社区 内核源代码研究区
社区管理员
  • 内核源代码研究区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧