Skip to content

Commit e7e1380

Browse files
committed
[bsp][qemu-vexpress-a9] add earlycon
Fix missing auto-init debug prints in qemu-vexpress-a9: add print buffer in board.c to cache messages before UART init, then flush after initialization.
1 parent a036ddc commit e7e1380

File tree

3 files changed

+37
-1
lines changed

3 files changed

+37
-1
lines changed

bsp/qemu-vexpress-a9/.config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ CONFIG_RT_USING_DEBUG=y
142142
CONFIG_RT_DEBUGING_ASSERT=y
143143
CONFIG_RT_DEBUGING_COLOR=y
144144
CONFIG_RT_DEBUGING_CONTEXT=y
145-
# CONFIG_RT_DEBUGING_AUTO_INIT is not set
145+
CONFIG_RT_DEBUGING_AUTO_INIT=y
146146
# CONFIG_RT_USING_CI_ACTION is not set
147147

148148
#

bsp/qemu-vexpress-a9/drivers/board.c

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,46 @@ struct mem_desc platform_mem_desc[] = {
3535
};
3636
#endif
3737

38+
/* Console buffer for early print before device init */
39+
#define RT_CONSOLE_EARLY_BUF_SIZE (RT_CONSOLEBUF_SIZE * 4)
40+
static char console_early_buf[RT_CONSOLE_EARLY_BUF_SIZE];
41+
static rt_size_t console_early_buf_idx = 0;
42+
3843
const rt_uint32_t platform_mem_desc_size = sizeof(platform_mem_desc)/sizeof(platform_mem_desc[0]);
3944

4045
#define SYS_CTRL __REG32(REALVIEW_SCTL_BASE)
4146

4247
extern void rt_hw_ipi_handler_install(int ipi_vector, rt_isr_handler_t ipi_isr_handler);
4348

49+
void rt_hw_console_output(const char *str)
50+
{
51+
if (console_early_buf_idx < RT_CONSOLE_EARLY_BUF_SIZE - 1)
52+
{
53+
rt_size_t copy_len = rt_strlen(str);
54+
if (console_early_buf_idx + copy_len >= RT_CONSOLE_EARLY_BUF_SIZE)
55+
{
56+
copy_len = RT_CONSOLE_EARLY_BUF_SIZE - console_early_buf_idx - 1;
57+
}
58+
59+
if (copy_len > 0)
60+
{
61+
rt_memcpy(&console_early_buf[console_early_buf_idx], str, copy_len);
62+
console_early_buf_idx += copy_len;
63+
console_early_buf[console_early_buf_idx] = '\0';
64+
}
65+
}
66+
}
67+
68+
static void rt_earlycon_kick_completed(void)
69+
{
70+
if (console_early_buf_idx > 0)
71+
{
72+
rt_kputs(console_early_buf);
73+
console_early_buf_idx = 0;
74+
console_early_buf[0] = '\0';
75+
}
76+
}
77+
4478
void idle_wfi(void)
4579
{
4680
asm volatile ("wfi");
@@ -85,6 +119,7 @@ void rt_hw_board_init(void)
85119

86120
rt_components_board_init();
87121
rt_console_set_device(RT_CONSOLE_DEVICE_NAME);
122+
rt_earlycon_kick_completed();
88123

89124
rt_thread_idle_sethook(idle_wfi);
90125

bsp/qemu-vexpress-a9/rtconfig.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@
8484
#define RT_DEBUGING_ASSERT
8585
#define RT_DEBUGING_COLOR
8686
#define RT_DEBUGING_CONTEXT
87+
#define RT_DEBUGING_AUTO_INIT
8788

8889
/* Inter-Thread communication */
8990

0 commit comments

Comments
 (0)