lightduer_ota_package_info.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. /**
  2. * Copyright (2017) Baidu Inc. All rights reserved.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. /*
  17. * File: lightduer_ota_package_info.h
  18. * Auth: Zhong Shuai (zhongshuai@baidu.com)
  19. * Desc: OTA Package Information Head File
  20. */
  21. #include <stddef.h>
  22. #include <stdint.h>
  23. #include <stdbool.h>
  24. #ifndef BAIDU_DUER_LIGHTDUER_INCLUDE_LIGHTDUER_OTA_PACKAGE_INFO_H
  25. #define BAIDU_DUER_LIGHTDUER_INCLUDE_LIGHTDUER_OTA_PACKAGE_INFO_H
  26. #define KEY_LEN (128)
  27. #define PACKAGE_NAME_LENGTH (15)
  28. #define META_VERSION_LENGTH (3)
  29. #define PACKAGE_VERSION_LENGTH (15)
  30. #define INSTALL_PATH_LENGTH (255)
  31. #define MODULE_NAME_LENGTH (15)
  32. #define MODULE_VERSION_LENGTH (15)
  33. #define MODULE_SIGNATURE_LENGTH (33)
  34. #ifdef __cplusplus
  35. extern "C" {
  36. #endif
  37. typedef enum _duer_ota_package_type_s {
  38. PACKAGE_TYPE_OS, // Operation system
  39. PACKAGE_TYPE_APP, // Application
  40. PACKAGE_TYPE_FIRMWARE, // Chip firmware
  41. PACKAGE_TYPE_MIXED, // MIXED
  42. } duer_ota_package_type_t;
  43. typedef enum _duer_ota_module_type_s {
  44. MODULE_TYPE_BIN,
  45. MODULE_TYPE_IMG,
  46. MODULE_TYPE_JSON,
  47. MODULE_TYPE_SO,
  48. } duer_ota_module_type_t;
  49. // package header
  50. typedef struct _duer_ota_package_header_s {
  51. // 'mbed' verify tag
  52. uint8_t tag[4];
  53. // package header size
  54. uint32_t package_header_size;
  55. // package signature size: 1024 bits
  56. uint32_t package_signature_size;
  57. // package signature: include meta.json and all modules
  58. unsigned char package_signature[KEY_LEN];
  59. // meta.json signature size: 1024 bits
  60. uint32_t meta_signature_size;
  61. // meta.json signature
  62. unsigned char meta_signature[KEY_LEN];
  63. // meta.json size: used for decompress meta.json from package body
  64. uint32_t meta_size;
  65. // size of meta.json + all modules (before compress)
  66. uint32_t ori_package_size;
  67. } duer_ota_package_header_t;
  68. typedef struct _duer_ota_package_basic_info_s {
  69. uint8_t package_name[PACKAGE_NAME_LENGTH + 1];
  70. uint8_t meta_version[META_VERSION_LENGTH + 1];
  71. duer_ota_package_type_t package_type;
  72. // Enforce the update
  73. bool update;
  74. } duer_ota_package_basic_info_t;
  75. typedef struct _duer_ota_module_info_s {
  76. uint8_t module_name[MODULE_NAME_LENGTH + 1];
  77. uint32_t module_size;
  78. duer_ota_module_type_t module_type;
  79. // Enforce the update
  80. bool update;
  81. uint8_t module_signature[MODULE_SIGNATURE_LENGTH + 1];
  82. uint8_t module_version[MODULE_VERSION_LENGTH + 1];
  83. uint8_t module_support_hardware_version[MODULE_VERSION_LENGTH + 1];
  84. uint8_t module_install_path[INSTALL_PATH_LENGTH + 1];
  85. } duer_ota_module_info_t;
  86. typedef struct _duer_ota_package_install_info_s {
  87. uint8_t package_install_path[INSTALL_PATH_LENGTH + 1];
  88. uint8_t module_count;
  89. duer_ota_module_info_t *module_list;
  90. } duer_ota_package_install_info_t;
  91. typedef struct _duer_ota_update_info_s {
  92. uint8_t package_version[PACKAGE_VERSION_LENGTH + 1];
  93. } duer_ota_update_info_t;
  94. #ifdef __cplusplus
  95. }
  96. #endif
  97. #endif // BAIDU_DUER_LIGHTDUER_INCLUDE_LIGHTDUER_OTA_PACKAGE_INFO_H