| | |
| | | #include "HIDO_TypeDef.h" |
| | | #include "mk_trace.h" |
| | | //#include "stm32f4xx_hal.h" |
| | | |
| | | #include "mk_wdt.h" |
| | | |
| | | pFunction Jump_To_Application; |
| | | uint32_t JumpAddress; |
| | |
| | | |
| | | return 0; |
| | | } |
| | | |
| | | extern volatile unsigned long time_100ms; |
| | | extern volatile unsigned long start_timer; |
| | | uint8_t FileName[FILE_NAME_LENGTH]; |
| | | |
| | | uint8_t gongkaflag,shouhuanflag; |
| | | extern int32_t Receive_Byte (uint8_t *c, uint32_t timeout); |
| | | /** |
| | | * @brief Download a file via serial port |
| | | * @param None |
| | |
| | | */ |
| | | unsigned char SerialDownload(void) |
| | | { |
| | | uint8_t Number[10] = {0}; |
| | | int32_t Size = 0; |
| | | Send_Byte(0x33); |
| | | uint8_t Number[10] = {0}; |
| | | int32_t Size = 0; |
| | | uint8_t c; |
| | | // wdt_ping(WDT_ID0);//喂狗 |
| | | // uart1_xuanze(0); |
| | | Send_Byte(0x33); |
| | | // start_timer=time_100ms; |
| | | // while(time_100ms<start_timer+5) |
| | | // { |
| | | // if (Receive_Byte(&c, 0x100000) == 0)//返回0成功收取数据,-1为没收到数据 |
| | | // { |
| | | // gongkaflag=1; |
| | | // break; |
| | | // } |
| | | // } |
| | | // if(gongkaflag==0) |
| | | // { |
| | | // wdt_ping(WDT_ID0);//喂狗 |
| | | // uart1_xuanze(1); |
| | | // Send_Byte(0x33); |
| | | // start_timer=time_100ms; |
| | | // while(time_100ms<start_timer+5) |
| | | // { |
| | | // if (Receive_Byte(&c, 0x100000) == 0)//返回0成功收取数据,-1为没收到数据 |
| | | // { |
| | | // shouhuanflag=1; |
| | | // break; |
| | | // } |
| | | // } |
| | | // } |
| | | // NVIC_SystemReset(); |
| | | Size = Ymodem_Receive(&tab_1024[0]);//开始接收文件,成功会返回文件的大小 |
| | | if (Size > 0) //返回成功 |
| | | { |
| | |
| | | flash_write_nbytes(FLASH_ID0,APP_CONFIG_IAPFLAG_MAP,(uint8_t*)&tmp,2); |
| | | // SPIFlash_Erase(SPI_FLASH_ID_0, APP_CONFIG_IAPFLAG_MAP,2, SPI_FLASH_SECTOR_ERASE_MODE_4K); MK8000修改 |
| | | // SPIFlash_Write(SPI_FLASH_ID_0, APP_CONFIG_IAPFLAG_MAP, (HIDO_UINT8*)&tmp, sizeof(tmp)); |
| | | |
| | | delay_ms(100); |
| | | //LOG_INFO(TRACE_MODULE_APP,"升级失败重启\r\n\n"); |
| | | NVIC_SystemReset(); |
| | | // if (((*(__IO uint32_t*)APP_CONFIG_APPLICATION_ADDRESS) & 0x2FFE0000 ) == 0x20000000)先注释掉即一成功就跳转 |
| | | // { |
| | | /* Jump to user application */ |
| | | //Serial0PutString("跳转APP\r\n"); |
| | | memcpy((void *)SRAM_BASE, (void *)APP_CONFIG_APPLICATION_ADDRESS, APP_CONFIG_APPLICATION_SIZE); |
| | | // setup new msp |
| | | __set_MSP(*(uint32_t *)SRAM_BASE); |
| | | //Serial0PutString("跳转APP后\r\n"); |
| | | typedef void (*p_entry_t)(void); |
| | | ((p_entry_t) (*(uint32_t *)(SRAM_BASE + 4) + SRAM_BASE))(); |
| | | // memcpy((void *)SRAM_BASE, (void *)APP_CONFIG_APPLICATION_ADDRESS, APP_CONFIG_APPLICATION_SIZE); |
| | | // // setup new msp |
| | | // __set_MSP(*(uint32_t *)SRAM_BASE); |
| | | // //Serial0PutString("跳转APP后\r\n"); |
| | | // typedef void (*p_entry_t)(void); |
| | | // ((p_entry_t) (*(uint32_t *)(SRAM_BASE + 4) + SRAM_BASE))(); |
| | | |
| | | //JumpAddress = *(__IO uint32_t*) (SRAM_BASE + 4); |
| | | |