Skip to content
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

v2.4 YOPAN-165 and YOPAN-168 #16912

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ Kconfig* @tejlmand
/subsys/nrf_profiler/ @pdunaj
/subsys/shell/ @nordic-krch
/subsys/nonsecure/ @SebastianBoe
/subsys/net_core_monitor/ @maje-emb
/modules/ @tejlmand
/modules/tfm/ @SebastianBoe @joerchan
/subsys/zigbee/ @tomchy @sebastiandraus
Expand Down
118 changes: 118 additions & 0 deletions doc/nrf/libraries/others/images/ncm_register.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
115 changes: 115 additions & 0 deletions doc/nrf/libraries/others/network_core_monitor.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
.. _network_core_monitor:

Network core monitor
####################

.. contents::
:local:
:depth: 2

This library monitors the network core status of the nRF5340 processor.

Overview
********

It detects suspensions and resets in the network processor.
When a reset occurs, you can read the cause of the reset.

Implementation
==============

The library uses two general-purpose registers of the IPC peripheral in the application core and writes the state of the network processor to them.

.. figure:: images/ncm_register.svg
:alt: Application of IPC peripheral registers

IPC peripheral registers

The ``GPMEM[0]`` register is divided into two 16-bit parts.

The ``COUNTER`` value is incremented by the network core every :kconfig:option:`CONFIG_NCM_FEEDING_INTERVAL_MSEC`.
If the network core is suspended, the counter value is not updated.

The ``FLAGS`` field has the ``Reset`` flag as the bit 0.

The reset bit is set at the boot of the network core.
It informs the application core that a reset of the network core has occurred.

During the startup of the network core, the reset bit is set and the cause of the reset is written to the IPC register ``GPMEM[1]``.
This value is rewritten from the network core's ``RESET.RESETREAS`` register.
For a detailed description of the bits in this register, see the `RESETREAS`_ section for nRF5340.

The :c:func:`ncm_net_core_event_handler` function may be implemented by your application.
On the application core, the network core monitor checks the values of IPC registers written by the network core every :kconfig:option:`CONFIG_NCM_FEEDING_INTERVAL_MSEC`.
If the network core malfunctions and fails to increment the ``COUNTER`` value, the :c:func:`ncm_net_core_event_handler` function is called on the application core.
This function is also called when the network core is restarted.
The network core monitor provides a ``__weak`` implementation of that function in the :file:`nrf/subsys/net_core_monitor/app_core.c` file.

The following events are supported and also listed in the :file:`nrf/include/net_core_monitor.h` file:

* :c:macro:`NCM_EVT_NET_CORE_RESET`

* Event triggered when a network core reset occurs.
* The ``reset_reas`` variable holds the reason for the reset.
It is rewritten from the ``RESET.RESETREAS`` register.

* :c:macro:`NCM_EVT_NET_CORE_FREEZE`

* Event triggered when the network core is not responding.

Configuration
*************

To enable this library, set the :kconfig:option:`CONFIG_NET_CORE_MONITOR` Kconfig option to ``y`` on both network and application cores.

The :kconfig:option:`CONFIG_NCM_APP_FEEDING_INTERVAL_MSEC` Kconfig option specifies how often the counter is updated by the network core.
The default value is 500 milliseconds.

The :kconfig:option:`CONFIG_NCM_RESET_INIT_PRIORITY` Kconfig option sets priority for the initialization function.
The function reads the cause of the processor reset and passes this information to the application core.
It is executed at the network core boot.

Usage
*****

To enable the Network core monitor library, set the :kconfig:option:`CONFIG_NET_CORE_MONITOR` Kconfig option.

The :c:func:`ncm_net_core_event_handler` function can be used to notify the application about the status of the network core.
To define the user action for the event, you must override the ``__weak`` function definition of :c:func:`ncm_net_core_event_handler`.
Otherwise, the ``__weak``` definition is called and it prints information about the event.

See the following usage example.

.. code-block::

#include "net_core_monitor.h"
...
/* This is the override for the __weak handler. */
void ncm_net_core_event_handler(enum ncm_event_type event, uint32_t reset_reas)
{
switch (event) {
case NCM_EVT_NET_CORE_RESET:
printk("The network core reset.\n");
/* do something */
break;
case NCM_EVT_NET_CORE_FREEZE:
printk("The network core is not responding.\n");
/* do something */
break;
}
}

Dependencies
************

The module uses two general-purpose registers, ``GPMEM[0]`` and ``GPMEM[1]``, of the application core's IPC peripheral.

API documentation
*****************

| Header file: :file:`include/net_core_monitor.h`
| Source files: :file:`subsys/net_core_monitor/`

.. doxygengroup:: net_core_monitor
:project: nrf
:members:
2 changes: 2 additions & 0 deletions doc/nrf/links.txt
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,8 @@
.. _`nRF5340 Audio DK Hardware`: https://infocenter.nordicsemi.com/topic/ug_nrf5340_audio/UG/nrf5340_audio/intro.html
.. _`Requirements for external flash memory DFU`: https://infocenter.nordicsemi.com/topic/ug_nrf5340_audio/UG/nrf5340_audio/hw_external_memory.html

.. _`RESETREAS`: https://infocenter.nordicsemi.com/index.jsp?topic=%2Fps_nrf5340%2Fchapters%2Freset%2Fdoc%2Freset.html&cp=4_0_0_3_9_10_0&anchor=register.RESETREAS

.. _`nRF52840 Product Specification`: https://infocenter.nordicsemi.com/topic/ps_nrf52840/keyfeatures_html5.html
.. _`System OFF mode`: https://infocenter.nordicsemi.com/topic/ps_nrf52840/power.html?cp=5_0_0_4_2_2#unique_220399309
.. _`nRF52840 DK User Guide`: https://infocenter.nordicsemi.com/topic/ug_nrf52840_dk/UG/dk/intro.html
Expand Down
21 changes: 21 additions & 0 deletions include/debug/ppi_trace.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
#ifndef __PPI_TRACE_H
#define __PPI_TRACE_H

#include <stdint.h>

#ifdef __cplusplus
extern "C" {
#endif
Expand Down Expand Up @@ -45,6 +47,25 @@ void *ppi_trace_config(uint32_t pin, uint32_t evt);
*/
void *ppi_trace_pair_config(uint32_t pin, uint32_t start_evt, uint32_t stop_evt);

/** @brief Configure and enable a PPI trace pin for tracing a DPPI channel.
*
* This function allows to trace DPPI triggers without knowing any events being the source of the
* trigger. Configuration of events so that they publish to the given DPPI and enabling the DPPI is
* out of scope of this function and must be done externally.
* This function allows also to trace DPPI channels which are triggered by multiple events or
* the set of events publishing to the DPPI channel changes in run-time.
*
* @note Supported only on platforms equipped with DPPI.
*
* @param pin Pin to use for tracing.
* @param dppi_ch DPPI channel number to be traced on the pin.
*
* @retval 0 The configuration succeeded.
* @retval -ENOMEM The configuration failed, due to lack of necessary resources.
* @retval -ENOTSUP The function is not supported on current hardware platform.
*/
int ppi_trace_dppi_ch_trace(uint32_t pin, uint32_t dppi_ch);

/** @brief Enable PPI trace pin.
*
* @param handle Handle.
Expand Down
53 changes: 53 additions & 0 deletions include/net_core_monitor.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*
* Copyright (c) 2023 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
*/

#ifndef NET_CORE_MONITOR_H_
#define NET_CORE_MONITOR_H_

/**
* @file
* @defgroup net_core_monitor Network Core Monitor API
* @{
* @brief API for the Network Core Monitor.
*/

#ifdef __cplusplus
extern "C" {
#endif

/** @brief Network core monitor event types, used to signal the application. */
enum ncm_event_type {
/** Event triggered when a network core reset occurs.
* The ``reset_reas`` variable holds the reason for the reset.
* It is rewritten from the RESET.RESETREAS register.
*/
NCM_EVT_NET_CORE_RESET,

/** Event triggered when the network core is not responding. */
NCM_EVT_NET_CORE_FREEZE
};

/** @brief Event handler that is called by the Network core monitor library when an event occurs.
*
* @note This function should be defined by the application.
* Otherwise, `__weak` definition will called and it prints information about the event.
*
* @param[out] event Event occurring.
* @param[out] reset_reas Reason for network core reset.
* When the NCM_EVT_NET_CORE_RESET event was triggered the variable is set.
* This value is rewritten from the network core's RESET.RESETREAS register.
*/
extern void ncm_net_core_event_handler(enum ncm_event_type event, uint32_t reset_reas);

#ifdef __cplusplus
}
#endif

/**
* @}
*/

#endif /* NET_CORE_MONITOR_H_ */
Loading
Loading