DCC-EX / DCCInspector-EX

The DCC signal packet inspector. A custom packet analyzer/sniffer for Arduino and ESP32
GNU General Public License v3.0
16 stars 12 forks source link

Compile errors using esp32 Board library 2.0.0 and 2.0.1, in Arduino IDE 1.8.6 #12

Open twr140 opened 2 years ago

twr140 commented 2 years ago

If either of the above board libraries are used, this sketch fails to compile (in the Arduino IDE), with the final error message shown as:

'struct esp_wps_config_t' has no member named 'crypto_funcs'

I first noticed this when I had v2.0.1 of the board library installed. Taking this library back to v2.0.0 did not resolve the problem - the error message remained the same.

When I went back to v1.0.6 of the library, this error disappeared.

Here is the full text of the compiler error when v2.0.0 of the library was in use:

Arduino: 1.8.16 (Windows 10), Board: "Heltec WiFi Kit 32, Disabled, 240MHz (WiFi/BT), 921600, None"

C:\Users\abc\Documents\Arduino\DCCInspector-EX\HttpManager.cpp: In member function 'bool HttpManagerClass::begin(const char*, const char*, const char*)':

HttpManager.cpp:187:10: error: 'struct esp_wps_config_t' has no member named 'crypto_funcs'

   config.crypto_funcs = &g_wifi_default_wps_crypto_funcs;

          ^~~~~~~~~~~~

HttpManager.cpp:187:26: error: 'g_wifi_default_wps_crypto_funcs' was not declared in this scope

   config.crypto_funcs = &g_wifi_default_wps_crypto_funcs;

                          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

HttpManager.cpp:190:26: error: no matching function for call to 'onEvent(void (&)(arduino_event_id_t, system_event_info_t))'

   WiFi.onEvent (WiFiEvent);

                          ^

In file included from C:\Users\abc\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.0\libraries\WiFi\src/WiFiSTA.h:28,

                 from C:\Users\abc\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.0\libraries\WiFi\src/WiFi.h:32,

                 from C:\Users\abc\Documents\Arduino\DCCInspector-EX\HttpManager.h:37,

                 from C:\Users\abc\Documents\Arduino\DCCInspector-EX\HttpManager.cpp:33:

C:\Users\abc\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.0\libraries\WiFi\src/WiFiGeneric.h:147:21: note: candidate: 'wifi_event_id_t WiFiGenericClass::onEvent(WiFiEventCb, arduino_event_id_t)' <near match>

     wifi_event_id_t onEvent(WiFiEventCb cbEvent, arduino_event_id_t event = ARDUINO_EVENT_MAX);

                     ^~~~~~~

C:\Users\abc\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.0\libraries\WiFi\src/WiFiGeneric.h:147:21: note:   conversion of argument 1 would be ill-formed:

HttpManager.cpp:190:26: error: invalid conversion from 'void (*)(arduino_event_id_t, system_event_info_t)' to 'WiFiEventCb' {aka 'void (*)(arduino_event_id_t)'} [-fpermissive]

   WiFi.onEvent (WiFiEvent);

                          ^

In file included from C:\Users\abc\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.0\libraries\WiFi\src/WiFiSTA.h:28,

                 from C:\Users\abc\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.0\libraries\WiFi\src/WiFi.h:32,

                 from C:\Users\abc\Documents\Arduino\DCCInspector-EX\HttpManager.h:37,

                 from C:\Users\abc\Documents\Arduino\DCCInspector-EX\HttpManager.cpp:33:

C:\Users\abc\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.0\libraries\WiFi\src/WiFiGeneric.h:149:21: note: candidate: 'wifi_event_id_t WiFiGenericClass::onEvent(WiFiEventSysCb, arduino_event_id_t)' <near match>

     wifi_event_id_t onEvent(WiFiEventSysCb cbEvent, arduino_event_id_t event = ARDUINO_EVENT_MAX);

                     ^~~~~~~

