-------------------------------------------------------------------------------------------
IAP+APP is the most basic remote upgrade kit, but many people ignore the importance of IAP upgrade software. Here we will talk about this IAP upgrade software. I will not consider xmode and ymode for now, because they are not practical at all: they are not compatible with different WINDOWS platforms, and they have to be divided into X86/64BIT versions. The IAP segment code takes up a lot of space... It can only be used for experiments at most.
-------------------------------------------------------------------------------------------
The STM32F0xx series is much cheaper than the F1 series, and cheapness also brings good things: low power consumption per unit, fewer pins, and a full range of products. However, there are some disadvantages, such as small FLASH capacity, slow computing speed, and even the IAP mechanism cannot be used with the F1 series.
So this article will introduce an IAP and PC-side upper-level IAP application software that can be used by F0.
As we all know, the IAP of F1 series usually takes up 12K space (08000000-08003000), or a smaller one takes up 8K space (08000000-08002000). This is not much for the 32K starting point of FLASH of F1 series; but it is too much for economical MCU like F0, so first of all, we need to reduce the IAP code segment by half to within 4K (08000000-08001000), which is especially effective for 16K FLASH such as STM32F030F4.
IAP generally uses serial port 1, but for STM32F042xx and other chips, it is recommended to use serial port 2. The IAP code should be modified because the serial port 1 of these chips is mostly reused for CAN/USB, and these modifications are also relatively easy.
Then the next part is the key content provided in this article: APP code modification, file merging tools, and IAP application software.
-------------------------------------------------------------------------------------------
1. APP code modification
This should be a long-standing topic. First of all, the interrupt vector offset problem. The interrupt vector offset of the F1 series is relatively simple, while that of the F0 series is slightly different, as follows:
RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG, ENABLE);
for(i = 0; i < 48; i++)
VectorTable[i] = *(__IO uint32_t *)(APPLICATION_ADDRESS + (i << 2));//APPLICATION_ADDRESS =0x08001000
SYSCFG_MemoryRemapConfig(SYSCFG_MemoryRemap_SRAM);
Please note: the above paragraph must be placed at the very beginning of the MAIN function, especially before each NVIC configuration; if the position is wrong, it is very likely to cause a runaway due to an unexpected interrupt!!!
Secondly, in order to save FLASH space, the FLASH flag is not used as the jump basis, but BKP0 is used as the flag register, as follows:
#ifdef IAP_DEBUG
case 0xe0:
if((UART1_RXB[2] == 0x01) && (UART1_RXB[3] == 0x01)) //The serial port receives specific data and enters IAP mode
{
RTC_WriteBackupRegister(RTC_BKP_DR0, 0xABABABAB); //Write IAP flag at BKP0 (0xABABABAB)
NVIC_SystemReset(); //After restarting, IAP will check the BKP0 register
}
break;
#endif
Because as long as the power is not lost, the data of the BKP register will not be lost during the SystemReset process, and it is completely possible to save the key flag data during the APP jump to IAP. Of course, the use of BKP needs to follow the ST manual and turn on the PWR\RTC function. Minor details will not be explained here.
Note: One advantage of using the BKP register is that the IAP code segment does not need to consider the FLASH size of the chip, and can be made universal for the entire series. Because the BKP addresses of chips with different capacities are consistent, the entire series can use the same IAP code; while using the FLASH method, the IAP segment code must be modified and recompiled according to the FLASH capacity of the chip. For example, the IAP segment of the stm32F0XX6/XX8 series cannot be universal, one is 32K and the other is 64K. Because the end FLASH addresses are different, the corresponding upgrade flag address must be modified, resulting in poor universality.
Then you need to set the starting position in the development tool. Here we take IAR as an example:
-------------------------------------------------------------------------------------------
2. File Merger Tool
Regardless of the type of IAP, you need to use a burning tool to burn the IAP segment first, and then burn the APP through IAP. However, this will cause troublesome operation and complicated production process.
Using a file consolidation tool can reduce this time.
This tool is used to merge the IAP segment and APP segment into the same file, which is convenient for one-time burning and avoids the trouble of secondary burning.
Of course, this tool will also write all the free FLASH in the APP segment to FF to avoid unexpected problems caused by residual code.
-------------------------------------------------------------------------------------------
3. IAP Application Software
Why spend so much time and effort to develop UI software? MCU engineers always take on some outsourcing projects, and inevitably encounter such problems:
A. Authorize burning, but cannot control the quantity;
B. Burning by yourself is time-consuming and laborious, and the logistics cost is high;
C. Risk of code leakage or decryption;
D. It is inconvenient to upgrade and difficult to deal with emergencies.
Because tools like JLINK, STLINK, and ULINK do not have counting functions or authorization files, anyone can burn and read all the codes, even if the read protection is not effective. This brings the above embarrassing problems.
IAP application software can solve these problems.
The authorization file is under development, so stay tuned (actually, I find it troublesome. The encryption function is inconvenient to use, and the most important thing is that I forgot the encryption algorithm once and got myself into trouble. I will add it in later if needed)
-----------------------------------------------------------------------------------------
Previous article:LIN bus development: STM32F0 TJA1020
Next article:STM32F0 USART wakeup from STOP mode
- Learn ARM development(16)
- Learn ARM development(17)
- Learn ARM development(18)
- Embedded system debugging simulation tool
- A small question that has been bothering me recently has finally been solved~~
- Learn ARM development (1)
- Learn ARM development (2)
- Learn ARM development (4)
- Learn ARM development (6)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- CGD and Qorvo to jointly revolutionize motor control solutions
- CGD and Qorvo to jointly revolutionize motor control solutions
- Keysight Technologies FieldFox handheld analyzer with VDI spread spectrum module to achieve millimeter wave analysis function
- Infineon's PASCO2V15 XENSIV PAS CO2 5V Sensor Now Available at Mouser for Accurate CO2 Level Measurement
- Advanced gameplay, Harting takes your PCB board connection to a new level!
- Advanced gameplay, Harting takes your PCB board connection to a new level!
- A new chapter in Great Wall Motors R&D: solid-state battery technology leads the future
- Naxin Micro provides full-scenario GaN driver IC solutions
- Interpreting Huawei’s new solid-state battery patent, will it challenge CATL in 2030?
- Are pure electric/plug-in hybrid vehicles going crazy? A Chinese company has launched the world's first -40℃ dischargeable hybrid battery that is not afraid of cold
- RISC-V open source hardware board — HiFive Unleashed
- CY8CKIT-149 PSoC 4100S PLUS PROTOTYPING KIT Unboxing and Power-On Run Example
- How does an intelligent fully automatic multimeter measure capacitance?
- PCB current and signal integrity design
- 15th Anniversary] EE DIY (Progress) -- Upper Computer UI Changes
- 【LoRa】Common Problems in LoRa Development
- How can I include all the component libraries and package libraries used when copying the PROTEL99 project file to another computer?
- Summary of where and how DSP stores and writes data
- [ST MEMS waterproof pressure sensor LPS27HHW review] + Problems with the routine
- Qinheng CH582mesh networking