This article will record in detail how to use the STM8S built-in BootLoader to implement program updates.
Preparation:
1. ST support document UM0560 (explains how to use BootLoader)
2. ST official download software STMFlashLoader Demo.exe
3. IAR Embedded Workbench 、ST Visual Programmer
4. 2 STM8S105K6, used to implement the update operation.
Practical operation:
1. 使用STVP -> OPTION BYTE -> ROP ->Read Out Protection OFF
STVP -> OPTION BYTE -> BOOTLOADER ENABLE ->BootLoader Enable
This article only records how to use BootLoader. If read protection is enabled, it is not discussed in this article (UM0560 mentions how to deal with it). Why these two bytes of option words need to be processed is explained in UM0560. If you do not do this, you cannot enter the BootLoader program. After the MCU is reset, if it detects that these two option bytes do not match, it will jump to the user application area 0x8000 address.
Additional notes:
Enable BootLoader to use library functions to write byte option words.
FLASH_Unlock(FLASH_MEMTYPE_DATA); //解锁Flash
FLASH_ProgramOptionByte(0x487E, 0x55); //Enable BootLoader
FLASH_Lock(FLASH_MEMTYPE_DATA); //Lock Flash and write code here
Read protection cannot be written using library functions.
Use UART to communicate with PC
Open STMFlashLoader Demo.exe on the PC and connect the serial port.
Within 1 second after the MCU is reset, click Next.
If you cannot enter the interface above, check from 3 aspects:
1. Step 1, whether the two-byte option word has been configured.
2. Are the serial port TX and RX connected correctly?
3. Is the MCU power supply normal?
Select the MCU density capacity, which corresponds to the firmware version 1.3, which is read from the Boot area by the host computer. Click Next.
Next, enter the erase, download, and update interface. I won’t say much about erase, you will understand what it means after you operate it. Updata means reading the MCU program and saving it as a file. Let’s focus on the download operation.
Before downloading, you need to execute label 1. The key point here is label 2, do not load the HEX file. If the HEX file is loaded, label 3 cannot be operated and the write address cannot be selected. The reason is that the HEX file itself contains the write address information, so it cannot be changed. In IAR, you can edit OPTION and select Generate Bin file. Only after the Bin file is generated can you select the address.
The address I choose here is 0xA000, which is determined by the developer. APP1.bin contains the firmware information to be updated, that is, the program to be copied to the target board slave.
At this point, the BootLoader has completed half of its task. The next article will describe how the host MCU shakes hands with the slave, and then how the host updates the slave's program.
When I was operating, I was thinking about how to put the firmware and application programs into the host's flash separately. I went to various forums for help but didn't get a satisfactory answer. I accidentally loaded a Bin file and the problem was solved. I wrote it down specially, hoping to help people with the same confusion.
Previous article:STM8L051F3 Hardware I2C Slave Example - Newbie Navigation
Next article:ST hardware IIC power check always detects busy state
Recommended ReadingLatest update time:2024-11-16 13:46
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!
- 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
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- Understanding of analog IC
- msp430f149 microcontroller serial port C program
- How do we distinguish the difference between bypass capacitors and decoupling capacitors?
- [Distributed temperature and humidity acquisition system] + WIFI module expansion board V2
- Basic knowledge of power amplifiers - the original feedforward - is still in use today
- A spike voltage appears when the current of a single-phase bridge phase-controlled rectifier resistor and inductive load is interrupted
- Could you please tell me what MOS tube the silk screen printed P3SBK 4 is?
- [SensorTile.Box] How to save the sound recorded through the microphone in the SD card, and then copy it to the computer for playback?
- Low-cost smart cat's eye based on RGB-D face detection and environmental monitoring] - Temperature, humidity and smoke sensor hardware design
- How good is NXP i.MX 8M Plus?