/*================================================================ Copyright (c) 2021, Quectel Wireless Solutions Co., Ltd. All rights reserved. Quectel Wireless Solutions Proprietary and Confidential. =================================================================*/ #ifndef _QL_FOTA_H_ #define _QL_FOTA_H_ #include "mi_api.h" #include "download.h" #include "ql_fs.h" #include "fbf_parse.h" // Used to select the flash type when setting the fota path, default is NOR #define QL_FOTA_IN_NOR_TAG "QOTANOR@" #define QL_FOTA_IN_NAND_TAG "QOTANAD@" typedef enum{ QL_FOTA_IN_NAND = 0u, QL_FOTA_IN_NOR }ql_fota_flash_type_t; typedef void* qlFotaImgProcCtxPtr; #define NoError 0x0 #define NotFoundError 0x1 #define GeneralError 0x2 #define WriteError 0x3 #define ReadError 0x4 #define NotSupportedError 0x5 #define InvalidPlatformConfigError 0x6 #define InvalidPlatformState 0x7 #define InvalidSizeError 0x9 #define ProbeListExhaustError 0xA #define DDR_NotInitializedError 0xB #define UnknownReservedPackage 0xD #define NULLPointer 0xE #define NANDIDDISMATCH 0xF #define FBF_VersionNotMatch 0x10 #define FBF_DeviceMoreThanOne 0x11 #define FBF_CheckSumError 0x12 #define FBF_UniqueError 0x13 #define NotEnoughMomeryError 0x14 #define NotEnoughFlashError 0x15 #define CRCFailedError 0x16 #define DFota_ImageDFotaDecodeFailed 0x17 #define DFota_LZMADecompressFailed 0x18 #define DFota_NotFoundRelevantFile 0x19 #define DFota_GetOldFileSizeError 0x20 #define DFota_BspatchFailed 0x21 #define DFota_CRCFailedError 0x22 #define DFota_MINI_StatusError 0x23 #define DFota_MINI_MagicError 0x24 #define DFota_ImageNumTooLarger 0x25 #define DFota_WriteFlashCheckFailed 0x26 #define DFota_MagicError 0x27 #define FotaImageSizeTooLarger 0x28 #define NotOtaUpdaterError 0x29 typedef enum { QUEC_FOTA_CODE_NOERROR = 0, QUEC_FOTA_CODE_GENERAL_SUCESS = QUEC_FOTA_CODE_NOERROR, QUEC_FOTA_CODE_GENERAL_ERROR = 500, QUEC_FOTA_CODE_NULL_POINTER, QUEC_FOTA_CODE_LEN_ERROR, QUEC_FOTA_CODE_UPGRADE_FAILED = 504, QUEC_FOTA_CODE_FILE_CHK_FAILED = 505, QUEC_FOTA_CODE_MD5_CHECK_ERROR, QUEC_FOTA_CODE_FILE_NUM_CHECK_ERROR, QUEC_FOTA_CODE_FILE_START_CHECK_ERROR, QUEC_FOTA_CODE_FILE_INFO_CHECK_ERROR, QUEC_FOTA_CODE_HEADER_CHECK_ERROR, QUEC_FOTA_CODE_FLASH_ERASE_ERROR = 511, QUEC_FOTA_CODE_FLASH_WRITE_ERROR, QUEC_FOTA_CODE_FLASH_READ_ERROR, QUEC_FOTA_CODE_RECV_TASK_ERROR = 514, QUEC_FOTA_CODE_WRITE_TASK_ERROR = 515, QUEC_FOTA_PKG_FILE_WRITE_ERROR = 535, QUEC_FOTA_PKG_FILE_HANDLE_ERROR = 536, QUEC_FOTA_FILE_SYSTEM_SPACE_NOT_ENOUGH = 537, QUEC_FOTA_NO_MEMORY_ERROR = 545, //! Not enough memory was available to perform the operation. }quec_fota_error_code_e; typedef enum { QL_FOTA_DWNLD_MOD_FTP, QL_FOTA_DWNLD_MOD_HTTP }qlFotaDwnldMod; struct ql_image_process_context { ImginfoTable * image_info_table; ImginfoTable * current_process; unsigned int processed_cnt; int state; char * flash_cache; int flash_cache_index; int (*flash_cb)(struct ql_image_process_context *, char *, int, unsigned int); char * checksum_cache; int checksum_cache_index; unsigned int image_checksum; struct image_state * image_state_list; QFILE *fp; unsigned int download_stage; unsigned int saved_head; unsigned int backupAddress; unsigned int startFirAddress; unsigned int startFirSize; unsigned int startSecAddress; unsigned int startSecSize; asr_non_diff_info nondiffinfo; }; #define FOTAPARAM_BLOCK_SIZE (4*1024) #define FOTA_FILE_NAME_SIZE 30 #define FOTA_DOWN_AND_UPGRADE "FULLOTA1" #define FOTA_ONLY_UPGRADE "FULLOTA2" typedef enum { QL_FOTA_SETFLAG = 2, QL_FOTA_INPROGRESS = 1, QL_FOTA_SUCCEED = 0, QL_FOTA_FAIL = -1 }qlFotaSta; typedef enum { QL_FULLAPP_SUCESS, //升级成功 QL_FULLAPP_ABNORMAL_ERROR, //升级失败 QL_FULLAPP_CONNECT_FAIL, //网络连接失败 QL_FULLAPP_FILE_NOT_EXIT, //url路径错误 QL_FULLAPP_FILE_CHECK_ERROR //fota文件检验失败 }ql_fullapp_result; typedef void(* fullfota_app_progress_cb)(char progress); typedef void(* fullfota_app_result_cb)(ql_fullapp_result result); extern int ql_fota_mini_system(int profile_idx, qlFotaDwnldMod mode, char * host, char * host2, char * username, char * password); extern int ql_fota_start(int profile_idx, char * url); extern int ql_fota_mergefile_mini_system(int profile_idx, qlFotaDwnldMod mode, char * host, char * host2, char * username, char * password); extern int ql_fullfota_app_start(char * host); /*********************************************************************** * * Name: ql_fullfota_app_progress * * Description: 注册获取全量升级app的升级进度 * * Parameters: cb:注册的回调函数,回调函数的参数即为升级进度 * * Returns: * ***********************************************************************/ extern void ql_fullfota_app_progress(fullfota_app_progress_cb cb); /*********************************************************************** * * Name: ql_fullfota_app_result * * Description: 注册获取全量升级app的升级结果 * * Parameters: cb:注册的回调函数,回调函数的参数即为升级结果,参考枚举ql_fullapp_result * * Returns: * ***********************************************************************/ extern void ql_fullfota_app_result(fullfota_app_result_cb cb); extern qlFotaImgProcCtxPtr ql_fota_init(void); extern int ql_fota_image_write(qlFotaImgProcCtxPtr context, void * data, int len); extern int ql_fota_image_read(qlFotaImgProcCtxPtr context, void * data, int len); extern int ql_fota_image_flush(qlFotaImgProcCtxPtr context); extern int ql_fota_image_verify(qlFotaImgProcCtxPtr context); extern void ql_fota_deinit(qlFotaImgProcCtxPtr context); extern char ql_fota_set_package_path(char* package_path); extern void ql_fota_fixed_internal_flash_upgrade(unsigned char flag); // secfota typedef void (*ql_secfota_cb_t)(int err_code); extern void ql_secfota_config(int enable, ql_secfota_cb_t cb); extern bool ql_secfota_get_enable(void); #endif /* _QL_UART_H_ */