From 623a60fb2abc61c107678a92f13e94bd74a545b8 Mon Sep 17 00:00:00 2001 From: Ajay Kishore Date: Wed, 28 Sep 2016 18:04:10 +0530 Subject: [PATCH] ipq806x : Enable crashdump support Change-Id: I0d0d45ad3f35f6d7e49ec96c9b29b6a9dcdc919e Signed-off-by: Ajay Kishore --- board/qca/common/cmd_bootqca.c | 118 ++++++++++++++++++++------------- board/qca/ipq806x/ipq806x.c | 40 +++++++++++ include/configs/ipq806x.h | 61 +++++++++++++++++ 3 files changed, 173 insertions(+), 46 deletions(-) diff --git a/board/qca/common/cmd_bootqca.c b/board/qca/common/cmd_bootqca.c index 379ae97cef..ec68aed75d 100644 --- a/board/qca/common/cmd_bootqca.c +++ b/board/qca/common/cmd_bootqca.c @@ -97,6 +97,17 @@ static int do_dumpqca_data(cmd_tbl_t *cmdtp, int flag, int argc, printf("\nProcessing %s:", dumpinfo[indx].name); memaddr = dumpinfo[indx].start; + if (dumpinfo[indx].is_aligned_access) { + snprintf(runcmd, sizeof(runcmd), "cp.l 0x%x 0x%x 0x%x", + memaddr, IPQ_TEMP_DUMP_ADDR, + dumpinfo[indx].size); + + if (run_command(runcmd, 0) != CMD_RET_SUCCESS) + return CMD_RET_FAILURE; + + memaddr = IPQ_TEMP_DUMP_ADDR; + } + snprintf(runcmd, sizeof(runcmd), "tftpput 0x%x 0x%x %s/%s", memaddr, dumpinfo[indx].size, dumpdir, dumpinfo[indx].name); @@ -243,11 +254,35 @@ int config_select(unsigned int addr, char *rcmd, int rcmd_size) return -1; } -static int do_boot_signedimg(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[]) +void dump_func() { #ifdef CONFIG_QCA_APPSBL_DLOAD uint64_t etime; +#endif + etime = get_timer_masked() + (10 * CONFIG_SYS_HZ); + printf("\nCrashdump magic found." + "\nHit any key within 10s to stop dump activity..."); + while (!tstc()) { /* while no incoming data */ + if (get_timer_masked() >= etime) { + if (do_dumpipq_data() == CMD_RET_FAILURE) + return CMD_RET_FAILURE; + break; + } + } + /* reset the system, some images might not be loaded + * when crashmagic is found + */ + run_command("reset", 0); + return; +} + + +static int do_boot_signedimg(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[]) +{ +#ifdef CONFIG_QCA_APPSBL_DLOAD volatile u32 val; + unsigned long * dmagic1 = (unsigned long *) 0x2A03F000; + unsigned long * dmagic2 = (unsigned long *) 0x2A03F004; #endif char runcmd[256]; int ret; @@ -264,30 +299,24 @@ static int do_boot_signedimg(cmd_tbl_t *cmdtp, int flag, int argc, char *const a #ifdef CONFIG_QCA_APPSBL_DLOAD ret = qca_scm_call(SCM_SVC_BOOT, SCM_SVC_RD, (void *)&val, sizeof(val)); - /* check if we are in download mode */ - if (val == DLOAD_MAGIC_COOKIE) { - /* clear the magic and run the dump command */ - val = 0x0; - ret = qca_scm_call(SCM_SVC_BOOT, SCM_SVC_WR, (void *)&val, sizeof(val)); - if (ret) - printf ("Error in reseting the Magic cookie\n"); - - etime = get_timer_masked() + (10 * CONFIG_SYS_HZ); - - printf("\nCrashdump magic found." - "\nHit any key within 10s to stop dump activity..."); - while (!tstc()) { /* while no incoming data */ - if (get_timer_masked() >= etime) { - if (do_dumpipq_data() == CMD_RET_FAILURE) - return CMD_RET_FAILURE; - break; - } + if (ret) { + if (*dmagic1 == 0xE47B337D && *dmagic2 == 0x0501CAB0) { + /* clear the magic and run the dump command */ + *dmagic1 = 0; + *dmagic2 = 0; + dump_func(); + } + } + else { + /* check if we are in download mode */ + if (val == DLOAD_MAGIC_COOKIE) { + /* clear the magic and run the dump command */ + val = 0x0; + ret = qca_scm_call(SCM_SVC_BOOT, SCM_SVC_WR, (void *)&val, sizeof(val)); + if (ret) + printf ("Error in reseting the Magic cookie\n"); + dump_func(); } - - /* reset the system, some images might not be loaded - * when crashmagic is found - */ - run_command("reset", 0); } #endif if ((ret = set_fs_bootargs(&ipq_fs_on_nand))) @@ -435,8 +464,9 @@ static int do_boot_signedimg(cmd_tbl_t *cmdtp, int flag, int argc, char *const a static int do_boot_unsignedimg(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[]) { #ifdef CONFIG_QCA_APPSBL_DLOAD - uint64_t etime; volatile u32 val; + unsigned long * dmagic1 = (unsigned long *) 0x2A03F000; + unsigned long * dmagic2 = (unsigned long *) 0x2A03F004; #endif int ret; char runcmd[256]; @@ -450,30 +480,26 @@ static int do_boot_unsignedimg(cmd_tbl_t *cmdtp, int flag, int argc, char *const debug = 1; #ifdef CONFIG_QCA_APPSBL_DLOAD ret = qca_scm_call(SCM_SVC_BOOT, SCM_SVC_RD, (void *)&val, sizeof(val)); - /* check if we are in download mode */ - if (val == DLOAD_MAGIC_COOKIE) { + if (ret) { + if (*dmagic1 == 0xE47B337D && *dmagic2 == 0x0501CAB0) { /* clear the magic and run the dump command */ - val = 0x0; - ret = qca_scm_call(SCM_SVC_BOOT, SCM_SVC_WR, (void *)&val, sizeof(val)); - if (ret) - printf ("Error in reseting the Magic cookie\n"); - - etime = get_timer_masked() + (10 * CONFIG_SYS_HZ); - - printf("\nCrashdump magic found." - "\nHit any key within 10s to stop dump activity..."); - while (!tstc()) { /* while no incoming data */ - if (get_timer_masked() >= etime) { - if (do_dumpipq_data() == CMD_RET_FAILURE) - return CMD_RET_FAILURE; - break; - } + *dmagic1 = 0; + *dmagic2 = 0; + dump_func(); } - /* reset the system, some images might not be loaded - * when crashmagic is found - */ - run_command("reset", 0); } + else { + /* check if we are in download mode */ + if (val == DLOAD_MAGIC_COOKIE) { + /* clear the magic and run the dump command */ + val = 0x0; + ret = qca_scm_call(SCM_SVC_BOOT, SCM_SVC_WR, (void *)&val, sizeof(val)); + if (ret) + printf ("Error in reseting the Magic cookie\n"); + dump_func(); + } + } + #endif if ((ret = set_fs_bootargs(&ipq_fs_on_nand))) diff --git a/board/qca/ipq806x/ipq806x.c b/board/qca/ipq806x/ipq806x.c index 813c1141bb..2e197a959d 100644 --- a/board/qca/ipq806x/ipq806x.c +++ b/board/qca/ipq806x/ipq806x.c @@ -35,6 +35,46 @@ const char *rsvd_node = "/reserved-memory"; const char *del_node[] = {NULL}; const add_node_t add_node[] = {}; +struct dumpinfo_t dumpinfo[] = { + /* Note1: when aligned access is set, the contents + * are copied to a temporary location and so + * the size of region should not exceed the size + * of region pointed by IPQ_TEMP_DUMP_ADDR + * + * Note2: IPQ_NSSTCM_DUMP_ADDR should be the + * first entry */ + { "NSSTCM.BIN", IPQ_NSSTCM_DUMP_ADDR, 0x20000, 0 }, + { "IMEM_A.BIN", 0x2a000000, 0x0003f000, 0 }, + { "IMEM_C.BIN", 0x2a03f000, 0x00001000, 0 }, + { "IMEM_D.BIN", 0x2A040000, 0x00020000, 0 }, + { "CODERAM.BIN", 0x00020000, 0x00028000, 0 }, + { "SPS_RAM.BIN", 0x12000000, 0x0002C000, 0 }, + { "RPM_MSG.BIN", 0x00108000, 0x00005fff, 1 }, + { "SPS_BUFF.BIN", 0x12040000, 0x00004000, 0 }, + { "SPS_PIPE.BIN", 0x12800000, 0x00008000, 0 }, + { "LPASS.BIN", 0x28400000, 0x00020000, 0 }, + { "RPM_WDT.BIN", 0x0006206C, 0x00000004, 0 }, + { "CPU0_WDT.BIN", 0x0208A044, 0x00000004, 0 }, + { "CPU1_WDT.BIN", 0x0209A044, 0x00000004, 0 }, + { "CPU0_REG.BIN", 0x39013ea8, 0x000000AC, 0 }, + { "CPU1_REG.BIN", 0x39013f54, 0x000000AC, 0 }, + { "WLAN_FW.BIN", 0x41400000, 0x000FFF80, 0 }, + { "WLAN_FW_900B.BIN", 0x44000000, 0x00600000, 0 }, + { "EBICS0.BIN", 0x40000000, 0x20000000, 0 }, + { "EBI1CS1.BIN", 0x60000000, 0x20000000, 0 } +}; +int dump_entries = ARRAY_SIZE(dumpinfo); + +void enable_caches(void) +{ + icache_enable(); +} + +void disable_caches(void) +{ + icache_disable(); +} + unsigned long timer_read_counter(void) { return 0; diff --git a/include/configs/ipq806x.h b/include/configs/ipq806x.h index 97c83c5e39..34d5d8948b 100644 --- a/include/configs/ipq806x.h +++ b/include/configs/ipq806x.h @@ -156,11 +156,72 @@ #define CONFIG_SYS_MMC_ENV_DEV 0 #endif +<<<<<<< HEAD #define QCA_ROOT_FS_PART_NAME "rootfs" +======= +/* + * CRASH DUMP ENABLE + */ + +#define CONFIG_QCA_APPSBL_DLOAD 1 +#ifdef CONFIG_QCA_APPSBL_DLOAD +#define CONFIG_CMD_TFTPPUT +/* We will be uploading very big files */ +#undef CONFIG_NET_RETRY_COUNT +#define CONFIG_NET_RETRY_COUNT 500 +#endif +>>>>>>> 26ff960... ipq806x : Enable crashdump support #ifndef __ASSEMBLY__ #include +<<<<<<< HEAD +======= +/* + * XXX XXX Please do not instantiate this structure. XXX XXX + * This is just a convenience to avoid + * - adding #defines for every new reservation + * - updating the multiple associated defines like smem base, + * kernel start etc... + * - re-calculation of the defines if the order changes or + * some reservations are deleted + * For new reservations just adding a member to the structure should + * suffice. + * Ensure that the size of this structure matches with the definition + * of the following IPQ806x compile time definitions + * PHYS_OFFSET (linux-sources/arch/arm/mach-msm/Kconfig) + * zreladdr (linux-sources/arch/arm/mach-msm/Makefile.boot) + * CONFIG_SYS_INIT_SP_ADDR defined above should point to the bottom. + * MSM_SHARED_RAM_PHYS (linux-sources/arch/arm/mach-msm/board-ipq806x.c) + * + */ + +#if !defined(DO_DEPS_ONLY) || defined(DO_SOC_DEPS_ONLY) +typedef struct { + uint8_t nss[16 * 1024 * 1024]; + uint8_t smem[2 * 1024 * 1024]; +#ifdef CONFIG_IPQ_APPSBL_DLOAD + uint8_t uboot[1 * 1024 * 1024]; + uint8_t nsstcmdump[128 * 1024]; + uint8_t sbl3[384 * 1024]; + uint8_t plcfwdump[512*1024]; + uint8_t wlanfwdump[(1 * 1024 * 1024) - GENERATED_GBL_DATA_SIZE]; + uint8_t init_stack[GENERATED_GBL_DATA_SIZE]; +#endif +} __attribute__ ((__packed__)) ipq_mem_reserve_t; + +/* Convenience macros for the above convenience structure :-) */ +#define IPQ_MEM_RESERVE_SIZE(x) sizeof(((ipq_mem_reserve_t *)0)->x) +#define IPQ_MEM_RESERVE_BASE(x) \ + (CONFIG_SYS_SDRAM_BASE + \ + ((uint32_t)&(((ipq_mem_reserve_t *)0)->x))) +#endif + +#define IPQ_NSSTCM_DUMP_ADDR (IPQ_MEM_RESERVE_BASE(nsstcmdump)) +#define IPQ_TEMP_DUMP_ADDR (IPQ_MEM_RESERVE_BASE(nsstcmdump)) + +#define CONFIG_QCA_SMEM_BASE CONFIG_SYS_SDRAM_BASE + 0x1000000 +>>>>>>> 26ff960... ipq806x : Enable crashdump support #endif /* __ASSEMBLY__ */ #ifndef CONFIG_FIT