已经实现了rt_hw_console_output函数,如下
#ifdef RT_USING_CONSOLE
void rt_hw_console_output(const char *str)
{
rt_enter_critical();
while ( *str != '\0')
{
if ( *str == '\n')
{
soc_uart1_putchar('\r');
}
soc_uart1_putchar(*str++);
}
rt_exit_critical();
}
#endif
尝试过单独使用rt_hw_console_output函数打印字符串,能够正常使用。查看rt_kprintf函数,如下
void rt_kprintf(const char *fmt, ...)
{
va_list args;
rt_size_t length;
static char rt_log_buf[RT_CONSOLEBUF_SIZE];
va_start(args, fmt);
/* the return value of vsnprintf is the number of bytes that would be
* written to buffer had if the size of the buffer been sufficiently
* large excluding the terminating null byte. If the output string
* would be larger than the rt_log_buf, we have to adjust the output
* length. */
length = rt_vsnprintf(rt_log_buf, sizeof(rt_log_buf) - 1, fmt, args);
if (length > RT_CONSOLEBUF_SIZE - 1)
length = RT_CONSOLEBUF_SIZE - 1;
#ifdef RT_USING_DEVICE
if (_console_device == RT_NULL)
{
rt_hw_console_output(rt_log_buf);
}
else
{
rt_uint16_t old_flag = _console_device->open_flag;
_console_device->open_flag |= RT_DEVICE_FLAG_STREAM;
rt_device_write(_console_device, 0, rt_log_buf, length);
_console_device->open_flag = old_flag;
}
#else
rt_hw_console_output(rt_log_buf);
#endif
va_end(args);
}
猜测是rt_vsnprintf附近出现问题。本人在同为la132架构的1c102芯片可正常运行,但在模拟相似内核的fpga上运行验证的时候出现了很多bug。