Skip to content
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 cli/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1000,6 +1000,7 @@ static int log_dump(int argc, char **argv)
const struct argconfig_choice types[] = {
{"RAM", SWITCHTEC_LOG_RAM, "dump the app log from RAM"},
{"FLASH", SWITCHTEC_LOG_FLASH, "dump the app log from flash"},
{"FTDC", SWITCHTEC_LOG_FTDC, "dump the FTDC firmware log"},
{"MEMLOG", SWITCHTEC_LOG_MEMLOG,
"dump the Memlog info from flash in the last fatal error handling dump"},
{"REGS", SWITCHTEC_LOG_REGS,
Expand Down
10 changes: 10 additions & 0 deletions inc/switchtec/log.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,14 @@ struct log_b_retr_result {
uint8_t data[MRPC_MAX_DATA_LEN - sizeof(struct log_b_retr_hdr)];
};

struct log_ftdc_retr {
uint8_t sub_cmd_id;
uint8_t reserved;
uint16_t req_seq;
};

struct log_ftdc_retr_result {
uint8_t data[MRPC_MAX_DATA_LEN];
};

#endif
3 changes: 2 additions & 1 deletion inc/switchtec/mrpc.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,9 @@ enum mrpc_cmd {
MRPC_SN_VER_GET_GEN5 = 0x119,
MRPC_DBG_UNLOCK_GEN5 = 0x11A,
MRPC_BOOTUP_RESUME_GEN5 = 0x11B,
MRPC_FTDC_LOG_DUMP = 0x147,

MRPC_MAX_ID = 0x11C,
MRPC_MAX_ID = 0x148,
};

enum mrpc_bg_status {
Expand Down
1 change: 1 addition & 0 deletions inc/switchtec/switchtec.h
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ enum switchtec_bw_type {
enum switchtec_log_type {
SWITCHTEC_LOG_RAM,
SWITCHTEC_LOG_FLASH,
SWITCHTEC_LOG_FTDC,
SWITCHTEC_LOG_MEMLOG,
SWITCHTEC_LOG_REGS,
SWITCHTEC_LOG_SYS_STACK,
Expand Down
36 changes: 36 additions & 0 deletions lib/switchtec.c
Original file line number Diff line number Diff line change
Expand Up @@ -1421,6 +1421,40 @@ static int log_c_to_file(struct switchtec_dev *dev, int sub_cmd_id, int fd)
return 0;
}

static int log_d_to_file(struct switchtec_dev *dev, int sub_cmd_id, int fd)
{
int ret;
int read = 0;

struct log_ftdc_retr_result res;
struct log_ftdc_retr cmd = {
.sub_cmd_id = sub_cmd_id,
.reserved = 0,
.req_seq = 0,
};
uint32_t length = sizeof(res.data);

cmd.req_seq = 0;
res.data[1] = 0;

while ( !(res.data[1]) ) {
ret = switchtec_cmd(dev, MRPC_FTDC_LOG_DUMP, &cmd, sizeof(cmd),
&res, sizeof(res));
if (ret)
return -1;

ret = write(fd, res.data, (res.data[0]+1)*4);
if (ret < 0)
return ret;

read += length;
cmd.req_seq++;

}

return 0;
}

static int log_ram_flash_to_file(struct switchtec_dev *dev,
int gen5_cmd, int gen4_cmd, int gen4_cmd_lgcy,
int fd, FILE *log_def_file,
Expand Down Expand Up @@ -1479,6 +1513,8 @@ int switchtec_log_to_file(struct switchtec_dev *dev,
MRPC_FWLOGRD_FLASH_WITH_FLAG,
MRPC_FWLOGRD_FLASH,
fd, log_def_file, info);
case SWITCHTEC_LOG_FTDC:
return log_d_to_file(dev, MRPC_FWLOGRD_RAM, fd);
case SWITCHTEC_LOG_MEMLOG:
return log_b_to_file(dev, MRPC_FWLOGRD_MEMLOG, fd);
case SWITCHTEC_LOG_REGS:
Expand Down