2

我正在尝试创建一个可在 SPI Nor 闪存上与 UBIFS 一起使用的操作系统。我使用了buildroot。Buildroot 创建rootfs.ubirootfs.ubifs因此我没有创建任何ubifs.img内容(我认为不需要它)。编译 buildroot 时我没有出错。

Buildroot 输出文件:

  • rootfs.ubi
  • rootfs.ubifs
  • sun5i-a13.dtb
  • u-boot.bin
  • u-boot-sunxi-with-spl.bin
  • uImage

将输出文件写入 SPI Nor Flash:

#!/bin/bash
DIR="/home/ubuntu/buildroot-spi-nor/output/images"

sudo sunxi-fel -v -p \
    spiflash-write 0x0 ${DIR}/u-boot-sunxi-with-spl.bin \
    spiflash-write 0xE0000 ${DIR}/sun5i-a13.dtb \
    spiflash-write 0x100000 ${DIR}/uImage \
    spiflash-write 0x600000 ${DIR}/rootfs.ubi \
    uboot ${DIR}/u-boot-sunxi-with-spl.bin

U-boot 配置:

BOOTARGS = ubi.mtd=3 rootfstype=ubifs rw rootwait rootfs=/dev/mtdblock3 loglevel=9
BOOTCOMMAND = run distro_bootcmd;sspi;sf probe;sf read 0x43000000 0xE0000 0x4000;sf read 0x42000000 0x100000 0x2F0000;bootm 0x42000000 - 0x43000000;
MTDIDS_DEFAULT = nor0=spi0.0
MTDPARTS_DEFAULT = mtdparts=spi0.0:0x000E0000(boot),0x00020000(dtb),0x00400000(kernel),0x00a00000(rootfs)

.dts 文件的 SPI flash 的一部分:

&spi0 {
    pinctrl-names = "default";
    pinctrl-0 = <&spi0_pins_a>, <&spi0_cs0_pins_a>;
    status = "okay";

    flash@0 {
        #address-cells = <1>;
        #size-cells = <1>;
        compatible = "mxicy,mx25l12805d", "jedec,spi-nor";
        spi-max-frequency = <1000000>;
        reg = <0>;
        mode = <0>;

        partition@0 {
            label = "bootloader";
            reg = <0x0 0xE0000>;
            // read-only;
        };

        partition@E0000 {
            label = "dtb";
            reg = <0xE0000 0x20000>;
            // read-only;
        };

        partition@100000 {
            label = "kernel";
            reg = <0x100000 0x500000>;
        };

        partition@600000 {
            label = "rootfs";
            reg = <0x600000 0xA00000>;
        };
    };
};

我有 4 个 mdt 分区,我努力将 ubifs 挂载到 rootfs 分区。


写入rootfs.ubifsSPI Nor Flash Dmesg 输出的 0x400000 地址后

[    0.045841] VFP support v0.3: implementor 41 architecture 3 part 30 variant c rev 3
[    0.046046] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 19112604462750000 ns
[    0.046096] futex hash table entries: 256 (order: -1, 3072 bytes, linear)
[    0.046200] pinctrl core: initialized pinctrl subsystem
[    0.047135] NET: Registered protocol family 16
[    0.047738] DMA: preallocated 256 KiB pool for atomic coherent allocations
[    0.048490] thermal_sys: Registered thermal governor 'step_wise'
[    0.048852] hw-breakpoint: debug architecture 0x4 unsupported.
[    0.063346] vgaarb: loaded
[    0.063718] SCSI subsystem initialized
[    0.063873] usbcore: registered new interface driver usbfs
[    0.063938] usbcore: registered new interface driver hub
[    0.064001] usbcore: registered new device driver usb
[    0.065175] clocksource: Switched to clocksource timer
[    0.065959] simple-framebuffer 5fe89000.framebuffer: framebuffer at 0x5fe89000, 0x177000 bytes, mapped to 0x(ptrval)
[    0.066018] simple-framebuffer 5fe89000.framebuffer: format=x8r8g8b8, mode=800x480x32, linelength=3200
[    0.071954] Console: switching to colour frame buffer device 100x30
[    0.080800] simple-framebuffer 5fe89000.framebuffer: fb0: simplefb registered!
[    0.090750] PCI: CLS 0 bytes, default 64
[    0.095320] Initialise system trusted keyrings
[    0.098848] workingset: timestamp_bits=30 max_order=17 bucket_order=0
[    0.106227] Key type asymmetric registered
[    0.109588] Asymmetric key parser 'x509' registered
[    0.112865] Block layer SCSI generic (bsg) driver version 0.4 loaded (major 252)
[    0.116197] io scheduler mq-deadline registered
[    0.119426] io scheduler kyber registered
[    0.126048] sun5i-pinctrl 1c20800.pinctrl: initialized sunXi PIO driver
[    0.177235] Serial: 8250/16550 driver, 8 ports, IRQ sharing disabled
[    0.182159] sun5i-pinctrl 1c20800.pinctrl: supply vcc-pg not found, using dummy regulator
[    0.206521] 1c28400.serial: ttyS0 at MMIO 0x1c28400 (irq = 33, base_baud = 1500000) is a U6_16550A
[    0.669462] printk: console [ttyS0] enabled
[    0.684378] loop: module loaded
[    0.691437] sun5i-pinctrl 1c20800.pinctrl: supply vcc-pc not found, using dummy regulator
[    0.704102] spi-nor spi0.0: mx25l12805d (16384 Kbytes)
[    0.712595] 4 fixed-partitions partitions found on MTD device spi0.0
[    0.722225] Creating 4 MTD partitions on "spi0.0":
[    0.730299] 0x000000000000-0x0000000e0000 : "bootloader"
[    0.740017] 0x0000000e0000-0x000000100000 : "dtb"
[    0.749058] 0x000000100000-0x000000600000 : "kernel"
[    0.758323] 0x000000500000-0x000000f00000 : "rootfs"
[    0.768061] ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
[    0.777963] ehci-pci: EHCI PCI platform driver
[    0.785658] ehci-platform: EHCI generic platform driver
[    0.794364] ehci-platform 1c14000.usb: EHCI Host Controller
[    0.803083] ehci-platform 1c14000.usb: new USB bus registered, assigned bus number 1
[    0.814054] ehci-platform 1c14000.usb: irq 23, io mem 0x01c14000
[    0.845204] ehci-platform 1c14000.usb: USB 2.0 started, EHCI 1.00
[    0.854424] usb usb1: New USB device found, idVendor=1d6b, idProduct=0002, bcdDevice= 5.12
[    0.865765] usb usb1: New USB device strings: Mfr=3, Product=2, SerialNumber=1
[    0.876007] usb usb1: Product: EHCI Host Controller
[    0.883853] usb usb1: Manufacturer: Linux 5.12.0-rc3 ehci_hcd
[    0.892601] usb usb1: SerialNumber: 1c14000.usb
[    0.900637] hub 1-0:1.0: USB hub found
[    0.907371] hub 1-0:1.0: 1 port detected
[    0.914828] usbcore: registered new interface driver usb-storage
[    0.924210] usb_phy_generic usb_phy_generic.0.auto: supply vcc not found, using dummy regulator
[    0.936722] musb-hdrc musb-hdrc.1.auto: MUSB HDRC host driver
[    0.945503] musb-hdrc musb-hdrc.1.auto: new USB bus registered, assigned bus number 2
[    0.956512] usb usb2: New USB device found, idVendor=1d6b, idProduct=0002, bcdDevice= 5.12
[    0.967679] usb usb2: New USB device strings: Mfr=3, Product=2, SerialNumber=1
[    0.977779] usb usb2: Product: MUSB HDRC host driver
[    0.985617] usb usb2: Manufacturer: Linux 5.12.0-rc3 musb-hcd
[    0.994187] usb usb2: SerialNumber: musb-hdrc.1.auto
[    1.002466] hub 2-0:1.0: USB hub found
[    1.009019] hub 2-0:1.0: 1 port detected
[    1.017193] dummy_hcd dummy_hcd.0: USB Host+Gadget Emulator, driver 02 May 2005
[    1.027371] dummy_hcd dummy_hcd.0: Dummy host controller
[    1.035441] dummy_hcd dummy_hcd.0: new USB bus registered, assigned bus number 3
[    1.045868] usb usb3: New USB device found, idVendor=1d6b, idProduct=0002, bcdDevice= 5.12
[    1.057120] usb usb3: New USB device strings: Mfr=3, Product=2, SerialNumber=1
[    1.067275] usb usb3: Product: Dummy host controller
[    1.075111] usb usb3: Manufacturer: Linux 5.12.0-rc3 dummy_hcd
[    1.083871] usb usb3: SerialNumber: dummy_hcd.0
[    1.091833] hub 3-0:1.0: USB hub found
[    1.098560] hub 3-0:1.0: 1 port detected
[    1.106573] sunxi-wdt 1c20c90.watchdog: Watchdog enabled (timeout=16 sec, nowayout=0)
[    1.119058] sun4i-ss 1c15000.crypto-engine: Die ID 1
[    1.127422] sun5i-pinctrl 1c20800.pinctrl: supply vcc-pf not found, using dummy regulator
[    1.139675] sunxi-mmc 1c0f000.mmc: Got CD GPIO
[    1.148837] usbcore: registered new interface driver usbhid
[    1.157506] usbhid: USB HID core driver
[    1.165056] Loading compiled-in X.509 certificates
[    1.181214] ubi0: attaching mtd3
[    1.188137] sunxi-mmc 1c0f000.mmc: initialized, max. request size: 16384 KB
[    1.208030] random: fast init done
[    1.354154] ubi0: scanning is finished
[    1.360876] ubi0 error: ubi_read_volume_table: the layout volume was not found
[    1.371165] ubi0 error: ubi_attach_mtd_dev: failed to attach mtd3, error -22
[    1.381210] UBI error: cannot attach mtd3
[    1.389077] Waiting for root device ...
[   31.845194] vcc3v0: disabling
[   31.851016] vcc3v3: disabling
[   31.856753] vcc5v0: disabling
[  196.405220] random: crng init done

