Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[STM32U59x_U5Ax]: st-flash will not write to secure region flash #1450

Open
6 tasks done
bry-decelles opened this issue Jan 30, 2025 · 0 comments
Open
6 tasks done

[STM32U59x_U5Ax]: st-flash will not write to secure region flash #1450

bry-decelles opened this issue Jan 30, 2025 · 0 comments

Comments

@bry-decelles
Copy link

  • I made serious effort to avoid creating duplicate or nearly similar issue

In order to allow developers to isolate and target your respective issue, please take some time to select the check boxes below and fill out each of the following items appropriate to your specific problem.

  • Programmer/board type: NUCLE_U5A5ZJ-Q with on-board st-link
  • Operating system an version: linux-arm (raspberry pi 5)
  • stlink tools version and/or git commit hash: 1.8.0
  • stlink commandline tool name: [st-flash]
  • Target chip (and board, if applicable): NUCLE_U5A5ZJ-Q and custom pcb w/ STM32U5A5AJHxQ MCU

here is my st-info --probe output:

dev@test:~/fw$ st-info --probe
Found 1 stlink programmers
  version:    V3J15
  serial:     001B00273532510831333430
  flash:      4194304 (pagesize: 8192)
  sram:       2574336
  chipid:     0x481
  dev-type:   STM32U59x_U5Ax

I am trying to flash my mcu using the st-flash utility on a raspberry pi. My project outputs 2 binaries, a Non-secure.hex(or bin or elf) and a Secure.hex. The NonSecure flash location is at 0x08200000 and the Secure flash starts at 0x0C000000. I am able to flash the non-secure code just fine, but when I go to flash the secure fw I get the following output:

dev@test:~/fw$ st-flash --format ihex write ./Secure.hex
st-flash 1.8.0
2025-01-30T20:24:42 INFO common.c: STM32U59x_U5Ax: 2514 KiB SRAM, 4096 KiB flash in at least 8 KiB pages.
Unknown memory region

for reference, here is the output I get for the Non-secure flash:

dev@test:~/fw$ st-flash --format ihex write ./NonSecure.hex
st-flash 1.8.0
2025-01-30T20:24:33 INFO common.c: STM32U59x_U5Ax: 2514 KiB SRAM, 4096 KiB flash in at least 8 KiB pages.
2025-01-30T20:24:33 INFO common_flash.c: Attempting to write 45980 (0xb39c) bytes to stm32 address: 136314880 (0x8200000)
-> Flash page at 0x820a000 erased (size: 0x2000)
2025-01-30T20:24:33 INFO flash_loader.c: Starting Flash write for WB/G0/G4/L5/U5/H5/C0
  5/5   pages writtenARN flash_loader.c: Data size is aligned to 16 byte
2025-01-30T20:24:37 INFO common_flash.c: Starting verification of write complete
2025-01-30T20:24:37 INFO common_flash.c: Flash written and verified! jolly good!

Originally I thought this was just a trust-zone issue, but I have verified that I can flash these hex files to the board successfully using the STM32CubeProgrammer utility on my windows computer using the same st-link interface and the same development board. In either case I'm attempting to flash over the SWD interface.

here is the output of the STM32CubeProgrammer when I flash the secure hex:

