换Log输出的UART口
一 查看uboot配置
以x2600e_vast_v20_nand_5.10_defconfig 编译配置为例
bhu@bhu-PC:~/work/build$ grep -nr "uboot" configs/x2600e_vast_v20_nand_5.10_defconfig
3:APP_uboot_toolchain_dir=../tools/toolchains/mips-gcc720-glibc229
4:APP_uboot_dir=../bootloader/uboot-x2000
5:APP_uboot_config=x2600e_base_xImage_sfc_nand //uboot配置
在bootloader/uboot-x2000目录下的boards.cfg文件查看uboot配置
bhu@bhu-PC:~/work/build$ grep -nr "x2600e_base_xImage_sfc_nand" ../bootloader/uboot-x2000/boards.cfg
798:x2600e_base_xImage_sfc_nand mips xburst2 x2600_base ingenic x2600 x2600_base:SPL_SFC_NAND,MTD_SFCNAND,SPL_OS_BOOT,SPL_PARAMS_FIXER,X2600E_DDR,RMEM_MB=16,LPJ="11476992"
二 修改uboot配置
可以看到使用的配置是x2600_base , 在x2600_base:后面可以设置打印uart口,格式为SYS_UART_INDEX=x,不添加默认使用x2600_base.h位于bootloader/uboot-x2000/include/configs
#ifndef __X2600_BASE_H__
#define __X2600_BASE_H__
#define CONFIG_ROOTFS_SQUASHFS
#define CONFIG_ROOTFS2_SQUASHFS
#define CONFIG_ARG_QUIET //去掉这个可以打开所有系统打印信息
#define CONFIG_SPL_SERIAL_SUPPORT
#include "x2600_base_common.h" //实际配置
#endif /* __X2600_BASE_H__ */
实际配置在同一目录下,可以对uart口及波特率进行修改,这里uart口的设置优先级小于前面x2600_base:后面设置的
/*
* uart setting
*/
#ifndef CONFIG_SYS_UART_INDEX
#define CONFIG_SYS_UART_INDEX 2 //uart口
#endif
#ifndef CONFIG_BAUDRATE
#define CONFIG_BAUDRATE 3000000 //波特率
#endif
/* boot args uart rate
*/ //默认只支持了115200和3000000,需要其他的请在这里添加
#if CONFIG_BAUDRATE == 115200
#define ARG_CONSOLE_RATE "115200n8"
#elif CONFIG_BAUDRATE == 3000000
#define ARG_CONSOLE_RATE "3000000n8"
#else
#error "please add more define here"
#endif
三 问题排查
若无串口输出,确保硬件正确,uart和io对应的上的情况
3.1 kernel设备树检查是否添加对应uart
以x2600e_vast_v20_nand_5.10_defconfig 为例查看使用的dts文件
bhu@bhu-PC:~/work/build$ grep -nr "kernel" configs/x2600e_vast_v20_nand_5.10_defconfig
6:APP_kernel_dir=../kernel/kernel
7:APP_kernel_config=x2600_vast_module_base_linux_sfc_nand_defconfig //kernel配置
9:# APP_kernel_dtb is not set
配置文件位于kernel/kernel/arch/mips/configs目录下
bhu@bhu-PC:~/work/build$ grep -nr ".dts" ../kernel/kernel/arch/mips/configs/x2600_vast_module_base_linux_sfc_nand_defconfig
257:CONFIG_DT_X2600_MODULE_BASE_DTS_FILE="x2600_vast_module_base.dts"
dts 文件位于kernel/kernel/module_drivers/dts,可以添加需要的uart,格式参考已经添加过的
kernel可以添加的uart参考同级目录下的x2600-pinctrl.dtsi文件,以uart0为例,支持pc21-24及pe9-12
3.2 kernel配置了uart
参考3.1找到kernel使用的dts文件, 若下面图中的框中部分没有被注释,就会用uart0,波特率115200,一般配置不会打开这里 .