写入rootfs.ubiSPI Nor Flash Dmesg 输出的 0x600000 地址后

[    0.714492] spi-nor spi0.0: mx25l12805d (16384 Kbytes)
[    0.722995] 4 fixed-partitions partitions found on MTD device spi0.0
[    0.732653] Creating 4 MTD partitions on "spi0.0":
[    0.740754] 0x000000000000-0x0000000e0000 : "bootloader"
[    0.750508] 0x0000000e0000-0x000000100000 : "dtb"
[    0.759608] 0x000000100000-0x000000600000 : "kernel"
[    0.768897] 0x000000500000-0x000000f00000 : "rootfs"
[    0.778640] ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
[    0.788514] ehci-pci: EHCI PCI platform driver
[    0.796182] ehci-platform: EHCI generic platform driver
[    0.804863] ehci-platform 1c14000.usb: EHCI Host Controller
[    0.813581] ehci-platform 1c14000.usb: new USB bus registered, assigned bus number 1
[    0.824528] ehci-platform 1c14000.usb: irq 23, io mem 0x01c14000
[    0.855269] ehci-platform 1c14000.usb: USB 2.0 started, EHCI 1.00
[    0.864542] usb usb1: New USB device found, idVendor=1d6b, idProduct=0002, bcdDevice= 5.12
[    0.875891] usb usb1: New USB device strings: Mfr=3, Product=2, SerialNumber=1
[    0.886138] usb usb1: Product: EHCI Host Controller
[    0.893979] usb usb1: Manufacturer: Linux 5.12.0-rc3 ehci_hcd
[    0.902719] usb usb1: SerialNumber: 1c14000.usb
[    0.910764] hub 1-0:1.0: USB hub found
[    0.917459] hub 1-0:1.0: 1 port detected
[    0.924897] usbcore: registered new interface driver usb-storage
[    0.934270] usb_phy_generic usb_phy_generic.0.auto: supply vcc not found, using dummy regulator
[    0.946772] musb-hdrc musb-hdrc.1.auto: MUSB HDRC host driver
[    0.955538] musb-hdrc musb-hdrc.1.auto: new USB bus registered, assigned bus number 2
[    0.966547] usb usb2: New USB device found, idVendor=1d6b, idProduct=0002, bcdDevice= 5.12
[    0.977706] usb usb2: New USB device strings: Mfr=3, Product=2, SerialNumber=1
[    0.987801] usb usb2: Product: MUSB HDRC host driver
[    0.995636] usb usb2: Manufacturer: Linux 5.12.0-rc3 musb-hcd
[    1.004203] usb usb2: SerialNumber: musb-hdrc.1.auto
[    1.012477] hub 2-0:1.0: USB hub found
[    1.019014] hub 2-0:1.0: 1 port detected
[    1.026691] musb_handle_intr_disconnect 983: unhandled DISCONNECT transition (a_idle)
[    1.038345] dummy_hcd dummy_hcd.0: USB Host+Gadget Emulator, driver 02 May 2005
[    1.048618] dummy_hcd dummy_hcd.0: Dummy host controller
[    1.056812] dummy_hcd dummy_hcd.0: new USB bus registered, assigned bus number 3
[    1.067365] usb usb3: New USB device found, idVendor=1d6b, idProduct=0002, bcdDevice= 5.12
[    1.078654] usb usb3: New USB device strings: Mfr=3, Product=2, SerialNumber=1
[    1.088859] usb usb3: Product: Dummy host controller
[    1.096802] usb usb3: Manufacturer: Linux 5.12.0-rc3 dummy_hcd
[    1.105650] usb usb3: SerialNumber: dummy_hcd.0
[    1.113672] hub 3-0:1.0: USB hub found
[    1.120483] hub 3-0:1.0: 1 port detected
[    1.128629] sunxi-wdt 1c20c90.watchdog: Watchdog enabled (timeout=16 sec, nowayout=0)
[    1.141063] sun4i-ss 1c15000.crypto-engine: Die ID 1
[    1.149452] sun5i-pinctrl 1c20800.pinctrl: supply vcc-pf not found, using dummy regulator
[    1.161773] sunxi-mmc 1c0f000.mmc: Got CD GPIO
[    1.170983] usbcore: registered new interface driver usbhid
[    1.179725] usbhid: USB HID core driver
[    1.187351] Loading compiled-in X.509 certificates
[    1.203610] ubi0: attaching mtd3
[    1.210562] sunxi-mmc 1c0f000.mmc: initialized, max. request size: 16384 KB
[    1.221794] ubi0 error: validate_ec_hdr: bad VID header offset 512, expected 64
[    1.232292] ubi0 error: validate_ec_hdr: bad EC header
[    1.240488] Erase counter header dump:
[    1.247177]  magic          0x55424923
[    1.253797]  version        1
[    1.259563]  ec             0
[    1.265285]  vid_hdr_offset 512
[    1.271135]  data_offset    2048
[    1.277052]  image_seq      1557467774
[    1.283518]  hdr_crc        0xfc6f20a5
[    1.289894] erase counter header hexdump:
[    1.296464] 00000000: 55 42 49 23 01 00 00 00 00 00 00 00 00 00 00 00 00 00 02 00 00 00 08 00 5c d5 12 7e 00 00 00 00  UBI#....................\..~....
[    1.315406] 00000020: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 fc 6f 20 a5  .............................o .
[    1.334481] CPU: 0 PID: 1 Comm: swapper Not tainted 5.12.0-rc3 #2
[    1.343368] Hardware name: Allwinner sun4i/sun5i Families
[    1.351584] [<c010b088>] (unwind_backtrace) from [<c01088f4>] (show_stack+0x10/0x14)
[    1.362271] [<c01088f4>] (show_stack) from [<c042daec>] (validate_ec_hdr+0x70/0xcc)
[    1.372919] [<c042daec>] (validate_ec_hdr) from [<c042e53c>] (ubi_io_read_ec_hdr+0x188/0x1d0)
[    1.384549] [<c042e53c>] (ubi_io_read_ec_hdr) from [<c0432a28>] (ubi_attach+0x2d8/0x1094)
[    1.395818] [<c0432a28>] (ubi_attach) from [<c0429448>] (ubi_attach_mtd_dev+0x57c/0x9ac)
[    1.406991] [<c0429448>] (ubi_attach_mtd_dev) from [<c081d018>] (ubi_init+0x1a8/0x214)
[    1.417956] [<c081d018>] (ubi_init) from [<c01015f4>] (do_one_initcall+0x70/0x194)
[    1.428550] [<c01015f4>] (do_one_initcall) from [<c0800f94>] (kernel_init_freeable+0x164/0x1b0)
[    1.440343] [<c0800f94>] (kernel_init_freeable) from [<c052ccc0>] (kernel_init+0x8/0x114)
[    1.451636] [<c052ccc0>] (kernel_init) from [<c0100150>] (ret_from_fork+0x14/0x24)
[    1.462347] Exception stack(0xc0c4bfb0 to 0xc0c4bff8)
[    1.470542] bfa0:                                     00000000 00000000 00000000 00000000
[    1.481944] bfc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[    1.493296] bfe0: 00000000 00000000 00000000 00000000 00000013 00000000
[    1.503033] ubi0 error: ubi_io_read_ec_hdr: validation failed for PEB 0
[    1.512812] ubi0 error: ubi_attach_mtd_dev: failed to attach mtd3, error -22
[    1.523275] UBI error: cannot attach mtd3
[    1.531472] Waiting for root device ...
[    2.435240] random: fast init done
[   31.845256] vcc3v0: disabling
[   31.851464] vcc3v3: disabling
[   31.857643] vcc5v0: disabling

Buildroot 版本:2020.02.11
U-boot 版本:U-Boot 2021.04-rc3
内核版本:5.12.0-rc3


这将是一个非常普遍的问题,但是我如何挂载和挂载 rootfs 和 ubifs 并运行系统?

谢谢。

4

1 回答 1

0

尝试修改命令 sunxi-fel

sudo sunxi-fel -v -p \
spiflash-write 0x0 ${DIR}/u-boot-sunxi-with-spl.bin \
spiflash-write 0xE0000 ${DIR}/sun5i-a13.dtb \
spiflash-write 0x100000 ${DIR}/uImage \
spiflash-write 0x600000 ${DIR}/rootfs.ubi \
uboot ${DIR}/u-boot-sunxi-with-spl.bin

和dts文件

partition@600000 {
        label = "rootfs";
        reg = <0x600000 0xA00000>;

};

于 2021-05-12T08:56:45.590 回答