天天看点

荔枝派Zero(V3s)修改默认串口 uart0 为 uart21、下载u-boot 和Linux 源码2、修改 uboot 和 linux 源码

如果想要修改为 uart1 也是一样的

1、下载u-boot 和Linux 源码

注意:下载之后千万要先编译一下,确保下载完整,没有缺少任何文件,编译过程没有任何错误。

1.1 uboot源码

git clone https://github.com/Lichee-Pi/u-boot.git -b v3s-current                                   #默认SD卡启动
#or git clone https://github.com/Lichee-Pi/u-boot.git -b v3s-spi-experimental              #默认SPI启动
           

编译过程参考:http://zero.lichee.pro/系统开发/uboot_build.html#id2

1.2 linux源码下载

git clone https://github.com/Lichee-Pi/linux.git
           

编译过程参考:http://zero.lichee.pro/系统开发/kernel_build.html#linux

2、修改 uboot 和 linux 源码

(1)修改 sun8i-v3s-licheepi-zero.dts

注意: uboot 和 linux 都要修改此文件,uboot 的路径为:arch/arm/dts ,Linux的路径是:arch/arm/boot/dts。

aliases {
		serial0 = &uart0;
		serial2 = &uart2;  //新增
	};

	chosen {
		stdout-path = "serial2:115200n8";  //修改
	};
           
&uart0 {
	pinctrl-0 = <&uart0_pins_a>;
	pinctrl-names = "default";
	status = "okay";
};

//新增
&uart2 {
	pinctrl-0 = <&uart2_pins_a>;
	pinctrl-names = "default";
	status = "okay";
};
           

(2)修改 sun8i-v3s.dtsi文件

注意: uboot 和 linux 都要修改此文件,uboot 的路径为:arch/arm/dts ,Linux的路径是:arch/arm/boot/dts。

uart0_pins_a: [email protected] {
				pins = "PB8", "PB9";
				function = "uart0";
				bias-pull-up;
			};

			//新增
			uart2_pins_a: [email protected] {
				pins = "PB0", "PB1";
				function = "uart2";
				bias-pull-up;
			};
           

(3)修改 include/configs/sunxi-common.h

注意: 只需要 uboot 修改此文件即可。

#define CONFIG_CONS_INDEX              1       /* UART0 */
           

改为

#define CONFIG_CONS_INDEX              3       /* UART2 */
           

(4)修改 include/configs/sun8i.h

注意: 只需要 uboot 修改此文件即可。

如果是spi启动方式,则将下列代码添加到该文件中,注意添加的位置在“#include <configs/sunxi-common.h>”的前面。

#define CONFIG_BOOTCOMMAND   "sf probe 0 108000000; "                           \
                             "sf read 0x41000000 0x0F0000 0x010000; "  \
                             "sf read 0x41010000 0x300000 0x800000; " \
                             "bootz 0x41010000 - 0x41000000"

#define CONFIG_BOOTARGS      "console=ttyS2,115200 earlyprintk panic=5 rootwait mtdparts=spi32766.0:960k(uboot),64k(dtb),1M(background),1M(animation),8M(kernel),-(appendfs) root=/dev/ram0 rdinit=/init vt.global_cursor_default=0"
           

如果是sd卡启动方式,则将下列代码添加到该文件中,注意添加的位置在“#include <configs/sunxi-common.h>”的前面。

#define CONFIG_BOOTCOMMAND   "setenv bootm_boot_mode sec; " 
                            "load mmc 0:1 0x41000000 zImage; "  
                            "load mmc 0:1 0x41800000 sun8i-v3s-licheepi-zero-dock.dtb; " 
                            "bootz 0x41000000 - 0x41800000;"
#define CONFIG_BOOTARGS      "console=ttyS2,115200 panic=5 rootwait root=/dev/mmcblk0p2 earlyprintk rw  vt.global_cursor_default=0"
           

然后编译烧录即可。

继续阅读