解决不能擦除flash的问题
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
#include "base/utility.h"
|
||||
#include "hardware/power.h"
|
||||
#include "hardware/timer_cfg.h"
|
||||
|
||||
#include "debug.h"
|
||||
|
||||
#define UPDATA_PACK_LEN 58
|
||||
#define UPDATA_BASE_ADDR 0x1000
|
||||
@@ -23,6 +23,7 @@ static uint8_t EW_Erease(void)
|
||||
uint8_t ret=0;
|
||||
DMod_SendBytesXor(data,2,1);
|
||||
ret=DMod_ReadBytesXor(read,4,100);
|
||||
DBG_LOG("ret=%d,dat=%02x,%02x,%02x,%02x,",ret,read[0],read[1],read[2],read[3]);
|
||||
delay_ms(50);
|
||||
return ret;
|
||||
}
|
||||
@@ -36,6 +37,7 @@ static uint8_t EW_Jump(void)
|
||||
uint8_t ret=0;
|
||||
DMod_SendBytesXor(data,2,1);
|
||||
ret=DMod_ReadBytesXor(read,4,100);
|
||||
DBG_LOG("ret=%d,dat=%02x,%02x,%02x,%02x,",ret,read[0],read[1],read[2],read[3]);
|
||||
delay_ms(50);
|
||||
return ret;
|
||||
}
|
||||
@@ -50,6 +52,7 @@ static uint8_t EW_Charg(void)
|
||||
delay_ms(2000);
|
||||
DMod_SendBytesXor(data,3,1);
|
||||
ret=DMod_ReadBytesXor(read,4,100);
|
||||
DBG_LOG("ret=%d,dat=%02x,%02x,%02x,%02x,",ret,read[0],read[1],read[2],read[3]);
|
||||
delay_ms(5000);
|
||||
return ret;
|
||||
}
|
||||
@@ -70,6 +73,7 @@ static uint8_t EW_Write(uint16_t addr,uint8_t *d,uint16_t len)
|
||||
DMod_SendBytesXor(buf,len+2+2,1);
|
||||
ret=DMod_ReadBytesXor(read,4,100);
|
||||
rt_free(buf);
|
||||
DBG_LOG("ret=%d,dat=%02x,%02x,%02x,%02x,",ret,read[0],read[1],read[2],read[3]);
|
||||
delay_ms(50);
|
||||
return ret;
|
||||
}
|
||||
@@ -89,6 +93,7 @@ static uint8_t EW_CheckCrc(uint16_t adr_start,uint16_t adr_end,uint32_t *crc)
|
||||
*crc=(read[3])|(read[4]<<8)|(read[5]<<16)|(read[6]<<24);
|
||||
}
|
||||
}
|
||||
DBG_LOG("ret=%d,dat=%02x,%02x,%02x,%02x,",ret,read[0],read[1],read[2],read[3]);
|
||||
delay_ms(50);
|
||||
return ret;
|
||||
}
|
||||
@@ -110,12 +115,23 @@ static uint8_t EW_Read(uint16_t adr,uint8_t *buf,uint16_t len)
|
||||
{
|
||||
rt_memcpy(buf,&read[3],len);
|
||||
}
|
||||
DBG_LOG("ret=%d,dat=%02x,%02x,%02x,%02x,",ret,read[0],read[1],read[2],read[3]);
|
||||
delay_ms(50);
|
||||
rt_free(read);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
// app:通信测试
|
||||
static void EW_appCommTest(void)
|
||||
{
|
||||
uint8_t data[4]={0x11,0x22};
|
||||
uint8_t ret;
|
||||
ret=EW_CommTest(data,2,300);
|
||||
DBG_LOG("ret=%d,dat=%02x,%02x,%02x,%02x,",ret,data[0],data[1],data[2],data[3]);
|
||||
}
|
||||
|
||||
|
||||
// 升级
|
||||
void EW_Updata(void)
|
||||
{
|
||||
@@ -127,9 +143,11 @@ void EW_Updata(void)
|
||||
uint8_t pack_len=UPDATA_PACK_LEN;
|
||||
uint32_t crc=0;
|
||||
uint32_t crc_module=0;
|
||||
EW_appCommTest();
|
||||
ret=EW_Charg();
|
||||
if(ret) {ret=1;goto err;}
|
||||
ret=EW_Erease();
|
||||
//ret=EW_Jump();
|
||||
if(ret) {ret=2;goto err;}
|
||||
while(len>0){
|
||||
pack_len=len>UPDATA_PACK_LEN?UPDATA_PACK_LEN:len;
|
||||
@@ -156,6 +174,7 @@ void EW_Updata(void)
|
||||
delay_ms(100);
|
||||
|
||||
err:
|
||||
DBG_LOG("ret=%d",ret);
|
||||
Checker_MaskResult(ret,checker_runcfg.task_info.runindex);
|
||||
}
|
||||
|
||||
@@ -191,8 +210,9 @@ void EW_Test_SetBusV(void)
|
||||
Checker_RunCfg_st *cfg=&checker_runcfg;
|
||||
uint8_t uc_rtv = 0;
|
||||
uint16_t us_h_v,us_m_v;
|
||||
//us_h_v = cfg->params[0];
|
||||
us_h_v = 240;
|
||||
uint16_t power_old;
|
||||
us_h_v = cfg->params[0];
|
||||
power_old=us_h_v;
|
||||
if(us_h_v < 55)
|
||||
{
|
||||
uc_rtv = 1;
|
||||
@@ -207,6 +227,12 @@ void EW_Test_SetBusV(void)
|
||||
us_h_v = Power_GetBousV();
|
||||
Checker_SetRtv(&us_h_v,cfg->rtv_count);
|
||||
}
|
||||
if(uc_rtv){
|
||||
DBG_WARN("bus power init failed.h");
|
||||
}
|
||||
if((us_h_v<power_old-10)||(us_h_v>power_old+10)){
|
||||
DBG_WARN("power set fialed,want=%d,reality=%d.",power_old,us_h_v);
|
||||
}
|
||||
Checker_MaskResult(uc_rtv,cfg->task_info.runindex);
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user