diff --git a/doc/JW3425_boot_v6.bin b/doc/JW3425_boot_v6.bin deleted file mode 100644 index e861c30..0000000 Binary files a/doc/JW3425_boot_v6.bin and /dev/null differ diff --git a/doc/JW3425_boot_v8.bin b/doc/JW3425_boot_v8.bin new file mode 100644 index 0000000..8a8c8c1 Binary files /dev/null and b/doc/JW3425_boot_v8.bin differ diff --git a/doc/creat_jwt_boot.py b/doc/creat_jwt_boot.py index 0d13a99..0c86eaf 100644 --- a/doc/creat_jwt_boot.py +++ b/doc/creat_jwt_boot.py @@ -5,7 +5,7 @@ import json -BOOT_PATH ="JW3425_boot_v6.bin" +BOOT_PATH ="JW3425_boot_v8.bin" APP_PATH ="MS-IEpro20231007.bin" OUT_PATH = "jwt_program.jwt" @@ -23,6 +23,27 @@ def arr_from_int(num:int): return bytearray([num&0xff,(num>>8)&0xff,(num>>16)&0xff,(num>>24)&0xff]) + +def crc32(data:bytearray): + temp=0 + crc=0xffffffff + i=0 + if(len(data)%4!=0): + return 0 + while(i0){ + ret=PowerCalibration_set(bus_hv,bus_mv); + } + else{ + ret=PowerCalibration_set(POWER_DEF_V,45); + POWER_OFF; + } cmd_print("cmd end,ret=%d.",ret); + return 0; } -commend_export(bus_power,cmd_set_bus_power,"set bus power,param:bus_power") +commend_export(bus_power,cmd_set_bus_power,"set bus power,param:bus_high_v,bus_mid_v") diff --git a/source/elec_det/interface/EWChecker.c b/source/elec_det/interface/EWChecker.c index 6061e44..b5ed6b5 100644 --- a/source/elec_det/interface/EWChecker.c +++ b/source/elec_det/interface/EWChecker.c @@ -7,8 +7,12 @@ #include "hardware/power.h" #include "hardware/timer_cfg.h" #include "debug.h" +#include "commend.h" +#include "mystring.h" +#include "mystdlib.h" -#define UPDATA_PACK_LEN 58 + +#define UPDATA_PACK_LEN 128 #define UPDATA_BASE_ADDR 0x1000 #define UPDATA_DATA_LEN (12*1024) #define UPDATA_FLAG_ADDR (0x3c7c) @@ -24,9 +28,15 @@ static uint8_t EW_Erease(void) 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; } +static int cmd_jwt_boot_erase(list_def *argv) +{ + int ret=0; + ret=EW_Erease(); + return ret; +} +commend_export(jwt_boot_erase,cmd_jwt_boot_erase,"jwt srase in boot") // 跳转 @@ -38,27 +48,61 @@ static uint8_t EW_Jump(void) 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; } +static int cmd_jwt_boot_jump(list_def *argv) +{ + int ret=0; + ret=EW_Jump(); + return ret; +} +commend_export(jwt_boot_jump,cmd_jwt_boot_jump,"jwt jump in boot") // 充电 static uint8_t EW_Charg(void) { - uint8_t data[4]={0xf8,0x01,0x04,0x00}; + uint8_t data[4]={0xf8,0x01,0x01,0x00}; uint8_t read[4]={0}; uint8_t ret=0; - 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; } +static int cmd_jwt_boot_charg(list_def *argv) +{ + int ret=0; + ret=EW_Charg(); + return ret; +} +commend_export(jwt_boot_charg,cmd_jwt_boot_charg,"jwt charg in boot") + + + +// 放电 +static uint8_t EW_DisCharg(void) +{ + uint8_t data[4]={0xf8,0x01,0x00,0x00}; + uint8_t read[4]={0}; + uint8_t ret=0; + 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]); + return ret; +} +static int cmd_jwt_boot_discharg(list_def *argv) +{ + int ret=0; + ret=EW_Charg(); + return ret; +} +commend_export(jwt_boot_discharg,cmd_jwt_boot_discharg,"jwt discharg in boot") + + // 发送数据 -// len 最长为58字节 +// len 最长为128字节 static uint8_t EW_Write(uint16_t addr,uint8_t *d,uint16_t len) { uint8_t ret=0; @@ -74,7 +118,6 @@ static uint8_t EW_Write(uint16_t addr,uint8_t *d,uint16_t len) 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; } @@ -93,10 +136,22 @@ 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); + DBG_LOG("addr_start=0x%04x,addr_end=0x%04x.",adr_start,adr_end); + DBG_LOG("ret=%d,dat=%02x,%02x,%02x,%02x,%02x,%02x,%02x,%02x,", + ret,read[0],read[1],read[2],read[3],read[4],read[5],read[6],read[7]); return ret; } +static int cmd_jwt_boot_checkcrc(list_def *argv) +{ + int ret=0; + uint32_t crc=0; + ret=EW_CheckCrc(UPDATA_BASE_ADDR,UPDATA_BASE_ADDR+UPDATA_DATA_LEN,&crc); + cmd_print("jwt crc32=0x%04x.",crc); + crc=Crc32Calu((uint32_t *)(MC_CODE_ADDR+UPDATA_BASE_ADDR),UPDATA_DATA_LEN); + cmd_print("local crc32=0x%04x.",crc); + return ret; +} +commend_export(jwt_boot_checkcrc,cmd_jwt_boot_checkcrc,"jwt checkcrc in boot") @@ -116,20 +171,31 @@ 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) +static int EW_appCommTest(void) { uint8_t data[4]={0x11,0x22}; uint8_t ret; + DBG_LOG("send:%02x,%02x.",data[0],data[1]); ret=EW_CommTest(data,2,300); DBG_LOG("ret=%d,dat=%02x,%02x,%02x,%02x,",ret,data[0],data[1],data[2],data[3]); + return ret; } +static int cmd_jwt_app_commtest(list_def *argv) +{ + int ret=0; + ret=EW_appCommTest(); + return ret; +} +commend_export(jwt_app_commtest,cmd_jwt_app_commtest,"jwt commtest in app") // 升级 @@ -143,12 +209,13 @@ void EW_Updata(void) uint8_t pack_len=UPDATA_PACK_LEN; uint32_t crc=0; uint32_t crc_module=0; - EW_appCommTest(); + delay_ms(100); ret=EW_Charg(); if(ret) {ret=1;goto err;} + delay_ms(6000); ret=EW_Erease(); - //ret=EW_Jump(); if(ret) {ret=2;goto err;} + delay_ms(600); while(len>0){ pack_len=len>UPDATA_PACK_LEN?UPDATA_PACK_LEN:len; ret=EW_Write(addr,data,pack_len); @@ -156,12 +223,15 @@ void EW_Updata(void) data+=pack_len; len-=pack_len; if(ret) {ret=3;goto err;} + delay_ms(50); } - crc=Crc32Calu((uint32_t *)MC_CODE_ADDR,UPDATA_DATA_LEN/4); + crc=Crc32Calu((uint32_t *)(MC_CODE_ADDR+UPDATA_BASE_ADDR),UPDATA_DATA_LEN); + DBG_LOG("local crc:0x%04x.",crc); ret=EW_CheckCrc(UPDATA_BASE_ADDR,UPDATA_BASE_ADDR+UPDATA_DATA_LEN,&crc_module); + DBG_LOG("module crc:0x%04x.",crc_module); if(ret) {ret=4;goto err;} - if(crc!=crc_module) - {ret=5;goto err;} + if(crc!=crc_module){ret=5;goto err;} + delay_ms(50); ret=EW_Jump(); if(ret) {ret=6;goto err;} delay_ms(100); @@ -185,6 +255,8 @@ void EW_Test_PowerOFF(void) uint8_t uc_rtv = 0; delay_os_ms(100); XTBUS_OFF; + PowerCalibration_set(POWER_DEF_V,45); + POWER_OFF; Checker_MaskResult(uc_rtv,checker_runcfg.task_info.runindex); } @@ -218,7 +290,7 @@ void EW_Test_SetBusV(void) uc_rtv = 1; }else{ - us_m_v = 50; + us_m_v = 55; uc_rtv |= PowerCalibration_set(us_h_v,us_m_v); XTBUS_ON diff --git a/source/main/compiler_info.h b/source/main/compiler_info.h index 985105b..7fe0422 100644 --- a/source/main/compiler_info.h +++ b/source/main/compiler_info.h @@ -6,7 +6,7 @@ -#define BUILD_DATE "2023-10-08 17:53:21" +#define BUILD_DATE "2023-10-09 17:54:49" #define SOFT_VERSION "0.03"