i.MX RT118x External Memory Configuration with SPSDK#

Procedure of initialization and using external memory connected MCU over blhost interface.

  1. Create the flashloader application with mBoot(blhost application)

  2. Load the flashloader application to the target device

  3. Generate a blhost script for memory configuration

  4. Execute the blhost script to configure the external memory

    • Example of creation a non-default memory configuration

  5. Build a bootable image and load it into a memory configured though the blhost-script

1. Prerequisites#

SPSDK is needed with examples extension. pip install spsdk[examples] (Please refer to the installation documentation.)

1.1 Connect your board to you PC.#

Use both the Debug USB Port and USB OTG1 port and set the board to SDP mode. Configure Boot Mode Switch to SDP: 1-OFF, 2-OFF, 3-OFF, 4-ON
Connect your board to your PC via a micro USB using the USB OTG1 port - J33
Connect your board to your PC via a micro USB using the Debug USB port - J53

The following picture describes connector placement of RT1180 EVK:

rt1189-evk

Run the code below to initialize parameters for the script:

import os

WORKSPACE = "workspace/"  # change this to path to your workspace
INPUTS = "inputs/"
VERBOSITY = (
    "-v"  # verbosity of commands, might be -v or -vv for debug or blank for no additional info
)

FLASHLOADER_FILE = (
    "../../ahab/rt118x_signed_flashloader/workspace/flashloader.bin"  # Path to Flashloader
)
CFG_MEM_FILE = WORKSPACE + "config_mem.bls"  # Configure memory template
CUSTOM_CFG_MEM_FILE = WORKSPACE + "custom_config_mem.bls"  # Configure memory template
FCB_FILE = WORKSPACE + "fcb.bin"  # Firmware Configuration block file
CUSTOM_FCB_FILE = WORKSPACE + "custom_fcb.bin"  # Firmware Configuration block file

2. Create the flashloader application with mBoot(blhost application)#

We will need program our boards with a flashloader binary to be able to send blhost commands to it. To get such a binary, we can use the signed_flashloader notebook. The details are out of scope for this session, so just open the signed_flashloader notebook, use the “Run All Cells” option and close it again.

Run All Cells

Scan for available devices with nxpdevscan, connect to the i.MX RT1180 and load a flashloader into it using blhost

Call nxpdevscan --help to get a list of options supported by nxpdevscan:

%! nxpdevscan
nxpdevscan 
-------- Connected NXP USB Devices --------

LPC-LINK2 CMSIS-DAP V5.361 - NXP Semiconductors
Vendor ID: 0x1fc9
Product ID: 0x0090
Path: HID\VID_1FC9&PID_0090&MI_00\B&39EC9C5&0&0000
Path Hash: 89666509
Name: 
Serial number: JXBUBWEQ

LPC-LINK2 DATA PORT - NXP Semiconductors
Vendor ID: 0x1fc9
Product ID: 0x0090
Path: HID\VID_1FC9&PID_0090&MI_04\B&14C470B6&0&0000
Path Hash: e6877f23
Name: 
Serial number: JXBUBWEQ

LPCSIO - NXP Semiconductors
Vendor ID: 0x1fc9
Product ID: 0x0090
Path: HID\VID_1FC9&PID_0090&MI_03\B&1945478&0&0000
Path Hash: 043ac251
Name: 
Serial number: JXBUBWEQ

-------- Connected NXP UART Devices --------

-------- Connected NXP SIO Devices --------

LIBUSBSIO - NXP Semiconductors, LPCSIO
Vendor ID: 0x1fc9
Product ID: 0x0090
Path: HID\VID_1FC9&PID_0090&MI_03\B&1945478&0&0000
Path Hash: 043ac251
Serial number: JXBUBWEQ
Interface number: 3
Release number: 256

-------- Connected NXP UUU Devices --------

The Vendor and Product ID values of the OO Blank RT Family - NXP SEMICONDUCTORS are the default values for the boot ROM.

Store them in a variable for later use:

COMPAR = "-u"  # USB
BLHOST_CONNECT_ROM = "0x1fc9,0x014c"  # PID/VID of ROM

Reset your board by pressing the SW3 button. This is necessary because calling nxpdevscan causes the boot ROM to stop being visible. You can test this by executing the nxpdevscan cell one more time.

