How to use nxpimage to generate .sb file from .bin file?

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

How to use nxpimage to generate .sb file from .bin file?

Jump to solution
563 Views
mbora
Contributor III

Hi,

in my project I use elftosb tool with kinetis option, like this:

elftosb -f kinetis -V -c .\path_to_bd_file.bd -o .\out_image.sb .\my_bin_file.bin

but, since elftosb is deprecated by nxpimage, I tried to use it the same way before

mbora_0-1711095780479.png

nxpimage sb21 export -c .\path_to_bd_file.bd -o .\out_image.sb .\my_bin_file.bin

but i get error:

GENERAL ERROR: KeyError: 'options'

 

I already asked for help here: https://community.nxp.com/t5/i-MX-RT/Specific-bytes-at-the-beginning-of-binary-file-don-t-allow-to/m..., but no one was able to help, that's why I created another question, that's more focused on how nxpimage should be used to replace elftosb.

Thanks

0 Kudos
1 Solution
490 Views
nxf46245
NXP Employee
NXP Employee

I have checked the other thread https://community.nxp.com/t5/i-MX-RT/Specific-bytes-at-the-beginning-of-binary-file-don-t-allow-to/m... and from the attached screenshot it seems

nxf46245_0-1711112262991.png

that first command is fill memory with configuration word for flex SPI configuration

blhost -p <com> fill-memory 0x2000 4 0xC0000106 word

second command is to enable this configuration

blhost -p <com> -- configure-memory 9 0x2000

third command is flash-erase regions 0...0x1e000

blhost -p <com> flash-erase-region 0x60000000 0x1e000 9

and the last command is load to memory

blhost -p <com> write-memory 0x60000000 <your binary file>

 

Please note, that flashloader must be running in target in order to execute these commands.

   sdphost -p <com>  -j -- write-file 0x20001C00 <path to flashloader bin>

    sdphost -p <com> -j -- jump-address 0x20001C00

 

Or check the SEC tool, which does it all for you. 

 

View solution in original post

10 Replies
485 Views
marek-trmac
NXP Employee
NXP Employee

Maria,

can you describe the use case? Why do you need the SB file? Why cannot you use script with list of blhost commands?

We'd like to understand your problem in the context, so we can help.

Regards,
Marek
0 Kudos
543 Views
marek-trmac
NXP Employee
NXP Employee

Hi Maria,

I'd recommend to use MCUXpresso Secure Provisioning tool and build a signed image. The tool will generate build script and all configuration file needed for you.

However, in case your question is specific for i.MX RTxxxx processors, the SB files are not supported in MCUXpresso Secure Provisioning tool yet. I'm not sure about nxpimage.

Regards,
Marek
0 Kudos
418 Views
mbora
Contributor III
Hi Marek,
I need to generate SB flashloader script with included unencrypted unsigned binary. Script is supposed to setup flash memory, then download and run the binary from flash. I don't want to build a signed image.
0 Kudos
412 Views
marek-trmac
NXP Employee
NXP Employee

Hi Maria,

Why cannot you use script (*.bat or *.sh) with list of blhost commands?

Regards,
Marek
0 Kudos
406 Views
mbora
Contributor III
I use them.
https://spsdk.readthedocs.io/en/latest/apps/blhost.html#blhost-receive-sb-file
This command requires a generated SB file, but I fail to generate one.
elftosb works in most cases, but as I described in my other topic, not in all. That's why I'm looking for an alternative for it.
Regards,
Maria
0 Kudos
400 Views
marek-trmac
NXP Employee
NXP Employee

Hi Maria,

I still do not understand, why the SB file is used. For all SB file commands, there exists a command in `blhost`. You can create simple script, that will do the same as SB file, just using other blhost commands like erase and write. You can use MCUXpresso Secure Provisioning Tool to generate the script for you. And big advantage is - it is much easier for maintenance, you can see response from the processor for each command and if it fails, you know the command where the problem is. 

From your description I do not see any reason to use SB file.

Regards,
Marek
373 Views
mbora
Contributor III
Hi Marek,
thanks, you helped me understand what I can do. The answer I marked as a solution worked. I still wonder why elftosb failed with this specific bytes configuration, but I guess this will stay a secret :).
Many thanks to both of you!
Regards,
Maria
0 Kudos
523 Views
mbora
Contributor III
Hi, thanks for the quick response.
So, this error probably occurs because I set output file as .sb file?
Could you suggest me another alternative to elftosb that would work in this case?
I'm not looking for any tool that would build me a signed image. I'm just looking for a tool that would work just as elftosb, since this is deprecated. I wouldn't switch, but according to my other topic (in the link), I guess I have to
Maria
0 Kudos
498 Views
nxf46245
NXP Employee
NXP Employee
Hello Maria,

what you are trying to achieve is building a Secure Binary 1.0 file which is unsigned and unencrypted file that contains
commands for flashloader to program the target device (It is not secure as the name say) The commands are equivalent to the commands in blhost, so you might try executing the commands in blhost directly.
It usually contains configuration of the external memory (Configure and fill command) and load of HAB to the memory.

Building of SB 1.0 file is not supported directly by NXPIMAGE tool. However, if that is really your usecase you can use SPSDK API to build the SB 1.0 (spsdk/sbfile/sb1/images.py).

If you want to create image that is able to boot from external flash memory, you can use the nxpimage bootable-image application.
This tool generates bootable image that contains FCB block, BEE encryption headers (optional) and HAB container. That is all what you need to boot from external flash memory.
 
Example of bootable image configuration:


# ================================ Bootable Image Configuration template for rt105x. =================================

# ======================================================================================================================

# == General Options ==

# ======================================================================================================================

# ------------------------------------------===== MCU family [Required] =====-------------------------------------------

# Description: MCU family name.

# Possible options: <lpc55s3x, rt101x, rt102x, rt104x, rt105x, rt106x, rt116x, rt117x, rt118x, rt5xx, rt6xx, rw61x>

family: rt105x

# -------------------------------------===== Chip silicon revision [Optional] =====-------------------------------------

# Description: If needed this could be used to specify silicon revision of device.

# Possible options: <a0, latest>

revision: latest

# ------------------------------------------===== Memory type [Required] =====------------------------------------------

# Description: Specify type of memory used by bootable image description.

# Possible options: <flexspi_nor>

memory_type: flexspi_nor

# ======================================================================================================================

# == Bootable Segments definition ==

# ======================================================================================================================

# ----------------------------------------===== FCB block path [Optional] =====-----------------------------------------

# Description: Flash Configuration block Image path. It could be used as pre-prepared binary form of FCB and also YAML

# configuration file for FCB. In case that YAML configuration file is used, the Bootable image tool build the FCB

# itself.

fcb: fcb.bin

# ------------------------------------===== BEE encryption header 0 [Optional] =====------------------------------------

# Description: BEE encryption header 0 path

bee_header_0: bee_header_0.bin

# ------------------------------------===== BEE encryption header 1 [Optional] =====------------------------------------

# Description: BEE encryption header 1 path

bee_header_1: bee_header_1.bin

# ======================================================================================================================

# == Executable Segment definition ==

# ======================================================================================================================

# -----------------------------------------===== HAB container [Required] =====-----------------------------------------

# Description: HAB container image path. It could be used as pre-prepared binary form of HAB and also YAML configuration

# file for HAB. In case that YAML configuration file is used, the Bootable image tool build the HAB itself.

hab_container: hab_container.yaml
Marek

0 Kudos
491 Views
nxf46245
NXP Employee
NXP Employee

I have checked the other thread https://community.nxp.com/t5/i-MX-RT/Specific-bytes-at-the-beginning-of-binary-file-don-t-allow-to/m... and from the attached screenshot it seems

nxf46245_0-1711112262991.png

that first command is fill memory with configuration word for flex SPI configuration

blhost -p <com> fill-memory 0x2000 4 0xC0000106 word

second command is to enable this configuration

blhost -p <com> -- configure-memory 9 0x2000

third command is flash-erase regions 0...0x1e000

blhost -p <com> flash-erase-region 0x60000000 0x1e000 9

and the last command is load to memory

blhost -p <com> write-memory 0x60000000 <your binary file>

 

Please note, that flashloader must be running in target in order to execute these commands.

   sdphost -p <com>  -j -- write-file 0x20001C00 <path to flashloader bin>

    sdphost -p <com> -j -- jump-address 0x20001C00

 

Or check the SEC tool, which does it all for you.