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.
2. Download the hex file (CRC or SUM) to the specified Flash storage area.
3. Erase any specified sector (8~127).
Previous article:STM32 low power mode practice
Next article:STM32 USB HID device driver analysis
Recommended ReadingLatest update time:2024-11-17 01:59
- Popular Resources
- Popular amplifiers
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- Rambus Launches Industry's First HBM 4 Controller IP: What Are the Technical Details Behind It?
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- The problem of TPS55340 output voltage noise is relatively large
- Newbie wants to convert assembly language to C language
- China Huawei PCB design related specifications
- [Mil MYS-8MMX] Mil MYS-8MMQ6-8E2D-180-C Application 3 - NLP Part of Speech Analysis and Application
- "Big Talk on Electronic Components and Circuits"
- How the electrification of automobiles develops voltage power board network
- DC servo motor driver is still very good
- On the RS485 side DB9 connector, what are the two PINs A and B respectively?
- 【Distributed temperature and humidity collection system】+MQTT debugging
- The channel for exchanging TI points for chip points has been opened. Full redemption within a limited time. The ultimate redemption is coming~