1 /*
2  * Copyright (C) 2015-2018 Alibaba Group Holding Limited
3  */
4 
5 #ifndef __GENIE_SAL_OTA_H__
6 #define __GENIE_SAL_OTA_H__
7 #include <stdbool.h>
8 
9 #ifndef CONFIG_AIS_TOTAL_FRAME
10 #define CONFIG_AIS_TOTAL_FRAME 16
11 #endif
12 
13 /**
14  * @brief reboot the device.
15  */
16 void hal_reboot(void);
17 
18 /**
19  * @brief finish ota and reboot the device.
20  */
21 void dfu_reboot(void);
22 
23 /**
24  * @brief check the dfu image.
25  * @param[in] the image type.
26  * @param[out] the crc of image.
27  * @return the result of checksum.
28  */
29 unsigned char dfu_check_checksum(short image_id, unsigned short *crc16_output);
30 
31 /**
32  * @brief write dfu data.
33  * @param[in] the image type.
34  * @param[in] the offset of flash.
35  * @param[in] the length of data.
36  * @param[in] the writting data.
37  * @return the current runing partition.
38  */
39 int ali_dfu_image_update(short signature, int offset, int length, int *p_void);
40 
41 uint32_t ali_dfu_get_ota_partition_max_size(void);
42 
43 #ifdef CONFIG_GENIE_OTA_PINGPONG
44 /**
45  * @brief get the current runing partition.
46  * @return the current runing partition.
47  */
48 uint8_t genie_sal_ota_get_program_image(void);
49 
50 /**
51  * @brief switch the running partition, without reboot.
52  * @param[in] the partition which switch to.
53  * @return the runing partition when next boot.
54  */
55 uint8_t genie_sal_ota_change_image_id(uint8_t target_id);
56 #endif
57 
58 int erase_dfu_flash(void);
59 
60 /*This api mainly for light product,if light is on we shouldn't reboot by ota*/
61 bool genie_sal_ota_is_allow_reboot(void);
62 
63 #endif
64