Modem trace

Sometimes, not everything goes according to plan, and we need information about what happened.

We already know how to get debugging information from the application, through log output. However, in the case of the nRF9160 SiP, we also want debugging information from the modem core. For this reason, the modem core has the functionality to output a modem trace.

To get a modem trace, there are 3 steps that are needed:

  1. Tell the modem to give us a trace.
  2. Because the modem does not have an interface to send the trace over, we need the application core to forward it to us.
  3. Finally, we need to decode the trace, so that we are able to read it.

Note

Taking a modem trace from the nRF9160 SiP requires no extra hardware, only the software tool described in this exercise.

Telling the modem

The first step is achieved through the AT command AT%XMODEMTRACE. This can be used both to activate and deactivate modem tracing in the modem.

The command has the following set command syntax

AT%XMODEMTRACE=<oper>,<set_id>
  • <oper> – Indicates the operation you want to do. The two most important values here are 0, which deactivates the traces, and 1, which enables them.

<set_id> – Decides which traces the modem will give. This works similar to how you can have different log levels for different libraries in the application. There are 5 different sets to choose from (1 to 5), with the most commonly used one being 2. This is the set that will give us the most information.

Forwarding from the modem

Sending the %XMODEMTRACE AT command only sends the modem traces to the application core. From there we need some way to get the trace out to us, in order for us to be able to read it.

The Modem library provides us with the necessary facilities, through the Modem trace module.

Enabling the Kconfig CONFIG_NRF_MODEM_LIB_TRACE will enable the module, start tracing and forward the modem traces to a default backend that outputs the track on UART1 at a baudrate of 1000000

Enabling this Kconfig will also send the %XMODEMTRACE AT command automatically at startup.

Decoding the trace

Now that the modem is sending traces to the application, and the application is sending the traces out of the SiP, we just need something to receive the traces. For this, any program that can read the data can be used, but we recommend using the Trace Collector V2 preview, which is part of the nRF Connect for Desktop. The trace collector will not only capture a trace and store it on your computer, but it will also let you decode the trace.

Register an account
Already have an account? Log in
(All fields are required unless specified optional)

Forgot your password?
Enter your email address, and we will send a link to reset your password.