最近用LCPI-F1C200S开发板,用Buildroot-tiny200 sdk,spi nand flash,启动速度超级慢,特别是从spi_nand加载内核的时候,居然要6-7s,整个开机过程要30s这样,体验太差了,但是我看有网友可以优化到几s以内的,但是没有看到有具体的方法。
下面是启动日志,不知道有没有大佬出手帮忙看下如何优化?在网上找了几天,完全没有头绪。
14:55:05.532 -> U-Boot SPL 2020.07 (Jul 24 2025 - 11:32:13 +0800)
14:55:05.536 -> DRAM: 64 MiB
14:55:05.550 -> Trying to boot from MMC1
14:55:05.563 -> Card did not respond to voltage select!
14:55:05.564 -> spl: mmc init failed with error: -95
14:55:05.566 -> Trying to boot from MMC2
14:55:05.582 -> Card did not respond to voltage select!
14:55:05.603 -> spl: mmc init failed with error: -95
14:55:05.603 -> Trying to boot from sunxi SPI
14:55:05.603 -> SPI-NAND: GigaDevice GD5F1GQ5UEYIG
14:55:05.603 -> SPI-NAND: U-Boot address: 53248
14:55:06.312 -> U-Boot 2020.07 (Jul 24 2025 - 11:32:13 +0800) Allwinner Technology
14:55:06.317 -> CPU: Allwinner F Series (SUNIV)
14:55:06.320 -> Model: Allwinner F1C100s Generic Device
14:55:06.335 -> DRAM: 64 MiB
14:55:06.851 -> MMC:
14:55:06.870 -> Setting up a 1024x600 lcd console (overscan 0x0)
14:55:06.957 -> In: serial
14:55:06.957 -> Out: serial
14:55:06.957 -> Err: serial
14:55:06.964 -> Allwinner mUSB OTG (Peripheral)
14:55:06.968 -> Hit any key to stop autoboot: 0
14:55:06.973 -> No MMC device available
14:55:06.973 -> No MMC device available
14:55:06.995 -> unrecognized JEDEC id bytes: ff, c8, 51
14:55:06.995 -> Failed to initialize SPI flash at 0:0 (error -2)
14:55:06.995 -> List of MTD devices:
14:55:06.995 -> * spi-nand0
14:55:06.995 -> - device: spi-nand@1
14:55:06.995 -> - parent: spi@1c05000
14:55:06.995 -> - driver: spi_nand
14:55:06.997 -> - type: NAND flash
14:55:06.997 -> - block size: 0x20000 bytes
14:55:06.999 -> - min I/O: 0x800 bytes
14:55:07.002 -> - OOB size: 128 bytes
14:55:07.005 -> - OOB available: 4 bytes
14:55:07.008 -> - 0x000000000000-0x000008000000 : "spi-nand0"
14:55:07.011 -> =========================
14:55:07.014 -> Boot Device: spi
14:55:07.016 -> Boot Slot 0: empty
14:55:07.016 -> Boot Slot 1: spi-nand
14:55:07.032 -> =========================
14:55:07.032 -> Reading 524288 byte(s) (256 page(s)) at offset 0x00080000
14:55:07.654 -> Unknown command 'bmp' - try 'help'
14:55:07.657 -> gpio: pin 134 (gpio 134) value is 1
14:55:07.660 -> Booting from SPI-NAND...
14:55:07.663 -> Reading 5242880 byte(s) (2560 page(s)) at offset 0x00100000
14:55:13.967 -> ## Loading kernel from FIT Image at 81000000 ...
14:55:13.969 -> Using 'conf@0' configuration
14:55:13.972 -> Trying 'kernel@0' kernel subimage
14:55:13.974 -> Description: Linux kernel
14:55:13.977 -> Type: Kernel Image
Compression: uncompressed
Data Start: 0x810000cc
Data Size: 4309824 Bytes = 4.1 MiB
14:55:14.004 -> Architecture: ARM
14:55:14.004 -> OS: Linux
14:55:14.004 -> Load Address: 0x80000000
14:55:14.004 -> Entry Point: 0x80000000
14:55:14.004 -> Hash algo: crc32
14:55:14.004 -> Hash value: 43cbf38a
14:55:14.005 -> Verifying Hash Integrity ... crc32+ OK
14:55:14.099 -> ## Loading fdt from FIT Image at 81000000 ...
14:55:14.102 -> Using 'conf@0' configuration
14:55:14.105 -> Trying 'fdt@0' fdt subimage
14:55:14.108 -> Description: Flattened Device Tree blob
14:55:14.129 -> Type: Flat Device Tree
14:55:14.129 -> Compression: uncompressed
14:55:14.129 -> Data Start: 0x8141c4f0
14:55:14.129 -> Data Size: 15674 Bytes = 15.3 KiB
14:55:14.129 -> Architecture: ARM
14:55:14.129 -> Hash algo: crc32
14:55:14.129 -> Hash value: afd1b6d0
14:55:14.132 -> Verifying Hash Integrity ... crc32+ OK
14:55:14.135 -> Booting using the fdt blob at 0x8141c4f0
14:55:14.138 -> Loading Kernel Image
14:55:14.191 -> Loading Device Tree to 817f9000, end 817ffd39 ... OK
14:55:14.209 -> Starting kernel ...
14:55:15.327 -> [ 0.000000] Booting Linux on physical CPU 0x0
14:55:15.329 -> [ 0.000000] Linux version 5.4.99 (ubt20@ubt20-Vbox) (gcc version
8.4.0 (Buildroot -g21de572-dirty)) #1 Tue Jul 22 21:15:58 CST 2025
14:55:15.341 -> [ 0.000000] CPU: ARM926EJ-S [41069265] revision 5 (ARMv5TEJ), cr=
0005317f
14:55:15.359 -> [ 0.000000] CPU: VIVT data cache, VIVT instruction cache
14:55:15.359 -> [ 0.000000] OF: fdt: Machine model: Widora MangoPi R3
14:55:15.359 -> [ 0.000000] Memory policy: Data cache writeback
14:55:15.362 -> [ 0.000000] cma: Reserved 16 MiB at 0x82c00000
14:55:15.367 -> [ 0.000000] Built 1 zonelists, mobility grouping on. Total pages
: 15660
14:55:15.373 -> [ 0.000000] Kernel command line: console=ttyS1,115200 rootwait in
it=/preinit root=/dev/mtdblock2 rootfstype=squashfs overlayfsdev=/dev/mtdblock3 net.
ifnames=0 vt.global_cursor_default=0
14:55:15.396 -> [ 0.000000] Dentry cache hash table entries: 8192 (order: 3, 3276
8 bytes, linear)
14:55:15.398 -> [ 0.000000] Inode-cache hash table entries: 4096 (order: 2, 16384
bytes, linear)
14:55:15.403 -> [ 0.000000] mem auto-init: stack:off, heap alloc:off, heap free:o
ff
14:55:15.412 -> [ 0.000000] Memory: 36332K/63136K available (6144K kernel code, 2
48K rwdata, 1676K rodata, 1024K init, 225K bss, 10420K reserved, 16384K cma-reserved
)
14:55:15.438 -> [ 0.000000] SLUB: HWalign=32, Order=0-3, MinObjects=0, CPUs=1, No
des=1
14:55:15.438 -> [ 0.000000] NR_IRQS: 16, nr_irqs: 16, preallocated irqs: 16
14:55:15.438 -> [ 0.000000] random: get_random_bytes called from start_kernel+0x2
54/0x444 with crng_init=0
14:55:15.445 -> [ 0.000048] sched_clock: 32 bits at 24MHz, resolution 41ns, wraps
every 89478484971ns
14:55:15.454 -> [ 0.000131] clocksource: timer: mask: 0xffffffff max_cycles: 0xff
ffffff, max_idle_ns: 79635851949 ns
14:55:15.462 -> [ 0.000754] Console: colour dummy device 80x30
14:55:15.478 -> [ 0.000849] Calibrating delay loop... 298.59 BogoMIPS (lpj=149299
2)
14:55:15.478 -> [ 0.070201] pid_max: default: 32768 minimum: 301
14:55:15.478 -> [ 0.070619] Mount-cache hash table entries: 1024 (order: 0, 4096
bytes, linear)
14:55:15.484 -> [ 0.070660] Mountpoint-cache hash table entries: 1024 (order: 0,
4096 bytes, linear)
14:55:15.493 -> [ 0.072341] CPU: Testing write buffer coherency: ok
14:55:15.498 -> [ 0.074365] Setting up static identity map for 0x80100000 - 0x801
00058
14:55:15.503 -> [ 0.075632] devtmpfs: initialized
14:55:15.520 -> [ 0.084854] clocksource: jiffies: mask: 0xffffffff max_cycles: 0x
ffffffff, max_idle_ns: 19112604462750000 ns
14:55:15.520 -> [ 0.084913] futex hash table entries: 256 (order: -1, 3072 bytes,
linear)
14:55:15.523 -> [ 0.088631] pinctrl core: initialized pinctrl subsystem
14:55:15.539 -> [ 0.091190] NET: Registered protocol family 16
14:55:15.539 -> [ 0.093960] DMA: preallocated 256 KiB pool for atomic coherent al
locations
14:55:15.539 -> [ 0.095815] cpuidle: using governor menu
14:55:15.542 -> [ 0.131480] SCSI subsystem initialized
14:55:15.560 -> [ 0.131821] usbcore: registered new interface driver usbfs
14:55:15.560 -> [ 0.131959] usbcore: registered new interface driver hub
14:55:15.560 -> [ 0.132103] usbcore: registered new device driver usb
14:55:15.562 -> [ 0.132533] mc: Linux media interface: v0.10
14:55:15.568 -> [ 0.132641] videodev: Linux video capture interface: v2.00
14:55:15.573 -> [ 0.132745] pps_core: LinuxPPS API ver. 1 registered
14:55:15.578 -> [ 0.132760] pps_core: Software ver. 5.3.6 - Copyright 2005-2007 R
odolfo Giometti <giometti@linux.it>
14:55:15.603 -> [ 0.132811] PTP clock support registered
14:55:15.603 -> [ 0.133786] ion_parse_dt_heap_common: id 4 type 4 name cma align
1000
14:55:15.603 -> [ 0.134646] Advanced Linux Sound Architecture Driver Initialized.
14:55:15.604 -> [ 0.136758] clocksource: Switched to clocksource timer
14:55:15.609 -> [ 0.138426] simple-framebuffer 83da8000.framebuffer: framebuffer
at 0x83da8000, 0x258000 bytes, mapped to 0x(ptrval)
14:55:15.620 -> [ 0.138478] simple-framebuffer 83da8000.framebuffer: format=x8r8g
8b8, mode=1024x600x32, linelength=4096
14:55:15.636 -> [ 0.167593] Console: switching to colour frame buffer device 128x
37
14:55:15.636 -> [ 0.194941] simple-framebuffer 83da8000.framebuffer: fb0: simplef
b registered!
14:55:15.643 -> [ 0.222941] thermal_sys: Registered thermal governor 'step_wise'
14:55:15.648 -> [ 0.223607] NET: Registered protocol family 2
14:55:15.650 -> [ 0.224969] tcp_listen_portaddr_hash hash table entries: 512 (ord
er: 0, 4096 bytes, linear)
14:55:15.659 -> [ 0.225045] TCP established hash table entries: 1024 (order: 0, 4
096 bytes, linear)
14:55:15.667 -> [ 0.225103] TCP bind hash table entries: 1024 (order: 0, 4096 byt
es, linear)
14:55:15.678 -> [ 0.225141] TCP: Hash tables configured (established 1024 bind 10
24)
14:55:15.682 -> [ 0.225449] UDP hash table entries: 256 (order: 0, 4096 bytes, li
near)
14:55:15.686 -> [ 0.225511] UDP-Lite hash table entries: 256 (order: 0, 4096 byte
s, linear)
14:55:15.695 -> [ 0.226025] NET: Registered protocol family 1
14:55:15.698 -> [ 0.228456] NetWinder Floating Point Emulator V0.97 (double preci
sion)
14:55:15.706 -> [ 0.230023] Initialise system trusted keyrings
14:55:15.715 -> [ 0.230558] workingset: timestamp_bits=30 max_order=14 bucket_ord
er=0
14:55:15.718 -> [ 0.248050] squashfs: version 4.0 (2009/01/31) Phillip Lougher
14:55:15.723 -> [ 0.248578] jffs2: version 2.2. (NAND) (SUMMARY) .. 2001-2006 Re
d Hat, Inc.
14:55:15.728 -> [ 0.324145] Key type asymmetric registered
14:55:15.734 -> [ 0.324182] Asymmetric key parser 'x509' registered
14:55:15.740 -> [ 0.324346] Block layer SCSI generic (bsg) driver version 0.4 loa
ded (major 249)
14:55:15.752 -> [ 0.324374] io scheduler mq-deadline registered
14:55:15.752 -> [ 0.324386] io scheduler kyber registered
14:55:15.754 -> [ 0.337088] suniv-f1c100s-pinctrl 1c20800.pinctrl: initialized su
nXi PIO driver
14:55:15.763 -> [ 0.357256] Serial: 8250/16550 driver, 8 ports, IRQ sharing disab
led
14:55:15.767 -> [ 0.362844] suniv-f1c100s-pinctrl 1c20800.pinctrl: 1c20800.pinctr
l supply vcc-pe not found, using dummy regulator
14:55:15.782 -> [ 0.384334] 1c25000.serial: ttyS0 at MMIO 0x1c25000 (irq = 26, ba
se_baud = 6250000) is a 16550A
14:55:15.787 -> [ 0.385446] suniv-f1c100s-pinctrl 1c20800.pinctrl: 1c20800.pinctr
l supply vcc-pa not found, using dummy regulator
14:55:15.800 -> [ 0.407127] 1c25400.serial: ttyS1 at MMIO 0x1c25400 (irq = 27, ba
se_baud = 6250000) is a 16550A
14:55:15.806 -> [ 0.888592] printk: console [ttyS1] enabled
14:55:15.820 -> [ 0.901299] SCSI Media Changer driver v0.25
14:55:15.826 -> [ 0.907161] suniv-f1c100s-pinctrl 1c20800.pinctrl: 1c20800.pinctr
l supply vcc-pc not found, using dummy regulator
14:55:15.840 -> [ 0.919851] spi-nand spi0.0: GigaDevice SPI NAND was found.
14:55:15.844 -> [ 0.925446] spi-nand spi0.0: 128 MiB, block size: 128 KiB, page s
ize: 2048, OOB size: 128
14:55:15.854 -> [ 0.935264] 4 fixed-partitions partitions found on MTD device spi
0.0
14:55:15.860 -> [ 0.941744] Creating 4 MTD partitions on "spi0.0":
14:55:15.865 -> [ 0.946558] 0x000000000000-0x000000100000 : "u-boot"
14:55:15.884 -> [ 0.958900] 0x000000100000-0x000000600000 : "kernel"
14:55:15.884 -> [ 0.964770] random: fast init done
14:55:15.907 -> [ 0.988667] 0x000000600000-0x000003000000 : "rom"
14:55:16.063 -> [ 1.143511] 0x000003000000-0x000004000000 : "overlay"
14:55:16.129 -> [ 1.208937] ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) D
river
14:55:16.133 -> [ 1.215469] ehci-platform: EHCI generic platform driver
14:55:16.139 -> [ 1.221104] ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Drive
r
14:55:16.144 -> [ 1.227421] ohci-platform: OHCI generic platform driver
14:55:16.151 -> [ 1.233111] usbcore: registered new interface driver usb-storage
14:55:16.157 -> [ 1.240142] usb_phy_generic usb_phy_generic.0.auto: usb_phy_gener
ic.0.auto supply vcc not found, using dummy regulator
14:55:16.172 -> [ 1.253713] i2c /dev entries driver
14:55:16.175 -> [ 1.257960] suniv-f1c100s-pinctrl 1c20800.pinctrl: 1c20800.pinctr
l supply vcc-pd not found, using dummy regulator
14:55:16.190 -> [ 1.271390] suniv-f1c100s-pinctrl 1c20800.pinctrl: pin PE0 alread
y requested by 1c25000.serial; cannot claim for 1cb0000.csi
14:55:16.201 -> [ 1.282726] suniv-f1c100s-pinctrl 1c20800.pinctrl: pin-128 (1cb00
00.csi) status -22
14:55:16.210 -> [ 1.290435] suniv-f1c100s-pinctrl 1c20800.pinctrl: could not requ
est pin 128 (PE0) from group PE0 on device 1c20800.pinctrl
14:55:16.218 -> [ 1.301654] sun4i-csi 1cb0000.csi: Error applying setting, revers
e things back
14:55:16.226 -> [ 1.308946] sun4i-csi: probe of 1cb0000.csi failed with error -22
14:55:16.235 -> [ 1.316518] sunxi-wdt 1c20ca0.watchdog: Watchdog enabled (timeout
=16 sec, nowayout=0)
14:55:16.251 -> [ 1.326310] suniv-f1c100s-pinctrl 1c20800.pinctrl: 1c20800.pinctr
l supply vcc-pf not found, using dummy regulator
14:55:16.283 -> [ 1.364554] sunxi-mmc 1c0f000.mmc: initialized, max. request size
: 16384 KB
14:55:16.295 -> [ 1.373775] usbcore: registered new interface driver usbhid
14:55:16.298 -> [ 1.379476] usbhid: USB HID core driver
14:55:16.301 -> [ 1.383610] sunxi-cedar 1c0e000.video-codec: sunxi cedar version
0.01alpha
14:55:16.307 -> [ 1.390915] sunxi-cedar 1c0e000.video-codec: cedar-ve the get irq
is 19
14:55:16.321 -> [ 1.402596] debugfs: Directory '1c23c00.codec' with parent 'F1C10
0s Audio Codec' already present!
14:55:16.335 -> [ 1.416552] sun4i-codec 1c23c00.codec: Codec <-> 1c23c00.codec ma
pping ok
14:55:16.355 -> [ 1.431305] NET: Registered protocol family 17
14:55:16.355 -> [ 1.435857] Key type dns_resolver registered
14:55:16.359 -> [ 1.441229] Loading compiled-in X.509 certificates
14:55:16.376 -> [ 1.457324] cfg80211: Loading compiled-in X.509 certificates for
regulatory database
14:55:16.391 -> [ 1.472747] cfg80211: Loaded X.509 cert 'sforshee: 00b28ddf47aef9
cea7'
14:55:16.397 -> [ 1.479596] ALSA device list:
14:55:16.409 -> [ 1.482584] #0: F1C100s Audio Codec
14:55:16.409 -> [ 1.487020] platform regulatory.0: Direct firmware load for regul
atory.db failed with error -2
14:55:16.412 -> [ 1.495676] cfg80211: failed to load regulatory.db
14:55:16.430 -> [ 1.511724] VFS: Mounted root (squashfs filesystem) readonly on d
evice 31:2.
14:55:16.458 -> [ 1.529298] devtmpfs: mounted
14:55:16.458 -> [ 1.538303] Freeing unused kernel memory: 1024K
14:55:16.460 -> [ 1.542946] Run /preinit as init process
14:55:16.483 -> [ 1.565000] random: crng init done
14:55:18.762 -> [ 3.843500] jffs2: Empty flash at 0x00c812f0 ends at 0x00c81800
14:55:18.813 -> [ 3.894858] jffs2: Empty flash at 0x00c82af0 ends at 0x00c83000
14:55:18.862 -> [ 3.943796] jffs2: Empty flash at 0x00c842f0 ends at 0x00c84800
14:55:18.916 -> [ 3.990475] jffs2: Empty flash at 0x00c85af0 ends at 0x00c86000
14:55:18.959 -> [ 4.034693] jffs2: Empty flash at 0x00c872f0 ends at 0x00c87800
14:55:19.001 -> [ 4.075984] jffs2: Empty flash at 0x00c892f0 ends at 0x00c89800
14:55:19.040 -> [ 4.114859] jffs2: Empty flash at 0x00c8aaf0 ends at 0x00c8b000
14:55:19.232 -> [ 4.313067] overlayfs: upper fs does not support tmpfile.
14:55:19.234 -> [ 4.318614] overlayfs: upper fs does not support xattr, falling b
ack to index=off and metacopy=off.
14:55:19.563 -> Starting test log: Naisu is coming!!!
14:55:19.594 -> Starting syslogd: OK
14:55:19.672 -> Starting klogd: OK
14:55:19.758 -> Running sysctl: OK
14:55:19.981 -> Populating /dev using udev: [ 5.638914] udevd[92]: starting versi
on 3.2.9
14:55:20.998 -> [ 6.078942] udevd[93]: starting eudev-3.2.9
14:55:23.473 -> [ 8.554907] Goodix-TS 0-005d: 0-005d supply AVDD28 not found, usi
ng dummy regulator
14:55:23.479 -> [ 8.562932] Goodix-TS 0-005d: 0-005d supply VDDIO not found, usin
g dummy regulator
14:55:23.551 -> [ 8.632264] ov2640 0-0030: Product ID error fa:fa
14:55:23.668 -> [ 8.748944] Goodix-TS 0-005d: ID 911, version: 1060
14:55:23.724 -> [ 8.806151] input: Goodix Capacitive TouchScreen as /devices/plat
form/soc/1c27000.i2c/i2c-0/0-005d/input/input0
14:55:24.551 -> done
14:55:24.710 -> Initializing random number generator: OK
14:55:24.753 -> Saving random seed: OK
14:55:24.841 -> Starting haveged: haveged: listening socket at 3
14:55:25.505 -> [ 10.587823] jffs2: notice: (74) check_node_data: wrong data CRC i
n data node at 0x00ed1ed0: read 0x927a2d51, calculated 0x6c8586b8.
14:55:25.607 -> [ 10.688560] jffs2: notice: (74) check_node_data: wrong data CRC i
n data node at 0x00c8bacc: read 0xf583919c, calculated 0xd54850c.
14:55:25.643 -> [ 10.719076] jffs2: notice: (74) check_node_data: wrong data CRC i
n data node at 0x00c8a2cc: read 0xf583919c, calculated 0xd54850c.
14:55:25.667 -> [ 10.749069] jffs2: notice: (74) check_node_data: wrong data CRC i
n data node at 0x00c88acc: read 0xf583919c, calculated 0xd54850c.
14:55:25.697 -> [ 10.779074] jffs2: notice: (74) check_node_data: wrong data CRC i
n data node at 0x00c86acc: read 0xf583919c, calculated 0xd54850c.
14:55:25.727 -> [ 10.809113] jffs2: notice: (74) check_node_data: wrong data CRC i
n data node at 0x00c852cc: read 0xf583919c, calculated 0xd54850c.
14:55:25.764 -> [ 10.838219] jffs2: notice: (74) check_node_data: wrong data CRC i
n data node at 0x00c83acc: read 0xf583919c, calculated 0xd54850c.
14:55:25.778 -> [ 10.859822] jffs2: notice: (74) check_node_data: wrong data CRC i
n data node at 0x00c822cc: read 0xf583919c, calculated 0xd54850c.
14:55:25.807 -> [ 10.889116] jffs2: notice: (74) check_node_data: wrong data CRC i
n data node at 0x00c80acc: read 0xf583919c, calculated 0xd54850c.
14:55:26.412 -> OK
14:55:26.524 -> Starting network: OK
14:55:26.967 -> Starting uMTPrd: [ 12.199589] file system registered
14:55:27.632 -> [ 12.709906] read descriptors
14:55:27.632 -> [ 12.712856] read strings
14:55:28.200 -> D:thread create succeed!
离线
目前先解决uboot加载内核慢的问题,经过排查发现SPI频率设置不对,默认是1Mhz,经过对AI的不断鞭策,AI还是给我干了点像样的活,终于有所获
1. SPI设备树节点没有设置频率,导致驱动无法获取到频率使用默认频率,驱动中的默认频率就是1Mhz
2. uboot的SPI驱动里面限制了SPI最大速度为24Mhz
解决办法
a)先解决设备树SPI节点没有设置频率的问题,在suniv-f1c100s-generic.dts文件中修改
&spi0 {
pinctrl-names = "default";
pinctrl-0 = <&spi0_pins_a>;
spi-max-frequency = <100000000>;
status = "okay";
b)修改uboot驱动,路径在这output/build/uboot-2020.07/drivers/spi/spi-sunxi.c,修改如下:
//主要修改这个最大频率就可以
#define SUN4I_SPI_MAX_RATE 100000000
目前修改后uboot加载内核(5MByte)的速度2s这样,应该是使用FIFO的问题。
后续再优化应该是SPI速度,内核大小裁剪的问题了。
最近编辑记录 BlinkWee (2025-07-25 11:34:12)
离线