换Log输出的UART口
1. 查看uboot配置
以x2000_darwin_factory_defconfig编译配置为例
bhu@bhu-PC:~/work/build$ grep -nr "uboot_" configs/x2000_darwin_factory_defconfig //查看uboot配置
3:APP_uboot_toolchain_dir=../tools/toolchains/mips-gcc720-glibc229
4:APP_uboot_dir=../bootloader/uboot-x2000
5:APP_uboot_config=x2000_base_xImage_sfc_nand //uboot配置文件
在bootloader/uboot-x2000目录下的boards.cfg文件搜索uboot配置
bhu@bhu-PC:~/work/build$ grep -nr "x2000_base_xImage_sfc_nand" ../bootloader/uboot-x2000/boards.cfg
679:x2000_base_xImage_sfc_nand mips xburst2 x2000_base ingenic x2000_v12 x2000_base:SPL_SFC_NAND,MTD_SFCNAND,SPL_OS_BOOT,RMEM_MB=16,SPL_PARAMS_FIXER
2. 修改uboot配置
可以看到使用的配置是x2000_base,在x2000_base:后面可以设置打印uart口,格式为SYS_UART_INDEX=x,不添加默认使用x2000_base的
x2000_base.h位于bootloader/uboot-x2000/include/configs
#ifndef __X2000_BASE_H__
#define __X2000_BASE_H__
#define CONFIG_ROOTFS_SQUASHFS
#define CONFIG_ROOTFS2_SQUASHFS
#define CONFIG_ARG_QUIET //去掉这个可以打开所有系统打印信息
#define CONFIG_SPL_SERIAL_SUPPORT
#include "x2000_base_common.h" //实际配置
#endif /* __X2000_BASE_H__ */
实际配置在同一目录下,可以对uart口及波特率进行修改,这里uart口的设置优先级小于前面x2000_base:后面设置的
/*
* uart setting
*/
#ifndef CONFIG_SYS_UART_INDEX
#define CONFIG_SYS_UART_INDEX 2 //uart口
#endif
#ifndef CONFIG_BAUDRATE
#define CONFIG_BAUDRATE 3000000 //波特率
#endif
3. 问题排查
若无串口输出,查看uart口和波特率是否与配置一致,新增串口需要在kernel中添加
以x2000_darwin_factory_defconfig编译配置为例,查看kernel中关于uart的配置
bhu@bhu-PC:~/work/build$ grep -nr "kernel" configs/x2000_darwin_factory_defconfig //先查看kernel的配置
6:APP_kernel_dir=../kernel/kernel-x2000
7:APP_kernel_config=x2000_module_base_linux_sfc_nand_defconfig //kernel配置文件
配置文件位于kernel/kernel-x2000/arch/mips/configs目录下
bhu@bhu-PC:~/work/kernel/kernel-x2000/arch/mips/configs$ grep -nr ".dts" ./x2000_module_base_linux_sfc_nand_defconfig
88:CONFIG_DT_X2000_MODULE_BASE_DTS_FILE="x2000_module_base.dts" //关于uart配置
x2000_module_base.dts位于kernel/kernel-x2000/arch/mips/boot/dts/ingenic目录下,可以对需要用到的串口进行添加修改
#include <dt-bindings/input/input.h>
#include "x2000.dtsi"
#include <dt-bindings/interrupt-controller/irq.h>
#include <generated/autoconf.h>
/ {
compatible = "ingenic,x2000_module_base", "ingenic,x2000";
};
&uart2 {
status = "okay";
pinctrl-names = "default";
pinctrl-0 = <&uart2_pd>;
};
&uart3 {
status = "okay";
pinctrl-names = "default";
pinctrl-0 = <&uart3_pd>;
};
参考串⼝引脚定义在kernel/kernel-x2000/arch/mips/boot/dts/ingenic目录下的x2000-pinctrl.dtsi文件
#include <dt-bindings/pinctrl/ingenic-pinctrl.h>
&pinctrl {
uart0_pin: uart0-pin {
uart0_pd: uart0-pd {
ingenic,pinmux = <&gpd 23 26>;
ingenic,pinmux-funcsel = <PINCTL_FUNCTION2>;
};
};
uart1_pin: uart1-pin {
uart1_pc: uart1-pc {
ingenic,pinmux = <&gpc 21 24>;
ingenic,pinmux-funcsel = <PINCTL_FUNCTION1>;
};
};
uart2_pin: uart2-pin {
uart2_pd: uart2-pd {
ingenic,pinmux = <&gpd 30 31>;
ingenic,pinmux-funcsel = <PINCTL_FUNCTION0>;
};
};
uart3_pin: uart3-pin {
uart3_pc: uart3-pc {
ingenic,pinmux = <&gpc 25 26>;
ingenic,pinmux-funcsel = <PINCTL_FUNCTION0>;
};
uart3_pd: uart3-pd {
ingenic,pinmux = <&gpd 0 3>;
ingenic,pinmux-funcsel = <PINCTL_FUNCTION1>;
};
};