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

esp32c3 #1751

Closed
hydrafi opened this issue Jan 29, 2022 · 28 comments · Fixed by #1768
Closed

esp32c3 #1751

hydrafi opened this issue Jan 29, 2022 · 28 comments · Fixed by #1768
Assignees
Labels
ESP32 ESP32 only issue Hardware Pending Confirmation Waiting for confirmation from user

Comments

@hydrafi
Copy link

hydrafi commented Jan 29, 2022

with esp32c3 device

Guru Meditation Error: Core 0 panic'ed (Load access fault). Exception was unhandled.

Core 0 register dump:
MEPC : 0x420193de RA : 0x42000d4c SP : 0x3fc948e0 GP : 0x3fc8b000
TP : 0x3fc8b424 T0 : 0x4005890e T1 : 0x403848e6 T2 : 0x00000000
S0/FP : 0x00000000 S1 : 0x00000000 A0 : 0x00000000 A1 : 0x0000c350
A2 : 0x0000c350 A3 : 0x00000000 A4 : 0x0000009f A5 : 0x00000032
A6 : 0x3fe00000 A7 : 0x00040000 S2 : 0x3fc8d1bc S3 : 0x00000000
S4 : 0x00000000 S5 : 0x00000000 S6 : 0x00000000 S7 : 0x00000000
S8 : 0x00000000 S9 : 0x00000000 S10 : 0x00000000 S11 : 0x00000000
T3 : 0xffffffff T4 : 0x00000000 T5 : 0x00000000 T6 : 0x00000000
MSTATUS : 0x00001881 MTVEC : 0x40380001 MCAUSE : 0x00000005 MTVAL : 0x00000001
MHARTID : 0x00000000

@NiKiZe
Copy link
Collaborator

NiKiZe commented Jan 29, 2022

You will probably need to provide more details, exactly which code is running and when does it happen?

@hydrafi
Copy link
Author

hydrafi commented Jan 30, 2022

sorry,
I tried IRrecvDemo example and with esp32 run correctly, with esp32c3 reboot continuosly after irrecv.enableIRIn(); istruction ...
thanks
rgds
Max

@crankyoldgit
Copy link
Owner

My guess is that there is something not quite right with the ESP core library for the ESP32-C3.
I don't have a C3, so I'll look at ordering one.

As you said it is working on the normal ESP32, I'm going to have to ask you for all the exact versions of this library you're using, and the relevant core library versions for BOTH your ESP32 and the ES_32-C3 so a) it can be replicated, and b) determined if it is our library's code that is the problem, or c) If it's a bug in the C3 version.

Also, can you please add the following to the "IRremoteESP8266.h" file:

#define _ESP32_IRRECV_TIMER_HACK false

Put it after:

#define IRREMOTEESP8266_H_

Also can you please confirm/check what the values of the following #defines are, or if they are defined at all:
ESP32, ESP_ARDUINO_VERSION_MAJOR, ESP_ARDUINO_VERSION_MINOR, ESP_ARDUINO_VERSION_PATCH

@crankyoldgit
Copy link
Owner

Oh, and what ESP32-C3 dev board are you using, so I can try to get the same?

@crankyoldgit crankyoldgit added the ESP32 ESP32 only issue label Jan 31, 2022
@hydrafi
Copy link
Author

hydrafi commented Feb 1, 2022

Oh, and what ESP32-C3 dev board are you using, so I can try to get the same?

ESP32-C3-DevKitM-1

library -> Arduino by Espressif System 2.0.2

I will try your proposal and update you
tks
M

@crankyoldgit
Copy link
Owner

Oh, and can you please try installing/running the same example code without anything plugged in to the board, other than the USB cable of course. Just to eliminate any hardware/wiring issues.

@crankyoldgit
Copy link
Owner

I've ordered a board, but that will take weeks & weeks to arrive.

@crankyoldgit
Copy link
Owner

Oh, and what ESP32-C3 dev board are you using, so I can try to get the same?

ESP32-C3-DevKitM-1

library -> Arduino by Espressif System 2.0.2

I will try your proposal and update you tks M

Also, what is the version of the IRremoteESP8266 library?

@crankyoldgit
Copy link
Owner

Oh, and can you please try installing/running the same example code without anything plugged in to the board, other than the USB cable of course. Just to eliminate any hardware/wiring issues.

@hydrafi Have you tried the above?

@crankyoldgit
Copy link
Owner

The ESP-C3 board I ordered arrived today.
I'll try to test it out soon.
Did you try the earlier suggestions?

@crankyoldgit crankyoldgit self-assigned this Mar 1, 2022
@crankyoldgit
Copy link
Owner

I just tried building this and got an error message of:

Error: This board doesn't support arduino framework!

@hydrafi Can you please post the platformio.ini file you are using to build with so I can replicate it?

@hydrafi
Copy link
Author

hydrafi commented Mar 1, 2022 via email

@hydrafi
Copy link
Author

hydrafi commented Mar 2, 2022

Hi,
I tried again with #define _ESP32_IRRECV_TIMER_HACK false, no change ....

In Arduino IDE 1.8.19 I have installed library -> Arduino by Espressif System 2.0.2 and no problem with ESP32C3 dev module
this is the ref to install that
https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_dev_index.json
Visualmicro & Visual code works too
I do not know if platformio support C3

example used is IRrecvDEMO and the target has only 2 components, ESP-kit + IRreceiver. Only my change is the pin used to IRreceived ..
my IRremoteESP8266 version is 2.8.1

@crankyoldgit
Copy link
Owner

Good news: I can kind-of replicate the crash. Bad news: I have no idea what is causing it yet.

@crankyoldgit
Copy link
Owner

I've seemed to have narrowed it down to the pinMode() call in IRrecv::enableIRIn(), not sure why that is causing the device to go crazy.

@crankyoldgit
Copy link
Owner

crankyoldgit commented Mar 4, 2022

I think I've found a/the problem. It is the use of GPIO 14, that seems to be used by the USB connection on the dev board for C3 devices.
It causes the board to crash by making that pin an INPUT. Probably causing a short circuit/current loop etc.

Using:

const uint16_t kRecvPin = 10;

Seemed to get to the main loop.

@hydrafi Can you please test that out?

@crankyoldgit
Copy link
Owner

crankyoldgit added a commit that referenced this issue Mar 4, 2022
Seems `14` was a poor default for the ESP-C3. Using it causes a reboot.
Using `10` for the input GPIO avoids the crash.

Fixes #1751
@crankyoldgit crankyoldgit added the Pending Confirmation Waiting for confirmation from user label Mar 4, 2022
@crankyoldgit
Copy link
Owner

@hydrafi Can you please try the code in branch: https://github.com/crankyoldgit/IRremoteESP8266/tree/espc3 / PR #1768 ?

Please let me know how it goes.
You will need to use the new versions of the examples. The core of the library has not been changed.

I've partly tested this on my ESP32-C3 board. I've not tried to capture an IR signal on it yet, but it doesn't crash/boot-loop like it did, thus I'm considering it fixed.

@crankyoldgit
Copy link
Owner

crankyoldgit commented Mar 4, 2022

As a note for those trying to use PlatformIO to build the examples on an ESP32-C3, you need something like the following in the platformio.ini file:

[env:esp32c3]
platform = espressif32
platform_packages =
    toolchain-riscv-esp
    framework-arduinoespressif32@https://github.com/espressif/arduino-esp32.git#cbcba53
    platformio/tool-esptoolpy @ ~1.30100
framework = arduino
board = esp32dev
board_build.mcu = esp32c3
board_build.variant = esp32c3
board_build.f_cpu = 160000000L
board_build.f_flash = 80000000L
board_build.flash_mode = dio
board_build.arduino.ldscript = esp32c3_out.ld
build_unflags =
    -DARDUINO_ESP32_DEV
    -DARDUINO_VARIANT="esp32"
build_flags =
    -DARDUINO_ESP32C3_DEV
    -DARDUINO_VARIANT="esp32c3"
  ; -D_IR_LOCALE_=en-AU

@hydrafi
Copy link
Author

hydrafi commented Mar 4, 2022

I had used gpio3 however I tried your new example sketch with gpio10 but nothing has changed. I don't know platformio, can you post the bin file that I try it?

