ipq807x: Add support for compressed crashdump collection.

This change will add support for collecting crashdump as
compressed gzip file, if specified through uboot environment
variable 'dump_compressed'

Change-Id: I0c3fb16bc07aaa0103e75a551477fce13f9e26da
Signed-off-by: Pavithra Palanisamy <pavip@codeaurora.org>
This commit is contained in:
Pavithra Palanisamy 2019-06-03 12:47:27 +05:30 committed by Karthick Shanmugham
parent 8b0e6488a2
commit 5e2038bc94
9 changed files with 97 additions and 16 deletions

View file

@ -94,6 +94,7 @@ struct dumpinfo_t{
*/
uint32_t offset; /* offset to be added to start address */
uint32_t dump_level;
uint32_t to_compress; /* non-zero represent for compressed dump*/
};
extern struct dumpinfo_t dumpinfo_n[];
extern int dump_entries_n;

View file

@ -404,7 +404,7 @@ static int dump_wlan_segments(struct dumpinfo_t *dumpinfo, int indx)
static int do_dumpqca_data(unsigned int dump_level)
{
uint32_t memaddr;
uint32_t memaddr, comp_addr = 0x0;
uint32_t remaining;
int indx;
int ebi_indx = 0;
@ -412,8 +412,8 @@ static int do_dumpqca_data(unsigned int dump_level)
char buf = 1;
struct dumpinfo_t *dumpinfo = dumpinfo_n;
int dump_entries = dump_entries_n;
char wlan_segment_name[32];
char *usb_dump = NULL;
char wlan_segment_name[32], runcmd[128], *s;
char *usb_dump = NULL, *compress = NULL;
ulong is_usb_dump = 0;
usb_dump = getenv("dump_to_usb");
@ -507,7 +507,6 @@ static int do_dumpqca_data(unsigned int dump_level)
for (indx = 0; indx < dump_entries; indx++) {
if (dump_level != dumpinfo[indx].dump_level)
continue;
printf("\nProcessing %s:", dumpinfo[indx].name);
if (dumpinfo[indx].is_redirected) {
memaddr = *((uint32_t *)(dumpinfo[indx].start));
@ -525,17 +524,57 @@ static int do_dumpqca_data(unsigned int dump_level)
if (!strncmp(dumpinfo[indx].name, "EBICS", strlen("EBICS")))
{
if (!strncmp(dumpinfo[indx].name,
"EBICS0", strlen("EBICS0")))
dumpinfo[indx].size = gd->ram_size;
compress = getenv("dump_compressed");
if (compress) {
if (!strncmp(dumpinfo[indx].name, "EBICS2", strlen("EBICS2"))) {
memaddr = CONFIG_SYS_SDRAM_BASE + (gd->ram_size / 2);
dumpinfo[indx].size = gd->ram_size / 2;
comp_addr = memaddr;
}
if (!strncmp(dumpinfo[indx].name, "EBICS_S2", strlen("EBICS_S2"))) {
dumpinfo[indx].size = gd->ram_size - (CONFIG_TZ_END_ADDR - CONFIG_SYS_SDRAM_BASE);
comp_addr = memaddr;
}
if (!strncmp(dumpinfo[indx].name, "EBICS1", strlen("EBICS1"))) {
dumpinfo[indx].size = (gd->ram_size / 2)
- (dumpinfo[indx + 1].size + 0x400000);
}
}
else {
if (!strncmp(dumpinfo[indx].name,
"EBICS0", strlen("EBICS0")))
dumpinfo[indx].size = gd->ram_size;
if (!strncmp(dumpinfo[indx].name,
"EBICS_S1", strlen("EBICS_S1")))
dumpinfo[indx].size = gd->ram_size
- dumpinfo[indx - 1].size
- CONFIG_TZ_SIZE;
if (!strncmp(dumpinfo[indx].name,
"EBICS_S1", strlen("EBICS_S1")))
dumpinfo[indx].size = gd->ram_size
- dumpinfo[indx - 1].size
- CONFIG_TZ_SIZE;
}
if (is_usb_dump == 1) {
if (compress && (dumpinfo[indx].to_compress == 1)) {
snprintf(runcmd, sizeof(runcmd), "zip 0x%x 0x%x 0x%x", memaddr, dumpinfo[indx].size, comp_addr);
if (run_command(runcmd, 0) != CMD_RET_SUCCESS)
printf("gzip compression of %s failed\n", dumpinfo[indx].name);
else {
s = getenv("filesize");
dumpinfo[indx].size = (int)simple_strtol(s, NULL, 16); //compressed_file_size
memaddr = comp_addr;
snprintf(dumpinfo[indx].name, sizeof(dumpinfo[indx].name), "%s.gz", dumpinfo[indx].name);
}
}
#ifdef CONFIG_IPQ40XX
if (buf != 1)
#endif
if ((compress && (dumpinfo[indx].to_compress != 1)) ||
(!compress && (dumpinfo[indx].to_compress == 1))) {
continue;
}
printf("\nProcessing %s:\n", dumpinfo[indx].name);
if (is_usb_dump == 1 || compress) {
ret = dump_to_dst (dumpinfo[indx].is_aligned_access, memaddr, dumpinfo[indx].size, dumpinfo[indx].name);
if (ret == CMD_RET_FAILURE) {
goto stop_dump;
@ -552,6 +591,7 @@ static int do_dumpqca_data(unsigned int dump_level)
else {
dumpinfo[indx].size = remaining;
}
ret = dump_to_dst (dumpinfo[indx].is_aligned_access, memaddr, dumpinfo[indx].size, dumpinfo[indx].name);
if (ret == CMD_RET_FAILURE)
goto stop_dump;
@ -564,6 +604,7 @@ static int do_dumpqca_data(unsigned int dump_level)
}
else
{
printf("\nProcessing %s:\n", dumpinfo[indx].name);
if (dumpinfo[indx].dump_level == MINIMAL_DUMP )
memaddr = dump_minimal(dumpinfo, indx);
if (dumpinfo[indx].size && memaddr) {

View file

@ -77,6 +77,9 @@ const add_node_t add_fdt_node[] = {
struct dumpinfo_t dumpinfo_n[] = {
{ "EBICS0.BIN", 0x80000000, 0x10000000, 0 },
{ "EBICS2.BIN", 0xA0000000, 0x10000000, 0, 0, 0, 0, 1 },
{ "EBICS1.BIN", CONFIG_UBOOT_END_ADDR, 0x10000000, 0, 0, 0, 0, 1 },
{ "EBICS0.BIN", 0x80000000, CONFIG_QCA_UBOOT_OFFSET, 0, 0, 0, 0, 1 },
};
int dump_entries_n = ARRAY_SIZE(dumpinfo_n);

View file

@ -75,7 +75,10 @@ struct dumpinfo_t dumpinfo_n[] = {
{ "WLAN_FW.BIN", 0x41400000, 0x000FFF80, 0 },
{ "WLAN_FW_900B.BIN", 0x44000000, 0x00600000, 0 },
{ "EBICS0.BIN", 0x40000000, 0x20000000, 0 },
{ "EBI1CS1.BIN", 0x60000000, 0x20000000, 0 }
{ "EBI1CS1.BIN", 0x60000000, 0x20000000, 0 },
{ "EBICS2.BIN", 0x60000000, 0x20000000, 0, 0, 0, 0, 1 },
{ "EBICS1.BIN", CONFIG_UBOOT_END_ADDR, 0x10000000, 0, 0, 0, 0, 1 },
{ "EBICS0.BIN", 0x40000000, CONFIG_QCA_UBOOT_OFFSET, 0, 0, 0, 0, 1 }
};
int dump_entries_n = ARRAY_SIZE(dumpinfo_n);
@ -105,7 +108,10 @@ struct dumpinfo_t dumpinfo_s[] = {
{ "WLAN_FW.BIN", 0x41400000, 0x000FFF80, 0 },
{ "WLAN_FW_900B.BIN", 0x44000000, 0x00600000, 0 },
{ "EBICS0.BIN", 0x40000000, 0x20000000, 0 },
{ "EBI1CS1.BIN", 0x60000000, 0x20000000, 0 }
{ "EBI1CS1.BIN", 0x60000000, 0x20000000, 0 },
{ "EBICS2.BIN", 0x60000000, 0x20000000, 0, 0, 0, 0, 1 },
{ "EBICS1.BIN", CONFIG_UBOOT_END_ADDR, 0x10000000, 0, 0, 0, 0, 1 },
{ "EBICS0.BIN", 0x40000000, CONFIG_QCA_UBOOT_OFFSET, 0, 0, 0, 0, 1 }
};
int dump_entries_s = ARRAY_SIZE(dumpinfo_s);

View file

@ -109,7 +109,15 @@ struct dumpinfo_t dumpinfo_n[] = {
* | PMIC dump (8k) |
* ------------------------
*/
/* Compressed EBICS dump follows descending order
* to use in-memory compression for which destination
* for compression will be address of EBICS2.BIN
*/
{ "EBICS0.BIN", 0x40000000, 0x10000000, 0 },
{ "EBICS2.BIN", 0x60000000, 0x20000000, 0, 0, 0, 0, 1 },
{ "EBICS1.BIN", CONFIG_UBOOT_END_ADDR, 0x10000000, 0, 0, 0, 0, 1 },
{ "EBICS0.BIN", 0x40000000, CONFIG_QCA_UBOOT_OFFSET, 0, 0, 0, 0, 1 },
{ "CODERAM.BIN", 0x00200000, 0x00028000, 0 },
{ "DATARAM.BIN", 0x00290000, 0x00014000, 0 },
{ "MSGRAM.BIN", 0x00060000, 0x00006000, 1 },
@ -126,6 +134,9 @@ int dump_entries_n = ARRAY_SIZE(dumpinfo_n);
struct dumpinfo_t dumpinfo_s[] = {
{ "EBICS_S0.BIN", 0x40000000, 0xAC00000, 0 },
{ "EBICS_S1.BIN", CONFIG_TZ_END_ADDR, 0x10000000, 0 },
{ "EBICS_S2.BIN", CONFIG_TZ_END_ADDR, 0x10000000, 0, 0, 0, 0, 1 },
{ "EBICS_S1.BIN", CONFIG_UBOOT_END_ADDR, 0x200000, 0, 0, 0, 0, 1 },
{ "EBICS_S0.BIN", 0x40000000, CONFIG_QCA_UBOOT_OFFSET, 0, 0, 0, 0, 1 },
{ "DATARAM.BIN", 0x00290000, 0x00014000, 0 },
{ "MSGRAM.BIN", 0x00060000, 0x00006000, 1 },
{ "IMEM.BIN", 0x08600000, 0x00001000, 0 },

View file

@ -84,6 +84,9 @@
#define CONFIG_TZ_END_ADDR 0x88000000
#define CONFIG_SYS_SDRAM_END (CONFIG_SYS_SDRAM_BASE + gd->ram_size)
#define CONFIG_QCA_UBOOT_OFFSET 0x7000000
#define CONFIG_UBOOT_END_ADDR 0x87400000
#define CONFIG_IPQ40XX_ENV
#define CONFIG_ENV_IS_IN_NAND

View file

@ -143,6 +143,9 @@
#define QCA_BOOT_PARAMS_ADDR (QCA_KERNEL_START_ADDR + 0x100)
#define CONFIG_QCA_SMEM_BASE CONFIG_SYS_SDRAM_BASE + 0x1000000
#define CONFIG_QCA_UBOOT_OFFSET 0x1D00000
#define CONFIG_UBOOT_END_ADDR 0x42100000
#define CONFIG_OF_COMBINE 1
#define CONFIG_CMD_BOOTZ

View file

@ -103,6 +103,8 @@
#define CONFIG_OF_COMBINE 1
#define CONFIG_QCA_UBOOT_OFFSET 0xA600000
#define CONFIG_UBOOT_END_ADDR 0x4AA00000
#define CONFIG_QCA_SMEM_BASE 0x4AB00000
#define CONFIG_IPQ_FDT_HIGH 0x4A400000

View file

@ -585,6 +585,7 @@ int ZEXPORT deflate (strm, flush)
{
int old_flush; /* value of flush param for previous deflate call */
deflate_state *s;
int hdr = 0;
if (strm == Z_NULL || strm->state == Z_NULL ||
flush > Z_BLOCK || flush < 0) {
@ -603,6 +604,7 @@ int ZEXPORT deflate (strm, flush)
/* Write the header */
if (s->status == INIT_STATE) {
hdr = 1;
#ifdef GZIP
if (s->wrap == 2) {
strm->adler = crc32(0L, Z_NULL, 0);
@ -782,7 +784,7 @@ int ZEXPORT deflate (strm, flush)
#endif
/* Flush as much pending output as possible */
if (s->pending != 0) {
if ((s->pending != 0) && (hdr != 1)) {
flush_pending(strm);
if (strm->avail_out == 0) {
/* Since avail_out is 0, deflate will be called again with
@ -819,6 +821,15 @@ int ZEXPORT deflate (strm, flush)
(s->strategy == Z_RLE ? deflate_rle(s, flush) :
(*(configuration_table[s->level].func))(s, flush));
/*****Flush header now to dst, which is src pointer after src data are read in previous step*****/
if ((s->pending != 0) && (hdr == 1)) {
flush_pending(strm);
if (strm->avail_out == 0) {
s->last_flush = -1;
return Z_OK;
}
}
if (bstate == finish_started || bstate == finish_done) {
s->status = FINISH_STATE;
}