XIP Execute in Place: Let Programs "Work On-Site", Fully Boosting Embedded Development Efficiency!
This article explains XIP, a technology allowing MCUs to execute code directly from Flash instead of copying it to RAM, using Raspberry Pi Pico as an example.
COMPONENTS
PROJECT DESCRIPTION
The memory units in a microcontroller can be roughly divided into two categories:
RAM: All variables that need to be rewritten during program execution are stored in RAM;
ROM: It is mainly used to store instruction codes and certain fixed values, which cannot be modified after the program runs. For example, all the code in. c and. h files, global variables, local variables, constant data defined by the 'const' qualifier, and the code in the startup. asm file are all stored in ROM.
FLASH memory, also known as flash memory, combines the advantages of both ROM and RAM. It not only features the electronically erasable programmable (EEPROM) performance, but also retains data without power supply while enabling fast data readout. In the past, embedded systems consistently used ROM (EPROM) as their storage device; however, in recent years, Flash has fully replaced the position of ROM in embedded systems.
During the code execution process of a microcontroller unit (MCU), it is usually necessary to read the code from ROM/external flash into a RAM buffer before executing it sequentially. However, many current NOR QSPI FLASH chips support the XIP (eXecute In Place) function, under which mode the embedded MCU chip can directly fetch instructions from the NOR QSPI FLASH for subsequent use by the decoder and executor, without the need to load the code into RAM in advance.Simply put, XIP is a mechanism that enables code to be executed directly in flash memory without being loaded into RAM for execution, which reduces the time required for the kernel to be copied from flash memory to RAM.
When flashing a self-developed application to the Raspberry Pi Pico, the program is first written to the external Flash, and then when the chip starts up, the bootloader in its internal ROM loads and executes the program via XIP/Cache.
QSPI interface implementing XIP function acts as the "direct access channel from external warehouse" for the factory: it connects to external flash memory (equivalent to an "external large warehouse") via the QSPI interface, and the XIP function enables the chip to read programs directly from the external warehouse without first transferring them to the internal temporary storage, thus saving internal space.