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 esp32 timer issues #2697

Merged
merged 4 commits into from
Jan 8, 2024
Merged

Fix esp32 timer issues #2697

merged 4 commits into from
Jan 8, 2024

Conversation

mikee47
Copy link
Contributor

@mikee47 mikee47 commented Jan 8, 2024

HostTests fails on esp32 due to following issues:

Flawed hw_timer2_read() implementation

Without setting update bit counter value won't change. Probably worked previously because some other code did this.

WDT with callback timers

Checked against IDF implementations and there's a missing flag which keeps interrupts initially disabled during setup.

Callbacks missing during timer testing

Offending code looks like this:

Timer timer;
String s;
s += timer; //<< Not what I expected

The above line actually calls the Timer copy constructor. Delete this and the compiler catches the error. The corrected line now reads s += String(timer).

HostTests needs more program space for ESP32

Builds are getting chunky!

mikee47 added 4 commits January 8, 2024 09:03
Without setting update bit counter value won't change.
Probably worked previously because some other code did this.
e.g.

```
String s;
s += timer;
```

Doesn't behave as expected and instead constructs new instance then calls destructor on it.
Manifests by hanging HostTests on esp32 (standard, s2 and c3 variants) but curiously not on esp8266 or host.
@SmingHub SmingHub deleted a comment from what-the-diff bot Jan 8, 2024
@mikee47
Copy link
Contributor Author

mikee47 commented Jan 8, 2024

@slaff Some of the what-the-diff comments are pretty unhelpful so I tend to delete them. (Others are surprisingingly accurate, though!)

@slaff slaff added this to the 5.2.0 milestone Jan 8, 2024
@slaff slaff merged commit e890519 into SmingHub:develop Jan 8, 2024
36 checks passed
@mikee47 mikee47 deleted the fix/esp32-timer branch January 8, 2024 19:44
mikee47 pushed a commit to mikee47/Sming that referenced this pull request Jan 31, 2024
IDF version 5 changed some low-level HAL calls to accept bit masks instead of timer index.
This is the root cause of the WDT allegedly fixewd in SmingHub#2697.
However, all we did there was disable interrupts and callback timers never actually worked.
mikee47 pushed a commit to mikee47/Sming that referenced this pull request Jan 31, 2024
PR SmingHub#2697 was supposed to fix the WDT from hardware timer interrupts.
It did this by disabling interrupts (and therefore callbacks) completely.

The actual reason for the WDT is twofold:

1. IDF version 5 changed some low-level HAL calls to accept bit masks instead of timer index.
2. Argument to interrupt callback wasn't stored or passed correctly so user-provided callback got junk for this parameter.
slaff pushed a commit that referenced this pull request Jan 31, 2024
Fix esp32 hardware timer callbacks

PR #2697 was supposed to fix the WDT from hardware timer interrupts.
It did this by disabling interrupts (and therefore callbacks) completely.

The actual reason for the WDT is twofold:

1. IDF version 5 changed some low-level HAL calls to accept bit masks instead of timer index.
2. Argument to interrupt callback wasn't stored or passed correctly so user-provided callback got junk for this parameter.

This PR fixes those issues and fixes incomplete testing in HostTests.

Also checked Basic_Blink sample using HardwareTimer.
@slaff slaff mentioned this pull request Feb 5, 2024
5 tasks
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.

2 participants