We've encountered an issue when reading OTP memory using tfm_platform_mem_read().
After invoking tfm_platform_mem_read(), any subsequent call to k_sleep() (or any other waiting function) triggers the following assertion:
ASSERTION FAIL [!sys_dnode_is_linked(&to->node)] @ WEST_TOPDIR/ncs/zephyr/kernel/timeout.c:111
nRF Connect SDK v3.2.1
Reproduction
The issue can be easily reproduced on nrf9151dk using the tfm_hello_world sample.
-
In
demonstrate_secure_memory_access(void), replace line 57:
info_ram = secure_read_word((intptr_t)&NRF_FICR_S->INFO.RAM);
with:
info_ram = secure_read_word((intptr_t)(&NRF_UICR_S->OTP[0]));
-
Add the following loop at the end of
main():
while (true)
{
printk("Example finished successfully!\n");
k_sleep(K_SECONDS(1));
}
After this modification, the assertion occurs as soon as k_sleep() is executed.
Project config:CONFIG_TFM_PROFILE_TYPE_MINIMAL=y
CONFIG_PSA_WANT_GENERATE_RANDOM=y
CONFIG_ASSERT=y
CONFIG_SERIAL=y
CONFIG_LOG=y
CONFIG_USE_SEGGER_RTT=n
CONFIG_RTT_CONSOLE=n
CONFIG_LOG_BACKEND_UART=y
CONFIG_UART_CONSOLE=y
CONFIG_CONSOLE=y
CONFIG_LOG_MODE_IMMEDIATE=y
Investigation
We suspect the issue may be related to:
modules/hal/nordic/nrfx/bsp/stable/mdk/nrf91_erratas.h
If we modify the implementation of:
bool nrf91_errata_7(void)
to always return true, the issue disappears and the system works as expected.
Questions
Could you confirm a bug or incorrect behavior in nrf91_errata_7()?
Additionally, should similar behavior be expected for other functions in the same file (e.g., nrf91_errata_x())?
Is there any recommended way to handle OTP access via tfm_platform_mem_read() on nRF9151 with respect to these errata checks?