RTM编译时,不要编译调试信息,甚至调试字符串都不要参与编译,测试通过,固件减小12.4%

This commit is contained in:
nnhy 2015-08-19 09:53:47 +00:00
parent 3453251026
commit 4b9161c1e6
5 changed files with 8 additions and 6 deletions

View File

@ -1,11 +1,11 @@
#include "Sys.h" #include "Sys.h"
// 仅用于调试使用的一些函数实现RTM不需要 // 仅用于调试使用的一些函数实现RTM不需要
#define MEM_DEBUG 1 #define MEM_DEBUG DEBUG
#if MEM_DEBUG #if MEM_DEBUG
#define mem_printf debug_printf #define mem_printf debug_printf
#else #else
__inline void mem_printf( const char *format, ... ) {} #define mem_printf(format, ...)
#endif #endif
extern uint __heap_base; extern uint __heap_base;

View File

@ -1,7 +1,7 @@
#include "Flash.h" #include "Flash.h"
#include <stdlib.h> #include <stdlib.h>
#define FLASH_DEBUG 1 #define FLASH_DEBUG DEBUG
//static const uint STM32_FLASH_KEY1 = 0x45670123; //static const uint STM32_FLASH_KEY1 = 0x45670123;
//static const uint STM32_FLASH_KEY2 = 0xcdef89ab; //static const uint STM32_FLASH_KEY2 = 0xcdef89ab;

View File

@ -270,10 +270,10 @@ typedef struct
void TSys::ShowInfo() void TSys::ShowInfo()
{ {
#if DEBUG
// 刚刚初始化完成的时间 // 刚刚初始化完成的时间
ulong initedTime = Time.Current(); ulong initedTime = Time.Current();
#if DEBUG
byte* ver = (byte*)&Version; byte* ver = (byte*)&Version;
debug_printf("%s::%s Code:%04X ", Company, Name, Code); debug_printf("%s::%s Code:%04X ", Company, Name, Code);
debug_printf("Ver:%x.%x Build:%s\r\n", *ver++, *ver++, BuildTime); debug_printf("Ver:%x.%x Build:%s\r\n", *ver++, *ver++, BuildTime);

2
Sys.h
View File

@ -17,7 +17,7 @@ extern "C"
#else #else
__inline void debug_printf( const char *format, ... ) {} #define debug_printf(format, ...)
#endif #endif
} }

View File

@ -7,7 +7,7 @@
#if MSG_DEBUG #if MSG_DEBUG
#define msg_printf debug_printf #define msg_printf debug_printf
#else #else
__inline void msg_printf( const char *format, ... ) {} #define msg_printf(format, ...)
#endif #endif
void SendTask(void* param); void SendTask(void* param);
@ -585,6 +585,7 @@ void StatTask(void* param)
// 显示统计信息 // 显示统计信息
void TinyController::ShowStat() void TinyController::ShowStat()
{ {
#if MSG_DEBUG
static uint lastSend = 0; static uint lastSend = 0;
static uint lastReceive = 0; static uint lastReceive = 0;
@ -606,6 +607,7 @@ void TinyController::ShowStat()
if(Last.Msg + Total.Msg > 0) if(Last.Msg + Total.Msg > 0)
retry = (Last.Send + tsend) * 100 / (Last.Msg + Total.Msg); retry = (Last.Send + tsend) * 100 / (Last.Msg + Total.Msg);
msg_printf("Tiny::State 成功=%d%% 平均=%dus 速度=%d Byte/s 重发=%d.%02d 收发=%d/%d \r\n", rate, cost, speed, retry/100, retry%100, Last.Receive + Total.Receive, Last.Msg + Total.Msg); msg_printf("Tiny::State 成功=%d%% 平均=%dus 速度=%d Byte/s 重发=%d.%02d 收发=%d/%d \r\n", rate, cost, speed, retry/100, retry%100, Last.Receive + Total.Receive, Last.Msg + Total.Msg);
#endif
} }
void MessageNode::SetMessage(TinyMessage& msg) void MessageNode::SetMessage(TinyMessage& msg)