NXP officially launched SBL and SFW for RT bootloader, which can well meet the requirements for secondary bootloader in regular use. Such as ISP, OTA, encryption and other functions. For specific SBL/SFW situations, you can view the application notes:
https://www.nxp.com/docs/en/user-guide/MCUOTASBLSFWUG.pdf
This article is mainly based on SBL and uses the ISP method to download user apps. Recently I encountered a case about RT1170 using the SBL ISP function to download APP. After configuring SBL, there is no problem in downloading simple SDK codes such as led_blinky and helloword. However, if you download the SDK GUI demo, such as vglite_examples\vector_freertos code, we find that the boot fails . The same applies to operations such as app offset, and the code size does not exceed 1MByte. However, SDK GUI demo uses SDRAM, so we speculated that it is related to SBL's SDRAM enablement. This article will explain how to use SBL ISP to download an app with SDRAM and make it boots OK.
Firstly, Download SBL source code and unzip it:
https://github.com/nxp-mcuxpresso/sbl
Download the ARM GCC and install it, here is the gcc-arm-none-eabi-9-2019-q4-major-win32.exe link:
The install path is:
C:\Program Files (x86)\GNU Tools Arm Embedded\9 2019-q4-major\bin
Open \sbl-master\target\evkmimxrt1170\ sblprofile.py, modify EXEC_PATH to the new installed ARM_GCC path:
EXEC_PATH = r'C:\Program Files (x86)\GNU Tools Arm Embedded\9 2019-q4-major\bin'
This is the SBL configuration steps:
(1). Open \sbl-master\target\evkmimxrt1170\ env.bat
input:
scons –menuconfig
Fig 1
(2). Configure Single image OTA
MCU SBL core->[*]Enable single image function
Fig 2
(3) Configure enable SDRAM
Fig 3
Fig 4
Fig 5
After configuration, save the .config file, save and exit it.
Fig 6
(4) Generate the sbl iar project
In the window, input:
scons --ide=iar
Then use IAR IDE to open \sbl-master\target\evkmimxrt1170\iar\sbl.eww
You can see, the SDRAM DCD has been added now:
Fig 7
(5) Configure the secure information
Input the following command in the commander window:
cd ..\..\component\secure\mcuboot\scripts
Switch the commander path, then use the following command to generate the pub key and private key:
python imgtool.py keygen -k xxxx_priv.pem -t rsa-2048-sign
python imgtool.py getpub -k xxxx_priv.pem -o xxxx_pub.pem -t sign
Fig 8
Open the file in path:sbl-master\component\secure\mcuboot\scripts\ xxxx_pub.c, copy the pub key information, and replay it to the file in path:
\sbl-master\component\secure\mcuboot\sign-rsa2048-pub.c
Then, it will update the SBL pub key information, now open the IAR project:
\sbl-master\target\evkmimxrt1170\iar \sbl.eww
Build the project, and use the debugger to download the SBL code to the MIMXRT1170-EVK board, I use the EVK on board debugger CMSIS DAP to download the sbl code.
This document app is using the MCUXpresso IDE to import the SDK project: evkmimxrt1170_vector_freertos_cm7
Configure the flash start location to offset address:0X30100400
Fig 9
Delete the FCB and DCD header like this:
Fig 10
Build the project, and generate the bin file:evkmimxrt1170_vector_freertos_cm7.bin, copy it to the SBL folder:
sbl-master\component\secure\mcuboot\scripts
Still in the commander window which you open the env.bat after you change the path previously:
python imgtool.py sign --key xxxx_priv.pem --align 4 --version "1.1" --header-size 0x400 --pad-header --slot-size 0x100000 --max-sectors 32 evkmimxrt1170_vector_freertos_cm7.bin app2.bin
This will help the app to add the header which matches the SBL requirement, and generate the app2.bin, which is the used app downloading file.
After the above configuration, it already downloads the SBL to the MIMXRT1170-EVK, and prepares the used app which contains the SDRAM, now use the MCUBootutility tool to download the app2.bin.
Fig 11
Note, the Tools->Run Mode, should be SBL OTA mode.
Find another USB cable to connect the EVK SDP J20 to the PC, after the EVK board reset, within the 5 seconds, connect the board by connection the MCUBootutility button “connect to SBL ISP”, then in the Fig 11, step 4, add the prepared app2.bin, step 3, input the address to: 0X30100000, then use step 5 to download the app.
After app is downloaded, reset and exit the connection. Reset the board, wait 5 seconds, you will find the LCD can display the figure, it means the GUI code is working, and the printf log is:
Fig 12
The board displays the result like this:
Fig 13
At this point, the app with SDRAM has been successfully run in combination with SBL, indicating that the configuration of SBL with SDRAM is successful.