-
Notifications
You must be signed in to change notification settings - Fork 7.3k
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
esp_eth: Cache disabled but cached memory region accessed (IDFGH-2263) #4406
Comments
Problems like this are relevant not only in the SPIRAM_MALLOC_ALWAYSINTERNAL = 0 case. They can also occur under heavy load, when the memory is nearly exhausted. |
Cool, nice found! Yes we should make sure Ethernet driver can run under cache disabled (OTA with Ethernet). |
With the current master it's much worse. Lots of InstrFetchProhibited, all seem to be ethernet/esp_netif/glue related. Wifi doesn't work either. |
Thanks for your reporting! @szmodz Could you post your backtrace, sdkconfig and test code here? Or could you tell us how to reproduce this issue based on any of the examples inside esp-idf? |
Ok, but this is going to take a while. It's not as simple as it seemed initially. But it's very reproducible. The backtrace doesn't explain much, it's a double exception (yay). |
The rest is nonsense. I'm not excluding an issue on my side, but the same code worked fine under heavy load for 3 days with the previous master. |
seems this is the cause: |
@szmodz Thanks for reporting, feel free to reopen if the issue still happens. Thanks. |
@Alvin1Zhang The problem is not solved. My last comment was referring to this: Instead, that turned out to be caused by #4541. The original problem remains. Sorry for the confusion. I can't reopen the issue myself. |
I test the basic Ethernet example with |
@suda-morris did you try OTA?
|
@suda-morris you don't need a test case for this. Visual inspection shows what the problem is.
emac_esp32_t (which contains emac_hal_context_t) is allocated using calloc, which returns a PSRAM pointer. Later, there's
(ESP_INTR_FLAG_IRAM) |
@suda-morris The driver works fine after fixing the PSRAM usage bugs. GPIO setup is ok. |
@szmodz Ah yes, thanks for your detailed reporting, now we can reproduce it. |
There is another issue here: esp-idf/components/esp_eth/src/esp_eth.c Line 174 in 647cb62
esp-idf/components/esp_eth/src/esp_eth.c Line 364 in 647cb62
atomic_fetch_add / atomic_fetch_sub can't be used with PSRAM addresses as they rely on s32c1i. Using stdatomic.h with PSRAM can cause some VERY hard to find problems. Probably should report a separate bug.
|
add ETH_MAC_FLAG_WORK_WITH_CACHE_DISABLE flag, make ethenret driver possible to work when cache disabled Closes #4406
add ETH_MAC_FLAG_WORK_WITH_CACHE_DISABLE flag, make ethenret driver possible to work when cache disabled Closes espressif/esp-idf#4406 * Original commit: espressif/esp-idf@5ad0bdd
add ETH_MAC_FLAG_WORK_WITH_CACHE_DISABLE flag, make ethenret driver possible to work when cache disabled Closes espressif/esp-idf#4406 * Original commit: espressif/esp-idf@5ad0bdd
add ETH_MAC_FLAG_WORK_WITH_CACHE_DISABLE flag, make ethenret driver possible to work when cache disabled Closes espressif/esp-idf#4406 * Original commit: espressif/esp-idf@5ad0bdd
add ETH_MAC_FLAG_WORK_WITH_CACHE_DISABLE flag, make ethenret driver possible to work when cache disabled Closes espressif/esp-idf#4406 * Original commit: espressif/esp-idf@5ad0bdd
add ETH_MAC_FLAG_WORK_WITH_CACHE_DISABLE flag, make ethenret driver possible to work when cache disabled Closes espressif/esp-idf#4406 * Original commit: espressif/esp-idf@5ad0bdd
add ETH_MAC_FLAG_WORK_WITH_CACHE_DISABLE flag, make ethenret driver possible to work when cache disabled Closes espressif/esp-idf#4406 * Original commit: espressif/esp-idf@5ad0bdd
esp_eth is using plain calloc to allocate the driver structures. This causes problems when SPIRAM_MALLOC_ALWAYSINTERNAL is set to 0 (or some other small value).
This happens in the latest master (93a8603).
For example,
esp-idf/components/esp_eth/src/esp_eth_phy_lan8720.c
Line 381 in 93a8603
Perhaps there are more similar problems. I think the codebase should be tested with SPIRAM_MALLOC_ALWAYSINTERNAL set to 0.
The text was updated successfully, but these errors were encountered: