You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by je...@apache.org on 2021/04/16 11:38:56 UTC

[mynewt-core] branch master updated: hw/ipc_nrf5340: Improve reset behavior

This is an automated email from the ASF dual-hosted git repository.

jerzy pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git


The following commit(s) were added to refs/heads/master by this push:
     new f360702  hw/ipc_nrf5340: Improve reset behavior
f360702 is described below

commit f3607027aefd9a8a34f809f9c4873ce879e01d1f
Author: Jerzy Kasenberg <je...@codecoup.pl>
AuthorDate: Fri Apr 16 11:24:43 2021 +0200

    hw/ipc_nrf5340: Improve reset behavior
    
    Software reset does not clear IPC registers.
    This can result in strange scenarios where
    IPC registers set before software reset are
    used as if some fresh communication happened.
    This will lead to hard fault virtually preventing
    OTA when reset is induced by software instead of
    reset pin.
    
    1. Now code does not handle pending interrupts that are
      visible in INTPEND but they were not enabled hence callback
      is NULL.
    2. During ipc_nrf5340_init() also clear RECEIVE_CNF so no
      spurious event is tried to be handled.
---
 hw/drivers/ipc_nrf5340/src/ipc_nrf5340.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/hw/drivers/ipc_nrf5340/src/ipc_nrf5340.c b/hw/drivers/ipc_nrf5340/src/ipc_nrf5340.c
index 7e13d0e..55e8fc8 100644
--- a/hw/drivers/ipc_nrf5340/src/ipc_nrf5340.c
+++ b/hw/drivers/ipc_nrf5340/src/ipc_nrf5340.c
@@ -129,7 +129,8 @@ ipc_nrf5340_isr(void)
 
     os_trace_isr_enter();
 
-    irq_pend = NRF_IPC->INTPEND;
+    /* Handle only interrupts that were enabled */
+    irq_pend = NRF_IPC->INTPEND & NRF_IPC->INTEN;
 
     for (i = 0; i < IPC_MAX_CHANS; i++) {
         if (irq_pend & (0x1UL << i)) {
@@ -169,8 +170,11 @@ ipc_nrf5340_init(void)
     /* Enable IPC channels */
     for (i = 0; i < IPC_MAX_CHANS; i++) {
         NRF_IPC->SEND_CNF[i] = (0x01UL << i);
+        NRF_IPC->RECEIVE_CNF[i] = 0;
     }
 
+    NRF_IPC->INTENCLR = 0xFFFF;
+    NVIC_ClearPendingIRQ(IPC_IRQn);
     NVIC_SetVector(IPC_IRQn, (uint32_t)ipc_nrf5340_isr);
     NVIC_EnableIRQ(IPC_IRQn);