-
Notifications
You must be signed in to change notification settings - Fork 4
Hang on write when using esp-wifi in the same crate #21
Comments
If only adding the dependency is causing this, then it's very odd. If you actually initialize esp-wifi in your code it makes sense. There is https://github.com/bjoernQ/esp32c3-ota-experiment which is for ESP32-C3 but I just pushed the On ESP32 this library needs to run our own version of the flash functions from RAM with flash detached. esp-wifi contains a scheduler which when it triggers runs code from flash which is not good when the flash is detached. In my example it seems to work because it's using an unreleased version of esp-storage which by defaults uses the I just tested it again and it seems I can't get |
After some trial and error, i have got it working and I have concluded the following:
are not the same.
Now I guess I'll investigate what happens to esp-wifi when thin local lto is enabled. Maybe it has improved since issues about it were opened. |
Here are some findings with different lto settings and what works and what does not on esp32:
|
Thanks for the analysis of the effects of different |
Has this been resolved then? because it still happens to me even with the suggested changes. So what am I doing wrong? |
I missed this ping, sorry folks! This should be fixed for all single core chips, hence why @bjoernQ's ESP32-C3 based project above works. For multi core, the whole world gets a bit more complicated. Neither core can access flash whilst writing to it, if you do all kinds of mayhem will ensue. To ensure the other core doesn't read the flash there needs to be some kind of software solution to say to the other core, "hey, stop until I say go". You also might not want to stop the other core at all, the other core can still run provided it doesn't refill the cache when trying to execute, so any code already in the cache, in RAM or ROM can be executed freely. So, in short, writing to flash in multicore systems is only possible when:
The only example I know of writing to flash on the esp32s3 is @bugadani's card-io-fw, and nor-fs. We don't have a generic solution for that yet. Might be some more interesting info in #26 too. |
Does your application do anything on the second core? As @MabezDev said for multi core just disabling interrupts is not enough. There was a PR addressing this by simply halting the other core when accessing the flash: #29 In my tests back then it worked but I never heard back from the user who created the original issue so it never got merged If you are only using one core it should work. Does the example in this repository work for you? |
I think the issue in my case was caused by me writing in some area where esp-wifi wanted to write. |
I attempted to make an OTA flasher for esp32 using esp-wifi and esp-storage.
Using only esp-storage, I'm able to read the partition table and I'm able to write the "otadata" partition and make it boot another partition.
However, as soon as I add esp-wifi as dependency, the embedded storage write seems to hang. This happens even if I don't call any function from esp-wifi, i just add the dependency and the necessary .cargo/config changes for it to compile.
I already tried bumping hal versions in esp-storage and adapting main for the &mut peripheral_clocks_control change. This crate works with new hal, but the issue persists. As soon as esp-wifi is added as dependency, write hangs. Very strange.
Any ideas what might be going on or what I might try?
The text was updated successfully, but these errors were encountered: