Skip to content

Commit e2a352b

Browse files
committed
[nrf noup] boot: zephyr: nrf_cleanup: clean all enabled UARTE instances
The UARTE cleanup list was hardcoded and missed EasyDMA-capable instances on some SoCs, so a UARTE left active by the previous image could keep writing RAM via EasyDMA after chain-load and fault the next image. Derive the list from devicetree (DT_FOREACH_STATUS_OKAY) so every enabled UARTE is quiesced, and stop the TX direction alongside RX before disabling. Signed-off-by: cqfmh <258567898+cqfmh@users.noreply.github.com>
1 parent 252d7bb commit e2a352b

1 file changed

Lines changed: 8 additions & 17 deletions

File tree

boot/zephyr/nrf_cleanup.c

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,13 @@
2424
#endif
2525

2626
#include <string.h>
27+
#include <zephyr/devicetree.h>
2728

2829
#if USE_PARTITION_MANAGER
2930
#include <pm_config.h>
3031
#endif
3132

32-
#if defined(NRF_UARTE0) || defined(NRF_UARTE1) || defined(NRF_UARTE20) || \
33-
defined(NRF_UARTE30)
33+
#if DT_HAS_COMPAT_STATUS_OKAY(nordic_nrf_uarte)
3434
#define NRF_UARTE_CLEANUP
3535
#endif
3636

@@ -85,23 +85,11 @@ static inline void nrf_cleanup_grtc(void)
8585
#endif
8686

8787
#if defined(NRF_UARTE_CLEANUP)
88+
#define NRF_UARTE_PTR(node_id) (NRF_UARTE_Type *)(uintptr_t)DT_REG_ADDR(node_id),
8889
static NRF_UARTE_Type *nrf_uarte_to_clean[] = {
89-
#if defined(NRF_UARTE0)
90-
NRF_UARTE0,
91-
#endif
92-
#if defined(NRF_UARTE1)
93-
NRF_UARTE1,
94-
#endif
95-
#if defined(NRF_UARTE20)
96-
NRF_UARTE20,
97-
#endif
98-
#if defined(NRF_UARTE30)
99-
NRF_UARTE30,
100-
#endif
101-
#if defined(NRF_UARTE136)
102-
NRF_UARTE136,
103-
#endif
90+
DT_FOREACH_STATUS_OKAY(nordic_nrf_uarte, NRF_UARTE_PTR)
10491
};
92+
#undef NRF_UARTE_PTR
10593
#endif
10694

10795
#if defined(CONFIG_NRFX_CLOCK)
@@ -134,10 +122,13 @@ void nrf_cleanup_peripheral(void)
134122
nrfy_uarte_int_disable(current, 0xFFFFFFFF);
135123
nrfy_uarte_int_uninit(current);
136124
nrfy_uarte_task_trigger(current, NRF_UARTE_TASK_STOPRX);
125+
nrfy_uarte_task_trigger(current, NRF_UARTE_TASK_STOPTX);
137126

138127
nrfy_uarte_event_clear(current, NRF_UARTE_EVENT_RXSTARTED);
139128
nrfy_uarte_event_clear(current, NRF_UARTE_EVENT_ENDRX);
140129
nrfy_uarte_event_clear(current, NRF_UARTE_EVENT_RXTO);
130+
nrfy_uarte_event_clear(current, NRF_UARTE_EVENT_ENDTX);
131+
nrfy_uarte_event_clear(current, NRF_UARTE_EVENT_TXSTOPPED);
141132
nrfy_uarte_disable(current);
142133

143134
#ifndef CONFIG_SOC_SERIES_NRF54LX

0 commit comments

Comments
 (0)