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

Crash with framework-arduinoespressif32 Version 2.0.2 #1713

Closed
FrankBoesing opened this issue Dec 28, 2021 · 16 comments · Fixed by #1715
Closed

Crash with framework-arduinoespressif32 Version 2.0.2 #1713

FrankBoesing opened this issue Dec 28, 2021 · 16 comments · Fixed by #1715
Assignees

Comments

@FrankBoesing
Copy link
Contributor

FrankBoesing commented Dec 28, 2021

Version/revision of the library used

2.8

Describe the bug

ESP32, Platformio, receive on PIN 34,
framework-arduinoespressif32 @ https://github.com/espressif/arduino-esp32.git#2.0.1
Enabled log prints the warning:

[ 8179][W][esp32-hal-timer.c:271] timerAttachInterrupt(): EDGE timer interrupt does not work properly on ESP32! Setting to LEVEL...

Worse with framework-arduinoespressif32 Version 2.0.2:
Same warning, but even crashes - ESP32 reboots, with unusable callstack-print on first interrupt.

@crankyoldgit
Copy link
Owner

Well, that's a bummer.

Can you please try older versions of the framework-arduinoespressif32 e,g, https://github.com/espressif/arduino-esp32/releases/tag/1.0.5 for now.

I think this is related to our horrible hack in #1350

Looks like the way they've done the hardware timers has changed in IDF 2.0+

We will have to change how we support hardware timers for the ESP32 for ESP32 IDF < 2.0 (existing) and >= 2.0 (not yet supported)

@crankyoldgit crankyoldgit self-assigned this Dec 28, 2021
@FrankBoesing
Copy link
Contributor Author

FrankBoesing commented Dec 28, 2021

Oh, it works perfectly - despite of the "EDGE timer interrupt does not work properly" message with 2.0.1

But it crashes with 2.02.

@crankyoldgit
Copy link
Owner

That's because 2.0.2 changed how the timers are handled in https://github.com/espressif/arduino-esp32/pull/5931/files
and we have a horrible hack to work around an issue in < 1.5. That hack relies on the previous way timers worked internally.

I'll have to change our code to use the hack for 2.0.1 and not use the hack for 2.0.2.
It will take some time and testing to come up with a working solution.

@NiKiZe
Copy link
Collaborator

NiKiZe commented Dec 28, 2021

Can/should we add/have a temporary #error "Timers in 2.0.2 is not yet supported"
And while add it add something similar for some other unsupported platforms ? (those that we get questions about from time to time)

@crankyoldgit
Copy link
Owner

Can/should we add/have a temporary #error "Timers in 2.0.2 is not yet supported" And while add it add something similar for some other unsupported platforms ? (those that we get questions about from time to time)

I've been working to try to find how to determine via predefined compiler #define for what version arduino-esp32 framework is in use so we can do a greater than/less than comparison. If someone know that off the top of their head, I'd appreciate it.

@FrankBoesing
Copy link
Contributor Author

Hi, #defines should be in https://github.com/espressif/arduino-esp32/blob/idf-release/v4.4/cores/esp32/esp_arduino_version.h#L22

...But it looks like they are not updated... they still say 2.0.0

@crankyoldgit
Copy link
Owner

Sigh. I think I have a work around but for the life of me I can't seem to see the #defines exposed in esp_arduino_version.h
e.g.

#include <Arduino.h>  // Which should include esp_arduino_version.h

#if !defined(ESP_ARDUINO_VERSION_MAJOR)
#error ESP_ARDUINO_VERSION_MAJOR not defined
#endif

Results in: (Not from the exact same code as above, but effectively the same)

/home/david/git/IRremoteESP8266/src/IRrecv.cpp:69:2: error: #error ESP_ARDUINO_VERSION_MAJOR not defined
 #error ESP_ARDUINO_VERSION_MAJOR not defined
  ^

Any suggestions?

@crankyoldgit
Copy link
Owner

crankyoldgit added a commit that referenced this issue Dec 30, 2021
Later versions of the arduino esp32 framework change how hardware timers work, so our hack breaks spectularly.

Check for when we are using V2.0.0+ and use the normal commands to do the hardware timers, otherwise, for older versions, keep the hack.

For #1713
@crankyoldgit
Copy link
Owner

Any suggestions?

I think my "problem" was assuming that esp_arduino_version.h existed in earlier versions of the framework. Looks like it's a recent addition. i.e. v2 or later

@FrankBoesing I've created a potential fix in branch: https://github.com/crankyoldgit/IRremoteESP8266/tree/Issue1713
Can you please try it out with old and new versions of the library?

@FrankBoesing
Copy link
Contributor Author

Hi, it works with 2.0.1 and 2.02 now, without warnings. Thank You!!

@FrankBoesing
Copy link
Contributor Author

Sorry, the warning is still there. Did'nt see it the first time..

However - it works.

@crankyoldgit
Copy link
Owner

Is the warning exactly the same as before?

What I find interesting is we don't set the EDGE or LEVEL of the interrupt in the timer code.

We do use EDGE on the gpio interrupt. Thus I'm not sure why it's mentioning timers.

@crankyoldgit
Copy link
Owner

What I find interesting is we don't set the EDGE or LEVEL of the interrupt in the timer code.

Well, I was incorrect it seems. We were unintentionally requesting it. The timerAttachInterrupt() routine was doing the correct thing for us anyway, so the latest change to that branch should address the warning message and have no impact to the library at all.

@FrankBoesing Care to test it again please?

@FrankBoesing
Copy link
Contributor Author

The warning is no longer shown. Many Thanx!

@FrankBoesing
Copy link
Contributor Author

I think this can be closed now.

crankyoldgit added a commit that referenced this issue Dec 31, 2021
* arduinoespressif32 Version 2+ no longer needs the horrible timer hack.
Later versions of the arduino esp32 framework change how hardware timers work, so our hack breaks spectularly.

Check for when we are using V2.0.0+ and use the normal commands to do the hardware timers, otherwise, for older versions, keep the hack.

* Avoid using EDGE trigger on timer Interrupt as it is not supported apparently.

Fixes #1713
crankyoldgit added a commit that referenced this issue Jan 1, 2022
## _v2.8.1 (20220101)_

**[Bug Fixes]**
- Arduino ESP32 Core v2.0.2+ crashes due to our timer hack. (#1715 #1713 )
- SONY: Fix old Sony CD-Player Remote (12 Bit) (#1714)

**[Features]**
- Add tool to convert protocol & code to raw timing info. (#1708 #1707 #1703)
- Add basic support for COOLIX48 protocol. (#1697 #1694)
- MITSUBISHI_AC: Added support for i-SAVE mode. (#1666)
- TOSHIBA_AC: Add Filter setting support. aka. Pure. (#1693 #1692)
- Airton: Add detailed A/C support. (#1688 #1670)

**[Misc]**
- Add a structured library version number. (#1717)
- Workflows Split UnitTests (#1712)
- Reduce time for workflow/Build (#1709)
- Fix some compiler & linter warnings (#1699 #1700)
- Fujitsu: Update supported A/C models (#1690 #1689 #1702 #1701)
- Remove extra `const` qualifier for char pointer (#1704)
- TCL: Update supported devices. (#1698)
- ESP32-C3: Work around for some C3 specific compiler issues. (#1696 #1695)
@crankyoldgit
Copy link
Owner

FYI, the changes mentioned above have now been included in the new v2.8.1 release of the library.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants