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

[STM32H753ZIT6]: ERROR common_flash.c: Failed to unlock flash option! #1401

Closed
6 tasks done
ND-creator opened this issue Jun 5, 2024 · 1 comment · Fixed by #1416
Closed
6 tasks done

[STM32H753ZIT6]: ERROR common_flash.c: Failed to unlock flash option! #1401

ND-creator opened this issue Jun 5, 2024 · 1 comment · Fixed by #1416
Assignees
Milestone

Comments

@ND-creator
Copy link

ND-creator commented Jun 5, 2024

  • I made serious effort to avoid creating duplicate or nearly similar issue
  • Programmer/board type: STLINK /V3
  • Operating system an version: raspberry pi os version 12 Bookworm
  • stlink tools version : v1.8.0-32-g32ce4bf-dirty
  • stlink commandline tool name: st-flash --format binary write /home/pi/opt_h7.bin 0x5200201c
  • Target chip: STM32H753ZIT6

Commandline output:
`sl->flash_type: 0x00000008
unlock - optkey_reg: 0x52002008
unlock - optkey2_reg: 0x52002108
unlock - optkey1: 0x08192A3B
unlock - optkey2: 0x4C5D6E7F
stlink_write_debug32: 0x08192a3b to 0x52002008
Error Checking the command execution status stored in the first byte of the response, cmd:WRITEDEBUGREG error rxbuf[0]:(0x19)
size: -1
stlink_write_debug32 result: -1
stlink_write_debug32: 0x4c5d6e7f to 0x52002008
Error Checking the command execution status stored in the first byte of the response, cmd:WRITEDEBUGREG error rxbuf[0]:(0x19)
size: -1
stlink_write_debug32 result2: -1
is locked ? 1
stlink_write_debug32: 0x08192a3b to 0x52002108
Error Checking the command execution status stored in the first byte of the response, cmd:WRITEDEBUGREG error rxbuf[0]:(0x19)
size: -1
stlink_write_debug32: 0x4c5d6e7f to 0x52002108
Error Checking the command execution status stored in the first byte of the response, cmd:WRITEDEBUGREG error rxbuf[0]:(0x19)

size: -1

2024-06-05T18:10:23 ERROR common_flash.c: Failed to unlock flash option!
2024-06-05T18:10:23 ERROR option_bytes.c: Flash option unlock failed!`

Expected/description:
I can flash my STM32H753 but not the option bytes.
The unlock of the flash works but not the unlock of the flash option.
I can read and write my STM32H753 using STM32CubeProgrammer.
In the function send_recv() from usb.c, I don't know what the error code 0x19 on rxbuf[0] is about, this code error is not handled by the source project.
I modified the source code to only add some printf() for debug purpose.
I also try with STLink V2 the unlock flash option still not work but error code not the same: 0x15 (STLINK_DEBUG_ERR_DP_FAULT) for the first key and 0x11 (STLINK_DEBUG_ERR_AP_FAULT) for the second key

@ND-creator ND-creator changed the title [STM32H753ZIT6]: $ERROR common_flash.c: Failed to unlock flash option! [STM32H753ZIT6]: ERROR common_flash.c: Failed to unlock flash option! Jun 5, 2024
@ND-creator
Copy link
Author

I have found the solution: in the function unlock_flash_option() i do not use optkey2_reg by not writing to this register then the unlock flash option works.

salyzyn added a commit to salyzyn/stm32g491 that referenced this issue Jul 15, 2024
Category 4 devices are 2K block size and do not have banks

Closes stlink-org#1401
@stlink-org stlink-org locked as resolved and limited conversation to collaborators Jul 17, 2024
@Nightwalker-87 Nightwalker-87 reopened this Aug 2, 2024
@Nightwalker-87 Nightwalker-87 moved this to In review in Release v1.8.1 Aug 2, 2024
@github-project-automation github-project-automation bot moved this from In review to Done in Release v1.8.1 Aug 2, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants