展讯平台如何调试之打LOG--串口log
2012-04-04 17:39
1111 查看
公司最近做一款数据卡,还是用的展讯的8800,板子还没回来,想先在8802上实验一下!但是在移植到8802上的时候板子一直都跑不起来。以前出现问题的时候第一反映就是去打LOG,查异常,但是这次貌似死得很早,根本就认不出diag!怎么办呢?
在这种情况下就用串口来打印吧,选择的理由是串口初始化简单,打印工具普遍!
在确定了不是FLASH的问题后,就要确定BOOT是不是跑过去了,汇编跑过去后进入main里面,在main.c里面的main函数里面把tf_main_nand.c里面的对串口初始化的代码考出来,
好了,在main.c里面加入TF_UartInit();串口初始化了,串口初始化完毕以后怎么打串口log呢?当时也不知道,就全局搜索关于uarttrace之类的函数,结果在tf_main_nand.c里面有这么一个函数,TF_UartTrace,好吧,移植一下,让这个函数在main.c里面就能用
OK,这样加了自己的一些宏,同时把这个打印函数所有要用的关联宏和函数拷贝出来,就好了。这样的话就只要在程序里面铺满 init_trace(),这样在XP下自带的串口输出工具就可以知道程序到底走在哪里了!
在这种情况下就用串口来打印吧,选择的理由是串口初始化简单,打印工具普遍!
在确定了不是FLASH的问题后,就要确定BOOT是不是跑过去了,汇编跑过去后进入main里面,在main.c里面的main函数里面把tf_main_nand.c里面的对串口初始化的代码考出来,
#define UART_BASE_CLK 26000000 LOCAL void TF_UartInit(void) { unsigned long baud_rate; baud_rate = UART_BASE_CLK/115200; //for 48MHz clk src *(volatile uint32 *)GR_GEN0 |= BIT_21; #ifdef PLATFORM_SC8800G //uart clk sel and div config REG32(GR_CLK_DLY) |= (BIT_22 | BIT_23); REG32(GR_CLK_GEN5) &= ~(BIT_5 | BIT_4 | BIT_3); #endif *(volatile uint32 *)0x84000010 = 0x00; *(volatile uint32 *)0x84000018 = 0x1C; *(volatile uint32 *)0x8400001C = 0x00; *(volatile uint32 *)0x84000024 = (uint16)baud_rate; //115200 *(volatile uint32 *)0x84000028 = (baud_rate>>8); }
好了,在main.c里面加入TF_UartInit();串口初始化了,串口初始化完毕以后怎么打串口log呢?当时也不知道,就全局搜索关于uarttrace之类的函数,结果在tf_main_nand.c里面有这么一个函数,TF_UartTrace,好吧,移植一下,让这个函数在main.c里面就能用
#include "stdarg.h" #define SIO_TX_EMPTY(s) ((s) & 0xFF00) #define WAIT_FIFO_EMPTY \ { \ while( SIO_TX_EMPTY(*(volatile uint32*)(0x8400000c)));\ } LOCAL void WriteCharToUART(char c) { while ((((*(volatile uint32*)0x8400000c) >> 8 )&0xFF) >= 32 ) {}; *(volatile uint32*)0x84000000 = c; } LOCAL void TF_SendMsgOut(char * buf, int size) { while (size --) { WriteCharToUART(*(buf++)); } WriteCharToUART('\r'); WriteCharToUART('\n'); } #define TRACE_LOG_MSG \ va_start(args, x_format);\ nBuf = vsprintf(format_str, x_format, args);\ /* was there an error? */\ /* Was the expanded string too long? */\ va_end(args);\ /* Send message to serial buffer! */ \ TF_SendMsgOut(format_str, nBuf + 1); PUBLIC void cg_TF_UartTrace( const char *x_format, ...) { char format_str[256]; va_list args; int nBuf; WAIT_FIFO_EMPTY memset (format_str,0,256); TRACE_LOG_MSG /*assert verified*/ WAIT_FIFO_EMPTY } LOCAL void delay() { uint32 i = 1000; while(i--); } #define init_trace() cg_TF_UartTrace("%s,%d", __func__, __LINE__);\ delay()
OK,这样加了自己的一些宏,同时把这个打印函数所有要用的关联宏和函数拷贝出来,就好了。这样的话就只要在程序里面铺满 init_trace(),这样在XP下自带的串口输出工具就可以知道程序到底走在哪里了!
相关文章推荐
- 展讯平台如何调试之打LOG--串口log
- 展讯平台如何调试之assert的串口打印
- day02_ndk常见错误&如何采用log调试代码
- 如何把wince Sate210 的调试串口(com3-uart2)改成普通串口
- android串口编程--------如何在window7系统上模拟串口调试
- 如何使用minicom去抓Android手机的串口Log
- WINDOWS如何调试Flash程序保存SWF其产生的LOG
- 如何在User版本开启串口(Uart),抓取上层Log,开启输入控制台
- 展讯平台调试之文件输出LOG
- 如何提高keil串口的调试效率
- 如何在WinCE模拟器中调试串口程序
- 如何在WinCE模拟器中调试串口程序
- 【已解决】 c8812在eclipse上调试打不出log来?求帮助如何解决?!!!
- 如何在User版本开启串口(Uart),抓取上层Log,开启输入控制台
- LINUX系统的调试信息是如何从串口输出的
- 如何关闭cocos2d调试时输出的log
- 如何正确打开华为手机的 USB 调试和 完整 log 功能?
- 如何在WinCE模拟器中调试串口程序(两台设备、一台设备的两种情况下的串口调试)
- 【MTK6572】如何在User版本开启串口(Uart),抓取上层Log,开启输入控制台
- android开发板只有网口和串口如何使用android studio进行调试