forked from gary/BCU
2
0
Fork 0
BCU/library/bsp/bsp_boot.h

103 lines
2.3 KiB
C

#ifndef BSP_BOOT_H_
#define BSP_BOOT_H_
#ifdef __cplusplus
extern "C" {
#endif
#include "kit_macro.h"
#include "drv_flash.h"
typedef enum
{
kBootStep_None,
kBootStep_WaitErase,
kBootStep_RvdData,
kBootStep_UpdateEnd,
}BootStep;
typedef enum
{
kBootJumpMode_Immediately = 0,
kBootJumpMode_ReBoot,
kBootJumpMode_End,
}BootJumpMode;
typedef enum
{
kBootLoadMode_Serial = 0,
kBootLoadMode_Parallel,
kBootLoadMode_End,
}BootLoadMode;
typedef enum
{
kBootCmd_None = 0,
kBootCmd_Reboot,
kBootCmd_Erase,
kBootCmd_SndFrame,
kBootCmd_UpdateEnd,
kBootCmd_Quit,
kBootCmd_ForceBoot,
kBootCmd_HeartBeat,
kBootCmd_UpdateRes,
kBootCmd_BmuReboot, //批量进入Boot
kBootCmd_Token,
kBootCmd_End,
}BootCmd;
struct _BootItem;
typedef void(*BootAnswerCall) (struct _BootItem *item, BootCmd cmd, kit_ret_e res);
typedef struct _BootItem
{
BootCmd cmd;
BootStep step;
bool is_token;
uint16_t pack_idx;
uint16_t buf_len;
uint32_t firmware_len;
uint32_t update_time;
uint32_t rcv_firmware_len;
uint8_t *buf_addr;//注意字节对齐
void * comm_item;
BootAnswerCall ans_call;
flash_Item_t *flash_item;
uint32_t back_up_addr;
uint32_t app_start_addr;
uint16_t product_num;
uint16_t product_num_offset; //产品编号相对于起始地址偏移量
}BootItem;
#define BOOT_STATIC_INIT(_name, _comm_item, _ans_call, _flash_item, _back_up_addr, _app_start_addr, _product_num, _product_num_offset) \
BootItem _name = \
{ \
kBootCmd_None, \
kBootStep_None, \
false, \
0, \
0, \
0, \
0, \
0, \
NULL, \
((void *)_comm_item), \
_ans_call, \
_flash_item, \
_back_up_addr, \
_app_start_addr, \
_product_num, \
_product_num_offset, \
}
void bsp_boot_poll(BootItem *item);
void bsp_boot_set_cmd(BootItem *item, BootCmd cmd, uint8_t* buf, uint16_t len);
bool bsp_boot_move_firmware(BootItem *item, uint32_t start_addr, uint32_t max_len);
uint16_t bsp_boot_get_pack_idx(BootItem *item);
uint32_t bsp_boot_get_update_time(BootItem *item);
#ifdef __cplusplus
}
#endif
#endif