ex

Fork of mbed-os-example-mbed5-blinky by mbed-os-examples

Committer:
TMBOY
Date:
Tue Jul 18 16:54:45 2017 +0800
Revision:
47:9e361da97763
?

Who changed what in which revision?

UserRevisionLine numberNew contents of line
TMBOY 47:9e361da97763 1
TMBOY 47:9e361da97763 2 #ifndef _MBED_OTA_PACK_INCLUDE_
TMBOY 47:9e361da97763 3 #define _MBED_OTA_PACK_INCLUDE_
TMBOY 47:9e361da97763 4 #include <stdint.h>
TMBOY 47:9e361da97763 5
TMBOY 47:9e361da97763 6 #define KEY_LEN 128
TMBOY 47:9e361da97763 7
TMBOY 47:9e361da97763 8 #define _DEBUG_
TMBOY 47:9e361da97763 9 //#define _DEBUG_OUT_
TMBOY 47:9e361da97763 10
TMBOY 47:9e361da97763 11 #ifndef _DEBUG_OUT_
TMBOY 47:9e361da97763 12 #define MBEDPACK_DEBUG_PRINT bca_printf
TMBOY 47:9e361da97763 13 #else
TMBOY 47:9e361da97763 14 #define MBEDPACK_DEBUG_PRINT printf
TMBOY 47:9e361da97763 15 #endif
TMBOY 47:9e361da97763 16
TMBOY 47:9e361da97763 17 ///
TMBOY 47:9e361da97763 18 /// package header
TMBOY 47:9e361da97763 19 typedef struct _package_header {
TMBOY 47:9e361da97763 20
TMBOY 47:9e361da97763 21 ///
TMBOY 47:9e361da97763 22 /// 'mbed' verify tag
TMBOY 47:9e361da97763 23 unsigned char tag[4];
TMBOY 47:9e361da97763 24
TMBOY 47:9e361da97763 25 ///
TMBOY 47:9e361da97763 26 /// package header size
TMBOY 47:9e361da97763 27 uint32_t header_size;
TMBOY 47:9e361da97763 28
TMBOY 47:9e361da97763 29 ///
TMBOY 47:9e361da97763 30 /// package signature size : 1024 bits
TMBOY 47:9e361da97763 31 uint32_t package_sig_size;
TMBOY 47:9e361da97763 32 ///
TMBOY 47:9e361da97763 33 /// package signature : include meta.json and all modules
TMBOY 47:9e361da97763 34 unsigned char package_sig[KEY_LEN];
TMBOY 47:9e361da97763 35
TMBOY 47:9e361da97763 36 ///
TMBOY 47:9e361da97763 37 /// meta.json signature size : 1024 bits
TMBOY 47:9e361da97763 38 uint32_t meta_sig_size;
TMBOY 47:9e361da97763 39 ///
TMBOY 47:9e361da97763 40 /// meta.json signature
TMBOY 47:9e361da97763 41 unsigned char meta_sig[KEY_LEN];
TMBOY 47:9e361da97763 42
TMBOY 47:9e361da97763 43 ///
TMBOY 47:9e361da97763 44 /// meta.json size : used for decompress meta.json from package body
TMBOY 47:9e361da97763 45 uint32_t meta_size;
TMBOY 47:9e361da97763 46
TMBOY 47:9e361da97763 47 ///
TMBOY 47:9e361da97763 48 /// package size before decompress
TMBOY 47:9e361da97763 49 uint32_t ori_package_size;
TMBOY 47:9e361da97763 50
TMBOY 47:9e361da97763 51 } package_header_t;
TMBOY 47:9e361da97763 52
TMBOY 47:9e361da97763 53 ///
TMBOY 47:9e361da97763 54 /// all modules included in mbed package is 'js' and mbed executable '.bin' file
TMBOY 47:9e361da97763 55 typedef enum _module_type {
TMBOY 47:9e361da97763 56 ModuleTypeALL,
TMBOY 47:9e361da97763 57 ModuleTypeJS,
TMBOY 47:9e361da97763 58 ModuleTypeSO,
TMBOY 47:9e361da97763 59 ModuleTypeBIN,
TMBOY 47:9e361da97763 60 ModuleTypeJSON,
TMBOY 47:9e361da97763 61 ModuleTypeIMG
TMBOY 47:9e361da97763 62 } module_type_t;
TMBOY 47:9e361da97763 63
TMBOY 47:9e361da97763 64
TMBOY 47:9e361da97763 65 typedef struct _file_type_pair {
TMBOY 47:9e361da97763 66 char* string;
TMBOY 47:9e361da97763 67 module_type_t type;
TMBOY 47:9e361da97763 68 } file_type;
TMBOY 47:9e361da97763 69
TMBOY 47:9e361da97763 70
TMBOY 47:9e361da97763 71 typedef enum _package_type {
TMBOY 47:9e361da97763 72 PackageTypeApp,
TMBOY 47:9e361da97763 73 PackageTypeOS,
TMBOY 47:9e361da97763 74 PackageTypeProfile,
TMBOY 47:9e361da97763 75 PackageTypeUnknown
TMBOY 47:9e361da97763 76 } package_type_t;
TMBOY 47:9e361da97763 77 /*
TMBOY 47:9e361da97763 78 typedef enum {
TMBOY 47:9e361da97763 79 false = 0,
TMBOY 47:9e361da97763 80 true
TMBOY 47:9e361da97763 81 } bool;*/
TMBOY 47:9e361da97763 82
TMBOY 47:9e361da97763 83 /*
TMBOY 47:9e361da97763 84 ///
TMBOY 47:9e361da97763 85 /// package body modules info excluding meta.json
TMBOY 47:9e361da97763 86 typedef struct _module_info {
TMBOY 47:9e361da97763 87
TMBOY 47:9e361da97763 88 ///
TMBOY 47:9e361da97763 89 /// module name : xx.js / xx.bin
TMBOY 47:9e361da97763 90 unsigned char* name;
TMBOY 47:9e361da97763 91
TMBOY 47:9e361da97763 92 ///
TMBOY 47:9e361da97763 93 /// module type : js / bin
TMBOY 47:9e361da97763 94 module_type_t type;
TMBOY 47:9e361da97763 95
TMBOY 47:9e361da97763 96 uint32_t module_size;
TMBOY 47:9e361da97763 97 uint8_t update;
TMBOY 47:9e361da97763 98 unsigned char* version;
TMBOY 47:9e361da97763 99 unsigned char* hw_version;
TMBOY 47:9e361da97763 100
TMBOY 47:9e361da97763 101 ///
TMBOY 47:9e361da97763 102 /// module data
TMBOY 47:9e361da97763 103 unsigned char* data;
TMBOY 47:9e361da97763 104 } module_info_t;
TMBOY 47:9e361da97763 105
TMBOY 47:9e361da97763 106 ///
TMBOY 47:9e361da97763 107 /// decompress info : used for extract meta data and modules array data
TMBOY 47:9e361da97763 108 typedef struct _decompress_info {
TMBOY 47:9e361da97763 109
TMBOY 47:9e361da97763 110 ///
TMBOY 47:9e361da97763 111 /// decompressed meta data size
TMBOY 47:9e361da97763 112 uint32_t decompress_meta_data_size;
TMBOY 47:9e361da97763 113 ///
TMBOY 47:9e361da97763 114 /// decompressed meta data from package body
TMBOY 47:9e361da97763 115 unsigned char* decompress_meta_data;
TMBOY 47:9e361da97763 116
TMBOY 47:9e361da97763 117 ///
TMBOY 47:9e361da97763 118 /// decompressed modules array data size
TMBOY 47:9e361da97763 119 uint32_t decompress_module_data_size;
TMBOY 47:9e361da97763 120 ///
TMBOY 47:9e361da97763 121 /// decompressed modules array data from package body
TMBOY 47:9e361da97763 122 unsigned char* decompress_module_data;
TMBOY 47:9e361da97763 123 } decompress_info_t;
TMBOY 47:9e361da97763 124 */
TMBOY 47:9e361da97763 125
TMBOY 47:9e361da97763 126
TMBOY 47:9e361da97763 127 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
TMBOY 47:9e361da97763 128 typedef struct _module_info {
TMBOY 47:9e361da97763 129
TMBOY 47:9e361da97763 130 ///
TMBOY 47:9e361da97763 131 /// module name : xx.js / xx.bin
TMBOY 47:9e361da97763 132 unsigned char* name;
TMBOY 47:9e361da97763 133
TMBOY 47:9e361da97763 134 ///
TMBOY 47:9e361da97763 135 /// module type : js / bin
TMBOY 47:9e361da97763 136 module_type_t type;
TMBOY 47:9e361da97763 137
TMBOY 47:9e361da97763 138 uint32_t module_size;
TMBOY 47:9e361da97763 139 uint8_t update;
TMBOY 47:9e361da97763 140 unsigned char* version;
TMBOY 47:9e361da97763 141 unsigned char* hw_version;
TMBOY 47:9e361da97763 142 uint32_t offset; // offset from file begin
TMBOY 47:9e361da97763 143
TMBOY 47:9e361da97763 144 } module_info_t;
TMBOY 47:9e361da97763 145
TMBOY 47:9e361da97763 146 ///
TMBOY 47:9e361da97763 147 /// meta info : used for extract meta data and modules array data
TMBOY 47:9e361da97763 148 typedef struct _meta_info {
TMBOY 47:9e361da97763 149
TMBOY 47:9e361da97763 150 ///
TMBOY 47:9e361da97763 151 /// decompressed meta data size
TMBOY 47:9e361da97763 152 uint32_t meta_data_size;
TMBOY 47:9e361da97763 153
TMBOY 47:9e361da97763 154 ///
TMBOY 47:9e361da97763 155 /// decompressed module data offset
TMBOY 47:9e361da97763 156 uint32_t module_data_offset;
TMBOY 47:9e361da97763 157
TMBOY 47:9e361da97763 158 ///
TMBOY 47:9e361da97763 159 /// decompressed meta data
TMBOY 47:9e361da97763 160 unsigned char* meta_data;
TMBOY 47:9e361da97763 161
TMBOY 47:9e361da97763 162 ///
TMBOY 47:9e361da97763 163 /// json object
TMBOY 47:9e361da97763 164 void* meta_object;
TMBOY 47:9e361da97763 165 } meta_info_t;
TMBOY 47:9e361da97763 166
TMBOY 47:9e361da97763 167 #endif
TMBOY 47:9e361da97763 168
TMBOY 47:9e361da97763 169