int OTAClass::beginArduinoMdnsService(char *device_name, uint16_t port) { int ret = -1; mdns_buf = (unsigned char *) malloc (DEFAULT_OTA_MDNS_BUF); txtRecord = malloc (sizeof(TXTRecordRef)); do { if (mDNSResponderInit() != 0) { OTA_PRINTF("Fail to init mDNS service\r\n"); break; } TXTRecordCreate((TXTRecordRef *)txtRecord, DEFAULT_OTA_MDNS_BUF, mdns_buf); TXTRecordSetValue((TXTRecordRef *)txtRecord, "board", strlen("ameba_rtl8195a"), "ameba_rtl8195a"); TXTRecordSetValue((TXTRecordRef *)txtRecord, "auth_upload", strlen("no"), "no"); TXTRecordSetValue((TXTRecordRef *)txtRecord, "tcp_check", strlen("no"), "no"); TXTRecordSetValue((TXTRecordRef *)txtRecord, "ssh_upload", strlen("no"), "no"); mdns_service_id = mDNSRegisterService(device_name, "_arduino._tcp", "local", port, (TXTRecordRef *)txtRecord); TXTRecordDeallocate((TXTRecordRef *)txtRecord); ret = 0; } while (0); if (ret < 0) { OTA_PRINTF("Fail to begin Arduino mDNS service\r\n"); } return ret; }
static INT32 InitStorage() { m_StoDevice = (struct sto_device *)dev_get_by_type(NULL, HLD_DEV_TYPE_STO); if(NULL == m_StoDevice) { OTA_PRINTF("%s: can not get sto device\n", __FUNCTION__); return ERR_NO_DEV; } INT32 er = sto_open(m_StoDevice); if(SUCCESS != er) { OTA_PRINTF("%s: can not open sto device\n", __FUNCTION__); } return er; }
void ddb_section(struct get_section_param *sr_request) { INT32 modul_idx; UINT8* section_buf = sr_request->buff; UINT16 table_id_extension = (section_buf[3]<<8) +section_buf[4]; OTA_PRINTF("rcvd :module_id = %x, section_num = %d\n",table_id_extension,section_buf[6]); for(modul_idx=0;modul_idx<g_dc_module_num;modul_idx++) { if(g_dc_module[modul_idx].module_id == table_id_extension) break; } if(modul_idx==g_dc_module_num) return; if((UINT8)(g_dc_module[modul_idx].block_num-1) != section_buf[7]) { OTA_PRINTF("g_dc_module[i].block_num-1 != last_section_num\n"); return ;//ASSERT(0); } struct section_param sec_param; sec_param.section_type = 2; sec_param.param8 = modul_idx; if(parse_dsmcc_sec(sr_request->buff,sr_request->buff_len,(void*)(&sec_param)) != OTA_SUCCESS) return; for(modul_idx=0;modul_idx<g_dc_module_num;modul_idx++) { if(g_dc_module[modul_idx].module_download_finish != 1) break; } if(modul_idx==g_dc_module_num) { sr_request->continue_get_sec = 0; } received_section_num ++; OTA_PRINTF("%d%\n",received_section_num*100/total_block_num); if(progress_disp!=NULL) progress_disp(PROCESS_NUM,received_section_num*100/total_block_num); return; }
int OTAClass::sync_ota_addr() { flash_t flash; uint32_t ota_addr_in_flash; flash_read_word(&flash, FLASH_SYSTEM_DATA_ADDR, &ota_addr_in_flash); if (ota_addr_in_flash == ~0x0) { // No OTA address configuired in flash OTA_PRINTF("use default OTA address\r\n"); ota_addr = DEFAULT_OTA_ADDRESS; flash_write_word(&flash, FLASH_SYSTEM_DATA_ADDR, ota_addr); } else { ota_addr = ota_addr_in_flash; } }
static INT32 BurnBlock(UINT8 *pBuffer, UINT32 Pos, UINT8 NumSectors) { struct sto_device *sto_dev = m_StoDevice; UINT32 param; INT32 offset, er = SUCCESS; UINT8 i; for(i=0; i<NumSectors; i++) { offset = (Pos + i) * C_SECTOR_SIZE; param = ((UINT32)offset) << 10; // upper 22 bits is offset based on SYS_FLASH_BASE_ADDR param += C_SECTOR_SIZE >> 10; // lower 10 bits is length in K bytes OTA_PRINTF("%s: erase sector %d\n", __FUNCTION__, Pos+i); er = sto_io_control(sto_dev, STO_DRIVER_SECTOR_ERASE, param); if(er != SUCCESS) { OTA_PRINTF("%s: erase sector %d failed\n", __FUNCTION__, i); break; } if(pBuffer) { OTA_PRINTF("%s: seek sector %d, offset = %xh\n", __FUNCTION__, Pos+i,offset); if(sto_lseek(sto_dev, offset, STO_LSEEK_SET) != offset) { OTA_PRINTF("%s: seek sector %d failed\n", __FUNCTION__, i); er = ERR_FAILED; break; } OTA_PRINTF("%s: write sector %d, src = %xh\n", __FUNCTION__, Pos+i,&pBuffer[C_SECTOR_SIZE * i]); if(sto_write(sto_dev, &pBuffer[C_SECTOR_SIZE * i], C_SECTOR_SIZE) != C_SECTOR_SIZE) { OTA_PRINTF("%s: write sector %d failed\n", __FUNCTION__, i); er = ERR_FAILED; break; } } StepBurningProgress(); } return er; }
INT32 si_private_sec_parsing_start(UINT8 section_type,UINT16 pid, section_parser_t section_parser, void *param) { INT32 i; struct dmx_device * dmx_dev; if((dmx_dev = (struct dmx_device *)dev_get_by_id(HLD_DEV_TYPE_DMX, 0)) == NULL) { OTA_PRINTF("ERROR : get dmx dev failure !"); return OTA_FAILURE; } struct get_section_param sr_request; struct restrict sr_restrict; MEMSET(&sr_restrict, 0, sizeof(struct restrict)); sr_request.buff = (UINT8 *)g_ota_section_buf; sr_request.buff_len = g_ota_section_buf_len; sr_request.crc_flag = 1; sr_request.pid = pid; sr_request.mask_value = &sr_restrict; sr_request.wai_flg_dly = 300000; if(section_type == 0) { /* DSI */ sr_restrict.mask_len = 7; sr_restrict.value_num = 1; MEMSET(sr_restrict.mask,0,sr_restrict.mask_len); MEMSET(sr_restrict.value[0],0,sr_restrict.mask_len); sr_restrict.mask[0] = 0xff; sr_restrict.mask[1] = 0x80; sr_restrict.mask[3] = 0xff; sr_restrict.mask[4] = 0xfe; sr_restrict.mask[6] = 0xff; sr_restrict.value[0][0] = 0x3b; sr_restrict.value[0][1] = 0x80; sr_restrict.value[0][3] = 0x00; sr_restrict.value[0][4] = 0x00; //0000 |0001 sr_restrict.value[0][6] = 0x00; //section_num = 0 sr_request.get_sec_cb = NULL; sr_request.continue_get_sec = 0; } else if(section_type == 1) { /* DII */ sr_restrict.mask_len = 7; sr_restrict.value_num = 1; MEMSET(sr_restrict.mask,0,sr_restrict.mask_len); MEMSET(sr_restrict.value[0],0,sr_restrict.mask_len); sr_restrict.mask[0] = 0xff; sr_restrict.mask[1] = 0x80; sr_restrict.mask[3] = 0xff; sr_restrict.mask[4] = 0xff; sr_restrict.mask[6] = 0xff; sr_restrict.value[0][0] = 0x3b; sr_restrict.value[0][1] = 0x80; sr_restrict.value[0][3] = ((g_dc_group.group_id)>>8)&0xff; sr_restrict.value[0][4] = (g_dc_group.group_id)&0xff; sr_restrict.value[0][6] = 0x00; //section_num = 0 sr_request.get_sec_cb = NULL; sr_request.continue_get_sec = 0; }
int OTAClass::beginLocal(uint16_t port, bool reboot_when_success) { int ret = -1; // variables for image processing flash_t flash; uint32_t img2_addr, img2_len, img3_addr, img3_len; uint32_t img_upper_bound; uint32_t checksum = 0; uint32_t signature1, signature2; // variables for network processing int server_socket = -1; int client_socket = -1; struct sockaddr_in localHost; struct sockaddr_in client_addr; int socket_error, socket_timeout; socklen_t optlen; // variables for OTA unsigned char *buf = NULL; int read_bytes = 0, processed_len; uint32_t file_info[3]; uint32_t ota_len; uint32_t ota_blk_size = 0; int i, n; do { sync_ota_addr(); get_image_info(&img2_addr, &img2_len, &img3_addr, &img3_len); img_upper_bound = img2_addr + 0x10 + img2_len; // image2 base + header + len if (img3_len > 0) { img_upper_bound += 0x10 + img3_len; // image 3 header + len } if ((ota_addr & 0xfff != 0) || (ota_addr == ~0x0) || (ota_addr < img_upper_bound)) { OTA_PRINTF("Invalid OTA address: %08X\r\n", ota_addr); break; } buf = (unsigned char *) malloc (BUFSIZE); if (buf == NULL) { OTA_PRINTF("Fail to allocate memory\r\n"); break; } server_socket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); if (server_socket < 0) { OTA_PRINTF("Fail to create socket\r\n"); break; } memset(&localHost, 0, sizeof(localHost)); localHost.sin_family = AF_INET; localHost.sin_port = htons(port); localHost.sin_addr.s_addr = INADDR_ANY; if (lwip_bind(server_socket, (struct sockaddr *)&localHost, sizeof(localHost)) < 0) { OTA_PRINTF("Bind fail\r\n"); break; } if (lwip_listen(server_socket , 1) < 0) { OTA_PRINTF("Listen fail\r\n"); break; } OTA_PRINTF("Wait for client\r\n"); n = (int) sizeof( client_addr ); memset(&client_addr, 0, sizeof(client_addr)); client_socket = lwip_accept(server_socket, (struct sockaddr *) &client_addr, (socklen_t *)&n); OTA_PRINTF("Client connected. IP:%s port:%d\r\n\r\n", inet_ntoa(client_addr.sin_addr.s_addr), ntohs(client_addr.sin_port)); socket_timeout = DEFAULT_IMAGE_DOWNLOAD_TIMEOUT; lwip_setsockopt(client_socket, SOL_SOCKET, SO_RCVTIMEO, &socket_timeout, sizeof(socket_timeout)); OTA_PRINTF("Read OTA info...\r\n"); read_bytes = read(client_socket, file_info, sizeof(file_info)); if (read_bytes < 0) { OTA_PRINTF("Fail to read OTA info\r\n"); break; } if (file_info[2] == 0) { OTA_PRINTF("OTA image len is 0\r\n"); break; } ota_len = file_info[2]; ota_blk_size = ((ota_len - 1) / 4096) + 1; for (i = 0; i < ota_blk_size; i++) { flash_erase_sector(&flash, ota_addr + i * 4096); } OTA_PRINTF("Start download\r\n"); // Now download OTA image processed_len = 0; while( processed_len < ota_len ) { memset(buf, 0, BUFSIZE); read_bytes = read(client_socket, buf, BUFSIZE); if (read_bytes < 0) { optlen = sizeof(socket_error); getsockopt(client_socket, SOL_SOCKET, SO_ERROR, &socket_error, &optlen); if (socket_error == EAGAIN) { // socket timeout } break; } if (flash_stream_write(&flash, ota_addr + processed_len, read_bytes, buf) < 0) { OTA_PRINTF("Write sector fail\r\n"); break; } processed_len += read_bytes; } if (processed_len != ota_len) { OTA_PRINTF("Download fail\r\n"); break; } // Read OTA image from flash and calculate checksum checksum = processed_len = 0; while ( processed_len < ota_len ) { n = (processed_len + BUFSIZE < ota_len) ? BUFSIZE : (ota_len - processed_len); flash_stream_read(&flash, ota_addr + processed_len, n, buf); for (i=0; i<n; i++) checksum += (buf[i] & 0xFF); processed_len += n; } if (checksum != file_info[0]) { OTA_PRINTF("Bad checksum:%d expected:%d\r\n", checksum, file_info[0]); break; } // Put signature for OTA image flash_write_word(&flash, ota_addr + 8, 0x35393138); flash_write_word(&flash, ota_addr + 12, 0x31313738); flash_read_word(&flash, ota_addr + 8, &signature1); flash_read_word(&flash, ota_addr + 12, &signature2); if (signature1 != 0x35393138 || signature2 != 0x31313738) { OTA_PRINTF("Put signature fail\r\n"); break; } // Mark image 2 as old image flash_write_word(&flash, img2_addr + 8, 0x35393130); ret = 0; OTA_PRINTF("OTA success\r\n"); } while (0); if (buf != NULL) { free(buf); } if (server_socket >= 0) { close(server_socket); } if (client_socket >= 0) { close(client_socket); } if (ret < 0) { OTA_PRINTF("OTA fail\r\n"); } else { if (reboot_when_success) { sys_reset(); } } return ret; }
static BOOL SetupOtaParameters() { UINT32 addr,address; UINT32 len, lenth; #if 1 UINT32 chid_key = 0x07F80100; UINT32 chid_db = 0x04FB0100; UINT32 chid = 0x01FE0101; m_ota_info.uncompressed_len = (UINT32)get_unzip_size((UINT8 *)m_ota_info.compressed_addr); chunk_init(m_ota_info.uncompressed_addr,m_ota_info.uncompressed_len); if ((UINT8*)chunk_goto(&chid, 0xFFFFFFFF, 1) != NULL) { // get unzip size; if(!get_chuck_add_len(0x04FB0100, &addr, &len)) { OTA_PRINTF("--------get_chuck_add_len failed -------- \n"); return FALSE; } // find the firmware position m_ota_info.ota_fw_addr = m_ota_info.uncompressed_addr; m_ota_info.ota_fw_size = addr + len - m_ota_info.ota_fw_addr; // find ota.bin position. m_ota_info.ota_bin_addr = m_ota_info.ota_fw_addr + m_ota_info.ota_fw_size; m_ota_info.ota_bin_size = m_ota_info.uncompressed_len - m_ota_info.ota_fw_size; m_ota_info.ota_bin_sectors = m_ota_info.ota_bin_size/C_SECTOR_SIZE; if(len % C_SECTOR_SIZE) m_ota_info.ota_bin_sectors++; // calculate upgrade sectors. m_ota_info.ota_upg_addr = m_ota_info.ota_fw_addr + C_SECTOR_SIZE; //skip bootloader sector. m_ota_info.ota_upg_size = m_ota_info.ota_fw_size - len - C_SECTOR_SIZE; //skip bootloader and user_db m_ota_info.ota_upg_sectors = m_ota_info.ota_upg_size/C_SECTOR_SIZE; if(m_ota_info.ota_upg_size % C_SECTOR_SIZE) m_ota_info.ota_upg_sectors++; m_ota_info.update_secotrs_index = 0; #ifdef _BUILD_OTA_E_ m_ota_info.update_total_sectors = m_ota_info.ota_upg_sectors + \ m_ota_info.user_db_sectors; #else m_ota_info.update_total_sectors = m_ota_info.ota_upg_sectors + \ m_ota_info.ota_bin_sectors + m_ota_info.user_db_sectors; #endif // find ota_cfg chunk. chunk_init(m_ota_info.ota_bin_addr,m_ota_info.ota_bin_size); UINT32 chid = 0x15Fa0200; UINT8 *p = (UINT8*)chunk_goto(&chid, 0xFFFFFFFF, 1); if(p) { m_ota_info.ota_bin_cfg_addr = (UINT32)p; ota_save_parameter(p); } OTA_PRINTF("ota_bin_sectors1111111111 == %d \n", m_ota_info.ota_bin_sectors); OTA_PRINTF("ota_bin_size1111111111 == %d \n", m_ota_info.ota_bin_size); burning_flag = 1; return TRUE; } else { //key if( (UINT8*)chunk_goto(&chid_key, 0xFFFFFFFF, 1) != NULL && (UINT8*)chunk_goto(&chid_db, 0xFFFFFFFF, 1) == NULL) { m_ota_info.uncompressed_len = (UINT32)get_unzip_size((UINT8 *)m_ota_info.compressed_addr); chunk_init(m_ota_info.uncompressed_addr,m_ota_info.uncompressed_len); if(!get_chuck_add_len(0x07F80100, &addr, &len)) { OTA_PRINTF("--------get_chuck_add_len failed -------- \n"); return FALSE; } m_ota_info.ota_fw_addr = m_ota_info.uncompressed_addr; m_ota_info.ota_fw_size = addr + len - m_ota_info.ota_fw_addr; m_ota_info.ota_upg_addr = m_ota_info.ota_fw_addr + 0*C_SECTOR_SIZE; m_ota_info.ota_upg_size = len; m_ota_info.ota_upg_sectors = 1; m_ota_info.update_secotrs_index = 0; m_ota_info.update_total_sectors = 1 ; api_get_chuck_addlen(0x07F80100, &addr, &len); m_ota_info.ota_fw_size = addr/C_SECTOR_SIZE;//now ,ota_fw_size is key block num chunk_init(m_ota_info.ota_bin_addr,m_ota_info.ota_bin_size); UINT32 chid = 0x15Fa0200; UINT8 *p = (UINT8*)chunk_goto(&chid, 0xFFFFFFFF, 1); if(p) { m_ota_info.ota_bin_cfg_addr = (UINT32)p; ota_save_parameter(p); } OTA_PRINTF("ota_fw_size == 0x%08x \n", m_ota_info.ota_fw_size); OTA_PRINTF("ota_upg_addr1111111111 == 0x%08x \n", m_ota_info.ota_upg_addr); OTA_PRINTF("ota_upg_size1111111111 == 0x%08x \n", m_ota_info.ota_upg_size); OTA_PRINTF("ota_upg_sectors1111111111 == %d \n", m_ota_info.ota_upg_sectors); burning_flag = 2; return TRUE; } //db if( (UINT8*)chunk_goto(&chid_key, 0xFFFFFFFF, 1) == NULL && (UINT8*)chunk_goto(&chid_db, 0xFFFFFFFF, 1) != NULL) { //OTA_PRINTF("ttttttttttttt \n"); m_ota_info.uncompressed_len = (UINT32)get_unzip_size((UINT8 *)m_ota_info.compressed_addr); chunk_init(m_ota_info.uncompressed_addr,m_ota_info.uncompressed_len); if(!get_chuck_add_len(0x04FB0100, &addr, &len)) { return FALSE; } OTA_PRINTF("addr == 0x%08x \n", addr); OTA_PRINTF("len == 0x%08x \n", len); m_ota_info.ota_fw_addr = m_ota_info.uncompressed_addr; m_ota_info.ota_fw_size = addr + len - m_ota_info.ota_fw_addr; m_ota_info.ota_upg_addr = m_ota_info.ota_fw_addr; m_ota_info.ota_upg_size = m_ota_info.ota_fw_size; //m_ota_info.ota_upg_size = len; m_ota_info.ota_upg_sectors = m_ota_info.ota_upg_size/C_SECTOR_SIZE; //if(m_ota_info.ota_upg_size % C_SECTOR_SIZE) // m_ota_info.ota_upg_sectors++; m_ota_info.update_secotrs_index = 0; m_ota_info.update_total_sectors = m_ota_info.ota_upg_sectors ; chunk_init(m_ota_info.ota_bin_addr,m_ota_info.ota_bin_size); UINT32 chid = 0x15Fa0200; UINT8 *p = (UINT8*)chunk_goto(&chid, 0xFFFFFFFF, 1); if(p) { m_ota_info.ota_bin_cfg_addr = (UINT32)p; ota_save_parameter(p); } burning_2 =2; //OTA_PRINTF("burning_2 == %d \n", burning_2); OTA_PRINTF("ota_upg_addr1111111111 == 0x%08x \n", m_ota_info.ota_upg_addr); OTA_PRINTF("ota_upg_size1111111111 == 0x%08x \n", m_ota_info.ota_upg_size); OTA_PRINTF("ota_upg_sectors1111111111 == %d \n", m_ota_info.ota_upg_sectors); return TRUE; } //key + db if( (UINT8*)chunk_goto(&chid_key, 0xFFFFFFFF, 1) != NULL && (UINT8*)chunk_goto(&chid_db, 0xFFFFFFFF, 1) != NULL) { m_ota_info.uncompressed_len = (UINT32)get_unzip_size((UINT8 *)m_ota_info.compressed_addr); chunk_init(m_ota_info.uncompressed_addr,m_ota_info.uncompressed_len); if(!get_chuck_add_len(0x04FB0100, &addr, &len)) { return FALSE; } if(!get_chuck_add_len(0x07F80100, &address, &lenth)) { return FALSE; } m_ota_info.ota_fw_addr = m_ota_info.uncompressed_addr; m_ota_info.ota_fw_size = lenth; m_ota_info.ota_upg_addr = m_ota_info.ota_fw_addr; m_ota_info.ota_upg_size = lenth; m_ota_info.ota_upg_sectors = 1; //if(m_ota_info.ota_upg_size % C_SECTOR_SIZE) // m_ota_info.ota_upg_sectors++; //m_ota_info.ota_fw_addr2 = m_ota_info.uncompressed_addr; m_ota_info.ota_fw_size2 = len; m_ota_info.ota_upg_addr2 = addr; m_ota_info.ota_upg_size2 = len; m_ota_info.ota_upg_sectors2 = m_ota_info.ota_upg_size2/C_SECTOR_SIZE; if(m_ota_info.ota_upg_size2 % C_SECTOR_SIZE) m_ota_info.ota_upg_sectors2++; m_ota_info.update_secotrs_index = 0; m_ota_info.update_total_sectors = m_ota_info.ota_upg_sectors +m_ota_info.ota_upg_sectors2 ; api_get_chuck_addlen(0x07F80100, &address, &lenth); m_ota_info.ota_fw_size = address/C_SECTOR_SIZE;//now ,ota_fw_size is key block num chunk_init(m_ota_info.ota_bin_addr,m_ota_info.ota_bin_size); UINT32 chid = 0x15Fa0200; UINT8 *p = (UINT8*)chunk_goto(&chid, 0xFFFFFFFF, 1); if(p) { m_ota_info.ota_bin_cfg_addr = (UINT32)p; ota_save_parameter(p); } OTA_PRINTF("ota_fw_addr == 0x%08x \n", m_ota_info.ota_fw_addr); OTA_PRINTF("ota_fw_size1111111111 == 0x%08x \n", m_ota_info.ota_fw_size); OTA_PRINTF("ota_upg_addr1111111111 == 0x%08x \n", m_ota_info.ota_upg_addr); OTA_PRINTF("ota_upg_size1111111111 == 0x%08x \n", m_ota_info.ota_upg_size); OTA_PRINTF("ota_upg_sectors1111111111 == %d \n", m_ota_info.ota_upg_sectors); OTA_PRINTF("ota_upg_addr2 == 0x%08x \n", m_ota_info.ota_upg_addr2); OTA_PRINTF("ota_upg_size2 == 0x%08x \n", m_ota_info.ota_upg_size2); OTA_PRINTF("ota_upg_sectors2 == %d \n", m_ota_info.ota_upg_sectors2); burning_flag = 3 ; return TRUE; } } #else // get unzip size; m_ota_info.uncompressed_len = (UINT32)get_unzip_size((UINT8 *)m_ota_info.compressed_addr); chunk_init(m_ota_info.uncompressed_addr,m_ota_info.uncompressed_len); if(!get_chuck_add_len(0x04FB0100, &addr, &len)) { OTA_PRINTF("--------get_chuck_add_len failed -------- \n"); return FALSE; } // find the firmware position m_ota_info.ota_fw_addr = m_ota_info.uncompressed_addr; m_ota_info.ota_fw_size = addr + len - m_ota_info.ota_fw_addr; // find ota.bin position. m_ota_info.ota_bin_addr = m_ota_info.ota_fw_addr + m_ota_info.ota_fw_size; m_ota_info.ota_bin_size = m_ota_info.uncompressed_len - m_ota_info.ota_fw_size; m_ota_info.ota_bin_sectors = m_ota_info.ota_bin_size/C_SECTOR_SIZE; if(len % C_SECTOR_SIZE) m_ota_info.ota_bin_sectors++; // calculate upgrade sectors. m_ota_info.ota_upg_addr = m_ota_info.ota_fw_addr + C_SECTOR_SIZE; //skip bootloader sector. m_ota_info.ota_upg_size = m_ota_info.ota_fw_size - len - C_SECTOR_SIZE; //skip bootloader and user_db m_ota_info.ota_upg_sectors = m_ota_info.ota_upg_size/C_SECTOR_SIZE; if(m_ota_info.ota_upg_size % C_SECTOR_SIZE) m_ota_info.ota_upg_sectors++; m_ota_info.update_secotrs_index = 0; #ifdef _BUILD_OTA_E_ m_ota_info.update_total_sectors = m_ota_info.ota_upg_sectors + \ m_ota_info.user_db_sectors; #else m_ota_info.update_total_sectors = m_ota_info.ota_upg_sectors + \ m_ota_info.ota_bin_sectors + m_ota_info.user_db_sectors; #endif // find ota_cfg chunk. chunk_init(m_ota_info.ota_bin_addr,m_ota_info.ota_bin_size); UINT32 chid = 0x15Fa0200; UINT8 *p = (UINT8*)chunk_goto(&chid, 0xFFFFFFFF, 1); if(p) { m_ota_info.ota_bin_cfg_addr = (UINT32)p; ota_save_parameter(p); } OTA_PRINTF("ota_bin_sectors1111111111 == %d \n", m_ota_info.ota_bin_sectors); OTA_PRINTF("ota_bin_size1111111111 == %d \n", m_ota_info.ota_bin_size); return TRUE; #endif }