I.MX RT - How to boot to SDRAM

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

I.MX RT - How to boot to SDRAM

I.MX RT - How to boot to SDRAM

  1. Introduction

i.MX RT ROM bootloader provides a wealth of options to enable user programs to start in various ways. In some cases, people want to copy application image from Flash or other storage device to SDRAM and run there. In this article, I record three ways to realize this. Section 2 and 3 shows load image from NOR flash. Section 4 shows load image from SD card.

Software and Tools:

MCUXpresso IDE v11.1

NXP-MCUBootUtility 2.2.0

  MIMXRT1060-EVK

  RT1060 SDK v2.7.0

  Win10

 

  1. Add DCD by MCUxpresso IDE

If customers use MCUXpresso to develop the project, they can add DCD head by MCUXpresso.

To show the work flow, we take evkmimxrt1020_iled_blinky as the example.

Step 1: Add the following to Compiler options:

XIP_BOOT_HEADER_DCD_ENABLE=1

SKIP_SYSCLK_INIT

Step 2: Modify the Memory Configuration

pastedImage_1.png

Step 3: Select link application to RAM

pastedImage_2.png

Step 4. Compile the project. MCUXpresso will generate linker script automatically.

Step 5. Since the code should be linked to RAM, MCUXpresso will not prefix IVT and DCD. We can add these link information to linker script manually. Add below code to .ld file’s head.

    .boot_hdr : ALIGN(4)

    {

        FILL(0xff)

        __boot_hdr_start__ = ABSOLUTE(.) ;

        KEEP(*(.boot_hdr.conf))

        . = 0x1000 ;

        KEEP(*(.boot_hdr.ivt))

        . = 0x1020 ;

        KEEP(*(.boot_hdr.boot_data))

        . = 0x1030 ;

        KEEP(*(.boot_hdr.dcd_data))

        __boot_hdr_end__ = ABSOLUTE(.) ;

        . = 0x2000 ;

    } >BOARD_SDRAM

 

Then deselect “Manage linker script” in last screenshot.

Step 6. Recompile the project, IVT/DCD/BOOT_DATA will be add to your project. Then right click the project axf file->Binary Utilities->Create S-record.

 

After all these step, you can open MCUBootUtility and download the .s19 file to NOR flash.

 

  1. Add DCD by MCUBootUtility

We can also keep the linker script managed by IDE. MCUBootUtility can add head too. Sometimes it is more flexible than other manners.

Step 1. This time BOARD_SDRAM location should be changed to 0x80002000 while the size should be 0x1cff000. This is because the start 8k space in bootable image is saved for IVT and DCD.

Step 2. compile the project and generate the .s19 file.

Step 3. Open MCUBootUtility. In MCUBootUtility, we should first set the Device Configuration Data. Here I use MIMXRT1060_EVK. So I select the DCD bin file in NXP-MCUBootUtility-2.2.0\src\targets\MIMXRT1062.

pastedImage_3.png

After that, select the application image file and click All-in-one Action button. MCUBootUtility can do all the work without any manual operation.

 

  1. Boot from SD card to SDRAM

In some application, customer don’t want XIP. They want to use SD card to keep application image and run the code in RAM. But if the code size is bigger than OCRAM size, they have to copy image into SDRAM when startup.

With MCUBootUtility’s help, this work is very easy too.  User just need to change the memory map which is located to 0x80001000.

 pastedImage_4.png

In MCUBootUtility, select the Boot Device to “uSDHC SD” and insert SD card. Then connect the target board. If RT1060 can read the SD card, it will display the SD card information. Then same as last section, set the DCD file and application image file.

Click the All-in-One Action button, MCUBootUtility will generate the bootable image and write it to SD card.

 

SD card has huge capacity. It's too wasteful to only store boot image. People may ask that can they also create a FAT32 system and store more data file in it? Yes, but you need tool's help. When booting from SD card, ROM code read IVT and DCD from SD card address 0x400. To FAT32, the first 512 bytes in SD is for MBR(MAIN BOOT RECORD). Data in address 0x1c6 in MBR reords the partition start address. If the space from MBR to partition start address is big enough to store boot image, then FAT32 system and boot image can live in peace.

.

 

Conclusions:

  1.      To help Boot ROM initialize SDRAM, DCD must be placed at right place and indexed by IVT correctly. When our code seems not work, we should first check IVT and DCD.

 pastedImage_5.png

 

  1.      The IVT offset from the base address for each boot device type is defined in the table below. The location of the IVT is the only fixed requirement by the ROM. The remainder or the image memory map is flexible and is determined by the contents of the IVT.
Comments

Hi,

Great article. I have followed all along using MCUExpresso IDE and the RT1176 evalkit.

Although when reach step 6, after hand modifying the script, the build operation crashes giving the following errors:

andrelongo85_0-1686144122157.png

 

Here the head of my linker script:

-----------------------------------------------------------------

/*
 * GENERATED FILE - DO NOT EDIT
 * Copyright (c) 2008-2013 Code Red Technologies Ltd,
 * Copyright 2015, 2018-2019 NXP
 * (c) NXP Semiconductors 2013-2023
 * Generated linker script file for MIMXRT1176xxxxx
 * Created from linkscript.ldt by FMCreateLinkLibraries
 * Using Freemarker v2.3.30
 * MCUXpresso IDE v11.7.1 [Build 9221] [2023-03-28] on Jun 7, 2023, 3:17:55 PM
 */
    
INCLUDE "evkmimxrt1170_dev_msc_disk_bm_cm7_Debug_library.ld"
INCLUDE "evkmimxrt1170_dev_msc_disk_bm_cm7_Debug_memory.ld"
 
ENTRY(ResetISR)
 
SECTIONS
{
.boot_hdr : ALIGN(4)
 
    {
 
        FILL(0xff)
 
        __boot_hdr_start__ = ABSOLUTE(.) ;
 
        KEEP(*(.boot_hdr.conf))
 
        . = 0x1000 ;
 
        KEEP(*(.boot_hdr.ivt))
 
        . = 0x1020 ;
 
        KEEP(*(.boot_hdr.boot_data))
 
        . = 0x1030 ;
 
        KEEP(*(.boot_hdr.dcd_data))
 
        __boot_hdr_end__ = ABSOLUTE(.) ;
 
        . = 0x2000 ;
 
    } >BOARD_SDRAM
    
     /* MAIN TEXT SECTION */
    .text : ALIGN(4)
    {
        FILL(0xff)
        __vectors_start__ = ABSOLUTE(.) ;
        KEEP(*(.isr_vector))
        /* Global Section Table */
        . = ALIGN(4) ;
---------------------------------------------------
 
And a snapshot of the memories map:
andrelongo85_1-1686144237960.png

 

 

Thanks for your great help!!

 

Andrea

Hello,

How can I do this with IMXRT1064? Should the memory section be modified the same way? 

Hi @andrelongo85@jingpan@MustafaEmre,

While booting from SDRAM you have faced error about undefined reference to "_boot_hdr_boot_data_loadder_" variables. Did you resolved it, if yes guide me with the steps to resolve this issue.

 

Adithya_0-1721652234200.png

Regards,

Adithya

 

 

No ratings
Version history
Last update:
‎06-06-2023 02:33 AM
Updated by: