Several Common Methods of MCU Program

Recently, | saw a friend ask a relatively basic question, probably asking: What are the common methods of programming MCU?


Let's talk about the three common methods of burning programs: ISP, IAP and ICP, and their differences.


ISP: In System Programming, in-system programming.
ISP means that programming can be performed on the board level, that is, the entire program is written without dismantling the chip, usually through the ISP interface line.


Chips that support ISP generally have a boot program (upgraded with ISP ) inside the chip.


For example: use STC-ISP to program STC chip, use FIash loader to program STM32, etc.

ICP: In Circuit Programming, in circuit programming.

ICSP: In-Circuit Serial Programming, in-circuit serial programming . Such as: EEPROM programming, etc.

There are different opinions on the ICP programming method on the Internet. From the literal meaning (in the circuit), all the chips that are being programmed need to be powered on, and they are all in the circuit. Strictly speaking, programming using .Link, ST.Link, e-Link32 and other tools also belongs to in-circuit programming (ICP).

 

In Wikipedia, ISP (In-System Programming), also known as In-Circuit Serial Programming (ICSP).

IAP

IAP: In applicaTIng Programming, in application programming. Perform programming (upgrade program, update firmware) while the program is running.
IAP is the programming of part of the User Flash by the user's own program during operation. The purpose is to update and upgrade the firmware program in the product through the reserved communication port conveniently after
the product is released.


IAP communication port


There are many kinds of IAP communication ports: UART serial port, ETH Ethernet, 12C, sPl...etc. It stands to reason that as long as the communication port that can transmit data can realize the
function of IAP.
IAP should be very extensive, you can refer to an article | shared before: STM32 official IAP routine detailed description, and Demo demonstration

 

Difference between ISP and IAP

1. Make a metaphor

1.The ISP demolishes the house and rebuilds it, so of course no one can live in it before it is built !

 

2.1AP is to carry out some decorations in the built house, of course people can continue to live in it!

2. Application


1. The ISP program upgrade needs to be solved on site, but the better thing is that there is no need to dismantle the machine;

2. If IAP has a network management system, use the network management to download everything, and people don' t have to run around.

3. How ISP and IAP work


The implementation of ISP is relatively simple, and the common practice is that the internal memory can be rewritten by the software of the host computer through the serial port. For the single-chip microcomputer, the data from the host computer can be received through SPI or other serial interfaces and written into the memory. So even if we solder the chip on the circuit board, as long as the serial port to interface with the host computer is reserved, the internal memory of the chip can be rewritten without removing the chip.


The implementation of IAP is relatively complicated. When realizing the IAP function, there must be two storage areas inside the microcontroller. Generally, one is called the BOOT area, and the other is called the storage area. The MCU is powered on and runs in the BOOT area. If the conditions for rewriting the program externally are not met, the program pointer jumps to the storage area and starts to execute the program placed in the storage area, thus realizing the IAP function.

4. Advantages of ISP and IAP

The advantage of ISP technology is that the experiment and development of the single-chip microcomputer can be carried out without a programmer. The single-chip microcomputer chip can be directly welded to the circuit board, and the finished product is ready after debugging, which eliminates the frequent insertion and removal of the chip to the chip and the circuit board during debugging. Inconvenience caused.

The IAP technology is to map the Flash memory into two memory banks structurally. When running the user program on one memory bank, the other memory bank can be reprogrammed, and then the program is transferred from one memory bank to the other.

TThe realization of ISP generally requires few external circuits to assist the realization, while the realization of IAP is more flexible. Usually, the serial port of the single-chip microcomputer can be used to connect to the RS232 port of the computer, and the internal memory can be programmed through a specially designed firmware program. It is very convenient to realize remote upgrade and
maintenance through Internet or other communication methods.