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

app: Enable modem traces in release builds #444

Merged
merged 2 commits into from
Nov 1, 2024
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
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ jobs:
echo CONFIG_MEMFAULT_NCS_FW_VERSION=\"${{ env.VERSION }}+debug\" >> overlay-memfault-debug.conf
echo CONFIG_MEMFAULT_NCS_FW_TYPE=\"${{ env.MEMFAULT_SW_TYPE }}\" >> overlay-memfault-debug.conf
echo CONFIG_APP_MEMFAULT_UPLOAD_METRICS_ON_CLOUD_READY=y >> overlay-memfault-debug.conf
west build -p -b thingy91x/nrf9151/ns -p --sysbuild -- -DEXTRA_CONF_FILE="overlay-memfault-debug.conf;overlay-modemtrace.conf;overlay-etb.conf"
west build -p -b thingy91x/nrf9151/ns -p --sysbuild -- -DEXTRA_CONF_FILE="overlay-memfault-debug.conf;overlay-modemtrace-to-memfault.conf;overlay-etb.conf"

- name: Rename debug artifacts
if: ${{ inputs.build_debug }}
Expand Down
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,24 @@ west flash --erase
| Solid | Configured | Device has received a LED configuration | NA |
| Blinking rapid | Red | Fatal error, the device will reboot | NA |
| Blinking slow | Red | Irrecoverable Fatal error | NA |

### Modem Traces

Modem traces are enabled by default on the Thingy:91 device. These traces can be output to UART for analysis using the **nRF Connect for Desktop Cellular Monitor** application.

#### Steps to Capture and Dump Modem Traces:

1. **Connect to a Serial Terminal**
- Connect your Thingy:91 device to a serial terminal on **UART 0**. This will allow you to interact with the device's shell commands. You might need to push **Button 1** to wake the UART up.

