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

Fix insertion location of trap section in ram #605

Merged
merged 3 commits into from
Jun 23, 2023
Merged

Conversation

MabezDev
Copy link
Member

@MabezDev MabezDev commented Jun 21, 2023

Although it shouldn't matter where the trap section is located in IRAM, it seems it does. Placing it before other IRAM items seems to resolve #604.

Must

  • The code compiles without errors or warnings.
  • All examples work.
  • cargo fmt was run.
  • Your changes were added to the CHANGELOG.md in the proper section.
  • You updated existing examples or added examples (if applicable).
  • Added examples are checked in CI

Nice to have

  • You add a description of your work to this PR.
  • You added proper docs for your newly added features and code.

Closes #604

@MabezDev MabezDev marked this pull request as ready for review June 23, 2023 09:36
@bjoernQ
Copy link
Contributor

bjoernQ commented Jun 23, 2023

This will fix the problem of esp-wifi not working anymore with the latest HAL 🎉

The reason might be:

  [ 7] .rwtext           PROGBITS        40380000 0df000 000850 00  AX  0   0  4
  [ 8] .trap             PROGBITS        40380900 0df900 000c74 00  AX  0   0 256
  [ 9] .rwtext.wifi      PROGBITS        40381574 0e0574 002dfe 00  AX  0   0  2
  [10] .rwdata_dummy     NOBITS          3fc80000 0e4000 0042c2 00  AX  0   0  1
  [11] .data             PROGBITS        3fc842c8 0e42c8 001296 00  WA  0   0  8
  [12] .bss              NOBITS          3fc85560 0e5560 026b90 00  WA  0   0  8
  [13] .noinit           NOBITS          3fcac0f0 0e5560 000000 00  WA  0   0  4
  [14] .data.wifi        PROGBITS        3fcac0f0 0e60f0 000168 00  WA  0   0  4
  [15] .heap_start       NOBITS          3fcac258 0e6258 000000 00  WA  0   0  4

Here .trap ends up at 0x40380900 while .rwtext is just 0x850 sized. That's because of .balign 0x100 for the vector-table.
In .rwdata_dummy we just use SIZEOF to calculate the total size of .rwdata_dummy and so .data and .rwtext will overlap in SRAM.

Placing .trap first makes it match the alignment requirement without an additional gap

Copy link
Contributor

@bjoernQ bjoernQ left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we need this fix also for db-riscv-link.x and mb-riscv-link.x files

@MabezDev MabezDev force-pushed the fix-riscv-trap-sections branch from 4bfb5fe to 52683bb Compare June 23, 2023 10:34
@MabezDev
Copy link
Member Author

Nice find, that makes total sense! I've added the changes to the DB and MCUboot scripts.

@MabezDev MabezDev requested a review from bjoernQ June 23, 2023 10:36
Copy link
Contributor

@bjoernQ bjoernQ left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for fixing this

@MabezDev MabezDev merged commit 087bfa5 into main Jun 23, 2023
MabezDev added a commit that referenced this pull request Jul 12, 2023
* Fix insertion location of trap section in ram

* Apply fixes for db and mcuboot

* Add changelog
playfulFence pushed a commit to playfulFence/esp-hal that referenced this pull request Sep 26, 2023
* Fix insertion location of trap section in ram

* Apply fixes for db and mcuboot

* Add changelog
@jessebraham jessebraham deleted the fix-riscv-trap-sections branch July 3, 2024 13:19
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

Successfully merging this pull request may close these issues.

embassy examples panic for riscv
3 participants