Understanding Chip Programming

Understanding Chip Programming

Understanding Chip Programming

When it comes to flashing firmware, everyone is likely familiar with it. The essence of flashing is to update all or part of the programs in the embedded product’s chip and external memory.

Based on the various methods of programming chips involved from PCB production to R&D debugging, assembly, and finally to the user, today we will discuss and clarify the relevant content.Flashing carries risks; please proceed with caution Understanding Chip Programming1. Online Programming vs. Offline ProgrammingDepending on whether the chip is programmed on the board, it can be divided into two types: offline programming and online programming.(1) Offline Programming:This usually refers to “bare chip programming,” where the MCU chip is programmed on a programmer with the appropriate adapter before being mounted on the PCB. We know that embedded chips require basic peripheral circuits to operate, and programming is no different. Offline programming essentially incorporates the necessary peripheral circuits and devices (such as power supply and JLINK) into the offline programmer. Once the chip is placed in the adapter and powered on, it creates a basic programming environment, allowing the corresponding program to be programmed via a PC or some extended functions of the programmer itself. Ignoring the time taken to place and remove the chip, the programming speed is very fast (the images below are taken from common offline programmers on ZLG and 1688).Understanding Chip ProgrammingUnderstanding Chip Programming(2) Online Programming:This usually refers to programming chips that are already mounted on the PCB, using various communication interfaces of the chip itself, such as USB, SWD, JTAG, UART, etc. This method is limited by the performance of the serial interface itself, with speeds varying from fast to slow. If using SWD or JTAG, the programming speed is comparable to offline programming; however, if using UART or similar, the speed is relatively slow due to baud rate limitations. During product development, programmers downloading and debugging programs via a JLINK box is an example of online programming. The image below shows a development board from a certain manufacturer with a JTAG interface.Understanding Chip Programming

2. ICP, ISP, IAP

ICP (In Circuit Programming):This refers to programming in-circuit, using the chip’s Debug Access Port for code programming, such as ARM core chips primarily using SWD (Serial Wire Debug) or JTAG (Joint Test Action Group). The offline programming mentioned in Chapter 2 can actually be categorized under this method.ISP (In System Programming):This refers to in-system programming, which can utilize the bootloader pre-installed by the chip manufacturer to program code through onboard interfaces like UART, USB, SPI, etc. For example, most STM32 series chips come with a manufacturer-provided bootloader, allowing the MCU to support downloading via UART using ST’s flash-loader on the host computer.IAP (In Application Programming):This refers to application programming, where developers implement bootloader functionality for programming upgrades. Generally, the software of embedded products is divided into two parts: the first part is the bootloader, and the second part is the main application (Main APP), which are stored in different areas of flash memory. The bootloader is executed first after power-up or reset, allowing us to initialize some hardware devices, check the integrity of the program, and determine whether to jump from the bootloader to the APP or update the APP. The main application is the actual functionality aimed at the customer. Typically, the bootloader will implement one or more IAP methods, which may include UART, SPI, CAN, or Ethernet, etc. Flashing mobile phones or upgrading wristbands via Bluetooth fall under this category.Understanding Chip ProgrammingThe main differences between ISP and IAP are as follows:Understanding Chip Programming

3. IAP: How to Debug and Simultaneously Program IAP Programs?

For IAP, during the development and production phases, we often need to debug or simultaneously program the bootloader and the corresponding main APP programming files.(1) First, it is important to clarify that the bootloader and Main APP projects have been set up through the linker file, and during the compilation and linking phase, they will each produce programming files with address information that do not conflict.Taking Keil as an example, we can select and edit the linker file in the Linker settings.Understanding Chip Programming(2) Then, in the Debug options, check the Erase Sectors option, so that during debugging and programming, Keil will automatically erase only the areas specified in the linker file. This allows for separate programming and debugging of the two projects without interference.Understanding Chip Programming(3) After separately programming the bootloader and Main APP programs, you can open the command window in debug mode, as shown in the image below:Understanding Chip ProgrammingThe command window supports exporting data from the specified storage area of the existing chip and saving it as an Intel HEX file. Therefore, we can use this function to export the entire Flash area code data of the user to a hex file, effectively merging the programming files of the bootloader and Main APP.The syntax is as follows: SAVE path\filename startAddr, endAddr.Understanding Chip Programming(4) On the production line, you can use Keil’s tools to program the merged Hex file, allowing for the simultaneous programming of the bootloader and Main APP, thus improving efficiency.(5) Additionally, J-Flash, STM32 ST-LINK Utility, and Uniflash also have similar functionalities, which will not be elaborated on here.Source: Xilinx Embedded Design CommunicationNote:

Due to recent changes in the WeChat public platform’s push rules, many readers have reported not seeing updated articles in a timely manner. According to the latest rules, it is recommended to frequently click on “Recommended Reading, Share, Favorite,” etc., to become a regular reader.

Recommended Reading:

  • After seeing Zhi Hui Jun’s workbench, I am envious~

  • After the ineffective suppression of China, US lawmakers are now targeting RISC-V

  • Stimulated by Huawei? Another 28 entities have been added to the control list

Please click 【View】 to give the editor a thumbs up

Understanding Chip Programming

Leave a Comment