接下来编译kernel,编译过程可能会出现缺少命令的报错,大概是下面这几个
sudo apt update
sudo apt install flex bison bc libncurses-dev
目前linux主线的最新版本并没有适配t113的相关外设驱动,虽然能启动并串口打印,但其他的一些外设并没有驱动,还不是可用的状态,所以这里选择全志D1的kernel进行修改。
GitHub - smaeul/linux at d1/allPatches include sunxi platform support and various driver fixes - GitHub - smaeul/linux at d1/allhttps://github.com/smaeul/linux/tree/d1/all
unzip linux-d1-all.zip
cd linux-d1-all
应用awboot提供的linux补丁
- linux/allow_select_d1_ccu_on_t113.patch
- linux/ccu-sun20i-make_cpux_clk_critical_for_t113.patch
- linux/second_core_support_in_platsmp.patch
- linux/d1s_t113_can_bus.patch
在arch\arm\configs\sunxi_defconfig中添加D1时钟
CONFIG_SUN20I_D1_CCU=y
CONFIG_SUN20I_D1_R_CCU=y
添加sun8i-t113.dtsi和sun8i-t113-mangopi-dual.dts设备树配置文件到arch\arm\boot\dts\
在arch\arm\boot\dts\Makefile的line:1389 处,CONFIG_MACH_SUN8I配置中添加sun8i-t113-mangopi-dual.dtb
awboot提供的sun8i-t113-mangopi-dual.dts设备树文件调试终端串口是5,需要改成uart0。
make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabihf- sunxi_defconfig
make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabihf- zImage -j4
make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabihf- dtbs
xfel spinand write 0x40000 arch/arm/boot/dts/sun8i-t113-mangopi-dual.dtb
xfel spinand write 0x80000 arch/arm/boot/zImage
复位,串口成功打印内核信息,目前spinand中还没有文件系统,所以系统无法启动成功。
[I] AWBoot r6143 starting...
[I] SPI-NAND: W25N01GV detected
[I] SPI-NAND: read dt blob of size 22242 at 43.00MB/S
[I] SPI-NAND: read Image of size 5424416 at 49.00MB/S
[I] booting linux...
[ 0.000000] Booting Linux on physical CPU 0x0
[ 0.000000] Linux version 6.1.0-rc3 (wsl@DESKTOP-NQRKTHB) (arm-none-linux-gnueabihf-gcc (Arm GNU Toolchain 12.2.Rel1 (Build arm-12.24)) 12.2.1 20221205, GNU ld (Arm GNU Toolchain 12.2.Rel1 (Build arm-12.24)) 2.39.0.20221210) #7 SMP Fri Dec 30 18:52:12 CST 2022
[ 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: MangoPi MQ-Dual
[ 0.000000] Memory policy: Data cache writealloc
[ 0.000000] cma: Reserved 16 MiB at 0x47000000
[ 0.000000] Zone ranges:
[ 0.000000] Normal [mem 0x0000000040000000-0x0000000047ffffff]
[ 0.000000] HighMem empty
[ 0.000000] Movable zone start for each node
[ 0.000000] Early memory node ranges
[ 0.000000] node 0: [mem 0x0000000040000000-0x0000000047ffffff]
[ 0.000000] Initmem setup node 0 [mem 0x0000000040000000-0x0000000047ffffff]
[ 0.000000] percpu: Embedded 11 pages/cpu s15764 r8192 d21100 u45056
[ 0.000000] Built 1 zonelists, mobility grouping on. Total pages: 32512
[ 0.000000] Kernel command line: mem=128M ubi.mtd=3 rootfstype=ubifs root=ubi0:rootfs rw rootwait console=ttyS0,115200
[ 0.000000] Dentry cache hash table entries: 16384 (order: 4, 65536 bytes, linear)
[ 0.000000] Inode-cache hash table entries: 8192 (order: 3, 32768 bytes, linear)
[ 0.000000] mem auto-init: stack:all(zero), heap alloc:off, heap free:off
[ 0.000000] Memory: 99804K/131072K available (8192K kernel code, 952K rwdata, 2188K rodata, 1024K init, 270K bss, 14884K reserved, 16384K cma-reserved, 0K highmem)
[ 0.000000] SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=2, Nodes=1
[ 0.000000] rcu: Hierarchical RCU implementation.
[ 0.000000] rcu: RCU restricting CPUs from NR_CPUS=8 to nr_cpu_ids=2.
[ 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=2
[ 0.000000] NR_IRQS: 16, nr_irqs: 16, preallocated irqs: 16
[ 0.000000] rcu: srcu_init: Setting srcu_struct sizes based on contention.
[ 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.000001] sched_clock: 56 bits at 24MHz, resolution 41ns, wraps every 4398046511097ns
[ 0.000013] Switching to timer-based delay loop, resolution 41ns
[ 0.000187] clocksource: timer: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 79635851949 ns
[ 0.000685] Console: colour dummy device 80x30
[ 0.000729] Calibrating delay loop (skipped), value calculated using timer frequency.. 48.00 BogoMIPS (lpj=240000)
[ 0.000744] pid_max: default: 32768 minimum: 301
[ 0.000903] Mount-cache hash table entries: 1024 (order: 0, 4096 bytes, linear)
[ 0.000918] Mountpoint-cache hash table entries: 1024 (order: 0, 4096 bytes, linear)
[ 0.001466] CPU: Testing write buffer coherency: ok
[ 0.001776] /cpus/cpu@0 missing clock-frequency property
[ 0.001806] /cpus/cpu@1 missing clock-frequency property
[ 0.001817] CPU0: thread -1, cpu 0, socket 0, mpidr 80000000
[ 0.002592] Setting up static identity map for 0x40100000 - 0x40100060
[ 0.002736] rcu: Hierarchical SRCU implementation.
[ 0.002743] rcu: Max phase no-delay instances is 1000.
[ 0.003267] smp: Bringing up secondary CPUs ...
[ 0.003968] CPU1: thread -1, cpu 1, socket 0, mpidr 80000001
[ 0.004097] smp: Brought up 1 node, 2 CPUs
[ 0.004108] SMP: Total of 2 processors activated (96.00 BogoMIPS).
[ 0.004116] CPU: All CPU(s) started in SVC mode.
[ 0.004636] devtmpfs: initialized
[ 0.008729] VFP support v0.3: implementor 41 architecture 2 part 30 variant 7 rev 5
[ 0.008927] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 19112604462750000 ns
[ 0.008954] futex hash table entries: 512 (order: 3, 32768 bytes, linear)
[ 0.009552] pinctrl core: initialized pinctrl subsystem
[ 0.010921] NET: Registered PF_NETLINK/PF_ROUTE protocol family
[ 0.011973] DMA: preallocated 256 KiB pool for atomic coherent allocations
[ 0.012788] thermal_sys: Registered thermal governor 'step_wise'
[ 0.012965] hw-breakpoint: found 5 (+1 reserved) breakpoint and 4 watchpoint registers.
[ 0.012977] hw-breakpoint: maximum watchpoint size is 8 bytes.
[ 0.020813] platform 5460000.tcon-top: Fixing up cyclic dependency with 5200000.mixer
[ 0.020879] platform 5460000.tcon-top: Fixing up cyclic dependency with 5100000.mixer
[ 0.021147] platform 5461000.lcd-controller: Fixing up cyclic dependency with 5460000.tcon-top
[ 0.021496] platform 5470000.lcd-controller: Fixing up cyclic dependency with 5604000.tv-encoder
[ 0.021552] platform 5470000.lcd-controller: Fixing up cyclic dependency with 5460000.tcon-top
[ 0.022299] platform 7090000.rtc: Fixing up cyclic dependency with 7010000.clock-controller
[ 0.032144] SCSI subsystem initialized
[ 0.032631] usbcore: registered new interface driver usbfs
[ 0.032668] usbcore: registered new interface driver hub
[ 0.032704] usbcore: registered new device driver usb
[ 0.032895] mc: Linux media interface: v0.10
[ 0.032937] videodev: Linux video capture interface: v2.00
[ 0.033021] pps_core: LinuxPPS API ver. 1 registered
[ 0.033027] pps_core: Software ver. 5.3.6 - Copyright 2005-2007 Rodolfo Giometti <giometti@linux.it>
[ 0.033043] PTP clock support registered
[ 0.033457] Advanced Linux Sound Architecture Driver Initialized.
[ 0.034305] clocksource: Switched to clocksource arch_sys_counter
[ 0.041567] NET: Registered PF_INET protocol family
[ 0.041769] IP idents hash table entries: 2048 (order: 2, 16384 bytes, linear)
[ 0.042309] tcp_listen_portaddr_hash hash table entries: 512 (order: 0, 4096 bytes, linear)
[ 0.042333] Table-perturb hash table entries: 65536 (order: 6, 262144 bytes, linear)
[ 0.042345] TCP established hash table entries: 1024 (order: 0, 4096 bytes, linear)
[ 0.042361] TCP bind hash table entries: 1024 (order: 2, 16384 bytes, linear)
[ 0.042396] TCP: Hash tables configured (established 1024 bind 1024)
[ 0.042483] UDP hash table entries: 256 (order: 1, 8192 bytes, linear)
[ 0.042516] UDP-Lite hash table entries: 256 (order: 1, 8192 bytes, linear)
[ 0.042672] NET: Registered PF_UNIX/PF_LOCAL protocol family
[ 0.043362] RPC: Registered named UNIX socket transport module.
[ 0.043375] RPC: Registered udp transport module.
[ 0.043378] RPC: Registered tcp transport module.
[ 0.043382] RPC: Registered tcp NFSv4.1 backchannel transport module.
[ 0.044740] workingset: timestamp_bits=30 max_order=15 bucket_order=0
[ 0.049688] NFS: Registering the id_resolver key type
[ 0.049743] Key type id_resolver registered
[ 0.049748] Key type id_legacy registered
[ 0.049910] Block layer SCSI generic (bsg) driver version 0.4 loaded (major 246)
[ 0.049919] io scheduler mq-deadline registered
[ 0.049925] io scheduler kyber registered
[ 0.110062] Serial: 8250/16550 driver, 8 ports, IRQ sharing disabled
[ 0.120343] CAN device driver interface
[ 0.123619] sun6i-rtc 7090000.rtc: registered as rtc0
[ 0.123743] sun6i-rtc 7090000.rtc: setting system clock to 1970-01-02T00:01:57 UTC (86517)
[ 0.123898] sun6i-rtc 7090000.rtc: RTC enabled
[ 0.124274] i2c_dev: i2c /dev entries driver
[ 0.126297] sunxi-wdt 20500a0.watchdog: Watchdog enabled (timeout=16 sec, nowayout=0)
[ 0.127485] sun8i-ce 3040000.crypto: Set mod clock to 300000000 (300 Mhz) from 400000000 (400 Mhz)
[ 0.127851] sun8i-ce 3040000.crypto: will run requests pump with realtime priority
[ 0.128180] sun8i-ce 3040000.crypto: will run requests pump with realtime priority
[ 0.128389] sun8i-ce 3040000.crypto: will run requests pump with realtime priority
[ 0.128567] sun8i-ce 3040000.crypto: will run requests pump with realtime priority
[ 0.128715] sun8i-ce 3040000.crypto: Register cbc(aes)
[ 0.128742] sun8i-ce 3040000.crypto: Register ecb(aes)
[ 0.128753] sun8i-ce 3040000.crypto: Register cbc(des3_ede)
[ 0.128761] sun8i-ce 3040000.crypto: Register ecb(des3_ede)
[ 0.128790] sun8i-ce 3040000.crypto: CryptoEngine Die ID 0
[ 0.129660] usbcore: registered new interface driver usbhid
[ 0.129671] usbhid: USB HID core driver
[ 0.132334] NET: Registered PF_PACKET protocol family
[ 0.132349] can: controller area network core
[ 0.132414] NET: Registered PF_CAN protocol family
[ 0.132422] can: raw protocol
[ 0.132428] can: broadcast manager protocol
[ 0.132437] can: netlink gateway - max_hops=1
[ 0.132536] Key type dns_resolver registered
[ 0.132624] Registering SWP/SWPB emulation handler
[ 0.153531] sun20i-d1-pinctrl 2000000.pinctrl: initialized sunXi PIO driver
[ 0.154838] printk: console [ttyS0] disabled
[ 0.175117] 2500000.serial: ttyS0 at MMIO 0x2500000 (irq = 231, base_baud = 1500000) is a 16550A
[ 0.982678] printk: console [ttyS0] enabled
[ 0.989524] spi-nand spi0.0: Winbond SPI NAND was found.
[ 0.994905] spi-nand spi0.0: 128 MiB, block size: 128 KiB, page size: 2048, OOB size: 64
[ 1.003735] 4 fixed-partitions partitions found on MTD device spi0.0
[ 1.010126] Creating 4 MTD partitions on "spi0.0":
[ 1.014929] 0x000000000000-0x000000040000 : "awboot"
[ 1.020734] 0x000000040000-0x000000080000 : "dtb"
[ 1.026242] 0x000000080000-0x000000800000 : "kernel"
[ 1.040692] 0x000000800000-0x000008000000 : "rootfs"
[ 1.196327] phy phy-4100400.phy.0: Changing dr_mode to 1
[ 1.197449] usb_phy_generic usb_phy_generic.1.auto: dummy supplies not allowed for exclusive requests
[ 1.201666] ehci-platform 4101000.usb: EHCI Host Controller
[ 1.211437] musb-hdrc musb-hdrc.2.auto: MUSB HDRC host driver
[ 1.216521] ehci-platform 4101000.usb: new USB bus registered, assigned bus number 1
[ 1.222258] musb-hdrc musb-hdrc.2.auto: new USB bus registered, assigned bus number 2
[ 1.231036] ehci-platform 4200000.usb: EHCI Host Controller
[ 1.238618] hub 2-0:1.0: USB hub found
[ 1.245347] ohci-platform 4200400.usb: Generic Platform OHCI controller
[ 1.247320] hub 2-0:1.0: 1 port detected
[ 1.257869] ehci-platform 4101000.usb: irq 233, io mem 0x04101000
[ 1.264003] ehci-platform 4200000.usb: new USB bus registered, assigned bus number 3
[ 1.271865] ohci-platform 4200400.usb: new USB bus registered, assigned bus number 4
[ 1.276328] ubi0: attaching mtd3
[ 1.283122] ehci-platform 4200000.usb: irq 235, io mem 0x04200000
[ 1.289344] ehci-platform 4101000.usb: USB 2.0 started, EHCI 1.00
[ 1.289449] ohci-platform 4200400.usb: irq 237, io mem 0x04200400
[ 1.302048] hub 1-0:1.0: USB hub found
[ 1.302066] sunxi-mmc 4020000.mmc: Got CD GPIO
[ 1.306205] hub 1-0:1.0: 1 port detected
[ 1.324365] ehci-platform 4200000.usb: USB 2.0 started, EHCI 1.00
[ 1.331672] hub 3-0:1.0: USB hub found
[ 1.334613] sunxi-mmc 4020000.mmc: initialized, max. request size: 2047 KB, uses new timings mode
[ 1.335864] hub 3-0:1.0: 1 port detected
[ 1.369028] hub 4-0:1.0: USB hub found
[ 1.373134] hub 4-0:1.0: 1 port detected
[ 1.444413] ohci-platform 4101400.usb: Generic Platform OHCI controller
[ 1.451108] ohci-platform 4101400.usb: new USB bus registered, assigned bus number 5
[ 1.459159] ohci-platform 4101400.usb: irq 236, io mem 0x04101400
[ 1.539220] hub 5-0:1.0: USB hub found
[ 1.543024] hub 5-0:1.0: 1 port detected
[ 1.634337] random: crng init done
[ 1.752292] ubi0: scanning is finished
[ 1.756075] ubi0: empty MTD device detected
[ 1.780913] ubi0: attached mtd3 (name "rootfs", size 120 MiB)
[ 1.786721] ubi0: PEB size: 131072 bytes (128 KiB), LEB size: 126976 bytes
[ 1.793593] ubi0: min./max. I/O unit sizes: 2048/2048, sub-page size 2048
[ 1.800387] ubi0: VID header offset: 2048 (aligned 2048), data offset: 4096
[ 1.807350] ubi0: good PEBs: 960, bad PEBs: 0, corrupted PEBs: 0
[ 1.813351] ubi0: user volume: 0, internal volumes: 1, max. volumes count: 128
[ 1.820582] ubi0: max/mean erase counter: 0/0, WL threshold: 4096, image sequence number: 434364822
[ 1.829631] ubi0: available PEBs: 936, total reserved PEBs: 24, PEBs reserved for bad PEB handling: 20
[ 1.838948] ubi0: background thread "ubi_bgt0d" started, PID 84
[ 1.839303] ALSA device list:
[ 1.847860] No soundcards found.
[ 1.851862] VFS: Cannot open root device "ubi0:rootfs" or unknown-block(0,0): error -19
[ 1.859912] Please append a correct "root=" boot option; here are the available partitions:
[ 1.868283] Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(0,0)
[ 1.876543] CPU: 1 PID: 1 Comm: swapper/0 Not tainted 6.1.0-rc3 #7
[ 1.882722] Hardware name: Generic DT based system
[ 1.887517] unwind_backtrace from show_stack+0x10/0x14
[ 1.892758] show_stack from dump_stack_lvl+0x40/0x4c
[ 1.897817] dump_stack_lvl from panic+0x108/0x2fc
[ 1.902615] panic from mount_block_root+0x174/0x20c
[ 1.907585] mount_block_root from prepare_namespace+0x9c/0x18c
[ 1.913505] prepare_namespace from kernel_init+0x18/0x12c
[ 1.918993] kernel_init from ret_from_fork+0x14/0x2c
[ 1.924047] Exception stack(0xc8815fb0 to 0xc8815ff8)
[ 1.929097] 5fa0: 00000000 00000000 00000000 00000000
[ 1.937266] 5fc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[ 1.945434] 5fe0: 00000000 00000000 00000000 00000000 00000013 00000000
[ 1.952045] CPU0: stopping
[ 1.954760] CPU: 0 PID: 84 Comm: ubi_bgt0d Not tainted 6.1.0-rc3 #7
[ 1.961022] Hardware name: Generic DT based system
[ 1.965808] unwind_backtrace from show_stack+0x10/0x14
[ 1.971037] show_stack from dump_stack_lvl+0x40/0x4c
[ 1.976089] dump_stack_lvl from do_handle_IPI+0xec/0x124
[ 1.981489] do_handle_IPI from ipi_handler+0x18/0x20
[ 1.986542] ipi_handler from handle_percpu_devid_irq+0x78/0x134
[ 1.992552] handle_percpu_devid_irq from generic_handle_domain_irq+0x28/0x38
[ 1.999691] generic_handle_domain_irq from gic_handle_irq+0x74/0x88
[ 2.006050] gic_handle_irq from generic_handle_arch_irq+0x34/0x44
[ 2.012230] generic_handle_arch_irq from call_with_stack+0x18/0x20
[ 2.018502] call_with_stack from __irq_svc+0x98/0xb0
[ 2.023558] Exception stack(0xc8b85918 to 0xc8b85960)
[ 2.028604] 5900: 047868c0 0000000e
[ 2.036772] 5920: 059dd8f2 00000000 05f5e100 05f5e100 00000010 0000000e 00000008 047868c0
[ 2.044940] 5940: 00000008 23c34600 c049cc30 c8b85968 c049ccc8 c0882338 20000013 ffffffff
[ 2.053105] __irq_svc from __aeabi_uidiv+0x0/0x9c
[ 2.057898] __aeabi_uidiv from ccu_mp_round_rate+0x98/0x2d8
[ 2.063560] ccu_mp_round_rate from ccu_mux_helper_determine_rate+0xb8/0x1f8
[ 2.070611] ccu_mux_helper_determine_rate from ccu_mp_determine_rate+0x28/0x30
[ 2.077919] ccu_mp_determine_rate from clk_core_set_rate_nolock+0x60/0x294
[ 2.084883] clk_core_set_rate_nolock from clk_set_rate+0x30/0x154
[ 2.091065] clk_set_rate from sun6i_spi_transfer_one+0x548/0x6e4
[ 2.097166] sun6i_spi_transfer_one from spi_transfer_one_message+0x284/0x65c
[ 2.104306] spi_transfer_one_message from __spi_pump_transfer_message+0x2ec/0x4f8
[ 2.111876] __spi_pump_transfer_message from __spi_sync+0x244/0x2e4
[ 2.118232] __spi_sync from spi_sync+0x24/0x3c
[ 2.122767] spi_sync from spi_mem_exec_op+0x280/0x3d8
[ 2.127910] spi_mem_exec_op from spinand_write_page+0x1c4/0x224
[ 2.133920] spinand_write_page from spinand_mtd_write+0x14c/0x268
[ 2.140098] spinand_mtd_write from mtd_write+0x60/0x8c
[ 2.145327] mtd_write from ubi_io_write+0x10c/0x610
[ 2.150299] ubi_io_write from ubi_io_write_ec_hdr+0xd4/0x134
[ 2.156050] ubi_io_write_ec_hdr from sync_erase+0x90/0x1d0
[ 2.161630] sync_erase from __erase_worker+0x2c/0x47c
[ 2.166775] __erase_worker from erase_worker+0x14/0x64
[ 2.172007] erase_worker from do_work+0x9c/0x11c
[ 2.176718] do_work from ubi_thread+0xf8/0x19c
[ 2.181257] ubi_thread from kthread+0xd0/0xec
[ 2.185713] kthread from ret_from_fork+0x14/0x2c
[ 2.190420] Exception stack(0xc8b85fb0 to 0xc8b85ff8)
[ 2.195468] 5fa0: 00000000 00000000 00000000 00000000
[ 2.203637] 5fc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[ 2.211803] 5fe0: 00000000 00000000 00000000 00000000 00000013 00000000
[ 2.218414] ---[ end Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(0,0) ]---