MCUXpresso Secure Provisioning Tool V3: Script failed with return code: [2]ERROR

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

MCUXpresso Secure Provisioning Tool V3: Script failed with return code: [2]ERROR

2,906 Views
microcris
Contributor III

Hello! 

I'm getting some trouble with Secure Provisioning running in text mode. It fails to flash the device with the following error:

GENERAL ERROR:unpack_from requires a buffer of at least 4 bytes for unpacking 4 bytes at offset 0 (actual buffer size is 2)
blhost failed
DEBUG: [src.utils.batchexecute] Execution took 2.3 seconds
Script failed with return code: [2]ERROR
Secure Provisioning Tool exited with an error. See above for errors.

 

 

Here it is the build command output:

/opt/nxp/MCUX_Provi_v3/bin/securep -v -w /home/cris/secure_provisioning/MIMXRT --device MIMXRT1064 --boot-device Winbond_W25Q32JV --boot-type unsigned build --source-image "/home/cris/workspace/Eclipse/i.MX/MIMXRT1064/Projects/SPACCC/Release/SPACCC.elf"
INFO: [root] workspace /home/cris/secure_provisioning/MIMXRT
INFO: [root] Loading settings from workspace: NO_SETTINGS
DEBUG: [src.logic.build.imageparser] ImageParser created: "/home/cris/workspace/Eclipse/i.MX/MIMXRT1064/Projects/SPACCC/Release/SPACCC.elf"
DEBUG: [src.logic.build.imageparser] image src=/home/cris/workspace/Eclipse/i.MX/MIMXRT1064/Projects/SPACCC/Release/SPACCC.elf in ImageFormat.ELF format
INFO: [src.logic.build.imageparser] Detected ARM ELF format
INFO: [src.logic.build.imageparser] Detected elf file build with MCUIDE
Executing script /home/cris/secure_provisioning/MIMXRT/gen_scripts/transform_image_lnx.sh
/opt/nxp/MCUX_Provi_v3/bin/tools/ide_utils/mcuxpresso/linux/amd64 ~
~
DEBUG: [src.utils.batchexecute] Execution took 0.0 seconds
DEBUG: [src.logic.build.imageparser] Converted ELF to S-Record format: /home/cris/secure_provisioning/MIMXRT/source_images/SPACCC.srec
Build script generated: build_image_lnx.sh
Build script generated: build_image_win.bat
Build script generated: build_image_mac.sh
Executing script /home/cris/secure_provisioning/MIMXRT/build_image_lnx.sh
mkdir: /opt/nxp/MCUX_Provi_v3/bin/libselinux.so.1: no version information available (required by mkdir)
/opt/nxp/MCUX_Provi_v3/bin/tools/elftosb/linux/amd64 ~
/opt/nxp/MCUX_Provi_v3/bin/tools/elftosb/linux/amd64/elftosb -f imx -V -c /home/cris/secure_provisioning/MIMXRT/bd_files/imx_application_gen_lnx.bd -o /home/cris/secure_provisioning/MIMXRT/bootable_images/SPACCC.bin /home/cris/secure_provisioning/MIMXRT/source_images/SPACCC.srec
~
Section: 0x0
iMX bootable image generated successfully
elftosb succeeded
DEBUG: [src.utils.batchexecute] Execution took 0.0 seconds
Image generated: bootable_images/SPACCC_nopadding.bin

And here it is the write command output:

/opt/nxp/MCUX_Provi_v3/bin/securep -v -w /home/cris/secure_provisioning/MIMXRT --device MIMXRT1064 --boot-device Winbond_W25Q32JV --boot-type unsigned --usb 0x1FC9 0x0135 write --source-image bootable_images/SPACCC_nopadding.bin
INFO: [root] workspace /home/cris/secure_provisioning/MIMXRT
INFO: [root] Loading settings from workspace: NO_SETTINGS
Read fuses script generated: gen_scripts/read_fuses_lnx.sh
Executing script /home/cris/secure_provisioning/MIMXRT/gen_scripts/read_fuses_lnx.sh
### Check presence of FlashLoader ###
/opt/nxp/MCUX_Provi_v3/bin/tools/spsdk ~
/opt/nxp/MCUX_Provi_v3/bin/tools/spsdk/blhost -u 0x15A2,0x0073 -j -- get-property 1 0
~
ERROR:SPSDK: Cannot find USB device '0x15a2:0x0073'
blhost failed
FlashLoader is not running yet, download and run it
### Check communication with target bootloader ###
/opt/nxp/MCUX_Provi_v3/bin/tools/spsdk ~
/opt/nxp/MCUX_Provi_v3/bin/tools/spsdk/sdphost -u 0x1FC9,0x0135 -j -- error-status
~
{
"command": "error-status",
"response": [
4042322160
],
"status": {
"description": "1450735702 (0x56787856) Hab Is Disabled (Unlocked)",
"value": 1450735702
}
}
sdphost succeeded, HAB disabled
### Write FlashLoader ###
/opt/nxp/MCUX_Provi_v3/bin/tools/spsdk ~
/opt/nxp/MCUX_Provi_v3/bin/tools/spsdk/sdphost -u 0x1FC9,0x0135 -j -- write-file 0x20000000 /opt/nxp/MCUX_Provi_v3/bin/data/targets/MIMXRT1064/ivt_flashloader.bin
~
Status (HAB mode) = 1450735702 (0x56787856) Hab Is Disabled (Unlocked).
sdphost succeeded, HAB disabled
### Start FlashLoader ###
/opt/nxp/MCUX_Provi_v3/bin/tools/spsdk ~
/opt/nxp/MCUX_Provi_v3/bin/tools/spsdk/sdphost -u 0x1FC9,0x0135 -j -- jump-address 0x20000400
~
Status (HAB mode) = 1450735702 (0x56787856) Hab Is Disabled (Unlocked).
sdphost succeeded, HAB disabled
### Waiting FlashLoader to be initialized for 3 seconds ###
### Timeout wait value can be adjusted from Preferences ###
### Check presence of BootLoader/FlashLoader ###
/opt/nxp/MCUX_Provi_v3/bin/tools/spsdk ~
/opt/nxp/MCUX_Provi_v3/bin/tools/spsdk/blhost -u 0x15A2,0x0073 -j -- get-property 1 0
~
{
"command": "get-property",
"response": [
1258422528
],
"status": {
"description": "0 (0x0) Success.",
"value": 0
}
}
blhost succeeded
### Read fuse: 0x460 ###
/opt/nxp/MCUX_Provi_v3/bin/tools/spsdk ~
/opt/nxp/MCUX_Provi_v3/bin/tools/spsdk/blhost -u 0x15A2,0x0073 -- efuse-read-once 0x6
~
Response status = 0 (0x0) Success.
Response word 1 = 4 (0x4)
Response word 2 = 8 (0x8)
blhost succeeded
### Success ###
DEBUG: [src.utils.batchexecute] Execution took 4.1 seconds
The following fuses status was detected:
Fuse request: 0x460 |= 0x0 (mask: 0x2); current value=0x8; status=MATCHES
SUMMARY: Detected status of fuses for write operation: all fuse(s) match with requested value(s)
Write script generated: write_image_lnx.sh
Write script generated: write_image_win.bat
Write script generated: write_image_mac.sh
Executing script /home/cris/secure_provisioning/MIMXRT/write_image_lnx.sh
### Parse input arguments ###
### Check presence of FlashLoader ###
/opt/nxp/MCUX_Provi_v3/bin/tools/spsdk ~
/opt/nxp/MCUX_Provi_v3/bin/tools/spsdk/blhost -u 0x15A2,0x0073 -j -- get-property 1 0
~
{
"command": "get-property",
"response": [
1258422528
],
"status": {
"description": "0 (0x0) Success.",
"value": 0
}
}
blhost succeeded
### Configure target memory using options on address 0x2000 ###
/opt/nxp/MCUX_Provi_v3/bin/tools/spsdk ~
/opt/nxp/MCUX_Provi_v3/bin/tools/spsdk/blhost -u 0x15A2,0x0073 -j -- fill-memory 0x2000 4 0xC0000007 word
~
{
"command": "fill-memory",
"response": [],
"status": {
"description": "0 (0x0) Success.",
"value": 0
}
}
blhost succeeded
/opt/nxp/MCUX_Provi_v3/bin/tools/spsdk ~
/opt/nxp/MCUX_Provi_v3/bin/tools/spsdk/blhost -u 0x15A2,0x0073 -j -- fill-memory 0x2004 4 0x00000000 word
~
{
"command": "fill-memory",
"response": [],
"status": {
"description": "0 (0x0) Success.",
"value": 0
}
}
blhost succeeded
/opt/nxp/MCUX_Provi_v3/bin/tools/spsdk ~
/opt/nxp/MCUX_Provi_v3/bin/tools/spsdk/blhost -u 0x15A2,0x0073 -j -- configure-memory 9 0x2000
~
{
"command": "configure-memory",
"response": [],
"status": {
"description": "0 (0x0) Success.",
"value": 0
}
}
blhost succeeded
### Erase memory before writing image ###
/opt/nxp/MCUX_Provi_v3/bin/tools/spsdk ~
/opt/nxp/MCUX_Provi_v3/bin/tools/spsdk/blhost -u 0x15A2,0x0073 -j -- flash-erase-region 0x70000000 61040 9
~
{
"command": "flash-erase-region",
"response": [],
"status": {
"description": "0 (0x0) Success.",
"value": 0
}
}
blhost succeeded
### Use tag 0xF000000F to notify FlashLoader to program FlexSPI NOR config block to the start of device ###
/opt/nxp/MCUX_Provi_v3/bin/tools/spsdk ~
/opt/nxp/MCUX_Provi_v3/bin/tools/spsdk/blhost -u 0x15A2,0x0073 -j -- fill-memory 0x3000 4 0xF000000F word
~
{
"command": "fill-memory",
"response": [],
"status": {
"description": "0 (0x0) Success.",
"value": 0
}
}
blhost succeeded
### Program configuration block ###
/opt/nxp/MCUX_Provi_v3/bin/tools/spsdk ~
/opt/nxp/MCUX_Provi_v3/bin/tools/spsdk/blhost -u 0x15A2,0x0073 -j -- configure-memory 9 0x3000
~
{
"command": "configure-memory",
"response": [],
"status": {
"description": "0 (0x0) Success.",
"value": 0
}
}
blhost succeeded
### Write image ###
/opt/nxp/MCUX_Provi_v3/bin/tools/spsdk ~
/opt/nxp/MCUX_Provi_v3/bin/tools/spsdk/blhost -u 0x15A2,0x0073 -j -- write-memory 0x70001000 /home/cris/secure_provisioning/MIMXRT/bootable_images/SPACCC_nopadding.bin 9
~
GENERAL ERROR:unpack_from requires a buffer of at least 4 bytes for unpacking 4 bytes at offset 0 (actual buffer size is 2)
blhost failed
DEBUG: [src.utils.batchexecute] Execution took 2.3 seconds
Script failed with return code: [2]ERROR
Secure Provisioning Tool exited with an error. See above for errors.

 

0 Kudos
Reply
1 Reply

2,871 Views
liborukropec
NXP Employee
NXP Employee

Hello Cristiano,

thank you for reporting this issue, it can be reproduced on our end as well. Problem is in the Flashloader and SPSDK version combination.

There are 2 possible workarounds at this moment:

  1. use serial communication if that's available, this works on the Linux without any issue for all uses cases and boot types.
  2. if USB is the only choice, then replace /opt/nxp/MCUX_Provi_v3/bin/data/targets/MIMXRT1064/MIMXRT1064.json file with the attached (two lines changed), you must extract it (json file type not allowed on this community), or you can manually edit at the very end for the sdphost and blhost the type. From "spsdk" to "legacy":
        "tools": {
    "elftosb": {
    "family": "imx"
    },
    "blhost": {
    "type": "legacy",
    "int_ram_buffer_addr_int": "0x2000"
    },
    "sdphost": {
    "type": "legacy"
    }
    }

    This workaround works only for Unsigned scenario. E.g. OTP configuration (reading/burning fuses won't work)

  3. There's possibility to tweak the SPSDK, which is open source (https://github.com/NXPmicro/spsdk). I can prepare the the steps how to build the CLI binaries and what to fix, if workarounds 1 or 2 are not suitable for you.

 

We'll work on the fix. Will keep you updated.

 

Sorry for the inconvenience.

Regards,

Libor