您尚未登录。

楼主 # 2022-12-06 16:37:03

twzy
会员
注册时间: 2021-04-16
已发帖子: 204
积分: 351.5
个人网站

T113-S3主线Linux支持方案(基于TF卡,包含串口修改)

原贴在这里
https://bbs.aw-ol.com/topic/2338/mangopi-dual-t113-%E4%B8%BB%E7%BA%BF%E5%86%85%E6%A0%B8%E7%BC%96%E8%AF%91%E8%AE%B0%E5%BD%95
感谢Evlers大佬的付出。

需要注意的是:本篇是基于所用的引导的是AWboot 而非传统的uboot-spl方式,并且是该AWboot是专为T113-S3而构建的引导。

1 . 配置AWboot编译环境
   AWboot需要用到arm-none-eabi-的交叉编译工具,我这里使用到的是 gcc-arm-none-eabi-10.3-2021.10-x86_64-linux.tar.bz2
   下载地址:https://developer.arm.com/downloads/-/gnu-rm
   接下来配置编译环境
   

# 解压
tar -vxjf gcc-arm-none-eabi-10.3-2021.10-x86_64-linux.tar.bz2

# 创建目录
sudo mkdir /usr/local/arm-none-eabi

# 进入解压目录下
cd gcc-arm-none-eabi-10.3-2021.10-x86_64-linux/
# 将该目录下的所有文件复制到新建的目录下
sudo cp -rd * /usr/local/arm-none-eabi/


# 最后需要添加该工具链的环境变量使其可以在任何目录下执行,打开/etc/profile文件
sudo nano /etc/profile

# 在文件末尾添加以下内容
PATH=$PATH:/usr/local/arm-linux-gcc/bin

# 添加完毕,使路径立即生效可以使用如下命令
source /etc/profile

# 接下来在终端输入
 arm-none-eabi-
#按两次tab键进行验证
 

2 . 编译AWboot

# 下拉 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下生成了:awboot-boot-sd.bin则表示工作正常了。

3 . 修改串口配置
  AWboot 默认使用UART5作为串口调试,但是因为墨云的板子使用的是UART3,所以需要进行一些调整,好在代码比较简单,进行如下修改:
  修改awboot目录下的board.cs文件,修改如图
  1.png
  需要注意base参数可以通过t113-s3用户手册查询到
  0x02500c00 为UART3 的地址
  还有就是对awboot/linux/sun8i-t113.dtsi、awboot/linux/sun8i-t113-snailpi-dual.dts 的修改
  主要是增加UART3 设备树配置和 BootArgs的配置,就是类似Uboot中BootArgs的配置:
  修改细微处较多,这里直接给文件吧

  awboot_sun8i-t113.zip
  awboot/linux/sun8i-t113.dtsi
  中pio节点下增加

	uart3_pb6_pins: uart3-pb6-pins {
				pins = "PB6", "PB7";
				function = "uart3";
			};

awboot/linux/sun8i-t113-snailpi-dual.dts
最后增加

&uart3 {
	pinctrl-0 = <&uart3_pb6_pins>;
	pinctrl-names = "default";
	status = "okay";
};

修改 aliases

	aliases {
		//ethernet0 = &rtl8189f;
		mmc0 = &mmc0;
		serial1 = &uart1;
		serial3 = &uart3;
		//serial5 = &uart5;
	};

修改chosen (这个地方就是用来指定类似uboot中bootargs的地方)

        chosen {
		stdout-path = "serial3:115200n8";
/*
                bootargs = "mem=128M cma=72M root=/dev/mmcblk0p2 rw init=/sbin/init rootwait earlyprintk=sunxi-uart,0x02500c00 console=tty0 console=ttyS5,115200";
*/
                bootargs = "mem=128M cma=64M root=/dev/mmcblk0p2 rw init=/sbin/init rootwait console=tty0 console=ttyS3,115200 earlyprintk=sunxi-uart,0x02500c00";
        };

最后一个就是类似uboot指定zimage和设备树的地方
2.png
因为该项目是特定版本,所以只是单纯的指定名称,不用指定要写入内存的位置。

写入TF卡:

sudo dd if=awboot-boot-sd.bin of=/dev/sdb bs=1024 seek=8

最后是执行结果
3.png
本篇结束

内核部分可以先看前面的原贴,墨云稍后更新。

最近编辑记录 twzy (2022-12-06 16:46:53)

离线

楼主 #1 2022-12-06 17:13:47

twzy
会员
注册时间: 2021-04-16
已发帖子: 204
积分: 351.5
个人网站

Re: T113-S3主线Linux支持方案(基于TF卡,包含串口修改)

内核编译
   可以直接找大佬修改好的主线稳定版内核(带WiFi):Linux-6.0.1https://github.com/Evlers/linux_kernel_t113
   也选择去官网下载内核:kernel https://kernel.org/
   修改 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);

配置内核
  在内核根目录修改Makefile

  ARCH = arm 
  CROSS_COMPILE = arm-linux-gnueabihf-

配置默认编译规则

 make sunxi_defconfig

打开配置菜单

 make sunxi_defconfig 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-snailpi-dual.dts sun8i-t113.dtsi (如果下载了大佬的Linux内核,就有这些文件,需要注意的是原版是 sun8i-t113-mangopi-dual.dts)
  linux-sun8i-t113.zip
  并在该目录 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-snailpi-dual.dtb

接下来就是正常编译

make

如果遇到

FATAL ERROR: MPC.H: 没有那个文件或目录

安装如下组件

sudo apt-get install libmpc-dev

接下来就是分区复制编译好的文件即可,这里不做赘述。
结合我们很久以前制作的Debian文件系统,那只熟悉的蜗牛又回来啦。

QQ图片20221206120716.png

感谢阅读
-----------------------------
这里再次感谢Evlers大佬的付出,本篇为拾人牙慧之作,如果其中内容涉及侵权之类的,请告知墨云,墨云会在得到信息的时候删除。

离线

楼主 #3 2022-12-08 11:14:38

twzy
会员
注册时间: 2021-04-16
已发帖子: 204
积分: 351.5
个人网站

Re: T113-S3主线Linux支持方案(基于TF卡,包含串口修改)

尝试调试WIFI,发现mmc1 初始化失败

sunxi-mmc 4021000.mmc: no support for card's volts
mmc1: error -22 whilst initialising SDIO card
……

QQ截图20221208110232.png

设备树

// SPDX-License-Identifier: (GPL-2.0+ or MIT)
// Copyright (C) 2022 Samuel Holland <samuel@sholland.org>

/dts-v1/;

#include <dt-bindings/gpio/gpio.h>
#include <dt-bindings/leds/common.h>
#include "sun8i-t113.dtsi"

/ {
	model = "SnailPi MQ-Dual";
	compatible = "allwinner,sun20i-d1", "allwinner,sun8i";

	aliases {
		//ethernet0 = &emac;
		mmc0 = &mmc0;
		//mmc1 = &mmc1;
		serial3 = &uart3;
	};

	chosen {
		stdout-path = "serial3:115200n8";
		bootargs = "mem=128M cma=72M root=/dev/mmcblk0p2 rw init=/sbin/init rootwait console=tty0 console=ttyS3,115200";
	};

	reg_vcc: vcc {
		compatible = "regulator-fixed";
		regulator-name = "vcc";
		regulator-min-microvolt = <5000000>;
		regulator-max-microvolt = <5000000>;
	};

	reg_usbvbus: usbvbus {
		compatible = "regulator-fixed";
		regulator-name = "usbvbus";
		regulator-min-microvolt = <5000000>;
		regulator-max-microvolt = <5000000>;
		vin-supply = <&reg_vcc>;
	};

	reg_vcc_3v3: vcc-3v3 {
		compatible = "regulator-fixed";
		regulator-name = "vcc-3v3";
		regulator-min-microvolt = <3300000>;
		regulator-max-microvolt = <3300000>;
		vin-supply = <&reg_vcc>;
	};

	reg_avdd2v8: avdd2v8 {
		compatible = "regulator-fixed";
		regulator-name = "avdd2v8";
		regulator-min-microvolt = <2800000>;
		regulator-max-microvolt = <2800000>;
		vin-supply = <&reg_vcc_3v3>;
	};

	reg_vdd_cpu: vdd-cpu {
		compatible = "regulator-fixed";
		regulator-name = "vdd-cpu";
		regulator-min-microvolt = <900000>;
		regulator-max-microvolt = <900000>;
		vin-supply = <&reg_vcc>;
	};


	dmic_codec: dmic-codec {
		compatible = "dmic-codec";
		num-channels = <2>;
		#sound-dai-cells = <0>;
	};

	dmic-sound {
		compatible = "simple-audio-card";
		#address-cells = <1>;
		#size-cells = <0>;

		simple-audio-card,dai-link@0 {
			format = "pdm";
			frame-master = <&link0_cpu>;
			bitclock-master = <&link0_cpu>;

			link0_cpu: cpu {
				sound-dai = <&dmic>;
			};

			link0_codec: codec {
				sound-dai = <&dmic_codec>;
			};
		};
	};

	leds {
		compatible = "gpio-leds";
		status_led {
			linux,default-trigger = "heartbeat";
			label = "blue:status";
			gpios = <&pio 3 22 GPIO_ACTIVE_HIGH>; //pd22
		};
	};


	wifi_pwrseq: wifi-pwrseq {
		compatible = "mmc-pwrseq-simple";
		reset-gpios = <&pio 6 12 GPIO_ACTIVE_HIGH>; /* PG12 */
		//pinctrl-0 = <&wifi_en_pin>;
		pinctrl-names = "default";

		clocks = <&ccu CLK_FANOUT1>;
		clock-names = "ext_clock";
		assigned-clocks = <&ccu CLK_FANOUT1>;
		assigned-clock-rates = <32768>;
		pinctrl-0 = <&clk_pg11_pin>;
	};

};

&reg_aldo {
	regulator-min-microvolt = <1800000>;
	regulator-max-microvolt = <1800000>;
	vdd33-supply = <&reg_vcc_3v3>;
};

&cpu0 {
	cpu-supply = <&reg_vdd_cpu>;
};

&cpu1 {
	cpu-supply = <&reg_vdd_cpu>;
};

&wdt {
	status = "okay";
};

&ve {
	status = "disabled";
};

// &de {
// 	status = "okay";
// };

// &dsi {
// 	pinctrl-0 = <&dsi_4lane_pins>;
// 	pinctrl-names = "default";
// 	status = "disabled";

//         panel: panel@0 {
// 			reg = <0>;
// 			compatible = "lg,lh500wx1-sd03";
// 			pinctrl-names = "default";

// 			// pinctrl-0 = <&panel_pin>;

// 			// port {
// 			// 		panel_in: endpoint {
// 			// 				remote-endpoint = <&dsi0_out>;
// 			// 		};
// 			// };

//         };
// };

&pio {

	vcc-pb-supply = <&reg_vcc_3v3>;
	vcc-pc-supply = <&reg_vcc_3v3>;
	vcc-pd-supply = <&reg_vcc_3v3>;
	vcc-pe-supply = <&reg_avdd2v8>;
	vcc-pf-supply = <&reg_vcc_3v3>;
	vcc-pg-supply = <&reg_vcc_3v3>;


	uart3_pb6_pins: uart3-pb6-pins {
	    pins = "PB6", "PB7";
	    function = "uart3";
	};

	uart5_pb4_pins: uart5-pb4-pins {
	    pins = "PB4", "PB5";
	    function = "uart5";
	};

	wifi_en_pin: wifi_en_pin {
		pins = "PG12";
		function = "gpio_out";
	};

	clk_pg11_pin: clk-pg11-pin {
			pins = "PG11";
			function = "clk";
	};

};

&uart1 {
        uart-has-rtscts;
        pinctrl-0 = <&uart1_pg6_pins>, <&uart1_pg8_rts_cts_pins>;
        pinctrl-names = "default";
        status = "disabled";

        /* XR829 bluetooth is connected here */
};

&uart3 {
	pinctrl-0 = <&uart3_pb6_pins>;
	pinctrl-names = "default";
	status = "okay";
};

&uart5 {
	pinctrl-0 = <&uart5_pb4_pins>;
	pinctrl-names = "default";
	status = "disabled";
};

&i2c2 {
	pinctrl-0 = <&i2c2_pe12_pins>;
	pinctrl-names = "default";
	status = "okay";
};

&spi0 {
	pinctrl-0 = <&spi0_pins>;
	pinctrl-names = "default";
	status = "disabled";
};

&mmc0 {
	bus-width = <4>;
	cd-gpios = <&pio 5 6 (GPIO_ACTIVE_LOW)>;
	disable-wp;
	vmmc-supply = <&reg_vcc_3v3>;
	vqmmc-supply = <&reg_vcc_3v3>;
	pinctrl-0 = <&mmc0_pins>;
	pinctrl-names = "default";
	status = "okay";
};

