1 /** @defgroup ota_hal_api
2  * @{
3  *
4  * This is an include file of OTA HAL interface.
5  *
6  * Copyright (C) 2015-2021 Alibaba Group Holding Limited
7  */
8 #ifndef OTA_HAL_H
9 #define OTA_HAL_H
10 #include "ota_agent.h"
11 
12 #ifdef __cplusplus
13 extern "C" {
14 #endif
15 
16 /**
17  * ota_hal_init   ota hal init main OTA partition.
18  *
19  * @param[in] ota_boot_param_t *param ota parameter
20  *
21  * @return OTA_SUCCESS              OTA success.
22  * @return OTA_UPGRADE_WRITE_FAIL   OTA upgrade write fail.
23  * @return OTA_UPGRADE_PARAM_FAIL   OTA upgrade parameter fail.
24  * @return OTA_UPGRADE_FW_SIZE_FAIL OTA upgrade FW too big.
25  * @return OTA_UPGRADE_SET_BOOT_FAIL OTA upgrade set boot fail.
26  */
27 int ota_hal_init(ota_boot_param_t *param);
28 
29 /**
30  * ota_hal_read   ota hal read main OTA partition.
31  *
32  * @param[in] unsigned int *off      read offset.
33  * @param[in] char *buf              read buffer.
34  * @param[in] unsigned int len       read buffer len.
35  *
36  * @return OTA_SUCCESS              OTA success.
37  * @return OTA_UPGRADE_WRITE_FAIL   OTA upgrade write fail.
38  * @return OTA_UPGRADE_PARAM_FAIL   OTA upgrade parameter fail.
39  * @return OTA_UPGRADE_FW_SIZE_FAIL OTA upgrade FW too big.
40  * @return OTA_UPGRADE_SET_BOOT_FAIL OTA upgrade set boot fail.
41  */
42 int ota_hal_read(unsigned int *off, char *buf, unsigned int len);
43 
44 /**
45  * ota_hal_write   ota hal write main OTA partition.
46  *
47  * @param[in] unsigned int *off      write offset.
48  * @param[in] char *buf              write buf.
49  * @param[in] unsigned int len       write buf len.
50  *
51  * @return OTA_SUCCESS              OTA success.
52  * @return OTA_UPGRADE_WRITE_FAIL   OTA upgrade write fail.
53  * @return OTA_UPGRADE_PARAM_FAIL   OTA upgrade parameter fail.
54  * @return OTA_UPGRADE_FW_SIZE_FAIL OTA upgrade FW too big.
55  * @return OTA_UPGRADE_SET_BOOT_FAIL OTA upgrade set boot fail.
56  */
57 int ota_hal_write(unsigned int *off, char *buf, unsigned int len);
58 
59 /**
60  * ota_hal_boot  ota hal boot.
61  *
62  * @param[in] ota_boot_param_t *param ota parameter
63  *
64  * @return OTA_SUCCESS              OTA success.
65  * @return OTA_UPGRADE_WRITE_FAIL   OTA upgrade write fail.
66  * @return OTA_UPGRADE_PARAM_FAIL   OTA upgrade parameter fail.
67  * @return OTA_UPGRADE_FW_SIZE_FAIL OTA upgrade FW too big.
68  * @return OTA_UPGRADE_SET_BOOT_FAIL OTA upgrade set boot fail.
69  */
70 int ota_hal_boot(ota_boot_param_t *parm);
71 
72 /**
73  * ota_hal_reboot_bank  ota hal reboot banker
74  *
75  * @param[in] void
76  *
77  * @return OTA_SUCCESS              OTA success.
78  * @return OTA_UPGRADE_WRITE_FAIL   OTA upgrade write fail.
79  * @return OTA_UPGRADE_PARAM_FAIL   OTA upgrade parameter fail.
80  * @return OTA_UPGRADE_FW_SIZE_FAIL OTA upgrade FW too big.
81  * @return OTA_UPGRADE_SET_BOOT_FAIL OTA upgrade set boot fail.
82  */
83 int ota_hal_reboot_bank(void);
84 
85 /**
86  * ota_hal_rollback ota hal rollback.
87  *
88  * @return OTA_SUCCESS              OTA success.
89  * @return OTA_UPGRADE_WRITE_FAIL   OTA upgrade write fail.
90  * @return OTA_UPGRADE_PARAM_FAIL   OTA upgrade parameter fail.
91  * @return OTA_UPGRADE_FW_SIZE_FAIL OTA upgrade FW too big.
92  * @return OTA_UPGRADE_SET_BOOT_FAIL OTA upgrade set boot fail.
93  */
94 int ota_hal_rollback(void);
95 
96 /**
97  * @}
98  */
99 #ifdef __cplusplus
100 }
101 #endif
102 #endif  /* OTA_HAL_H */
103