@crankyoldgit
Copy link
Owner

I had used gpio3 however I tried your new example sketch with gpio10 but nothing has changed. I don't know platformio, can you post the bin file that I try it?

@hydrafi Try this:
IRrecvDumpV3-espc3-20220305.zip

@hydrafi
Copy link
Author

hydrafi commented Mar 5, 2022

Hi, good news.
Your bin run.
Not clear why?
I debugged / traced verifying that the statement "timer = timer Begin (_timer_num, 80, true);" in line 455 of IRrecv.cpp which defaults to 3 in _timer_num crash.
ESP32C3 has only 2 timers (https://docs.espressif.com/projects/arduino-esp32/en/latest/api/timer.html).
If you set 0 or 1 my compilation works too.

@crankyoldgit
Copy link
Owner

That's great to know. I'll look at the timers used soon as well.
It could be that I'm using a slightly different version of the ESP32 Arduino core. Not sure why

@crankyoldgit crankyoldgit removed more info Pending Confirmation Waiting for confirmation from user labels Mar 5, 2022
crankyoldgit added a commit that referenced this issue Mar 5, 2022
* Add debug messages & a runtime assert to ensure we correctly allocated a system timer in `IRrecv::enableIRIn()`.
* Limit the max number of the system timer to the appropriate size for the ESP32. ESP32-C3's only have two system timers (0-1), the rest have 4 (0-3).
* Done in such a way it should be correct for future ESP32 models.

Ref: https://docs.espressif.com/projects/arduino-esp32/en/latest/api/timer.html

Fixes #1751
crankyoldgit added a commit that referenced this issue Mar 5, 2022
Fixes a compile error on older/normal ESP32 Arduino framework/cores.

For #1751
@crankyoldgit
Copy link
Owner

@hydrafi I've updated that branch & PR #1768. This time there is a library change. Can you please build against that version of the library.
It should ensure that only a timer of 0 or 1 is used for an ESP32-C3, thus hopefully fix the issue you're having.

@crankyoldgit crankyoldgit added the Pending Confirmation Waiting for confirmation from user label Mar 8, 2022
@crankyoldgit
Copy link
Owner

@hydrafi Chasing up on this. Can you confirm if the recent changes now construct a binary for the ESP32-C3 that doesn't crash from the examples without any modifications in your build environment/hardware?
i.e. Can we safely merge this into the master branch?

@hydrafi
Copy link
Author

hydrafi commented Mar 8, 2022

ok

@hydrafi hydrafi closed this as completed Mar 8, 2022
crankyoldgit added a commit that referenced this issue Mar 8, 2022
- Seems an irrecv gpio of `14` was a poor default for the ESP-C3. Using it causes a reboot.
  - Using `10` for the input GPIO avoids the reboot.
- Ensure when we allocate/use a system timer, that it actually succeeds.
  - ESP32-C3 only has two system timers (0 & 1). Try to automatically cater for that scenario.
  - Add extra debug messages
  - Add a run-time assert to check it succeeded.

Fixes #1751
crankyoldgit added a commit that referenced this issue Mar 14, 2022
_v2.8.2 (20220314)_

**[Bug Fixes]**
- ESP32-C3: Fix reboot/crashes on ESP32-C3s when receiving. (#1768 #1751)

**[Features]**
- HITACHI_AC296: Add `IRac` class support & tests. (#1776 #1758 #1757)
- Support for Hitachi RAS-70YHA3 (remote RAR-3U3) (#1758 #1757)
- LG: Add Swing Toggle support for Model `LG6711A20083V` (#1771 #1770)
- IRMQTTServer: add `MQTT_SERVER_AUTODETECT_ENABLE` via mqtt mDNS (#1769)
- Experimental basic support for Kelon 168 bit / 21 byte protocol. (#1747 #1745 #1744)
- MitsubishiAC: Tweak repeat gap timing. (#1760 #1759)
- Gree YAP0F8 (Detected as Kelvinator) vertical position set support (#1756)
- Make KELON (48 bit) protocol decoding stricter. (#1746 #1744)
- IRMQTTServer V1.6.1 (#1740 #1739 #1729)
- HITACHI_AC264: Add minimal detailed support. (#1735 #1729)
- LG2: Improve Light toggle msg handling. (#1738 #1737)
- MIDEA: Add support for Quiet, Clean & Freeze Protect controls. (#1734 #1733)
- Add basic support for HITACHI_AC264 264bit protocol. (#1730 #1729)
- ESP32-C3: Work around for some C3 specific compiler issues again. (#1732 #1695)

**[Misc]**
- MIDEA: Update supported devices (#1774 #1773 #1716)
- Update devices supported by ELECTRA_AC (#1766 #1765)
- Improve documentation for `encodePioneer()` (#1761 #1749)
- Update (un)supported DAIKIN128 devices. (#1752)
- Refactor `decodeCOOLIX()` code & add another test case. (#1750 #1748)
- Simplify code based on state_t being initialised by default. (#1736 #1699)
- Add comments to help Teknopoint users. (#1731 #1728)
- Fix library version string calculation. (#1727 #1725)
- Confirm we can reproduce `TurnOnFujitsuAC.ino` via IRac/IRMQTTServer. (#1726 #1701)
crankyoldgit added a commit that referenced this issue Mar 15, 2022
##_v2.8.2 (20220314)_

**[Bug Fixes]**
- ESP32-C3: Fix reboot/crashes on ESP32-C3s when receiving. (#1768 #1751)

**[Features]**
- HITACHI_AC296: Add `IRac` class support & tests. (#1776 #1758 #1757)
- Support for Hitachi RAS-70YHA3 (remote RAR-3U3) (#1758 #1757)
- LG: Add Swing Toggle support for Model `LG6711A20083V` (#1771 #1770)
- IRMQTTServer: add `MQTT_SERVER_AUTODETECT_ENABLE` via mqtt mDNS (#1769)
- Experimental basic support for Kelon 168 bit / 21 byte protocol. (#1747 #1745 #1744)
- MitsubishiAC: Tweak repeat gap timing. (#1760 #1759)
- Gree YAP0F8 (Detected as Kelvinator) vertical position set support (#1756)
- Make KELON (48 bit) protocol decoding stricter. (#1746 #1744)
- IRMQTTServer V1.6.1 (#1740 #1739 #1729)
- HITACHI_AC264: Add minimal detailed support. (#1735 #1729)
- LG2: Improve Light toggle msg handling. (#1738 #1737)
- MIDEA: Add support for Quiet, Clean & Freeze Protect controls. (#1734 #1733)
- Add basic support for HITACHI_AC264 264bit protocol. (#1730 #1729)
- ESP32-C3: Work around for some C3 specific compiler issues again. (#1732 #1695)

**[Misc]**
- MIDEA: Update supported devices (#1774 #1773 #1716)
- Update devices supported by ELECTRA_AC (#1766 #1765)
- Improve documentation for `encodePioneer()` (#1761 #1749)
- Update (un)supported DAIKIN128 devices. (#1752)
- Refactor `decodeCOOLIX()` code & add another test case. (#1750 #1748)
- Simplify code based on state_t being initialised by default. (#1736 #1699)
- Add comments to help Teknopoint users. (#1731 #1728)
- Fix library version string calculation. (#1727 #1725)
- Confirm we can reproduce `TurnOnFujitsuAC.ino` via IRac/IRMQTTServer. (#1726 #1701)
@crankyoldgit
Copy link
Owner

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

@Jason2866
Copy link

Jason2866 commented Mar 15, 2022

@crankyoldgit I made a custom setup for Tasmota for Platformio to use the C3, S2 and S3. Feel free to use :-)

Thx for your awesome work with IRremoteESP8266

platform = https://github.com/tasmota/platform-espressif32/releases/download/v2.0.2.3/platform-espressif32-2.0.2.3.zip
platform_packages = framework-arduinoespressif32 @ https://github.com/Jason2866/esp32-arduino-lib-builder/releases/download/733/framework-arduinoespressif32-v4.4_dev-2509ea4227.tar.gz

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ESP32 ESP32 only issue Hardware Pending Confirmation Waiting for confirmation from user
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants