Skip to content

Commit

Permalink
platform: nordic: Allow reading UICR registers
Browse files Browse the repository at this point in the history
On certain nRF plaforms, like nRF9160, reading UICR registers
might need special handling, which is already implemented in
nrfx_nvmc_uicr_word_read() so use that, instead on memcpy().

For more information, see nRF9160 Errata 7.

Change-Id: Iea9d0bf4184decd5650b4d4b620fbef0c64a55f6
Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
  • Loading branch information
SeppoTakalo authored and adeaarm committed Aug 19, 2024
1 parent a401ef1 commit ca03e40
Showing 1 changed file with 24 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include <tfm_platform_user_memory_ranges.h>

#include <hal/nrf_gpio.h>
#include <nrfx_nvmc.h>

#include "handle_attr.h"

Expand Down Expand Up @@ -61,6 +62,29 @@ tfm_platform_hal_read_service(const psa_invec *in_vec,

if (args->addr >= start &&
args->addr + args->len <= start + size) {
#ifdef NRF_UICR_S_BASE
if (start >= NRF_UICR_S_BASE &&
start < (NRF_UICR_S_BASE + sizeof(NRF_UICR_Type))) {
/* Range is inside UICR. Some nRF platforms need special handling */
uint32_t *src = (uint32_t *)args->addr;
uint32_t *dst = (uint32_t *)args->destination;
uint32_t uicr_end = NRF_UICR_S_BASE + sizeof(NRF_UICR_Type);

if (!IS_ALIGNED(src, sizeof(uint32_t)) ||
(args->len % sizeof(uint32_t)) != 0 ||
(args->addr + args->len) > uicr_end) {
return TFM_PLATFORM_ERR_NOT_SUPPORTED;
}

while (args->len) {
*dst++ = nrfx_nvmc_uicr_word_read(src++);
args->len -= sizeof(uint32_t);
}
out->result = 0;
err = TFM_PLATFORM_ERR_SUCCESS;
break;
}
#endif
memcpy(args->destination,
(const void *)args->addr,
args->len);
Expand Down

0 comments on commit ca03e40

Please sign in to comment.