nrf5340 net core upgrade

Hi,

I just found that upgrade the net core need to set CONFIG_SERIAL=y and enable the UART in dts file, otherwise, it hangs on the network_core_pcd_cmdset function when upgrading the net core FW,  pcd_fw_copy_status_get() always returns 0.  Is this expected?  if yes, I would like to disable the net core's UART to save the current consumption, any workarounds?

static int network_core_pcd_cmdset(const void *src_addr, size_t len, bool wait)
{
	int err;
	/* Ensure that the network core is turned off */
	nrf_reset_network_force_off(NRF_RESET, true);

	err = pcd_cmd_write(src_addr, len, PCD_NET_CORE_APP_OFFSET);
	if (err != 0) {
		LOG_INF("Error while writing PCD cmd: %d", err);
		return err;
	}

	nrf_reset_network_force_off(NRF_RESET, false);
	LOG_INF("Turned on network core");

	if (!wait) {
		return 0;
	}

	do {
		/* Wait for 1 second to avoid issue where network core
		 * is unable to write to shared RAM.
		 */
		k_busy_wait(1 * USEC_PER_SEC);

		err = pcd_fw_copy_status_get();
	} while (err == PCD_STATUS_COPY);

	if (err == PCD_STATUS_COPY_FAILED) {
		LOG_ERR("Network core update failed");
		return err;
	}

	nrf_reset_network_force_off(NRF_RESET, true);
	LOG_INF("Turned off network core");
	network_core_pcd_tidy();
	return 0;
}

Parents Reply Children
  • Jason said:
    this issue is caused by CONFIG_RESET_ON_FATAL_ERROR=n, and it was fixed after I set it to y in overlay-minimal-size.conf

    Good job tracking this down!

    It is a bit awkward, but think you can add "-Dhci_rpmsg_b0n_CONFIG_RESET_ON_FATAL_ERROR=y" after you include the minimal conf.

    Alternatively, you can point -Dhci_rpmsg_b0n_OVERLAY_CONFIG:STRING to a local copy of your overlay-minimal-size.conf. For this you must use full path, or CMake for a relative path to project dir. See this sample for how to use Cmake to set Kconfig variables.

    However, the issue could be cause by anomaly [161] RESET: Core is not fully reset after Force-OFF.
    This should be handeled by our MDK, but there might be a bug there.
    A possible solution is to add the following to the beginning of SystemInit() in the net core:

    if (((NRF_RESET_NS->RESETREAS & RESET_RESETREAS_SREQ_Msk) || 
    
            (NRF_RESET_NS->RESETREAS & RESET_RESETREAS_LOCKUP_Msk)) &&
    
            !(NRF_RESET_NS->RESETREAS & RESET_RESETREAS_LSREQ_Msk)) 
    
        {
    
            NVIC_SystemReset();
    
        }
    
        
    
        /* Clear LSREQ bit to allow workaround to be applied on subsequent resets */   NRF_RESET_NS->RESETREAS = RESET_RESETREAS_LSREQ_Msk;

    Regards,
    Sigurd Hellesvik

  • Thanks, all of the workaround works. 

    by the way, if CONFIG_RESET_ON_FATAL_ERROR=n, what will happen on the network core when a fatal error occurs, crash, or ...?

  • Jason said:
    by the way, if CONFIG_RESET_ON_FATAL_ERROR=n, what will happen on the network core when a fatal error occurs, crash, or ...?

    The network core will not reset on its own, and must be reset by other means.
    For example, from nRF5340 RESET: "When the application core performs a soft reset, the network core is held in reset, see Network Force-OFF. A soft reset in the network core will only cause the network core to reset."

    Depending a bit on your application, you might want the network core to reset automatically or not, so that would be up to you.

    Regards,
    Sigurd Hellesvik

Related