1 /* 2 * Copyright (C) 2015-2017 Alibaba Group Holding Limited 3 */ 4 #ifndef SECOND_BOOT_HAL_H 5 #define SECOND_BOOT_HAL_H 6 #include "aos/hal/flash.h" 7 #include "updater.h" 8 9 #define SECTOR_SIZE 0x1000 /* flash sector size */ 10 11 #ifndef OTA_2NDBOOT_WDG_TIMEOUT 12 #define OTA_2NDBOOT_WDG_TIMEOUT 120 13 #endif 14 15 #define ROUND_DOWN(a,b) (((a) / (b)) * (b)) 16 #define FLASH_ALIGN_MASK ~(sizeof(unsigned int) - 1) 17 #define FLASH_ALIGN sizeof(unsigned int) 18 19 /* system APIs */ 20 void sys_reboot(void); 21 void sys_delayms(volatile int ms); 22 #ifdef AOS_2ND_BOOT_NO_LDS 23 void *sys_set_heap(unsigned int *size); 24 #endif 25 26 /* uart APIs */ 27 void uart_init(void); 28 void uart_send(unsigned char *buf, int len); 29 void uart_send_string(char *buf); 30 unsigned char uart_recv_byte(unsigned char *c); 31 void uart_send_byte(unsigned char buf); 32 33 /* flash APIs */ 34 int flash_erase(unsigned int offset, unsigned int len); 35 int flash_read_data(unsigned int offset, unsigned char *buf, unsigned int len); 36 int flash_write_data(unsigned int offset, unsigned char *buf, unsigned int len); 37 hal_logic_partition_t *flash_get_info(hal_partition_t no); 38 39 /* watchdog APIs */ 40 void wdg_init(unsigned int ms); 41 void wdg_feed(void); 42 void wdg_finish(void); 43 44 #ifdef AOS_2ND_BOOT_AB 45 /* 0: A, 1: B*/ 46 int ota_2ndboot_ab_get(void); 47 void ota_2ndboot_ab_switch(void); 48 #endif 49 50 #endif /*SECOND_BOOT_HAL_H */ 51