mtk uart串口信息是包含pl lk kernel层log信息
本次项目的包含两组uart口 uart0,uart1客户要使用uart用于通信功能
1 配置好GPIO口信息
1)配置dts文件
查看原理图和GPIO映射表配置GPIO口信息
从原理图和GPIO口映射表中可以看出uart0 Rx口是gpio20引脚,uart0 Tx口是gpio21引脚; uart1 Rx口是gpio22引脚, Tx口是gpio23引脚
/* UART GPIO */
&apuart0 {
pinctrl-names = "uart0_gpio_default",
"uart0_rx_set",
"uart0_rx_clear",
"uart0_tx_set",
"uart0_tx_clear";
pinctrl-0 = <&uart0_gpio_def_cfg>;
pinctrl-1 = <&uart0_rx_set_cfg>;
pinctrl-2 = <&uart0_rx_clr_cfg>;
pinctrl-3 = <&uart0_tx_set_cfg>;
pinctrl-4 = <&uart0_tx_clr_cfg>;
status = "okay";
};
&apuart1 {
pinctrl-names = "uart1_gpio_default",
"uart1_rx_set",
"uart1_rx_clear",
"uart1_tx_set",
"uart1_tx_clear";
pinctrl-0 = <&uart1_gpio_def_cfg>;
pinctrl-1 = <&uart1_rx_set_cfg>;
pinctrl-2 = <&uart1_rx_clr_cfg>;
pinctrl-3 = <&uart1_tx_set_cfg>;
pinctrl-4 = <&uart1_tx_clr_cfg>;
status = "okay";
};
&pio {
/* UART GPIO Settings - Start */
/* UART0: rx set, rx clear, tx clear, tx clear*/
uart0_gpio_def_cfg:uart0gpiodefault {
};
uart0_rx_set_cfg:uart0_rx_set@gpio20 {
pins_cmd_dat {
pins = ;
};
};
uart0_rx_clr_cfg:uart0_rx_clear@gpio20 {
pins_cmd_dat {
pins = ;
slew-rate = <1>;
output-high;
};
};
uart0_tx_set_cfg:uart0_tx_set@gpio21 {
pins_cmd_dat {
pins = ;
};
};
uart0_tx_clr_cfg:uart0_tx_clear@gpio21 {
pins_cmd_dat {
pins = ;
slew-rate = <1>;
output-high;
};
};
/* UART1: rx set, rx clear, tx clear, tx clear*/
uart1_gpio_def_cfg:uart1gpiodefault {
};
uart1_rx_set_cfg:uart1_rx_set@gpio22 {
pins_cmd_dat {
pins = ;
};
};
uart1_rx_clr_cfg:uart1_rx_clear@gpio22 {
pins_cmd_dat {
pins = ;
slew-rate = <1>;
output-high;
};
};
uart1_tx_set_cfg:uart1_tx_set@gpio23 {
pins_cmd_dat {
pins = ;
};
};
uart1_tx_clr_cfg:uart1_tx_clear@gpio23 {
pins_cmd_dat {
pins = ;
slew-rate = <1>;
output-high;
};
};
};/* UART GPIO end */
2)配置dws文件
2 pl层配置
首先明白log口的定义,CFG_UART_LOG和CFG_UART_META,在mediatek/custom/project name/preloader/cust bldr.mak中定义。使用CFG UART LOG定义AP日志端口;CFG_UART_META用于定义MD/META日志端口。
\vendor\mediatek\proprietary\bootable\bootloader\preloader\custom\tb8765ap1_bsp\cust_bldr.mak 改定义口
CFG_UART_LOG :=UART4
CFG_UART_META :=UART2
\vendor\mediatek\proprietary\bootable\bootloader\preloader\platform\mt6739\mode\DUMMY_AP.mak改定义口
CFG_UART_LOG :=UART3
CFG_UART_META :=UART3
\vendor\mediatek\proprietary\bootable\bootloader\preloader\platform\mt6739\default.mak 改定义口
CFG_UART_LOG :=UART4
CFG_UART_META :=UART2
**\vendor\mediatek\proprietary\bootable\bootloader\preloader\platform\mt6739\src\drivers\uart.c 打印实现体不执行直接return返回
void PutUARTByte (const char c)
{
// /*disable UART log in preloader, do nothing here*/
return;
while (!(UART_READ32 (UART_LSR(g_uart)) & UART_LSR_THRE))
{
}
if (c == '\n')
UART_WRITE32 ((unsigned int) '\r', UART_THR(g_uart));
UART_WRITE32 ((unsigned int) c, UART_THR(g_uart));
}
**
2)lk层
**\vendor\mediatek\proprietary\bootable\bootloader\lk\app\mt_boot\mt_boot.c 传进kernel参数printk.disable_uart=1表示不打印log
printk.disable_uart=1
`
int boot_linux_fdt(void *kernel, unsigned *tags,
unsigned machtype,
void *ramdisk, unsigned ramdisk_sz)
{
..........
if (!has_set_p2u) {
switch (eBuildType) {
case BUILD_TYPE_USER://用户版本
if (((g_boot_mode == META_BOOT) && is_meta_log_disable &&
#ifdef LOG_STORE_SUPPORT
(is_meta_log_disable() == 0)) || g_boot_arg->log_dynamic_switch)
#else
(is_meta_log_disable() == 0)))
#endif
cmdline_append("printk.disable_uart=1");
else
cmdline_append("printk.disable_uart=1");
break;
case BUILD_TYPE_USERDEBUG://用户调试版本
if ((g_boot_mode == META_BOOT) && is_meta_log_disable &&
#ifdef LOG_STORE_SUPPORT
(is_meta_log_disable() == 1) && (g_boot_arg->log_dynamic_switch == 0))
#else
(is_meta_log_disable() == 1))
#endif
cmdline_append("printk.disable_uart=1 slub_debug=O");
#ifdef LOG_STORE_SUPPORT
else if (boot_ftrace && g_boot_arg->log_dynamic_switch == 0)
#else
else if (boot_ftrace)
#endif
cmdline_append("printk.disable_uart=1 slub_debug=-");
else
cmdline_append("printk.disable_uart=1");
break;
case BUILD_TYPE_ENG://工程师版本
if ((g_boot_mode == META_BOOT) && is_meta_log_disable &&
(is_meta_log_disable() == 1))
cmdline_append("printk.disable_uart=1 slub_debug=O");
else
cmdline_append("printk.disable_uart=1 ddebug_query=\"file *mediatek* +p ; file *gpu* =_\"");
break;
default:
assert(0);
break;
}
.......
}
`**
修改路径有两个\vendor\mediatek\proprietary\bootable\bootloader\lk\platform\common\uart\uart.c
\vendor\mediatek\proprietary\bootable\bootloader\lk\platform\mt6739\uart.c
屏蔽uart开关宏
//#define __ENABLE_UART_LOG_SWITCH_FEATURE__
修改路径有两个\vendor\mediatek\proprietary\bootable\bootloader\lk\platform\common\uart\uart.c
\vendor\mediatek\proprietary\bootable\bootloader\lk\platform\mt6739\uart.c
打印实现体不执行直接return返回**
int uart_putc(const char c )
{
/*disable UART log in lk, do nothing here*/
return 0;
if (g_boot_arg->log_enable == 0)
return 0;
#ifdef USER_LOAD
if (g_boot_arg->log_dynamic_switch == 0)
return 0;
if (g_lk_final_log == 0)
return 0;
#endif
while (!(DRV_Reg32(UART_LSR(g_uart)) & UART_LSR_THRE));
if (c == '\n')
mt65xx_reg_sync_writel((unsigned int)'\r', UART_THR(g_uart));
mt65xx_reg_sync_writel((unsigned int)c, UART_THR(g_uart));
return 0;
}
int uart_getc(void) /* returns -1 if no data available */
{
return 0;
if (g_boot_arg->log_enable == 0)
return 0;
#ifdef USER_LOAD
if (g_boot_arg->log_dynamic_switch == 0)
return 0;
if (g_lk_final_log == 0)
return 0;
#endif
while (!(DRV_Reg32(UART_LSR(g_uart)) & UART_LSR_DR));
return (int)DRV_Reg32(UART_RBR(g_uart));
}
void uart_puts(const char *s)
{
return;
while (*s)
uart_putc(*s++);
}
\trusty\vendor\mediatek\proprietary\platform\mt6739\rules.mk****把log打印口换成串口3 uart0和uart1就不会有打印串口信息
CFG_LOG_REG_BASE ?= UART3_BASE
4 kernel层
把动态打印,时间打印,打印信息相关宏改关闭,我这里是直接屏蔽掉
**这里有两处修改的地方
\device\mediateksample\tb8765ap1_bsp\elink\PCBA\S108\tb8765ap1_bsp_debug_defconfig
\device\mediateksample\tb8765ap1_bsp\elink\PCBA\S108\tb8765ap1_bsp_defconfig
#CONFIG_PRINTK_TIME=y
#CONFIG_DYNAMIC_DEBUG=y
#CONFIG_DEBUG_INFO=y
**
\kernel-4.4\include\linux\printk.h 把打印等级给调到最低值 0
/* We show everything that is MORE important than this.. */
#define CONSOLE_LOGLEVEL_SILENT 0 /* Mum's the word */
#define CONSOLE_LOGLEVEL_MIN 0 /* Minimum loglevel we let people use */
#define CONSOLE_LOGLEVEL_QUIET 0 /* Shhh ..., when booted with "quiet" */
#define CONSOLE_LOGLEVEL_DEFAULT 0 /* anything MORE serious than KERN_DEBUG */
#define CONSOLE_LOGLEVEL_DEBUG 0 /* issue debug messages */
#define CONSOLE_LOGLEVEL_MOTORMOUTH 0 /* You can't shut this one up */
5 控制台相关使能log口关闭
**\device\mediatek\mt6739\init.mt6739.rc
**
不使能prink
## mtk printk uart controller
on property:persist.vendor.uartconsole.enable=0
write /proc/mtprintk ${persist.vendor.uartconsole.enable}
....
on property:persist.vendor.mediatek.fg.log.enable=0
write /sys/devices/platform/battery_meter/FG_daemon_log_level 7
write /sys/bus/platform/devices/battery/FG_daemon_log_level 7
write /proc/sys/kernel/printk 8
\device\mediatek\mt6739\init.mt6739.usb.rc
不使能prink
on property:vendor.usb.printk=0
write /proc/sys/kernel/printk ${vendor.usb.printk}
on property:persist.vendor.usb.printk=0
setprop vendor.usb.printk ${persist.vendor.usb.printk}
\system\core\rootdir\init.rc
关闭debuggable
on property:ro.debuggable=0
# Give writes to anyone for the trace folder on debug builds.
# The folder is used to store method traces.
chmod 0773 /data/misc/trace
# Give reads to anyone for the window trace folder on debug builds.
chmod 0775 /data/misc/wmtrace
start console