Skip to content

Commit de96a27

Browse files
committed
[nrf noup] boot/zephyrnrf_cleanup: ensure UARTE RX disabled
The workaround in the UARTE driver which was up to disabling RX was removed in zephyr-rtos v4.0. Since that MCUboot needs to do corresponding action. Signed-off-by: Andrzej Puzdrowski <[email protected]>
1 parent 285fd59 commit de96a27

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

boot/zephyr/nrf_cleanup.c

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
/*
2-
* Copyright (c) 2020 Nordic Semiconductor ASA
2+
* Copyright (c) 2020-2025 Nordic Semiconductor ASA
33
*
44
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
55
*/
66

7+
#include <zephyr/kernel.h>
8+
79
#if defined(CONFIG_NRFX_CLOCK)
810
#include <hal/nrf_clock.h>
911
#endif
@@ -105,6 +107,21 @@ void nrf_cleanup_peripheral(void)
105107
for (int i = 0; i < sizeof(nrf_uarte_to_clean) / sizeof(nrf_uarte_to_clean[0]); ++i) {
106108
NRF_UARTE_Type *current = nrf_uarte_to_clean[i];
107109

110+
/* Ensured that RX is stopped */
111+
if (nrfy_uarte_event_check(current, NRF_UARTE_EVENT_RXSTARTED)) {
112+
nrfy_uarte_task_trigger(current, NRF_UARTE_TASK_STOPRX);
113+
/* Wait up to 100ms for task to stop */
114+
for (int i = 0; i < 1000; i++) {
115+
if (nrfy_uarte_event_check(current, NRF_UARTE_EVENT_RXTO) ||
116+
nrfy_uarte_event_check(current, NRF_UARTE_EVENT_ERROR)) {
117+
/* RX terminated, break*/
118+
break;
119+
}
120+
/* Wait before next check */
121+
k_busy_wait(100);
122+
}
123+
}
124+
108125
nrfy_uarte_int_disable(current, 0xFFFFFFFF);
109126
nrfy_uarte_int_uninit(current);
110127
nrfy_uarte_task_trigger(current, NRF_UARTE_TASK_STOPRX);

0 commit comments

Comments
 (0)