123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- #include "gd32f10x.h"
- #include "main.h"
- #include "delay.h"
- #include "fmc.h"
- #include "ota_message.h"
- #include "boot.h"
- #include "w25q32.h"
- void task_fwdgt_reload(void);
- OTA_STRUCT UpDataA; //A区更新用到的结构体
- void my_test(void)
- {
- static OTA_MESSAGE ota_message = {0};
- uint32_t i = 0;
- ota_message.otaflag = 1;
- ota_message.XmodemByte = 200 * 1024;
- //往地址0x08070000写OTA_MESSAGE结构体
- // GD32_WriteFlash(OTA_EVENT_START_ADDR,&ota_message,sizeof(OTA_MESSAGE));
- fmc_state_enum state;
- // state = fmc_word_program((uint32_t)0x08070000,(uint32_t)(1));
- // fmc_flag_clear(FMC_FLAG_BANK0_END | FMC_FLAG_BANK0_WPERR | FMC_FLAG_BANK0_PGERR);
- // state = fmc_word_program((uint32_t)0x08070004,(uint32_t)(100 * 1024));
- // fmc_flag_clear(FMC_FLAG_BANK0_END | FMC_FLAG_BANK0_WPERR | FMC_FLAG_BANK0_PGERR);
- // FLASH_WriteNotErase(0x08070000,&ota_message,sizeof(OTA_MESSAGE)/2);
- // FLASH_ErasePage(0x08069000,1);
- GD32_EraseFlash(210,1);
- FLASH_Write(0x08069000,&ota_message,sizeof(OTA_MESSAGE)/2);
- i = *(uint32_t*)(0x08069000);
- i = *(uint32_t*)(0x08069004);
- // FLASH_Write(0x08069008,&ota_message,sizeof(OTA_MESSAGE)/2);
-
- Delay_Ms(100);
- }
- int main(void)
- {
- Delay_Init();
- W25Q32_Init(); //弃用w25q32改用fmc存储
- OTA_MESSAGE *ota_data;
- task_fwdgt_reload();
- // my_test();
- if(load_ota_message_config_params()==0)
- {
- //ota事件产生了,进入Bootloader分支
- ota_data=get_config_params();
- BootLoader_Brance(ota_data->XmodemByte);
- }
- //没有OTA事件产生跳转A区
- else
- {
- LOAD_A(GD32_A_SADDR);
- }
-
- while(1)
- {
-
-
- }
-
- }
- void task_fwdgt_reload(void)
- {
- /* uncock fwdgt write protect*/
- fwdgt_write_enable();
- /* feed fwdgt */
- fwdgt_counter_reload();
- }
|