Skip to content

Commit 674dbfb

Browse files
committed
fix(st-uart): skip console flush if UART is disabled
Check the USART_CR1_UE bit and if it is 0, the UART is not enabled, or not clocked (but the read won't freeze the bus and will return 0). In this case skip the console flush. If flush didn't happen in time, just exit the function instead of panic. Signed-off-by: Yann Gautier <yann.gautier@foss.st.com> Change-Id: I5d1ef7e51612b4795e314b2f2da04a514b6c96a0 Reviewed-on: https://gerrit.st.com/c/mpu/oe/st/tf-a/+/315467 ACI: CITOOLS <MDG-smet-aci-reviews@list.st.com>
1 parent 6d9aa48 commit 674dbfb

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

drivers/st/uart/aarch32/stm32_console.S

+7-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2018-2022, ARM Limited and Contributors. All rights reserved.
2+
* Copyright (c) 2018-2023, ARM Limited and Contributors. All rights reserved.
33
*
44
* SPDX-License-Identifier: BSD-3-Clause
55
*/
@@ -217,14 +217,19 @@ func console_stm32_core_flush
217217
cmp r0, #0
218218
ASM_ASSERT(ne)
219219
#endif /* ENABLE_ASSERTIONS */
220+
/* Skip flush if UART is not enabled */
221+
ldr r1, [r0, #USART_CR1]
222+
tst r1, #USART_CR1_UE
223+
beq 1f
220224
/* Check Transmit Data Register Empty */
221225
mov r2, #USART_TIMEOUT
222226
txe_loop_3:
223227
subs r2, r2, #1
224-
beq plat_panic_handler
228+
beq 1f
225229
ldr r1, [r0, #USART_ISR]
226230
tst r1, #USART_ISR_TXE
227231
beq txe_loop_3
232+
1:
228233
bx lr
229234
endfunc console_stm32_core_flush
230235

0 commit comments

Comments
 (0)