rt_fota.h 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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);
  48. /* v1.3.0 升级回滚接口(main.c 的 uart4 屏幕命令 backupapp / dbg_restore / resetapp 亦使用) */
  49. int rt_fota_backup_app_to_df(void);
  50. int rt_fota_restore_app_from_df(int consume_backup);
  51. /* 喂 IWDG(仅在其已被 syswatch 启动时生效):供长耗时 flash 擦/写循环调用 */
  52. void rt_fota_wdt_feed(void);
  53. /* v1.3.5:NOR 可用性快速检查(读 JEDEC ID)。返回 0 表示器件无响应,
  54. * 调用方应跳过 EasyFlash 初始化,避免其对 768 个扇区逐一无效格式化。 */
  55. int rt_fota_nor_ready(void);