&mmc1 {
	bus-width = <4>;
	mmc-pwrseq = <&wifi_pwrseq>;
	non-removable;
	//broken-cd;
	vmmc-supply = <&reg_vcc_3v3>;
	vqmmc-supply = <&reg_vcc_3v3>;
	pinctrl-0 = <&mmc1_pins>;
	pinctrl-names = "default";
	status = "okay";

	brcmf: sdio_wifi@1 {
			reg = <1>;
			compatible = "brcm,bcm4329-fmac";
			interrupt-parent = <&pio>;
			interrupts = <6 10 IRQ_TYPE_LEVEL_HIGH>; /* PG10 */
			interrupt-names = "host-wake";
	};
};

// &codec {
// 	routing = "Headphone Jack", "HPOUTL",
// 		      "Headphone Jack", "HPOUTR",
// 		      "Headset Microphone", "MICIN3"; 

// /*		  "LINEINL", "HPOUTL",
// 		      "LINEINR", "HPOUTR";
// */
// 	widgets = "Microphone", "Headset Microphone",
// 		  "Headphone", "Headphone Jack";
// 	status = "disabled";
// };

&usb_otg {
	dr_mode = "otg";
	status = "okay";
};

&ehci0 {
	status = "okay";
};

&dmic {
	status = "okay";
};

&ehci1 {
	status = "okay";
};


&ohci0 {
	status = "okay";
};

&ohci1 {
	status = "okay";
};


&ths {
	status = "okay";
	vref-supply = <&reg_aldo>;
};

&usbphy {
	usb0_vbus-supply = <&reg_usbvbus>;
	usb1_vbus-supply = <&reg_usbvbus>;
	status = "okay";
};

&mdio {
	ext_rgmii_phy: ethernet-phy@1 {
		compatible = "ethernet-phy-ieee802.3-c22";
		reg = <1>;
	};
};

&emac {
	pinctrl-0 = <&rgmii_pe_pins>;
	pinctrl-names = "default";
	phy-handle = <&ext_rgmii_phy>;
	phy-mode = "rgmii-id";
	phy-supply = <&reg_vcc_3v3>;
	status = "disabled";
};

/*
&can0 {
	pinctrl-names = "default";
	pinctrl-0 = <&can0_pins>;
	status = "disabled";
};

&can1 {
	pinctrl-names = "default";
	pinctrl-0 = <&can1_pins>;
	status = "disabled";
};
*/

原理图
QQ截图20221208110623.png
QQ截图20221208110610.png

但是我挂的模组是Ap6212A
_20221208111307.jpg
是不是我这样乱搞,导致起不来的?

离线

楼主 #5 2022-12-08 15:56:17

twzy
会员
注册时间: 2021-04-16
已发帖子: 204
积分: 351.5
个人网站

Re: T113-S3主线Linux支持方案(基于TF卡,包含串口修改)

哇酷小二 说:

@twzy
先检查供电和wl_reg, wl_wake引脚电平

还有ap系列需要外挂32k晶振

多谢,受教了,看来还得换成rtl的

离线

楼主 #7 2022-12-10 08:45:47

twzy
会员
注册时间: 2021-04-16
已发帖子: 204
积分: 351.5
个人网站

Re: T113-S3主线Linux支持方案(基于TF卡,包含串口修改)

剑气冲天 说:

awboot支持直接从ddr中加载镜像吗?

没有,就是针对spi、tf的几种引导方式

离线

楼主 #20 2024-03-04 08:51:08

twzy
会员
注册时间: 2021-04-16
已发帖子: 204
积分: 351.5
个人网站

Re: T113-S3主线Linux支持方案(基于TF卡,包含串口修改)

离线

楼主 #23 2024-03-19 15:20:50

twzy
会员
注册时间: 2021-04-16
已发帖子: 204
积分: 351.5
个人网站

Re: T113-S3主线Linux支持方案(基于TF卡,包含串口修改)

dsp2000 说:

内核的编译也是使用gcc-arm-none-eabi-10.3-2021.10-x86_64-linux吗?好像是  CROSS_COMPILE = arm-linux-gnueabihf-
如果用arm-none-eabi有很多出错啊

内核用gnueabihf

离线

页脚

工信部备案:粤ICP备20025096号 Powered by FluxBB

感谢为中文互联网持续输出优质内容的各位老铁们。 QQ: 516333132, 微信(wechat): whycan_cn (哇酷网/挖坑网/填坑网) service@whycan.cn