参考https://www.kancloud.cn/lichee/lpi0/470837,不过flash芯片使用的W25q128
uboot关键代码 include/configs/sun8i.h
#define CONFIG_MACH_TYPE 0x1029
#define CONFIG_BOOTCOMMAND "sf probe 0; " \
"sf read 0x41d00000 0x100000 0x10000; " \
"sf read 0x41000000 0x110000 0x400000; " \
"bootz 0x41000000"
#define CONFIG_BOOTARGS "console=ttyS0,115200 earlyprintk panic=5 rootwait " \
"mtdparts=spi32766.0:1M(uboot)ro,64k(script)ro,4M(kernel)ro,-(rootfs) root=31:03 rw rootfstype=jffs2"
kernel关键代码m25p80.c
static int partitions_register(struct mtd_info *mtd, struct mtd_part_parser_data *ppdata)
{
int i;
int ret = 0;
size_t retlen = 0;
MBR *sunxi_mbr = NULL;
struct mtd_partition *partitions = NULL;
printk("m25p80.c this is a test~~\n");
sunxi_mbr = (MBR *)kzalloc(MBR_SIZE, GFP_KERNEL);
if (sunxi_mbr == NULL) {
M25_ERR("Failed to kzalloc(%d)\n", MBR_SIZE);
return -ENOMEM;
}
partitions = kzalloc(4, GFP_KERNEL);
if (partitions == NULL) {
M25_ERR("Failed to kzalloc(%d patition)\n", sunxi_mbr->PartCount);
kfree(sunxi_mbr);
return -ENOMEM;
}
partitions[0].name = "uboot";
partitions[0].offset = 0;
partitions[0].size = 1024 * 1024;
partitions[1].name = "script";
partitions[1].offset = 1024*1024;
partitions[1].size = 64 * 1024;
partitions[2].name = "kernel";
partitions[2].offset = 1024*1024 + 64*1024;
partitions[2].size = 4 * 1024 * 1024;
partitions[3].name = "rootfs";
partitions[3].offset = 1024*1024 + 64*1024 + 4*1024*1024;
partitions[3].size = 11200 * 1024;
ret = mtd_device_parse_register(mtd, NULL, ppdata, partitions, 4);
kfree(partitions);
kfree(sunxi_mbr);
return ret;
}
kernel里已配置SPI Flash
<*> Support most SPI Flash chips (AT26DF, M25P, W25X, ...) │ │
│ │ [ ] Use FAST_READ OPCode allowing SPI CLK <= 50MHz │ │
│ │ [*] Use Dual Mode Read OPCode │ │
│ │ < > Support SST25L (non JEDEC) SPI Flash chips │ │
│ │ < > Uncached system RAM │ │
│ │ < > Physical system RAM │ │
│ │ < > Test driver using RAM │ │
│ │ <*> MTD using block device │ │
│ │ *** Disk-On-Chip Device Drivers *** │ │
│ │ < > M-Systems Disk-On-Chip G3
对比文档里的日志少了这部分日志
[ 0.534254] m25p_probe()988 - Use the Dual Mode Read.
[ 0.540124] m25p80 spi0.0: found W25q128, expected at25df641
[ 0.546639] m25p80 spi0.0: W25q128 (16384 Kbytes)
[ 0.552353] Creating 4 MTD partitions on "spi0.0":
[ 0.557911] 0x000000000000-0x000000100000 : "uboot"
[ 0.564635] 0x000000100000-0x000000110000 : "script"
[ 0.571423] 0x000000110000-0x000000510000 : "kernel"
[ 0.578020] 0x000000510000-0x000001000000 : "rootfs"
启动日志如下
U-Boot SPL 2017.01-rc2-00073-gdd6e8740dc-dirty (Feb 05 2023 - 21:05:22)
DRAM: 64 MiB
Trying to boot from sunxi SPISF: 4194304 bytes @ 0x110000 Read: OK
Starting kernel ...
[ 0.000000] Booting Linux on physical CPU 0
[ 0.000000] Linux version 3.4.39 (nan@ubuntu) (gcc version 4.6.3 20120201 (prerelease) (crosstool-NG linaro-1.13.1-2012.02-20120222 - Linaro3
[ 0.000000] Initialized persistent memory from 41d20800-41d307ff
[ 0.000000] Kernel command line: console=ttyS0,115200 earlyprintk panic=5 rootwait mtdparts=spi32766.0:1M(uboot)ro,64k(script)ro,4M(kernel)r2
[ 0.000000] PID hash table entries: 256 (order: -2, 1024 bytes)
[ 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: 64MB = 64MB total
[ 0.000000] Memory: 30384k/30384k available, 35152k reserved, 0K highmem
[ 0.000000] Virtual kernel memory layout:
[ 0.000000] vector : 0xffff0000 - 0xffff1000 ( 4 kB)
[ 0.000000] fixmap : 0xfff00000 - 0xfffe0000 ( 896 kB)
[ 0.000000] vmalloc : 0xc4800000 .000000] modules : 0xbf000000 - 0xc0000000 ( 16 MB)
[ 0.000000] .text : 0xc0008000 - 0xc047e000 (4568 kB)
[ 0.000000] .init : 0xc047e000 - 0xc04a1000 ( 140 kB)
[ 0.000000] .data : 0xc04a2000 - 0xc04e5f80 ( 272 kB)
[ 0.000000] .bss : 0xc04e5fa4 - 0xc0580b8c ( 619 kB)
[ 0.000000] NR_IRQS:544
[ 0.000000] Architected local timer running at 24.00MHz.
[ 0.000000] Switching to timer-based delay loop
[ 0.000000] sched_clock: 32 bits at 24MHz, resolution 41ns, wraps every 178956ms
[ 0.000000] Console: colour dummy device 80x30
[ 0.000155] Calibrating delay loop (skipped), value calculated using timer frequency.. 4800.00 BogoMIPS (lpj=24000000)
[ 0.000176] pid_max: default: 32768 minimum: 301
[ 0.000314] Mount-cache hash table entries: 512
[ 0.000861] CPU: Testing write buffer coherency: ok
[ 0.001120] Setting up static identity map for 0x40359928 - 0x40359980
[ 0.001778] devtmpfs: initialized
[ 0.003497] pinctrl core: initialized pinctrl subsystem
[ 0.003983] NET: Registered protocol family 16
[ 0.004313] DMA: preallocated 128 KiB pool for atomic coherent allocations
[ 0.004369] script_sysfs_init success
[ 0.005126] gpiochip_add: registered GPIOs 0 to 223 on device: sunxi-pinctrl
[ 0.006020] sunxi-pinctrl sunxi-pinctrl: initialized sunXi PIO driver
[ 0.006391] gpiochip_add: registered GPIOs 1024 to 1031 on device: axp-pinctrl
[ 0.007273] persistent_ram: uncorrectable error in header
[ 0.007289] persistent_ram: no valid data in buffer (sig = 0x11808162)
[ 0.011408] console [ram-1] enabled
[ 0.012210] Not Found clk pll_isp in script
[ 0.012324] Not Found clk pll_video in script
[ 0.012513] Not Found clk pll_ve in script
[ 0.012616] Not Found clk pll_periph0 in script
[ 0.012805] Not Found clk pll_de in script
[ 0.016757] bio: create slab <bio-0> at 0
[ 0.017127] pwm module init!
[ 0.019427] SCSI subsystem initialized
[ 0.019762] usbcore: registered new interface driver usbfs
[ 0.019933] usbcore: registered new interface driver hub
[ 0.020163] usbcore: registered new device driver usb
[ 0.020418] twi_chan_cfg()340 - [twi0] has no twi_regulator.
[ 0.020611] twi_chan_cfg()340 - [twi1] has no twi_regulator.
[ 0.021390] twi_start()434 - [i2c0] START can't sendout!
[ 0.021840] twi_start()434 - [i2c0] START can't sendout!
[ 0.022194] twi_start()434 - [i2c0] START can't sendout!
[ 0.022491] axp20_board 0-0034: failed reading at 0x03
[ 0.022622] axp20_board: probe of 0-0034 failed with error -121
[ 0.022848] Linux video capture interface: v2.00
[ 0.023034] gpiochip_add: gpios 1024..1028 (axp_pin) failed to register
[ 0.023541] Advanced Linux Sound Architecture Driver Version 1.0.25.
[ 0.024352] Switching to clocksource arch_sys_counter
[ 0.029978] NET: Registered protocol family 2
[ 0.029978] IP route cache hash table entries: 1024 (order: 0, 4096 bytes)
[ 0.030248] TCP established hash table entries: 2048 (order: 2, 16384 bytes)
[ 0.030396] TCP bind hash table entries: 2048 (order: 1, 8192 bytes)
[ 0.030606] TCP: Hash tables configured (established 2048 bind 2048)
[ 0.030712] TCP: reno registered
[ 0.030901] UDP hash table entries: 256 (order: 0, 4096 bytes)
[ 0.031017] UDP-Lite hash table entries: 256 (order: 0, 4096 bytes)
[ 0.031456] NET: Registl family 1
[ 0.031916] standby_mode = 1.
[ 0.032023] wakeup src cnt is : 3.
[ 0.032232] pmu1_enable = 0x1.
[ 0.032334] pmux_id = 0x1.
[ 0.032445] config_pmux_para: script_parser_fetch err.
[ 0.032634] pmu2_enable = 0x0.
[ 0.032740] add_sys_pwr_dm: get ldo name failed
[ 0.032843] add_sys_pwr_dm: get ldo name failed
[ 0.033031] add_sys_pwr_dm: get ldo name failed
[ 0.033135] add_sys_pwr_dm: get ldo name failed
[ 0.033322] add_sys_pwr_dm: get ldo name failed
[ 0.033426] add_sys_pwr_dm: get ldo name failed
[ 0.033530] add_sys_pwr_dm: get ldo name failed
[ 0.033718] add_sys_pwr_dm: get ldo name failed
[ 0.033822] add_sys_pwr_dm: get ldo name failed
[ 0.034011] add_sys_pwr_dm: get ldo name failed
[ 0.034114] after inited: sys_mask config = 0x0.
[ 0.034218] dynamic_standby enalbe = 0x0.
[ 0.034453] sunxi_reg_init enter
[ 0.036468] squashfs: version 4.0 (2009/01/31) Phillip Lougher
[ 0.036714] jffs2: version 2.2. (NAND) (SUMMARY) © 2001-2006 Red Hat, Inc.
[ 0.037002] msgmni has been set to 59
[ 0.038050] io scheduler noop registered
[ 0.038248] io scheduler deadline registered
[ 0.038428] io scheduler cfq registered (default)
[ 0.039020] [DISP]disp_module_init
[ 0.039526] cmdline,disp=
[ 0.040230] [DISP] disp_get_rotation_sw,line:68:disp 0 out of range? g_rot_sw=0
[ 0.040527] [DISP] disp_init_connections,line:289:NULL pointer: 0, 0
[ 0.042337] [DISP] Fb_map_kernel_logo,line:924:Fb_map_kernel_logo failed!
[ 0.045079] [DISP] disp_sys_power_enable,line:387:some error happen, fail to get regulator
[ 0.046165] [DISP]disp_module_init finish
[ 0.046548] sw_uart_get_devinfo()1503 - uart0 has no uart_regulator.
[ 0.047099] uart0: ttyS0 at MMIO 0x1c28000 (irq = 32) is a SUNXI
[ 0.047214] sw_uart_pm()890 - uart0 clk is already enable
[ 0.047416] sw_console_setup()1233 - console setup baud 115200 parity n bits 8, flow n
[ 0.161154] console [ttyS0] enabled
[ 0.703403] sunxi_spi_chan_cfg()1376 - [spi-0] has no spi_regulator.
[ 0.711372] spi spi0: master is unqueued, this is deprecated
[ 0.719309] Failed to alloc md5
[ 0.723078] eth0: Use random mac address
[ 0.727587] ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
[ 0.755154] sunxi-ehci sunxi-ehci.1: SW USB2.0 'Enhanced' Host Controller (EHCI) Driver
[ 0.764278] sunxi-ehci sunxi-ehci.1: new USB bus registered, assigned bus number 1
[ 0.772993] sunxi-ehci sunxi-ehci.1: irq 104, io mem 0xf1c1a000
[ 0.790049] sunxi-ehci sunxi-ehci.1: USB 0.0 started, EHCI 1.00
[ 0.797535] hub 1-0:1.0: USB hub found
[ 0.801962] hub 1-0:1.0: 1 port detected
[ 0.806932] sunxi-ehci sunxi-ehci.1: remove, state 1
[ 0.812611] usb usb1: USB disconnect, device number 1
[ 0.819738] sunxi-ehci sunxi-ehci.1: USB bus 1 deregistered
[ 0.836173] ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver
[ 0.863322] sunxi-ohci sunxi-ohci.1: SW USB2.0 'Open' Host Controller (OHCI) Driver
[ 0.871984] sunxi-ohci sunxi-ohci.1: new USB bus registered, assigned bus number 1
[ 0.880617] sunxi-ohci sunxi-ohci.1: irq 105, io mem 0xf1c1a400
[ 0.944639] hub 1-0:1.0: USB hub found
[ 0.949025] hub 1-0:1.0: 1 port detected
[ 0.953899] sunxi-ohci sunxi-ohci.1: remove, state 1
[ 0.959606] usb usb1: USB disconnect, device number 1
[ 0.965919] sunxi-ohci sunxi-ohci.1: USB bus 1 deregistered
[ 0.982434] Initializing USB Mass Storage driver...
[ 0.988025] usbcore: registered new interface driver usb-storage
[ 0.994817] USB Mass Storage support registered.
[ 1.000468] file system registered
[ 1.ion: 2009/09/11
[ 1.013711] android_usb gadget: Number of LUNs=1
[ 1.018928] lun0: LUN: removable file: (no medium)
[ 1.024996] android_usb gadget: android_usb ready
[ 1.030475] sunxikbd_script_init: key para not found, used default para.
[ 1.038932] [RTC] WARNING: Rtc time will be wrong!!
[ 1.044942] sunxi-rtc sunxi-rtc: rtc core: registered sunxi-rtc as rtc0
[ 1.053414] platform reg-20-cs-dcdc2: Driver reg-20-cs-dcdc2 requests probe deferral
[ 1.062316] platform reg-20-cs-dcdc3: Driver reg-20-cs-dcdc3 requests probe deferral
[ 1.071243] platform reg-20-cs-ldo1: Driver reg-20-cs-ldo1 requests probe deferral
[ 1.079928] platform reg-20-cs-ldo2: Driver reg-20-cs-ldo2 requests probe deferral
[ 1.088574] platform reg-20-cs-ldo3: Driver reg-20-cs-ldo3 requests probe deferral
[ 1.097285] platform reg-20-cs-ldo4: Driver reg-20-cs-ldo4 requests probe deferral
[ 1.106003] platform reg-20-cs-ldoio0: Driver reg-20-cs-ldoio0 requests probe deferral
[ 1.114978] sunxi_wdt_init_module: sunxi WatchDog Timer Driver v1.0
[ 1.122336] sunxi_wdt_probe: devm_ioremap return wdt_reg 0xf1c20ca0, res->start 0x01c20ca0, res->end 0x01c20cbf
[ 1.133763] sunxi_wdt_probe: initialized (g_timeout=16s, g_nowayout=0)
[ 1.141424] wdt_enable, write reg 0xf1c20cb8 val 0x00000000
[ 1.147799] wdt_set_tmout, write 0x000000b0 to mode reg 0xf1c20cb8, actual timeout 16 sec
[ 1.159728] sunxi_leds_fetch_sysconfig_para leds is not used in config
[ 1.167160] =========script_get_err============
[ 1.173850] usbcore: registered new interface driver usbhid
[ 1.180177] usbhid: USB HID core driver
[ 1.185205] ashmem: initialized
[ 1.189005] logger: created 256K log 'log_main'
[ 1.194546] logger: created 32K log 'log_events'
[ 1.199989] logger: created 32K log 'log_radio'
[ 1.205289] logger: created 32K log 'log_system'
[ 1.212134] script_get_item return type err, consider it no [ 1.223302] asoc: sndcodec <-> sunxi-codec mapping ok
[ 1.229078] *******************Try sdio*******************
[ 1.237526] TCP: cubic registered
[ 1.241375] NET: Registered protocol family 17
[ 1.246700] VFP support v0.3: [mmc]: *** sunxi_mci_dump_errinfo(L826): smc 0 err, cmd 5, RTO !!
[ 1.256811] ThumbEE CPU extension supported.
[ 1.261772] Registering SWP/SWPB emulation handler
[ 1.267216] *******************Try sd *******************
[ 1.274438] platform reg-20-cs-ldoio0: Driver reg-20-cs-ldoio0 requests probe deferral
[ 1.283496] platform reg-20-cs-ldo4: Driver reg-20-cs-ldo4 requests probe deferral
[ 1.292186] platform reg-20-cs-ldo3: Driver reg-20-cs-ldo3 requests probe deferral
[ 1.300863] platform reg-20-cs-ldo2: Driver reg-20-cs-ldo2 requests probe deferral
[ 1.309390] *******************Try mmc*******************
[ 1.315653] platform reg-20-cs-ldo1: Driver reg-20-cs-ldo1 requests probe deferral
[ 1.324364] platform reg-20-cs-dcdc3: Driver reg-20-cs-dcdc3 requests probe deferral
[ 1.333428] platform reg-20-cs-dcdc2: Driver reg-20-cs-dcdc2 requests probe deferral
[ 1.343458] sunxi-rtc sunxi-rtc: hctosys: unable to read the hardware clock
[ 1.353869] ALSA device list:
[ 1.357372] #0: audiocodec
[ 1.361256] Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(31,3)
[ 1.370763] Backtrace:
[ 1.373699] [<c0013410>] (dump_backtrace+0x0/0x110) from [<c0354410>] (dump_stack+0x18/0x1c)
[ 1.383285] r6:00008000 r5:c183d000 r4:c183d000 r3:00000001
[ 1.390120] [<c03543f8>] (dump_stack+0x0/0x1c) from [<c03547f4>] (panic+0x78/0x1cc)
[ 1.398810] [<c035477c>] (panic+0x0/0x1cc) from [<c047ed20>] (mount_block_root+0x240/0x290)
[ 1.408279] r3:c04c309c r2:00000000 r1:c1821f38 r0:c040405e
[ 1.415052] r7:c049c0b8
[ 1.418059] [<c047eae0>] (mount_block_root+0x0/0x290) from [<c047edc8>] (mount_root+0x58/0x68)
[ 1.427814] [<c047ed70>] (mount_root+0x0/0x68) from [<c047ef08>] (prepare_namespace+0x130/0x190)
[ 1.437757] r5:c049c0c4 r4:c04e6024
[ 1.442033] [<c047edd8>] (prepare_namespace+0x0/0x190) from [<c047e94c>] (kernel_init+0x16c/0x1a8)
[ 1.452166] r5:c049c0b0 r4:00000007
[ 1.456432] [<c047e7e0>] (kernel_init+0x0/0x1a8) from [<c0031df4>] (do_exit+0x0/0x66c)
[ 1.465413] Rebooting in 5 seconds..
离线