-
Notifications
You must be signed in to change notification settings - Fork 7.6k
Using xSemaphoreTake() in task running httpUpdate.update() breaks httpUpdate.update() #7967
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
Comments
I just made and tested a new branch with an even simpler version of the problem. In this branch:
The problem still exists exactly as described above... permitting |
I've further simplified the example and just merged it into master on my example repo: https://github.com/papakpmartin/ota-troubleshooting-freertos What I think I'm seeing... In a project that will use
|
FWIW, I did see that @Jason2866 has sometimes recommended a special platform build that Tasmota uses that resolves some networking issues, but using that seemed to make no difference to what I'm observing here. |
Semaphores are pretty basic - they are native to FreeRTOS. I'm certain that the httpUpdate library has no conflicts with Semaphores. I've looked at your demo project a couple times. Observations: While clever, you are doing things pretty differently than the httpUpdate example. |
Thanks for taking a look at this, @mrengineer7777! I am pretty new to using semaphores (and FreeRTOS), but the intention of starting with the delay was to try to ensure it didn't fire right away. Otherwise, most of the time I have the delay at the end. For So maybe I should ask:
|
In that case I would use delay() in the beginning of the task as you have done.
Using the semaphore from multiple tasks is almost guaranteed to cause issues. I would set a flag or call a function to stop I2C communication during the OTA update. Also pause any other services that might interfere with the OTA process.
Yes
There are low level ways to clear an I2C bus on startup. The basic concept is to set the I2C clock pin as open drain or strong output. Toggle it X times to get any slaves to release their clock-stretching hold. Optionally monitor I2C data pin (input) to see when it stays high. If I recall correctly it takes 8-16 clock cycles to clear an I2C bus. Keep in mind minimum pulse width on the clock toggling. |
Wow... this is extremely helpful! I did end up "getting around this" by using a flag... it sounds like "getting around this" was probably just "doing it right". :) Thanks so much for this and your time! |
Board
ESP32-S2
Device Description
Example code can be found here.
If
xSemaphoreTake()
is used, the actual file download ofhttpUpdate.update()
slows down, acts erratically, and very often doesn't complete, allowing enough time for the watchdog to kick in and reboot the device. See debug below for what it looks like when it fails.In the example repo noted above, I have these three vars in place:
Comment out
#define MUTEX_USE_INSIDE_OF_COMMS 1
and the update works perfectly and reliably. Uncommented and the failures occur.“Interesting” part of the code is below. No other mutex of any kind is used anywhere else in the example project.
Hardware Configuration
Two I2C busses are setup but not used. (I wanted to leave that in the example code since my real code uses them, in case I2C is a factor.)
Version
v2.0.7
IDE Name
VS Code + Platformio
Operating System
macOS 12.5.1
Flash frequency
40MHz
PSRAM enabled
no
Upload speed
460800
Description
I would expect to be able to
xSemaphoreTake()
without any adverse effect onhttpUpdate.begin()
.Sketch
Debug Message
Other Steps to Reproduce
No response
I have checked existing issues, online documentation and the Troubleshooting Guide
The text was updated successfully, but these errors were encountered: