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

[STM32F72x] Incorrect memory map #2006

Open
Fabien-B opened this issue Nov 26, 2024 · 0 comments
Open

[STM32F72x] Incorrect memory map #2006

Fabien-B opened this issue Nov 26, 2024 · 0 comments
Labels
Bug Confirmed bug
Milestone

Comments

@Fabien-B
Copy link

Fabien-B commented Nov 26, 2024

I tried debugging an STM32F722 with blackmagic probe, and it worked... until my code grew bigger.
I looked into the code, the memory region for both flash and RAM are incorrect.

How to reproduce

  • Place a breakpoint in a code located after 0x210000 (flash on ITCM interface)
  • set mem inaccessible-by-default off
  • Run code: the code does not stop at the breakpoint

Solution

RAM

It had no effect in my situation, but I replaced these two lines:

target_add_ram32(target, 0x20000000, 0x20000); /* 128kiB DTCM RAM */
target_add_ram32(target, 0x20020000, 0x60000); /* 384kiB RAM */

with

target_add_ram32(target, 0x20000000, 0x10000); /* 64kiB DTCM RAM */
target_add_ram32(target, 0x20010000, 0x30000); /* 192kiB RAM */

Flash

And I made it work by replacing these 2 lines:

if (is_f7)
stm32f4_add_flash(target, ITCM_BASE, 0x10000, 0x4000, 0, split);

with

if (is_f7) {
    stm32f4_add_flash(target, ITCM_BASE, 0x10000, 0x4000, 0, split);
    stm32f4_add_flash(target, ITCM_BASE+0x10000, 0x10000, 0x10000, 4, split);
    stm32f4_add_flash(target, ITCM_BASE+0x20000, 0x60000, 0x20000, 5, split);
}

Which is exactly the code a few lines below, except the STM32F72xxx is not dual bank.

if (use_dual_bank) {
if (is_f7) {
const uint32_t bank1_base = ITCM_BASE + bank_length;
stm32f4_add_flash(target, bank1_base, 0x10000, 0x4000, 0, split);
stm32f4_add_flash(target, bank1_base + 0x10000U, 0x10000, 0x10000, 4, split);
stm32f4_add_flash(target, bank1_base + 0x20000U, remaining_bank_length, 0x20000, 5, split);
}

Next steps

I am not confident in doing a pull request because of the intricate code paths.
If I had to do it, I would probably try to replace all the if... else... by an array of structures defining the memory map for each devices. I am not sure that this is the path you want to take, and maybe there are issues with this method I don't foresee, so I am leaving it to you to decide what to do.

@dragonmux dragonmux added the Bug Confirmed bug label Nov 26, 2024
@dragonmux dragonmux added this to the v2.0 release milestone Nov 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Confirmed bug
Projects
None yet
Development

No branches or pull requests

2 participants