From 20587e2c71716e243a883198bd7e29ce246f5e25 Mon Sep 17 00:00:00 2001 From: Andrzej Puzdrowski Date: Mon, 1 Sep 2025 16:47:16 +0200 Subject: [PATCH] [nrf noup] boot/zephyr/nrf_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 --- boot/zephyr/nrf_cleanup.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/boot/zephyr/nrf_cleanup.c b/boot/zephyr/nrf_cleanup.c index 5ddc74a64..56e1084a7 100644 --- a/boot/zephyr/nrf_cleanup.c +++ b/boot/zephyr/nrf_cleanup.c @@ -1,9 +1,11 @@ /* - * Copyright (c) 2020 Nordic Semiconductor ASA + * Copyright (c) 2020-2025 Nordic Semiconductor ASA * * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause */ +#include + #if defined(CONFIG_NRFX_CLOCK) #include #endif @@ -105,6 +107,21 @@ void nrf_cleanup_peripheral(void) for (int i = 0; i < sizeof(nrf_uarte_to_clean) / sizeof(nrf_uarte_to_clean[0]); ++i) { NRF_UARTE_Type *current = nrf_uarte_to_clean[i]; + /* Ensured that RX is stopped */ + if (nrfy_uarte_event_check(current, NRF_UARTE_EVENT_RXSTARTED)) { + nrfy_uarte_task_trigger(current, NRF_UARTE_TASK_STOPRX); + /* Wait up to 100ms for task to stop */ + for (int i = 0; i < 1000; i++) { + if (nrfy_uarte_event_check(current, NRF_UARTE_EVENT_RXTO) || + nrfy_uarte_event_check(current, NRF_UARTE_EVENT_ERROR)) { + /* RX terminated, break*/ + break; + } + /* Wait before next check */ + k_busy_wait(100); + } + } + nrfy_uarte_int_disable(current, 0xFFFFFFFF); nrfy_uarte_int_uninit(current); nrfy_uarte_task_trigger(current, NRF_UARTE_TASK_STOPRX);