//not used void ICACHE_FLASH_ATTR debug_FlashUpdateExpetInfo(uint16 len) { if(debug_FlashAddrCheck() && (FlashDebugBufParam.OutPos+len <= FlashDebugBufParam.InPos)){ FlashDebugBufParam.InPos-=len; debug_FlashParamSv(); }else{ //return false; } }
void ICACHE_FLASH_ATTR debug_FlashBufInit() { spi_flash_read(Flash_DEBUG_INFO_ADDR*0x1000,(uint32*)&FlashDebugBufParam,sizeof(FlashDebugBufParam)); if(debug_FlashParamCsumCheck() && debug_FlashAddrCheck()){ }else{ debug_FlashBufReset(); } }
//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(); }
//FLASH buf init void ICACHE_FLASH_ATTR debug_FlashBufInit(flashDebugBuf* flashDbgBuf,uint32 idx_sec) { //spi_flash_read(idx_sec*0x1000,(uint32*)flashDbgBuf,sizeof(flashDebugBuf)); config_ParamLoadWithProtect(idx_sec,0,(uint8*)flashDbgBuf,sizeof(flashDebugBuf)); if(debug_FlashParamCsumCheck(flashDbgBuf) && debug_FlashAddrCheck(flashDbgBuf)){ ESP_DBG("flash debug check sum ok..\r\n"); }else{ ESP_DBG("flash debug info reset...\r\n"); debug_FlashBufReset(flashDbgBuf,idx_sec); } }
void ICACHE_FLASH_ATTR debug_FlashPrintParamInit() { //debug_FlashBufInit(&FlashPrintBufParam,FLASH_PRINT_INDEX_ADDR); //spi_flash_read(idx_sec*0x1000,(uint32*)flashDbgBuf,sizeof(flashDebugBuf)); config_ParamLoadWithProtect(FLASH_PRINT_INDEX_ADDR,0,(uint8*)&FlashPrintBufParam,sizeof(flashDebugBuf)); if(debug_FlashParamCsumCheck(&FlashPrintBufParam) && debug_FlashAddrCheck(&FlashPrintBufParam)){ ESP_DBG("flash debug check sum ok..\r\n"); }else{ ESP_DBG("flash debug info reset...\r\n"); //debug_FlashBufReset(&FlashPrintBufParam,FLASH_PRINT_INDEX_ADDR); debug_FlashPrintParamReset(); } }
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(); } }
//write debug info to flash void ICACHE_FLASH_ATTR debug_PrintToFlash(uint8* data, uint16 len,flashDebugBuf* flashDbgBuf,uint32 idx_sector) { ESP_DBG("debug_PrintToFlash\r\n"); if(len%4 != 0){ ESP_DBG("4Bytes ...\r\n"); return; } if(debug_FlashAddrCheck(flashDbgBuf)){ //if( (flashDbgBuf->InPos == flashDbgBuf->StartAddr &&flashDbgBuf->InPos == flashDbgBuf->OutPos) || if((flashDbgBuf->InPos+len)/0x1000 == flashDbgBuf->CurrentSec+1){ #if 1 flashDbgBuf->CurrentSec = (flashDbgBuf->InPos+len>=flashDbgBuf->StartAddr+flashDbgBuf->Size)? flashDbgBuf->StartAddr/0x1000:(flashDbgBuf->InPos+len)/0x1000 ; //ESP_DBG("out: %08x; flashDbgBuf->CurrentSec*0x1000: %08x \r\n",flashDbgBuf->OutPos,flashDbgBuf->CurrentSec*0x1000); if((flashDbgBuf->OutPos<flashDbgBuf->CurrentSec*0x1000+0x1000) && (flashDbgBuf->OutPos>=flashDbgBuf->CurrentSec*0x1000)){ flashDbgBuf->OutPos = flashDbgBuf->CurrentSec*0x1000 + 0x1000; if(flashDbgBuf->OutPos>=flashDbgBuf->StartAddr+flashDbgBuf->Size) flashDbgBuf->OutPos-=flashDbgBuf->Size; } //ESP_DBG("after set: out: %08x \r\n",flashDbgBuf->OutPos); #else if(flashDbgBuf->InPos+len>flashDbgBuf->StartAddr+flashDbgBuf->Size){ flashDbgBuf->CurrentSec = flashDbgBuf->StartAddr/0x1000; ESP_DBG("overflow,loop back\r\n"); if(flashDbgBuf->OutPos<flashDbgBuf->CurrentSec*0x1000+0x1000){ flashDbgBuf->OutPos = flashDbgBuf->CurrentSec*0x1000 + 0x1000; } }else{ flashDbgBuf->CurrentSec = (flashDbgBuf->InPos+len)/0x1000; } #endif spi_flash_erase_sector(flashDbgBuf->CurrentSec); } }else{ //debug_FlashBufInit(flashDbgBuf,idx_sector); ESP_DBG("error1\r\n"); } #if 0 ESP_DBG("================================\r\n"); ESP_DBG("test data: LEN: %d\r\n",len); ESP_DBG("%s \r\n",data); ESP_DBG("================================\r\n"); #endif if(flashDbgBuf->InPos+len < flashDbgBuf->StartAddr+flashDbgBuf->Size ){ ESP_DBG("in: %08x ,len: %d \r\n",flashDbgBuf->InPos,len); spi_flash_write(flashDbgBuf->InPos,(uint32 *)data,len); flashDbgBuf->InPos+=len; //debug_FlashParamSv(); //debug_FlashParamSv(flashDbgBuf,Flash_DEBUG_INFO_ADDR); debug_FlashParamSv(flashDbgBuf,idx_sector); ESP_DBG("1\r\n"); }else{ ESP_DBG("in: %08x ,len: %d \r\n",flashDbgBuf->InPos,len); int len_tmp = flashDbgBuf->StartAddr+flashDbgBuf->Size - flashDbgBuf->InPos; int len_remain = len-len_tmp; spi_flash_write(flashDbgBuf->InPos,(uint32 *)data,len_tmp); spi_flash_write(flashDbgBuf->StartAddr,(uint32 *)(data+len_tmp),len_remain); flashDbgBuf->InPos = flashDbgBuf->StartAddr+len_remain; //debug_FlashParamSv(flashDbgBuf,Flash_DEBUG_INFO_ADDR); debug_FlashParamSv(flashDbgBuf,idx_sector); ESP_DBG("2\r\n"); } }