您尚未登录。

楼主 #1 2019-10-11 16:22:55

Rikka0w0
会员
注册时间: 2019-10-08
已发帖子: 8
积分: 8

为F1C100S的SPI Flash制作SquashFS+JFFS2+OverlayFS的rootfs来增大可读写空间

荔枝派标配的是16MB的W25Q128 SPI Flash,在放入荔枝派官方的uboot 内核 rootfs的情况下,可用空间一般不超过1MB。
其实仔细观察一下还是有很多可以调整的空间的。

SquashFS可以对rootfs进行压缩,但是rootfs会变成只读的。可以使用OverlayFS将只读分区和可写分区合并,这样的rootfs优先使用SquashFS里的数据并且会把更改储存到JFFS2分区里面。只要运行时没有过多修改SquashFS里的数据,那这种方案节省的空间还是很多的。大名鼎鼎的OpenWRT既是采用了这种解决方案从而能在8MB Flash的路由器上运行的。这种方案运行时修改来自SquashFS的文件时,那个文件并不会动,而是会在JFFS2里储存修改后的文件,这样会有一个文件的两个版本,OverlayFS优先使用JFFS2里的版本,但是这样会造成两个版本同时存在,反而浪费空间,但是这也没办法。有得有失嘛。

这个是我的SPI Flash的结构:

Partition	Content		Offset		Size (byte)
mtd0		uboot-bin		0			0x58000 (360448 Byte)
		uboot-env		0x58000		0x8000
mtd1		dtb			0x60000		0x4000  (16kB)
mtd2		kernel		0x64000		0x400000 (4MB)
mtd3		rootfs		0x464000		0x4FC000 (4.98MB)
mtd4		overlay		0x960000		0x500000 (5MB)

相比官方的镜像,多了一个mtd4分区,就是用于储存运行时对rootfs修改的地方。注意这个mtd4的起始地址和大小必须是擦除区块大小的整数倍,不然无法写!我用的W25Q128这个数字是0x10000(64kB)。

首先是降低uboot的空间占用, https://whycan.cn/t_2179.html 里提到了uboot本体只有270kb,我看了下,确实是这样,我的u-boot.bin是268kb。
于是激进一点,把Environment Offset从0x100000调成了0x58000,这样Uboot部分分400kB就可以了,比原版的1MB小太多了。
话说回来Uboot一般也不会在之后加太多东西了,最多变变启动参数什么的,本体大小变化不大,这个应该是安全的。
具体的Uboot配置需要在`make ARCH=arm menuconfig`里修改,一共有三处:

# [ *] Enable boot arguments
   = console=ttyS0,115200 panic=5 rootwait root=/dev/mtdblock3 rw rootfstype=squashfs init=/etc/preinit
# [ *] Enable a default value for bootcmd
   = sf probe 0 50000000; sf read 0x80C00000 0x60000 0x4000; sf read 0x80008000 0x64000 0x400000; bootz 0x80008000 - 0x80C00000
# Environment -> Environment Offset = 0x58000

分别是:

1. 指定Linux的启动参数,要点是rootfstype=squashfs init=/etc/preinit这部分,之后会说。
2. 告诉UBoot如何把dtb和内核zImage从SPI Flash装载到内存里,这部分的SPI Flash地址要和上面的表对应。
3. 修改UBoot环境变量储存区的开始位置,减小空间浪费。

UBoot不需要修改c或者h文件。




然后是修改Linux内核的配置,同样还是`make ARCH=arm menuconfig`:

<*> Overlay filesystem support
[ *] Miscellaneous filesystems  --->
--><*>   Journalling Flash File System v2 (JFFS2) support
--><*>   SquashFS 4.0 - Squashed file system support

Device Drivers:

<*> Memory Technology Device (MTD) support  --->
--><*>   Caching block device access to MTD devices

[ *] SPI support  --->
-->< >   Allwinner A10 SoCs SPI controller
--><*>   Allwinner A31 SPI controller

分别是启用了OverlayFS、JFFS2、SquashFS文件系统的支持,
启动MTD设备的缓存(这样才能用SPI Flash上启动)
然后就是修正原版.config里SPI控制器选错了的问题。

