如标题环境,在使用spi nand flash存储时,如果系统在运行时 发送异常掉电情况,有概率会出现ubifs根目录损坏导致无法开机的情况
启动log如下
U-Boot 2022.04 (Apr 28 2024 - 10:15:08 +0800) Allwinner Technology
CPU: Allwinner V3s (SUN8I 1681)
Model: Lichee Pi Zero
DRAM: 64 MiB
Core: 28 devices, 16 uclasses, devicetree: separate
WDT: Not starting watchdog@1c20ca0
MMC: mmc@1c0f000: 0
Loading Environment from FAT... Card did not respond to voltage select! : -110
In: serial
Out: serial
Err: serial
Net: No ethernet found.
Hit any key to stop autoboot: 0
Reading 131072 byte(s) (64 page(s)) at offset 0x00100000
Reading 5242880 byte(s) (2560 page(s)) at offset 0x00120000
Kernel image @ 0x41000000 [ 0x000000 - 0x446b28 ]
## Flattened Device Tree blob at 41800000
Booting using the fdt blob at 0x41800000
Loading Device Tree to 42df9000, end 42dff47c ... OK
Starting kernel ...
[ 0.000000] Booting Linux on physical CPU 0x0
[ 0.000000] Linux version 5.2.0-licheepi-zero+ (spongebobxd@spongebobxd) (gcc version 9.4.0 (Ubuntu 9.4.0-1ubuntu1~20.04.2)) #67 SMP Thu Apr 25 09:41:29 CST 2024
[ 0.000000] CPU: ARMv7 Processor [410fc075] revision 5 (ARMv7), cr=10c5387d
[ 0.000000] CPU: div instructions available: patching division code
[ 0.000000] CPU: PIPT / VIPT nonaliasing data cache, VIPT aliasing instruction cache
[ 0.000000] OF: fdt: Machine model: Lichee Pi Zero
[ 0.000000] Memory policy: Data cache writealloc
[ 0.000000] cma: Reserved 16 MiB at 0x41c00000
[ 0.000000] psci: probing for conduit method from DT.
[ 0.000000] psci: Using PSCI v0.1 Function IDs from DT
[ 0.000000] percpu: Embedded 16 pages/cpu s34508 r8192 d22836 u65536
[ 0.000000] Built 1 zonelists, mobility grouping on. Total pages: 14986
[ 0.000000] Kernel command line: console=ttyS0,115200 earlyprintk panic=5 rootwait mtdparts=spi0.0:1M(uboot)ro,128k(dtb)ro,5M(kernel)ro,-(rootfs) ubi.mtd=3 root=ubi0:rootfs rw rootflags=sync rootfstype=ubifs
[ 0.000000] Dentry cache hash table entries: 8192 (order: 3, 32768 bytes, linear)
[ 0.000000] Inode-cache hash table entries: 4096 (order: 2, 16384 bytes, linear)
[ 0.000000] mem auto-init: stack:off, heap alloc:off, heap free:off
[ 0.000000] Memory: 32492K/60416K available (7168K kernel code, 311K rwdata, 1784K rodata, 1024K init, 256K bss, 11540K reserved, 16384K cma-reserved, 0K highmem)
[ 0.000000] SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
[ 0.000000] rcu: Hierarchical RCU implementation.
[ 0.000000] rcu: RCU event tracing is enabled.
[ 0.000000] rcu: RCU restricting CPUs from NR_CPUS=8 to nr_cpu_ids=1.
[ 0.000000] rcu: RCU calculated value of scheduler-enlistment delay is 10 jiffies.
[ 0.000000] rcu: Adjusting geometry for rcu_fanout_leaf=16, nr_cpu_ids=1
[ 0.000000] NR_IRQS: 16, nr_irqs: 16, preallocated irqs: 16
[ 0.000000] GIC: GICv2 detected, but range too small and irqchip.gicv2_force_probe not set
[ 0.000000] random: get_random_bytes called from start_kernel+0x2f8/0x498 with crng_init=0
[ 0.000000] arch_timer: cp15 timer(s) running at 24.00MHz (phys).
[ 0.000000] clocksource: arch_sys_counter: mask: 0xffffffffffffff max_cycles: 0x588fe9dc0, max_idle_ns: 440795202592 ns
[ 0.000007] sched_clock: 56 bits at 24MHz, resolution 41ns, wraps every 4398046511097ns
[ 0.000019] Switching to timer-based delay loop, resolution 41ns
[ 0.000226] clocksource: timer: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 79635851949 ns
[ 0.000470] Console: colour dummy device 80x30
[ 0.000526] Calibrating delay loop (skipped), value calculated using timer frequency.. 48.00 BogoMIPS (lpj=240000)
[ 0.000541] pid_max: default: 32768 minimum: 301
[ 0.000697] Mount-cache hash table entries: 1024 (order: 0, 4096 bytes, linear)
[ 0.000712] Mountpoint-cache hash table entries: 1024 (order: 0, 4096 bytes, linear)
[ 0.001517] CPU: Testing write buffer coherency: ok
[ 0.002039] /cpus/cpu@0 missing clock-frequency property
[ 0.002067] CPU0: thread -1, cpu 0, socket 0, mpidr 80000000
[ 0.002884] Setting up static identity map for 0x40100000 - 0x40100060
[ 0.003103] rcu: Hierarchical SRCU implementation.
[ 0.003674] smp: Bringing up secondary CPUs ...
[ 0.003698] smp: Brought up 1 node, 1 CPU
[ 0.003708] SMP: Total of 1 processors activated (48.00 BogoMIPS).
[ 0.003715] CPU: All CPU(s) started in HYP mode.
[ 0.003720] CPU: Virtualization extensions available.
[ 0.004799] devtmpfs: initialized
[ 0.008717] VFP support v0.3: implementor 41 architecture 2 part 30 variant 7 rev 5
[ 0.009036] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 19112604462750000 ns
[ 0.009069] futex hash table entries: 256 (order: 2, 16384 bytes, linear)
[ 0.009878] pinctrl core: initialized pinctrl subsystem
[ 0.011100] NET: Registered protocol family 16
[ 0.012355] DMA: preallocated 256 KiB pool for atomic coherent allocations
[ 0.013706] hw-breakpoint: found 5 (+1 reserved) breakpoint and 4 watchpoint registers.
[ 0.013728] hw-breakpoint: maximum watchpoint size is 8 bytes.
[ 0.043308] SCSI subsystem initialized
[ 0.043472] usbcore: registered new interface driver usbfs
[ 0.043527] usbcore: registered new interface driver hub
[ 0.043653] usbcore: registered new device driver usb
[ 0.043899] mc: Linux media interface: v0.10
[ 0.043942] videodev: Linux video capture interface: v2.00
[ 0.044574] ion_parse_dt_heap_common: id 4 type 4 name cma align 1000
[ 0.045075] Advanced Linux Sound Architecture Driver Initialized.
[ 0.046367] clocksource: Switched to clocksource arch_sys_counter
[ 0.059026] NET: Registered protocol family 2
[ 0.059845] tcp_listen_portaddr_hash hash table entries: 512 (order: 0, 6144 bytes, linear)
[ 0.059883] TCP established hash table entries: 1024 (order: 0, 4096 bytes, linear)
[ 0.059906] TCP bind hash table entries: 1024 (order: 1, 8192 bytes, linear)
[ 0.059929] TCP: Hash tables configured (established 1024 bind 1024)
[ 0.060093] UDP hash table entries: 256 (order: 1, 8192 bytes, linear)
[ 0.060145] UDP-Lite hash table entries: 256 (order: 1, 8192 bytes, linear)
[ 0.060453] NET: Registered protocol family 1
[ 0.062370] Initialise system trusted keyrings
[ 0.062744] workingset: timestamp_bits=30 max_order=14 bucket_order=0
[ 0.105807] Key type asymmetric registered
[ 0.105831] Asymmetric key parser 'x509' registered
[ 0.105943] Block layer SCSI generic (bsg) driver version 0.4 loaded (major 250)
[ 0.105955] io scheduler mq-deadline registered
[ 0.105962] io scheduler kyber registered
[ 0.107226] sun4i-usb-phy 1c19400.phy: Couldn't request ID GPIO
[ 0.111199] sun8i-v3s-pinctrl 1c20800.pinctrl: initialized sunXi PIO driver
[ 0.111694] sun8i-v3s-pinctrl 1c20800.pinctrl: 1c20800.pinctrl supply vcc-pb not found, using dummy regulator
[ 0.112508] pwm-backlight backlight: backlight supply power not found, using dummy regulator
[ 0.184415] Serial: 8250/16550 driver, 8 ports, IRQ sharing disabled
[ 0.187944] printk: console [ttyS0] disabled
[ 0.208258] 1c28000.serial: ttyS0 at MMIO 0x1c28000 (irq = 36, base_baud = 1500000) is a U6_16550A
[ 0.767563] printk: console [ttyS0] enabled
[ 0.772335] sun8i-v3s-pinctrl 1c20800.pinctrl: 1c20800.pinctrl supply vcc-pe not found, using dummy regulator
[ 0.803672] 1c28400.serial: ttyS1 at MMIO 0x1c28400 (irq = 37, base_baud = 1500000) is a U6_16550A
[ 0.834435] 1c28800.serial: ttyS2 at MMIO 0x1c28800 (irq = 38, base_baud = 1500000) is a U6_16550A
[ 0.870628] panel-simple panel: panel supply power not found, using dummy regulator
[ 0.880272] sun8i-v3s-pinctrl 1c20800.pinctrl: 1c20800.pinctrl supply vcc-pc not found, using dummy regulator
[ 0.891772] spi-nand spi0.0: Winbond SPI NAND was found.
[ 0.897185] spi-nand spi0.0: 128 MiB, block size: 128 KiB, page size: 2048, OOB size: 64
[ 0.906039] 4 fixed-partitions partitions found on MTD device spi0.0
[ 0.912496] Creating 4 MTD partitions on "spi0.0":
[ 0.917336] 0x000000000000-0x000000100000 : "uboot"
[ 0.925195] 0x000000100000-0x000000120000 : "dtb"
[ 0.931143] 0x000000120000-0x000000620000 : "kernel"
[ 0.937685] random: fast init done
[ 0.950995] 0x000000620000-0x000008000000 : "rootfs"
[ 1.124862] random: crng init done
[ 1.210355] ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
[ 1.216968] ehci-platform: EHCI generic platform driver
[ 1.222538] ehci-platform 1c1a000.usb: EHCI Host Controller
[ 1.228217] ehci-platform 1c1a000.usb: new USB bus registered, assigned bus number 1
[ 1.236308] ehci-platform 1c1a000.usb: irq 28, io mem 0x01c1a000
[ 1.266380] ehci-platform 1c1a000.usb: USB 2.0 started, EHCI 1.00
[ 1.273588] hub 1-0:1.0: USB hub found
[ 1.277590] hub 1-0:1.0: 1 port detected
[ 1.282236] ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver
[ 1.288567] ohci-platform: OHCI generic platform driver
[ 1.294145] ohci-platform 1c1a400.usb: Generic Platform OHCI controller
[ 1.300879] ohci-platform 1c1a400.usb: new USB bus registered, assigned bus number 2
[ 1.308983] ohci-platform 1c1a400.usb: irq 29, io mem 0x01c1a400
[ 1.381433] hub 2-0:1.0: USB hub found
[ 1.385276] hub 2-0:1.0: 1 port detected
[ 1.392617] usbcore: registered new interface driver usb-storage
[ 1.400394] sun6i-rtc 1c20400.rtc: registered as rtc0
[ 1.405460] sun6i-rtc 1c20400.rtc: RTC enabled
[ 1.410215] i2c /dev entries driver
[ 1.415150] input: ns2009_ts as /devices/platform/soc/1c2ac00.i2c/i2c-0/0-0048/input/input0
[ 1.424885] sunxi-wdt 1c20ca0.watchdog: Watchdog enabled (timeout=16 sec, nowayout=0)
[ 1.433731] sun8i-v3s-pinctrl 1c20800.pinctrl: 1c20800.pinctrl supply vcc-pf not found, using dummy regulator
[ 1.469005] sunxi-mmc 1c0f000.mmc: initialized, max. request size: 16384 KB
[ 1.476261] sun8i-v3s-pinctrl 1c20800.pinctrl: 1c20800.pinctrl supply vcc-pg not found, using dummy regulator
[ 1.513086] sunxi-mmc 1c10000.mmc: initialized, max. request size: 16384 KB
[ 1.520668] sun8i-v3s-pinctrl 1c20800.pinctrl: pin PG1 already requested by 1c10000.mmc; cannot claim for 1c20800.pinctrl:193
[ 1.532060] sun8i-v3s-pinctrl 1c20800.pinctrl: pin-193 (1c20800.pinctrl:193) status -22
[ 1.540115] leds-gpio: probe of leds failed with error -22
[ 1.546546] usbcore: registered new interface driver usbhid
[ 1.552120] usbhid: USB HID core driver
[ 1.556096] sunxi-cedar 1c0e000.video-codec: sunxi cedar version 0.01alpha
[ 1.563254] sunxi-cedar 1c0e000.video-codec: cedar-ve the get irq is 22
[ 1.573052] Initializing XFRM netlink socket
[ 1.577498] NET: Registered protocol family 17
[ 1.582625] Registering SWP/SWPB emulation handler
[ 1.588697] Loading compiled-in X.509 certificates
[ 1.601416] simple-framebuffer 43b00000.framebuffer: framebuffer at 0x43b00000, 0x7f800 bytes, mapped to 0xdec4ed25
[ 1.611981] simple-framebuffer 43b00000.framebuffer: format=x8r8g8b8, mode=480x272x32, linelength=1920
[ 1.621637] sunxi-mmc 1c10000.mmc: card claims to support voltages below defined range
[ 1.632149] Console: switching to colour frame buffer device 60x34
[ 1.640766] simple-framebuffer 43b00000.framebuffer: fb0: simplefb registered!
[ 1.651705] sun4i-drm display-engine: bound 1100000.mixer (ops 0xc0848d50)
[ 1.659343] sun4i-drm display-engine: bound 1c0c000.lcd-controller (ops 0xc0846048)
[ 1.667083] [drm] Supports vblank timestamp caching Rev 2 (21.10.2013).
[ 1.673693] [drm] No driver support for vblank timestamp query.
[ 1.679644] fb0: switching to sun4i-drm-fb from simple
[ 1.685613] Console: switching to colour dummy device 80x30
[ 1.692337] [drm] Initialized sun4i-drm 1.0.0 20150629 for display-engine on minor 0
[ 1.709994] mmc1: new high speed SDIO card at address 0001
[ 1.734517] Console: switching to colour frame buffer device 60x34
[ 1.762573] sun4i-drm display-engine: fb0: sun4i-drmdrmfb frame buffer device
[ 1.770629] usb_phy_generic usb_phy_generic.0.auto: usb_phy_generic.0.auto supply vcc not found, using dummy regulator
[ 1.782173] musb-hdrc musb-hdrc.1.auto: MUSB HDRC host driver
[ 1.788028] musb-hdrc musb-hdrc.1.auto: new USB bus registered, assigned bus number 3
[ 1.797169] hub 3-0:1.0: USB hub found
[ 1.801012] hub 3-0:1.0: 1 port detected
[ 1.806433] ubi0: attaching mtd3
[ 2.954151] ubi0: scanning is finished
[ 2.973646] ubi0: attached mtd3 (name "rootfs", size 121 MiB)
[ 2.979494] ubi0: PEB size: 131072 bytes (128 KiB), LEB size: 126976 bytes
[ 2.986389] ubi0: min./max. I/O unit sizes: 2048/2048, sub-page size 2048
[ 2.993206] ubi0: VID header offset: 2048 (aligned 2048), data offset: 4096
[ 3.000184] ubi0: good PEBs: 975, bad PEBs: 0, corrupted PEBs: 0
[ 3.006195] ubi0: user volume: 1, internal volumes: 1, max. volumes count: 128
[ 3.013429] ubi0: max/mean erase counter: 5/2, WL threshold: 4096, image sequence number: 1333395715
[ 3.022572] ubi0: available PEBs: 0, total reserved PEBs: 975, PEBs reserved for bad PEB handling: 20
[ 3.031867] sun6i-rtc 1c20400.rtc: setting system clock to 1970-01-01T00:00:22 UTC (22)
[ 3.040198] vcc3v0: disabling
[ 3.043180] vcc5v0: disabling
[ 3.046144] ALSA device list:
[ 3.049222] No soundcards found.
[ 3.053199] ubi0: background thread "ubi_bgt0d" started, PID 94
[ 3.059757] UBIFS: parse sync
[ 3.064518] UBIFS (ubi0:0): Mounting in unauthenticated mode
[ 3.072849] UBIFS (ubi0:0): background thread "ubifs_bgt0_0" started, PID 95
[ 3.151460] UBIFS (ubi0:0): recovery needed
[ 5.082065] UBIFS (ubi0:0): background thread "ubifs_bgt0_0" stops
[ 5.088886] VFS: Cannot open root device "ubi0:rootfs" or unknown-block(0,0): error -2
[ 5.096898] Please append a correct "root=" boot option; here are the available partitions:
[ 5.105288] Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(0,0)
[ 5.113547] CPU: 0 PID: 1 Comm: swapper/0 Not tainted 5.2.0-licheepi-zero+ #67
[ 5.120758] Hardware name: Allwinner sun8i Family
[ 5.125493] [<c010ee18>] (unwind_backtrace) from [<c010b638>] (show_stack+0x10/0x14)
[ 5.133235] [<c010b638>] (show_stack) from [<c0728af0>] (dump_stack+0x84/0x98)
[ 5.140455] [<c0728af0>] (dump_stack) from [<c011df10>] (panic+0x110/0x2fc)
[ 5.147418] [<c011df10>] (panic) from [<c0a013ac>] (mount_block_root+0x250/0x304)
[ 5.154898] [<c0a013ac>] (mount_block_root) from [<c0a01584>] (prepare_namespace+0x9c/0x198)
[ 5.163328] [<c0a01584>] (prepare_namespace) from [<c073f140>] (kernel_init+0x8/0x110)
[ 5.171239] [<c073f140>] (kernel_init) from [<c01010e8>] (ret_from_fork+0x14/0x2c)
[ 5.178797] Exception stack(0xc3435fb0 to 0xc3435ff8)
[ 5.183844] 5fa0: 00000000 00000000 00000000 00000000
[ 5.192013] 5fc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[ 5.200180] 5fe0: 00000000 00000000 00000000 00000000 00000013 00000000
[ 5.206801] Rebooting in 5 seconds..
主要问题点在以下这段
[ 3.053199] ubi0: background thread "ubi_bgt0d" started, PID 94
[ 3.059757] UBIFS: parse sync
[ 3.064518] UBIFS (ubi0:0): Mounting in unauthenticated mode
[ 3.072849] UBIFS (ubi0:0): background thread "ubifs_bgt0_0" started, PID 95
[ 3.151460] UBIFS (ubi0:0): recovery needed
[ 5.082065] UBIFS (ubi0:0): background thread "ubifs_bgt0_0" stops
[ 5.088886] VFS: Cannot open root device "ubi0:rootfs" or unknown-block(0,0): error -2
[ 5.096898] Please append a correct "root=" boot option; here are the available partitions:
[ 5.105288] Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(0,0)
[ 5.113547] CPU: 0 PID: 1 Comm: swapper/0 Not tainted 5.2.0-licheepi-zero+ #67
[ 5.120758] Hardware name: Allwinner sun8i Family
[ 5.125493] [<c010ee18>] (unwind_backtrace) from [<c010b638>] (show_stack+0x10/0x14)
[ 5.133235] [<c010b638>] (show_stack) from [<c0728af0>] (dump_stack+0x84/0x98)
[ 5.140455] [<c0728af0>] (dump_stack) from [<c011df10>] (panic+0x110/0x2fc)
[ 5.147418] [<c011df10>] (panic) from [<c0a013ac>] (mount_block_root+0x250/0x304)
[ 5.154898] [<c0a013ac>] (mount_block_root) from [<c0a01584>] (prepare_namespace+0x9c/0x198)
[ 5.163328] [<c0a01584>] (prepare_namespace) from [<c073f140>] (kernel_init+0x8/0x110)
[ 5.171239] [<c073f140>] (kernel_init) from [<c01010e8>] (ret_from_fork+0x14/0x2c)
[ 5.178797] Exception stack(0xc3435fb0 to 0xc3435ff8)
[ 5.183844] 5fa0: 00000000 00000000 00000000 00000000
[ 5.192013] 5fc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[ 5.200180] 5fe0: 00000000 00000000 00000000 00000000 00000013 00000000
[ 5.206801] Rebooting in 5 seconds..
内核的bootargs:
bootargs = "console=ttyS0,115200 earlyprintk panic=5 rootwait mtdparts=spi0.0:1M(uboot)ro,128k(dtb)ro,5M(kernel)ro,-(rootfs) ubi.mtd=3 root=ubi0:rootfs rw rootflags=sync rootfstype=ubifs";
之前没有加入rootflags=sync ,尝试以sync挂载ubifs还是会出现这种情况,一般在异常掉电时才有概率出现,必须重新烧录才能恢复
离线
基本没啥好办法,只能重刷
离线
基本没啥好办法,只能重刷
没办法解决嘛,他好频繁出现,也不知道有没有什么补丁
虽然ubifs系统本身对掉电容忍度很差,但这也太差了
每次重刷buildroot又要个五六分钟
离线
划两个ubifs分区,root只读,会改动的放另外一个里
离线
划两个ubifs分区,root只读,会改动的放另外一个里
感谢大佬的建议
具体是将整个根目录只读嘛?这样会不会影响wifi或者一些别的操作?
离线
4610 说:划两个ubifs分区,root只读,会改动的放另外一个里
感谢大佬的建议
具体是将整个根目录只读嘛?这样会不会影响wifi或者一些别的操作?
看具体业务 一般没影响
要修改的文件特别杂可以再套层overlayfs
最近编辑记录 4610 (2024-05-08 16:45:15)
离线
@4610
感谢大佬
想问一下第二个分区是否也是挂载成ubi卷呢?如果是两个分区都挂载成ubi卷,那第二个分区如果损坏了 是否也会影响到开机。
我的理解是弄两个ubi卷 然后第二个分区是data,我尝试了一下 ,如果把第二个分区也以ubi卷的方式去挂载,我没有烧录那个分区的数据 他也是启动不起来
不知道我理解的对不对 大佬可以详细讲一下嘛
离线
@SpongeBobxD
不同mtd分区,data区不放fstab里,启动脚本里命令挂载
至于是预烧录个空的ubi卷还是ubiformat ubimkvol自动格式化就无所谓了
最近编辑记录 4610 (2024-05-08 19:33:08)
离线
这个方法应该有效果,有空试试
离线
感谢@4610大佬的解答
目前进度 成功将rootfs分区挂载成只读 新建立一个可读写分区用于修改和存放文件。
目前测试wifi、dropbear都没有问题
由于根目录只读,dropbear无法创建密钥,需要链接一个路径到/etc/dropbear才能正常使用
再看看是否还会出现异常掉电系统损坏情况
再次感谢@4610大佬的解答
离线
楼主,我们也碰到同样问题了,断电重启有概率会卡在kernel,进不去系统,现在知道的问题是kernel的文件好像坏了,但是不知道为什么,比如断电上电10次可能出现2-3次
离线
楼主,我们也碰到同样问题了,断电重启有概率会卡在kernel,进不去系统,现在知道的问题是kernel的文件好像坏了,但是不知道为什么,比如断电上电10次可能出现2-3次
kernel的zImage和dtb一般都是只读的 如果是kerenl损坏了可以检查一下是不是你的mtd分区没有设置只读 和 bootargs 是不是ro 而不是rw
如果设置了 可能就不是kernel损坏 可以试试只重新烧录buildroot可不可以恢复 可以的话 那就是跟我的问题一样 建议是再加一个data分区 rootfs设置只读
这样如果损坏了也不会导致无法开机
但是经过我的后续测试 data分区也有概率损坏 然后好像是因为dropbear的原因 把dropbear关了 就没怎么遇到过了
离线