|
@@ -99,7 +99,7 @@ void iap_flag_release(void)
|
|
|
{
|
|
|
send_buff[i] = fmc_read_byte(UPGRADE_FLAG_START_ADDR + (UPGRADE_FLAG_DATA_SIZE * 2) + i);
|
|
|
}
|
|
|
- hal_can_msg_tx(0x180000001, CAN_Id_Extended, send_buff, 8);
|
|
|
+ hal_can_msg_tx(0x18000001, CAN_Id_Extended, send_buff, 8);
|
|
|
CAN_ITConfig(CAN1, CAN_IT_TME, ENABLE);
|
|
|
}
|
|
|
}
|
|
@@ -109,10 +109,36 @@ uint8_t erase_app_flash(uint32_t start_address, uint32_t end_addr)
|
|
|
uint8_t status = 0;
|
|
|
uint16_t page_len = 0;
|
|
|
// page_len = (end_addr - start_address) / FMC_PAGE_SIZE;
|
|
|
- status = fmc_erase_pages(start_address, page_len);
|
|
|
+ if ((start_address == ADDR_FLASH_SECTOR_2))
|
|
|
+ {
|
|
|
+ status = fmc_erase_pages(start_address, 5);
|
|
|
+ }
|
|
|
+ else if ((start_address == ADDR_FLASH_SECTOR_8))
|
|
|
+ {
|
|
|
+ status = fmc_erase_pages(start_address, 3);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ status = 1;
|
|
|
+ }
|
|
|
+
|
|
|
return status;
|
|
|
}
|
|
|
|
|
|
+void jump_boot_time_ctrl(void)
|
|
|
+{
|
|
|
+ if (jump_boot_time > 0)
|
|
|
+ {
|
|
|
+ jump_boot_time--;
|
|
|
+ if (jump_boot_time == 0)
|
|
|
+ {
|
|
|
+ // jump_flag = 1;
|
|
|
+ __set_FAULTMASK(1); // 关闭所有中断
|
|
|
+ NVIC_SystemReset(); // 复位
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
void write_app_flash(uint16_t *buf, uint16_t pack_len, uint16_t pack_num)
|
|
|
{
|
|
|
static uint32_t w_start_addr = 0;
|
|
@@ -224,7 +250,7 @@ void iap_rec_handler(pdu_tag rec_msg)
|
|
|
{
|
|
|
// 喂狗
|
|
|
fmc_clear_flag_star();
|
|
|
- erase_flag = erase_app_flash(DOWNLOAD_START_ADDR, DOWNLOAD_MIDDLE_ADDR);
|
|
|
+ erase_flag = erase_app_flash(DOWNLOAD_START_ADDR, DOWNLOAD_END_ADDR);
|
|
|
fmc_clear_flag_end();
|
|
|
// 喂狗
|
|
|
g_iap.count_bytes = 0;
|