还有需要修改dts文件(arch/arm/boot/dts/suniv-f1c100s-licheepi-nano.dts):

    flash: w25q128@0 {
        #address-cells = <1>;
        #size-cells = <1>;
        compatible = "winbond,w25q128", "jedec,spi-nor";
        reg = <0>;
        spi-max-frequency = <50000000>;
        partitions {
            compatible = "fixed-partitions";
            #address-cells = <1>;
            #size-cells = <1>;

            partition@0 {
                label = "u-boot";
                reg = <0x000000 0x58000>;
                read-only;
            };

            partition@60000 {
                label = "dtb";
                reg = <0x60000 0x4000>;
                read-only;
            };

            partition@64000 {
                label = "kernel";
                reg = <0x64000 0x400000>;
                read-only;
            };

            partition@464000 {
                label = "rootfs";
                reg = <0x464000 0x4FC000>;
                read-only;
            };

            partition@960000 {
                label = "overlayfs";
                reg = <0x960000 0x500000>;
            };

        };
    };

   

这里面的分区开始位置和大小要和uboot启动参数还有最上面的表对应才行。
到此为止uboot和Linux内核就修改好了。现在可以对u-boot和linux分别使用:
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- -j4

然后是编译linux的内核模块:

make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- -j4 INSTALL_MOD_PATH=out modules
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- -j4 INSTALL_MOD_PATH=out modules_install

现在可以开始制作rootfs了。首先是制作SquashFS部分,这部分是基于原版的Rootfs的。
1. 释放原来的rootfs到一个文件夹:

mkdir rootfs_new
cd rootfs_new
tar xvpzf ../rootfs.tar.gz

2. 把新编译的内核模块放进去
3. 创建映射文件夹

mkdir rootfs_new/overlay
mkdir rootfs_new/chroot
mkdir rootfs_new/rom

4. 建立一个启动脚本`rootfs_new/etc/preinit`:

#!/bin/sh

# export PATH="/usr/sbin:/usr/bin:/sbin:/bin"

# mount the new rootfs
mount -t squashfs /dev/mtdblock3 /rom
mount -t jffs2 /dev/mtdblock4 /overlay
mount -n -t overlay overlayfs:/overlay -o lowerdir=/rom,upperdir=/overlay/rw,workdir=/overlay/work /chroot

# mount /dev and /sys for chroot environment
# /dev/pts, /dev/shm, /proc, /tmp and /run will be mounted by inittab from fstab
mount -t sysfs sysfs /sys
mount --rbind /sys /chroot/sys/
mount --rbind /dev /chroot/dev/


exec chroot /chroot /sbin/init

启动参数里的init=/etc/preinit就是指这个脚本。根据Linux文档,init=这个参数会替换原本的/sbin/init被执行。
咱们的preinit首先会挂载只读分区SquashFS和可写分区JFFS2,再在/chroot文件夹中创建overlay,
然后在新的rootfs里挂在/dev和/sys,最后执行chroot并在新的root环境下执行/sbin/init,
回归系统正常的启动程序,只不过是在新的rootfs下。这样之后的程序都不会察觉rootfs发生了变化。使用如下命令打包SquashFS:
mksquashfs rootfs_new/ rootfs_new.img -no-exports -no-xattrs -all-root

最后一步是制作JFFS2的镜像:

mkdir -p overlay/work
mkdir -p overlay/rw
mkfs.jffs2 -s 0x100 -e 0x10000 --pad=0x500000 -o jffs2.img -d overlay/

work文件夹是OverlayFS需要的一个空文件夹,rw是储存增量修改的地方。



烧写入SPI Flash, 注意地址别写错:

# uboot
sudo sunxi-fel -p spiflash-write 0 u-boot/u-boot-sunxi-with-spl.bin
# dtb
sudo sunxi-fel -p spiflash-write 0x60000 linux/arch/arm/boot/dts/suniv-f1c100s-licheepi-nano.dtb
# kernel
sudo sunxi-fel -p spiflash-write 0x64000 linux/arch/arm/boot/zImage
# squashfs
sudo sunxi-fel -p spiflash-write 0x464000 rootfs_new.img
# jffs2
sudo sunxi-fel -p spiflash-write 0x960000 jffs2.img

推荐阅读:
https://gist.github.com/rikka0w0/f56977f81d1228fc503b00ad7b526aa7
https://gist.github.com/rikka0w0/e04eee5fa623b37866ded805c855f287
https://whycan.cn/t_2179_2.html
https://www.kernel.org/doc/Documentation/filesystems/overlayfs.txt

离线

#2 2019-10-11 16:48:05

晕哥
管理员
注册时间: 2017-09-06
已发帖子: 9,349
积分: 9202

Re: 为F1C100S的SPI Flash制作SquashFS+JFFS2+OverlayFS的rootfs来增大可读写空间

感谢楼主分享,前排围观学习!





离线

#3 2019-10-11 18:35:18

msr06rr
会员
所在地: 苏州
注册时间: 2018-01-11
已发帖子: 180
积分: 170.5

Re: 为F1C100S的SPI Flash制作SquashFS+JFFS2+OverlayFS的rootfs来增大可读写空间

这个很干货

离线

#4 2019-10-11 18:52:56

jiangming1399
会员
注册时间: 2018-06-14
已发帖子: 113
积分: 113

Re: 为F1C100S的SPI Flash制作SquashFS+JFFS2+OverlayFS的rootfs来增大可读写空间

是rikka!

之前卡在了preinit的脚本的编写上,感谢分享

离线

#5 2019-10-11 19:01:35

pythinker
会员
注册时间: 2019-02-12
已发帖子: 215
积分: 215

Re: 为F1C100S的SPI Flash制作SquashFS+JFFS2+OverlayFS的rootfs来增大可读写空间

干货, 打卡学习

离线

#6 2019-10-11 23:05:50

zzm24
会员
注册时间: 2018-05-07
已发帖子: 120
积分: 107

Re: 为F1C100S的SPI Flash制作SquashFS+JFFS2+OverlayFS的rootfs来增大可读写空间

打卡学习

离线

#7 2019-10-22 11:23:22

pans203
会员
注册时间: 2019-09-19
已发帖子: 5
积分: 0

Re: 为F1C100S的SPI Flash制作SquashFS+JFFS2+OverlayFS的rootfs来增大可读写空间

请问下
做overlayfs的时候加载的时候提示

[    1.532950] random: crng init done
[    1.968507] overlayfs: upper fs does not support tmpfile.
[    1.974024] overlayfs: upper fs does not support xattr, falling back to index=off and metacopy=off.
Starting syslogd: OK
Starting klogd: OK
Running sysctl: OK
read-only file system detected...done
Starting nginx...
Starting redis: OK
ssh-keygen: generating new host keys: RSA Could not save your public key in /etc/ssh/ssh_host_rsa_key.WUUwzuCq4Z: Read-only file system
ssh-keygen: generating new host keys: DSA Could not save your public key in /etc/ssh/ssh_host_dsa_key.gzfYBUwEuO: Read-only file system
ssh-keygen: generating new host keys: ECDSA Could not save your public key in /etc/ssh/ssh_host_ecdsa_key.NhHCDssYbw: Read-only file system
ssh-keygen: generating new host keys: ED25519 Could not save your public key in /etc/ssh/ssh_host_ed25519_key.3gaphbfyLB: Read-only file system
Starting sshd: Unable to load host key: /overlay/ssh/ssh_host_rsa_key
Unable to load host key: /overlay/ssh/ssh_host_ecdsa_key
Unable to load host key: /overlay/ssh/ssh_host_ed25519_key
sshd: no hostkeys available -- exiting.
OK

mount指令我加到/etc/inittab中了

# Startup the system
::sysinit:/bin/mount -t proc proc /proc
::sysinit:/bin/mount -o remount,rw /
::sysinit:/bin/mkdir -p /dev/pts /dev/shm
::sysinit:/bin/mount -a
::sysinit:/sbin/swapon -a
null::sysinit:/bin/ln -sf /proc/self/fd /dev/fd
null::sysinit:/bin/ln -sf /proc/self/fd/0 /dev/stdin
null::sysinit:/bin/ln -sf /proc/self/fd/1 /dev/stdout
null::sysinit:/bin/ln -sf /proc/self/fd/2 /dev/stderr
::sysinit:/bin/hostname -F /etc/hostname

::sysinit:mount -n -t jffs2 /dev/mtdblock4  /overlay
::sysinit:mount -n -t overlay overlayfs:/overlay -o lowerdir=/,upperdir=/overlay/upperdir,workdir=/overlay/workdir /merged/
#::sysinit:pivot_root /merged /merged/rom


# now run any rc scripts
::sysinit:/etc/init.d/rcS

ssh报错readonly问下有什么解决方法么

离线

#8 2019-11-18 17:20:28

qianhao
会员
注册时间: 2017-12-14
已发帖子: 138
积分: 122

Re: 为F1C100S的SPI Flash制作SquashFS+JFFS2+OverlayFS的rootfs来增大可读写空间

干货 需要收藏

离线

#9 2019-11-19 08:13:51

qter
会员
注册时间: 2017-09-14
已发帖子: 40
积分: 40

Re: 为F1C100S的SPI Flash制作SquashFS+JFFS2+OverlayFS的rootfs来增大可读写空间

好贴, 赶脚相见恨晚。

离线

#10 2020-05-04 13:14:18

tianjjff
会员
注册时间: 2018-12-24
已发帖子: 129
积分: 22

Re: 为F1C100S的SPI Flash制作SquashFS+JFFS2+OverlayFS的rootfs来增大可读写空间

好帖,收藏下

离线

#11 2020-05-07 14:45:26

流氓兔
会员
注册时间: 2020-02-01
已发帖子: 121
积分: 109.5

Re: 为F1C100S的SPI Flash制作SquashFS+JFFS2+OverlayFS的rootfs来增大可读写空间

楼主全干货,正在筹划 squashfs + overlay 跑 Qt

离线

#12 2020-05-27 21:36:25

xiaowuOK
会员
注册时间: 2020-05-27
已发帖子: 5
积分: 5

Re: 为F1C100S的SPI Flash制作SquashFS+JFFS2+OverlayFS的rootfs来增大可读写空间

好贴,学习打卡

离线

#13 2020-06-14 14:35:00

billnie
会员
注册时间: 2018-11-13
已发帖子: 47
积分: 37

Re: 为F1C100S的SPI Flash制作SquashFS+JFFS2+OverlayFS的rootfs来增大可读写空间

Starting kernel ...

[    0.000000] Booting Linux on physical CPU 0x0
[    0.000000] Linux version 5.2.0-licheepi-nano+ (billnie@ubuntu) (gcc version 7.4.1 20181213 [linaro-7.4-2019.02 revision 56ec6f6b99cc167ff0c2f8e1a2eed33b1edc85d4] (Linaro GCC 7.4-2019.02)) #14 Sat Jun 13 23:07:29 PDT 2020
[    0.000000] CPU: ARM926EJ-S [41069265] revision 5 (ARMv5TEJ), cr=0005317f
[    0.000000] CPU: VIVT data cache, VIVT instruction cache
[    0.000000] OF: fdt: Machine model: Lichee Pi Nano
[    0.000000] Memory policy: Data cache writeback
[    0.000000] Built 1 zonelists, mobility grouping on.  Total pages: 16256
[    0.000000] Kernel command line: console=ttyS0,115200 panic=5 rootwait root=/dev/mtdblock3 rw rootfstype=squashfs  init=/etc/preinit
[    0.000000] Dentry cache hash table entries: 8192 (order: 3, 32768 bytes)
[    0.000000] Inode-cache hash table entries: 4096 (order: 2, 16384 bytes)
[    0.000000] Memory: 55188K/65536K available (6144K kernel code, 235K rwdata, 1508K rodata, 1024K init, 231K bss, 10348K reserved, 0K cma-reserved, 0K highmem)
[    0.000000] SLUB: HWalign=32, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
[    0.000000] NR_IRQS: 16, nr_irqs: 16, preallocated irqs: 16
[    0.000000] random: get_random_bytes called from start_kernel+0x254/0x42c with crng_init=0
[    0.000045] sched_clock: 32 bits at 24MHz, resolution 41ns, wraps every 89478484971ns
[    0.000121] clocksource: timer: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 79635851949 ns
[    0.000635] Console: colour dummy device 80x30
[    0.000726] Calibrating delay loop... 203.16 BogoMIPS (lpj=1015808)
[    0.070235] pid_max: default: 32768 minimum: 301
[    0.070655] Mount-cache hash table entries: 1024 (order: 0, 4096 bytes)
[    0.070694] Mountpoint-cache hash table entries: 1024 (order: 0, 4096 bytes)
[    0.072296] CPU: Testing write buffer coherency: ok
[    0.074155] Setting up static identity map for 0x80100000 - 0x80100058
[    0.076349] devtmpfs: initialized
[    0.082626] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 19112604462750000 ns
[    0.082684] futex hash table entries: 256 (order: -1, 3072 bytes)
[    0.082968] pinctrl core: initialized pinctrl subsystem
[    0.084900] NET: Registered protocol family 16
[    0.086344] DMA: preallocated 256 KiB pool for atomic coherent allocations
[    0.088341] cpuidle: using governor menu
[    0.137286] SCSI subsystem initialized
[    0.137666] usbcore: registered new interface driver usbfs
[    0.137844] usbcore: registered new interface driver hub
[    0.138025] usbcore: registered new device driver usb
[    0.138455] pps_core: LinuxPPS API ver. 1 registered
[    0.138479] pps_core: Software ver. 5.3.6 - Copyright 2005-2007 Rodolfo Giometti <giometti@linux.it>
[    0.138976] Advanced Linux Sound Architecture Driver Initialized.
[    0.140740] clocksource: Switched to clocksource timer
[    0.169594] NET: Registered protocol family 2
[    0.171225] tcp_listen_portaddr_hash hash table entries: 512 (order: 0, 4096 bytes)
[    0.171301] TCP established hash table entries: 1024 (order: 0, 4096 bytes)
[    0.171365] TCP bind hash table entries: 1024 (order: 0, 4096 bytes)
[    0.171413] TCP: Hash tables configured (established 1024 bind 1024)
[    0.171689] UDP hash table entries: 256 (order: 0, 4096 bytes)
[    0.171748] UDP-Lite hash table entries: 256 (order: 0, 4096 bytes)
[    0.172234] NET: Registered protocol family 1
[    0.174780] NetWinder Floating Point Emulator V0.97 (double precision)
[    0.176754] Initialise system trusted keyrings
[    0.177279] workingset: timestamp_bits=30 max_order=14 bucket_order=0
[    0.197541] squashfs: version 4.0 (2009/01/31) Phillip Lougher
[    0.198108] jffs2: version 2.2. (NAND) 漏 2001-2006 Red Hat, Inc.
[    0.205742] Key type asymmetric registered
[    0.205781] Asymmetric key parser 'x509' registered
[    0.205955] Block layer SCSI generic (bsg) driver version 0.4 loaded (major 252)
[    0.205979] io scheduler mq-deadline registered
[    0.205996] io scheduler kyber registered
[    0.218248] suniv-f1c100s-pinctrl 1c20800.pinctrl: initialized sunXi PIO driver
[    0.228488] Serial: 8250/16550 driver, 8 ports, IRQ sharing disabled
[    0.234111] suniv-f1c100s-pinctrl 1c20800.pinctrl: 1c20800.pinctrl supply vcc-pe not found, using dummy regulator
[    0.235367] printk: console [ttyS0] disabled
[    0.255617] 1c25000.serial: ttyS0 at MMIO 0x1c25000 (irq = 23, base_baud = 6250000) is a 16550A
[    0.648534] printk: console [ttyS0] enabled
[    0.675027] 1c25800.serial: ttyS2 at MMIO 0x1c25800 (irq = 24, base_baud = 6250000) is a 16550A
[    0.687689] suniv-f1c100s-pinctrl 1c20800.pinctrl: 1c20800.pinctrl supply vcc-pd not found, using dummy regulator
[    0.713345] brd: module loaded
[    0.736069] loop: module loaded
[    0.740021] SCSI Media Changer driver v0.25 
[    0.745914] suniv-f1c100s-pinctrl 1c20800.pinctrl: 1c20800.pinctrl supply vcc-pc not found, using dummy regulator
[    0.758773] m25p80 spi0.0: w25q128 (16384 Kbytes)
[    0.763687] 5 fixed-partitions partitions found on MTD device spi0.0
[    0.770035] Creating 5 MTD partitions on "spi0.0":
[    0.774907] 0x000000000000-0x000000100000 : "u-boot"
[    0.783686] 0x000000100000-0x000000110000 : "dtb"
[    0.792022] 0x000000110000-0x000000510000 : "kernel"
[    0.800449] 0x000000510000-0x000000c10000 : "rootfs"
[    0.808997] 0x000000c10000-0x000001000000 : "overlayfs"
[    0.818275] ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
[    0.824932] ehci-platform: EHCI generic platform driver
[    0.830449] ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver
[    0.836760] ohci-platform: OHCI generic platform driver
[    0.842454] usbcore: registered new interface driver usb-storage
[    0.849088] i2c /dev entries driver
[    0.854436] suniv-f1c100s-pinctrl 1c20800.pinctrl: 1c20800.pinctrl supply vcc-pf not found, using dummy regulator
[    0.892286] sunxi-mmc 1c0f000.mmc: initialized, max. request size: 16384 KB
[    0.901705] usbcore: registered new interface driver usbhid
[    0.907279] usbhid: USB HID core driver
[    0.927270] NET: Registered protocol family 17
[    0.931971] Key type dns_resolver registered
[    0.938513] Loading compiled-in X.509 certificates
[    0.952934] suniv-f1c100s-pinctrl 1c20800.pinctrl: 1c20800.pinctrl supply vcc-pd not found, using dummy regulator
[    0.964269] sun4i-backend 1e60000.display-backend: Couldn't find matching frontend, frontend features disabled
[    0.975113] sun4i-drm display-engine: bound 1e60000.display-backend (ops 0xc0739054)
[    0.984200] sun4i-drm display-engine: bound 1c0c000.lcd-controller (ops 0xc0737cac)
[    0.991983] [drm] Supports vblank timestamp caching Rev 2 (21.10.2013).
[    0.998584] [drm] No driver support for vblank timestamp query.
[    1.005873] [drm] Initialized sun4i-drm 1.0.0 20150629 for display-engine on minor 0
[    1.255718] Console: switching to colour frame buffer device 100x30
[    1.295607] sun4i-drm display-engine: fb0: sun4i-drmdrmfb frame buffer device
[    1.303649] cfg80211: Loading compiled-in X.509 certificates for regulatory database
[    1.322079] cfg80211: Loaded X.509 cert 'sforshee: 00b28ddf47aef9cea7'
[    1.328866] ALSA device list:
[    1.331981]   #0: Loopback 1
[    1.335465] platform regulatory.0: Direct firmware load for regulatory.db failed with error -2
[    1.344192] cfg80211: failed to load regulatory.db
[    1.353545] random: fast init done
[    1.358818] VFS: Mounted root (squashfs filesystem) readonly on device 31:3.
[    1.370858] devtmpfs: mounted
[    1.381273] Freeing unused kernel memory: 1024K
[    1.385959] Run /etc/preinit as init process
[    1.427577] Kernel panic - not syncing: Requested init /etc/preinit failed (error -8).
[    1.435512] CPU: 0 PID: 1 Comm: swapper Not tainted 5.2.0-licheepi-nano+ #14
[    1.442539] Hardware name: Allwinner suniv Family
[    1.447303] [<c010e4ac>] (unwind_backtrace) from [<c010ba84>] (show_stack+0x10/0x14)
[    1.455049] [<c010ba84>] (show_stack) from [<c0116dc0>] (panic+0xe8/0x2e4)
[    1.461935] [<c0116dc0>] (panic) from [<c067f6a8>] (kernel_init+0x90/0x110)
[    1.468898] [<c067f6a8>] (kernel_init) from [<c01010e0>] (ret_from_fork+0x14/0x34)
[    1.476445] Exception stack(0xc3835fb0 to 0xc3835ff8)
[    1.481494] 5fa0:                                     00000000 00000000 00000000 00000000
[    1.489662] 5fc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[    1.497824] 5fe0: 00000000 00000000 00000000 00000000 00000013 00000000
[    1.504435] Rebooting in 5 seconds..
[    7.483668] Reboot failed -- System halted

离线

#14 2020-06-14 14:47:31

billnie
会员
注册时间: 2018-11-13
已发帖子: 47
积分: 37

Re: 为F1C100S的SPI Flash制作SquashFS+JFFS2+OverlayFS的rootfs来增大可读写空间

[    1.358941] VFS: Mounted root (squashfs filesystem) readonly on device 31:3.
[    1.370987] devtmpfs: mounted
[    1.381393] Freeing unused kernel memory: 1024K
[    1.386096] Run /etc/preinit as init process
[    1.629275] random: crng init done
mount: mounting /dev/mtdblock3 on /rom failed: Device or resource busy
[    2.476113] overlayfs: upper fs does not support tmpfile.
[    2.481676] overlayfs: upper fs does not support xattr, falling back to index=off and metacopy=off.
mount: mounting /sys on /chroot/sys/ failed: No such file or directory
mount: mounting /dev on /chroot/dev/ failed: No such file or directory
chroot: can't execute '/sbin/init': No such file or directory
[    2.651104] Kernel panic - not syncing: Attempted to kill init! exitcode=0x00007f00
[    2.658781] CPU: 0 PID: 1 Comm: chroot Not tainted 5.2.0-licheepi-nano+ #14
[    2.665721] Hardware name: Allwinner suniv Family
[    2.670476] [<c010e4ac>] (unwind_backtrace) from [<c010ba84>] (show_stack+0x10/0x14)
[    2.678223] [<c010ba84>] (show_stack) from [<c0116dc0>] (panic+0xe8/0x2e4)
[    2.685098] [<c0116dc0>] (panic) from [<c01185f4>] (do_exit+0x9dc/0xa18)
[    2.691797] [<c01185f4>] (do_exit) from [<c0119190>] (do_group_exit+0x3c/0xb4)
[    2.699014] [<c0119190>] (do_group_exit) from [<c0119218>] (sys_exit_group+0x10/0x14)
[    2.706837] [<c0119218>] (sys_exit_group) from [<c0101000>] (ret_fast_syscall+0x0/0x50)
[    2.714814] Exception stack(0xc3835fa8 to 0xc3835ff0)
[    2.719870] 5fa0:                   b6f1e6d8 b6f1e6d8 0000007f 00000000 0000007f 00000001
[    2.728040] 5fc0: b6f1e6d8 b6f1e6d8 b6f23148 000000f8 00000001 00000000 00000000 b6f23140
[    2.736198] 5fe0: 00000000 bed08cf8 b6e09464 b6e7a3f4
[    2.741251] Rebooting in 5 seconds..
[    8.720483] Reboot failed -- System halted

离线

#15 2020-06-15 08:41:12

哇酷小二
管理员
所在地: 你猜
注册时间: 2020-04-22
已发帖子: 3,388
积分: 1902
个人网站

Re: 为F1C100S的SPI Flash制作SquashFS+JFFS2+OverlayFS的rootfs来增大可读写空间

[    2.476113] overlayfs: upper fs does not support tmpfile.
[    2.481676] overlayfs: upper fs does not support xattr, falling back to index=off and metacopy=off.





离线

#16 2020-06-15 08:44:09

shawnzhang
会员
注册时间: 2020-06-15
已发帖子: 3
积分: 3

Re: 为F1C100S的SPI Flash制作SquashFS+JFFS2+OverlayFS的rootfs来增大可读写空间

干活,必须收藏,正在学习linux

离线

#17 2020-06-15 10:52:01

hukolau
会员
注册时间: 2020-06-15
已发帖子: 9
积分: 9

Re: 为F1C100S的SPI Flash制作SquashFS+JFFS2+OverlayFS的rootfs来增大可读写空间

打卡学习:)

离线

#18 2020-08-02 22:42:18

an99h
会员
注册时间: 2020-07-17
已发帖子: 2
积分: 2

Re: 为F1C100S的SPI Flash制作SquashFS+JFFS2+OverlayFS的rootfs来增大可读写空间

rootfs_new/etc/preinit 脚本需要添加执行权限,不然启动会Kernel panic

[    1.227756] VFS: Mounted root (squashfs filesystem) readonly on device 31:3.
[    1.239415] devtmpfs: mounted
[    1.246976] Freeing unused kernel memory: 1024K
[    1.251824] Kernel panic - not syncing: Requested init /etc/preinit failed (error -13).
[    1.259832] CPU: 0 PID: 1 Comm: swapper Not tainted 4.15.0-rc8-licheepi-nano #14
[    1.267207] Hardware name: Allwinner suniv Family
[    1.271990] [<c010e550>] (unwind_backtrace) from [<c010b6a8>] (show_stack+0x10/0x14)
[    1.279746] [<c010b6a8>] (show_stack) from [<c0116878>] (panic+0xb8/0x230)
[    1.286645] [<c0116878>] (panic) from [<c0672134>] (kernel_init+0x8c/0x10c)
[    1.293621] [<c0672134>] (kernel_init) from [<c0107dc0>] (ret_from_fork+0x14/0x34)
[    1.301185] Rebooting in 5 seconds..
[    7.280418] Reboot failed -- System halted

chmod +x rootfs_new/etc/preinit

离线

#19 2020-08-06 09:30:50

zhangmufa
会员
注册时间: 2020-08-05
已发帖子: 2
积分: 2

Re: 为F1C100S的SPI Flash制作SquashFS+JFFS2+OverlayFS的rootfs来增大可读写空间

很有参考意义,谢谢楼主的分享

离线

#20 2020-08-06 09:59:57

xk100
会员
注册时间: 2018-12-13
已发帖子: 73
积分: 56.5

Re: 为F1C100S的SPI Flash制作SquashFS+JFFS2+OverlayFS的rootfs来增大可读写空间

好东西,谢谢分享。

离线

#21 2020-08-07 11:43:30

wangweigang0
会员
注册时间: 2020-08-07
已发帖子: 17
积分: 47

Re: 为F1C100S的SPI Flash制作SquashFS+JFFS2+OverlayFS的rootfs来增大可读写空间

现在串行falsh 1g那个价格跟128这个差不多,能不能直接更换使用?

离线

#22 2020-08-15 11:42:24

linyu0395
会员
注册时间: 2020-08-15
已发帖子: 1
积分: 1

Re: 为F1C100S的SPI Flash制作SquashFS+JFFS2+OverlayFS的rootfs来增大可读写空间

