2022-10-05 03:57 PM
I am trying to write a user key to CKS on a P-NUCLEO-WB55 using either STM32CubeProgrammer or STM32_Programmer_CLI and the SWD interface. I am able to start the FUS no problem, as shown here:
C:\Program Files\STMicroelectronics\STM32Cube\STM32CubeProgrammer\bin>STM32_Programmer_CLI.exe -c port=swd -startfus
-------------------------------------------------------------------
STM32CubeProgrammer v2.10.0
-------------------------------------------------------------------
ST-LINK SN : 0661FF3837334D4E43124615
ST-LINK FW : V2J40M27
Board : P-NUCLEO-WB55
Voltage : 3.27V
SWD freq : 4000 KHz
Connect mode: Normal
Reset mode : Software reset
Device ID : 0x495
Revision ID : Rev Y
Device name : STM32WB5x
Flash size : 1 MBytes
Device type : MCU
Device CPU : Cortex-M4
BL Version : 0xd5
Debug in Low Power mode enabled
Warning: Option Byte: nSWboot0, value: 0x0, was not modified.
Warning: Option Byte: nboot0, value: 0x1, was not modified.
Warning: Option Byte: nboot1, value: 0x1, was not modified.
Warning: Option Bytes are unchanged, Data won't be downloaded
Time elapsed during option Bytes configuration: 00:00:00.003
Succeeded to set nSWboot0=0 nboot1=1 nboot0=1
Memory Programming ...
Opening and parsing file: 0x495_FUS_Operator.bin
File : 0x495_FUS_Operator.bin
Size : 8.00 KB
Address : 0x08000000
Erasing memory corresponding to segment 0:
Erasing internal memory sectors [0 1]
Download in Progress:
██████████████████████████████████████████████████ 100%
File download complete
Time elapsed during download operation: 00:00:00.302
Application is running, Please Hold on...
Reconnecting...
Reconnected !
Reconnecting...
Reconnected !
StartFus activated successfully
FUS_STATE_IDLE
startfus command execution finished
And I can verify the FUS version:
C:\Program Files\STMicroelectronics\STM32Cube\STM32CubeProgrammer\bin>STM32_Programmer_CLI.exe -c port=swd mode=UR -r32 0x20010010 1
-------------------------------------------------------------------
STM32CubeProgrammer v2.10.0
-------------------------------------------------------------------
ST-LINK SN : 0661FF3837334D4E43124615
ST-LINK FW : V2J40M27
Board : P-NUCLEO-WB55
Voltage : 3.26V
SWD freq : 4000 KHz
Connect mode: Under Reset
Reset mode : Hardware reset
Device ID : 0x495
Revision ID : Rev Y
Device name : STM32WB5x
Flash size : 1 MBytes
Device type : MCU
Device CPU : Cortex-M4
BL Version : 0xd5
Debug in Low Power mode enabled
Reading 32-bit memory content
Size : 4 Bytes
Address: : 0x20010010
0x20010010 : 01020000
However, when I try to program a user key, the software is not returning a key index as expected:
C:\Program Files\STMicroelectronics\STM32Cube\STM32CubeProgrammer\bin>STM32_Programmer_CLI.exe -c port=swd -wusrkey \Users\Michael\Desktop\OEM_KEY_COMPANY1_key_AES_CBC.bin keytype=1
-------------------------------------------------------------------
STM32CubeProgrammer v2.10.0
-------------------------------------------------------------------
ST-LINK SN : 0661FF3837334D4E43124615
ST-LINK FW : V2J40M27
Board : P-NUCLEO-WB55
Voltage : 3.27V
SWD freq : 4000 KHz
Connect mode: Normal
Reset mode : Software reset
Device ID : 0x495
Revision ID : Rev Y
Device name : STM32WB5x
Flash size : 1 MBytes
Device type : MCU
Device CPU : Cortex-M4
BL Version : 0xd5
Debug in Low Power mode enabled
Key File path : \users\michael\desktop\oem_key_company1_key_aes_cbc.bin
Write user key in memory process started ...
Warning: Option Byte: nSWboot0, value: 0x0, was not modified.
Warning: Option Byte: nboot0, value: 0x1, was not modified.
Warning: Option Byte: nboot1, value: 0x1, was not modified.
Warning: Option Bytes are unchanged, Data won't be downloaded
Time elapsed during option Bytes configuration: 00:00:00.003
Succeeded to set nSWboot0=0 nboot1=1 nboot0=1
Memory Programming ...
Opening and parsing file: 0x495_FUS_Operator.bin
File : 0x495_FUS_Operator.bin
Size : 8.00 KB
Address : 0x08000000
Erasing memory corresponding to segment 0:
Erasing internal memory sectors [0 1]
Download in Progress:
██████████████████████████████████████████████████ 100%
File download complete
Time elapsed during download operation: 00:00:00.301
Application is running, Please Hold on...
Reconnecting...
Reconnected !
wUsrkey command execution finished
I was expecting output more like this (pulled from another post:(
Write user key in memory process started ...
FUS state is FUS_IDLE
FUS status is FUS_NO_ERROR
Writing key in memory ...
write user key in memory returned the following key index 0x3
write key in memory process finished
Write user key in memory command execution finished
At this point, I'm unsure if the command completed successfully at all, or if it's just that the new version of the interface doesn't return the key index. If the latter is the case, how can I determine the key index for use in my software?
Thank you!
Michael
2022-10-11 02:16 AM
Hello,
Did you try to change the verbosity level into STM32CubeProgrammer tool in order to see more information?
Best Regards
2022-10-12 07:44 AM
Hi Remy--
Changing verbosity level to 3 gives a lot more information, but it's not clear than any of this is the index to which the key was written:
C:\Program Files\STMicroelectronics\STM32Cube\STM32CubeProgrammer\bin>STM32_Programmer_CLI.exe -c port=swd -wusrkey \Users\Michael\Desktop\OEM_KEY_COMPANY1_key_AES_CBC.bin keytype=1 -vb 3
-------------------------------------------------------------------
STM32CubeProgrammer v2.10.0
-------------------------------------------------------------------
STLinkUSBDriver.dll loaded
STLinkUSBDriver.dll loaded
ST-LINK SN : 0661FF3837334D4E43124615
ST-LINK FW : V2J40M27
Board : P-NUCLEO-WB55
Voltage : 3.27V
SWD freq : 4000 KHz
Connect mode: Normal
Reset mode : Software reset
Device ID : 0x495
Revision ID : Rev Y
flash loader C:/Program Files/STMicroelectronics/STM32Cube/STM32CubeProgrammer/bin/FlashLoader/0x495.stldr is loaded
r ap 0 @0xE0042008 0x00000004 bytes Data 0x00000000
w ap 0 @0xE0042008 0x00000004 bytes Data 0x00001800
r ap 0 @0xE0042004 0x00000004 bytes Data 0x00000007
w ap 0 @0xE0042004 0x00000004 bytes Data 0x00000007
Device name : STM32WB5x
Reading data...
r ap 0 @0x1FFF75E0 0x00000004 bytes Data 0xFFFF0400
Flash size : 1 MBytes
Device type : MCU
Device CPU : Cortex-M4
r ap 0 @0x1FFF6FFE 0x00000004 bytes Data 0xFFFF00D5
BL Version : 0xd5
Debug in Low Power mode enabled
Key File path : \users\michael\desktop\oem_key_company1_key_aes_cbc.bin
Write user key in memory process started ...
UPLOADING OPTION BYTES DATA ...
Bank : 0x00
Address : 0x58004020
Size : 96 Bytes
Reading data...
r ap 0 @0x58004020 0x00000060 bytes Data 0x39FFF1AA
Bank : 0x01
Address : 0x58004080
Size : 8 Bytes
Reading data...
r ap 0 @0x58004080 0x00000008 bytes Data 0x000010CE
PROGRAMMING OPTION BYTES AREA ...
Warning: Option Byte: nSWboot0, value: 0x0, was not modified.
Warning: Option Byte: nboot0, value: 0x1, was not modified.
Warning: Option Byte: nboot1, value: 0x1, was not modified.
Warning: Option Bytes are unchanged, Data won't be downloaded
Time elapsed during option Bytes configuration: 00:00:00.004
Succeeded to set nSWboot0=0 nboot1=1 nboot0=1
Memory Programming ...
Opening and parsing file: 0x495_FUS_Operator.bin
File : 0x495_FUS_Operator.bin
Size : 8.00 KB
Address : 0x08000000
Erasing Segment <0> Address <0x08000000> Size <8192>Bytes
Erasing memory corresponding to segment 0:
Memory erase...
halt ap 0
w ap 0 reg 15 PC (0x20000000)
w ap 0 reg 17 MSP (0x20000500)
w ap 0 reg 16 xPSR (0x01000000)
w ap 0 @0x20000C40 0x00000200 bytes Data 0x00000000
w ap 0 @0x20000000 0x00000004 bytes Data 0x0000BE00
w ap 0 @0x20000004 0x0000081C bytes Data 0xB672B580
Erasing internal memory sectors [0 1]
Init flashloader...
halt ap 0
w ap 0 reg 0 R0 0x00000001
w ap 0 reg 1 R1 0x00000000
w ap 0 reg 2 R2 0x00000000
w ap 0 reg 3 R3 0x00000000
w ap 0 reg 4 R4 0x00000000
w ap 0 reg 5 R5 0x00000000
w ap 0 reg 6 R6 0x00000000
w ap 0 reg 7 R7 0x00000000
w ap 0 reg 8 R8 0x00000000
w ap 0 reg 9 R9 0x00000000
w ap 0 reg 10 R10 0x00000000
w ap 0 reg 11 R11 0x00000000
w ap 0 reg 12 R12 0x00000000
w ap 0 reg 13 SP 0x00000000
w ap 0 reg 14 LR 0x20000001
w ap 0 reg 15 PC 0x20000005
w ap 0 reg 16 xPSR 0x01000000
w ap 0 reg 17 MSP 0x20000C1C
w ap 0 reg 18 PSP 0x00000000
run ap 0
halt ap 0
r ap 0 reg 0 R0 0x00000001
Loader sector erase...
w ap 0 reg 0 R0 0x08000000
w ap 0 reg 1 R1 0x08001000
w ap 0 reg 2 R2 0x00000002
w ap 0 reg 3 R3 0x00000000
w ap 0 reg 4 R4 0x00000000
w ap 0 reg 5 R5 0x00000000
w ap 0 reg 6 R6 0x00000000
w ap 0 reg 7 R7 0x00000000
w ap 0 reg 8 R8 0x00000000
w ap 0 reg 9 R9 0x00000000
w ap 0 reg 10 R10 0x00000000
w ap 0 reg 11 R11 0x00000000
w ap 0 reg 12 R12 0x00000000
w ap 0 reg 13 SP 0x00000000
w ap 0 reg 14 LR 0x20000001
w ap 0 reg 15 PC 0x20000645
w ap 0 reg 16 xPSR 0x01000000
w ap 0 reg 17 MSP 0x20000C1C
w ap 0 reg 18 PSP 0x00000000
run ap 0
halt ap 0
r ap 0 reg 0 R0 0x00000001
erase: 0117ms
Download in Progress:
▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ 100%e : 8192 Bytes
Address : 0x08000000
Buffer program...
halt ap 0
w ap 0 reg 15 PC (0x20000000)
w ap 0 reg 17 MSP (0x20000500)
w ap 0 reg 16 xPSR (0x01000000)
w ap 0 @0x20000C40 0x00000200 bytes Data 0x00000000
w ap 0 @0x20000000 0x00000004 bytes Data 0x0000BE00
w ap 0 @0x20000004 0x0000081C bytes Data 0xB672B580
Loader write range...
w ap 0 @0x20000C40 0x00001000 bytes Data 0x20000820
W B1 in RAM @0x20000C40 size 0x00001000 : 0028ms
Init flashloader...
halt ap 0
w ap 0 reg 0 R0 0x00000001
w ap 0 reg 1 R1 0x00000000
w ap 0 reg 2 R2 0x00000000
w ap 0 reg 3 R3 0x00000000
w ap 0 reg 4 R4 0x00000000
w ap 0 reg 5 R5 0x00000000
w ap 0 reg 6 R6 0x00000000
w ap 0 reg 7 R7 0x00000000
w ap 0 reg 8 R8 0x00000000
w ap 0 reg 9 R9 0x00000000
w ap 0 reg 10 R10 0x00000000
w ap 0 reg 11 R11 0x00000000
w ap 0 reg 12 R12 0x00000000
w ap 0 reg 13 SP 0x00000000
w ap 0 reg 14 LR 0x20000001
w ap 0 reg 15 PC 0x20000005
w ap 0 reg 16 xPSR 0x01000000
w ap 0 reg 17 MSP 0x20000C1C
w ap 0 reg 18 PSP 0x00000000
run ap 0
halt ap 0
r ap 0 reg 0 R0 0x00000001
w ap 0 reg 0 R0 0x08000000
w ap 0 reg 1 R1 0x00001000
w ap 0 reg 2 R2 0x20000C40
w ap 0 reg 3 R3 0x00000002
w ap 0 reg 4 R4 0x00000000
w ap 0 reg 5 R5 0x00000000
w ap 0 reg 6 R6 0x00000000
w ap 0 reg 7 R7 0x00000000
w ap 0 reg 8 R8 0x00000000
w ap 0 reg 9 R9 0x00000000
w ap 0 reg 10 R10 0x00000000
w ap 0 reg 11 R11 0x00000000
w ap 0 reg 12 R12 0x00000000
w ap 0 reg 13 SP 0x00000000
w ap 0 reg 14 LR 0x20000001
w ap 0 reg 15 PC 0x20000059
w ap 0 reg 16 xPSR 0x01000000
w ap 0 reg 17 MSP 0x20000C1C
w ap 0 reg 18 PSP 0x00000000
run ap 0
w ap 0 @0x20001C40 0x00001000 bytes Data 0x20010004
W B2 in RAM @0x20018440 size 0x00001000: 0070ms
r ap 0 reg 0 R0 0x00000001
Wait W B1 in Flash @0x08000000 size 0x00001000: 0028ms
w ap 0 reg 0 R0 0x08001000
w ap 0 reg 1 R1 0x00001000
w ap 0 reg 2 R2 0x20001C40
w ap 0 reg 3 R3 0x00000002
w ap 0 reg 4 R4 0x00000000
w ap 0 reg 5 R5 0x00000000
w ap 0 reg 6 R6 0x00000000
w ap 0 reg 7 R7 0x00000000
w ap 0 reg 8 R8 0x00000000
w ap 0 reg 9 R9 0x00000000
w ap 0 reg 10 R10 0x00000000
w ap 0 reg 11 R11 0x00000000
w ap 0 reg 12 R12 0x00000000
w ap 0 reg 13 SP 0x00000000
w ap 0 reg 14 LR 0x20000001
w ap 0 reg 15 PC 0x20000059
w ap 0 reg 16 xPSR 0x01000000
w ap 0 reg 17 MSP 0x20000C1C
w ap 0 reg 18 PSP 0x00000000
run ap 0
██████████████████████████████████████████████████r ap 0 reg 0 R0 0x00000001
Write elapsed time: 0203ms
Segment[0] downloaded successfully
File download complete
Time elapsed during download operation: 00:00:00.356
w ap 0 @0x20010004 0x00000004 bytes Data 0x00000000
w ap 0 reg 15 PC 0x0800170D
w ap 0 reg 17 MSP 0x20000820
w ap 0 reg 16 xPSR 0x01000000
Application is running, Please Hold on...
w ap 0 @0x20010030 0x00000014 bytes Data 0x10010012
w ap 0 @0x20010000 0x00000004 bytes Data 0x00000009
Reconnecting...
Disconnected
STLinkUSBDriver.dll loaded
ST-LINK SN : 0661FF3837334D4E43124615
ST-LINK FW : V2J40M27
Board : P-NUCLEO-WB55
Voltage : 3.27V
SWD freq : 4000 KHz
Connect mode: Hot Plug
Reset mode : Software reset
Device ID : 0x495
Revision ID : Rev Y
Reconnected !
Success with Time elapsed during Reconnect: 17 ms
wUsrkey command execution finished
Disconnected
Michael
2022-10-28 09:15 AM
Hello,
Can you retry using UART/USB interface to see if you have the same behavior?
Best Regards
2022-11-01 01:23 PM
Hi Remy--
Using the USB interface, it seems that I do get a key index:
C:\Program Files\STMicroelectronics\STM32Cube\STM32CubeProgrammer\bin>STM32_Programmer_CLI.exe -c port=usb1 -wusrkey \Users\Michael\Desktop\OEM_KEY_COMPANY1_key_AES_CBC.bin keytype=1
-------------------------------------------------------------------
STM32CubeProgrammer v2.10.0
-------------------------------------------------------------------
USB speed : Full Speed (12MBit/s)
Manuf. ID : STMicroelectronics
Product ID : DFU in FS Mode
SN : 2082389B3036
DFU protocol: 1.1
Board : --
Device ID : 0x0495
Device name : STM32WB5x
Flash size : 1 MBytes
Device type : MCU
Revision ID : --
Device CPU : Cortex-M4
Key File path : \users\michael\desktop\oem_key_company1_key_aes_cbc.bin
Write user key in memory process started ...
FUS state is FUS_ERROR
FUS status is FUS_NOT_RUNNING
FUS state is FUS_IDLE
FUS status is FUS_NO_ERROR
Writing key in memory ...
write user key in memory returned the following key index 0x19
write key in memory process finished
Write user key in memory command execution finished
Requesting FUS state ...
FUS state is FUS_IDLE
FUS status is FUS_NO_ERROR
Is this feature exclusive to the USB interface?
Michael