In-system programming
In-system programming, also known as ISP or in-circuit programming (ICP), is the process of programming a computer chip in system, so when it has already been soldered (connected) to a printed circuit board. Almost all devices with some sort of non-volatile storage can be programmed in-system. This applies to microcontrollers (MCUs), FPGAs (Field programmables gate arrays) as well as typically serial (Q)SPI flashes. Even other types of flashes (parallel NOR or NAND flashes) with many pins can be programmed in-system, typically through the MCU or SoC that they are connected to. The In-system programmer in this case typically downloads a program to the MCU or SoC, which then receives and programs the connected flash memory.
Overview
There is no standard for in-system programming. Almost all microcontrollers support ISP, but the protocols are very different. In many cases, the debug interface can be used to do the programming as well, usually by downloading a flashloader into the RAM of the MCU and then using the flashloader to program the flash memory. There is also no standard for a debug interface, even though many devices can be programmed via JTAG (which requires 4 pins) or SWD (requiring 2 pins). There are however also single pin interfaces, dual pin (SPI-style), I2C and many other variations. Since things are different from one manufacturer to the next, but even between different devices from the same manufacturer, the field of In-system programmers is very fragmented, with many programmers specializing on a particular family of MCUs or devices of a specific vendor. However, there are universal In-system programmers like SEGGER's Flashers, a family of programmers which are extremely versatile and can be used to program almost anything with almost any interface and protocol
In-system Programming vs. Out-of-system Programming
Out-of-system programming, also known as pre-programming, means sending the target chip (the one which contains the non-volatile memory, so the MCU or (Q)SPI Flash, to an external programming house. The programming house now takes the chip out of the packaging, into a fixture, programs it and then repackages it and sends it back. This process needs to happen prior to assembly, so earlier than in an ISP setup, where programming happens after assembly, after soldering the device onto the PCB. ISP has various advantages and is therefor much more common:
- Lower cost
- Faster time to market as software is programmed in final step, after assembly
- Reprogramming possible in case new firmware becomes available
Production environments
ISP is typically used in production environments
Using ISP for firmware updates
In-system programming can also be used to update a firmware in the field. Once a device is in the hands of a customer, there are typically other ways to update it, via a communication interface such as USB or Ethernet or via USB memory stick or SD card. For these in-field updates, a bootloader is required, which is started before the actual firmware and typically checks for the availability of a firmware update, validates it (typically using a signature check) and then updates the actual firmware However, some embedded devices do not have this technology or simply do not have a communication interface to receive an update. There are In-system programmers available such as SEGGER Flasher Portable, specifically designed to do firmware updates in the field.
FAQ
Programming speed
Q: What are typically programming speeds? A: Again, there is absolutely no standard for ISP programming. Different interfaces and protocols deliver different performance, and the underlying flash technology is also vastly different, just like the size of the flash memory and the image that needs to be programmed. Small MCUs (Up to 256KB Flash) are typically programmed in less than 2 seconds. Larger MCUs might need more time. As a rule of thumb, modern Flash devices have a programming speed of around 500KB/ second, so that it takes around 2 seconds to program one MB. The same values is also a good estimate for programming of (Q)SPI Flashes. Note that these values are very much ballparks, as they depend on many factors, including very much the programmer used. In general, SEGGER Flash programmers tend to deliver the best performance, very close to the maximum speed possible.