C:\Users\abc\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.0\libraries\WiFi\src/WiFiGeneric.h:149:21: note:   conversion of argument 1 would be ill-formed:

HttpManager.cpp:190:26: error: invalid conversion from 'void (*)(arduino_event_id_t, system_event_info_t)' to 'WiFiEventSysCb' {aka 'void (*)(arduino_event_t*)'} [-fpermissive]

   WiFi.onEvent (WiFiEvent);

                          ^

Multiple libraries were found for "WiFi.h"

 Used: C:\Users\abc\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.0\libraries\WiFi

 Not used: C:\Program Files (x86)\Arduino\libraries\WiFi

exit status 1

'struct esp_wps_config_t' has no member named 'crypto_funcs'
atanisoft commented 2 years ago

Arduino-esp32 2.0.x is based on ESP-IDF v4.4 (pre-release code). A few adjustments will be necessary to compile against the newer versions.

For now I'd suggest stick with 1.0.6 until the necessary adjustments are made.

twr140 commented 2 years ago

Thanks for the information atanisoft. I appreciate you taking the time to respond. It's good to get information back from others like yourself, who have a better understanding of why the error was occurring than I did.

I will stick with v1.0.6 for now.

I thought I'd just make a note about this problem here, in case others had the same issue.

Neil-McK commented 1 year ago

The code reported as in error has been modified and compiled without errors and ran with ESP32 support v2.0.4 (most recent version on PlatformIO) and v2.0.7 (on Arduino IDE). Thanks for reporting this, and sorry it's been so long.

twr140 commented 1 year ago

Thanks for looking into this Neil.

I'm now running the Arduino IDE 2.0.4, and I upgraded the ESP32 library today to v2.0.7. I then downloaded the DCCInspector-EX code as a ZIP file and placed the new code in the Arduino folder on my system. I've set the board to the Heltec WiFi Kit 32. When I try to compile it, I'm now getting a different error:

Compilation error: expected unqualified-id before numeric constant

Here is the full error text:

`In file included from C:\Users\Trevor\Documents\Arduino\DCCInspector-EX\OledDisplay.cpp:24: C:\Users\Trevor\Documents\Arduino\DCCInspector-EX\Config.h:101:20: error: expected unqualified-id before numeric constant

define SCL_OLED 5

                ^

C:\Users\Trevor\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.7\variants\heltec_wifi_kit_32/pins_arduino.h:72:22: note: in expansion of macro 'SCL_OLED' static const uint8_t SCL_OLED = 15; ^~~~ C:\Users\Trevor\Documents\Arduino\DCCInspector-EX\Config.h: 100:20: error: expected unqualified-id before numeric constant

define SDA_OLED 4

                ^

C:\Users\Trevor\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.7\variants\heltec_wifi_kit_32/pins_arduino.h:73:22: note: in expansion of macro 'SDA_OLED' static const uint8_t SDA_OLED = 4; ^~~~

exit status 1

Compilation error: expected unqualified-id before numeric constant`

I assume I've got something wrong on my system. Can you assist please?

FrightRisk commented 1 year ago

Did you clear everything out of the folder first? What version of the Adafruit SSD1306 Library do you have installed? Strange that I was able to duplicate that error, which is an odd error, but when something I did made that disappear and others appear. I was bouncing back and forth between the 1.8.9 IDE and the 2.0.4 IDE and I installed the latest Adafruit library. Now I get different errors.

atanisoft commented 1 year ago

@FrightRisk The issue in this case is your Config.h is trying to redefine a constant that is defined in the board's pins_arduino.h file. I'd suggest renaming your define in Config.h to not overlap with the board definition that is coming from arduino-esp32, most boards are switching from using #define FOO {pin number} to const FOO = {pin number} as it triggers a compilation failure such as above which would otherwise go unnoticed and result in unintended behaviors.

