//write reset info to flash void ICACHE_FLASH_ATTR debug_FlashSvExceptInfo(struct rst_info* pInfo) { debug_FlashBufInit(&FlashDebugBufParam,Flash_DEBUG_INFO_ADDR); uint8 InfoBuf[200]; os_memset(InfoBuf,0,200); uint8* ptmp = InfoBuf; ptmp += os_sprintf(ptmp,"reset reason:%x\n", pInfo->reason); if (pInfo->reason == REASON_WDT_RST || pInfo->reason == REASON_EXCEPTION_RST || pInfo->reason == REASON_SOFT_WDT_RST) { if (pInfo->reason == REASON_EXCEPTION_RST) { ptmp += os_sprintf(ptmp,"Fatal exception (%d):\n", pInfo->exccause); } ptmp+=os_sprintf(ptmp,"debug_version:%d\r\n",FlashDebugBufParam.DebugVersion); ptmp+=os_sprintf(ptmp,"epc1=0x%08x, epc2=0x%08x, epc3=0x%08x, excvaddr=0x%08x, depc=0x%08x\r\n", pInfo->epc1, pInfo->epc2, pInfo->epc3, pInfo->excvaddr, pInfo->depc); } int len = os_strlen(InfoBuf); uint8 pad_len = 0; if(len%4 != 0){ pad_len = 4 - (len%4); os_memcpy(ptmp," ",pad_len); } len += pad_len; ESP_DBG("============\r\nSV DBUG INFO:\r\n%s\r\n==============\r\n",InfoBuf); debug_PrintToFlash(InfoBuf,len,&FlashDebugBufParam,Flash_DEBUG_INFO_ADDR); }
//set debug version void ICACHE_FLASH_ATTR debug_SetDebugVersion(int ver) { if(debug_FlashParamCsumCheck(&FlashDebugBufParam) && debug_FlashAddrCheck(&FlashDebugBufParam)){ //FlashDebugBufParam.DebugVersion = ver; }else{ debug_FlashBufInit(&FlashDebugBufParam,Flash_DEBUG_INFO_ADDR); } FlashDebugBufParam.DebugVersion = ver; //debug_FlashParamSv(); debug_FlashParamSv(&FlashDebugBufParam,Flash_DEBUG_INFO_ADDR); }
void ICACHE_FLASH_ATTR debug_SetDebugVersion(int ver) { if(debug_FlashParamCsumCheck() && debug_FlashAddrCheck()){ //FlashDebugBufParam.DebugVersion = ver; }else{ debug_FlashBufInit(); } FlashDebugBufParam.DebugVersion = ver; debug_FlashParamSv(); }
void ICACHE_FLASH_ATTR debug_PrintToFlash(uint8* data, uint16 len) { if(len%4 != 0){ os_printf("4Bytes ...\r\n"); return; } if(debug_FlashAddrCheck()){ if(FlashDebugBufParam.InPos % 0x1000 ==0) spi_flash_erase_sector(FlashDebugBufParam.InPos / 0x1000); }else{ debug_FlashBufInit(); } if(FlashDebugBufParam.InPos+len < FlashDebugBufParam.StartAddr+FlashDebugBufParam.Size ){ spi_flash_write(FlashDebugBufParam.InPos,(uint32 *)data,len); FlashDebugBufParam.InPos+=len; debug_FlashParamSv(); } }