Compilation Errors with M5Tough ESP32, Husarnet Library, and PlatformIO

I am working on a project where I am using Husarnet to connect my ESP32 (M5Tough ESP32) to serve HTML files online. I have downloaded the Husarnet library for ESP32 in the Arduino framework using PlatformIO. However, I am encountering compilation errors that seem to relate to both the Husarnet library and the ESP32 toolchain.

Here are the errors I am facing:

  1. error: 'pthread_mutex_timedlock' was not declared in this scope
  • Suggested alternative: 'pthread_mutex_trylock'
  1. error: expected initializer before '__result_use_check'
  2. error: '::calloc' has not been declared
  3. error: '::malloc' has not been declared
  4. error: '::realloc' has not been declared
  5. error: 'malloc' was not declared in this scope
  • Note: 'malloc' is defined in header '<cstdlib>'; did you forget to '#include <cstdlib>'?
  1. error: expected initializer before '__alloc_align'

From what I understand, the issues are around:

I have ensured that my PlatformIO environment, ESP32 core, and all libraries are updated to their latest versions. However, the issues persist.

Is there a known resolution for these errors, or any steps you would recommend for troubleshooting this further?

Additionally, if there’s any further information needed to diagnose these issues, I’d be happy to provide it.

Thank you in advance for any assistance!

Hi

Make sure in [env] section of platformio.ini you have line:

platform = espressif32@2.1.0

Example:

[env]
platform = espressif32@2.1.0
framework = arduino
platform_packages =
    framework-arduinoespressif32 @ https://github.com/husarnet/arduino-esp32/releases/download/1.0.4-1/arduino-husarnet-esp32.zip
lib_deps =
    Husarnet ESP32

[env:esp32cam]
board = esp32cam
monitor_speed = 115200

Regards, Filip

I ensured this in the beginning. I have rechecked the code several times, Didnt work. Could it be because of M5Core libraries like M5Unified or Asyncwebserver and AsyncTCP libraries?

Yes, this may be possible because of M5Unified or AsyncTCP.

Firstly make sure you are using our fork of AsyncTCP

Make sure your platformio.ini contains line:

lib_deps =
    https://github.com/husarion/AsyncTCP.git

If that doesn’t help try using older M5Unified library version, especially if latest version require newer versions of arduino-esp32. We’re quite frankly using a pretty ancient one and still working on making it more modern.

Regards, Filip