Neil-McK commented 1 year ago

Sorry, I was a bit premature in my comments here - I've produced a new version in the bugfixes branch, but that hasn't made its way to master yet. I should have made that clear. The latest error you are seeing appears to come from the order in which the include files are included, I'll look at fixing that too.

Neil-McK commented 1 year ago

The problem is that there used to be a #define ARDUINO_HELTEC_WIFI_KIT_32 implicit during the compilation, but that appears to have disappeared in the more recent versions of the ESP32 support. So the only platform test that can be done in this version of the Arduino IDE is #ifdef ESP_PLATFORM which covers lots of boards and processors. I've moved the #includes around so that the compilation error no longer happens, but you will need to edit the Config.h to reflect the board configuration, e.g. by adding an explicit #define ARDUINO_HELTEC_WIFI_KIT_32 to the top of Config.h. Once I've put the bugfixes into the master branch I'll update the comment and close this issue.

atanisoft commented 1 year ago

The problem is that there used to be a #define ARDUINO_HELTEC_WIFI_KIT_32 implicit during the compilation, but that appears to have disappeared in the more recent versions of the ESP32 support.

That define should still be present if you select the board in the boards menu. Can you confirm it is indeed missing in the verbose compile output? The issue above for the define is due to the pins_arduino.h has a definition that you are trying to overwrite in your Config.h and that is not supported.

Neil-McK commented 1 year ago

I've copied a line from the output and they've changed the macro declaration from ARDUINO_HELTEC_WIFI_KIT_32 to ARDUINO_heltec_wifi_kit_32 - not the same! I'll add a check to the Config.h to address this.

`"C:\Users\neil_\AppData\Local\Arduino15\packages\esp32\tools\xtensa-esp32-elf-gcc\esp-2021r2-patch5-8.4.0/bin/xtensa-esp32-elf-g++" -DHAVE_CONFIG_H "-DMBEDTLS_CONFIG_FILE=\"mbedtls/esp_config.h\"" -DUNITY_INCLUDE_CONFIG_H -DWITH_POSIX -D_GNU_SOURCE "-DIDF_VER=\"v4.4.4\"" -DESP_PLATFORM -D_POSIX_READER_WRITERLOCKS "-IC:\Users\neil\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.7/tools/sdk/esp32/include/newlib/platform_include" "-

...

IC:\Users\neil_\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.7/tools/sdk/esp32/include/fbgfx/include" "-IC:\Users\neil\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.7/tools/sdk/esp32/dio_qspi/include" -mlongcalls -Wno-frame-address -ffunction-sections -fdata-sections -Wno-error=unused-function -Wno-error=unused-variable -Wno-error=deprecated-declarations -Wno-unused-parameter -Wno-sign-compare -ggdb -freorder-blocks -Wwrite-strings -fstack-protector -fstrict-volatile-bitfields -Wno-error=unused-but-set-variable -fno-jump-tables -fno-tree-switch-conversion -std=gnu++11 -fexceptions -fno-rtti -c -w -Os -w -x c++ -E -CC -DF_CPU=240000000L -DARDUINO=10607 -DARDUINO_heltec_wifi_kit_32 -DARDUINO_ARCH_ESP32 "-DARDUINO_BOARD=\"heltec_wifi_kit_32\"" "-DARDUINO_VARIANT=\"heltec_wifi_kit_32\"" -DARDUINO_PARTITION_default -DESP32 -DCORE_DEBUG_LEVEL=0 -DARDUINO_USB_CDC_ONBOOT=0 "@C:\Users\neil\AppData\Local\Temp\arduino\sketches\C9B6DAA3BC22209232E11319AF21D3A9/buildopt.h" "-IC:\Users\neil\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.7\cores\esp32" "-IC:\Users\neil_\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.7\variants\heltec_wifi_kit32" "-IC:\Users\neil\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.7\libraries\WiFi\src" "-IC:\Users\neil\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.7\libraries\WebServer\src" "-IC:\Users\neil\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.7\libraries\ESPmDNS\src" "-Ic:\Users\neil_\Documents\Arduino\libraries\AdafruitSSD1306" "-Ic:\Users\neil\Documents\Arduino\libraries\Adafruit_GFXLibrary" "-Ic:\Users\neil\Documents\Arduino\libraries\AdafruitBusIO" "-IC:\Users\neil\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.7\libraries\Wire\src" "-IC:\Users\neil\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.7\libraries\SPI\src" "C:\Users\neil\AppData\Local\Temp\arduino\sketches\C9B6DAA3BC22209232E11319AF21D3A9\sketch\OledDisplay.cpp" -o nul `

