Unable to Deploy binary built in MCUXpresso via BL host

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

Unable to Deploy binary built in MCUXpresso via BL host

1,286 Views
mrichardson23
Contributor IV

I have an RT685 that I am attempting to deploy a binary on using the blhost scripts that communicate with the ROM bootloader.  I need to build multiple binaries for demo purposes.  I have been able to successfully deploy binaries that are provided by with the provisioning tool kit by NXP, but I have been unable to deploy binaries using the blhost tool that were built in either the MCUXpresso IDE or in VS Code using the MCUXpresso tool.  Can anyone give me some guidance on this?

Thanks.

Labels (1)
Tags (3)
0 Kudos
Reply
4 Replies

1,236 Views
mrichardson23
Contributor IV

@diego_charles It looks like the build_sb command might be my ticket to fixing this situation.  Can you provide guidance on how to build a secure boot image for the RT685 evaluation kit from and axf or 19 file that is built in the MCUXpresso environment?

0 Kudos
Reply

1,118 Views
diego_charles
NXP TechSupport
NXP TechSupport

Hi @mrichardson23 

Thanks a lot for your patience. I am sorry for the delay, let me provide you my reply.

To generate a signed image using MCUXpresso. Build the image without the FCB ( BOOT_HEADER_ENABLE=0). Then compile the image and generate a binary from the axf file. The MCUXpresso Secure Provisioning Tool is the provisioning tool to convert this raw binary image into a signed bootable image. Refer to MCUXSPTUG ( for SPTv8.0) sections 6.6.3.2 Booting signed image using shadow registers or  6.6.3.4 Booting signed/encrypted image – burn fuses depending if you want to use shadow registers or fuses, which are recommended for production. 

If you have any further questions, do not hesitate to let me know.

Best regards, 

Diego

0 Kudos
Reply

1,269 Views
mrichardson23
Contributor IV

Hello @diego_charles,

So I think I understand why, now I am trying to figure out how to fix this.  So, a standard build will create an image for the entire space - this includes the space reserved for the fcb (offset at 0x400) as well as the version (offset 0x600).  The image itself is stored in flash at offset 0x1000.  I was writing to 0x1000.  I am not using the image which is generated via the flash_release script which starts at an offset of 0x400 (the image will include the fcb).  However, when I try to write this image via the write_memory command, I get the error "WriteMemory interrupted -> Memory Cumulative Write".  I am obviously missing something.  My script for this is:

from spsdk.mboot.interfaces.uart import MbootUARTInterface
from spsdk.mboot.mcuboot import McuBoot, McuBootCommandError, StatusCode

# Bootloader ROM uses FC0 pins 0_1 (Tx) and 0_2 (Rx) for UART
interfaces = MbootUARTInterface.scan(port="/dev/ttyACM0", baudrate=921600)

# Assumes only one interface really...
for interface in interfaces:
    # Raise an exception when there is an McuBootCommandError
    with McuBoot(interface, True) as mb:

# 22444
        try:
            # If memory is unconfigured, we will not be able to be erase and
            # an exceptionwill be thrown
            mb.flash_erase_region(0x08000000, 32000, 9)
        except McuBootCommandError as e:
            mb.fill_memory(0x0010C000, 4, 0xC1503057)
            mb.fill_memory(0x0010C004, 4, 0x20000000)
            mb.configure_memory(0x10c000, 9)
            mb.flash_erase_region(0x08000000, 32000, 9)

            mb.fill_memory(0x0010C000, 4, 0xF000000F)
            mb.configure_memory(0x10c000, 9)

            fcb = mb.read_memory(0x08000400, 0x200, )

            for i in range(0, len(fcb), 16):
                line = fcb[i:i+16]
                hex_line = ' '.join(f'{byte:02X}' for byte in line)
                print(hex_line)

            try:
                # with open(f"/home/mrichardson/secure_provisioning/gen_sb/image_version.bin", "rb") as f:
                #     # Version here is just
                #     img_version = f.read()
                #     works = mb.write_memory(0x08000600, img_version, 0)
                # with open(f"evkmimxrt685_led_blinky_ext_flash.bin", "rb") as f:
                with open(f"gpio_led_output.bin", "rb") as f:
                    img = f.read()
                    mb.write_memory(0x08000400, img, 0)

                # Reset MCU
                mb.reset(reopen=False)
            except McuBootCommandError as e:
                print(e)

and I am attaching my binary along with the srec.

Cheers, m

1,271 Views
diego_charles
NXP TechSupport
NXP TechSupport

Hi @mrichardson23 

It will be a pleasure to help! 

I understand that you want to generate an application binary then load it using BLHOST, with the MCU in serial downloader mode. The MCUXPresso Secure Provisioning Tool  ( SPT ) can make bootable the generated binary from MCUXpresso or VS code and call BLHOST commands to write that binary. You can later on take BLHOST commands from the SPT's output log and run then separetely.

To understand better,  could you give more details about  the error you are getting? Do you want to see how you can generate, for example, a led_blinky and  load it, to external flash memory, using BLHOST?

Best regards, 

Diego

0 Kudos
Reply