This chapter provides some tips for debugging the sleep process. It covers the following topics:
? Shared memory log � smem_log is a very important tool for analyzing DEM and Sleep issues. It is written by both apps and modem systems and saved in shared memory region.
? Other logs � Other useful logs for debugging sleep issues include mao_trace, tramp_gpio, and tramp_log, etc.
? IRAM debugging � Since SDRAM needs to be put in Self-Refresh mode, the final stage of sleep process is executed in IRAM. We provide some tips on how to set breakpoints or adding log messages inside IRAM for debugging any issues inside IRAM.
? NV item � A couple of NV items related to power consumption
Shared memory log
The shared memory (SMEM) logging system provides a lightweight facility for logging events in the multiprocessor environment. It logs mainly sleep, DEM, and RPC events. This section discusses the implementation of smem log in AMSS, how to collect/read smem log, and some advise on inserting additional smem logs in software.
SMEM log in AMSS
Data structures
The smem log feature is guarded by the following compiler switch.
#define FEATURE_SMEM_LOG
There are three types of shared memory log areas.
/** Identifies the log areas available */
typedef enum {
/** Identifies the first log entry available. */
SMEM_LOG_AREA_FIRST,
/** The circular multiprocessor logging area is used by ONCRPC
and SMD. */
SMEM_LOG_AREA_CIRCULAR_MPROC = SMEM_LOG_AREA_FIRST,
/** The static logging area is used by initialization code. */
SMEM_LOG_AREA_STATIC,
/** The circular power logging area is used by power optimization. */
SMEM_LOG_AREA_CIRCULAR_POWER,
/** Identifies the number of log entries available. */
SMEM_LOG_AREA_COUNT
} smem_log_area;
The circular log contains ONCRPC, SMD, DEM, and sleep logs. The static log is used by
initialization code. The circular power log contains sleep and clock regime logs.
Each shared memory log event consists of timestamp, an event ID, and three 32-bit data values.
An extended smem log entry contains two log events, i.e., six data values.
/** The structure of a single log entry in shared memory. */
typedef struct {
/**
* The log entry identifier, consisting of the processor id,
* continuation number, subsystem id, and event id.
*
* - Bits 31-30 are processor ID: 10 => apps, 00 => modem, 01 =>
* qdsp6
* - Bits 29-28 are continuation number
* - Bits 27-16 are subsystem id (event base); see
* SMEM_LOG_*_EVENT_BASE
* - Bits 15-0 are event id
*
* Bit 28 is set for log entries are a continuation of the previous
* log entry, allowing more data to be written in a single
* transaction. In the current implementation, bit 29 is reserved.
*
* The subsystem id and event id uniquely identify a log entry type,
* and dictate the identity of their arguments.
*/
uint32 identifier;
/**
* The log entry timestamp, from the 32 kHz timetick.
*/
uint32 timetick;
/** The first word of data provided by the user. */
uint32 data1;
/** The second word of data provided by the user. */
uint32 data2;
/** The third word of data provided by the user. */
uint32 data3;
} smem_log_struct_type;
The smem logs are stored in the following table.
/* Static and runtime configuration for SMEM log areas */
typedef struct {
/* Static configuration: Is this log static or circular? */
enum {
SMEM_LOG_TYPE_STATIC,
SMEM_LOG_TYPE_CIRCULAR
} smem_log_type;
/* Static configuration: Is this log area to be readable from
* software?
*/
enum {
SMEM_LOG_WRITEONLY,
SMEM_LOG_READWRITE
} smem_log_readable;
/* Static configuration: The number of entries in this. Defaults to
* SMEM_LOG_NUM_ENTRIES. */
uint32 smem_num_entries;
/* Static configuration: The smem entry that contains the event
* table */
smem_mem_type smem_entry_events;
/* Static configuration: The smem entry that contains the index
* of the next log entry */
smem_mem_type smem_entry_idx;
/* Static configuration: The smem entry that contains the number
* of times the log has wrapped, or SMEM_INVALID if this is the
* existing shared memory log and this information is not
* available. */
smem_mem_type smem_entry_wrap;
/* Static configuration: The spinlock to acquire while updating
* this log area. */
uint32 smem_log_spinlock;
/* Runtime state: Pointer to the shared memory location for the
* event table. */
volatile smem_log_struct_type *smem_log_events;
/* Runtime state: Pointer to the shared memory location for the
* index of the next log entry. */
volatile uint32 *smem_log_write_idx;
/* Runtime state: Pointer to the shared memory location for the
* number of times the log has wrapped, or NULL if the
* information is not available. */
volatile uint32 *smem_log_write_wrap;
/* Runtime state: The index of the next log entry to read. Local
* to each processor. */
uint32 smem_log_read_idx;
/* Runtime state: The number of times the read index has wrapped
* past the end of the buffer. */
uint32 smem_log_read_wrap;
} smem_log_table_type;
static smem_log_table_type smem_log_table[SMEM_LOG_AREA_COUNT] = {
/* SMEM_LOG_AREA_CIRCULAR_MPROC */
{
/* This log must be circular or the static log rollover in
* smem_log_event and smem_log_event6 will recurse infinitely. */
SMEM_LOG_TYPE_CIRCULAR, /* smem_log_type */
SMEM_LOG_READWRITE, /* smem_log_readable */
SMEM_LOG_NUM_ENTRIES, /* smem_num_entries */
SMEM_SMEM_LOG_EVENTS, /* smem_entry_events */
SMEM_SMEM_LOG_IDX, /* smem_entry_idx */
SMEM_SMEM_LOG_MPROC_WRAP, /* smem_entry_wrap */
SMEM_SPINLOCK_SMEM_LOG, /* smem_log_spinlock */
},
/* SMEM_LOG_AREA_STATIC */
{
SMEM_LOG_TYPE_STATIC, /* smem_log_type */
SMEM_LOG_READWRITE, /* smem_log_readable */
SMEM_STATIC_LOG_NUM_ENTRIES, /* smem_num_entries */
SMEM_SMEM_STATIC_LOG_EVENTS, /* smem_entry_events */
SMEM_SMEM_STATIC_LOG_IDX, /* smem_entry_idx */
SMEM_INVALID, /* smem_entry_wrap */
SMEM_SPINLOCK_STATIC_LOG, /* smem_log_spinlock */
};
},
/* SMEM_LOG_AREA_CIRCULAR_POWER */
/* smem_log_rea{ dable */ SMEM_LOG_NUM_ENTRIES, /* smem_num_entries */ SMEM_SMEM_LOG_POWER_EVENTS, /* smem_entry_events */ SMEM_SMEM_LOG_POWER_IDX, /* smem_entry_idx */ SMEM_SMEM_LOG_POWER_WRAP, /* smem_entry_wrap */ SMEM_SPINLOCK_SMEM_LOG, /* smem_log_spinlock */
SMEM_LOG_TYPE_CIRCULAR, /* smem_log_type */ SMEM_LOG_READWRITE,
},
No comments:
Post a Comment