atanisoft commented 1 year ago

changed the macro declaration from ARDUINO_HELTEC_WIFI_KIT_32 to ARDUINO_heltec_wifi_kit_32

Ouch, that is not expected. If you can file an issue for them to fix that as it should not be mixed case, my guess is someone incorrectly updated the board definition accidentially.

Neil-McK commented 1 year ago

The issue in this case is your Config.h is trying to redefine a constant that is defined in the board's pins_arduino.h file.

Quite the opposite - the Config.h was trying not to redefine the existing constants where they already exist, but to define them sensibly when they do not. When such parameters are defined through #define, then it is possible for coders to detect whether a parameter is defined or not by using #ifdef and to take a sensible action either way. However, when such a parameter is declared as a const, I don't know of a way of determining whether it exists or not, other than by compiling and looking for errors.

FrightRisk commented 1 year ago

I submitted an issue. I suppose I could issue a PR too if I have time today

atanisoft commented 1 year ago

it should be as simple as fixing this line. Probably also good to fix these as well:

and any others that used lower case incorrectly for build.board.

FrightRisk commented 1 year ago

Thanks Mike. @twr140 If you need something right now, changing line 92 of config.h to this:

#elif defined(ARDUINO_HELTEC_WIFI_KIT_32) || defined(ARDUINO_heltec_wifi_kit_32) // Heltec Kit 32 has pins 4/15 predefined for I2C If using the Heltec library instead (itself a clone of the Expressif library with just the Heltec boards files), the board name is ARDUINO_wifi_kit_32

Should work. It compiles, but I haven't tested it.

@Neil-McK do we need one for ARDUINO_wifi_kit_32_V3. If someone selects that board, that is what is defined

FrightRisk commented 1 year ago

Just verifying, is everyone using the Heltec ESP32 dev-boards library by Heltec Automation version 1.1.1? Heltec is no longer in the name if it was before. Here is what the compiler sets if you select the "wifi kit 32" board:

-DARDUINO_wifi_kit_32 -DARDUINO_ARCH_ESP32 "-DARDUINO_BOARD=\"wifi_kit_32\"" "-DARDUINO_VARIANT=\"wifi_kit_32\""

image

atanisoft commented 1 year ago

@FrightRisk That doesn't look like the standard arduino-esp32 board definitions, there should be considerably more boards listed.

FrightRisk commented 1 year ago

I just realized there are 2 libraries. I was using the one that my Heltec board referenced. It is from here:

https://github.com/Heltec-Aaron-Lee/WiFi_Kit_series

NOTES: This environment is fully cloned from espressif ESP32 and ESP8266 projects, on that basis, we fixed "variants" folder and "boards.txt", for convenience of "Arduino + ESP" beginners and Heltec ESP series Dev boards users.

This environment does not include onboard OLED LoRa etc. drivers and examples anymore, they had been moved to another library:

For ESP32 series: https://github.com/HelTecAutomation/Heltec_ESP32

For ESP8266 series: https://github.com/HelTecAutomation/Heltec_ESP8266

Sigh. Assuming all they changed was the 2 files listed above, I can use the Expressif library.

atanisoft commented 1 year ago

Assuming all they changed was the 2 files listed above, I can use the Espressif library.

I would strongly suggest moving to the Espressif repository only and not third party clones of the same. The version you referenced (WiFi_Kit_series) is a bit out-of-date considering it is only v2.0.4 and the latest is v2.0.7 in Espressif's repository.

Neil-McK commented 1 year ago

I was using the esp32 library that Arduino IDE recommends, which is 2.0.7 I think. Pio uses 2.0.6 (edited). Neither is provided by heltec.

On Wed, 8 Mar 2023, 19:27 Mike Dunston, @.***> wrote:

Assuming all they changed was the 2 files listed above, I can use the Espressif library.

I would strongly suggest moving to the Espressif repository only and not third party clones of the same. The version you referenced (WiFi_Kit_series) is a bit out-of-date considering it is only v2.0.4 and the latest is v2.0.7 in Espressif's repository.

— Reply to this email directly, view it on GitHub https://github.com/DCC-EX/DCCInspector-EX/issues/12#issuecomment-1460735979, or unsubscribe https://github.com/notifications/unsubscribe-auth/ASCNI2O2STKHTHUXBJSY5TLW3DMRHANCNFSM5KNUQTVA . You are receiving this because you were mentioned.Message ID: @.***>

Neil-McK commented 1 year ago

Correction - the PIO library is v2.0.6.

CONFIGURATION: https://docs.platformio.org/page/boards/espressif32/heltec_wifi_kit_32_v2.html PLATFORM: Espressif 32 (6.0.1) > Heltec WiFi Kit 32 (V2) HARDWARE: ESP32 240MHz, 320KB RAM, 8MB Flash DEBUG: Current (cmsis-dap) External (cmsis-dap, esp-bridge, esp-prog, iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, tumpa) PACKAGES:

------ Original Message ------ From: "Mike Dunston" @.> To: "DCC-EX/DCCInspector-EX" @.> Cc: "Neil McKechnie" @.>; "Mention" @.> Sent: 08/03/2023 19:27:15 Subject: Re: [DCC-EX/DCCInspector-EX] Compile errors using esp32 Board library 2.0.0 and 2.0.1, in Arduino IDE 1.8.6 (Issue #12)

Assuming all they changed was the 2 files listed above, I can use the Espressif library.

I would strongly suggest moving to the Espressif repository only and not third party clones of the same. The version you referenced (WiFi_Kit_series) is a bit out-of-date considering it is only v2.0.4 and the latest is v2.0.7 in Espressif's repository.

— Reply to this email directly, view it on GitHub https://github.com/DCC-EX/DCCInspector-EX/issues/12#issuecomment-1460735979, or unsubscribe https://github.com/notifications/unsubscribe-auth/ASCNI2O2STKHTHUXBJSY5TLW3DMRHANCNFSM5KNUQTVA. You are receiving this because you were mentioned.Message ID: @.***>

Neil-McK commented 1 year ago

When using PlatformIO (framework v2.0.6), the macro ARDUINO_HELTEC_WIFI_KIT_32 is being defined and not ARDUINO_heltec_wifi_kit_32, so the conditional compilation works as intended.

So it's possible that the Arduino IDE has always had the #define ARDUINO_heltec_wifi_kit_32, I mostly use PIO and I've only just pushed those changes to fix other bugs.

Neil-McK commented 1 year ago

The original Heltec esp32 platform has the following in the boards.txt in the Arduino15 folder: wifi_kit_32.build.board=WIFI_KIT_32 The corresponding entry in the esp32 2.0.7 platform is: heltec_wifi_kit_32.build.board=heltec_wifi_kit_32 Looking through the boards.txt, there isn't much consistency about capitalisation of the board names. Many are upper case but some are mixed case and a few lower case.

PlatformIO doesn't appear to have a boards.txt but it does have files like heltec_wifi_kit_32.json which contains:

{
  "build": {
    "arduino":{
      "ldscript": "esp32_out.ld"
    },
    "core": "esp32",
    "extra_flags": "-DARDUINO_HELTEC_WIFI_KIT_32",
etc.
atanisoft commented 1 year ago

there isn't much consistency about capitalisation of the board names.

An issue should definitely be logged as it should always be upper case to be consistent with typical usages / recommendations for #define based constants.

atanisoft commented 1 year ago

Accidentally hit the close button, sorry...

twr140 commented 1 year ago

Well I certainly didn't expect to wake up to all this!

Sorry, I was a bit premature in my comments here - I've produced a new version in the bugfixes branch, but that hasn't made its way to master yet. I should have made that clear. The latest error you are seeing appears to come from the order in which the include files are included, I'll look at fixing that too.

@Neil-McK: I'm sorry if I was too quick to try this out and have caused problems.

@FrightRisk:

Did you clear everything out of the folder first? What version of the Adafruit SSD1306 Library do you have installed? Strange that I was able to duplicate that error, which is an odd error, but when something I did made that disappear and others appear. I was bouncing back and forth between the 1.8.9 IDE and the 2.0.4 IDE and I installed the latest Adafruit library. Now I get different errors.

Reading through all the rest of the comments since you asked this, I think this isn't relevant, but my Adafruit SSD1306 library is v2.5.7

Thanks Mike. @twr140 If you need something right now, changing line 92 of config.h to this:

#elif defined(ARDUINO_HELTEC_WIFI_KIT_32) || defined(ARDUINO_heltec_wifi_kit_32) // Heltec Kit 32 has pins 4/15 predefined for I2C If using the Heltec library instead (itself a clone of the Expressif library with just the Heltec boards files), the board name is ARDUINO_wifi_kit_32

Should work. It compiles, but I haven't tested it.

@Neil-McK do we need one for ARDUINO_wifi_kit_32_V3. If someone selects that board, that is what is defined

Thanks, but I won't bother yet. I simply tested this yesterday because Neil had kindly posted what I thought was a fix to the issue I raised, and felt it was the right thing to do to try it out and provide feedback.

Thanks everyone for investigating this. Sorry that I can't help, but I'm not a programmer. I only know enough to be able to cobble together simple code for my own stuff, and most of the time just use what others such as yourselves kindly provide.

Neil-McK commented 1 year ago

Not at all, thanks for the feedback. You can see that it was very useful to us! I'll try to be more explicit on the state-of-play in future, to avoid raising expectations.

Neil-McK commented 1 year ago

The relevant changes have now been applied in the master branch, please confirm if the problem has been solved.

twr140 commented 1 year ago

Thanks @Neil-McK I have successfully compiled the code this morning. From my quick check, it all seems to be working on the actual hardware as well.

There does appear to be an issue with the new(?) battery voltage check in setup() though. I'll open another Issue for it because it isn't related to this issue.

Neil-McK commented 1 year ago

Thanks for the update. I was aware that the esp32 battery check isn't quite right. It was something I had on an esp8266 which worked fine. The heltec esp32 should have the same connections but I don't know why it doesn't work.

Cheers!

On Thu, 23 Mar 2023, 23:45 twr140, @.***> wrote:

Thanks @Neil-McK https://github.com/Neil-McK I have successfully compiled the code this morning. From my quick check, it all seems to be working on the actual hardware as well.

There does appear to be an issue with the new(?) battery voltage check in setup() though. I'll open another Issue for it because it isn't related to this issue.

— Reply to this email directly, view it on GitHub https://github.com/DCC-EX/DCCInspector-EX/issues/12#issuecomment-1482055218, or unsubscribe https://github.com/notifications/unsubscribe-auth/ASCNI2O75YFWRYNWB2KIFBTW5TODNANCNFSM5KNUQTVA . You are receiving this because you were mentioned.Message ID: @.***>