USB IAP program upgrade steps based on STM32

Publisher:Howard_SunLatest update time:2018-09-20 Source: eefocusKeywords:stm32  usb  iap Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

USB automatic update program IAP (in application programming) DFU (development firemeware upgrade). The entire chip has 512k on-chip flash, and the user program is downloaded and run in it. The flash address is 0x8000000, and the size is 0x80000. The USB automatic update program first downloads 0x8000000-0x80002FFF, with a total size of 12K. The user program is downloaded to 0x80003000, with a size of 0x7D000 (500K). The USB automatic update code is as follows. If the button is pressed, it enters DFU mode, otherwise it starts the user code.

In addition to the void NVIC_Configuration(void)

{

  /* Set the Vector Table base location at 0x3000 */ 

  NVIC_SetVectorTable(NVIC_VectTab_FLASH, 0x3000);

}

Modify it inside, and also modify the compiled address to 0x80003000, the size to 0x7d000,

The compiled address of the iap program is 0x80000000, the end is 0x80002fff, and the size is 0x3000. In this way, the user program and the USB iap program are burned separately and started. The PC host needs to install ST's dfuse_demo_v3.0, which will contain the dfu driver. After plugging in the USB, manually install the driver C:\Program Files\STMicroelectronics\Software\DfuSe\Driver\x86\ file. Run DFU filemanager to convert the compiled .hex file into .dfu, and then run DFUse demonstration upgrade to generate the .dfu file.


int main(void)  

{  

  DFU_Button_Config(); //Configure the button identification of the USB automatic upgrade program  

  

  /* Check if the Key push-button on STM3210x-EVAL Board is pressed */  

  if (DFU_Button_Read() != 0x00)  

  { /* Test if user code is programmed starting from address 0x8003000 */  

    if (((*(__IO uint32_t*)ApplicationAddress) & 0x2FFE0000 ) == 0x20000000)  

    { /* Jump to user application */  

  

      JumpAddress = *(__IO uint32_t*) (ApplicationAddress + 4);  

      Jump_To_Application = (pFunction) JumpAddress;  

      /* Initialize user application's Stack Pointer */  

      __set_MSP(*(__IO uint32_t*) ApplicationAddress);  

      Jump_To_Application();  

    }  

  } /* Otherwise enters DFU mode to allow user to program his application */  

  

  /* Enter DFU mode */  

  DeviceState = STATE_dfuERROR;  

  DeviceStatus[0] = STATUS_ERRFIRMWARE;  

  DeviceStatus[4] = DeviceState;  

  

  Set_System();  

  Set_USBClock();  

  USB_Init();  

  

  /* Main loop */  

  while (1)  

  {  

  }  

}  


Keywords:stm32  usb  iap Reference address:USB IAP program upgrade steps based on STM32

Previous article:The difference between RO segment, RW segment and ZI segment in ARM
Next article:The concept of priority in STM32 (Cortex-M3)

Latest Microcontroller Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号