plerup/makeEspArduino

Compilation of a simple program for esp32 fails because it tries to include library SoftwareSerial only available for architecture avr

vtamara opened this issue · 1 comments

Platform where I tested:

  • OS: adJ/OpenBSD 7.2
  • makeEspArduino: 6.6.5 (I also tried with branch main with the same result)
  • Target: esp32

Steps to reproduce the problem:

  1. If you are using adJ/OpenBSD 7.2 or 7.3 install packages:
       doas pkg_add makeesparduino \
    arduino \
    arduino-esp32 \
    arduino-makefile \
    py3-esptool \
    xtensa-esp32-elf-gcc \
    xtensa-esp32-elf-binutils \
    xtensa-esp32-elf-newlib \
    mkspiffs \
    gmake
    
  2. Clone https://github.com/vtamara/prob-makeEspArduino
  3. Compile with gmake

You should see many errors like:

/usr/local/xtensa-esp32-elf/xtensa-esp32-elf/include/wchar.h:75:16:
error: conflicting declaration 'typedef __FILE FILE'
 typedef __FILE FILE;
                ^~~~
In file included from
/usr/local/share/arduino/hardware/espressif/esp32/cores/esp32/HardwareSerial.cpp:2:
/usr/local/avr/include/stdio.h:277:23: note: previous declaration as 'typedef
struct __file FILE'
 typedef struct __file FILE;

How to overcome the problem:

If in the source file you change:

#if defined(__AVR__)
#include <SoftwareSerial.h>
#endif

with

#if defined(__AVR__)
//#include <SoftwareSerial.h>
#endif

The problem will no happen.

What I think is producing the problem

The generated files are trying to use at the same time libc for esp32 and
libc for avr.

The problem is that makeEspArduino tries to add SerialSoftware that is only for architecture avr,
alghough it is referenced inside a section #if defined(__AVR__) .
The symbol __AVR__ is not defined when compiling for esp32, so the
#include <SoftwareSerial.h> should be skipped but it seems
the algorithm used by makeEspArduino to decide what to compile
ignores the directive #if.

The search for dependencies is rather blunt and does not handle ifdefs
However you can avoid the problem by adding:

 EXCLUDE_DIRS=SoftwareSerial

to the command line or your makefile