MangoPi Dual T113 主线内核编译记录
-
awboot 编译(无需 SPL UBOOT 直接引导内核)
# 交叉编译器需使用 arm-none-eabi-gcc 以下是我交叉编译器的版本 gcc version 8.3.1 20190703 (release) [gcc-8-branch revision 273027] (GNU Tools for Arm Embedded Processors 8-2019-q3-update) # 下拉 awboot git clone https://github.com/szemzoa/awboot cd awboot # 编译工具 cd tools gcc mksunxi.c -o mksunxi # 修改 Makefile 中的 /bin/expr 为 /usr/bin/expr @/usr/bin/expr `/bin/cat .build_revision` + 1 > .build_revision # 编译 awboot make
测试 awboot
xfel write 0x30000 .\awboot.bin xfel exec 0x30000
写入 awboot 到 TF 卡
- 修改链接地址:arch/arm32/mach-t113s3/link.ld 文件中 ORIGIN = 0x00030000 修改为 ORIGIN = 0x00020000
- 修改完链接地址后需要清除重新编译
make clean all
- 写入到 TF 卡中:
sudo dd if=awboot.bin of=/dev/sdd bs=1024 seek=8
内核编译
- 这个是我修改好的主线稳定版内核(带WiFi):Linux-6.0.1
- 也选择去官网下载内核:kernel
- 修改 kernel.org 下载的内核源代码:
# 修改 drivers/clk/sunxi-ng/Kconfig 文件 config SUN20I_D1_CCU tristate "Support for the Allwinner D1 CCU" default RISCV && ARCH_SUNXI - depends on (RISCV && ARCH_SUNXI) || COMPILE_TEST + depends on (ARCH_SUNXI) || COMPILE_TEST config SUN20I_D1_R_CCU tristate "Support for the Allwinner D1 PRCM CCU" default RISCV && ARCH_SUNXI - depends on (RISCV && ARCH_SUNXI) || COMPILE_TEST + depends on (ARCH_SUNXI) || COMPILE_TEST # 修改 drivers/clk/sunxi-ng/ccu-sun20i-d1.c 文件 static SUNXI_CCU_MUX_DATA(cpux_clk, "cpux", cpux_parents, - 0x500, 24, 3, CLK_SET_RATE_PARENT); + 0x500, 24, 3, CLK_SET_RATE_PARENT | CLK_IS_CRITICAL); # 修改 arch/arm/mach-sunxi/platsmp.c 文件,在末尾添加以下内容 static int sun8i_t113_smp_boot_secondary(unsigned int cpu, struct task_struct *idle) { u32 reg; void __iomem *cpucfg_membase = ioremap(0x09010000, 0x10); void __iomem *cpuexec_membase[] = {ioremap(0x070005C4, 0x10),ioremap(0x070005C8, 0x10)}; if (cpu != 1) return 0; spin_lock(&cpu_lock); /* Set CPU boot address */ writel(__pa_symbol(secondary_startup), cpuexec_membase[cpu]); /* Deassert the CPU core reset */ reg = readl(cpucfg_membase); writel(reg | BIT(cpu), cpucfg_membase); spin_unlock(&cpu_lock); return 0; } static const struct smp_operations sun8i_t113_smp_ops __initconst = { .smp_boot_secondary = sun8i_t113_smp_boot_secondary, }; CPU_METHOD_OF_DECLARE(sun8i_t113_smp, "allwinner,sun8iw20p1", &sun8i_t113_smp_ops);
配置内核
- 先使用默认配置
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- sunxi_defconfig
- 再打开内核配置
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- menuconfig
- 打开芯片时钟支持:
> Device Drivers > Common Clock Framework <*> Clock support for Allwinner SoCs <*> Support for the Allwinner D1 CCU <*> Support for the Allwinner D1 PRCM CCU
添加设备树
- 将设备树添加到内核 arch/arm/boot/dts/ 目录中:sun8i-t113-mangopi-dual.dts sun8i-t113.dtsi
- 并在该目录 Makefile 文件中的CONFIG_MACH_SUN8I下添加改设备树文件:
dtb-$(CONFIG_MACH_SUN8I) += \ sun8i-a23-evb.dtb \ sun8i-a23-gt90h-v4.dtb \ sun8i-a23-inet86dz.dtb \ ..................... sun8i-v3s-licheepi-zero-dock.dtb \ sun8i-v40-bananapi-m2-berry.dtb \ sun8i-t113-mangopi-dual.dtb
编译
# 编译内核,设备树以及模块 make -j48 ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- zImage dtbs modules # 内核文件 arch/arm/boot/zImage # 设备树文件 arch/arm/boot/dts/sun8i-t113-mangopi-dual.dtb
启动日志
Allwinner T113-loader DRAM SIZE = 128M DRAM simple test OK. CPU freq=1200 MHz SD/MMC card at 'sdhci0' controller found SD/MMC: Image: Read file zImage addr=45000000 SD/MMC: dt blob: Read file sun8i-t113-mangopi-dual.dtb addr=41800000 booting linux... [ 0.000000] Booting Linux on physical CPU 0x0 [ 0.000000] Linux version 6.0.1-g75e3c08038b8 (evler@DESKTOP-6BPS301) (arm-linux-gnueabihf-gcc (Ubuntu/Linaro 7.5.0-3ubuntu1~18.04) 7.5.0, GNU ld (GNU Binutils for Ubuntu) 2.30) #1 SMP Fri Oct 14 20:36:14 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 72 MiB at 0x43800000 [ 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 s15508 r8192 d21356 u45056 [ 0.000000] Built 1 zonelists, mobility grouping on. Total pages: 32512 [ 0.000000] Kernel command line: mem=128M cma=72M root=/dev/mmcblk0p2 init=/sbin/init rootwait console=tty0 console=ttyS5,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:off, heap alloc:off, heap free:off [ 0.000000] Memory: 43384K/131072K available (7168K kernel code, 942K rwdata, 2104K rodata, 1024K init, 266K bss, 13960K reserved, 73728K 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.000189] clocksource: timer: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 79635851949 ns [ 0.000686] Console: colour dummy device 80x30 [ 0.000998] printk: console [tty0] enabled [ 0.001042] Calibrating delay loop (skipped), value calculated using timer frequency.. 48.00 BogoMIPS (lpj=240000) [ 0.001071] pid_max: default: 32768 minimum: 301 [ 0.001240] Mount-cache hash table entries: 1024 (order: 0, 4096 bytes, linear) [ 0.001276] Mountpoint-cache hash table entries: 1024 (order: 0, 4096 bytes, linear) [ 0.001835] CPU: Testing write buffer coherency: ok [ 0.002166] /cpus/cpu@0 missing clock-frequency property [ 0.002215] /cpus/cpu@1 missing clock-frequency property [ 0.002237] CPU0: thread -1, cpu 0, socket 0, mpidr 80000000 [ 0.003020] Setting up static identity map for 0x40100000 - 0x40100060 [ 0.003193] rcu: Hierarchical SRCU implementation. [ 0.003213] rcu: Max phase no-delay instances is 1000. [ 0.003749] smp: Bringing up secondary CPUs ... [ 0.004454] CPU1: thread -1, cpu 1, socket 0, mpidr 80000001 [ 0.004581] smp: Brought up 1 node, 2 CPUs [ 0.004622] SMP: Total of 2 processors activated (96.00 BogoMIPS). [ 0.004638] CPU: All CPU(s) started in SVC mode. [ 0.005159] devtmpfs: initialized [ 0.009273] VFP support v0.3: implementor 41 architecture 2 part 30 variant 7 rev 5 [ 0.009513] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 19112604462750000 ns [ 0.009556] futex hash table entries: 512 (order: 3, 32768 bytes, linear) [ 0.011856] pinctrl core: initialized pinctrl subsystem [ 0.013201] NET: Registered PF_NETLINK/PF_ROUTE protocol family [ 0.014339] DMA: preallocated 256 KiB pool for atomic coherent allocations [ 0.015229] thermal_sys: Registered thermal governor 'step_wise' [ 0.015529] hw-breakpoint: found 5 (+1 reserved) breakpoint and 4 watchpoint registers. [ 0.015578] hw-breakpoint: maximum watchpoint size is 8 bytes. [ 0.023287] platform 5460000.tcon-top: Fixing up cyclic dependency with 5200000.mixer [ 0.023396] platform 5460000.tcon-top: Fixing up cyclic dependency with 5100000.mixer [ 0.023705] platform 5461000.lcd-controller: Fixing up cyclic dependency with 5460000.tcon-top [ 0.024089] platform 5470000.lcd-controller: Fixing up cyclic dependency with 5604000.tv-encoder [ 0.024169] platform 5470000.lcd-controller: Fixing up cyclic dependency with 5460000.tcon-top [ 0.025007] platform 7090000.rtc: Fixing up cyclic dependency with 7010000.clock-controller [ 0.035143] SCSI subsystem initialized [ 0.035656] usbcore: registered new interface driver usbfs [ 0.035715] usbcore: registered new interface driver hub [ 0.035764] usbcore: registered new device driver usb [ 0.035998] mc: Linux media interface: v0.10 [ 0.036059] videodev: Linux video capture interface: v2.00 [ 0.036145] pps_core: LinuxPPS API ver. 1 registered [ 0.036162] pps_core: Software ver. 5.3.6 - Copyright 2005-2007 Rodolfo Giometti <giometti@linux.it> [ 0.036192] PTP clock support registered [ 0.036650] Advanced Linux Sound Architecture Driver Initialized. [ 0.037823] clocksource: Switched to clocksource arch_sys_counter [ 0.045181] NET: Registered PF_INET protocol family [ 0.045408] IP idents hash table entries: 2048 (order: 2, 16384 bytes, linear) [ 0.045967] tcp_listen_portaddr_hash hash table entries: 512 (order: 0, 4096 bytes, linear) [ 0.046019] Table-perturb hash table entries: 65536 (order: 6, 262144 bytes, linear) [ 0.046044] TCP established hash table entries: 1024 (order: 0, 4096 bytes, linear) [ 0.046076] TCP bind hash table entries: 1024 (order: 1, 8192 bytes, linear) [ 0.046105] TCP: Hash tables configured (established 1024 bind 1024) [ 0.046201] UDP hash table entries: 256 (order: 1, 8192 bytes, linear) [ 0.046248] UDP-Lite hash table entries: 256 (order: 1, 8192 bytes, linear) [ 0.046434] NET: Registered PF_UNIX/PF_LOCAL protocol family [ 0.047125] RPC: Registered named UNIX socket transport module. [ 0.047166] RPC: Registered udp transport module. [ 0.047180] RPC: Registered tcp transport module. [ 0.047192] RPC: Registered tcp NFSv4.1 backchannel transport module. [ 0.048343] Initialise system trusted keyrings [ 0.048634] workingset: timestamp_bits=30 max_order=15 bucket_order=0 [ 0.053533] NFS: Registering the id_resolver key type [ 0.053617] Key type id_resolver registered [ 0.053634] Key type id_legacy registered [ 0.053689] Key type asymmetric registered [ 0.053705] Asymmetric key parser 'x509' registered [ 0.053840] Block layer SCSI generic (bsg) driver version 0.4 loaded (major 246) [ 0.053866] io scheduler mq-deadline registered [ 0.053879] io scheduler kyber registered [ 0.112158] Serial: 8250/16550 driver, 8 ports, IRQ sharing disabled [ 0.121805] CAN device driver interface [ 0.122573] ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver [ 0.122600] ehci-platform: EHCI generic platform driver [ 0.122740] ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver [ 0.122778] ohci-platform: OHCI generic platform driver [ 0.125187] sun6i-rtc 7090000.rtc: registered as rtc0 [ 0.125338] sun6i-rtc 7090000.rtc: setting system clock to 1970-01-02T00:10:37 UTC (87037) [ 0.125500] sun6i-rtc 7090000.rtc: RTC enabled [ 0.125852] i2c_dev: i2c /dev entries driver [ 0.127617] sunxi-wdt 20500a0.watchdog: Watchdog enabled (timeout=16 sec, nowayout=0) [ 0.128870] sun8i-ce 3040000.crypto: Set mod clock to 300000000 (300 Mhz) from 400000000 (400 Mhz) [ 0.129231] sun8i-ce 3040000.crypto: will run requests pump with realtime priority [ 0.129586] sun8i-ce 3040000.crypto: will run requests pump with realtime priority [ 0.129826] sun8i-ce 3040000.crypto: will run requests pump with realtime priority [ 0.130039] sun8i-ce 3040000.crypto: will run requests pump with realtime priority [ 0.130195] sun8i-ce 3040000.crypto: Register cbc(aes) [ 0.130230] sun8i-ce 3040000.crypto: Register ecb(aes) [ 0.130249] sun8i-ce 3040000.crypto: Register cbc(des3_ede) [ 0.130268] sun8i-ce 3040000.crypto: Register ecb(des3_ede) [ 0.130307] sun8i-ce 3040000.crypto: CryptoEngine Die ID 0 [ 0.131201] usbcore: registered new interface driver usbhid [ 0.131233] usbhid: USB HID core driver [ 0.133879] NET: Registered PF_PACKET protocol family [ 0.133934] can: controller area network core [ 0.134023] NET: Registered PF_CAN protocol family [ 0.134045] can: raw protocol [ 0.134058] can: broadcast manager protocol [ 0.134075] can: netlink gateway - max_hops=1 [ 0.134293] Key type dns_resolver registered [ 0.134448] Registering SWP/SWPB emulation handler [ 0.134555] Loading compiled-in X.509 certificates [ 0.152533] sun20i-d1-pinctrl 2000000.pinctrl: initialized sunXi PIO driver [ 0.174214] 2500400.serial: ttyS1 at MMIO 0x2500400 (irq = 231, base_baud = 1500000) is a 16550A [ 0.195942] 2501400.serial: ttyS5 at MMIO 0x2501400 (irq = 232, base_baud = 1500000) is a 16550A [ 1.049330] printk: console [ttyS5] enabled [ 1.055564] phy phy-4100400.phy.0: Changing dr_mode to 1 [ 1.056783] usb_phy_generic usb_phy_generic.1.auto: dummy supplies not allowed for exclusive requests [ 1.060995] ehci-platform 4101000.usb: EHCI Host Controller [ 1.070724] musb-hdrc musb-hdrc.2.auto: MUSB HDRC host driver [ 1.075755] ehci-platform 4101000.usb: new USB bus registered, assigned bus number 1 [ 1.081516] musb-hdrc musb-hdrc.2.auto: new USB bus registered, assigned bus number 2 [ 1.090282] ehci-platform 4200000.usb: EHCI Host Controller [ 1.097935] hub 2-0:1.0: USB hub found [ 1.104550] ohci-platform 4200400.usb: Generic Platform OHCI controller [ 1.106450] hub 2-0:1.0: 1 port detected [ 1.117184] ehci-platform 4101000.usb: irq 233, io mem 0x04101000 [ 1.123361] ehci-platform 4200000.usb: new USB bus registered, assigned bus number 3 [ 1.127942] ohci-platform 4200400.usb: new USB bus registered, assigned bus number 4 [ 1.140803] ehci-platform 4200000.usb: irq 235, io mem 0x04200000 [ 1.147129] sunxi-mmc 4020000.mmc: Got CD GPIO [ 1.148376] ehci-platform 4101000.usb: USB 2.0 started, EHCI 1.00 [ 1.157972] ohci-platform 4200400.usb: irq 237, io mem 0x04200400 [ 1.159104] ALSA device list: [ 1.167091] No soundcards found. [ 1.171251] sunxi-mmc 4021000.mmc: allocated mmc-pwrseq [ 1.176832] hub 1-0:1.0: USB hub found [ 1.177242] sunxi-mmc 4020000.mmc: initialized, max. request size: 2048 KB, uses new timings mode [ 1.180665] ehci-platform 4200000.usb: USB 2.0 started, EHCI 1.00 [ 1.195722] hub 1-0:1.0: 1 port detected [ 1.200970] hub 3-0:1.0: USB hub found [ 1.204802] hub 3-0:1.0: 1 port detected [ 1.212314] sunxi-mmc 4021000.mmc: initialized, max. request size: 2048 KB, uses new timings mode [ 1.229522] sunxi-mmc 4021000.mmc: card claims to support voltages below defined range [ 1.232548] hub 4-0:1.0: USB hub found [ 1.241326] hub 4-0:1.0: 1 port detected [ 1.257235] mmc1: new high speed SDIO card at address 0001 [ 1.284358] mmc0: new high speed SDHC card at address aaaa [ 1.290803] mmcblk0: mmc0:aaaa SL32G 29.7 GiB [ 1.300997] mmcblk0: p1 p2 [ 1.307944] ohci-platform 4101400.usb: Generic Platform OHCI controller [ 1.314620] ohci-platform 4101400.usb: new USB bus registered, assigned bus number 5 [ 1.322709] ohci-platform 4101400.usb: irq 236, io mem 0x04101400 [ 1.402615] hub 5-0:1.0: USB hub found [ 1.406430] hub 5-0:1.0: 1 port detected [ 1.443652] EXT4-fs (mmcblk0p2): mounted filesystem with ordered data mode. Quota mode: disabled. [ 1.452694] VFS: Mounted root (ext4 filesystem) readonly on device 179:2. [ 1.467648] devtmpfs: mounted [ 1.471630] Freeing unused kernel image (initmem) memory: 1024K [ 1.478021] Run /sbin/init as init process [ 1.840340] EXT4-fs (mmcblk0p2): re-mounted. Quota mode: disabled. Starting syslogd: OK Starting klogd: OK Running sysctl: OK Starting mdev... OK [ 2.771703] cfg80211: Loading compiled-in X.509 certificates for regulatory database [ 2.815733] cfg80211: Loaded X.509 cert 'sforshee: 00b28ddf47aef9cea7' Initializing random number generator: OK Saving random seed: [ 5.777828] random: crng init done OK Starting system message bus: done Starting network: OK Starting WiFi: Successfully initialized wpa_supplicant OK udhcpc: started, v1.35.0 udhcpc: broadcasting discover Starting sshd: OK Welcome to MangoPi Dual buildroot login: root [root@buildroot]:~$ udhcpc: broadcasting discover udhcpc: broadcasting select for 192.168.10.211, server 192.168.10.251 udhcpc: lease of 192.168.10.211 obtained from 192.168.10.251, lease time 43200 deleting routers adding dns 192.168.10.251 [root@buildroot]:~$ free -h total used free shared buff/cache available Mem: 115.4M 12.7M 79.8M 60.0K 22.8M 97.0M Swap: 0 0 0 [root@buildroot]:~$ df -h Filesystem Size Used Available Use% Mounted on /dev/root 29.0G 21.8M 27.4G 0% / devtmpfs 21.2M 0 21.2M 0% /dev tmpfs 57.7M 0 57.7M 0% /dev/shm tmpfs 57.7M 32.0K 57.7M 0% /tmp tmpfs 57.7M 28.0K 57.7M 0% /run [root@buildroot]:~$ uname -a Linux buildroot 6.0.1-g75e3c08038b8 #1 SMP Fri Oct 14 20:36:14 CST 2022 armv7l GNU/Linux [root@buildroot]:~$ iperf3 -s warning: this system does not seem to support IPv6 - trying IPv4 ----------------------------------------------------------- Server listening on 5201 (test #1) ----------------------------------------------------------- Accepted connection from 192.168.10.246, port 8252 [ 5] local 192.168.10.211 port 5201 connected to 192.168.10.246 port 8254 [ ID] Interval Transfer Bitrate [ 5] 0.00-1.00 sec 3.92 MBytes 32.9 Mbits/sec [ 5] 1.00-2.00 sec 5.59 MBytes 46.9 Mbits/sec [ 5] 2.00-3.00 sec 5.49 MBytes 46.1 Mbits/sec [ 5] 3.00-4.00 sec 5.69 MBytes 47.7 Mbits/sec [ 5] 4.00-5.00 sec 5.76 MBytes 48.3 Mbits/sec [ 5] 5.00-6.00 sec 5.72 MBytes 48.0 Mbits/sec [ 5] 6.00-7.00 sec 5.79 MBytes 48.5 Mbits/sec [ 5] 7.00-8.00 sec 5.54 MBytes 46.5 Mbits/sec [ 5] 8.00-9.00 sec 5.48 MBytes 45.9 Mbits/sec [ 5] 9.00-10.00 sec 5.70 MBytes 47.8 Mbits/sec [ 5] 10.00-10.04 sec 239 KBytes 48.0 Mbits/sec - - - - - - - - - - - - - - - - - - - - - - - - - [ ID] Interval Transfer Bitrate [ 5] 0.00-10.04 sec 54.9 MBytes 45.9 Mbits/sec receiver ----------------------------------------------------------- Server listening on 5201 (test #2) -----------------------------------------------------------
给 TF 卡分区以及跟文件系统的制作等,这里就不再讲解,可以参考我写的另一篇帖子:MQ-Quad H616 主线内核编译调试记录(u-boot、kernel、buildroot)
-
主线,主线
-
ftwtwzy
-
This post is deleted! -
This post is deleted! -
@evler 在 MangoPi Dual T113 主线内核编译记录 中说:
sudo dd if=awboot.bin of=/dev/sdd bs=1024 seek=8
神奇,使用百问网的t113 pro开发板,不管改不改内核设备树里面的 uart接口,都是boot启动不了 内核,明天再排查排查
-
@allwinnertech 在 MangoPi Dual T113 主线内核编译记录 中说:
@evler 在 MangoPi Dual T113 主线内核编译记录 中说:
sudo dd if=awboot.bin of=/dev/sdd bs=1024 seek=8
神奇,使用百问网的t113 pro开发板,不管改不改内核设备树里面的 uart接口,都是boot启动不了 内核,明天再排查排查
看看这个,希望能用到
https://whycan.com/t_9231.html -
@ftwtwzy 好的,谢谢
-
@baiwen 大佬,有弄出来吗?我用你们百问网的板子也是这个问题,启动不了内核?nand型号是MX35LF1GE4AB
Copyright © 2022 深圳全志在线有限公司 粤ICP备2021084185号 粤公网安备44030502007680号