12:39:49:752 : UR connection mode is defined with the HWrst reset mode
  12:39:49:888 : ST-LINK SN  : 001B00273532510831333430
  12:39:49:888 : ST-LINK FW  : V3J15M7
  12:39:49:888 : Board       : NUCLEO-U5A5ZJ-Q
  12:39:49:888 : Voltage     : 3.30V
  12:39:49:888 : SWD freq    : 8000 KHz
  12:39:49:888 : Connect mode: Hot Plug
  12:39:49:889 : Reset mode  : Software reset
  12:39:49:889 : Device ID   : 0x481
  12:39:49:889 : Revision ID : Rev X
  12:39:49:891 : Database: Config 1 is active.
  12:39:49:891 : flash loader C:\Program Files\STMicroelectronics\STM32Cube\STM32CubeProgrammer\bin/FlashLoader/0x481.stldr is loaded
  12:39:49:891 : Debug in Low Power mode enabled.
  12:39:50:090 : UPLOADING OPTION BYTES DATA ...
  12:39:50:091 :   Bank          : 0x00
  12:39:50:091 :   Address       : 0x40022040
  12:39:50:091 :   Size          : 32 Bytes
  12:39:50:092 :   Bank          : 0x01
  12:39:50:092 :   Address       : 0x40022068
  12:39:50:092 :   Size          : 8 Bytes
  12:39:50:093 : UPLOADING OPTION BYTES DATA ...
  12:39:50:093 :   Bank          : 0x00
  12:39:50:093 :   Address       : 0x40022040
  12:39:50:093 :   Size          : 32 Bytes
  12:39:50:093 :   Bank          : 0x01
  12:39:50:093 :   Address       : 0x40022068
  12:39:50:093 :   Size          : 8 Bytes
  12:39:50:094 : UPLOADING ...
  12:39:50:094 :   Size          : 1024 Bytes
  12:39:50:095 :   Address       : 0x8000000
  12:39:50:095 : Read progress:
  12:39:50:096 : Data read successfully
  12:39:50:096 : Time elapsed during the read operation is: 00:00:00.006
  12:39:52:465 : Opening and parsing file: Secure.hex
  12:39:52:466 : Memory Programming ...
  12:39:52:466 :   File          : Secure.hex
  12:39:52:470 :   Size          : 73.11 KB 
  12:39:52:470 :   Address       : 0x0C000000 
  12:39:52:472 : Erasing memory corresponding to segment 0:
  12:39:52:474 : Memory Erase via Debugger!
  12:39:52:474 : Memory erase...
  12:39:52:474 : Erasing internal memory sectors [0 9]
  12:39:52:599 : Erasing memory corresponding to segment 1:
  12:39:52:601 : Memory Erase via Debugger!
  12:39:52:601 : Memory erase...
  12:39:52:601 : Erasing internal memory sector 255
  12:39:52:615 : Download in Progress:
  12:39:52:616 :   Size          : 74704 Bytes
  12:39:52:616 :   Address       : 0x0C000000 
  12:39:52:620 : Programming via FlashLoader!
  12:39:52:628 : halt ap 0 
  12:39:52:632 : Loader write range...
  12:39:52:734 : Init flashloader...
  12:39:52:736 : halt ap 0 
  12:39:52:741 : run ap 0 
  12:39:52:743 : halt ap 0 
  12:39:52:752 : run ap 0 
  12:39:53:035 : run ap 0 
  12:39:53:317 : Segment[0] downloaded successfully
  12:39:53:317 :   Size          : 160 Bytes
  12:39:53:317 :   Address       : 0x0C1FE000 
  12:39:53:324 : Programming via FlashLoader!
  12:39:53:332 : halt ap 0 
  12:39:53:339 : Loader write range...
  12:39:53:345 : Init flashloader...
  12:39:53:345 : halt ap 0 
  12:39:53:350 : run ap 0 
  12:39:53:351 : halt ap 0 
  12:39:53:357 : run ap 0 
  12:39:53:367 : run ap 0 
  12:39:53:368 : Segment[1] downloaded successfully
  12:39:53:368 : File download complete
  12:39:53:405 : Time elapsed during download operation: 00:00:00.897

I have also tried the s-flash command on the raspberry pi with the --debug, --reset, --connect-under-reset options and have tried flashing either the .bin file while specifying the address or just using the hex file with the --area ihex option enabled and I get the exact same output.

I've also double checked the memory locations in CubeMX to make sure I'm trying to flash to the correct addresses

Image

Expected/description:

st-flash utility can flash the firmware Flash Bank1 (S) (0x0c000000) for the secure firmware package the same way it's able to flash at the Flash Bank1 (NS)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant