-
Notifications
You must be signed in to change notification settings - Fork 8.3k
ethernet: stm32h7: Move DMA buffers from sram3 to sram2 #54217
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
ethernet: stm32h7: Move DMA buffers from sram3 to sram2 #54217
Conversation
|
@rlezuo1 That's odd. I'd like to know more about what goes wrong. Is your build using sram2 for anything else? As I understand the issue, the 8ed12ae patch works by force-flushing the AXI SRAM (D1 domain), where your dma buffers are currently positioned. Moving the buffers to an AHB SRAM area (D2 domain) removes the need for flushing. This is the solution ST recommends, and it is already merged into Zephyr. Now we just need to make it work for targets that lack sram3. |
|
@zagor sram2 is not in use, the bootloader leaves some bytes in sram4 though. dma_tx_buffer_ends up @ 0x24000000. Perhaps this change depends on some other commits which have been merged after v3.2.0 ? It applied cleanly and looked plausible though. |
|
@rlezuo1 I just tried this on v3.2.0 and it works fine on my H742 board. Are you able to debug your target and see more details about what goes wrong? |
Wait a minute. 0x24000000 is the AXI SRAM, SRAM2 is located at 0x30004000. |
|
You've pushed me the right direction with that address comment, I've found the reason it does not work, you'll like that one, there is a very subtle difference in sram2 addresses across h7 product lines it seems, screenshot from h723/733, h725/735, h730 RM: with above patch applied sram2 DMA buffers work as expected |
Ouch, that's pretty severe and needs a separate PR. Do you want to do it @rlezuo1 or shall I? |
Actually we've done rather intensive testing on STM32 ethernet recently. We didn't notified specific issue, at least the one you mention. |
|
@erwango No it does not require DEBUG_CONFIG=y, bug triggers when: CONFIG_ETH_STM32_HAL_USE_DTCM_FOR_DMA_BUFFER=n results in crash before main starts |
ETH_STM32_HAL_USE_DTCM_FOR_DMA_BUFFER is F7 specific, so you basically mean ethernet is broken for H7. |
|
To clarify, the bug that this PR is about is #29915. It manifests as Unfortunately, the #30403 fix assumes the existence of sram3. If sram3 does not exist, it silently reverts to putting ethernet DMA buffers in AXI SRAM, which is what causes bug #29915. |
erwango
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had a look to sram2 definition on other H7 devices and I'm not 100% confident they are correctly done (for instance stm32h7a3 defines AXI SRAM Address, some sram2 regions declare 384K) and that change is 100% harmless on existing configurations: what is the impact on users already using sram2 in cacheable configuration?
I agree this is a required change but given we're a bit late in the party to merge risky change, can you re-arrange this PR in order not to impact SoC that currently use SRAM3 ?
In next DV we'll take time to revisit this, review existing SRAM descriptions, ensure this is harmless on existing configuration or notify users otherwise.
7e9a0e8 to
71dd619
Compare
|
Patch updated, now uses sram3 if available and sram2 otherwise. I don't have both kinds of targets to test on but I built a sample for 723 and 753 and could see that the buffers end up in sram2 on the 723 and sram3 on the 753: |
PR zephyrproject-rtos#30403 implemented nocache regions for ethernet DMA buffers in sram3 to fix issue zephyrproject-rtos#29915. Unfortunately, some STM32H7 variants do not have any sram3 so they still suffer from zephyrproject-rtos#29915. All H7 variants have sram2 though, so use that for targets without sram3. Signed-off-by: Björn Stenberg <[email protected]>
erwango
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the quick change.
This is fine for me.
71dd619 to
7aa344a
Compare

PR #30403 implemented nocache regions for ethernet DMA buffers in sram3 to fix issue #29915. Unfortunately, chip variants STM32H742xx do not have any sram3, so they still suffer from #29915.
All H7 variants have sram2 though, so lets use that instead.
(Additionally, I removed the ifdef
DT_NODE_HAS_STATUS(DT_NODELABEL(sramX), okay)because it hid the problem. The H7 ethernet driver requires nocache dma buffers, we should not let the build succeed without them.)Fixes #29915