-
Notifications
You must be signed in to change notification settings - Fork 263
[nrf noup] boot: zephyr: cleanup of SPIM for nRF91 #606
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -26,7 +26,9 @@ | |
| #include <hal/nrf_vpr.h> | ||
| #include <softperipheral_regif.h> | ||
| #endif | ||
|
|
||
| #if defined(SPIM_PRESENT) | ||
| #include <hal/nrf_spim.h> | ||
| #endif | ||
|
|
||
| #include <string.h> | ||
|
|
||
|
|
@@ -200,6 +202,33 @@ void nrf_cleanup_peripheral(void) | |
| } | ||
| #endif | ||
|
|
||
| #if defined(SPIM_PRESENT) | ||
| /* Stop SPIM EasyDMA and disable all instances to prevent stale DMA | ||
| * from causing RAMACCERR when TF-M reconfigures SPU permissions. */ | ||
| { | ||
| NRF_SPIM_Type *spim_inst[] = { | ||
| #if defined(NRF_SPIM0) | ||
| NRF_SPIM0, | ||
| #endif | ||
| #if defined(NRF_SPIM1) | ||
| NRF_SPIM1, | ||
| #endif | ||
| #if defined(NRF_SPIM2) | ||
| NRF_SPIM2, | ||
| #endif | ||
| #if defined(NRF_SPIM3) | ||
| NRF_SPIM3, | ||
| #endif | ||
| }; | ||
|
|
||
| for (int i = 0; i < sizeof(spim_inst) / sizeof(spim_inst[0]); ++i) { | ||
| nrf_spim_task_trigger(spim_inst[i], NRF_SPIM_TASK_STOP); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. in theory code should wait for STOPPED event. Same goes for existing UARTE code. Reference:
|
||
| nrf_spim_disable(spim_inst[i]); | ||
| nrf_spim_int_disable(spim_inst[i], 0xFFFFFFFF); | ||
| } | ||
| } | ||
| #endif | ||
|
|
||
| #if defined(NRF_PPI) | ||
| nrf_ppi_channels_disable_all(NRF_PPI); | ||
| #endif | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| - Added SPIM peripheral cleanup in nrf_cleanup to prevent RAMACCERR when | ||
| TF-M reconfigures SPU SRAM permissions after MCUboot uses SPI flash. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nrf_cleanup_peripheral()now also stops/disables SPIM, but the public API comment inboot/zephyr/include/nrf_cleanup.hstill says it only disables RTC and UARTE. Please update that header comment so the documented behavior matches what the function actually does (and so future additions don’t get missed).