We are not using the OTFAD mode. We are using "Encrypted + Signed" mode which is NOT supported by the Secure Provisioning Tool, but IS supported by elftosb.exe. We use this mode because we are using external PSRAM.
As you can see from these lines in the json config file (provided with my last post):
"outputImageExecutionTarget": "RAM",
Indicates that our image will be copied to On Chip RAM from Flash by the bootloader.
"outputImageAuthenticationType": "Encrypted + Signed",
Indicates that our image will also be decrypted entirely in RAM...not On The Fly.
"inputImageFile": "C:/nxp_files/extram_loader.bin",
"multicoreImages": [
{"address": "0x08000000", "file": "C:/nxp_files/RT685EVK.bin"}
],
Indicates that our final image is a combination of two images: the extram_loader.bin and RT685EVK.bin (our application image). The extram_loader is the image created by NXP's sample project, evkmimxrt685_mpi_loader_extram_loader. Once the combined image is copied to On Chip RAM and decrypted by the bootloader, the extram_loader runs and copies the RT685EVK.bin (our app) to external PSRAM, and then executes it from PSRAM. So we are not using OTFAD mode since that mode is only allowed when running XIP out of Flash, as far as we know. (is that true? If there is a way to use OTFAD mode when running out of external RAM, that would be good to know.)
So all that seems to work for a small application. In the beginning to test the "Encrypted + Signed" mode, I created a very small app to just flash some leds, and this was decrypted correctly by the bootloader, and the app executed perfectly. But when we tried our actual app which is much larger (1200KB vs. 120KB), we discovered that the combined image was correctly copied to On Chip RAM by the bootloader, but the image was NOT decrypted correctly.
We put a breakpoint at the beginning of the extram_loader, so that we could see what was done in the On Chip RAM. We saw that the image was correctly decrypted up to an arbitrary address. This address changed anytime we rebuilt the combined image (note that each build uses a different AES256 Init Vector), but the address always was on a 16 byte boundary. After this address, the decryption was incorrect, until the cert table. Again, the values after this address did NOT MATCH the values of the original encrypted combined image (image programmed into Flash), so it looks like the bootloader attempted to decrypt those values, but somehow came up with the wrong decrypted values.
So it looks like the bootloader attempts to decrypt the entire image. But there is always a point were the decryption fails and the decryption results are incorrect until the cert table.
You asked for a picture of this:
In the attached, you see on the left is the exported memory from OCRAM which should be completely decrypted. In the center is the image before encryption. These two should match, and they match up to 0x6A210, but afterwards they do not. On the right is the encrypted image. Note that the OCRAM DOES NOT match the encrypted image after 0x6A210. If the decryption was just ending prematurely, then the OCRAM should match the encrypted image after 0x6A210, but this is not the case.
Just the image has decryption issues. The cert table and everything after are not encrypted, so no decryption is needed
I did not test hello world program because I already tested a small app which was decrypted correctly and executed as expected.
Thanks. Hope that answers all you questions.