diff --git a/cli/main.c b/cli/main.c index 390724ef..ab779e01 100644 --- a/cli/main.c +++ b/cli/main.c @@ -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, diff --git a/inc/switchtec/log.h b/inc/switchtec/log.h index 78a7b600..5f805df9 100644 --- a/inc/switchtec/log.h +++ b/inc/switchtec/log.h @@ -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 diff --git a/inc/switchtec/mrpc.h b/inc/switchtec/mrpc.h index b5b7882a..dfb29a16 100644 --- a/inc/switchtec/mrpc.h +++ b/inc/switchtec/mrpc.h @@ -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 { diff --git a/inc/switchtec/switchtec.h b/inc/switchtec/switchtec.h index a8a11b8f..0022d87d 100644 --- a/inc/switchtec/switchtec.h +++ b/inc/switchtec/switchtec.h @@ -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, diff --git a/lib/switchtec.c b/lib/switchtec.c index 2fd407bf..a4448a86 100644 --- a/lib/switchtec.c +++ b/lib/switchtec.c @@ -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, @@ -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: