#全志t113在主线上的debian,rgb屏幕和触摸驱动 闲来无事折腾一下linux,对于全志所有芯片的主线支持情况在 sunxi-wiki 上有着详细的记录,可以看出社区在linux6.0之后对D1/D1S/T113系列芯片的支持做的很不错。
##编译主线u-boot,zimage 预装编译环境
1 apt install gcc-arm-linux-gnueabihf debootstrap
先创建一个文件夹,并下载好对应的库
1 2 3 4 5 6 mkdir linux mkdir bin # 用于存放二进制文件 mkdir mdir # 用于挂载 cd linux git clone --depth=1 https://github.com/u-boot/u-boot git clone --depth=1 https://github.com/torvalds/linux
创建一个 boot.cmd 脚本
1 2 3 4 setenv bootargs mem=128M cma=72M console=ttyS3,115200 root=/dev/mmcblk0p2 rootwait panic=10 fatload mmc 0:1 0x43000000 ${fdtfile} || load mmc 0:1 0x43000000 boot/${fdtfile} fatload mmc 0:1 0x42000000 zImage || load mmc 0:1 0x42000000 boot/zImage bootz 0x42000000 - 0x43000000
创建一个 build.sh 脚本,用于方便提取所需文件
1 2 3 4 5 6 7 8 9 10 11 12 13 cd u-boot make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- mangopi_mq_r_defconfig make -j6 ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- DEVICE_TREE=sun8i-t113s-mangopi-mq-r-t113 cd ../linux make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- sunxi_defconfig make -j6 ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- zImage dtbs modules cd .. cp u-boot/u-boot-sunxi-with-spl.bin bin/ cp linux/arch/arm/boot/zImage bin/ cp linux/arch/arm/boot/dts/allwinner/sun8i-t113s-mangopi-mq-r-t113.dtb bin/ mkimage -C none -A arm -T script -d boot.cmd bin/boot.scr
编译时只需要source build.sh
就可以在bin中可以得到所需文件,使用fdisk对sd卡进行分区,先按d
删除所有区,再按n
新建一个分区,用来存放zimage dtb之类的文件,偏移输入8192
,大小输入+16M
,再按n
新建一个分区,用来存放linux文件系统,建议大小大于1G,偏移量输入40960
,再按t
进行分区,第一区为0b,第二区为83,最后按w
退出。 格式化所有分区
1 2 sudo mkfs.fat /dev/sda1 sudo mkfs.ext4 /dev/sda2
编写一个writeboot.sh,用于将所image和uboot刷入sd卡
1 2 3 4 5 6 7 sudo dd if=bin/u-boot-sunxi-with-spl.bin of=/dev/sda bs=1024 seek=8 sudo mount /dev/sda1 mdir sudo cp zImage mdir/ sudo cp sun8i-t113s-mangopi-mq-r-t113.dtb mdir/ sudo cp boot.scr mdir/ sudo cp uboot.env mdir/ sudo umount /dev/sda1 mdir
接下来source writeboot.sh
就可以将sd卡插入t113验证uboot和kernel是否工作,由于还没有文件系统,会在最后卡住。 ##debootstrap创建debian文件系统 先创建一个用于挂载的ch-mount.sh
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 #!/bin/bash function mnt() { echo "MOUNTING" sudo mount -t proc /proc ${2}/proc sudo mount -t sysfs /sys ${2}/sys sudo mount -o bind /dev ${2}/dev sudo mount -o bind /dev/pts ${2}/dev/pts sudo chroot ${2} } function umnt() { echo "UNMOUNTING" sudo umount ${2}/proc sudo umount ${2}/sys sudo umount ${2}/dev/pts sudo umount ${2}/dev } if [ "$1" == "-m" ] && [ -n "$2" ] ; then mnt $1 $2 elif [ "$1" == "-u" ] && [ -n "$2" ]; then umnt $1 $2 else echo "" echo "Either 1'st, 2'nd or both parameters were missing" echo "" echo "1'st parameter can be one of these: -m(mount) OR -u(umount)" echo "2'nd parameter is the full path of rootfs directory(with trailing '/')" echo "" echo "For example: ch-mount -m /media/sdcard/" echo "" echo 1st parameter : ${1} echo 2nd parameter : ${2} fi
使用debootstrap创建文件系统并挂载进sda2
1 2 3 sudo mount /dev/sda2 mdir/ sudo debootstrap --arch=armhf sid mdir https://mirrors.tuna.tsinghua.edu.cn/debian/ chmod 777 ch-mount.sh
接下来就是初始化配置下载一些库
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 export LC_ALL=en_US.UTF-8 apt-get install locales dpkg-reconfigure locales # 选 97 enus # 选 3 apt install sudo ssh openssh-server net-tools ethtool wireless-tools network-manager iputils-ping \ rsyslog alsa-utils bash-completion gnupg busybox kmod wget curl nano neofetch \ libdrm2 libdrm-common drm-info glmark2-drm libdrm-dev libegl1-mesa-dev libegl-mesa0 libegl1 \ i2c-tools \ # 下载库 cat <<EOF > /etc/hosts #ss 127.0.0.1 localhost 127.0.1.1 $HOST ::1 localhost ip6-localhost ip6-loopback ff02::1 ip6-allnodes ff02::2 ip6-allrouters EOF mkdir -p /etc/network cat >/etc/network/interfaces <<EOF auto lo iface lo inet loopback auto eth0 iface eth0 inet dhcp EOF cat >/etc/resolv.conf <<EOF nameserver 1.1.1.1 nameserver 8.8.8.8 EOF cat >/etc/fstab <<EOF #<file system> <mount point> <type> <options> <dump> <pass> /dev/mmcblk0p1 /boot vfat defaults 0 0 /dev/mmcblk0p2 / ext4 defaults,noatime 0 1 EOF passwd # 设置你的密码 echo sullivan_project > /etc/hostname exit ./ch-mount.sh -u mdir
至此,你的debian系统就设置完成了,如国你想保存下来,只需sudo tar -cvf t113-debian.tar mdir/
,接下来将sd卡插入t113,就可以进入debian系统使用了,
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 root@sullivanproject:~# neofetch _,met$$$$$gg. root@sullivanproject ,g$$$$$$$$$$$$$$$P. -------------------- ,g$$P" """Y$$.". OS: Debian GNU/Linux trixie/sid armv7l ,$$P' `$$$. Host: MangoPi MQ-R-T113 ',$$P ,ggs. `$$b: Kernel: 6.11.0-rc6-g67784a74e258-dirty `d$$' ,$P"' . $$$ Uptime: 35 mins $$P d$' , $$P Packages: 478 (dpkg) $$: $$. - ,d$$' Shell: bash 5.2.32 $$; Y$b._ _,d$P' Terminal: /dev/ttyS3 Y$$. `.`"Y$$$$P"' CPU: Generic DT based system (2) `$$b "-.__ Memory: 35MiB / 112MiB `Y$$ `Y$$. `$$b. `Y$$b. `"Y$b._ `"""
##drm驱动和input子系统 t113使用sun4i的drm驱动,已在debian中通过apt下载好,如果在譬如busybox中则需使用mesa 源码交叉编译,mesa库编译环境挺麻烦的,建议还是能用包管理器下载就用包管理器下载。 修改位于linux/arch/arm/boot/dts/allwinner/sun8i-t113s-mangopi-mq-r-t113.dts
的设备树,
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 // SPDX-License-Identifier: (GPL-2.0+ OR MIT) // Copyright (C) 2022 Arm Ltd. #include <dt-bindings/interrupt-controller/irq.h> /dts-v1/; #include "sun8i-t113s.dtsi" #include "sunxi-d1s-t113-mangopi-mq-r.dtsi" / { model = "MangoPi MQ-R-T113"; compatible = "widora,mangopi-mq-r-t113", "allwinner,sun8i-t113s"; aliases { ethernet0 = &rtl8189ftv; }; panel { compatible = "bananapi,s070wv20-ct16", "simple-panel"; port { panel_input: endpoint { remote-endpoint = <&tcon_lcd0_out_panel>; }; }; }; wifi_pwrseq: wifi-pwrseq { compatible = "mmc-pwrseq-simple"; clocks = <&ccu CLK_FANOUT1>; clock-names = "ext_clock"; reset-gpios = <&pio 6 12 GPIO_ACTIVE_LOW>; /* PG12 */ assigned-clocks = <&ccu CLK_FANOUT1>; assigned-clock-rates = <32768>; pinctrl-0 = <&clk_pg11_pin>; pinctrl-names = "default"; }; }; &de { status = "okay"; }; &tcon_lcd0 { pinctrl-names = "default"; pinctrl-0 = <&lcd_rgb666_pins>; status = "okay"; }; &tcon_lcd0_out { tcon_lcd0_out_panel: endpoint@0 { reg = <0>; remote-endpoint = <&panel_input>; }; }; &pio { i2c2_pe12_pins: i2c2-pe12-pins { pins = "PE12", "PE13"; function = "i2c2"; }; }; &i2c2 { pinctrl-0 = <&i2c2_pe12_pins>; pinctrl-names = "default"; status = "okay"; gt911@5d { compatible = "goodix,gt911"; reg = <0x5d>; interrupt-parent = <&pio>; interrupts = <1 3 IRQ_TYPE_EDGE_FALLING>; irq-gpios = <&pio 1 3 GPIO_ACTIVE_HIGH>; reset-gpios = <&pio 1 2 GPIO_ACTIVE_HIGH>; VDD-supply = <®_3v3>; status = "okay"; }; }; &usb_otg { dr_mode = "otg"; status = "okay"; }; &usbphy { status = "okay"; }; &ehci0 { status = "disabled"; }; &ohci0 { status = "disabled"; }; &ehci1 { status = "okay"; }; &ohci1 { status = "okay"; }; &cpu0 { cpu-supply = <®_vcc_core>; }; &cpu1 { cpu-supply = <®_vcc_core>; }; &mmc1 { bus-width = <4>; mmc-pwrseq = <&wifi_pwrseq>; non-removable; vmmc-supply = <®_3v3>; vqmmc-supply = <®_3v3>; pinctrl-0 = <&mmc1_pins>; pinctrl-names = "default"; status = "okay"; rtl8189ftv: wifi@1 { reg = <1>; interrupt-parent = <&pio>; interrupts = <6 10 IRQ_TYPE_LEVEL_LOW>; /* PG10 = WL_WAKE_AP */ interrupt-names = "host-wake"; }; };
panel 驱动使用你实际屏幕的参数,再次修改linux/t113-s3/linux/arch/arm/configs/sunxi_defconfig
向其中添加
1 2 CONFIG_EXPERT=y CONFIG_TOUCHSCREEN_GOODIX=y
重新编译烧录,在命令行中使用glmark2-drm
即可看到熟悉的小马 当然,这个测试是跑不完的,因为t113s3只有128m内存,lvgl有一个drm驱动 直接可以使用drm显示。