当前位置: 首页 > news >正文

全志A40i android7.1 调试信息打印串口由uart0改为uart3

一,概述

1. 目的

将调试信息打印串口由uart0改为uart3。

2. 版本信息

Uboot版本:2014.07;
Kernel版本:Linux-3.10;

二,Uboot

1. sys_config.fex改动

使能uart3(TX:PH00 RX:PH01),并让boot0,uboot的debug串口由uart0改为uart3(TX:PH00 RX:PH01)

diff --git a/pack/chips/sun8iw11p1/configs/a40i-p3/sys_config.fex b/pack/chips/sun8iw11p1/configs/a40i-p3/sys_config.fex index 159d3fa..afe98fe 100755
--- a/pack/chips/sun8iw11p1/configs/a40i-p3/sys_config.fex
+++ b/pack/chips/sun8iw11p1/configs/a40i-p3/sys_config.fex@@ -111,9 +111,9 @@ twi_scl         = port:PB0<2><default><default><default>twi_sda         = port:PB1<2><default><default><default>[uart_para]-uart_debug_port = 0-uart_debug_tx         = port:PB22<2><1><default><default>-uart_debug_rx         = port:PB23<2><1><default><default>+uart_debug_port = 3+uart_debug_tx         = port:PH00<4><1><default><default>+uart_debug_rx         = port:PH01<4><1><default><default>[jtag_para]jtag_enable     = 1@@ -387,7 +387,7 @@ uart2_rx         = port:PI19<7><1><default><default>[uart3]-uart3_used       = 0+uart3_used       = 1uart3_port       = 3uart3_type       = 2uart3_tx         = port:PH00<4><1><default><default>

2. 宏定义改动

brandy/u-boot-2014.07/include/configs/sunXXX.h路径中,修改如下:

diff --git a/u-boot-2014.07/include/configs/sun8iw11p1.h b/u-boot
2014.07/include/configs/sun8iw11p1.h
index b733162..22390a9 100755
--- a/u-boot-2014.07/include/configs/sun8iw11p1.h
+++ b/u-boot-2014.07/include/configs/sun8iw11p1.h
@@ -282,7 +282,7 @@
#define CONFIG_SYS_NS16550_COM4                SUNXI_UART3_BASE
#define CONFIG_NS16550_FIFO_ENABLE     (1)
-#define CONFIG_CONS_INDEX                      1                       /* 
which serial channel for console */
+#define CONFIG_CONS_INDEX                      4                       /* 
which serial channel for console */
#define CONFIG_SETUP_MEMORY_TAGS

CONFIG_CONS_INDEX=4,对应serial3 ;如下表:

串口通道CONFIG_CONS_INDEX
serial01
serial12
serial23
serial34
serial45
serial56

指定波特率:

 #define CONFIG_BAUDRATE             115200

3. 初始化改动

boot0已经限制了仅使用uart0,将这一修改去掉,将会按照sys_config.fex中的uart_debug_port配置的uart端口输出信息。

 diff --git a/u-boot-2014.07/arch/arm/cpu/armv7/sun8iw11p1/spl/serial_spl.c 
b/u-boot-2014.07/arch/arm/cpu/armv7/sun8iw11p1/spl/serial_spl.cindex 3f6c141..70955df 100644--- a/u-boot-2014.07/arch/arm/cpu/armv7/sun8iw11p1/spl/serial_spl.c+++ b/u-boot-2014.07/arch/arm/cpu/armv7/sun8iw11p1/spl/serial_spl.c@@ -44,10 +44,10 @@ void sunxi_serial_init(int uart_port, void *gpio_cfg, 
int gpio_max)u32 reg, i;u32 uart_clk;
-       if( (uart_port < 0) ||(uart_port > 0) )
-       {
-               return;-       }+       // if( (uart_port < 0) ||(uart_port > 0) )+       // {+       //      return;+       // }//resetreg = readl(CCMU_BUS_SOFT_RST_REG4);reg &= ~(1<<(CCM_UART_PORT_OFFSET + uart_port));

4. 打包改动

由于平台适配性问题,在更改了uart_para参数后,会出现采用PhoenixSuit无法烧录固件的情况。由于在pack阶段,会解析sys_confg.fex的uart_para配置项,然后更新boot0,fes1,uboot的头部信息,路径(tools/pack/pack

 update_fes1  fes1.fex           sys_config.bin > /dev/null

出现无法烧录的原因是pack更新了fes1的头部信息,导致校验不通过,所以需要屏蔽fes1的更新,修改如下:

diff --git a/pack_tools/update_fes1/update_fes1.c 
b/pack_tools/update_fes1/update_fes1.c
index 6134c96..536dfb1 100755--- a/pack_tools/update_fes1/update_fes1.c+++ b/pack_tools/update_fes1/update_fes1.c@@ -230,6 +230,21 @@ int update_for_fes1(char *fes1_name, int storage_type)}}+       fes1_head->prvt_head.uart_port = 0;+       fes1_head->prvt_head.uart_ctrl[0].port      = 2;+       fes1_head->prvt_head.uart_ctrl[0].port_num  = 22;+       fes1_head->prvt_head.uart_ctrl[0].mul_sel   = 2;+       fes1_head->prvt_head.uart_ctrl[0].pull      = 1;+       fes1_head->prvt_head.uart_ctrl[0].drv_level = -1;+       fes1_head->prvt_head.uart_ctrl[0].data      = -1;++       fes1_head->prvt_head.uart_ctrl[1].port      = 2;+       fes1_head->prvt_head.uart_ctrl[1].port_num  = 23;+       fes1_head->prvt_head.uart_ctrl[1].mul_sel   = 2;+       fes1_head->prvt_head.uart_ctrl[1].pull      = 1;+       fes1_head->prvt_head.uart_ctrl[1].drv_level = -1;+       fes1_head->prvt_head.uart_ctrl[1].data      = -1;+//取出数据进行修正,debugenable参数if(!script_parser_fetch("jtag_para", "jtag_enable", value)){

更新update_fes1工具:进入brandy/pack_tools/update_fes1/ 目录,执行make命令,用生成的 update_fes1覆盖tools/pack/pctools/linux/mod_update/update_fes1 ,再进行 pack 操作即可。
但这样会造成fes1的输出依然还是uart0,所以我们需要更改fes1的代码,如下:

diff --git a/lichee/brandy/u-boot-2014.07/sunxi_spl/fes_init/main/fes1_main.c b/lichee/brandy/u-boot-2014.07/sunxi_spl/fes_init/main/fes1_main.c
index 31a01017c5..1b794e2010 100755
--- a/lichee/brandy/u-boot-2014.07/sunxi_spl/fes_init/main/fes1_main.c
+++ b/lichee/brandy/u-boot-2014.07/sunxi_spl/fes_init/main/fes1_main.c
@@ -101,9 +101,35 @@ int main(void){__s32 dram_size=0;-       timer_init();
+       timer_init();       
+if(CONFIG_CONS_INDEX == 4)
+{
+               boot0_file_head_t fes1_head_fix;
+               fes1_head_fix.prvt_head.uart_port = 3;
+               fes1_head_fix.prvt_head.uart_ctrl[0].port = 8;      
+               fes1_head_fix.prvt_head.uart_ctrl[0].port_num  = 0;
+               fes1_head_fix.prvt_head.uart_ctrl[0].mul_sel  = 4;
+               fes1_head_fix.prvt_head.uart_ctrl[0].pull   = 1;   
+               fes1_head_fix.prvt_head.uart_ctrl[0].drv_level = -1;
+               fes1_head_fix.prvt_head.uart_ctrl[0].data = -1;      
+               
+
+               fes1_head_fix.prvt_head.uart_ctrl[1].port  = 8;
+               fes1_head_fix.prvt_head.uart_ctrl[1].port_num  = 0;
+               fes1_head_fix.prvt_head.uart_ctrl[1].mul_sel  = 4;
+               fes1_head_fix.prvt_head.uart_ctrl[1].pull   = 1;
+               fes1_head_fix.prvt_head.uart_ctrl[1].drv_level = -1;
+               fes1_head_fix.prvt_head.uart_ctrl[1].data = -1;
+               
+               //serial init
+               sunxi_serial_init(fes1_head_fix.prvt_head.uart_port, (void *)fes1_head_fix.prvt_head.uart_ctrl, 2);
+ }
+ else
+ {//serial init
-       sunxi_serial_init(fes1_head.prvt_head.uart_port, (void *)fes1_head.prvt_head.uart_ctrl, 2);
+       sunxi_serial_init(fes1_head_fix.prvt_head.uart_port, (void *)fes1_head_fix.prvt_head.uart_ctrl, 2);
+ }
+#ifdef CONFIG_SUNXI_MULITCORE_BOOTpmu_init();set_pll_voltage(1260);

其中,CONFIG_CONS_INDEX即为brandy/u-boot-2014.07/include/configs/sunXXX.h路径中的宏。

5. 启动参数改动

更改uboot传递给kernel的启动参数,路径pack/chips/sun8iw11p1/configs/default/env.cfg可能
因为配置有所不同

diff --git a/pack/chips/sun8iw11p1/configs/default/env.cfg 
b/pack/chips/sun8iw11p1/configs/default/env.cfgindex eb60f41..922057e 100755
--- a/pack/chips/sun8iw11p1/configs/default/env.cfg
+++ b/pack/chips/sun8iw11p1/configs/default/env.cfg@@ -1,9 +1,9 @@#kernel command argumentsenforcing=1-earlyprintk=sunxi-uart,0x01c28000+earlyprintk=sunxi-uart,0x01c28c00initcall_debug=0-console=ttyS0,115200+console=ttyS3,115200nand_root=/dev/systemmmc_root=/dev/mmcblk0p7nor_root=/dev/mtdblock2

重新编译boot0,uboot。


三. Kernel

1. config改动

修改 kernel 的 menuconfig 中 uart 的打印端口和基地址:

diff --git a/arch/arm/Kconfig.debug b/arch/arm/Kconfig.debugindex 4d17934..3aea83e 100644
--- a/arch/arm/Kconfig.debug
+++ b/arch/arm/Kconfig.debug
@@ -443,6 +443,13 @@ choiceSay Y here if you want kernel low-level debugging supporton Allwinner A1X based platforms on the UART1.+       config DEBUG_SUNXI_UART3+               bool "Kernel low-level debugging messages via sunXi UART3"+               depends on ARCH_SUNXI+               help+                 Say Y here if you want kernel low-level debugging support+                 on Allwinner A1X based platforms on the UART3.+config DEBUG_TEGRA_UARTdepends on ARCH_TEGRAbool "Use Tegra UART for low-level debug"@@ -662,7 +669,7 @@ config DEBUG_LL_INCLUDEDEBUG_MMP_UART3default "debug/sirf.S" if DEBUG_SIRFPRIMA2_UART1 || 
DEBUG_SIRFMARCO_UART1default "debug/socfpga.S" if DEBUG_SOCFPGA_UART-       default "debug/sunxi.S" if DEBUG_SUNXI_UART0 || DEBUG_SUNXI_UART1+       default "debug/sunxi.S" if DEBUG_SUNXI_UART0 || DEBUG_SUNXI_UART1 || DEBUG_SUNXI_UART3default "debug/tegra.S" if DEBUG_TEGRA_UARTdefault "debug/ux500.S" if DEBUG_UX500_UARTdefault "debug/vexpress.S" if DEBUG_VEXPRESS_UART0_DETECT || \
diff --git a/arch/arm/include/debug/sunxi.S b/arch/arm/include/debug/sunxi.Sindex 04eb56d..5f66699 100644--- a/arch/arm/include/debug/sunxi.S+++ b/arch/arm/include/debug/sunxi.S@@ -16,6 +16,9 @@#elif defined(CONFIG_DEBUG_SUNXI_UART1)#define SUNXI_UART_DEBUG_PHYS_BASE 0x01c28400#define SUNXI_UART_DEBUG_VIRT_BASE 0xf1c28400+#elif defined(CONFIG_DEBUG_SUNXI_UART3)+#define SUNXI_UART_DEBUG_PHYS_BASE 0x01c28c00+#define SUNXI_UART_DEBUG_VIRT_BASE 0xf1c28c00#endif.macro  addruart, rp, rv, tmp

增加DEBUG_SUNXI_UART3后,在menuconfig中选择:

make ARCH=arm menuconfig

在这里插入图片描述

2. 设备树改动

dts可改可不改,为了统一,这里的设备树也一起更改,实际上这里的配置会被uboot传递的启动参数覆盖

 diff --git a/arch/arm/boot/dts/sun8iw11p1.dtsi 
b/arch/arm/boot/dts/sun8iw11p1.dtsiindex 526fe29..4e00a86 100755--- a/arch/arm/boot/dts/sun8iw11p1.dtsi+++ b/arch/arm/boot/dts/sun8iw11p1.dtsi@@ -61,7 +61,7 @@};chosen {-               bootargs = "earlyprintk=sunxi-uart,0x01c28000 loglevel=8 
initcall_debug=1 console=ttyS0 init=/init";+               bootargs = "earlyprintk=sunxi-uart,0x01c28c00 loglevel=8 
initcall_debug=1 console=ttyS3 init=/init";linux,initrd-start = <0x0 0x0>;linux,initrd-end = <0x0 0x0>;};

四,文件系统

1. defconfig改动

修改buildroot-201611/configs/sun8iw11p1_defconfig 下的配置:

 diff --git a/configs/sun8iw11p1_defconfig b/configs/sun8iw11p1_defconfigindex e4b6313..89c9e01 100755--- a/configs/sun8iw11p1_defconfig+++ b/configs/sun8iw11p1_defconfig@@ -273,7 +273,7 @@ BR2_SYSTEM_BIN_SH_BASH=y# BR2_SYSTEM_BIN_SH_NONE is not setBR2_SYSTEM_BIN_SH="bash"BR2_TARGET_GENERIC_GETTY=y-BR2_TARGET_GENERIC_GETTY_PORT="ttyS0"+BR2_TARGET_GENERIC_GETTY_PORT="ttyS3"# BR2_TARGET_GENERIC_GETTY_BAUDRATE_KEEP is not set# BR2_TARGET_GENERIC_GETTY_BAUDRATE_9600 is not set# BR2_TARGET_GENERIC_GETTY_BAUDRATE_19200 is not set

注:
执行build.sh编译builroot的过程:
tools/build/mkcommon.sh 会执行buildroot-201611/scripts/mkcommon.sh ,然后在buildroot-201611/scripts/build.sh 的build_buildroot函数中,
会判断是否存在out/sun8iw11p1/linux/common/buildroot/.config
如果存在,则使用该配置,否则使用buildroot-201611/configs/sun8iw11p1_defconfig ,所以需要
清空out目录,或者直接删除out/sun8iw11p1/linux/common/buildroot/.config

如果不确定是否配置成功,可以在buildroot-201611/package/skeleton/skeleton.mk 增加打印:

diff --git a/package/skeleton/skeleton.mk b/package/skeleton/skeleton.mkindex a4788e1..702596b 100644--- a/package/skeleton/skeleton.mk+++ b/package/skeleton/skeleton.mk@@ -223,6 +223,7 @@ endefelse ifeq ($(BR2_INIT_BUSYBOX),y)# Add getty to busybox inittabdefine SKELETON_SET_GETTY+       echo "SKELETON_TARGET_GENERIC_GETTY_PORT$(SKELETON_TARGET_GENERIC_GETTY_PORT)"$(SED) '/# 
GENERIC_SERIAL$$/s~^.*#~$(SKELETON_TARGET_GENERIC_GETTY_PORT)::respawn:/sbin/getty -L $(SKELETON_TARGET_GENERIC_GETTY_OPTIONS) 
$(SKELETON_TARGET_GENERIC_GETTY_PORT) $(SKELETON_TARGET_GENE$(TARGET_DIR)/etc/inittabendef

五,整体重新编译打包

 ./build.sh && ./build.sh pack
http://www.xdnf.cn/news/867367.html

相关文章:

  • 六种高阶微分方程的特解(原创:daode3056)
  • Java观察者模式深度解析:构建松耦合事件驱动系统的艺术
  • NC28 最小覆盖子串【牛客网】
  • 基于Axure+墨刀设计的电梯管理系统云台ERP的中保真原型图
  • Apache APISIX
  • CMake入门:3、变量操作 set 和 list
  • 深度学习项目之RT-DETR训练自己数据集
  • 通过模型文件估算模型参数量大小
  • Flask框架详解:轻量高效的Python Web开发利器
  • 深入解析Oracle SQL调优健康检查工具(SQLHC):从原理到实战优化
  • intense-rp-api开源程序是一个具有直观可视化界面的 API,可以将 DeepSeek 非正式地集成到 SillyTavern 中
  • Windows系统工具:WinToolsPlus 之 SQL Server Suspect/质疑/置疑/可疑/单用户等 修复
  • stress 服务器压力测试的工具学习
  • linux操作系统---网络协议
  • LeetCode 3370.仅含置位位的最小整数
  • 二维 根据矩阵变换计算镜像旋转角度
  • 短剧+小说网盘搜索系统(支持全网网盘转存拉新)
  • 《T/CI 404-2024 医疗大数据智能采集及管理技术规范》全面解读与实施分析
  • [ Qt ] | 与系统相关的操作(二):键盘、定时器、窗口移动和大小
  • 虚拟机CentOS 7 网络连接显示“以太网(ens33,被拔出)“、有线已拔出、CentOS7不显示网络图标
  • 【Unity】R3 CSharp 响应式编程 - 使用篇(集合)(三)
  • Async-profiler 内存采样机制解析:从原理到实现
  • Elasticsearch中什么是分析器(Analyzer)?它由哪些组件组成?
  • 2025年- H68-Lc176--46.全排列(回溯,组合)--Java版
  • 通光散基因组-文献精读139
  • C++11 defaulted和deleted函数从入门到精通
  • 【更新中】(文档+代码)基于推荐算法和Springboot+Vue的购物商城
  • 【echarts】分割环形图组件
  • 【Java算法】八大排序
  • 【2025】通过idea把项目到私有仓库(3)