| /** |
| * @file upi_delta.h |
| * @brief ²î·ÖÎļþÏà¹ØÍ·Îļþ |
| * |
| * Copyright (C) 2017 Sanechips Technology Co., Ltd. |
| * @author |
| * |
| */ |
| |
| #ifndef _UPI_UPGRADE_PACKAGE_H |
| #define _UPI_UPGRADE_PACKAGE_H |
| |
| /******************************************************************************* |
| * Include header files * |
| ******************************************************************************/ |
| |
| #include "upi_public.h" |
| |
| /******************************************************************************* |
| * Macro definitions * |
| ******************************************************************************/ |
| |
| #define UPGRADE_PACKAGE_HEAD_MAGIC ("FOTA") |
| #define UPGRADE_PACKAGE_HEAD_MAGIC_LEN (4) |
| |
| #define VERSION_LEN (64) |
| |
| |
| /******************************************************************************* |
| * Type definitions * |
| ******************************************************************************/ |
| |
| /** |
| * @brief ²î·ÖÎļþÎļþÍ·ÐÅÏ¢£¬¿ÉÒÔÓÃÓÚУÑé²î·ÖÎļþµÈ£»¼°»ñÈ¡µ±Ç°ÎļþÖзÖÇø¼°extraÊýµÈ£» |
| * @param magic_word: ÎļþͷħÊõ×Ö |
| * @param plat: ƽ̨ |
| * @param upgrade_package_type: Éý¼¶°üÎļþÀàÐÍ AL£ºÈ«°æ±¾£¬ DE£º²î·Ö |
| * @param upgrade_type Éý¼¶ÀàÐÍ |
| * @param upgrade_package_version: Éý¼¶°üÎļþ°æ±¾ |
| * @param partition_num: ·ÖÇøÊý |
| * @param extra_num: hashËã·¨ÀàÐÍ£¬0£ºÄ¬ÈÏ SHA512 |
| * @param block_size: ¿é´óС£¬128ÕûÊý±¶ |
| * @param extra_num: extraÎļþÊý |
| * @param version_src: ²î·ÖÎļþÉý¼¶Ô´°æ±¾£¬¶ÔÓ¦ÄÚ²¿°æ±¾ºÅ |
| * @param version_dst: ²î·ÖÎļþÉý¼¶Ä¿±ê°æ±¾ºÅ£¬¶ÔÓ¦ÄÚ²¿°æ±¾ºÅ |
| * @param hash: hashËã·¨Öµ |
| **/ |
| |
| |
| |
| typedef struct |
| { |
| char magic_word[UPGRADE_PACKAGE_HEAD_MAGIC_LEN]; |
| int upgrade_package_version; |
| int plat; |
| int upgrade_package_type; |
| int upgrade_type; |
| int partition_num; |
| int extra_num; |
| int hash_type; |
| int block_size; |
| char version_src[VERSION_LEN]; |
| char version_dst[VERSION_LEN]; |
| unsigned char hash[HASH_MAX_LEN]; |
| char reserve[28]; |
| } upgrade_package_head_info_t; |
| |
| /** |
| * @brief ·ÖÇøÎļþÍ·ÐÅÏ¢£¬°üº¬´ýÉý¼¶µÄ²î·Ö·ÖÇøÎļþÐÅÏ¢ |
| * @param name: ²î·Ö·ÖÇøÃû |
| * @param len: ²î·Ö·ÖÇøÎļþ³¤¶È |
| * @param offset: ²î·Ö·ÖÇøÎļþÏà¶ÔÓÚdeltaÎļþ0µØÖ·µÄÆ«ÒÆ |
| * @param partition_type: ·ÖÇøÀàÐÍ |
| * @param zipped: ÊÇ·ñ¾¹ýѹËõ |
| * @param reserve: ±£Áô |
| * @param hash: ÖÆ×÷²î·Ö·ÖÇøµÄÔ´·ÖÇøÎļþmd5 |
| */ |
| typedef struct |
| { |
| char name[PARTITION_NAME_LEN]; |
| int len; |
| int offset; |
| int partition_type; |
| int zipped; |
| char reserve[16]; |
| unsigned char hash[HASH_MAX_LEN]; |
| } partition_head_info_t; |
| |
| |
| /** |
| * @brief extraÐÅÏ¢ |
| * @param name: extraÎļþÃû |
| * @param len: Îļþ³¤¶È |
| * @param offset: »ùÓÚÕû¸ö²î·ÖÎļþµÄÆ«ÒÆ |
| * @param hash: ÎļþhashÖµ |
| * @param reserve: Ô¤ÁôÐÅÏ¢ |
| */ |
| typedef struct |
| { |
| char name[EXTRA_NAME_LEN]; |
| int len; |
| int offset; |
| char reserve_1[8]; |
| unsigned char hash[HASH_MAX_LEN]; |
| char reserve_2[8]; |
| } extra_head_info_t; |
| |
| |
| /** |
| * @brief ²î·ÖÎļþÐÅÏ¢ |
| * @param head: ÎļþÍ·ÐÅÏ¢ |
| * @param partition_num: ÎļþÖзÖÇøÊý |
| * @param partition_info: ·ÖÇøÐÅÏ¢Ö¸ÕëÍ· |
| * @param extra_num: extraÎļþÊý |
| * @param extra_info: extraÎļþÐÅÏ¢Ö¸Õë |
| * @param upgrade_package_file_desc: Îļþ¾ä±ú |
| * @param upgrade_package_file_size: Îļþ³¤¶È |
| */ |
| typedef struct |
| { |
| upgrade_package_head_info_t *head; |
| // int partition_num; |
| partition_head_info_t *partition_info; |
| // int extra_num; |
| extra_head_info_t *extra_info; |
| int upgrade_package_file_desc; |
| unsigned int upgrade_package_file_size; |
| } upgrade_package_info_t; |
| |
| |
| |
| |
| |
| |
| /******************************************************************************* |
| * Global variable declarations * |
| ******************************************************************************/ |
| |
| |
| /******************************************************************************* |
| * Global function declarations * |
| ******************************************************************************/ |
| |
| |
| int init_upgrade_package_info(const char * upagrade_package_file_path); |
| void deinit_upgrade_package_info(); |
| |
| upgrade_package_info_t *get_upgrade_package_info(); |
| |
| partition_head_info_t *get_partition_head_info(); |
| int get_partition_num(); |
| |
| extra_head_info_t *get_extra_head_info(); |
| int get_extra_num(); |
| |
| int get_upgrade_package_file_fd(); |
| |
| partition_head_info_t *get_partition_head_info_by_name(const char *partition_name); |
| int get_total_partition_length(); |
| |
| int get_upgrade_type(); |
| |
| /******************************************************************************* |
| * Inline function implementations * |
| ******************************************************************************/ |
| |
| |
| |
| |
| #endif // _UPI_UPGRADE_PACKAGE_H |
| |