Ping the boot ROM via blhost:

%! blhost $COMPAR $BLHOST_CONNECT_ROM get-property 1
blhost -u 0x1fc9,0x014c get-property 1 
Response status = 0 (0x0) Success.
Response word 1 = 1258487809 (0x4b030001)
Current Version = K3.0.1

Load a flashloader image into the device:

from time import sleep

assert os.path.exists(FLASHLOADER_FILE)

%! blhost $COMPAR $BLHOST_CONNECT_ROM load-image $FLASHLOADER_FILE
sleep(3)  # wait for device
blhost -u 0x1fc9,0x014c load-image ../../ahab/rt118x_signed_flashloader/workspace/flashloader.bin 
Loading image
Response status = 0 (0x0) Success.

Call nxpdevscan again to get the Value and Product ID of the flashloader:

%! nxpdevscan
nxpdevscan 
-------- Connected NXP USB Devices --------

USB COMPOSITE DEVICE - FREESCALE SEMICONDUCTOR INC.
Vendor ID: 0x15a2
Product ID: 0x0073
Path: HID\VID_15A2&PID_0073\9&1D63E617&0&0000
Path Hash: a3f7b925
Name: mwct2014s | mimxrt1182 | mcxc444 | mimxrt1171 | mwct2d16s | mimxrt1024 | mcxc244 | mimxrt1165 | mcxc243 | mimxrt1173 | mcxc143 | mwct2015s | mimxrt1050 | mimxrt1010 | mimxrt1020 | mwct2016s | mimxrt1166 | mcxc443 | mimxrt1015 | mcxc144 | mimxrt1064 | mimxrt1187 | mcxc141 | mwct2d17s | mimxrt1040 | mimxrt1176 | mimxrt1189 | mimxrt1060 | mcxc242 | mimxrt1172 | mcxc142 | mimxrt1175 | mimxrt1181 | mcxc041
Serial number: 

LPC-LINK2 CMSIS-DAP V5.361 - NXP Semiconductors
Vendor ID: 0x1fc9
Product ID: 0x0090
Path: HID\VID_1FC9&PID_0090&MI_00\B&39EC9C5&0&0000
Path Hash: 89666509
Name: 
Serial number: JXBUBWEQ

LPC-LINK2 DATA PORT - NXP Semiconductors
Vendor ID: 0x1fc9
Product ID: 0x0090
Path: HID\VID_1FC9&PID_0090&MI_04\B&14C470B6&0&0000
Path Hash: e6877f23
Name: 
Serial number: JXBUBWEQ

LPCSIO - NXP Semiconductors
Vendor ID: 0x1fc9
Product ID: 0x0090
Path: HID\VID_1FC9&PID_0090&MI_03\B&1945478&0&0000
Path Hash: 043ac251
Name: 
Serial number: JXBUBWEQ

-------- Connected NXP UART Devices --------

-------- Connected NXP SIO Devices --------

LIBUSBSIO - NXP Semiconductors, LPCSIO
Vendor ID: 0x1fc9
Product ID: 0x0090
Path: HID\VID_1FC9&PID_0090&MI_03\B&1945478&0&0000
Path Hash: 043ac251
Serial number: JXBUBWEQ
Interface number: 3
Release number: 256

-------- Connected NXP UUU Devices --------

Store the values in a variable again:

BLHOST_CONNECT_FLDR = "0x15A2,0x0073"  # PID/VID of NXP Flashloader

Reset your board by pressing the SW3 button. This is necessary because calling nxpdevscan causes the flashloader to stop being visible as well. You can test this by executing the nxpdevscan cell one more time.

Reload the flashloader to be able to continue:

%! blhost $COMPAR $BLHOST_CONNECT_ROM load-image $FLASHLOADER_FILE
sleep(3)  # wait for device
blhost -u 0x1fc9,0x014c load-image ../../ahab/rt118x_signed_flashloader/workspace/flashloader.bin 
Loading image
Response status = 0 (0x0) Success.

Ping the flashloader to double check everything worked correctly:

%! blhost $VERBOSITY $COMPAR $BLHOST_CONNECT_FLDR get-property 1
blhost -v -u 0x15A2,0x0073 get-property 1 
INFO:spsdk.mboot.mcuboot:Connect: identifier='usb', device=USB COMPOSITE DEVICE (0x15A2, 0x0073)path=b'\\\\?\\hid#vid_15a2&pid_0073#9&1d63e617&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}' sn=''
INFO:spsdk.mboot.mcuboot:CMD: GetProperty(CurrentVersion, index=0)
INFO:spsdk.mboot.mcuboot:CMD: Status: 0 (0x0) Success.
Response status = 0 (0x0) Success.
Response word 1 = 1258424320 (0x4b020800)
Current Version = K2.8.0
INFO:spsdk.mboot.mcuboot:Closing: identifier='usb', device=USB COMPOSITE DEVICE (0x15A2, 0x0073)path=b'\\\\?\\hid#vid_15a2&pid_0073#9&1d63e617&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}' sn=''

Check the enabled flashloader commands:

%! blhost $COMPAR $BLHOST_CONNECT_FLDR get-property 7
blhost -u 0x15A2,0x0073 get-property 7 
Response status = 0 (0x0) Success.
Response word 1 = 25530335 (0x1858fdf)
Available Commands = ['FlashEraseAll', 'FlashEraseRegion', 'ReadMemory', 'WriteMemory', 'FillMemory', 'GetProperty', 'ReceiveSBFile', 'Execute', 'Call', 'Reset', 'SetProperty', 'FlashReadResource', 'ConfigureMemory', 'GenerateKeyBlob', 'UpdateLifeCycle', 'EleMessage']

3 Generate a blhost script for memory configuration using nxpmemcfg#

Call nxpmemcfg or nxpmemcfg --help to get a list of options and sub-commands supported by nxpmemcfg

%! nxpmemcfg
nxpmemcfg 
Usage: nxpmemcfg [OPTIONS] COMMAND [ARGS]...

  Collection of utilities for memory configuration operations.

Options:
  -v, --verbose  Print more detailed information
  -vv, --debug   Display more debugging information.
  --version      Show the version and exit.
  --help         Show this message and exit.

Commands:
  nxpmemcfg          Collection of utilities for memory configuration operations.
  ├── blhost-script  Export the configuration option words to blhost script.
  ├── export         Export the configuration option words from configuration.
  ├── family-info    List known memory configurations for the family.
  ├── get-families   Shows the full families information for commands in this group.
  ├── get-templates  Create template of Memory option words in YAML format.
  └── parse          Parse the existing memory configuration option words.

Call nxpmemcfg blhost-script or nxpmemcfg blhost-script --help to get a list of options supported by nxpmemcfg blhost-script:

%! nxpmemcfg blhost-script --help
nxpmemcfg blhost-script --help
Usage: nxpmemcfg blhost-script [OPTIONS]

  Export the configuration option words to blhost script.

Options:
  Known chip select. Alternative to known chip is YAML configuration '-c': [all_or_none]
    -f, --family [lpc5502|lpc5504|lpc5506|lpc5512..., and more. Use 'get-families' command to show all.]
                                  Select the chip family.
    -p, --peripheral [flexspi_nor|xspi_nor|flexspi_nand|semc_nor|semc_nand|spi_nor|mmc|sd]
                                  Choose the peripheral of the input option
                                  words
    -m, --memory-chip TEXT        Select supported memory chip name. Use
                                  family-info command to get the known names.
    -i, --interface TEXT          Select supported memory chip interface. Use
                                  family-info command to get the known
                                  interfaces.
  -c, --config FILE               Option word configuration YAML file, in case
                                  that known chip has not been used
  -ix, --instance INTEGER         Instance of peripheral if applicable
  --fcb PATH                      Optional filename of FCB block generated by
                                  HW and read back to PC. Be aware that script
                                  will contain also erase of 4KB on base
                                  address.
  --secure-addresses              If defined, the secure address will be used
                                  in case of generating FCB block.
  -o, --output FILE               Name of BLHOST script. If not specified, the
                                  script will be printed to command line
  --force                         Force overwriting of existing files.
  --help                          Show this message and exit.

Call nxpmemcfg family-info to check the known memories and their default configurations:

