Title: STM32H7x option_write reads incorrect address in flash · Issue #45 · STMicroelectronics/OpenOCD · GitHub
Open Graph Title: STM32H7x option_write reads incorrect address in flash · Issue #45 · STMicroelectronics/OpenOCD
X Title: STM32H7x option_write reads incorrect address in flash · Issue #45 · STMicroelectronics/OpenOCD
Description: A recently added support for STM32H7R/H7Sx MCUs (aa109db) broke stm32h7x option_write command on STM32H757BIT6. I tested stm32h7x option_write command with 3 different commits: Most recent commit - 0a084c2 Added support for STM32H7R/H7Sx...
Open Graph Description: A recently added support for STM32H7R/H7Sx MCUs (aa109db) broke stm32h7x option_write command on STM32H757BIT6. I tested stm32h7x option_write command with 3 different commits: Most recent commit -...
X Description: A recently added support for STM32H7R/H7Sx MCUs (aa109db) broke stm32h7x option_write command on STM32H757BIT6. I tested stm32h7x option_write command with 3 different commits: Most recent commit -...
Opengraph URL: https://github.com/STMicroelectronics/OpenOCD/issues/45
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"STM32H7x option_write reads incorrect address in flash","articleBody":"A recently added support for STM32H7R/H7Sx MCUs (https://github.com/STMicroelectronics/OpenOCD/commit/aa109db19ffd22eb05e18b010140fb562934533b) broke `stm32h7x option_write` command on STM32H757BIT6. I tested `stm32h7x option_write` command with 3 different commits:\n\n- Most recent commit - https://github.com/STMicroelectronics/OpenOCD/commit/0a084c29345576911fb8d10fcbd158d0361b6186\n- Added support for STM32H7R/H7Sx - https://github.com/STMicroelectronics/OpenOCD/commit/aa109db19ffd22eb05e18b010140fb562934533b\n- One commit prior to adding support for STM32H7R/H7Sx - https://github.com/STMicroelectronics/OpenOCD/commit/b62cbc2e853189e730fd94e6d9c0a1d3ceb2661f\n\n# Hardware\n\n- STM32H757BIT6 - dual core\n- STLINK-V3MINIE\n\n# Software\nOpenOCD is running in a Docker container:\n```\nRUN git clone https://github.com/STMicroelectronics/OpenOCD.git \u0026\u0026 \\\n cd OpenOCD \u0026\u0026 \\\n git checkout insert_git_commit_here \u0026\u0026 \\\n ./bootstrap \u0026\u0026 \\\n ./configure --enable-stlink \u0026\u0026 \\\n make -j$(nproc) \u0026\u0026 \\\n make install \u0026\u0026 \\\n cd .. \u0026\u0026 \\\n rm -rf OpenOCD\n```\n\nI am running OpenOCD with the following command\n`openocd -f openocd_stm32h757.cfg`\n\nI am connecting to the OpenOCD with telnet\n`telnet 127.0.0.1 4444`\n\n### Configuration file:\n```\n# openocd_stm32h757.cfg\nsource [find interface/stlink-dap.cfg]\ntransport select dapdirect_swd\nsource [find target/stm32h7x_dual_bank.cfg]\nreset_config srst_only \n```\n\n# Test results\n\nI tried disabling booting of CM4 by changing option byte FLASH_OPTSR_PRG and also tried `stm32h7x option_write` example in the [OpenOCD documentation section 12.5.2](https://openocd.org/doc/pdf/openocd.pdf). The output of the commands tested with different commits are shown in a table below. Only commit b62cbc2 produced expected results and wrote the option byte.\n\n| Command | Most recent https://github.com/STMicroelectronics/OpenOCD/commit/0a084c29345576911fb8d10fcbd158d0361b6186 | STM32H7R/H7Sx support https://github.com/STMicroelectronics/OpenOCD/commit/aa109db19ffd22eb05e18b010140fb562934533b | Prior to adding support https://github.com/STMicroelectronics/OpenOCD/commit/b62cbc2e853189e730fd94e6d9c0a1d3ceb2661f |\n| ------------- | ------------- | ------------- | ------------- |\n| reset | - | - | - |\n| stm32h7x option_read 0 0x1c | Option Register: \u003c0x5200201c\u003e = 0x1bc6aaf0 | Option Register: \u003c0x5200201c\u003e = 0x1bc6aaf0 | Option Register: \u003c0x5200201c\u003e = 0x1bc6aaf0 |\n| stm32h7x option_write 0 0x20 0x00000000 0x00400000 | Failed to read memory at 0x51e3be78 \u003cbr\u003e error while reading from address 0x51e3be78 | Failed to read memory at 0xe000edf4 \u003cbr\u003e error while reading from address 0x856d9473 | - |\n| stm32h7x option_read 0 0x1c | Option Register: \u003c0x5200201c\u003e = 0x1bc6aaf0 | Option Register: \u003c0x5200201c\u003e = 0x1bc6aaf0 | Option Register: \u003c0x5200201c\u003e = 0x1b86aaf0 |\n| stm32h7x option_write 0 0x20 0x8000000 0x8000000 | Failed to read memory at 0x51e3be78 \u003cbr\u003e error while reading from address 0x51e3be78 | Failed to read memory at 0xe000edf4 \u003cbr\u003e error while reading from address 0x856d9473 | - |\n| stm32h7x option_read 0 0x1c | Option Register: \u003c0x5200201c\u003e = 0x1bc6aaf0 | Option Register: \u003c0x5200201c\u003e = 0x1bc6aaf0 | Option Register: \u003c0x5200201c\u003e = 0x1b86aaf0 |\n\n# Observations\n\nDifferent functions are used in `src/flash/nor/stm32h7x.c` for reading values for commands `option_read` and `option_write`.\n\n| commit | OpenOCD command | function in stm32h7x.c |\n| ------------- | ------------- | ------------- |\n| aa109db | stm32h7x option_read | stm32x_read_flash_reg |\n| aa109db | stm32h7x option_write | stm32h7_read_flash_reg_by_index |\n| b310b3b | stm32h7x option_read | stm32x_read_flash_reg |\n| b310b3b | stm32h7x option_write | stm32x_read_flash_reg |\n\n# Conclusion\n\nIt seems function `stm32h7_read_flash_reg_by_index` in `src/flash/nor/stm32h7x.c` used in `option_write` command reads incorrect address from flash.\n\nThanks in advance!","author":{"url":"https://github.com/novakmichalinfo","@type":"Person","name":"novakmichalinfo"},"datePublished":"2026-01-13T13:57:45.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/45/OpenOCD/issues/45"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:5e078d21-8e55-7834-8a2a-853317a746fe |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9E6C:29A644:67D6C42:8932B9D:6A5DDA61 |
| html-safe-nonce | a9c66c2bbecb4a51368343a7fa7c0e0cffe4280ac86d70b69347b4632ca73285 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5RTZDOjI5QTY0NDo2N0Q2QzQyOjg5MzJCOUQ6NkE1RERBNjEiLCJ2aXNpdG9yX2lkIjoiNDA5NDg5Mjk4NTEwNDA2MzA3MyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 8f0e9135d86c67ecd03d5c8a4fac1a33de55f74926208ab9d250a1559645ad8c |
| hovercard-subject-tag | issue:3808972566 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/STMicroelectronics/OpenOCD/45/issue_layout |
| twitter:image | https://opengraph.githubassets.com/5d2753fd83ac672bdf2360f4588ac1e91f8cb018962e8cfd61e743e0d9e232af/STMicroelectronics/OpenOCD/issues/45 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/5d2753fd83ac672bdf2360f4588ac1e91f8cb018962e8cfd61e743e0d9e232af/STMicroelectronics/OpenOCD/issues/45 |
| og:image:alt | A recently added support for STM32H7R/H7Sx MCUs (aa109db) broke stm32h7x option_write command on STM32H757BIT6. I tested stm32h7x option_write command with 3 different commits: Most recent commit -... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | novakmichalinfo |
| hostname | github.com |
| expected-hostname | github.com |
| None | 5290d7e14309ad1e76106a9c4237bd1041517e83ea182c8ab756752cb0c6940b |
| turbo-cache-control | no-preview |
| go-import | github.com/STMicroelectronics/OpenOCD git https://github.com/STMicroelectronics/OpenOCD.git |
| octolytics-dimension-user_id | 10744877 |
| octolytics-dimension-user_login | STMicroelectronics |
| octolytics-dimension-repository_id | 226140039 |
| octolytics-dimension-repository_nwo | STMicroelectronics/OpenOCD |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 226140039 |
| octolytics-dimension-repository_network_root_nwo | STMicroelectronics/OpenOCD |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 9c975978430e9ad293956f2bbdaf153b1bd84a99 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width