Specific bytes at the beginning of binary file don't allow to generate SB file

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

Specific bytes at the beginning of binary file don't allow to generate SB file

772 Views
mbora
Contributor III

Hello,

I try to generate SB file from BD file for memory programming. I used i.MX RT 1060 Manufacturing User's Guide and followed the instructions on how to do that.

Generally, it works, except one special word at the beginning of my binary input file. From what I have tested, the error only appears with specific pattern of the first two bytes.

My .bin files are generated from this pattern:

  • 4 bytes: my_variable
  • 4 bytes: 0x00
  • 1 byte: 0x0A
  • 3 bytes: 0x00
  • 217 bytes: random values, they don't really matter

When my my_variable has really any value, the script works as expected

mbora_0-1707233317641.png

Binary file when my_variable = 21300

mbora_1-1707233381998.png

But, when my_variable has value that follows this pattern (in little-endian):

0x53any number from range [0x30, 0x39]any number from range [0x00, 0xFE]any number from range [0x00, 0xFE]

script fails with error "error: invalid hex digit".

Example:

mbora_2-1707233478733.png

mbora_3-1707233507489.png

As you can see, the only thing that changes is the first 4 bytes. Also, what's important is that, first 8 bytes have to be followed by 

0A 00 00 00

for the script to fail.

I tried to upgrade my elftosb tool, but i failed to find a new one (https://community.nxp.com/t5/MCUXpresso-Secure-Provisioning/where-to-find-elftosb-sources/m-p/173185...).
Also, I know that elftosb was replaced by nxpimage, but as far as i know it doesn't support my target:

mbora_5-1707233744170.png

I tried reading this (https://spsdk.readthedocs.io/en/latest/apps/nxpimage.html#nxpimage-sb21) documentation but honestly, I can't find how to use this for my case.

 

My guess is that this particular byte configuration is read in some mysterious way, but I couldn't find any information about this. Here is a glimpse of some of the bytes that caused script to fail:

mbora_0-1708352133613.png

 

I attached my files. There are .bin files that you can use as i did. Change type of .txt file to .bd (i couldn't include .bd file).

 

Labels (1)
Tags (3)
0 Kudos
9 Replies

668 Views
diego_charles
NXP TechSupport
NXP TechSupport

Hi @mbora 

I hope that you are doing well.

The MCUXpresso Secure Provisioning tool  (SPT for short )v7.0 implements elftosb to generated signed  (HAB) images, v8 now implements nxpimage instead. The SPT v7.0 runs  elftosb 5.1.19. You could download our SPTv7.0 and take the elftosb.exe from there and test. 

diego_charles_0-1708635603587.png

I saw that you are using kinetis command , rather than  i.MX command when generating your SB file. Another thing is that I do not recognize your input binaries as raw i.MX RT application images, apparently,  you are working on a custom file, not a raw i.MX RT application image. This could limit our support ability for this scenario. Could you clarify? The SPT v7 or V8, should support you to generate signed images for High Assurance Boot (HAB)

Thanks for your patience. 

Diego

 

0 Kudos

647 Views
mbora
Contributor III
Hi, thanks for your reply.
Unfortunately, elftosb In version 5.1.19 fails too.
I am working on custom file. First 32 bits are my specific number, which works in most of the cases. The only pattern i noticed is that when binary file starts with 0x53, <0x30, 0x39> it always fails.
In ASCII it looks like these two signs cause the problem:
"S0", "S1", ... "S9"
I've been using my method of creating .bin file for a long time now, and it always worked, both with using HAB and not. The problem started to appear when I set the first four bytes to these numbers.
0 Kudos

640 Views
diego_charles
NXP TechSupport
NXP TechSupport

Hi @mbora 

Many thanks for your response!

I understand and thanks for your report. Since elftosb  is now deprecated, I can not compromise to solve this issue. If you are still willing to get an example of the use of nxpimage for SB2.1 please generate a signed image for the LPC55s69 with the SPT v8.0. Below an example.

nxpimage succeeded
### Create SB file ###
nxpimage sb21 export 	-c "C:\...\gen_sb\sb2_config.yaml" 	-o "C:\..\bootable_images\led_blinky_0x00000000.sb"
RKTH: 28ae2d68f21fd1c34f8f47ddd5c12c4b9f3d1baffa4d89eb1387307bc7cd8dcf
Success. 
(Secure binary 2.1: C:\...\bootable_images\led_blinky_0x00000000.sb created.)
nxpimage succeeded)

 I hope this could help you!

Diego

0 Kudos

595 Views
mbora
Contributor III
Hi @diego_charles,
I'm sorry but I don't quite get how to use 'export' function for my example. I would like to generate SB file based on binary file, not yaml. Do you have any other examples on how to do that?
Also, as you have noticed before, i used kinetis option so i don't understand why would I generate image for LPC55s69.
Maria
0 Kudos

591 Views
diego_charles
NXP TechSupport
NXP TechSupport

Hi Maria,


Thanks for your reply! the sb 21 export command generates a sb file using a config template (Generate Secure Binary v2.1 Image, according to documentation ) My apologies, I have not explained why I mentioned the LPC55s69, I showed this MCU since its signed images are in sb2.1 and that is it. Currently, I do not have more examples to show, rather than recommend you look at the SPT log output. I cannot guarantee that the nxpimage will be able to generate a sb for a custom binary. But feel free to test with our tools, to see if they work for you. Let me know if there is anything else I could do for you.

Diego

 

0 Kudos

572 Views
mbora
Contributor III

Hi Diego,

according to the documentation:

mbora_0-1709121605890.png

I should be able to use binary files. My .bd configuration file starts with:

mbora_1-1709121652679.png

thus, everything should work fine. But I come with an issue:

mbora_2-1709121715512.png

Could you tell me what the error means?

Thanks,

Maria

 

0 Kudos

472 Views
diego_charles
NXP TechSupport
NXP TechSupport

 

Hi Maria, 

I have not used this command before;  I presume that you may have been missing keys? Did you had success using the LPC55s69 example?

There is another tool that you might use. it is the image tool from the open source MCU bootloader project. I think this tool might also be a choice for you since, it is not specifically dedicated for NXP MCUs. We use the image tool for a project called SBL, please check to this command in the MCUOTASBLSFWUG

My apologies for the delay, I hope this could help.

Diego 

0 Kudos

467 Views
mbora
Contributor III
Hi Diego,
Could you ask another person from tech support to help me with this problem, since you haven't use it before?
Thanks,
Maria
0 Kudos

473 Views
mbora
Contributor III
Hi @diego_charles,
I would really appreciate it if you could help me.
Thanks,
Maria
0 Kudos