2. **Set Up Cellular Monitor Application**
- Open the [Cellular Monitor Application](https://docs.nordicsemi.com/bundle/nrf-connect-cellularmonitor/page/index.html).
- Connect the Thingy:91 to the application, select **UART 1** as the trace output, and click **Start Traces** to begin capturing modem activity.

3. **Dump Traces via UART**
- Use the following shell commands in the connected serial terminal to manage and dump the modem traces on **UART 1**:

```shell
modem_trace stop # Stop modem tracing if running
modem_trace size # Check the size of stored traces
modem_trace dump_uart # Dump traces to UART 1 for analysis
15 changes: 15 additions & 0 deletions app/overlay-modemtrace-to-memfault.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#
# Copyright (c) 2024 Nordic Semiconductor
#
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
#

CONFIG_APP_MEMFAULT_INCLUDE_MODEM_TRACES=y

# Disable traces by default, let the Memfault module enable and set the trace the log level.
CONFIG_NRF_MODEM_LIB_TRACE_LEVEL_OFF=y

# Set nRF Cloud CoAP security tag to a dev tag to enable decoded DTLS traces.
# It is required that the nRF Cloud CoAP server certificate has been provisioned to the sec tag.
CONFIG_NRF_CLOUD_COAP_SEC_TAG=2147483667
CONFIG_NRF_CLOUD_COAP_JWT_SEC_TAG=4242
35 changes: 0 additions & 35 deletions app/overlay-modemtrace.conf

This file was deleted.

17 changes: 17 additions & 0 deletions app/prj.conf
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ CONFIG_NRF_MODEM_LIB=y
# AT commands interface
CONFIG_UART_INTERRUPT_DRIVEN=y
CONFIG_SHELL=y
CONFIG_SHELL_WILDCARD=n
CONFIG_SHELL_STACK_SIZE=1560
CONFIG_AT_SHELL=y

Expand Down Expand Up @@ -247,3 +248,19 @@ CONFIG_TASK_WDT_CHANNELS=9

# Device power management
CONFIG_PM_DEVICE=y

# Modem tracing
CONFIG_FCB=y
CONFIG_FLASH_MAP=y
CONFIG_NRF_MODEM_LIB_TRACE=y
CONFIG_NRF_MODEM_LIB_SHELL_TRACE=y
CONFIG_NRF_MODEM_LIB_TRACE_LEVEL_OVERRIDE=y
# Start IP traces after boot with LTE and IP trace level
CONFIG_NRF_MODEM_LIB_TRACE_LEVEL_LTE_AND_IP=y
CONFIG_NRF_MODEM_LIB_TRACE_BACKEND_FLASH=y
CONFIG_NRF_MODEM_TRACE_FLASH_NOSPACE_ERASE_OLDEST=y
CONFIG_NRF_MODEM_LIB_TRACE_STACK_SIZE=1024
# Maximum number of sectors that the trace backend can handle
CONFIG_NRF_MODEM_LIB_TRACE_FLASH_SECTORS=255
# Modem trace flash partition size with 255 sectors of 4KB each
CONFIG_NRF_MODEM_LIB_TRACE_BACKEND_FLASH_PARTITION_SIZE=0xFF000
2 changes: 1 addition & 1 deletion app/sample.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ tests:
- thingy91x/nrf9151/ns
extra_configs:
- CONFIG_MEMFAULT_NCS_PROJECT_KEY="PROJECTKEY"
extra_args: EXTRA_CONF_FILE="overlay-memfault.conf;overlay-modemtrace.conf;overlay-etb.conf"
extra_args: EXTRA_CONF_FILE="overlay-memfault.conf;overlay-modemtrace-to-memfault.conf;overlay-etb.conf"
tags: ci_build
app.build.bootloader_update:
build_only: true
Expand Down
6 changes: 6 additions & 0 deletions app/src/modules/memfault/Kconfig.memfault
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ menuconfig APP_MEMFAULT

if APP_MEMFAULT

config APP_MEMFAULT_INCLUDE_MODEM_TRACES
bool "Modem traces to memfault"
select MEMFAULT_CDR_ENABLE
help
Include modem traces with Memfault coredumps.

config APP_MEMFAULT_THREAD_STACK_SIZE
int "Thread stack size"
default 1536
Expand Down
6 changes: 3 additions & 3 deletions app/src/modules/memfault/memfault.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ static void task_wdt_callback(int channel_id, void *user_data)
SEND_FATAL_ERROR_WATCHDOG_TIMEOUT();
}

#if defined(CONFIG_NRF_MODEM_LIB_TRACE) && defined(CONFIG_NRF_MODEM_LIB_TRACE_BACKEND_FLASH)
#if defined(CONFIG_APP_MEMFAULT_INCLUDE_MODEM_TRACES)

static const char *mimetypes[] = { MEMFAULT_CDR_BINARY };

Expand Down Expand Up @@ -175,7 +175,7 @@ static void on_connected(void)
return;
}

#if defined(CONFIG_NRF_MODEM_LIB_TRACE) && defined(CONFIG_NRF_MODEM_LIB_TRACE_BACKEND_FLASH)
#if defined(CONFIG_APP_MEMFAULT_INCLUDE_MODEM_TRACES)
/* If there was a coredump, also send modem trace */

if (has_coredump) {
Expand All @@ -186,7 +186,7 @@ static void on_connected(void)

memfault_zephyr_port_post_data();

#if defined(CONFIG_NRF_MODEM_LIB_TRACE) && defined(CONFIG_NRF_MODEM_LIB_TRACE_BACKEND_FLASH)
#if defined(CONFIG_APP_MEMFAULT_INCLUDE_MODEM_TRACES)
int err = modem_trace_enable();

if (err) {
Expand Down
2 changes: 2 additions & 0 deletions app/src/modules/network/Kconfig.network
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ config APP_NETWORK_EXEC_TIME_SECONDS_MAX
help
Maximum time allowed for a single execution of the module's thread loop.

config APP_NETWORK_SAMPLE_NETWORK_QUALITY
bool "Sample network quality"

module = APP_NETWORK
module-str = Network
Expand Down
5 changes: 4 additions & 1 deletion app/src/modules/network/network.c
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,10 @@ static void state_sampling_run(void *obj)

if (trigger_type == TRIGGER_DATA_SAMPLE) {
LOG_DBG("Data sample trigger received, getting network quality data");
sample_network_quality();

if (IS_ENABLED(CONFIG_APP_NETWORK_SAMPLE_NETWORK_QUALITY)) {
sample_network_quality();
}
}
}
}
Expand Down
28 changes: 15 additions & 13 deletions scripts/pmr_nrf91.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
| 0x0: mcuboot_secondary (0xd0000 - 832kB) |
| 0xd0000: fmfu_storage (0x400000 - 4096kB) |
| 0x4d0000: settings_storage (0x2000 - 8kB) |
| 0x4d2000: external_flash (0x1b2e000 - 27832kB) |
| 0x4d2000: modem_trace (0xff000 - 1020kB) |
| 0x5d1000: external_flash (0x1a2f000 - 26812kB) |
+------------------------------------------------+

flash_primary (0x100000 - 1024kB):
Expand Down Expand Up @@ -34,15 +35,16 @@
+------------------------------------+

sram_primary (0x40000 - 256kB):
+-------------------------------------------------+
+---0x20000000: mcuboot_sram (0xa000 - 40kB)------+
+---0x20000000: sram_secure (0xa000 - 40kB)-------+
| 0x20000000: tfm_sram (0xa000 - 40kB) |
+---0x2000a000: sram_nonsecure (0x36000 - 216kB)--+
+---0x2000a000: nrf_modem_lib_sram (0x24e8 - 9kB)-+
| 0x2000a000: nrf_modem_lib_ctrl (0x4e8 - 1kB) |
| 0x2000a4e8: nrf_modem_lib_tx (0x1000 - 4kB) |
| 0x2000b4e8: nrf_modem_lib_rx (0x1000 - 4kB) |
+-------------------------------------------------+
| 0x2000c4e8: sram_primary (0x33b18 - 206kB) |
+-------------------------------------------------+
+--------------------------------------------------+
+---0x20000000: mcuboot_sram (0xa000 - 40kB)-------+
+---0x20000000: sram_secure (0xa000 - 40kB)--------+
| 0x20000000: tfm_sram (0xa000 - 40kB) |
+---0x2000a000: sram_nonsecure (0x36000 - 216kB)---+
+---0x2000a000: nrf_modem_lib_sram (0x64e8 - 25kB)-+
| 0x2000a000: nrf_modem_lib_ctrl (0x4e8 - 1kB) |
| 0x2000a4e8: nrf_modem_lib_tx (0x1000 - 4kB) |
| 0x2000b4e8: nrf_modem_lib_rx (0x1000 - 4kB) |
| 0x2000c4e8: nrf_modem_lib_trace (0x4000 - 16kB) |
+--------------------------------------------------+
| 0x200104e8: sram_primary (0x2fb18 - 190kB) |
+--------------------------------------------------+
1 change: 1 addition & 0 deletions tests/module/network/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ target_compile_definitions(app PRIVATE
-DCONFIG_APP_NETWORK_MESSAGE_QUEUE_SIZE=5
-DCONFIG_APP_NETWORK_EXEC_TIME_SECONDS_MAX=1
-DCONFIG_APP_NETWORK_WATCHDOG_TIMEOUT_SECONDS=2
-DCONFIG_APP_NETWORK_SAMPLE_NETWORK_QUALITY
-DCONFIG_NET_MGMT_EVENT
)

Expand Down
Loading