PI Ziheng embedded: hardware of NXP i.MX rt1xxx Series MCU (2.6) – Serial nor flash download algorithm (MCU express IDE)

Time:2021-6-4

Hello everyone, I’m a ruffian Heng. I’m a serious technical ruffian. Today, ruffian Heng introduces to youDesign of serial nor flash download algorithm for i.mxrt under mcuxpresso ide development environment

In the i.mxrt hardware seriesPrinciple of debugging in serial nor flash XIPIn this article, PI Ziheng simply mentioned the concept of serial nor flash download algorithm, and did not introduce the specific design details. As for the NOR flash download algorithm, each ide has its own design. Although the basic design concept is the same, there are still differences in details. In the previous article, ruffian Heng respectively introducedAlgorithm design under j-linkAlgorithm design under keil MDKAlgorithm design under IAR EWARMToday, PI Ziheng will talk about nor flash download algorithm under MCU express ide

1、 The support of mcuxpresso IDE for i.mxrt

Mcuxpresso IDE is a new ide after the merger of Freescale and NXP. This IDE is free and can be used for all series of arm Cortex-M controllers (kinetis, LPC, jn, QN, i.mxrt, etc.) of NXP. Those familiar with the two companies should know that mcuxpresso IDE is actually the combination of the original NXP lpcxpresso IDE and the original Freescale kinetic design studio ide.

According to the official website of NXP, the latest version of mcuxpresso IDE is v11.2.1, which can support all mass-produced i.mxrt series. fromMcuxpresso ide historical release notesFrom the above, we can see the support for i.mxrt in various versions as follows:

Download address of each version:https://nxp.flexnetoperations.com/control/frse/product?child_plneID=756637&ver=ARC

Although the support of MCU express IDE for new MCU models is not strictly bound with its own version, it is more complex to patch it, and the official does not support it. Anyway, the IDE is free, and it does not need to be upgraded and applied for a license. It is better to install the latest version to support the new models.

2、 Add new download algorithm support for current mcuxpresso IDE

PI Ziheng is installed with the latest v11.2.1. We take rt600 as an example to introduce the use of MCU express ide. Before we start, we should pay special attention to the difference between mcuxpresso IDE and MDK / IAR. The flash download algorithm of MDK / IAR has nothing to do with specific hardware emulators. It can be used normally in all supported emulators (JLINK / daplink, etc.), butThe flash download algorithm of mcuxpresso ide can only be used in cmsis-dap simulator. If you use JLINK in the mcuxpresso IDE, you can only download the algorithm from JLINK.

Now let’s open an i.mxrt600 SDK project at random. Right click the project to enter the properties setting interface. Under MCU settings, you can see the setting interface of linkserver flash driver. Here is to select the flash download algorithm. Mcuxpresso ide comes with many flash download algorithms by default (the file suffix is. CFX, which is actually the executable file ELF). Even for the same chip rt600, you can see that it has many. CFG options, which correspond to different types of flash and the connection port with the main chip.

If the flash download algorithm file selected by default is not applicable to your board, you need to provide the appropriate algorithm file (. CFX) and put it into the installation directory of mcuxpresso IDE ( mcuxpresso IDE)_ 11.2.1_ 4149 / IDE / binaries / Flash), reopen the project option, and the new algorithm will automatically refresh to the list of algorithms to be selected

3、 NOR flash download algorithm design

The flash download algorithm in MCU express IDE is public_ 11.2.1_ 4149\MCUXpresso_ IDE_ User_ Guide.pdfLinkServer Flash SupportThere are some introduction about the usage in this chapter. You can have a look at it.

3.1 download algorithm template project

Although the download algorithm itself is public, there are few design documents and only a sample project is given. But for engineers, what is more direct than giving code.

  • Example Algorithm Project path: mcuxpressoide_ 11.2.1_ 4149\ide\Examples\Flashdrivers\NXP\iMXRT

Let’s take imxrt1050 as an example_ QSPI. Zip sample package code to analyze its structure design. This sample package contains two projects (lpcxflashdriverlib and imxrt1050)_ First, you need to compile the lpcxflashdriverlib project to generate liblpcxflashdriverlib. A. this library is imxrt1050_ QSPI project source file, and then compile imxrt1050_ The QSPI project generates the algorithm file mimxrt1050-evk that we need_ IS25WP064A.cfx。

Mcuxpresso ide download algorithm, a two-level compiler design, is totally different from IAR / MDK download algorithm structure. The main reason for this design is that NXP has a large number of MCU product lines in arm Cortex-M kernel, and mcuxpresso ide needs to support all MCU. Therefore, the common design part is extracted into lpcxflashdriverlib project (cm0 instruction set is used to compile the project for generality). In addition, you can see from the project name that the gene of the previous generation lpcxpresso IDE is still preserved.

There are many builds in lpcxflashdriverlib project. You can compile macros according to the conditions in servicemessages. C file to find out their differences_ The sectorhashing project is selected by default for the final generation of. CFX. This build mainly uses 32 bit Fowler / Noll / VO fnv-1a hash algorithm to verify the data download of each sector.

Go to imxrt1050_ QSPI project, which is compiled with the specific MCU kernel instruction set (CM7), can be seen in the project settings linked to the lpcxflashdriverlib project release_ The. A file generated by sectorhashing, if lpcxflashdriverlib project chooses other build, it should be changed accordingly.

3.2 structure design of download algorithm

The algorithm itself is the most complex one among several commonly used ides. iMXRT1050_ In addition to the general flexspi driver, QSPI project has two source files flashdev. C and flashprg. C. are you familiar with this file name? Yes, this is the standard CMSIS open source flash algorithm API definition, and the contents are similar. I won’t go into details here. It needs to be emphasized that these flash erasure APIs are not actually called by mcuxpresso ide when downloading.

The core design of the algorithm is in the lpcxflashdriverlib project. Let’s look at lpcx first_ flash_ In memdev. C, this file defines an important constant structure, memorydevice, which will be linked to the starting position (0x20000000) of the algorithm execution area (the first 64KB dtcm) to provide all the algorithm information to the mcuxpresso ide debugger.

// MemoryDevice Instance (fill it in)
EXTERN_MEMORY_DEVICE
MemoryDeviceMsg_t MemoryDevice =
{
  MEM_FLASH_VER2_MAJ+0x0,       // Version of flash interface
                                // Magic number to identify flash driver
                                // interface
  { 0x01, 0x23, 0x45, 0x00, 0x00, 0x54, 0x32, 0x10 },
  (uint32_t)&__load_base,         // Driver load address
  (uint32_t)&__image_size,        // Size of .text and .data
  (uint32_t)&__cache,             // RAM buffer location
  (uint32_t)&__cache_size,        // RAM buffer size
  (uint32_t)&__initial_sp,        // Stack top
  (uint32_t)&__stack_size,        // Stack size
  (uint32_t)&__opmap_val,         // Bitmap of available operations - 0 = everything there
  &FlashDevice,                   // Flash Device configuration
  ServiceMessages,                // Service mailbox flash operation message
  0                               // Reserved
};

A member of memorydevice is the servicemessages() function, which is the soul of the algorithm. It is the real entrance for the mcuxpresso ide debugger to call the flash erase API. The debugger passes in MSG parameters (the so-called mailbox structure) to let the algorithm perform specific flash operations and get the execution results. This special design may be the reason why mcxpresso ide algorithm can only be used in cmsis-dap simulator.

So far, the design of serial nor flash download algorithm of i.mxrt under mcuxpresso ide development environment has been introduced. Where is the applause~~~

Welcome to subscribe

The article will be published to me at the same timeBlog Garden Home PageCSDN home pageZhihu HomepageWeChat official accountOn the platform.

Wechat search“Ruffian scale embedded“Or scan the following QR code, you can see it on your mobile phone for the first time.