%! nxpmemcfg family-info -f mimxrt1189
nxpmemcfg family-info -f mimxrt1189
List of all supported peripherals and its instances:
╔═══╦════════════╦═════════════╦══════════╦══════════════╦══════════╦═══════════╦══════════════╦════════╦════════╗
║ # ║   Family   ║ flexspi_nor ║ xspi_nor ║ flexspi_nand ║ semc_nor ║ semc_nand ║   spi_nor    ║  mmc   ║   sd   ║
╠═══╬════════════╬═════════════╬══════════╬══════════════╬══════════╬═══════════╬══════════════╬════════╬════════╣
║ 0mimxrt1189[1, 2]N/A[1, 2]YesYes[1, 2, 4, 5][1, 2][1, 2] ║
╚═══╩════════════╩═════════════╩══════════╩══════════════╩══════════╩═══════════╩══════════════╩════════╩════════╝
List of all known memory configuration option words:
╔════╦══════╦══════════════════════╦══════════════╦═════════════╦════════════════════════════════════╦════════╗
║ #  ║ Type ║         Name         ║ Manufacturer ║  Interface  ║ Option words                       ║ Tested ║
╠════╬══════╬══════════════════════╬══════════════╬═════════════╬════════════════════════════════════╬════════╣
║ 0norW25QxxxJVWinbondquad_spiOpt0: 0xC0000207                   ║        ║
║ 1norW35T51NWWinbondoctal_spiOpt0: 0xC0603005                   ║        ║
║ 2norMX25Uxxx32FMacronixquad_spiOpt0: 0xC0000007*    ║
║ 3norMX25Lxxx45GMacronixquad_spiOpt0: 0xC0000007*    ║
║ 4norMX25UMxxx45GMacronixoctal_spiOpt0: 0xC0403037                   ║        ║
║ 5norMX66UMxxx45GMacronixoctal_spiOpt0: 0xC0403037                   ║        ║
║ 6norMX25LMxxx45GMacronixoctal_spiOpt0: 0xC0403037                   ║        ║
║ 7norMX25UM51345GMacronixoctal_spiOpt0: 0xC0403037                   ║        ║
║ 8norMX25UM51345G_2ndMacronixoctal_spiOpt0: 0xC1503051, Opt1: 0x20000014 ║        ║
║ 9norGD25QxxxCGigaDevicequad_spiOpt0: 0xC0000406                   ║        ║
║ 10norGD25LBxxxEGigaDevicequad_spiOpt0: 0xC0000007                   ║        ║
║ 11norGD25LTxxxEGigaDevicequad_spiOpt0: 0xC0000008                   ║        ║
║ 12norGD25LXxxxEGigaDevicequad_spiOpt0: 0xC0603008                   ║        ║
║ 13norIS25LPxxxAISSIquad_spiOpt0: 0xC0000007                   ║        ║
║ 14norIS25WPxxxAISSIquad_spiOpt0: 0xC0000007                   ║        ║
║ 15norIS25LXxxxISSIoctal_spiOpt0: 0xC0603005                   ║        ║
║ 16norIS25WXxxxISSIoctal_spiOpt0: 0xC0603005                   ║        ║
║ 17norIS26KSxxxSISSIhyper_flashOpt0: 0xC0233007                   ║        ║
║ 18norIS26KLxxxSISSIhyper_flashOpt0: 0xC0233007                   ║        ║
║ 19norMT25QLxxxAMicronquad_spiOpt0: 0xC0000007                   ║        ║
║ 20norRW303-MT35XUxxxABA1GMicronoctal_spiOpt0: 0xC0603005                   ║        ║
║ 21norRW304-MT35XUxxxABA2GMicronoctal_spiOpt0: 0xC0633005                   ║        ║
║ 22norMT28EW128ABAMicronparallelOpt0: 0xD0000600                   ║        ║
║ 23norMT28UG128ABAMicronparallelOpt0: 0xD0000601                   ║        ║
║ 24norAT25SFxxxAAdestoquad_spiOpt0: 0xC0000007                   ║        ║
║ 25norATXPxxxAdestooctal_spiOpt0: 0xC0803007                   ║        ║
║ 26norS25FSxxxSCypressquad_spiOpt0: 0xC0000007                   ║        ║
║ 27norS25FLxxxSCypressquad_spiOpt0: 0xC0000007                   ║        ║
║ 28norS26KSxxxSCypresshyper_flashOpt0: 0xC0233007                   ║        ║
║ 29norS26KLxxxSCypresshyper_flashOpt0: 0xC0233007                   ║        ║
║ 30norSST26VFxxxBMicrochipquad_spiOpt0: 0xC0000005                   ║        ║
║ 31norFM25QxxxFudanMicroquad_spiOpt0: 0xC0000205                   ║        ║
║ 32norBY25QxxxBSBoyaMicroquad_spiOpt0: 0xC0000405                   ║        ║
║ 33norXM25QHxxxBXMCquad_spiOpt0: 0xC0000007                   ║        ║
║ 34norXM25QUxxxBXMCquad_spiOpt0: 0xC0000007                   ║        ║
║ 35norX25FxxxBXTXtechquad_spiOpt0: 0xC0000407                   ║        ║
║ 36norX25QxxxDXTXtechquad_spiOpt0: 0xC0000407                   ║        ║
║ 37norP25QxxxLEPuyaquad_spiOpt0: 0xC0000405                   ║        ║
║ 38norP25QxxxHPuyaquad_spiOpt0: 0xC0000405                   ║        ║
║ 39norP25QxxxUPuyaquad_spiOpt0: 0xC0000405                   ║        ║
║ 40norA25LQxxxAMICquad_spiOpt0: 0xC0000105                   ║        ║
╚════╩══════╩══════════════════════╩══════════════╩═════════════╩════════════════════════════════════╩════════╝
║ 41nandW25N01GWinbondquad_spiOpt0: 0xC1010026, Opt1: 0x000000EF ║        ║
║ 42nandW25N02KWinbondquad_spiOpt0: 0xC1020026, Opt1: 0x000000EF ║        ║
║ 43nandMX35UF1GMacronixquad_spiOpt0: 0xC1010026, Opt1: 0x000000C2 ║        ║
║ 44nandMX35LF1GMacronixquad_spiOpt0: 0xC1010026, Opt1: 0x000000C2 ║        ║
║ 45nandMX35UF2GMacronixquad_spiOpt0: 0xC1020026, Opt1: 0x000000C2 ║        ║
║ 46nandMX35LF2GMacronixquad_spiOpt0: 0xC1020026, Opt1: 0x000000C2 ║        ║
║ 47nandGD5F1GQ5GigaDevicequad_spiOpt0: 0xC1010026, Opt1: 0x000000C8 ║        ║
║ 48nandGD5F2GQ5GigaDevicequad_spiOpt0: 0xC1020026, Opt1: 0x000000C8 ║        ║
║ 49nandMT29F1G01AAMicronquad_spiOpt0: 0xC1011022, Opt1: 0x0000002C ║        ║
║ 50nandMT29F2G01AAMicronquad_spiOpt0: 0xC1021022, Opt1: 0x0000002C ║        ║
║ 51nandPN26Q01AParagonquad_spiOpt0: 0xC1010026, Opt1: 0x000000A1 ║        ║
║ 52nandPN26G01AParagonquad_spiOpt0: 0xC1010026, Opt1: 0x000000A1 ║        ║
║ 53nandPN26Q02AParagonquad_spiOpt0: 0xC1020026, Opt1: 0x000000A1 ║        ║
║ 54nandPN26G02AParagonquad_spiOpt0: 0xC1020026, Opt1: 0x000000A1 ║        ║
╚════╩══════╩══════════════════════╩══════════════╩═════════════╩════════════════════════════════════╩════════╝
║ 55sd1bit_sdr12Generalinstance_0Opt0: 0xD0000000                   ║        ║
║ 56sd1bit_sdr12Generalinstance_1Opt0: 0xD0000001                   ║        ║
║ 57sd1bit_sdr12Generalinstance_2Opt0: 0xD0000002                   ║        ║
║ 58sd1bit_sdr12Generalinstance_3Opt0: 0xD0000003                   ║        ║
╚════╩══════╩══════════════════════╩══════════════╩═════════════╩════════════════════════════════════╩════════╝

Since we’re using the EVK, we are interested in the default FlexSPI NOR from Winbond on interface index 1:

╔════╦══════════╦═════════════╦══════════════╦══════════╦═══════════╦════════════════════╦════════╦════════╗
║ #  ║  Family  ║ flexspi_nor ║ flexspi_nand ║ semc_nor ║ semc_nand ║      spi_nor       ║  mmc   ║   sd   ║
╠════╬══════════╬═════════════╬══════════════╬══════════╬═══════════╬════════════════════╬════════╬════════║
║ 15 ║  rt118x  ║    [1, 2]   ║    [1, 2]    ║   Yes    ║    Yes    ║ [0, 1, 2, 3, 4, 5] ║ [0, 1] ║ [0, 1] ║
╚════╩══════════╩═════════════╩══════════════╩══════════╩═══════════╩════════════════════╩════════╩════════╝

╔════╦══════════════╦══════════════╦══════════════════════╦═════════════╦════════════════════════════════════╗
║ #  ║  Peripheral  ║ Manufacturer ║         Name         ║  Interface  ║ Option words                       ║
╠════╬══════════════╬══════════════╬══════════════════════╬═════════════╬════════════════════════════════════╣
║ 0  ║ flexspi_nor  ║   Winbond    ║      W25QxxxJV       ║   quad_spi  ║ Opt0: 0xC0000207                   ║
╚════╩══════════════╩══════════════╩══════════════════════╩═════════════╩════════════════════════════════════╝

Note that if you use this approach, you will configure your memory with the default option words shown in the table.

Now we can set the options according to the table:

  • f: device family => mimxrt1189

  • m: memory chip => W25QxxxJV

  • i: memory interface => quad_spi

  • ix: peripheral instance index => 1

%! nxpmemcfg blhost-script -f mimxrt1189 -m W25QxxxJV -p flexspi_nor -i quad_spi -ix 1 -o $CFG_MEM_FILE --force --fcb $FCB_FILE

assert os.path.exists(CFG_MEM_FILE)
nxpmemcfg blhost-script -f mimxrt1189 -m W25QxxxJV -p flexspi_nor -i quad_spi -ix 1 -o workspace/config_mem.bls --force --fcb workspace/fcb.bin 
Loaded option words: Opt0: 0xC0000007
WARNING:spsdk.memcfg.memcfg:FCB block read back script has been generated. Be aware that s 4KB block at base address will be erased to avoid cumulative write! (355ms since start, memcfg.py:434)
Exported blhost script.

Let’s look inside the blhost-script:#

# BLHOST configure memory programming script
# Generated by SPSDK NXPMEMCFG tool
# Chip: mimxrt1189
# Peripheral: flexspi_nor
# Instance: 1

# Switch the instance of the peripheral to 1:
fill-memory 0x1FFE0000 4 0xCF900001
configure-memory 9 0x1FFE0000

# Configure memory:
# Option word 0: 0xC0000207
fill-memory 0x1FFE0000 4 0xC0000207
configure-memory 9 0x1FFE0000

# Script to erase FCB location, create FCB and read back a FCB block:
flash-erase-region 0x28000000 0x1000
fill-memory 0x1FFE0000 4 0xF000000F
configure-memory 9 0x1FFE0000
read-memory 0x28000400 0x200 workspace/fcb.bin


4. Execute the blhost script#

The blhost script is used to configure the memory controller and initialize the external memory on the i.MX RT1180 EVK board. The script utilizes the NXP MCU Bootloader Host (blhost) tool to communicate with the target device over a serial or USB connection. Due to request to get FCB block, the script will erase the first memory block, generate a new FCB by BLHOST command and read back the FCB block to file.

# The board must be in SDP mode
# Configure Boot Mode Switch to : 1/2/3-OFF, 4-ON
# Connect micro USB cable into USB OTG1         - J33
# Connect micro USB cable into Debug USB Port   - J53

# FLASHLOADER_FILE = "../flashloader/ahab/workspace/flashloader.bin"  # Path to Flashloader
# CFG_MEM_FILE = WORKSPACE + "config_mem.bls"                         # Configure memory template
# FCB_FILE = WORKSPACE + "fcb.bin"                                    # Firmware Configuration block file

