STM32 IAP upgrade based on Xmodem [Transfer]

Publisher:温柔之风Latest update time:2017-09-25 Source: eefocusKeywords:Xmodem Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

Experimental platform: Windows 7 + STM32F103ZET6
Experimental purpose: You don't need any burning tools to remotely upgrade the code of your product!
1. Introduction to Xmodem protocol
2. IAP programming principle
3. Boot and App programming
4. Experimental steps
5. Remote upgrade application

1. Modem protocol

The main file transfer protocols for serial communication are: Xmodem, Ymodem, Zmodem and KERMIT.

Xmodem protocol transmission is completed by the receiving program and the sending program. The receiving program first sends a negotiation character to negotiate the verification method. After the negotiation is passed, the sending program starts to send data packets. After the receiving program receives a complete data packet, it verifies the data packet according to the negotiated method. After the verification is passed, a confirmation character is sent, and then the sending program continues to send the next packet; if the verification fails, a denial character is sent, and the sending program retransmits the data packet.
The Xmodem protocol was proposed and implemented by Ward Chritensen in the 1970s. The unit of transmitted data is information packets.
The Xmodem protocol generally supports 128-byte data packets, and supports two verification methods: checksum and CRC.

2. IAP programming principles

There are currently two ways to implement online programming: In-System Programming (ISP) and In-Application Programming (IAP). ISP generally programs the entire internal Flash memory through the microcontroller's dedicated serial port, while IAP technology structurally divides the Flash memory into two parts. When running a user program on one memory bank, the other memory bank can be reprogrammed, and then the control is transferred from one memory bank to another. The implementation of IAP is more flexible: usually the serial port, network port, USB and other interfaces of the microcontroller can be used for online programming, thereby realizing remote code upgrades. 

Some users hope that the product can automatically update the program content through some remote communication method during actual application. Obviously, ISP can no longer meet such needs. The newly emerged IAP burning method provides an effective means for self-update of the program. The Flash memory inside the microcontroller stores the user's program code, which cannot be modified during normal operation. However, with IAP, the user program can modify part or even all of the program code as needed (if certain conditions are met). The new program code may be automatically generated during the program operation, or it may come from a remote device.


The Boot code must be burned in through other means, such as JTAG or ISP; the APP code can be burned in using the IAP function of the Boot code, and the IAP function can be used to easily update the code in the future. 

These two parts of code are stored in different address ranges of FLASH. Generally, the Bootloader is stored in the lowest address area, followed by the APP program (note that if the FLASH capacity is sufficient, many APP programs can be designed).

Interrupt vector table offset setting: (in misc.c)
void NVIC_SetVectorTable(uint32_t NVIC_VectTab, uint32_t Offset)
#ifdef VECT_TAB_SRAM
SCB->VTOR = SRAM_BASE | VECT_TAB_OFFSET;
#else
SCB->VTOR = FLASH_BASE | VECT_TAB_OFFSET;
#endif
Design VECT_TAB_OFFSET=0x4000 Reserve 16KB of Flash space for the Boot program.

3. Experimental steps:
Experimental verification through the STM3210e development board:
The Boot program implements the following functions:

1. Implement in-application programming (IAP) through the serial port.
1396610179_2d1962ca.jpg 

2. Download the hex file (CRC or SUM) to the specified Flash storage area.
1396610194_a743d80d.png 
3. Erase any specified sector (8~127).
1396610158_276b1442.png 

Keywords:Xmodem Reference address:STM32 IAP upgrade based on Xmodem [Transfer]

Previous article:STM32 low power mode practice
Next article:STM32 USB HID device driver analysis

Recommended ReadingLatest update time:2024-11-17 01:59

STM32 SPI mode
SPI protocol (Serial Peripheral Interface), also known as serial peripheral interface, is a high-speed full-duplex Communication bus, it was proposed by Motorola, and the latest version is V04.01-2004. There are four SPI modes according to the different configurations of SPI clock polarity (CPOL) and clock phase
[Microcontroller]
STM32 GPIO interrupt example
Preface: I am currently developing a rangefinder data summary display instrument. I started learning hardware in February 2017. I am good at software. I spent 1 month drawing the schematic diagram and half a month drawing the PCB board. In the middle, I spent 2 months using JAVA to develop an intermediate version of t
[Microcontroller]
Introduction to STM32 timers (mainly introduction to UEV update events)
The timer of the microcontroller is indeed very powerful. It occupies more than 100 pages in the reference manual, which is more than 1/4 of the reference manual. The timers of STM32 are divided into several categories, and the functions of each category are quite different. They are: 1. Advanced timer 2. General time
[Microcontroller]
Using watchdog wdt in stm32 low power sleep mode
Recently, a project is using stm32f103. I found that once the watchdog of stm32 is turned on, it cannot be turned off. After entering low power mode, the watchdog is also restarted. It is very dangerous not to use the watchdog. I have read a lot of information on the Internet but can't find a solution. Later, I though
[Microcontroller]
STM32 Development Board Getting Started Tutorial - Internal Temperature Sensor
Without further ado, let's take a look at its parameters . 1. The internal temperature sensor of STM32 is connected to channel 16 of ADC and used in conjunction with ADC to achieve temperature measurement; 2. The measurement range is -40~125℃, with an accuracy of ±1.5℃. 3. The temperature sensor generate
[Microcontroller]
STM32 Development Board Getting Started Tutorial - Internal Temperature Sensor
STM32 BOOT0, BOOT1 configuration
STM32 has three boot modes: main memory, system memory and internal SRAM. You can find them in the user manual of the chip. Regarding these three startup modes, they are as follows: BOOT1=x, BOOT0=0: boot from main memory, which is the on-chip Flash memory of 64K, 128K, 256K, 512K, etc. Under normal circumstances, w
[Microcontroller]
Migration between different series of STM32 projects
1. The determination of chip capacity is often overlooked. Small capacity products refer to STM32F101xx, STM32F102xx and STM32F103xx microcontrollers with flash memory capacities between 16K and 32K bytes . Medium capacity products refer to STM32F101xx, STM32F102xx and STM32F103xx microcontrollers with flash memory c
[Microcontroller]
STM32 uses serial port interrupts to send and receive data
The chip used here is STM32F103, which uses interrupts to receive and send serial port data. Here we use the method of directly operating the registers. Using the library function is similar to this, except that we just call the corresponding library function instead. Configure serial ports and multiplexed IO ports v
[Microcontroller]
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号