Problems with build_flags

Dear forum,

I am working on a project with ESP32 web server and web socket.

I use this library: <GitHub - ESP32Async/ESPAsyncWebServer: Async Web Server for ESP32> and <GitHub - ESP32Async/AsyncTCP: Async TCP Library for ESP32>

The documentation states (literally):
I personally use the following configuration in my projects:

  -D CONFIG_ASYNC_TCP_MAX_ACK_TIME=5000   // (keep default)
  -D CONFIG_ASYNC_TCP_PRIORITY=10         // (keep default)
  -D CONFIG_ASYNC_TCP_QUEUE_SIZE=64       // (keep default)
  -D CONFIG_ASYNC_TCP_RUNNING_CORE=1      // force async_tcp task to be on same core as Arduino app (default is any core)
  -D CONFIG_ASYNC_TCP_STACK_SIZE=4096     // reduce the stack size (default is 16K)

If I run my project without build_flags everything is OK but I actually have server crashes.
with build_flags I get errors

20 / 5.000

my platformio.ini:

[env:debug]
platform = espressif32
framework = arduino
board = az-delivery-devkit-v4
upload_port = /dev/ttyUSB0
lib_deps =
sstaub/TickTwo@^4.4.0
Rickgg/ESP-Dmx.git
arduino-libraries/Arduino_JSON@^0.2.0
me-no-dev/ESPAsyncWebServer @ ^3.6.0
me-no-dev/AsyncTCP @ ^3.3.2
build_flags =
-D CONFIG_ASYNC_TCP_RUNNING_CORE=1 ;// force async_tcp task to be on same core as the app (default is core 0)
-D CONFIG_ASYNC_TCP_STACK_SIZE=4096; // reduce the stack size (default is 16K)

I get the following errors:

TypeError: Tried to lookup Dir '/home/ich/.platformio/platforms/espressif32/builder' as a File.:
  File "/home/ich/.platformio/penv/lib/python3.10/site-packages/platformio/builder/main.py", line 173:
    env.SConscript("$BUILD_SCRIPT")
  File "/home/ich/.platformio/packages/tool-scons/scons-local-4.8.1/SCons/Script/SConscript.py", line 620:
    return _SConscript(self.fs, *files, **subst_kw)
  File "/home/ich/.platformio/packages/tool-scons/scons-local-4.8.1/SCons/Script/SConscript.py", line 280:
    exec(compile(scriptdata, scriptname, 'exec'), call_stack[-1].globals)
  File "/home/ich/.platformio/platforms/espressif32/builder/main.py", line 368:
    target_elf = env.BuildProgram()
  File "/home/ich/.platformio/packages/tool-scons/scons-local-4.8.1/SCons/Util/envs.py", line 252:
    return self.method(*nargs, **kwargs)
  File "/home/ich/.platformio/penv/lib/python3.10/site-packages/platformio/builder/tools/piobuild.py", line 61:
    env.ProcessProgramDeps()
  File "/home/ich/.platformio/packages/tool-scons/scons-local-4.8.1/SCons/Util/envs.py", line 252:
    return self.method(*nargs, **kwargs)
  File "/home/ich/.platformio/penv/lib/python3.10/site-packages/platformio/builder/tools/piobuild.py", line 118:
    env.ProcessFlags(env.get("BUILD_FLAGS"))
  File "/home/ich/.platformio/packages/tool-scons/scons-local-4.8.1/SCons/Util/envs.py", line 252:
    return self.method(*nargs, **kwargs)
  File "/home/ich/.platformio/penv/lib/python3.10/site-packages/platformio/builder/tools/piobuild.py", line 233:
    env.Append(**env.ParseFlagsExtended(flags))
  File "/home/ich/.platformio/packages/tool-scons/scons-local-4.8.1/SCons/Util/envs.py", line 252:
    return self.method(*nargs, **kwargs)
  File "/home/ich/.platformio/penv/lib/python3.10/site-packages/platformio/builder/tools/piobuild.py", line 195:
    for key, value in env.ParseFlags(str(raw)).items():
  File "/home/ich/.platformio/packages/tool-scons/scons-local-4.8.1/SCons/Environment.py", line 1034:
    do_parse(arg)
  File "/home/ich/.platformio/packages/tool-scons/scons-local-4.8.1/SCons/Environment.py", line 950:
    mapping['LIBS'].append(self.fs.File(arg))
  File "/home/ich/.platformio/packages/tool-scons/scons-local-4.8.1/SCons/Node/FS.py", line 1458:
    return self._lookup(name, directory, File, create)
  File "/home/ich/.platformio/packages/tool-scons/scons-local-4.8.1/SCons/Node/FS.py", line 1437:
    return root._lookup_abs(p, fsclass, create)
  File "/home/ich/.platformio/packages/tool-scons/scons-local-4.8.1/SCons/Node/FS.py", line 2480:
    result.must_be_same(klass)
  File "/home/ich/.platformio/packages/tool-scons/scons-local-4.8.1/SCons/Node/FS.py", line 644:
    raise TypeError("Tried to lookup %s '%s' as a %s." %\
========================== [FAILED] Took 0.41 seconds ==========================

Thank you very much for taking a look!
Best regards Holger

Hi @hotte !

No, you don’t. You use

me-no-dev/ESPAsyncWebServer @ ^3.6.0
me-no-dev/AsyncTCP @ ^3.3.2

Change this to

  ESP32Async/ESPAsyncWebServer @ ^3.7.0

Since ESPAsyncWebServer is dependent to AsyncTCP the latter will be installed automatically and can removed from the lib_deps.

Now the main issue:

Please check the indention of your platformio.ini. lib_deps and build_flags must be used with 2 leading spaces, like so:

[env:debug]
platform = espressif32
framework = arduino
board = az-delivery-devkit-v4
upload_port = /dev/ttyUSB0
lib_deps =
  sstaub/TickTwo@^4.4.0
  Rickgg/ESP-Dmx.git
  arduino-libraries/Arduino_JSON@^0.2.0
  ESP32Async/ESPAsyncWebServer @ ^3.7.0
build_flags =
  -D CONFIG_ASYNC_TCP_RUNNING_CORE=1 ;// force async_tcp task to be on same core as the app (default is core 0)
  -D CONFIG_ASYNC_TCP_STACK_SIZE=4096; // reduce the stack size (default is 16K)

Are you sure about arduino-libraries/Arduino_JSON ?
There is blanchon/ArduinoJson See https://arduinojson.org/

Dear sivar2311,
I thank you very much for your help!
It is not a given and I know everything here is voluntary.
As a beginner and occasional programmer, I have learned a lot again. My problem is solved
Best regards
Holger

1 Like