最近在关注f1c100s 驱动屏幕

离线

#23 2020-09-16 16:10:55

ccl
会员
注册时间: 2020-09-16
已发帖子: 10
积分: 0

Re: 为F1C100S的SPI Flash制作SquashFS+JFFS2+OverlayFS的rootfs来增大可读写空间

太给力了。。。。。

离线

#24 2020-09-19 10:38:57

sdxmps
会员
注册时间: 2020-09-19
已发帖子: 13
积分: 13

Re: 为F1C100S的SPI Flash制作SquashFS+JFFS2+OverlayFS的rootfs来增大可读写空间

非常好啊啊

离线

#25 2021-01-07 23:36:22

hzy831225
会员
注册时间: 2020-04-11
已发帖子: 40
积分: 35

Re: 为F1C100S的SPI Flash制作SquashFS+JFFS2+OverlayFS的rootfs来增大可读写空间

好东西,正想着空间不够用的事,移植完4G网卡拨号+L2TP+SSH+FTP;空间就没多少了。应用程序还没放,OVER玩不下去了。

离线

#26 2021-01-18 15:20:50

大帅
会员
注册时间: 2019-01-17
已发帖子: 169
积分: 128.5

Re: 为F1C100S的SPI Flash制作SquashFS+JFFS2+OverlayFS的rootfs来增大可读写空间

官方的tina就是使用了overlay

离线

#27 2021-01-19 09:40:02

wujique
会员
注册时间: 2018-10-30
已发帖子: 178
积分: 172

Re: 为F1C100S的SPI Flash制作SquashFS+JFFS2+OverlayFS的rootfs来增大可读写空间

干货满满。
以前只有路由器会用openwrt,现在在其他平台也很多人用openwrt或overlay机制。

离线

#28 2021-06-17 21:36:26

ueiia
会员
注册时间: 2021-04-30
已发帖子: 29
积分: 12

Re: 为F1C100S的SPI Flash制作SquashFS+JFFS2+OverlayFS的rootfs来增大可读写空间

是不是UBOOT的ENV都可以改成nowhere,只调用hardcode的env,这样既省flash空间,又可以加速启动

离线

#29 2022-03-14 00:44:51

ne_demon
会员
注册时间: 2021-06-20
已发帖子: 16
积分: 21

Re: 为F1C100S的SPI Flash制作SquashFS+JFFS2+OverlayFS的rootfs来增大可读写空间

修改楼主脚本如下,解决mtdblock3 busy的问题,以及自动创建rw目录和work目录(首先你得用jffs2格式化mtd4分区)

#!/bin/sh

# export PATH="/usr/sbin:/usr/bin:/sbin:/bin"

# mount the new rootfs
# mount -t squashfs /dev/mtdblock3 /rom
mount -t jffs2 /dev/mtdblock4 /overlay
if [ ! -d "/overlay/rw" ];then
  echo "create /overlay/rw"
  mkdir /overlay/rw
fi
if [ ! -d "/overlay/work" ];then
  echo "create /overlay/work"
  mkdir /overlay/work
fi

mount -n -t overlay overlayfs:/overlay -o lowerdir=/,upperdir=/overlay/rw,workdir=/overlay/work /chroot

# mount /dev and /sys for chroot environment
# /dev/pts, /dev/shm, /proc, /tmp and /run will be mounted by inittab from fstab
mount -t sysfs sysfs /sys
mount --rbind /sys /chroot/sys/
mount --rbind /dev /chroot/dev/


exec chroot /chroot /sbin/init

不过我出现了新的问题:根目录可以读写,但不能使用mv,但可以先cp,再rm,然后就可以使用mv了,什么原因?很奇怪,比如:

# mv esp8089.ko xx.bak
mv: can't rename 'esp8089.ko': Invalid argument
# cp -af esp8089.ko esp8089.ko-bak
# ls
esp8089.ko      esp8089.ko-bak
# rm esp8089.ko
# ls
esp8089.ko-bak
# mv esp8089.ko-bak esp8089.ko
# ls
esp8089.ko

再次mv esp8089.ko esp8089.ko-bak,同样会报错,感觉像是rootfs自带的文件就不能使用mv,有大佬知道什么问题吗?

最近编辑记录 ne_demon (2022-03-14 00:45:12)

离线

页脚

工信部备案:粤ICP备20025096号 Powered by FluxBB

感谢为中文互联网持续输出优质内容的各位老铁们。 QQ: 516333132, 微信(wechat): whycan_cn (哇酷网/挖坑网/填坑网) service@whycan.cn