在移植RT-Thread新版本到STM32时,遇到警告:
warning: #550-D: variable "obj" was set but never used
定位到文件为object.c中如下部分:
原因为obj用在了RT_ASSERT中,而RT_ASSERT只有在debug模式下,宏才会有实际的函数体。解决方式为:
在rtconfig.h配置文件中,勾选RT_DEBUG:
报错:
Error: L6218E: Undefined symbol rt_thread_create (referred from main.o).
解决方式:
在rtconfig配置文件中,打开RT_USING_HEAP:
移植完成,需要在board.c中做配置初始化工作,board.c中做rt_kprintf重映射,映射代码为(这里为串口映射):
void rt_hw_console_output(const char *str)
{
/* 进入临界段 */
rt_enter_critical();
/* 直到字符串结束 */
while (*str!='\0')
{
/* 换行 */
if (*str=='\n')
{
USART_SendData(DEBUG_USARTx, '\r');
while (USART_GetFlagStatus(DEBUG_USARTx, USART_FLAG_TXE) == RESET);
}
USART_SendData(DEBUG_USARTx, *str++);
while (USART_GetFlagStatus(DEBUG_USARTx, USART_FLAG_TXE) == RESET);
}
/* 退出临界段 */
rt_exit_critical();
}