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

[Build] Add compatibility with C++20 #2040

Open
wants to merge 14 commits into
base: master
Choose a base branch
from

Conversation

tonhuisman
Copy link
Contributor

@tonhuisman tonhuisman commented Oct 6, 2023

Feature:

  • Make IRremoteESP8266 compatible with C++20
    • Fix use of deprecated volatile operators like ++ and volatile method arguments
    • Add build environment for using ESP32 IDF 5.x and fix compilation for 'regular' ESP32 environment, still using IDF 4.x
    • Fix differences for IDF 5.x build using code by Tasmota team (by @s-hadinger )

Resolves #2039

@tonhuisman
Copy link
Contributor Author

tonhuisman commented Oct 6, 2023

Looks like the linter and doxygen need some fix to support conditional compilation 👎

@NiKiZe
Copy link
Collaborator

NiKiZe commented Oct 6, 2023

Have you considered defining internal types separately, all the #if s are becoming quite messy?

@tonhuisman
Copy link
Contributor Author

Have you considered defining internal types separately, all the #if s are becoming quite messy?

I'll think about that, but IMHO it'll be about as messy... 😞

@tonhuisman
Copy link
Contributor Author

Have you considered defining internal types separately, all the #if s are becoming quite messy?

Now using typedefs for everything that was defined volatile (though most still using volatile).

platformio.ini Outdated Show resolved Hide resolved
Copy link
Collaborator

@NiKiZe NiKiZe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm for the atomic_ changes, not sure about the rest which is more relevant to platformio than c++?

platformio.ini Outdated Show resolved Hide resolved
src/IRrecv.h Outdated Show resolved Hide resolved
@Jason2866
Copy link

Jason2866 commented Oct 7, 2023

@tonhuisman Why going back to core 2.0.x? Makes no sense. The platform 2023.10.03 is NOT based on IDF5.1
The left compile error is just a missing include of gpio.h

EDIT: Comment race condition ;-)

@Jason2866
Copy link

@tonhuisman Adding this fixes the compile error and no code change regarding interrupts are needed

#if defined(ESP32)
#if ( defined(ESP_ARDUINO_VERSION_MAJOR) && (ESP_ARDUINO_VERSION_MAJOR >= 3) )
#include <driver/gpio.h>
#endif  // ESP_ARDUINO_VERSION_MAJOR >= 3
#endif
#endif  // UNIT_TEST

@tonhuisman
Copy link
Contributor Author

Adding this fixes the compile error

Thanks! 🦸
That was what I didn't know I was searching for, but had to find...

@crankyoldgit
Copy link
Owner

FYI. I've seen this PR and been thinking about how to do this "better" in a way.
My plan is to create a new branch/PR etc and try to get rid of as much of the existing volatile stuff and replace it with atomic where appropriate. I think I can wittle it down to only a few variables/memory pointers etc. As this will be a major change that could introduce race-conditions and concurrency issues, I want to make sure this is tested on real hardware & in real situations as much as practical before I release it.

Btw .. thanks ever so much for all the work you've all put into this PR, it's awesome. You've done a great job. I just want to clean up something we inherited from the original IRremote library and the early days of this library. That stuff was left pretty much unchanged because it was magic code & worked, and assumed people know exactly what they were doing. My research in to volatile and what it does makes it sort of clear the use of it was more a kuldge than the right way to fix it. You're work has forced me to look at it and research it, and realise it only kind of does what we wanted.

In short, I want to enlist you guys (@tonhuisman & @Jason2866, tasmota etal) in helping to better fix it, and I don't want to just copy a lot of your work and pretend it was my work.

@crankyoldgit crankyoldgit self-assigned this Oct 11, 2023
@crankyoldgit crankyoldgit added enhancement ESP32 ESP32 only issue labels Oct 11, 2023
@Jason2866
Copy link

Looking forward to do testing on all ESP32x MCUS. Considering to do a RMT driver?
It looks like all newer ESP32 MCUs have timing issues with the current driver.

@crankyoldgit
Copy link
Owner

I've changed my mind on the approach.
I'll look at approving/merging this as is and do the other changes later. I'm quite time-poor now-a-days so best I not hold this up.

@crankyoldgit crankyoldgit self-requested a review October 18, 2023 23:11
Copy link
Owner

@crankyoldgit crankyoldgit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What tests on actual hardware have been done? i.e. Does it still capture okay on ESP32s & 8266s?

@@ -21,6 +21,12 @@ extern "C" {
#include "IRremoteESP8266.h"
#include "IRutils.h"

#if defined(ESP32)
#if ( defined(ESP_ARDUINO_VERSION_MAJOR) && (ESP_ARDUINO_VERSION_MAJOR >= 3) )
#include <driver/gpio.h>
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this hurt or cause an issue if it is always included?
i.e. Can we just include this header all the time?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm more inclined to only add includes when really needed, trying to avoid unneeded code being pulled in the build or having unexpected interactions.

src/IRrecv.cpp Show resolved Hide resolved
@Jason2866
Copy link

Jason2866 commented Oct 19, 2023

@crankyoldgit The changes fixes the compile, but it is not useable at all. With actual Arduino 3.0 alpha2 it crashes. In my earlier builds it did not crash but the receiving recognition rate was horrible. Tests where done with Tasmota and your provided receive test example.

@s-hadinger
Copy link
Contributor

I did the changers to the new timer interface of esp-idf 5.1 only by documentation. I have most certainly missed something here because I'm not sure how it worked before, nor how it is supposed to work with the new timers. I will receive my ESP32 test device shortly to do actual tests.

@crankyoldgit
Copy link
Owner

Hmm. I'll probably have to dust off my old ESP32 as well.
I'm a little worried at how much we've made atomic
I think we can get away with only having the irparams_t.rawlen and the pointer to the buffer being atomic in API available stuff.
Obviously, irparams_t.rcvstate will need to be too most likely.

@sagariotminds
Copy link

Hi @tonhuisman,

I am facing the same problem. When I am compiling the IR receiver code in ESP-IDF, I am getting the following errors:

"/home/iotminds/esp/ESP-IDF-CPP-Template/components/IRremoteESP8266-master/src/IRrecv.cpp: In function 'void gpio_intr()':
/home/iotminds/esp/ESP-IDF-CPP-Template/components/IRremoteESP8266-master/src/IRrecv.cpp:218:10: warning: '++' expression of 'volatile'-qualified type is deprecated [-Wvolatile]
218 | params.rawlen++;
| ~~~~~~~^~~~~~
/home/iotminds/esp/ESP-IDF-CPP-Template/components/IRremoteESP8266-master/src/IRrecv.cpp:246:3: error: 'timerAlarmEnable' was not declared in this scope; did you mean 'timerAlarm'?
246 | timerAlarmEnable(timer);
| ^~~~~~~~~~~~~~~~
| timerAlarm
/home/iotminds/esp/ESP-IDF-CPP-Template/components/IRremoteESP8266-master/src/IRrecv.cpp: In member function 'void IRrecv::enableIRIn(bool)':
/home/iotminds/esp/ESP-IDF-CPP-Template/components/IRremoteESP8266-master/src/IRrecv.cpp:362:21: error: too many arguments to function 'hw_timer_t* timerBegin(uint32_t)'
362 | timer = timerBegin(_timer_num, 80, true);
| ~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
In file included from /home/iotminds/esp/ESP-IDF-CPP-Template/components/arduino/cores/esp32/esp32-hal.h:84,
from /home/iotminds/esp/ESP-IDF-CPP-Template/components/arduino/cores/esp32/Arduino.h:36,
from /home/iotminds/esp/ESP-IDF-CPP-Template/components/IRremoteESP8266-master/src/IRrecv.h:10,
from /home/iotminds/esp/ESP-IDF-CPP-Template/components/IRremoteESP8266-master/src/IRrecv.cpp:6:
/home/iotminds/esp/ESP-IDF-CPP-Template/components/arduino/cores/esp32/esp32-hal-timer.h:35:14: note: declared here
35 | hw_timer_t * timerBegin(uint32_t frequency);
| ^~~~~~~~~~
/home/iotminds/esp/ESP-IDF-CPP-Template/components/IRremoteESP8266-master/src/IRrecv.cpp:371:3: error: 'timerAlarmWrite' was not declared in this scope; did you mean 'timerWrite'?
371 | timerAlarmWrite(timer, MS_TO_USEC(params.timeout), ONCE);
| ^~~~~~~~~~~~~~~
| timerWrite
/home/iotminds/esp/ESP-IDF-CPP-Template/components/IRremoteESP8266-master/src/IRrecv.cpp:375:23: error: too many arguments to function 'void timerAttachInterrupt(hw_timer_t*, void (*)())'
375 | timerAttachInterrupt(timer, &read_timeout, false);
| ~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/iotminds/esp/ESP-IDF-CPP-Template/components/arduino/cores/esp32/esp32-hal-timer.h:50:6: note: declared here
50 | void timerAttachInterrupt(hw_timer_t * timer, void (userFunc)(void));
| ^~~~~~~~~~~~~~~~~~~~
/home/iotminds/esp/ESP-IDF-CPP-Template/components/IRremoteESP8266-master/src/IRrecv.cpp: In member function 'void IRrecv::disableIRIn()':
/home/iotminds/esp/ESP-IDF-CPP-Template/components/IRremoteESP8266-master/src/IRrecv.cpp:401:3: error: 'timerAlarmDisable' was not declared in this scope
401 | timerAlarmDisable(timer);
| ^~~~~~~~~~~~~~~~~
/home/iotminds/esp/ESP-IDF-CPP-Template/components/IRremoteESP8266-master/src/IRrecv.cpp: In member function 'void IRrecv::pause()':
/home/iotminds/esp/ESP-IDF-CPP-Template/components/IRremoteESP8266-master/src/IRrecv.cpp:416:3: error: 'gpio_intr_disable' was not declared in this scope; did you mean 'esp_intr_disable'?
416 | gpio_intr_disable((gpio_num_t)params.recvpin);
| ^~~~~~~~~~~~~~~~~
| esp_intr_disable
/home/iotminds/esp/ESP-IDF-CPP-Template/components/IRremoteESP8266-master/src/IRrecv.cpp: In member function 'void IRrecv::resume()':
/home/iotminds/esp/ESP-IDF-CPP-Template/components/IRremoteESP8266-master/src/IRrecv.cpp:429:3: error: 'timerAlarmDisable' was not declared in this scope
429 | timerAlarmDisable(timer);
| ^~~~~~~~~~~~~~~~~
/home/iotminds/esp/ESP-IDF-CPP-Template/components/IRremoteESP8266-master/src/IRrecv.cpp:430:3: error: 'gpio_intr_enable' was not declared in this scope; did you mean 'esp_intr_enable'?
430 | gpio_intr_enable((gpio_num_t)params.recvpin);
| ^~~~~~~~~~~~~~~~
| esp_intr_enable
/home/iotminds/esp/ESP-IDF-CPP-Template/components/IRremoteESP8266-master/src/IRrecv.cpp: In member function 'void IRrecv::crudeNoiseFilter(decode_results
, uint16_t)':
/home/iotminds/esp/ESP-IDF-CPP-Template/components/IRremoteESP8266-master/src/IRrecv.cpp:506:37: warning: compound assignment with 'volatile'-qualified left operand is deprecated [-Wvolatile]
506 | results->rawbuf[offset - 1] += addition;
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~
[16/106] Building CXX object esp-idf/main/CMakeFiles/idf_main.dir//components/IRremoteESP8266-master/src/ir_Whirlpool.cpp.obj
ninja: build stopped: subcommand failed.
ninja failed with exit code 1, output of the command is in the /home/iotminds/esp/ESP-IDF-CPP-Template/build/log/idf_py_stderr_output_11553 and /home/iotminds/esp/ESP-IDF-CPP-Template/build/log/idf_py_stdout_output_11553"


After removing the IRrecv.cpp file configuration in the ESP-IDF CMakeLists.txt and recompiling the code, the compilation is successful, and the IR send code is working.

However, after replacing the IRrecv.cpp, IRrecv.h, IRremoteESP8266.h, and IRutils.h files from commit 9cfcebc, the compilation is successful, but the IR receive code is not working. The ESP module is continuously restarting, and the following error is encountered.


"I (32) boot: ESP-IDF v5.2-dev-2164-g3befd5fff7-dirty 2nd stage bootloader
I (32) boot: compile time Nov 10 2023 12:07:45
I (35) boot: Multicore bootloader
I (39) boot: chip revision: v3.1
I (43) boot.esp32: SPI Speed : 40MHz
I (48) boot.esp32: SPI Mode : DIO
I (52) boot.esp32: SPI Flash Size : 2MB
I (57) boot: Enabling RNG early entropy source...
I (62) boot: Partition Table:
I (66) boot: ## Label Usage Type ST Offset Length
I (73) boot: 0 nvs WiFi data 01 02 00009000 00006000
I (80) boot: 1 phy_init RF data 01 01 0000f000 00001000
I (88) boot: 2 factory factory app 00 00 00010000 00100000
I (95) boot: End of partition table
I (100) esp_image: segment 0: paddr=00010020 vaddr=3f400020 size=10e9ch ( 69276) map
I (133) esp_image: segment 1: paddr=00020ec4 vaddr=3ffb0000 size=02530h ( 9520) load
I (137) esp_image: segment 2: paddr=000233fc vaddr=40080000 size=0cc1ch ( 52252) load
I (161) esp_image: segment 3: paddr=00030020 vaddr=400d0020 size=41680h (267904) map
I (258) esp_image: segment 4: paddr=000716a8 vaddr=4008cc1c size=011f0h ( 4592) load
I (267) boot: Loaded app from partition at offset 0x10000
I (267) boot: Disabling RNG early entropy source...
I (280) cpu_start: Multicore app
I (280) cpu_start: Pro cpu up.
I (280) cpu_start: Starting app cpu, entry point is 0x4008124c
0x4008124c: call_start_cpu1 at /home/iotminds/esp/esp-idf/components/esp_system/port/cpu_start.c:170
I (267) cpu_start: App cpu up.
I (298) cpu_start: Pro cpu start user code
I (299) cpu_start: cpu freq: 160000000 Hz
I (299) cpu_start: Application information:
I (303) cpu_start: Project name: cpp-template-app
I (309) cpu_start: App version: b557759-dirty
I (314) cpu_start: Compile time: Nov 10 2023 12:07:34
I (321) cpu_start: ELF file SHA256: 25bc68b7f...
I (326) cpu_start: ESP-IDF: v5.2-dev-2164-g3befd5fff7-dirty
I (333) cpu_start: Min chip rev: v0.0
I (338) cpu_start: Max chip rev: v3.99
I (343) cpu_start: Chip rev: v3.1
I (347) heap_init: Initializing. RAM available for dynamic allocation:
I (355) heap_init: At 3FFAE6E0 len 00001920 (6 KiB): DRAM
I (361) heap_init: At 3FFB3350 len 0002CCB0 (179 KiB): DRAM
I (367) heap_init: At 3FFE0440 len 00003AE0 (14 KiB): D/IRAM
I (373) heap_init: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAM
I (380) heap_init: At 4008DE0C len 000121F4 (72 KiB): IRAM
I (387) spi_flash: detected chip: generic
I (390) spi_flash: flash io: dio
W (394) spi_flash: Detected size(4096k) larger than the size in the binary image header(2048k). Using the size in the binary image header.
I (409) app_start: Starting scheduler on CPU0
I (413) app_start: Starting scheduler on CPU1
I (413) main_task: Started on CPU0
I (423) main_task: Calling app_main()
I (462) gpio: GPIO[4]| InputEn: 1| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0
I (464) gpio: GPIO[15]| InputEn: 1| OutputEn: 0| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0

[ 84][E][esp32-hal-timer.c:105] timerBegin(): Resolution cannot be reached with any clock source, aborting!
assert failed: void IRrecv::enableIRIn(bool) IRrecv.cpp:384 (timer != NULL)
Backtrace: 0x400818b6:0x3ffb5450 0x400871d5:0x3ffb5470 0x4008c8c9:0x3ffb5490 0x400e7d0d:0x3ffb55b0 0x400d71c5:0x3ffb55e0 0x40110a92:0x3ffb5650 0x4008998a:0x3ffb5680
0x400818b6: panic_abort at /home/iotminds/esp/esp-idf/components/esp_system/panic.c:452
0x400871d5: esp_system_abort at /home/iotminds/esp/esp-idf/components/esp_system/port/esp_system_chip.c:93
0x4008c8c9: __assert_func at /home/iotminds/esp/esp-idf/components/newlib/assert.c:81
0x400e7d0d: IRrecv::enableIRIn(bool) at /home/iotminds/esp/ESP-IDF-CPP-Template/components/IRremoteESP8266-master/src/IRrecv.cpp:384 (discriminator 1)
0x400d71c5: app_main at /home/iotminds/esp/ESP-IDF-CPP-Template/main/main.cpp:105
0x40110a92: main_task at /home/iotminds/esp/esp-idf/components/freertos/app_startup.c:217 (discriminator 13)
0x4008998a: vPortTaskWrapper at /home/iotminds/esp/esp-idf/components/freertos/FreeRTOS-Kernel/portable/xtensa/port.c:162

ELF file SHA256: 25bc68b7f
Rebooting...
ets Jul 29 2019 12:21:46
rst:0xc (SW_CPU_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3fff0030,len:7132
ho 0 tail 12 room 4
load:0x40078000,len:15708
load:0x40080400,len:4
0x40080400: _init at ??:?
ho 8 tail 4 room 4
load:0x40080404,len:3884
entry 0x40080650 "


Is there a solution available to resolve this problem, or could you provide any assistance? Additionally, any estimate on the time required to address this issue would be helpful.

@tonhuisman
Copy link
Contributor Author

I assume you are compiling the code from this branch? (though it looks like you don't... 🤔)
The master branch doesn't have these adjustments included yet.

@sagariotminds
Copy link

sagariotminds commented Nov 10, 2023 via email

@Jason2866
Copy link

You have to use latest commit db98aa0

@sagariotminds
Copy link

sagariotminds commented Nov 10, 2023 via email

@sagariotminds
Copy link

Hi @Jason2866,

I have applied the commit you suggested: db98aa0. The compilation is successful without any errors, still IR receive code is not working get the error log continuously [E (501) gptimer: gptimer_start(344): timer is not enabled yet]. However, the IR send code is functional. I've included my code below along with the code logs. Could you please review and suggest what mistake I might have made? Your assistance would be greatly appreciated.

Module : ESP-32

[My code ]

#include "Arduino.h"
#include <IRremoteESP8266.h>
#include <IRrecv.h>
#include <IRsend.h>
#include <IRac.h>
#include <IRtext.h>
#include <IRutils.h>

const uint16_t kRecvPin = 15;
const uint16_t kIrLed = 4;

const uint32_t kBaudRate = 115200;
const uint16_t kCaptureBufferSize = 1024;

#if DECODE_AC
const uint8_t kTimeout = 50;
#else
const uint8_t kTimeout = 15;
#endif
const uint16_t kMinUnknownSize = 12;
const uint8_t kTolerancePercentage = kTolerance;

#define LEGACY_TIMING_INFO false

IRrecv irrecv(kRecvPin, kCaptureBufferSize, kTimeout, true);
decode_results results;

IRsend irsend(kIrLed);
//IRrecv irrecv(kRecvPin);

uint16_t rawData[439] = {3460, 1752, 426, 472, 426, 1264, 466, 470, 424, 434, 462, 470, 426, 470, 448, 448, 448, 446, 448, 410, 464, 470, 426, 432, 464, 470, 450, 448, 426, 1300, 426, 472, 450, 446, 426, 432, 462, 434, 490, 444, 444, 414, 486, 448, 444, 1248, 466, 1264, 464, 1264, 466, 432, 466, 468, 426, 1304, 426, 434, 464, 470, 424, 472, 450, 444, 426, 434, 464, 472, 424, 472, 426, 470, 424, 470, 448, 448, 450, 408, 464, 470, 426, 470, 426, 430, 464, 470, 426, 432, 462, 434, 486, 410, 462, 434, 462, 434, 486, 448, 450, 406, 488, 446, 452, 446, 448, 408, 484, 414, 488, 408, 488, 410, 488, 408, 486, 410, 486, 1244, 462, 1266, 486, 410, 490, 406, 482, 414, 488, 408, 490, 406, 486, 9988, 3496, 1712, 492, 408, 490, 1238, 488, 410, 462, 474, 426, 430, 488, 448, 450, 408, 488, 408, 486, 408, 490, 408, 490, 404, 490, 406, 488, 408, 490, 1238, 488, 410, 488, 408, 490, 408, 488, 408, 488, 410, 486, 410, 464, 434, 488, 1240, 490, 1240, 488, 1242, 488, 410, 488, 408, 486, 1242, 488, 410, 488, 446, 452, 444, 448, 410, 488, 410, 488, 408, 488, 408, 488, 408, 486, 410, 488, 408, 488, 408, 490, 408, 486, 410, 486, 410, 486, 410, 492, 404, 488, 1240, 488, 408, 490, 406, 492, 406, 488, 408, 492, 406, 488, 408, 488, 1240, 488, 1242, 492, 1238, 490, 1240, 488, 410, 488, 408, 486, 410, 488, 408, 488, 408, 486, 448, 450, 408, 490, 406, 490, 406, 488, 1242, 490, 1238, 488, 410, 490, 406, 486, 410, 488, 1242, 490, 1240, 486, 1242, 492, 406, 464, 438, 484, 408, 490, 406, 488, 408, 488, 410, 486, 410, 488, 408, 490, 408, 490, 404, 488, 408, 490, 406, 488, 408, 490, 406, 486, 410, 488, 410, 486, 410, 490, 406, 490, 1240, 488, 1242, 490, 1240, 488, 410, 488, 406, 490, 406, 490, 406, 490, 408, 486, 410, 492, 406, 490, 406, 488, 408, 486, 1244, 486, 1242, 488, 1242, 488, 410, 488, 408, 490, 406, 498, 398, 490, 406, 488, 408, 488, 408, 486, 408, 488, 408, 488, 408, 492, 406, 490, 406, 488, 410, 492, 404, 490, 406, 470, 428, 486, 1242, 488, 408, 490, 406, 488, 1242, 488, 410, 488, 408, 490, 406, 488, 1242, 492, 406, 490, 404, 490, 406, 488, 410, 490, 406, 490, 406, 486, 410, 488, 408, 486, 408, 486, 410, 486, 410, 492, 404, 488, 408, 494, 402, 488, 408, 488, 408, 490, 406, 488, 1240, 490, 408, 488, 410, 488, 1240, 488, 1242, 488, 408, 488, 1244, 486};

extern "C" void app_main()
{
initArduino();

#if defined(ESP8266)
Serial.begin(kBaudRate, SERIAL_8N1, SERIAL_TX_ONLY);
#else
Serial.begin(kBaudRate, SERIAL_8N1);
#endif
while (!Serial)
delay(50);
assert(irutils::lowLevelSanityCheck() == 0);

Serial.printf("\n" D_STR_IRRECVDUMP_STARTUP "\n", kRecvPin);
#if DECODE_HASH
irrecv.setUnknownThreshold(kMinUnknownSize);
#endif
irrecv.setTolerance(kTolerancePercentage);
irrecv.enableIRIn();
irsend.begin();

pinMode(19,OUTPUT);

while(true){
Serial.println("loop");
// digitalWrite(19, HIGH);
// delay(1000);
// digitalWrite(19, LOW);
// delay(1000);
Serial.println("a rawData capture from IRrecvDumpV2");
irsend.sendRaw(rawData, 439, 38); // Send a raw data capture at 38kHz.
delay(500);

if (irrecv.decode(&results)) {
uint32_t now = millis();
Serial.printf(D_STR_TIMESTAMP " : %06lu.%03lu\n", now / 1000, now % 1000);
if (results.overflow)
Serial.printf(D_WARN_BUFFERFULL "\n", kCaptureBufferSize);
Serial.println(D_STR_LIBRARY " : v" _IRREMOTEESP8266_VERSION_STR "\n");
if (kTolerancePercentage != kTolerance)
Serial.printf(D_STR_TOLERANCE " : %d%%\n", kTolerancePercentage);
Serial.print(resultToHumanReadableBasic(&results));
String description = IRAcUtils::resultAcToString(&results);
if (description.length()) Serial.println(D_STR_MESGDESC ": " + description);
yield();
#if LEGACY_TIMING_INFO
Serial.println(resultToTimingInfo(&results));
yield();
#endif
Serial.println(resultToSourceCode(&results));
Serial.println();
yield();
}
delay(500);

}
}

[LOGS]

I (33) boot: ESP-IDF v5.2-dev-2164-g3befd5fff7-dirty 2nd stage bootloader
I (33) boot: compile time Nov 11 2023 08:15:59
I (35) boot: Multicore bootloader
I (39) boot: chip revision: v3.1
I (43) boot.esp32: SPI Speed : 40MHz
I (48) boot.esp32: SPI Mode : DIO
I (52) boot.esp32: SPI Flash Size : 2MB
I (57) boot: Enabling RNG early entropy source...
I (62) boot: Partition Table:
I (66) boot: ## Label Usage Type ST Offset Length
I (73) boot: 0 nvs WiFi data 01 02 00009000 00006000
I (81) boot: 1 phy_init RF data 01 01 0000f000 00001000
I (88) boot: 2 factory factory app 00 00 00010000 00100000
I (96) boot: End of partition table
I (100) esp_image: segment 0: paddr=00010020 vaddr=3f400020 size=10f94h ( 69524) map
I (133) esp_image: segment 1: paddr=00020fbc vaddr=3ffb0000 size=02530h ( 9520) load
I (137) esp_image: segment 2: paddr=000234f4 vaddr=40080000 size=0cb24h ( 52004) load
I (161) esp_image: segment 3: paddr=00030020 vaddr=400d0020 size=41804h (268292) map
I (258) esp_image: segment 4: paddr=0007182c vaddr=4008cb24 size=012c8h ( 4808) load
I (267) boot: Loaded app from partition at offset 0x10000
I (267) boot: Disabling RNG early entropy source...
I (280) cpu_start: Multicore app
I (281) cpu_start: Pro cpu up.
I (281) cpu_start: Starting app cpu, entry point is 0x40081248
0x40081248: call_start_cpu1 at /home/iotminds/esp/esp-idf/components/esp_system/port/cpu_start.c:170

I (0) cpu_start: App cpu up.
I (299) cpu_start: Pro cpu start user code
I (299) cpu_start: cpu freq: 160000000 Hz
I (299) cpu_start: Application information:
I (303) cpu_start: Project name: cpp-template-app
I (309) cpu_start: App version: b557759-dirty
I (315) cpu_start: Compile time: Nov 11 2023 08:15:50
I (321) cpu_start: ELF file SHA256: 44390ceae...
I (326) cpu_start: ESP-IDF: v5.2-dev-2164-g3befd5fff7-dirty
I (333) cpu_start: Min chip rev: v0.0
I (338) cpu_start: Max chip rev: v3.99
I (343) cpu_start: Chip rev: v3.1
I (347) heap_init: Initializing. RAM available for dynamic allocation:
I (355) heap_init: At 3FFAE6E0 len 00001920 (6 KiB): DRAM
I (361) heap_init: At 3FFB3350 len 0002CCB0 (179 KiB): DRAM
I (367) heap_init: At 3FFE0440 len 00003AE0 (14 KiB): D/IRAM
I (373) heap_init: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAM
I (380) heap_init: At 4008DDEC len 00012214 (72 KiB): IRAM
I (387) spi_flash: detected chip: generic
I (390) spi_flash: flash io: dio
W (394) spi_flash: Detected size(4096k) larger than the size in the binary image header(2048k). Using the size in the binary image header.
I (409) app_start: Starting scheduler on CPU0
I (413) app_start: Starting scheduler on CPU1
I (413) main_task: Started on CPU0
I (423) main_task: Calling app_main()
I (46
IRrecvDump is now running and waiting for IR input on Pin 15
I (466) gpio: GPIO[15]| InputEn: 1| OutputEn: 0| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0
I (470) gpio: GPIO[4]| InputEn: 1| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0
I (478) gpio: GPIO[19]| InputEn: 1| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0
loop
a rawData capture from IRrecvDumpV2
E (501) gptimer: gptimer_start(344): timer is not enabled yet
E (503) gptimer: gptimer_start(344): timer is not enabled yet
E (503) gptimer: gptimer_start(344): timer is not enabled yet
E (511) gptimer: gptimer_start(344): timer is not enabled yet
E (511) gptimer: gptimer_start(344): timer is not enabled yet
E (524) gptimer: gptimer_start(344): timer is not enabled yet
E (524) gptimer: gptimer_start(344): timer is not enabled yet
E (537) gptimer: gptimer_start(344): timer is not enabled yet
E (537) gptimer: gptimer_start(344): timer is not enabled yet
E (549) gptimer: gptimer_start(344): timer is not enabled yet
E (549) gptimer: gptimer_start(344): timer is not enabled yet
E (562) gptimer: gptimer_start(344): timer is not enabled yet
E (562) gptimer: gptimer_start(344): timer is not enabled yet
E (575) gptimer: gptimer_start(344): timer is not enabled yet
E (575) gptimer: gptimer_start(344): timer is not enabled yet
E (588) gptimer: gptimer_start(344): timer is not enabled yet
E (588) gptimer: gptimer_start(344): timer is not enabled yet
...................
E (5270) task_wdt: Task watchdog got triggered. The following tasks/users did not reset the watchdog in time:
E (5270) task_wdt: - IDLE (CPU 0)
E (5270) task_wdt: Tasks currently running:
E (5270) task_wdt: CPU 0: main
E (5270) task_wdt: CPU 1: IDLE
E (5270) task_wdt: Print CPU 0 (current core) backtrace

Backtrace: 0x400FB3E2:0x3FFB10C0 0x400FB58E:0x3FFB10E0 0x400832A5:0x3FFB1100 0xGuru Meditation Error: Core 0 panic'ed (Interrupt wdt timeout on CPU0).
0x400fb3e2: task_wdt_timeout_handling at /home/iotminds/esp/esp-idf/components/esp_system/task_wdt/task_wdt.c:461 (discriminator 3)

0x400fb58e: task_wdt_isr at /home/iotminds/esp/esp-idf/components/esp_system/task_wdt/task_wdt.c:585

0x400832a5: _xt_lowint1 at /home/iotminds/esp/esp-idf/components/xtensa/xtensa_vectors.S:1236

Core 0 register dump:
PC : 0x4000921a PS : 0x00060234 A0 : 0x80007d16 A1 : 0x3ffb0f50
0x4000921a: uart_tx_one_char in ROM

A2 : 0x00800000 A3 : 0x20000000 A4 : 0x00000000 A5 : 0x00001496
A6 : 0x0000002a A7 : 0x3ffb10c0 A8 : 0x3ff40000 A9 : 0x00000034
A10 : 0x00800000 A11 : 0x3ff4001c A12 : 0x00000000 A13 : 0xffffffff
A14 : 0x0000000a A15 : 0x3ffb10a0 SAR : 0x00000005 EXCCAUSE: 0x00000005
EXCVADDR: 0x00000000 LBEG : 0x4000c2e0 LEND : 0x4000c2f6 LCOUNT : 0x00000000
0x4000c2e0: memcpy in ROM

0x4000c2f6: memcpy in ROM

Core 0 was running in ISR context:
EPC1 : 0x400d350f EPC2 : 0x00000000 EPC3 : 0x00000000 EPC4 : 0x4000921a
0x400d350f: uart_hal_write_txfifo at /home/iotminds/esp/esp-idf/components/hal/uart_hal_iram.c:27

0x4000921a: uart_tx_one_char in ROM

Backtrace: 0x40009217:0x3ffb0f50 0x40007d13:0x3ffb0f70 0x40007c69:0x3ffb0f90 0x40008106:0x3ffb0fb0 0x40081b26:0x3ffb1040 0x40081d00:0x3ffb1060 0x40081d6a:0x3ffb1090 0x400fb3e2:0x3ffb10c0 0x400fb58e:0x3ffb10e0 0x400832a5:0x3ffb1100 0x400835c7:0x3ffb6500 0x40082c63:0x3ffb6520 0x400f2d93:0x3ffb6540 0x400eac3f:0x3ffb6560 0x400eacd4:0x3ffb6580 0x400eaeee:0x3ffb65c0 0x400d7275:0x3ffb65e0 0x40110c16:0x3ffb6650 0x4008996a:0x3ffb6680
0x40009217: uart_tx_one_char in ROM

0x40007d13: ets_write_char_uart in ROM

0x40007c69: ets_write_char in ROM

0x40008106: ets_printf in ROM

0x40081b26: print_entry at /home/iotminds/esp/esp-idf/components/esp_system/port/arch/xtensa/debug_helpers.c:44

0x40081d00: esp_backtrace_print_from_frame at /home/iotminds/esp/esp-idf/components/esp_system/port/arch/xtensa/debug_helpers.c:82

0x40081d6a: esp_backtrace_print at /home/iotminds/esp/esp-idf/components/esp_system/port/arch/xtensa/debug_helpers.c:102

0x400fb3e2: task_wdt_timeout_handling at /home/iotminds/esp/esp-idf/components/esp_system/task_wdt/task_wdt.c:461 (discriminator 3)

0x400fb58e: task_wdt_isr at /home/iotminds/esp/esp-idf/components/esp_system/task_wdt/task_wdt.c:585

0x400832a5: _xt_lowint1 at /home/iotminds/esp/esp-idf/components/xtensa/xtensa_vectors.S:1236

0x400835c7: gpio_intr_service at /home/iotminds/esp/esp-idf/components/driver/gpio/gpio.c:493

0x40082c63: esp_timer_impl_get_time at /home/iotminds/esp/esp-idf/components/esp_timer/src/esp_timer_impl_lac.c:140

0x400f2d93: delayMicroseconds at /home/iotminds/esp/ESP-IDF-CPP-Template/components/arduino/cores/esp32/esp32-hal-misc.c:225

0x400eac3f: IRsend::_delayMicroseconds(unsigned long) at /home/iotminds/esp/ESP-IDF-CPP-Template/components/IRremoteESP8266-master/src/IRsend.cpp:119

0x400eacd4: IRsend::mark(unsigned short) at /home/iotminds/esp/ESP-IDF-CPP-Template/components/IRremoteESP8266-master/src/IRsend.cpp:177

0x400eaeee: IRsend::sendRaw(unsigned short const*, unsigned short, unsigned short) at /home/iotminds/esp/ESP-IDF-CPP-Template/components/IRremoteESP8266-master/src/IRsend.cpp:547

0x400d7275: app_main at /home/iotminds/esp/ESP-IDF-CPP-Template/main/main.cpp:64

0x40110c16: main_task at /home/iotminds/esp/esp-idf/components/freertos/app_startup.c:217 (discriminator 13)

0x4008996a: vPortTaskWrapper at /home/iotminds/esp/esp-idf/components/freertos/FreeRTOS-Kernel/portable/xtensa/port.c:162

Core 1 register dump:
PC : 0x400852ae PS : 0x00060734 A0 : 0x800d3316 A1 : 0x3ffb7230
0x400852ae: esp_cpu_wait_for_intr at /home/iotminds/esp/esp-idf/components/esp_hw_support/cpu.c:145

A2 : 0x00000000 A3 : 0x00000000 A4 : 0x3ffaf8c0 A5 : 0x3ffaf8a0
A6 : 0x40084f68 A7 : 0x00000001 A8 : 0x800fb7d6 A9 : 0x3ffb71f0
0x40084f68: ipc_task at /home/iotminds/esp/esp-idf/components/esp_system/esp_ipc.c:48

A10 : 0x00000000 A11 : 0x00000000 A12 : 0x80089c56 A13 : 0x3ffb7140
A14 : 0x00000003 A15 : 0x00060023 SAR : 0x00000000 EXCCAUSE: 0x00000005
EXCVADDR: 0x00000000 LBEG : 0x00000000 LEND : 0x00000000 LCOUNT : 0x00000000

Backtrace: 0x400852ab:0x3ffb7230 0x400d3313:0x3ffb7250 0x400883d5:0x3ffb7270 0x4008996a:0x3ffb7290
0x400852ab: xt_utils_wait_for_intr at /home/iotminds/esp/esp-idf/components/xtensa/include/xt_utils.h:81
(inlined by) esp_cpu_wait_for_intr at /home/iotminds/esp/esp-idf/components/esp_hw_support/cpu.c:132

0x400d3313: esp_vApplicationIdleHook at /home/iotminds/esp/esp-idf/components/esp_system/freertos_hooks.c:59

0x400883d5: prvIdleTask at /home/iotminds/esp/esp-idf/components/freertos/FreeRTOS-Kernel/tasks.c:4364 (discriminator 1)

0x4008996a: vPortTaskWrapper at /home/iotminds/esp/esp-idf/components/freertos/FreeRTOS-Kernel/portable/xtensa/port.c:162

@sagariotminds
Copy link

Hi @Jason2866 ,
do you have any solutions for this issue? If you have any suggestions or insights, could you please share them?

@Jason2866
Copy link

Looks like compiled with IDF. Don't know if the lib works with IDF

@Zhentao-Lin
Copy link

Recently, the Arduino ESP32 launched a stable version of V3.0.0, it seems that some interfaces in the library have changed, resulting in failure to compile through

@sagariotminds
Copy link

sagariotminds commented May 31, 2024 via email

@Zhentao-Lin
Copy link

V2.0.14 before can use this library, V2.0.15-V2.0.17 I have not tested, it should be OK. Neither V3.0.0 is possible.

@sagariotminds
Copy link

sagariotminds commented May 31, 2024 via email

@mboehmerm
Copy link

mboehmerm commented Aug 16, 2024

Works for me without errors, if add "bool timerStarted(hw_timer_t *timer);" to "esp32-hal-timer.h" and "esp32-hal-timer.c" and use this function in "IRrecv.cpp".

Base were the commits 9cfcebc and db98aa0

Test and files can be found here : https://github.com/mboehmerm/Three-IPS-Displays-with-ST7789-170x320-240x280-240x320/tree/main/IRremoteESP8266

Added in esp32-hal-timer.h

bool timerStarted(hw_timer_t *timer);

Added in esp32-hal-timer.c

bool timerStarted(hw_timer_t *timer) {
  return timer->timer_started;
}

In the file IRrecv.cpp i replaced

  timerWrite(timer, 0);
  timerStart(timer);

with

  timerWrite(timer, 0);
  if (timerStarted(timer))
    timerRestart(timer);
  else
    timerStart(timer);

and

  timerStop(timer);

with

  if (timerStarted(timer))
    timerStop(timer);

I hope there is a better solution without modifying the esp32-hal-timer files.

@Jason2866
Copy link

Jason2866 commented Aug 16, 2024

@mboehmerm Dont know what's causing the need that you have to modify files.
The PR is working well in EspEasy and Tasmota without any further changes with Arduino Core 3.0.x

@mboehmerm
Copy link

@mboehmerm Dont know what's causing the need that you have to modify files. The PR is working well in EspEasy and Tasmota without any further changes with Arduino Core 3.0.x

This is the first solution i found, that works with Arduino IDE without any errors. Is there a better solution? Where can i find it?

@tonhuisman
Copy link
Contributor Author

the first solution i found, that works with Arduino IDE without any errors. Is there a better solution?

🤔 (... sorry, too obvious...)

@almirus
Copy link

almirus commented Aug 29, 2024

I get an error

16:49:14.291 -> E (1146905) gptimer: gptimer_start(348): timer is not enabled yet
16:49:14.322 -> Timestamp : 001146.959
16:49:14.322 -> Library   : v2.8.6
16:49:14.322 -> 
16:49:14.322 -> Protocol  : UNKNOWN
16:49:14.322 -> Code      : 0xEBA17F (11 Bits)
16:49:14.322 -> uint16_t rawData[22] = {3060, 1620,  468, 4140,  5816, 5818,  5814, 5816,  5816, 5816,  5814, 5818,  5816, 5816,  5816, 5814,  5818, 5816,  5814, 5816,  5814, 5818 }E (1146978) gptimer: gptimer_start(348): timer is not enabled yet
16:49:14.354 -> E (1146979) gptimer: gptimer_start(348): timer is not enabled yet
16:49:14.354 -> E (1146980) gptimer: gptimer_start(348): timer is not enabled yet
16:49:14.354 -> E (1146985) gptimer: gptimer_start(348): timer is not enabled yet
16:49:14.354 -> E (1146991) gptimer: gptimer_start(348): timer is not enabled yet
16:49:14.450 -> E (1147072) gptimer: gptimer_start(348): timer is not enabled yet
16:49:14.450 -> E (1147078) gptimer: gptimer_start(348): timer is not enabled yet
16:49:14.450 -> E (1147084) gptimer: gptimer_start(348): timer is not enabled yet
16:49:14.450 -> E (1147090) gptimer: gptimer_start(348): timer is not enabled yet
16:49:14.450 -> E (1147096) gptimer: gptimer_start(348): timer is not enabled yet
16:49:14.489 -> ;  // UNKNOWN EBA17F
16:49:14.489 -> 
16:49:14.489 -> 
16:49:14.489 -> Timestamp : 001147.149
16:49:14.523 -> Library   : v2.8.6
16:49:14.523 -> 
16:49:14.523 -> Protocol  : UNKNOWN
16:49:14.523 -> Code      : 0x5B39BFD5 (12 Bits)
16:49:14.523 -> uint16_t rawData[23] = {3058, 1622,  470, 5494,  5818, 5816,  5814, 5818,  5816, 5816,  5816, 5816,  5812, 5818,  5816, 5816,  5816, 5814,  5818, 5816,  5816, 5816,  5816};  // UNKNOWN 5B39BFD5
16:49:14.523 -> 
16:49:14.523 -> 
16:59:14.509 -> E (1747136) gptimer: gptimer_start(348): timer is not enabled yet
16:59:14.541 -> E (1747138) gptimer: gptimer_start(348): timer is not enabled yet
16:59:14.541 -> E (1747138) gptimer: gptimer_start(348): timer is not enabled yet
16:59:14.541 -> E (1747142) gptimer: gptimer_start(348): timer is not enabled yet
16:59:14.541 -> E (1747148) gptimer: gptimer_start(348): timer is not enabled yet
16:59:14.541 -> E (1747154) gptimer: gptimer_start(348): timer is not enabled yet
16:59:14.573 -> E (1747160) gptimer: gptimer_start(348): timer is not enabled yet
16:59:14.573 -> E (1747166) gptimer: gptimer_start(348): timer is not enabled yet
16:59:14.573 -> E (1747172) gptimer: gptimer_start(348): timer is not enabled yet
16:59:14.573 -> E (1747177) gptimer: gptimer_start(348): timer is not enabled yet
16:59:14.573 -> E (1747183) gptimer: gptimer_start(348): timer is not enabled yet
16:59:14.573 -> E (1747189) gptimer: gptimer_start(348): timer is not enabled yet
16:59:14.605 -> E (1747195) gptimer: gptimer_start(348): timer is not enabled yet
16:59:14.605 -> E (1747201) gptimer: gptimer_start(348): timer is not enabled yet
16:59:14.605 -> E (1747206) gptimer: gptimer_start(348): timer is not enabled yet

@Buddy-Matt
Copy link

Buddy-Matt commented Sep 16, 2024

I'm also seeing the same error as @almirus regarding gptimer when using Arduino IDE targeting a M5Stack NanoC6.

The library also fails to receive the NEC codes that were previously working under ESP32 2.0.17 - so I don't believe they're spurious either.

@NiKiZe
Copy link
Collaborator

NiKiZe commented Sep 23, 2024

I'm considering merging #2144 which only has changes for ESP32 CoreV3, that way we don't risk breaking anything for earlier versions?

After that we could look into merging any other changes? How does that sound?
Or any reasons for not doing that?

@tonhuisman
Copy link
Contributor Author

We have been using these adjustments on the Arduino 3.x/IDF 5.x builds of ESPEasy since I started this PR, so I see no reason not to merge this, and other relevant changes.
I still don't fully understand why PR 2144 was created, though, since this PR has been open for quite some time...

@NiKiZe
Copy link
Collaborator

NiKiZe commented Sep 23, 2024

We have been using these adjustments on the Arduino 3.x/IDF 5.x builds of ESPEasy since I started this PR, so I see no reason not to merge this, and other relevant changes. I still don't fully understand why PR 2144 was created, though, since this PR has been open for quite some time...

In principle I agree, #2144 is a duplicate, but there is also about the cleanest solution. (read: easiest to review)
#2040 (this PR) has 3? different fixes mixed in one PR. I'm not able to verify these changes.
The reason for me starting to look into merging #2144 was #2144 (comment)

In it's current state it essentially only has added lines and no changes, which I can validate does not create any new issues for <V3
Another part, which currently is over my head, is the mentions about IDF, for example #1575, this library is for Arduino, even if that pulls in something else.

My hope is that this PR can be rebased on #2144 and then review the remaining parts.

@tonhuisman
Copy link
Contributor Author

In principle I agree, #2144 is a duplicate, but there is also about the cleanest solution. (read: easiest to review)
#2040 (this PR) has 3? different fixes mixed in one PR. I'm not able to verify these changes.

The scope of this PR is to instate compatibility with C++20, not 'just' Arduino 3.x.
To have compatibility with C++20 the 3 mentioned changes are required to avoid compiler warnings in the build log.

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

Successfully merging this pull request may close these issues.

Feature Request: Support for esp32 Arduino 3.0.0
10 participants