# COMPAR = "-u"                          # USB
# BLHOST_CONNECT_ROM = "0x1fc9,0x014c"   # PID/VID of ROM
# BLHOST_CONNECT_FLDR = "0x15A2,0x0073"  # PID/VID of NXP Flashloader

# Execute the commands generated by "blhost-script". This script will configure flash,
# program FCB into the external memory and reads back the binary data. Be aware tha erase of the first sector must be done.
# The script can be executed only once to read FCB.
%! blhost $COMPAR $BLHOST_CONNECT_FLDR batch $CFG_MEM_FILE
blhost -u 0x15A2,0x0073 batch workspace/config_mem.bls 
Response status = 0 (0x0) Success.
Response status = 0 (0x0) Success.
Response status = 0 (0x0) Success.
Response status = 0 (0x0) Success.
Response status = 0 (0x0) Success.
Response status = 0 (0x0) Success.
Response status = 0 (0x0) Success.
Reading memory
Response status = 0 (0x0) Success.
Response word 1 = 512 (0x200)
Read 512 of 512 bytes.

5. Create a non-default memory configuration#

The nxpmemcfg get-templates sub-command generates YAML configuration templates that serve as a starting point for customization. These templates can be easily modified to meet specific memory configuration requirements for the MIMXRT1189 microcontroller.

%! nxpmemcfg get-templates
nxpmemcfg get-templates 
Usage: nxpmemcfg get-templates [OPTIONS]

  Create template of Memory option words in YAML format.

Options:
  -f, --family [lpc5502|lpc5504|lpc5506|lpc5512..., and more. Use 'get-families' command to show all.]
                                  Select the chip family.
  -o, --output DIRECTORY          Path to a directory, where to store
                                  generated/parsed files.  [required]
  --force                         Force overwriting of existing files.
  --help                          Show this message and exit.

5.1 Let’s inspect the flexspi_nor template#

Let’s examine the flexspi_nor template. When inspecting this template, it’s important to note that the ‘each’ value can be modified using the options provided in the comments. Additionally, if a configuration line is removed, the default value will be automatically applied. These features provide flexibility in customization while ensuring that the configuration remains functional by falling back to default values when necessary.

# Show the typical external memory configuration for FlexSPI and NOR
YamlDiffWidget("inputs/rt118x_external_memory_config.diffc").html
nxpmemcfg get-templates -f mimxrt1189 -o workspace/cfg_opt_templates/ --force
The Memory Configuration template for mimxrt1189 has been saved into workspace/cfg_opt_templates YAML file
The Memory Configuration template for mimxrt1189 has been saved into workspace/cfg_opt_templates YAML file
The Memory Configuration template for mimxrt1189 has been saved into workspace/cfg_opt_templates YAML file
The Memory Configuration template for mimxrt1189 has been saved into workspace/cfg_opt_templates YAML file
The Memory Configuration template for mimxrt1189 has been saved into workspace/cfg_opt_templates YAML file
The Memory Configuration template for mimxrt1189 has been saved into workspace/cfg_opt_templates YAML file
The Memory Configuration template for mimxrt1189 has been saved into workspace/cfg_opt_templates YAML file

Configuration Differences

Once the template is configured for the new memory, it can be used to export a blhost script with nxpmemcfg blhost-script like this:

%! nxpmemcfg blhost-script -c "inputs/ow_flexspi_nor.yaml" -ix 1 -o $CUSTOM_CFG_MEM_FILE --force
nxpmemcfg blhost-script -c inputs/ow_flexspi_nor.yaml -ix 1 -o --force
Exported blhost script.

Let’s inspect the blhost-script generated from the flexspi_nor template (note the difference in the option word):

# BLHOST configure memory programming script
# Generated by SPSDK NXPMEMCFG tool
# Chip: mimxrt1189
# Peripheral: flexspi_nor
# Instance: 1

# Switch the instance of the peripheral to 1:
fill-memory 0x1FFE0000 4 0xCF900001
configure-memory 9 0x1FFE0000

# Configure memory:
# Option word 0: 0xC0000000
fill-memory 0x1FFE0000 4 0xC0000000
configure-memory 9 0x1FFE0000

6. Build a bootable image#

Load it into a memory configured though the blhost-script.

This process is explained in the Secure Boot notebook