Key points of using STM32 IAP (online update program)

Publisher:快乐舞动Latest update time:2016-12-27 Source: eefocusKeywords:STM32 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

The so-called IAP is actually equivalent to a small bootloader used to update the program.

Many products are basically programmed once on the production line, but BUGs are sometimes unavoidable. There are often painful experiences where the product has to be removed from the shell and the board and put back on the programming rack for programming after it is installed. Therefore, IAP is very necessary in this case. As long as there is an external interface, it can be updated online. The commonly used one is the USB port. Of course, if you must use the serial port, it is also possible, but the hardware is a little more troublesome. The following is the routine program


  1. typedef void (*pFunction)(void);  

  2. pFunction Jump_To_Application;  

  3. unsigned long JumpAddress;  

  4.   

  5. if(!Check_Whether_Enter_UpdateMode()) //This function is custom and determines whether to enter the bootloader or the APP application by judging the key  

  6. {  

  7.     if (((*(__IO uint32_t*)FLASH_START_ADDR_NORMAL_FIRMWARE) & 0x2FFE0000 ) == 0x20000000) // Check the top of the stack pointer  

  8.     {   

  9.         /* Jump to user application */  

  10.         JumpAddress = *(__IO uint32_t*) (FLASH_START_ADDR_NORMAL_FIRMWARE + 4); //Get the RESET address of APP   

  11.         Jump_To_Application = (pFunction) JumpAddress; // pass the address to the function pointer  

  12.         /* Initialize user application's Stack Pointer */  

  13.         __set_MSP(*(__IO uint32_t*) FLASH_START_ADDR_NORMAL_FIRMWARE); //Set the top of the stack pointer  

  14.         Jump_To_Application(); // Jump into APP  

  15.     }  

  16. }  


  1. FLASH_START_ADDR_NORMAL_FIRMWARE is the starting address of the APP  

  2. This is the basic idea of ​​IAP. If you don't enter the APP, enter IAP to update the code. Add USB processing in IAP. At this point, the IAP program is basically completed (but the related processing of USB protocol is still a bit troublesome and difficult,  

  3. You have to understand it before you can start, otherwise it’s easy to get confused. I often get confused myself...)  

  4. In fact, many people have written similar blogs about IAP. The reason why I write it here is that there is something that is easy to overlook. I encountered it myself. Maybe I am careless and others have reminded me but I didn’t notice it, or maybe it’s because of the article I read.  

  5. Not enough, I'm being long-winded again... Oh, let's get to the point  

  6. The APP address of the above example is set to 0x08003000; the program base address of the APP project should also be set to 0x08003000 and the FLASH SIZE should also be subtracted by 0x3000 accordingly.  


There is one more thing to note here. We all know that in general, after STM32 is reset, it starts fetching instructions from 0x08000000, and the interrupt vector starts from 0x08000004. The first one is the RESET vector. The interrupt vector of the APP project cannot be like this. The vector address of the APP should start from 0x08003000. This is easy to be overlooked, but it may be my own stupid problem. Maybe most people understand it, but I am still in the dark. As shown in the following figure


    Keywords:STM32 Reference address:Key points of using STM32 IAP (online update program)

    Previous article:STM32 interrupt usage
    Next article:The relationship between multiplexing and re-imaging of STM32 pins

    Latest Microcontroller Articles
    • Download from the Internet--ARM Getting Started Notes
      A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
    • Learn ARM development(22)
      Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
    • Learn ARM development(21)
      First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
    • Learn ARM development(20)
      With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
    • Learn ARM development(19)
      After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
    • Learn ARM development(14)
    • Learn ARM development(15)
    • Learn ARM development(16)
    • Learn ARM development(17)
    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号