rt_fota.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /*
  2. * File : rt_fota.h
  3. * COPYRIGHT (C) 2012-2018, Shanghai Real-Thread Technology Co., Ltd
  4. *
  5. * Change Logs:
  6. * Date Author Notes
  7. * 2019-09-22 warfalcon the first version
  8. */
  9. #ifndef _RT_FOTA_H_
  10. #define _RT_FOTA_H_
  11. #ifdef __CC_ARM /* ARM Compiler */
  12. #define RT_FOTA_WEAK __weak
  13. #elif defined (__IAR_SYSTEMS_ICC__) /* for IAR Compiler */
  14. #define RT_FOTA_WEAK __weak
  15. #elif defined (__GNUC__) /* GNU GCC Compiler */
  16. #define RT_FOTA_WEAK __attribute__((weak))
  17. #endif /* __CC_ARM */
  18. /**
  19. * FOTA firmware encryption algorithm and compression algorithm
  20. */
  21. enum rt_fota_algo
  22. {
  23. RT_FOTA_CRYPT_ALGO_NONE = 0x0L, /**< no encryption algorithm and no compression algorithm */
  24. RT_FOTA_CRYPT_ALGO_XOR = 0x1L, /**< XOR encryption */
  25. RT_FOTA_CRYPT_ALGO_AES256 = 0x2L, /**< AES256 encryption */
  26. RT_FOTA_CMPRS_ALGO_GZIP = 0x1L << 8, /**< Gzip: zh.wikipedia.org/wiki/Gzip */
  27. RT_FOTA_CMPRS_ALGO_QUICKLZ = 0x2L << 8, /**< QuickLZ: www.quicklz.com */
  28. RT_FOTA_CMPRS_ALGO_FASTLZ = 0x3L << 8, /**< FastLZ: fastlz.org/ */
  29. RT_FOTA_CRYPT_STAT_MASK = 0xFL,
  30. RT_FOTA_CMPRS_STAT_MASK = 0xFL << 8,
  31. };
  32. typedef enum rt_fota_algo rt_fota_algo_t;
  33. /* FOTA error code */
  34. typedef enum {
  35. RT_FOTA_NO_ERR = 0,
  36. RT_FOTA_GENERAL_ERR = -1, /* general error */
  37. RT_FOTA_CHECK_FAILED = -2, /* check failed */
  38. RT_FOTA_ALGO_NOT_SUPPORTED = -3, /* firmware algorithm not supported */
  39. RT_FOTA_COPY_FAILED = -4, /* copy firmware to destination partition failed */
  40. RT_FOTA_FW_VERIFY_FAILED = -5, /* firmware verify failed */
  41. RT_FOTA_NO_MEM_ERR = -6, /* no memory */
  42. RT_FOTA_PART_READ_ERR = -7, /* partition read error */
  43. RT_FOTA_PART_WRITE_ERR = -8, /* partition write error */
  44. RT_FOTA_PART_ERASE_ERR = -9, /* partition erase error */
  45. } rt_fota_err_t;
  46. #endif /* _RT_FOTA_H_ */
  47. int rt_fota_start_application(void);