Code Monkey home page Code Monkey logo

makeesparduino's People

Contributors

basepr1me avatar dom96 avatar everslick avatar glynhudson avatar gpancot avatar hamishcunningham avatar igrr avatar me-no-dev avatar njdancer avatar opokatech avatar plerup avatar reitermarkus avatar sp4rkie avatar tho85 avatar veractor avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

makeesparduino's Issues

Linker error with a multi-file project

Hi,
I have a project which I try to build using makeEspArduino Makefile, and I seem to run into some issues when using multiple files in my project (to create several libraries for the project for example).
More particularly, I have build an independent "Wifi_Lib" library, in separate files (Wifi_Lib.h & Wifi_Lib.cpp). in Wifi_Lib.cpp, the appropriate include is executed:

#include "ESP8266WiFi.h"
WiFiClient client;
...

This library is included in the main ino file of the project.
When linking I have the following issue:

  Versions: 815e3a0-dirty, 2.3.0
/Wifi_Lib.cpp.o:(.text._Z14initializeWifiv+0x0): undefined reference to `WiFi'
/Wifi_Lib.cpp.o:(.text._Z14initializeWifiv+0x4): undefined reference to `ESP8266WiFiGenericClass::mode(WiFiMode)'
/Wifi_Lib.cpp.o: In function `initializeWifi()':
/Wifi_Lib.cpp:214: undefined reference to `ESP8266WiFiGenericClass::mode(WiFiMode)'

An include of ESP8266WiFi.h in the main ino file solves the issue. However, this include is not mandatory per se in the ino file., only in the library.
I think the issue is related to the automatic search performed for LIBS (which is only executed for the sketch file, not for the dependent files).

Is there any possible fix for this ? Or are there some guiding rules for a multifile project with makeEspArduino ?

Thank you,

Edit: might be linked to #28 ?

How to set output directory relative to the sketch

I made an alias for the makeEspArduino.mk file as described in the readme. Now i want to change the makefile so that it produces a binary in the /buid folder next to the sketch. So if I have the sketch at ~/Documents/sketches/mySketch/fiest.ino , the output should be placed at ~/Documents/sketches/mySketch/build/first.bin

Build error when building a project with Azure IoT Arduino libraries

I have built a relatively simple Arduino project successfully with makeEspArduino, which is great. Now I'm trying to build a more complex project that involves Microsoft's Azure IoT libraries, and the build fails with a compiler error for the very first file.

I tried to track this down, and the reason appears to be that in the failing build additional include directories from the ESP8266 gcc installation are provided on the compiler command line that cause a compilation failure.

This is the very first file that is compiled in the failing build (sorry for the very long lines):

	"/mnt/e/Users/stm/Documents/GitHub/Arduino-esp8266//tools/xtensa-lx106-elf/bin/xtensa-lx106-elf-g++" -D__ets__ -DICACHE_FLASH -U__STRICT_ANSI__ "-I/mnt/e/Users/stm/Documents/GitHub/Arduino-esp8266//tools/sdk/include" "-I/mnt/e/Users/stm/Documents/GitHub/Arduino-esp8266//tools/sdk/lwip2/include" "-I/mnt/e/Users/stm/Documents/GitHub/Arduino-esp8266//tools/sdk/libc/xtensa-lx106-elf/include" "-I/tmp/mkESP/simplesample_http_generic/core"  -c -w -Os -g -mlongcalls -mtext-section-literals -fno-exceptions -fno-rtti -falign-functions=4 -std=c++11 -MMD -ffunction-sections -fdata-sections -DF_CPU=80000000L -DLWIP_OPEN_SRC -DTCP_MSS=536   -DARDUINO=10605 -DARDUINO_ESP8266_GENERIC -DARDUINO_ARCH_ESP8266 -DARDUINO_BOARD=\"ESP8266_GENERIC\"   -DESP8266  -I/mnt/e/Users/stm/Documents/GitHub/Arduino-esp8266//cores/esp8266 -I/mnt/e/Users/stm/Documents/GitHub/Arduino-esp8266//variants/generic -I/tmp/mkESP/simplesample_http_generic -I../azure-iot-arduino-protocol-http/src/ -I../azure-iot-arduino-utility/src/ -I../azure-iot-arduino-utility/src/adapters/ -I../azure-iot-arduino-utility/src/azure_c_shared_utility/ -I../azure-iot-arduino-utility/src/esp8266/ -I../azure-iot-arduino-utility/src/samd/ -I../azure-iot-arduino/src/ -I../azure-iot-arduino/src/azure_umqtt_c/ -I../azure-iot-arduino/src/sdk/ -I./ -I/mnt/e/Users/stm/Documents/GitHub/Arduino-esp8266/bootloaders/eboot/ -I/mnt/e/Users/stm/Documents/GitHub/Arduino-esp8266/cores/esp8266/ -I/mnt/e/Users/stm/Documents/GitHub/Arduino-esp8266/cores/esp8266/libb64/ -I/mnt/e/Users/stm/Documents/GitHub/Arduino-esp8266/cores/esp8266/spiffs/ -I/mnt/e/Users/stm/Documents/GitHub/Arduino-esp8266/cores/esp8266/umm_malloc/ -I/mnt/e/Users/stm/Documents/GitHub/Arduino-esp8266/libraries/ArduinoOTA/ -I/mnt/e/Users/stm/Documents/GitHub/Arduino-esp8266/libraries/DNSServer/src/ -I/mnt/e/Users/stm/Documents/GitHub/Arduino-esp8266/libraries/EEPROM/ -I/mnt/e/Users/stm/Documents/GitHub/Arduino-esp8266/libraries/ESP8266AVRISP/src/ -I/mnt/e/Users/stm/Documents/GitHub/Arduino-esp8266/libraries/ESP8266HTTPClient/src/ -I/mnt/e/Users/stm/Documents/GitHub/Arduino-esp8266/libraries/ESP8266HTTPUpdateServer/src/ -I/mnt/e/Users/stm/Documents/GitHub/Arduino-esp8266/libraries/ESP8266LLMNR/ -I/mnt/e/Users/stm/Documents/GitHub/Arduino-esp8266/libraries/ESP8266NetBIOS/ -I/mnt/e/Users/stm/Documents/GitHub/Arduino-esp8266/libraries/ESP8266SSDP/ -I/mnt/e/Users/stm/Documents/GitHub/Arduino-esp8266/libraries/ESP8266WebServer/src/ -I/mnt/e/Users/stm/Documents/GitHub/Arduino-esp8266/libraries/ESP8266WebServer/src/detail/ -I/mnt/e/Users/stm/Documents/GitHub/Arduino-esp8266/libraries/ESP8266WiFi/src/ -I/mnt/e/Users/stm/Documents/GitHub/Arduino-esp8266/libraries/ESP8266WiFi/src/include/ -I/mnt/e/Users/stm/Documents/GitHub/Arduino-esp8266/libraries/ESP8266WiFiMesh/src/ -I/mnt/e/Users/stm/Documents/GitHub/Arduino-esp8266/libraries/ESP8266httpUpdate/src/ -I/mnt/e/Users/stm/Documents/GitHub/Arduino-esp8266/libraries/ESP8266mDNS/ -I/mnt/e/Users/stm/Documents/GitHub/Arduino-esp8266/libraries/Ethernet/examples/udpntpclient_pedantic/ -I/mnt/e/Users/stm/Documents/GitHub/Arduino-esp8266/libraries/Ethernet/src/ -I/mnt/e/Users/stm/Documents/GitHub/Arduino-esp8266/libraries/Ethernet/src/utility/ -I/mnt/e/Users/stm/Documents/GitHub/Arduino-esp8266/libraries/GDBStub/src/ -I/mnt/e/Users/stm/Documents/GitHub/Arduino-esp8266/libraries/GDBStub/src/internal/ -I/mnt/e/Users/stm/Documents/GitHub/Arduino-esp8266/libraries/GDBStub/src/xtensa/ -I/mnt/e/Users/stm/Documents/GitHub/Arduino-esp8266/libraries/GDBStub/src/xtensa/config/ -I/mnt/e/Users/stm/Documents/GitHub/Arduino-esp8266/libraries/Hash/src/ -I/mnt/e/Users/stm/Documents/GitHub/Arduino-esp8266/libraries/Hash/src/sha1/ -I/mnt/e/Users/stm/Documents/GitHub/Arduino-esp8266/libraries/SD/src/ -I/mnt/e/Users/stm/Documents/GitHub/Arduino-esp8266/libraries/SD/src/utility/ -I/mnt/e/Users/stm/Documents/GitHub/Arduino-esp8266/libraries/SPI/ -I/mnt/e/Users/stm/Documents/GitHub/Arduino-esp8266/libraries/SPISlave/src/ -I/mnt/e/Users/stm/Documents/GitHub/Arduino-esp8266/libraries/Servo/src/ -I/mnt/e/Users/stm/Documents/GitHub/Arduino-esp8266/libraries/Servo/src/esp8266/ -I/mnt/e/Users/stm/Documents/GitHub/Arduino-esp8266/libraries/TFT_Touch_Shield_V2/ -I/mnt/e/Users/stm/Documents/GitHub/Arduino-esp8266/libraries/Ticker/ -I/mnt/e/Users/stm/Documents/GitHub/Arduino-esp8266/libraries/Wire/ -I/mnt/e/Users/stm/Documents/GitHub/Arduino-esp8266/libraries/esp8266/src/ -I/mnt/e/Users/stm/Documents/GitHub/Arduino-esp8266/tests/device/libraries/BSTest/src/ -I/mnt/e/Users/stm/Documents/GitHub/Arduino-esp8266/tests/host/common/ -I/mnt/e/Users/stm/Documents/GitHub/Arduino-esp8266/tools/sdk/include/ -I/mnt/e/Users/stm/Documents/GitHub/Arduino-esp8266/tools/sdk/include/json/ -I/mnt/e/Users/stm/Documents/GitHub/Arduino-esp8266/tools/sdk/libc/xtensa-lx106-elf/include/ -I/mnt/e/Users/stm/Documents/GitHub/Arduino-esp8266/tools/sdk/libc/xtensa-lx106-elf/include/machine/ -I/mnt/e/Users/stm/Documents/GitHub/Arduino-esp8266/tools/sdk/libc/xtensa-lx106-elf/include/sys/ -I/mnt/e/Users/stm/Documents/GitHub/Arduino-esp8266/tools/sdk/libc/xtensa-lx106-elf/include/xtensa/config/ -I/mnt/e/Users/stm/Documents/GitHub/Arduino-esp8266/tools/sdk/lwip/include/ -I/mnt/e/Users/stm/Documents/GitHub/Arduino-esp8266/tools/sdk/lwip/include/arch/ -I/mnt/e/Users/stm/Documents/GitHub/Arduino-esp8266/tools/sdk/lwip/include/lwip/ -I/mnt/e/Users/stm/Documents/GitHub/Arduino-esp8266/tools/sdk/lwip/include/lwip/app/ -I/mnt/e/Users/stm/Documents/GitHub/Arduino-esp8266/tools/sdk/lwip/include/netif/ -I/mnt/e/Users/stm/Documents/GitHub/Arduino-esp8266/tools/sdk/lwip2/include/ -I/mnt/e/Users/stm/Documents/GitHub/Arduino-esp8266/tools/sdk/lwip2/include/arch/ -I/mnt/e/Users/stm/Documents/GitHub/Arduino-esp8266/tools/sdk/lwip2/include/lwip/ -I/mnt/e/Users/stm/Documents/GitHub/Arduino-esp8266/tools/sdk/lwip2/include/lwip/apps/ -I/mnt/e/Users/stm/Documents/GitHub/Arduino-esp8266/tools/sdk/lwip2/include/lwip/priv/ -I/mnt/e/Users/stm/Documents/GitHub/Arduino-esp8266/tools/sdk/lwip2/include/lwip/prot/ -I/mnt/e/Users/stm/Documents/GitHub/Arduino-esp8266/tools/sdk/lwip2/include/netif/ -I/mnt/e/Users/stm/Documents/GitHub/Arduino-esp8266/tools/sdk/lwip2/include/netif/ppp/ -I/mnt/e/Users/stm/Documents/GitHub/Arduino-esp8266/tools/sdk/lwip2/include/netif/ppp/polarssl/ -I/mnt/e/Users/stm/Documents/GitHub/Arduino-esp8266/tools/sdk/lwip2/include/posix/ -I/mnt/e/Users/stm/Documents/GitHub/Arduino-esp8266/tools/sdk/lwip2/include/posix/sys/ -I/mnt/e/Users/stm/Documents/GitHub/Arduino-esp8266/tools/xtensa-lx106-elf/include/gdb/ -I/mnt/e/Users/stm/Documents/GitHub/Arduino-esp8266/tools/xtensa-lx106-elf/lib/gcc/xtensa-lx106-elf/4.8.2/include-fixed/ -I/mnt/e/Users/stm/Documents/GitHub/Arduino-esp8266/tools/xtensa-lx106-elf/lib/gcc/xtensa-lx106-elf/4.8.2/include/ -I/mnt/e/Users/stm/Documents/GitHub/Arduino-esp8266/tools/xtensa-lx106-elf/lib/gcc/xtensa-lx106-elf/4.8.2/install-tools/ -I/mnt/e/Users/stm/Documents/GitHub/Arduino-esp8266/tools/xtensa-lx106-elf/lib/gcc/xtensa-lx106-elf/4.8.2/install-tools/include/ -I/mnt/e/Users/stm/Documents/GitHub/Arduino-esp8266/tools/xtensa-lx106-elf/lib/gcc/xtensa-lx106-elf/4.8.2/plugin/include/ -I/mnt/e/Users/stm/Documents/GitHub/Arduino-esp8266/tools/xtensa-lx106-elf/lib/gcc/xtensa-lx106-elf/4.8.2/plugin/include/c-family/ -I/mnt/e/Users/stm/Documents/GitHub/Arduino-esp8266/tools/xtensa-lx106-elf/lib/gcc/xtensa-lx106-elf/4.8.2/plugin/include/config/ -I/mnt/e/Users/stm/Documents/GitHub/Arduino-esp8266/tools/xtensa-lx106-elf/lib/gcc/xtensa-lx106-elf/4.8.2/plugin/include/config/xtensa/ -I/mnt/e/Users/stm/Documents/GitHub/Arduino-esp8266/tools/xtensa-lx106-elf/lib/gcc/xtensa-lx106-elf/4.8.2/plugin/include/cp/ -I/mnt/e/Users/stm/Documents/GitHub/Arduino-esp8266/tools/xtensa-lx106-elf/xtensa-lx106-elf/include/ -I/mnt/e/Users/stm/Documents/GitHub/Arduino-esp8266/tools/xtensa-lx106-elf/xtensa-lx106-elf/include/c++/4.8.2/ -I/mnt/e/Users/stm/Documents/GitHub/Arduino-esp8266/tools/xtensa-lx106-elf/xtensa-lx106-elf/include/c++/4.8.2/backward/ -I/mnt/e/Users/stm/Documents/GitHub/Arduino-esp8266/tools/xtensa-lx106-elf/xtensa-lx106-elf/include/c++/4.8.2/bits/ -I/mnt/e/Users/stm/Documents/GitHub/Arduino-esp8266/tools/xtensa-lx106-elf/xtensa-lx106-elf/include/c++/4.8.2/debug/ -I/mnt/e/Users/stm/Documents/GitHub/Arduino-esp8266/tools/xtensa-lx106-elf/xtensa-lx106-elf/include/c++/4.8.2/decimal/ -I/mnt/e/Users/stm/Documents/GitHub/Arduino-esp8266/tools/xtensa-lx106-elf/xtensa-lx106-elf/include/c++/4.8.2/ext/ -I/mnt/e/Users/stm/Documents/GitHub/Arduino-esp8266/tools/xtensa-lx106-elf/xtensa-lx106-elf/include/c++/4.8.2/parallel/ -I/mnt/e/Users/stm/Documents/GitHub/Arduino-esp8266/tools/xtensa-lx106-elf/xtensa-lx106-elf/include/c++/4.8.2/profile/ -I/mnt/e/Users/stm/Documents/GitHub/Arduino-esp8266/tools/xtensa-lx106-elf/xtensa-lx106-elf/include/c++/4.8.2/profile/impl/ -I/mnt/e/Users/stm/Documents/GitHub/Arduino-esp8266/tools/xtensa-lx106-elf/xtensa-lx106-elf/include/c++/4.8.2/tr1/ -I/mnt/e/Users/stm/Documents/GitHub/Arduino-esp8266/tools/xtensa-lx106-elf/xtensa-lx106-elf/include/c++/4.8.2/xtensa-lx106-elf/bits/ -I/mnt/e/Users/stm/Documents/GitHub/Arduino-esp8266/tools/xtensa-lx106-elf/xtensa-lx106-elf/include/c++/4.8.2/xtensa-lx106-elf/ext/ -I/mnt/e/Users/stm/Documents/GitHub/Arduino-esp8266/tools/xtensa-lx106-elf/xtensa-lx106-elf/include/machine/ -I/mnt/e/Users/stm/Documents/GitHub/Arduino-esp8266/tools/xtensa-lx106-elf/xtensa-lx106-elf/include/sys/ -I/mnt/e/Users/stm/Documents/GitHub/Arduino-esp8266/tools/xtensa-lx106-elf/xtensa-lx106-elf/include/xtensa/config/ -I/mnt/e/Users/stm/Documents/GitHub/Arduino-esp8266/variants/ESPDuino/ -I/mnt/e/Users/stm/Documents/GitHub/Arduino-esp8266/variants/adafruit/ -I/mnt/e/Users/stm/Documents/GitHub/Arduino-esp8266/variants/arduino_spi/ -I/mnt/e/Users/stm/Documents/GitHub/Arduino-esp8266/variants/arduino_uart/ -I/mnt/e/Users/stm/Documents/GitHub/Arduino-esp8266/variants/d1/ -I/mnt/e/Users/stm/Documents/GitHub/Arduino-esp8266/variants/d1_mini/ -I/mnt/e/Users/stm/Documents/GitHub/Arduino-esp8266/variants/espino/ -I/mnt/e/Users/stm/Documents/GitHub/Arduino-esp8266/variants/espinotee/ -I/mnt/e/Users/stm/Documents/GitHub/Arduino-esp8266/variants/espresso_lite_v1/ -I/mnt/e/Users/stm/Documents/GitHub/Arduino-esp8266/variants/espresso_lite_v2/ -I/mnt/e/Users/stm/Documents/GitHub/Arduino-esp8266/variants/generic/ -I/mnt/e/Users/stm/Documents/GitHub/Arduino-esp8266/variants/nodemcu/ -I/mnt/e/Users/stm/Documents/GitHub/Arduino-esp8266/variants/oak/ -I/mnt/e/Users/stm/Documents/GitHub/Arduino-esp8266/variants/phoenix_v1/ -I/mnt/e/Users/stm/Documents/GitHub/Arduino-esp8266/variants/phoenix_v2/ -I/mnt/e/Users/stm/Documents/GitHub/Arduino-esp8266/variants/thing/ -I/mnt/e/Users/stm/Documents/GitHub/Arduino-esp8266/variants/wifinfo/ -I/mnt/e/Users/stm/Documents/GitHub/Arduino-esp8266/variants/wifio/   /mnt/e/Users/stm/Documents/GitHub/Arduino-esp8266//cores/esp8266/abi.cpp -o /tmp/mkESP/simplesample_http_generic/abi.cpp.o
In file included from /mnt/e/Users/stm/Documents/GitHub/Arduino-esp8266//tools/sdk/libc/xtensa-lx106-elf/include/stdlib.h:11:0,
                 from /mnt/e/Users/stm/Documents/GitHub/Arduino-esp8266//cores/esp8266/abi.cpp:19:
/mnt/e/Users/stm/Documents/GitHub/Arduino-esp8266//tools/sdk/libc/xtensa-lx106-elf/include/stdio.h:158:18: error: '__gnuc_va_list' has not been declared
 #define __VALIST __gnuc_va_list
                  ^
/mnt/e/Users/stm/Documents/GitHub/Arduino-esp8266//tools/sdk/libc/xtensa-lx106-elf/include/_ansi.h:65:35: note: in definition of macro '_EXFUN'
 #define _EXFUN(name, proto)  name proto
                                   ^
/mnt/e/Users/stm/Documents/GitHub/Arduino-esp8266//tools/sdk/libc/xtensa-lx106-elf/include/stdio.h:184:65: note: in expansion of macro '__VALIST'
 int _EXFUN(vfprintf, (FILE *__restrict, const char *__restrict, __VALIST)
 <more errors follow>

This is the compiler invocation for the first file abi.cpp for the succeeding build from the simple build:

"/mnt/e/Users/stm/Documents/GitHub/Arduino-esp8266//tools/xtensa-lx106-elf/bin/xtensa-lx106-elf-g++" -D__ets__ -DICACHE_FLASH -U__STRICT_ANSI__ "-I/mnt/e/Users/stm/Documents/GitHub/Arduino-esp8266//tools/sdk/include" "-I/mnt/e/Users/stm/Documents/GitHub/Arduino-esp8266//tools/sdk/lwip2/include" "-I/mnt/e/Users/stm/Documents/GitHub/Arduino-esp8266//tools/sdk/libc/xtensa-lx106-elf/include" "-I/tmp/mkESP/radmon_generic/core"  -c -w -Os -g -mlongcalls -mtext-section-literals -fno-exceptions -fno-rtti -falign-functions=4 -std=c++11 -MMD -ffunction-sections -fdata-sections -DF_CPU=80000000L -DLWIP_OPEN_SRC -DTCP_MSS=536   -DARDUINO=10605 -DARDUINO_ESP8266_GENERIC -DARDUINO_ARCH_ESP8266 -DARDUINO_BOARD=\"ESP8266_GENERIC\"   -DESP8266  -I/mnt/e/Users/stm/Documents/GitHub/Arduino-esp8266//cores/esp8266 -I/mnt/e/Users/stm/Documents/GitHub/Arduino-esp8266//variants/generic -I/tmp/mkESP/radmon_generic -I./ -I/mnt/e/Users/stm/Documents/GitHub/Arduino-esp8266//libraries/ArduinoOTA/ -I/mnt/e/Users/stm/Documents/GitHub/Arduino-esp8266//libraries/DNSServer/src/ -I/mnt/e/Users/stm/Documents/GitHub/Arduino-esp8266//libraries/EEPROM/ -I/mnt/e/Users/stm/Documents/GitHub/Arduino-esp8266//libraries/ESP8266AVRISP/src/ -I/mnt/e/Users/stm/Documents/GitHub/Arduino-esp8266//libraries/ESP8266HTTPClient/src/ -I/mnt/e/Users/stm/Documents/GitHub/Arduino-esp8266//libraries/ESP8266HTTPUpdateServer/src/ -I/mnt/e/Users/stm/Documents/GitHub/Arduino-esp8266//libraries/ESP8266LLMNR/ -I/mnt/e/Users/stm/Documents/GitHub/Arduino-esp8266//libraries/ESP8266NetBIOS/ -I/mnt/e/Users/stm/Documents/GitHub/Arduino-esp8266//libraries/ESP8266SSDP/ -I/mnt/e/Users/stm/Documents/GitHub/Arduino-esp8266//libraries/ESP8266WebServer/src/ -I/mnt/e/Users/stm/Documents/GitHub/Arduino-esp8266//libraries/ESP8266WebServer/src/detail/ -I/mnt/e/Users/stm/Documents/GitHub/Arduino-esp8266//libraries/ESP8266WiFi/src/ -I/mnt/e/Users/stm/Documents/GitHub/Arduino-esp8266//libraries/ESP8266WiFi/src/include/ -I/mnt/e/Users/stm/Documents/GitHub/Arduino-esp8266//libraries/ESP8266WiFiMesh/src/ -I/mnt/e/Users/stm/Documents/GitHub/Arduino-esp8266//libraries/ESP8266httpUpdate/src/ -I/mnt/e/Users/stm/Documents/GitHub/Arduino-esp8266//libraries/ESP8266mDNS/ -I/mnt/e/Users/stm/Documents/GitHub/Arduino-esp8266//libraries/Ethernet/examples/udpntpclient_pedantic/ -I/mnt/e/Users/stm/Documents/GitHub/Arduino-esp8266//libraries/Ethernet/src/ -I/mnt/e/Users/stm/Documents/GitHub/Arduino-esp8266//libraries/Ethernet/src/utility/ -I/mnt/e/Users/stm/Documents/GitHub/Arduino-esp8266//libraries/GDBStub/src/ -I/mnt/e/Users/stm/Documents/GitHub/Arduino-esp8266//libraries/GDBStub/src/internal/ -I/mnt/e/Users/stm/Documents/GitHub/Arduino-esp8266//libraries/GDBStub/src/xtensa/ -I/mnt/e/Users/stm/Documents/GitHub/Arduino-esp8266//libraries/GDBStub/src/xtensa/config/ -I/mnt/e/Users/stm/Documents/GitHub/Arduino-esp8266//libraries/Hash/src/ -I/mnt/e/Users/stm/Documents/GitHub/Arduino-esp8266//libraries/Hash/src/sha1/ -I/mnt/e/Users/stm/Documents/GitHub/Arduino-esp8266//libraries/SD/src/ -I/mnt/e/Users/stm/Documents/GitHub/Arduino-esp8266//libraries/SD/src/utility/ -I/mnt/e/Users/stm/Documents/GitHub/Arduino-esp8266//libraries/SPI/ -I/mnt/e/Users/stm/Documents/GitHub/Arduino-esp8266//libraries/SPISlave/src/ -I/mnt/e/Users/stm/Documents/GitHub/Arduino-esp8266//libraries/Servo/src/ -I/mnt/e/Users/stm/Documents/GitHub/Arduino-esp8266//libraries/Servo/src/esp8266/ -I/mnt/e/Users/stm/Documents/GitHub/Arduino-esp8266//libraries/TFT_Touch_Shield_V2/ -I/mnt/e/Users/stm/Documents/GitHub/Arduino-esp8266//libraries/Ticker/ -I/mnt/e/Users/stm/Documents/GitHub/Arduino-esp8266//libraries/Wire/ -I/mnt/e/Users/stm/Documents/GitHub/Arduino-esp8266//libraries/esp8266/src/   /mnt/e/Users/stm/Documents/GitHub/Arduino-esp8266//cores/esp8266/abi.cpp -o /tmp/mkESP/radmon_generic/abi.cpp.o

Note all the include directories in the compiler command line of the failing build which start with -I/mnt/e/Users/stm/Documents/GitHub/Arduino-esp8266/tools/xtensa-lx106-elf which are not there in the succeeding build.

I compared the preprocessor output for abi.cpp for the two builds with the gcc -dD flag. Here are the first lines that differ:

Failing build:

# 37 "/mnt/e/Users/stm/Documents/GitHub/Arduino-esp8266//tools/sdk/libc/xtensa-lx106-elf/include/stdio.h" 2

#define __need___va_list 
# 1 "/mnt/e/Users/stm/Documents/GitHub/Arduino-esp8266/tools/xtensa-lx106-elf/xtensa-lx106-elf/include/c++/4.8.2/tr1/stdarg.h" 1
# 30 "/mnt/e/Users/stm/Documents/GitHub/Arduino-esp8266/tools/xtensa-lx106-elf/xtensa-lx106-elf/include/c++/4.8.2/tr1/stdarg.h"
#define _TR1_STDARG_H 1

Succeeding build:

# 37 "/mnt/e/Users/stm/Documents/GitHub/Arduino-esp8266//tools/sdk/libc/xtensa-lx106-elf/include/stdio.h" 2

#define __need___va_list 
# 1 "/mnt/e/Users/stm/Documents/GitHub/Arduino-esp8266/tools/xtensa-lx106-elf/lib/gcc/xtensa-lx106-elf/4.8.2/include/stdarg.h" 1 3 4
# 34 "/mnt/e/Users/stm/Documents/GitHub/Arduino-esp8266/tools/xtensa-lx106-elf/lib/gcc/xtensa-lx106-elf/4.8.2/include/stdarg.h" 3 4
#undef __need___va_list

So it looks to me like the stdarg.h header form the .../tools/xtensa-lx106-elf/xtensa-lx106-elf/include/c++/4.8.2/tr1 directory is spoiling the compilation.

So the question is, why are all the -I include directives for the .../tools/xtensa-lx106-elf/... directories present, and should they be actually present?

Add a way to exclude directories

Any test files that reside with your included directories (USER_INC) or source directories (USER_SRC) get automatically grabbed when building. I have files where I mock the EEPROM.h or specify test definitions for example that I certainly don't want the makefile to grab just because they sit inside my project directory under the folder test/. Today I have to modify the makefile or move all testing away from my projects. A supported way to have a list of exclusions would be a nice to have!

ESP32 support

Hi folks, any idea if this repo is also going to support ESP32-Arduino in the (near) future? I'd be very much looking forward to that. Thanks for all the work! Tijn

Compiling libs only once

We will use different makefiles to compile different sketches/projects all using the same esp core and arduino libraries. It might be that different projects are compiled in parallel.

Is is possible to use precompiled libraries that are shared for all makefiles/sketches to speed up the compile process and reduce the needed CPU power?

Thanks
Johannes

auto include pins_arduino.h

Hi,

I wonder if there is/will be support for automatic inclusion of the pins headers, maybe specifying the variant.

../variants/d1_mini/pins_arduino.h
../variants/wifinfo/pins_arduino.h
../variants/nodemcu/pins_arduino.h
../variants/d1/pins_arduino.h

xtensa-lx106-elf-g++: not found

โžœ  git:(functional) โœ— make -f makeEspArduino.mk ESP_ROOT=~/Documents/github/esp8266/Arduino SKETCH=src/main.cpp   
debug.cpp
WMath.cpp
core_esp8266_wiring_analog.c
/bin/sh: 1: ~/Documents/github/esp8266/Arduino/tools/xtensa-lx106-elf/bin/xtensa-lx106-elf-g++: not found
HardwareSerial.cpp
makeEspArduino.mk:180: recipe for target '/tmp/mkESP/main_generic/debug.cpp.o' failed
make: *** [/tmp/mkESP/main_generic/debug.cpp.o] Error 127
make: *** Waiting for unfinished jobs....
/bin/sh: 1: ~/Documents/github/esp8266/Arduino/tools/xtensa-lx106-elf/bin/xtensa-lx106-elf-g++: not found
makeEspArduino.mk:180: recipe for target '/tmp/mkESP/main_generic/WMath.cpp.o' failed
make: *** [/tmp/mkESP/main_generic/WMath.cpp.o] Error 127
/bin/sh: 1: ~/Documents/github/esp8266/Arduino/tools/xtensa-lx106-elf/bin/xtensa-lx106-elf-gcc: not found
makeEspArduino.mk:188: recipe for target '/tmp/mkESP/main_generic/core_esp8266_wiring_analog.c.o' failed
make: *** [/tmp/mkESP/main_generic/core_esp8266_wiring_analog.c.o] Error 127
core_esp8266_timer.c
/bin/sh: 1: ~/Documents/github/esp8266/Arduino/tools/xtensa-lx106-elf/bin/xtensa-lx106-elf-g++: not found
makeEspArduino.mk:180: recipe for target '/tmp/mkESP/main_generic/HardwareSerial.cpp.o' failed
make: *** [/tmp/mkESP/main_generic/HardwareSerial.cpp.o] Error 127
/bin/sh: 1: ~/Documents/github/esp8266/Arduino/tools/xtensa-lx106-elf/bin/xtensa-lx106-elf-gcc: not found
makeEspArduino.mk:188: recipe for target '/tmp/mkESP/main_generic/core_esp8266_timer.c.o' failed
make: *** [/tmp/mkESP/main_generic/core_esp8266_timer.c.o] Error 127
โžœ  git:(functional) โœ— ~/Documents/github/esp8266/Arduino/tools/xtensa-lx106-elf/bin/xtensa-lx106-elf-g++ --version
xtensa-lx106-elf-g++ (crosstool-NG 1.20.0) 4.8.2
Copyright (C) 2013 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

I haven't spent any time debugging this. I see a "not found" and then it gives me the path to what it couldn't find. I set it up following the instructions in the readme and all of the steps seemed pretty clear.

I just tried it on a small cpp file to see what happens.

โžœ  ~ make -f ~/Documents/github/plerub/makeEspArduino/makeEspArduino.mk ESP_ROOT=~/Documents/github/esp8266/Arduino SKETCH=make-unique-test.cpp    

find: โ€˜./.cache/dconfโ€™: Permission denied
find: โ€˜./.cache/dconfโ€™: Permission denied
find: โ€˜./.cache/dconfโ€™: Permission denied
find: โ€˜./.cache/dconfโ€™: Permission denied
core_esp8266_wiring_analog.c
HardwareSerial.cpp
/bin/sh: 1: ~/Documents/github/esp8266/Arduino/tools/xtensa-lx106-elf/bin/xtensa-lx106-elf-gcc: not found
/home/richie/Documents/github/plerub/makeEspArduino/makeEspArduino.mk:188: recipe for target '/tmp/mkESP/make-unique-test_generic/core_esp8266_wiring_analog.c.o' failed
make: *** [/tmp/mkESP/make-unique-test_generic/core_esp8266_wiring_analog.c.o] Error 127
make: *** Waiting for unfinished jobs....
/bin/sh: 1: ~/Documents/github/esp8266/Arduino/tools/xtensa-lx106-elf/bin/xtensa-lx106-elf-g++: not found
/home/richie/Documents/github/plerub/makeEspArduino/makeEspArduino.mk:180: recipe for target '/tmp/mkESP/make-unique-test_generic/HardwareSerial.cpp.o' failed
make: *** [/tmp/mkESP/make-unique-test_generic/HardwareSerial.cpp.o] Error 127

The file that I was trying to compile was just this.

#include <memory>
#include <string>

template <typename T>
class Nom
{
public:
    Nom(T d) : data(d) {};
    T data;
};

int main()
{
    auto value = std::make_unique<Nom<int>>(6);
    return  #0;
}

I have been using platformio but I suddenly want to use std::make_unique and I haven't figured out how to build with c++14. I'll want to upload this code to an esp8266. I'm running Ubuntu 16.04.

โžœ  ~ uname -a
Linux chuwi 4.8.0-41-generic #44~16.04.1-Ubuntu SMP Fri Mar 3 17:11:16 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux

Thanks for the work! I hope I can figure out how to build with c++14.

No more "foo as not declared in this scope"

Basically in Arduino IDE you can call a function and declare it AFTER the first one.
This make file does not do that, witch I think causes an error " 'STAILQ_NEXT' was not declared in this scope" when I flash PainlessMesh. The exact same sketch and lib work with the Arduino IDE.

This is the sketch :
https://gitlab.com/BlackEdder/painlessMesh/blob/master/examples/startHere/startHere.ino
NOTE: using the .ino above with the makefile I also get
'receivedCallback' was not declared in this scope 'newConnectionCallback' was not declared in this scope etc. witch are solved by simply moving the setup and loop functions at the end of the file (error does not apear in Arduino IDE).

I think there is also a problem in the "automatic" library detection, note how I have to explicitly include

Command and output :

make -f /PATH1/deploy-libs/makeEspArduino/makeEspArduino.mk ESP_ROOT=/PATH1/deploy-libs/esp8266 
LIBS="/PATH1/deploy-libs/esp8266/libraries /PATH1/sketch-libs "  BOARD=d1_mini   -L  
flash  SKETCH=/PATH2/mesh/mesh.ino


* Build state has changed, doing a full rebuild *
core_esp8266_phy.c
abi.cpp
base64.cpp
cbuf.cpp
cont.S
cont_util.c
core_esp8266_eboot_command.c
core_esp8266_flash_utils.c
core_esp8266_i2s.c
core_esp8266_noniso.c
core_esp8266_main.cpp
pgmspace.cpp
Schedule.cpp
Print.cpp
spiffs_cache.c
spiffs_gc.c
spiffs_nucleus.c
spiffs_check.c
spiffs_hydrogen.c
spiffs_api.cpp
spiffs_hal.cpp
StreamString.cpp
Stream.cpp
time.c
Tone.cpp
uart.c
umm_malloc.c
Updater.cpp
core_esp8266_si2c.c
core_esp8266_postmortem.c
core_esp8266_timer.c
core_esp8266_wiring.c
WMath.cpp
WString.cpp
core_esp8266_wiring_analog.c
core_esp8266_wiring_digital.c
core_esp8266_wiring_pulse.c
core_esp8266_wiring_shift.c
core_esp8266_wiring_pwm.c
FS.cpp
debug.cpp
heap.c
HardwareSerial.cpp
Esp.cpp
IPAddress.cpp
cencode.c
cdecode.c
libc_replacements.c
MD5Builder.cpp
mesh.ino
ArduinoOTA.cpp
DNSServer.cpp
EEPROM.cpp
ESP8266AVRISP.cpp
ESP8266HTTPClient.cpp
ESP8266HTTPUpdateServer.cpp
ESP8266httpUpdate.cpp
ESP8266LLMNR.cpp
ESP8266mDNS.cpp
ESP8266NetBIOS.cpp
ESP8266SSDP.cpp
ESP8266WebServer.cpp
Parsing.cpp
ESP8266WiFi.cpp
ESP8266WiFiAP.cpp
ESP8266WiFiGeneric.cpp
ESP8266WiFiMulti.cpp
ESP8266WiFiScan.cpp
ESP8266WiFiSTA.cpp
WiFiClient.cpp
WiFiClientSecure.cpp
WiFiServer.cpp
WiFiUdp.cpp
ESP8266WiFiMesh.cpp
Dns.cpp
Dhcp.cpp
Ethernet.cpp
EthernetClient.cpp
EthernetServer.cpp
EthernetUdp.cpp
socket.cpp
w5100.cpp
gdbstub-entry.S
gdbstub.c
Hash.cpp
sha1.c
File.cpp
SD.cpp
Sd2Card.cpp
SdFile.cpp
SdVolume.cpp
Servo.cpp
SPI.cpp
hspi_slave.c
SPISlave.cpp
font.c
TFTv2.cpp
Ticker.cpp
Adafruit_BMP085.cpp
DHT.cpp
Wire.cpp
DHT_U.cpp
painlessMesh.cpp
painlessMeshAP.cpp
painlessMeshComm.cpp
painlessMeshConnection.cpp
painlessMeshDebug.cpp
painlessMeshSync.cpp
painlessMeshSTA.cpp
/PATH1/sketch-libs/PainlessMesh/src/painlessMeshSTA.cpp: In member function 'void StationScan::scanComplete(bss_info*)':
/PATH1/sketch-libs/PainlessMesh/src/painlessMeshSTA.cpp:185:44: error: 'STAILQ_NEXT' was not declared in this scope
         bssInfo = STAILQ_NEXT(bssInfo, next);
                                            ^
Creating core archive
make: *** [/tmp/mkESP/mesh_d1_mini/painlessMeshSTA.cpp.o] Error 1
/PATH1/deploy-libs/makeEspArduino/makeEspArduino.mk:198: recipe for target '/tmp/mkESP/mesh_d1_mini/painlessMeshSTA.cpp.o' failed
make: *** Waiting for unfinished jobs....

collect2: error: ld returned 1 exit status

I am trying to compile the simplest ino file

#include <Arduino.h>
void setup() {
    pinMode(D0, OUTPUT);
}
void loop() {
}

but fails with the error shown in the subject and,

/tmp/test/obj/core.ar(core_esp8266_main.cpp.o): In function `loop_wrapper':
/home/leonardo/esp8266/cores/esp8266/core_esp8266_main.cpp:110: undefined reference to `printf'

I tried adding -ld as mentioned in other cross-compile forums, but it doesn't help

can anybody help? Ideas?

Why is $(HOME)/Arduino/libraries not searched automatically?

The Libs that are installed by arduino(linux,1.8.2) -> sketch -> include library -> manage libraries are not found automatically.

workaround:

+ESP_LIBS2 = $(HOME)/Arduino/libraries

  • LIBS += $(shell perl -e 'use File::Find;$$d = shift;while (<>) {$$f{"$$1"} = 1 if /^\s*#include\s+<"/;}find(sub {print $$File::Find::dir," " if $$f{$$_}}, $$d);' $(ESP_LIBS2) $(SKETCH))

compile of Blynk example fail

compile of ESP8266_Standalone sample from Blynk lib fail:

zero@fight ~/src/arduino/esp8266/ESP8266_Standalone $ make -f makeEspArduino.mk
main.cpp
In file included from /home/zero/src/arduino/libraries/Blynk/linux/main.cpp:17:0:
/home/zero/src/arduino/libraries/Blynk/linux/BlynkSocket.h:13:24: fatal error: sys/socket.h: No such file or directory
#include <sys/socket.h>

Cannot open linker script file

The output :

echo Linking /tmp/mkESP/esp_ws28x_web_d1_mini_lite/esp_ws28x_web.bin
Linking /tmp/mkESP/esp_ws28x_web_d1_mini_lite/esp_ws28x_web.bin
echo "  Versions: 2435911-dirty, 2.4.0-rc2-47-g58937dd"
  Versions: 2435911-dirty, 2.4.0-rc2-47-g58937dd
echo    '#include <buildinfo.h>' >/tmp/mkESP/esp_ws28x_web_d1_mini_lite/buildinfo.c++
echo '_tBuildInfo _BuildInfo = {"2017-12-15","14:50:44","2435911-dirty","2.4.0-rc2-47-g58937dd"};' >>/tmp/mkESP/esp_ws28x_web_d1_mini_lite/buildinfo.c++
"/home/amo/mybroj/3rd-party/nodes-mybroj/deploy-libs/esp8266/tools/xtensa-lx106-elf/bin/xtensa-lx106-elf-g++" -D__ets__ -DICACHE_FLASH -U__STRICT_ANSI__ "-I/home/amo/mybroj/3rd-party/nodes-mybroj/deploy-libs/esp8266/tools/sdk/include" "-I/home/amo/mybroj/3rd-party/nodes-mybroj/deploy-libs/esp8266/tools/sdk/lwip2/include" "-I/home/amo/mybroj/3rd-party/nodes-mybroj/deploy-libs/esp8266/tools/sdk/libc/xtensa-lx106-elf/include" "-I/tmp/mkESP/esp_ws28x_web_d1_mini_lite/core"  -c -w -Os -g -mlongcalls -mtext-section-literals -fno-exceptions -fno-rtti -falign-functions=4 -std=c++11 -MMD -ffunction-sections -fdata-sections -DF_CPU=80000000L -DLWIP_OPEN_SRC   -DARDUINO=10605 -DARDUINO_ESP8266_WEMOS_D1MINILITE -DARDUINO_ARCH_ESP8266 -DARDUINO_BOARD=\"ESP8266_WEMOS_D1MINILITE\"  -DESP8266  -I/home/amo/mybroj/3rd-party/nodes-mybroj/deploy-libs/esp8266/cores/esp8266 -I/home/amo/mybroj/3rd-party/nodes-mybroj/deploy-libs/esp8266/variants/d1_mini -I/tmp/mkESP/esp_ws28x_web_d1_mini_lite  /tmp/mkESP/esp_ws28x_web_d1_mini_lite/buildinfo.c++ -o /tmp/mkESP/esp_ws28x_web_d1_mini_lite/buildinfo.c++.o
"/home/amo/mybroj/3rd-party/nodes-mybroj/deploy-libs/esp8266/tools/xtensa-lx106-elf/bin/xtensa-lx106-elf-gcc" -g -w -Os -nostdlib -Wl,--no-check-sections -u call_user_start -u _printf_float -u _scanf_float -Wl,-static "-L/home/amo/mybroj/3rd-party/nodes-mybroj/deploy-libs/esp8266/tools/sdk/lib" "-L/home/amo/mybroj/3rd-party/nodes-mybroj/deploy-libs/esp8266/tools/sdk/ld" "-L/home/amo/mybroj/3rd-party/nodes-mybroj/deploy-libs/esp8266/tools/sdk/libc/xtensa-lx106-elf/lib" "-T" -Wl,--gc-sections -Wl,-wrap,system_restart_local -Wl,-wrap,spi_flash_read  -o "/tmp/mkESP/esp_ws28x_web_d1_mini_lite/esp_ws28x_web.elf" -Wl,--start-group /tmp/mkESP/esp_ws28x_web_d1_mini_lite/arduino.ar /tmp/mkESP/esp_ws28x_web_d1_mini_lite/esp_ws28x_web_.cpp.o /tmp/mkESP/esp_ws28x_web_d1_mini_lite/buildinfo.c++.o "/tmp/mkESP/esp_ws28x_web_d1_mini_lite/arduino.ar" -lhal -lphy -lpp -lnet80211 -llwip2 -lwpa -lcrypto -lmain -lwps -laxtls -lespnow -lsmartconfig -lairkiss -lmesh -lwpa2 -lstdc++ -lm -lc -lgcc -Wl,--end-group  "-L/tmp/mkESP/esp_ws28x_web_d1_mini_lite"
/home/amo/mybroj/3rd-party/nodes-mybroj/deploy-libs/esp8266/tools/xtensa-lx106-elf/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/../../../../xtensa-lx106-elf/bin/ld: cannot open linker script file -Wl,--gc-sections: No such file or directory
collect2: error: ld returned 1 exit status
/home/amo/mybroj/3rd-party/nodes-mybroj/deploy-libs/makeEspArduino/makeEspArduino.mk:239: recipe for target '/tmp/mkESP/esp_ws28x_web_d1_mini_lite/esp_ws28x_web.bin' failed
make: *** [/tmp/mkESP/esp_ws28x_web_d1_mini_lite/esp_ws28x_web.bin] Error 1

The command:

cd
"/home/amo/mybroj/nodes-mybroj/sketches/esp_ws28x_web"
&&
make
-f
/home/amo/mybroj/3rd-party/nodes-mybroj/deploy-libs/makeEspArduino/makeEspArduino.mk
BOARD="d1_mini_lite"
FLASH_DEF="1M"
UPLOAD_PORT="/dev/ttyUSB1"
SKETCH="/home/amo/mybroj/nodes-mybroj/sketches/esp_ws28x_web/esp_ws28x_web.ino"
ESP_ROOT="/home/amo/mybroj/3rd-party/nodes-mybroj/deploy-libs/esp8266"
VERBOSE=1
flash

Correct usage about including libraries.

I do something like this:
Open my cygwin terminal ( I use win64 ) and input:

cd ~
git clone https://github.com/plerup/makeEspArduino.git
git clone https://github.com/eeyrw/LcdTcp # It's my arduino project.
alias espmake="make -f ~/makeEspArduino/makeEspArduino.mk"
cd LcdTcp
espmake

Then...

which: no esptool.py in (/usr/local/bin:/usr/bin:/cygdrive/f/Perl64/site/bin:/cygdrive/f/Perl64/bin:/cygdrive/f/Windows/system32:/cygdrive/f/Windows:/cygdrive/f/Windows/System32/Wbem:/cygdrive/f/Windows/System32/WindowsPowerShell/v1.0:/cygdrive/f/Program Files (x86)/NVIDIA Corporation/PhysX/Common:/cygdrive/f/Program Files (x86)/GTK2-Runtime/bin:/cygdrive/f/WINDOWS/system32:/cygdrive/f/WINDOWS:/cygdrive/f/WINDOWS/System32/Wbem:/cygdrive/f/WINDOWS/System32/WindowsPowerShell/v1.0:/cygdrive/e/Git/cmd:/cygdrive/f/mingw64/bin:/cygdrive/f/Program Files/TortoiseGit/bin:/cygdrive/e/GNU Tools ARM Embedded/7 2017-q4-major/bin:/cygdrive/f/Users/yuan/AppData/Local/Microsoft/WindowsApps:/cygdrive/e/SDCC/bin:/cygdrive/e/CMake/bin:/cygdrive/d/Microsoft VS Code/bin:/usr/bin:/cygdrive/d/stm8flash:/cygdrive/e/avra-1.3.0/src)
which: no esptool.py in (/usr/local/bin:/usr/bin:/cygdrive/f/Perl64/site/bin:/cygdrive/f/Perl64/bin:/cygdrive/f/Windows/system32:/cygdrive/f/Windows:/cygdrive/f/Windows/System32/Wbem:/cygdrive/f/Windows/System32/WindowsPowerShell/v1.0:/cygdrive/f/Program Files (x86)/NVIDIA Corporation/PhysX/Common:/cygdrive/f/Program Files (x86)/GTK2-Runtime/bin:/cygdrive/f/WINDOWS/system32:/cygdrive/f/WINDOWS:/cygdrive/f/WINDOWS/System32/Wbem:/cygdrive/f/WINDOWS/System32/WindowsPowerShell/v1.0:/cygdrive/e/Git/cmd:/cygdrive/f/mingw64/bin:/cygdrive/f/Program Files/TortoiseGit/bin:/cygdrive/e/GNU Tools ARM Embedded/7 2017-q4-major/bin:/cygdrive/f/Users/yuan/AppData/Local/Microsoft/WindowsApps:/cygdrive/e/SDCC/bin:/cygdrive/e/CMake/bin:/cygdrive/d/Microsoft VS Code/bin:/usr/bin:/cygdrive/d/stm8flash:/cygdrive/e/avra-1.3.0/src)
abi.cpp
base64.cpp
cbuf.cpp
cont.S
cont_util.c
core_esp8266_eboot_command.c
core_esp8266_flash_utils.c
core_esp8266_i2s.c
core_esp8266_main.cpp
core_esp8266_noniso.c
core_esp8266_phy.c
core_esp8266_postmortem.c
core_esp8266_si2c.c
core_esp8266_timer.c
core_esp8266_wiring.c
core_esp8266_wiring_analog.c
core_esp8266_wiring_digital.c
core_esp8266_wiring_pulse.c
core_esp8266_wiring_pwm.c
core_esp8266_wiring_shift.c
debug.cpp
Esp.cpp
FS.cpp
FunctionalInterrupt.cpp
HardwareSerial.cpp
heap.c
IPAddress.cpp
cdecode.c
cencode.c
libc_replacements.c
MD5Builder.cpp
pgmspace.cpp
Print.cpp
Schedule.cpp
sntp-lwip2.c
spiffs_cache.c
spiffs_check.c
spiffs_gc.c
spiffs_hydrogen.c
spiffs_nucleus.c
spiffs_api.cpp
spiffs_hal.cpp
Stream.cpp
StreamString.cpp
time.c
Tone.cpp
uart.c
umm_malloc.c
Updater.cpp
WMath.cpp
WString.cpp
Creating core archive
LcdTcp.ino
In file included from LcdTcp.ino:2:0:
LcdTcp.h:11:25: fatal error: ESP8266WiFi.h: No such file or directory
 #include <ESP8266WiFi.h>
                         ^
compilation terminated.
make: *** [/home/yuan/makeEspArduino/makeEspArduino.mk:220๏ผšF:/cygwin64/tmp/mkESP/LcdTcp_generic/LcdTcp_.cpp.o] error 1

It seems that library ESP8266WiFi should be included manually ?
How can I make it work ?
---------------Half an hour later------------------
I create a config.mk like this:

THIS_DIR := $(realpath $(dir $(realpath $(lastword $(MAKEFILE_LIST)))))
ROOT := $(THIS_DIR)/..
LIBS = $(ESP_LIBS)/SPI \
  $(ESP_LIBS)/Wire \
  $(ESP_LIBS)/ESP8266WiFi \
UPLOAD_SPEED = 115200

And copy my libraries dir to my project root. But it get even worse...

$ espmake
which: no esptool.py in (/usr/local/bin:/usr/bin:/cygdrive/f/Perl64/site/bin:/cygdrive/f/Perl64/bin:/cygdrive/f/Windows/system32:/cygdrive/f/Windows:/cygdrive/f/Windows/System32/Wbem:/cygdrive/f/Windows/System32/WindowsPowerShell/v1.0:/cygdrive/f/Program Files (x86)/NVIDIA Corporation/PhysX/Common:/cygdrive/f/Program Files (x86)/GTK2-Runtime/bin:/cygdrive/f/WINDOWS/system32:/cygdrive/f/WINDOWS:/cygdrive/f/WINDOWS/System32/Wbem:/cygdrive/f/WINDOWS/System32/WindowsPowerShell/v1.0:/cygdrive/e/Git/cmd:/cygdrive/f/mingw64/bin:/cygdrive/f/Program Files/TortoiseGit/bin:/cygdrive/e/GNU Tools ARM Embedded/7 2017-q4-major/bin:/cygdrive/f/Users/yuan/AppData/Local/Microsoft/WindowsApps:/cygdrive/e/SDCC/bin:/cygdrive/e/CMake/bin:/cygdrive/d/Microsoft VS Code/bin:/usr/bin:/cygdrive/d/stm8flash:/cygdrive/e/avra-1.3.0/src)
which: no esptool.py in (/usr/local/bin:/usr/bin:/cygdrive/f/Perl64/site/bin:/cygdrive/f/Perl64/bin:/cygdrive/f/Windows/system32:/cygdrive/f/Windows:/cygdrive/f/Windows/System32/Wbem:/cygdrive/f/Windows/System32/WindowsPowerShell/v1.0:/cygdrive/f/Program Files (x86)/NVIDIA Corporation/PhysX/Common:/cygdrive/f/Program Files (x86)/GTK2-Runtime/bin:/cygdrive/f/WINDOWS/system32:/cygdrive/f/WINDOWS:/cygdrive/f/WINDOWS/System32/Wbem:/cygdrive/f/WINDOWS/System32/WindowsPowerShell/v1.0:/cygdrive/e/Git/cmd:/cygdrive/f/mingw64/bin:/cygdrive/f/Program Files/TortoiseGit/bin:/cygdrive/e/GNU Tools ARM Embedded/7 2017-q4-major/bin:/cygdrive/f/Users/yuan/AppData/Local/Microsoft/WindowsApps:/cygdrive/e/SDCC/bin:/cygdrive/e/CMake/bin:/cygdrive/d/Microsoft VS Code/bin:/usr/bin:/cygdrive/d/stm8flash:/cygdrive/e/avra-1.3.0/src)
abi.cpp
base64.cpp
cbuf.cpp
cont.S
cont_util.c
core_esp8266_eboot_command.c
core_esp8266_flash_utils.c
core_esp8266_i2s.c
core_esp8266_main.cpp
core_esp8266_noniso.c
core_esp8266_phy.c
core_esp8266_postmortem.c
core_esp8266_si2c.c
core_esp8266_timer.c
core_esp8266_wiring.c
core_esp8266_wiring_analog.c
core_esp8266_wiring_digital.c
core_esp8266_wiring_pulse.c
core_esp8266_wiring_pwm.c
core_esp8266_wiring_shift.c
debug.cpp
Esp.cpp
FS.cpp
FunctionalInterrupt.cpp
HardwareSerial.cpp
heap.c
IPAddress.cpp
cdecode.c
cencode.c
libc_replacements.c
MD5Builder.cpp
pgmspace.cpp
Print.cpp
Schedule.cpp
sntp-lwip2.c
spiffs_cache.c
spiffs_check.c
spiffs_gc.c
spiffs_hydrogen.c
spiffs_nucleus.c
spiffs_api.cpp
spiffs_hal.cpp
Stream.cpp
StreamString.cpp
time.c
Tone.cpp
uart.c
umm_malloc.c
Updater.cpp
WMath.cpp
WString.cpp
Creating core archive
LcdTcp.ino
CmdProc.cpp
LcdInterface.cpp
LCD_I2C.cpp
WiFiManager.cpp
LiquidCrystal_I2C.cpp
TcpServer.cpp
WifiConnection.cpp
SPI.cpp
Wire.cpp
ESP8266WiFi.cpp
ESP8266WiFiAP.cpp
ESP8266WiFiGeneric.cpp
ESP8266WiFiMulti.cpp
ESP8266WiFiScan.cpp
ESP8266WiFiSTA.cpp
WiFiClient.cpp
WiFiClientSecure.cpp
WiFiServer.cpp
WiFiUdp.cpp
Linking F:/cygwin64/tmp/mkESP/LcdTcp_generic/LcdTcp.bin
  Versions: Unknown, 2.4.0
F:/cygwin64/tmp/mkESP/LcdTcp_generic/WiFiManager.cpp.o:(.text._ZN11WiFiManager10handleInfoEv+0x74): undefined reference to `ESP8266WebServer::sendHeader(String const&, String const&, bool)'
F:/cygwin64/tmp/mkESP/LcdTcp_generic/WiFiManager.cpp.o:(.text._ZN11WiFiManager10handleInfoEv+0x78): undefined reference to `ESP8266WebServer::send(int, char const*, String const&)'
F:/cygwin64/tmp/mkESP/LcdTcp_generic/WiFiManager.cpp.o: In function `WiFiManager::handleInfo()':
F:/cygwin64/home/yuan/LcdTcp/libraries/WiFiManager/WiFiManager.cpp:759: undefined reference to `ESP8266WebServer::sendHeader(String const&, String const&, bool)'
F:/cygwin64/tmp/mkESP/LcdTcp_generic/WiFiManager.cpp.o: In function `String::operator+=(__FlashStringHelper const*)':
F:/cygwin64/home/yuan/LcdTcp/libraries/WiFiManager/WiFiManager.cpp:759: undefined reference to `ESP8266WebServer::send(int, char const*, String const&)'
F:/cygwin64/home/yuan/LcdTcp/libraries/WiFiManager/WiFiManager.cpp:759: undefined reference to `ESP8266WebServer::sendHeader(String const&, String const&, bool)'
F:/cygwin64/tmp/mkESP/LcdTcp_generic/WiFiManager.cpp.o: In function `String::operator+=(String const&)':
F:/cygwin64/home/yuan/LcdTcp/libraries/WiFiManager/WiFiManager.cpp:759: undefined reference to `ESP8266WebServer::send(int, char const*, String const&)'
F:/cygwin64/tmp/mkESP/LcdTcp_generic/WiFiManager.cpp.o: In function `DEBUG_WM<String>':
F:/cygwin64/home/yuan/LcdTcp/libraries/WiFiManager/WiFiManager.cpp:759: undefined reference to `ESP8266WebServer::~ESP8266WebServer()'
F:/cygwin64/tmp/mkESP/LcdTcp_generic/WiFiManager.cpp.o: In function `std::default_delete<ESP8266WebServer>::operator()(ESP8266WebServer*) const':
F:/cygwin64/home/yuan/LcdTcp/libraries/WiFiManager/WiFiManager.cpp:759: undefined reference to `ESP8266WebServer::~ESP8266WebServer()'
F:/cygwin64/tmp/mkESP/LcdTcp_generic/WiFiManager.cpp.o:(.text._ZN11WiFiManager14handleWifiSaveEv+0x38): undefined reference to `ESP8266WebServer::arg(String)'
F:/cygwin64/tmp/mkESP/LcdTcp_generic/WiFiManager.cpp.o:(.text._ZN11WiFiManager14handleWifiSaveEv+0x68): undefined reference to `ESP8266WebServer::arg(String)'
F:/cygwin64/tmp/mkESP/LcdTcp_generic/WiFiManager.cpp.o:(.text._ZN11WiFiManager14handleWifiSaveEv+0x90): undefined reference to `ESP8266WebServer::arg(String)'
F:/cygwin64/tmp/mkESP/LcdTcp_generic/WiFiManager.cpp.o:(.text._ZN11WiFiManager14handleWifiSaveEv+0xc7): undefined reference to `ESP8266WebServer::arg(String)'
F:/cygwin64/tmp/mkESP/LcdTcp_generic/WiFiManager.cpp.o:(.text._ZN11WiFiManager14handleWifiSaveEv+0x144): undefined reference to `ESP8266WebServer::arg(String)'
F:/cygwin64/tmp/mkESP/LcdTcp_generic/WiFiManager.cpp.o:(.text._ZN11WiFiManager14handleWifiSaveEv+0x17b): more undefined references to `ESP8266WebServer::arg(String)' follow
F:/cygwin64/tmp/mkESP/LcdTcp_generic/WiFiManager.cpp.o: In function `WiFiManager::handleWifiSave()':
F:/cygwin64/home/yuan/LcdTcp/libraries/WiFiManager/WiFiManager.cpp:759: undefined reference to `ESP8266WebServer::sendHeader(String const&, String const&, bool)'
F:/cygwin64/home/yuan/LcdTcp/libraries/WiFiManager/WiFiManager.cpp:759: undefined reference to `ESP8266WebServer::send(int, char const*, String const&)'
F:/cygwin64/tmp/mkESP/LcdTcp_generic/WiFiManager.cpp.o: In function `String::operator+=(__FlashStringHelper const*)':
F:/cygwin64/home/yuan/LcdTcp/libraries/WiFiManager/WiFiManager.cpp:759: undefined reference to `ESP8266WebServer::sendHeader(String const&, String const&, bool)'
F:/cygwin64/tmp/mkESP/LcdTcp_generic/WiFiManager.cpp.o: In function `WiFiManager::handleWifi(unsigned char)':
F:/cygwin64/home/yuan/LcdTcp/libraries/WiFiManager/WiFiManager.cpp:759: undefined reference to `ESP8266WebServer::send(int, char const*, String const&)'
F:/cygwin64/home/yuan/LcdTcp/libraries/WiFiManager/WiFiManager.cpp:759: undefined reference to `DNSServer::DNSServer()'
F:/cygwin64/home/yuan/LcdTcp/libraries/WiFiManager/WiFiManager.cpp:759: undefined reference to `ESP8266WebServer::ESP8266WebServer(int)'
F:/cygwin64/home/yuan/LcdTcp/libraries/WiFiManager/WiFiManager.cpp:759: undefined reference to `DNSServer::setErrorReplyCode(DNSReplyCode const&)'
F:/cygwin64/home/yuan/LcdTcp/libraries/WiFiManager/WiFiManager.cpp:759: undefined reference to `DNSServer::start(unsigned short const&, String const&, IPAddress const&)'
F:/cygwin64/home/yuan/LcdTcp/libraries/WiFiManager/WiFiManager.cpp:759: undefined reference to `ESP8266WebServer::on(String const&, std::function<void ()>)'
F:/cygwin64/home/yuan/LcdTcp/libraries/WiFiManager/WiFiManager.cpp:759: undefined reference to `ESP8266WebServer::onNotFound(std::function<void ()>)'
F:/cygwin64/home/yuan/LcdTcp/libraries/WiFiManager/WiFiManager.cpp:759: undefined reference to `ESP8266WebServer::begin()'
F:/cygwin64/home/yuan/LcdTcp/libraries/WiFiManager/WiFiManager.cpp:759: undefined reference to `DNSServer::DNSServer()'
F:/cygwin64/home/yuan/LcdTcp/libraries/WiFiManager/WiFiManager.cpp:759: undefined reference to `ESP8266WebServer::ESP8266WebServer(int)'
F:/cygwin64/tmp/mkESP/LcdTcp_generic/WiFiManager.cpp.o: In function `String::operator+=(String const&)':
F:/cygwin64/home/yuan/LcdTcp/libraries/WiFiManager/WiFiManager.cpp:759: undefined reference to `DNSServer::setErrorReplyCode(DNSReplyCode const&)'
F:/cygwin64/tmp/mkESP/LcdTcp_generic/WiFiManager.cpp.o: In function `std::unique_ptr<DNSServer, std::default_delete<DNSServer> >::reset(DNSServer*)':
F:/cygwin64/home/yuan/LcdTcp/libraries/WiFiManager/WiFiManager.cpp:759: undefined reference to `DNSServer::start(unsigned short const&, String const&, IPAddress const&)'
F:/cygwin64/tmp/mkESP/LcdTcp_generic/WiFiManager.cpp.o: In function `WiFiManager::setupConfigPortal()':
F:/cygwin64/home/yuan/LcdTcp/libraries/WiFiManager/WiFiManager.cpp:759: undefined reference to `ESP8266WebServer::on(String const&, std::function<void ()>)'
F:/cygwin64/home/yuan/LcdTcp/libraries/WiFiManager/WiFiManager.cpp:759: undefined reference to `ESP8266WebServer::on(String const&, std::function<void ()>)'
F:/cygwin64/tmp/mkESP/LcdTcp_generic/WiFiManager.cpp.o: In function `IPAddress':
F:/cygwin64/home/yuan/LcdTcp/libraries/WiFiManager/WiFiManager.cpp:759: undefined reference to `ESP8266WebServer::on(String const&, std::function<void ()>)'
F:/cygwin64/tmp/mkESP/LcdTcp_generic/WiFiManager.cpp.o: In function `WiFiManager::setupConfigPortal()':
F:/cygwin64/home/yuan/LcdTcp/libraries/WiFiManager/WiFiManager.cpp:759: undefined reference to `ESP8266WebServer::on(String const&, std::function<void ()>)'
F:/cygwin64/home/yuan/LcdTcp/libraries/WiFiManager/WiFiManager.cpp:759: undefined reference to `ESP8266WebServer::on(String const&, std::function<void ()>)'
F:/cygwin64/tmp/mkESP/LcdTcp_generic/WiFiManager.cpp.o:F:/cygwin64/home/yuan/LcdTcp/libraries/WiFiManager/WiFiManager.cpp:759: more undefined references to `ESP8266WebServer::on(String const&, std::function<void ()>)' follow
F:/cygwin64/tmp/mkESP/LcdTcp_generic/WiFiManager.cpp.o: In function `_Head_base<bool, void>':
F:/cygwin64/home/yuan/LcdTcp/libraries/WiFiManager/WiFiManager.cpp:759: undefined reference to `ESP8266WebServer::onNotFound(std::function<void ()>)'
F:/cygwin64/tmp/mkESP/LcdTcp_generic/WiFiManager.cpp.o: In function `bind<void (WiFiManager::*)(unsigned char), WiFiManager* const, bool>':
F:/cygwin64/home/yuan/LcdTcp/libraries/WiFiManager/WiFiManager.cpp:759: undefined reference to `ESP8266WebServer::begin()'
F:/cygwin64/tmp/mkESP/LcdTcp_generic/WiFiManager.cpp.o: In function `WiFiManager::setupConfigPortal()':
F:/cygwin64/home/yuan/LcdTcp/libraries/WiFiManager/WiFiManager.cpp:759: undefined reference to `DNSServer::processNextRequest()'
F:/cygwin64/home/yuan/LcdTcp/libraries/WiFiManager/WiFiManager.cpp:759: undefined reference to `ESP8266WebServer::handleClient()'
F:/cygwin64/tmp/mkESP/LcdTcp_generic/WiFiManager.cpp.o: In function `_Bind<WiFiManager* const>':
F:/cygwin64/home/yuan/LcdTcp/libraries/WiFiManager/WiFiManager.cpp:759: undefined reference to `DNSServer::processNextRequest()'
F:/cygwin64/tmp/mkESP/LcdTcp_generic/WiFiManager.cpp.o: In function `String::operator+=(__FlashStringHelper const*)':
F:/cygwin64/home/yuan/LcdTcp/libraries/WiFiManager/WiFiManager.cpp:759: undefined reference to `ESP8266WebServer::handleClient()'
F:/cygwin64/tmp/mkESP/LcdTcp_generic/WiFiManager.cpp.o: In function `WiFiManager::autoConnect(char const*, char const*)':
F:/cygwin64/home/yuan/LcdTcp/libraries/WiFiManager/WiFiManager.cpp:759: undefined reference to `ESP8266WebServer::hostHeader()'
F:/cygwin64/home/yuan/LcdTcp/libraries/WiFiManager/WiFiManager.cpp:759: undefined reference to `ESP8266WebServer::hostHeader()'
F:/cygwin64/tmp/mkESP/LcdTcp_generic/WiFiManager.cpp.o: In function `WiFiManager::captivePortal()':
F:/cygwin64/home/yuan/LcdTcp/libraries/WiFiManager/WiFiManager.cpp:759: undefined reference to `ESP8266WebServer::sendHeader(String const&, String const&, bool)'
F:/cygwin64/tmp/mkESP/LcdTcp_generic/WiFiManager.cpp.o: In function `StringSumHelper':
F:/cygwin64/home/yuan/LcdTcp/libraries/WiFiManager/WiFiManager.cpp:759: undefined reference to `ESP8266WebServer::send(int, char const*, String const&)'
F:/cygwin64/tmp/mkESP/LcdTcp_generic/WiFiManager.cpp.o: In function `WiFiManager::handleRoot()':
F:/cygwin64/home/yuan/LcdTcp/libraries/WiFiManager/WiFiManager.cpp:759: undefined reference to `ESP8266WebServer::sendHeader(String const&, String const&, bool)'
F:/cygwin64/home/yuan/LcdTcp/libraries/WiFiManager/WiFiManager.cpp:759: undefined reference to `ESP8266WebServer::send(int, char const*, String const&)'
F:/cygwin64/tmp/mkESP/LcdTcp_generic/WiFiManager.cpp.o: In function `String::operator+=(char const*)':
F:/cygwin64/home/yuan/LcdTcp/libraries/WiFiManager/WiFiManager.cpp:759: undefined reference to `ESP8266WebServer::args()'
F:/cygwin64/tmp/mkESP/LcdTcp_generic/WiFiManager.cpp.o: In function `String::operator+=(__FlashStringHelper const*)':
F:/cygwin64/home/yuan/LcdTcp/libraries/WiFiManager/WiFiManager.cpp:759: undefined reference to `ESP8266WebServer::argName(int)'
F:/cygwin64/home/yuan/LcdTcp/libraries/WiFiManager/WiFiManager.cpp:759: undefined reference to `ESP8266WebServer::arg(int)'
F:/cygwin64/tmp/mkESP/LcdTcp_generic/WiFiManager.cpp.o: In function `WiFiManager::handleRoot()':
F:/cygwin64/home/yuan/LcdTcp/libraries/WiFiManager/WiFiManager.cpp:759: undefined reference to `ESP8266WebServer::args()'
F:/cygwin64/tmp/mkESP/LcdTcp_generic/WiFiManager.cpp.o:(.text._ZN11WiFiManager14handleNotFoundEv+0xe0): undefined reference to `ESP8266WebServer::argName(int)'
F:/cygwin64/tmp/mkESP/LcdTcp_generic/WiFiManager.cpp.o: In function `WiFiManager::handleNotFound()':
F:/cygwin64/home/yuan/LcdTcp/libraries/WiFiManager/WiFiManager.cpp:759: undefined reference to `ESP8266WebServer::arg(int)'
F:/cygwin64/tmp/mkESP/LcdTcp_generic/WiFiManager.cpp.o: In function `String::operator+=(char const*)':
F:/cygwin64/home/yuan/LcdTcp/libraries/WiFiManager/WiFiManager.cpp:759: undefined reference to `ESP8266WebServer::args()'
F:/cygwin64/tmp/mkESP/LcdTcp_generic/WiFiManager.cpp.o: In function `WiFiManager::handleNotFound()':
F:/cygwin64/home/yuan/LcdTcp/libraries/WiFiManager/WiFiManager.cpp:759: undefined reference to `ESP8266WebServer::sendHeader(String const&, String const&, bool)'
F:/cygwin64/tmp/mkESP/LcdTcp_generic/WiFiManager.cpp.o: In function `String::operator+=(char const*)':
F:/cygwin64/home/yuan/LcdTcp/libraries/WiFiManager/WiFiManager.cpp:759: undefined reference to `ESP8266WebServer::sendHeader(String const&, String const&, bool)'
F:/cygwin64/home/yuan/LcdTcp/libraries/WiFiManager/WiFiManager.cpp:759: undefined reference to `ESP8266WebServer::sendHeader(String const&, String const&, bool)'
F:/cygwin64/tmp/mkESP/LcdTcp_generic/WiFiManager.cpp.o: In function `WiFiManager::handleNotFound()':
F:/cygwin64/home/yuan/LcdTcp/libraries/WiFiManager/WiFiManager.cpp:759: undefined reference to `ESP8266WebServer::sendHeader(String const&, String const&, bool)'
F:/cygwin64/home/yuan/LcdTcp/libraries/WiFiManager/WiFiManager.cpp:759: undefined reference to `ESP8266WebServer::send(int, char const*, String const&)'
collect2.exe: error: ld returned 1 exit status
make: *** [/home/yuan/makeEspArduino/makeEspArduino.mk:244๏ผšF:/cygwin64/tmp/mkESP/LcdTcp_generic/LcdTcp.bin] ้”™่ฏฏ 1

It appears that the lib WiFiManager requires other libs... So should I add it in my config.mk one by one ..?
It sounds really tough..

Handling Multiple .ino files

Firstly, can I say great work on building this infrastructure :-)

In my usage I have multiple .ino files, and .h files, I am not sure how I can handle this, it seems you are expecting a single .ino file.
Is there a way to handle what I need ?

Kind Regards

BOARD variable doesn't accept boards name with parenthesis

Selecting as board name NodeMCU 0.9 (ESP-12 Module) the make fails as follows:

~/makeEspArduino$ make -f ~/makeEspArduino/makeEspArduino.mk ~/Arduino/ESP8266-WiMgr-AutoConnectWithTelegram/ESP8266-WiMgr-AutoConnectWithTelegram.ino BOARD='NodeMCU 0.9 (ESP-12 Module)'
/bin/sh: 1: Syntax error: "(" unexpected

  • Build state has changed, doing a full rebuild *
    /bin/sh: 1: Syntax error: "(" unexpected
    /bin/sh: 1: Syntax error: "(" unexpected
    make: *** /tmp/mkESP/HelloServer_NodeMCU: Is a directory. Stop.

even using escape backslashes I got similar errors.

Adding all sourcefiles in Sketch directory when LIBS variable is not defined

Thanks for such a great tool!
I want to have my own folder structure and I was tweaking the Makefile a little bit, just found a small issue when the LIBS variable is empty:

ifneq ($(LIBS),)
USER_SRC := $(SKETCH) $(filter-out $(IGNORE_PATTERN),$(shell find $(dir $(LIBS)) -name ".S" -o -name ".c" -o -name "*.cpp"))
else
USER_SRC := $(SKETCH)
endif

When LIBS variable is empty (which was my case), it tries to compile all source files under the Makefile directory. So I added a simple check to assure it is not empty.

Link error when using config.mk or including makeEspArduino.mk

When using the makeEspArduino.mk with all defaults i.e. make -f ../../makeEspArduino/makeEspArduino.mk, the sketch builds and links fine. When wanting to do per sketch build configuration by using either a config.mk file in my local sketch dir, or creating a Makefile which includes makeEspArduino.mk, I get a linker error:

Creating core archive
Linking /home/tomc/ownCloud/Electronics/ESP8266/sketchbook/tempMonitor/.build/tempMonitor_generic/tempMonitor.bin
  Versions: Unknown, 2.3.0
/home/tomc/.arduino15/packages/esp8266/tools/xtensa-lx106-elf-gcc/1.20.0-26-gb404fb9-2/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/../../../../xtensa-lx106-elf/bin/ld: cannot open linker script file -Wl,--gc-sections: No such file or directory
collect2: error: ld returned 1 exit status

My environment is Arduino v1.6.11 on Linux with esp8266 v2.3.0 installed via the boards manager. The makeEspArduino finds all dependencies from the Arduino environment just fine.

My ESP8266 dev dir structure is as follows:

.
โ”œโ”€โ”€ makeEspArduino
โ”‚ย ย  โ”œโ”€โ”€ LICENSE
โ”‚ย ย  โ”œโ”€โ”€ makeEspArduino.mk
โ”‚ย ย  โ””โ”€โ”€ README.md
โ””โ”€โ”€ sketchbook
    โ””โ”€โ”€ tempMonitor
        โ”œโ”€โ”€ config.mk
        โ””โ”€โ”€ tempMonitor.ino

The contents of sketchbook/tempMonitor/config.mk is:

# config.mk
THIS_DIR := $(realpath $(dir $(realpath $(lastword $(MAKEFILE_LIST)))))
ROOT := $(THIS_DIR)/..
#LIBS = $(ESP_LIBS)/SPI \
#  $(ESP_LIBS)/Wire \
#  $(ESP_LIBS)/ESP8266WiFi \
#  $(ROOT)/libraries \
#  $(ROOT)/ext_lib

FLASH_DEF = 512K64K
BUILD_DIR = $(THIS_DIR)/.build/$(MAIN_NAME)_$(BOARD)

and the tempMonitor.ino is a very simple sketch that reads the ADC and writes to the serial port, no special libs and it compiles and links fine as described above without the config.mk file.

I get the error mentioned above when running: make -f ../../makeEspArduino/makeEspArduino.mk from within the sketchbook/tempMonitor dir.

Any help would be much appreciated in helping me understand what I am missing to do in config.mk for the linker to find the required parts.

Thanks,
Tom

PS: I also tried setting up a Makefile which then includes {correct_path}/makeEspArduino.mk, but the error is the same, so the problem seems to be me messing up or not setting some var in my own make files.

Missing memory configurations for existing board causes "Unknown Board" message

tldr; Notify user when $(FLASH_DEF) is empty instead of just board not found.

While messing around with pull requests in esp8266/Arduino, a changeset somewhere removed the [BOARD].menu.FlashSize section for my board in the boards.txt file.
With no flash size loaded, the call to PARSE_ARDUINO is missing the $$flashSize parameter which causes the rest of the parameters to be offset incorrectly when passed in. In my scenario, the board.txt filename parameter got left out of the mix for actually searching for boards. This issue gave me the "Unknown board [BOARD]" message which took me down a hole of troubleshooting the missing board that certainly existed within the boards.txt.

Extra -o on Windows causes no files to compile

Running on Windows it fails with "xtensa-lx106-elf-g++.exe: fatal error: no input files"

looking more closely with GNU Make 4.2.1 I see output like...

/e/git-junk/hardware/esp8266/tools/xtensa-lx106-elf/bin/xtensa-lx106-elf-g++ -D__ets__ -DICACHE_FLASH -U__STRICT_ANSI__ -I/e/git-junk/hardware/esp8266/tools/sdk/include -I/e/git-junk/hardware/esp8266/tools/sdk/lwip/include -I/e/git-junk/hardware/esp8266/tools/sdk/libc/xtensa-lx106-elf/include -IE:/msys64/tmp/mkESP/test_generic/core -c -w -Os -g -mlongcalls -mtext-section-literals -fno-exceptions -fno-rtti -falign-functions=4 -std=c++11 -MMD -ffunction-sections -fdata-sections -DF_CPU=80000000L -DLWIP_OPEN_SRC -DARDUINO=10605 -DARDUINO_ESP8266_ESP01 -DARDUINO_ARCH_esp8266 -DARDUINO_BOARD="ESP8266_ESP01" -DESP8266 -I/e/git-junk/hardware/esp8266/cores/esp8266 -I/e/git-junk/hardware/esp8266/variants/generic -IE:/msys64/tmp/mkESP/test_generic -IE:/git-junk/makeEspArduino/arduino/ -o /e/git-junk/hardware/esp8266/cores/esp8266/abi.cpp -o E:/msys64/tmp/mkESP/test_generic/abi.cpp.o

There is an extra -o before the cpp file.

This comes from the of CPP_COM that is the following for me

/e/git-junk/hardware/esp8266/tools/xtensa-lx106-elf/bin/xtensa-lx106-elf-g++ -D__ets__ -DICACHE_FLASH -U__STRICT_ANSI__ -I/e/git-junk/hardware/esp8266/tools/sdk/include -I/e/git-junk/hardware/esp8266/tools/sdk/lwip/include -I/e/git-junk/hardware/esp8266/tools/sdk/libc/xtensa-lx106-elf/include -IE:/msys64/tmp/mkESP/test_generic/core -c -w -Os -g -mlongcalls -mtext-section-literals -fno-exceptions -fno-rtti -falign-functions=4 -std=c++11 -MMD -ffunction-sections -fdata-sections -DF_CPU=80000000L -DLWIP_OPEN_SRC -DARDUINO=10605 -DARDUINO_ESP8266_ESP01 -DARDUINO_ARCH_esp8266 -DARDUINO_BOARD="ESP8266_ESP01" -DESP8266 -I/e/git-junk/hardware/esp8266/cores/esp8266 -I/e/git-junk/hardware/esp8266/variants/generic -IE:/msys64/tmp/mkESP/test_generic -IE:/git-junk/makeEspArduino/arduino/ -o

The only place I see CPP_COM set in print "CPP_COM=$$v{'recipe.cpp.o.pattern'}\n"; but as I don't understand makefiles well enough I'm not sure how it is being set.

How can I remove this pesky -o ?

Maybe a sanity check for CPP_COM that if it sees a -o at the end it removes it.

makefile seems to launch all compiles in parallel

When using this makefile I observe 2 behaviours ๐Ÿ‘
1/ It launches all compiles in parallel, putting my PC out of memory and freezes the user interface
2/ All files are recompiled , even when not changed

Is this expected behaviour ?

reliability

With the arduino IDE the esp12 gives me no trouble. with this make file the esp will WDT reset dozens of times before it gets a successful run. even with a basic blink sketch.

esp32: path to esptool is incorrect

I think I've figured out what's going on, but I'm not quite sure how to fix it (having no perl skills..)

ELF2BIN_COM gets set from platform.txt's recipe.objcopy.hex.pattern, which starts with {tools.esptool.cmd} - however that needs to be substituted for {tools.esptool.cmd.windows} if on windows, otherwise {tools.esptool.cmd.linux}. The platform-specific keys in platform.txt have the correct full paths to esptool.py or esptool.exe.

As a workaround I just symlinked esptool -> esptool.py in my ESP_ROOT/tools directory, and that does work, but I don't think its a proper solution...

esp8266/Arduino latest master breaks converting to binary

Creating core archive
Linking ../build/ESP8266/3.0.0/alpha/ger/emonio.bin
  Versions: 2.4.0-258-g9782fe8-dirty, 2.4.0-rc2-18-g303a71d
error: invalid flash mode value: -bf
../../makeEspArduino/makeEspArduino.mk:235: recipe for target '../build/ESP8266/3.0.0/alpha/ger/emonio.bin' failed
make: *** [../build/ESP8266/3.0.0/alpha/ger/emonio.bin] Error 2

I think it has something to do with parsing platform.txt, but i was unable to find out what really happens there.

setting ARDUINO_ARCH_

I am using the make file under linux (ubuntu), from a project originally set up with platformio (atom).

One of the projects uses the RingBuffer library.
https://github.com/wizard97/ArduinoRingBuffer

The library checks the architecture:
#elif defined(ARDUINO_ARCH_ESP8266)

with the makefile the architecture is set to:
ARDUINO_ARCH_esp8266

as a workaround I added:
BUILD_EXTRA_FLAGS = -DARDUINO_ARCH_ESP8266

Is there a better way of doing this?

cannot make any program work on ESP32

Sorry for the very generic title, I was using your makefile on ESP8266 without any issue and I'm now trying it with ESP32.
I downloaded the toolchain from https://github.com/espressif/arduino-esp32.git and followed instructions for Linux (I'm xenial 64bits) and I can compile all sketches just fine.
Flashing also shows no errors.
But even a simple blink script does not work: I don't have any output in the serial monitor (cutecom) too.
The chip seems to be ok because I've successfully flashed the nodemcu firmware and tested some simple scripts.

Is there anything I could do to diagnose the issue?

Proposal: adding $(LD_EXTRA)

I would like to propose the addition of the variable LD_EXTRA for giving extra linker flags.

by changing:

$(LD_COM)

to:

$(LD_COM) $(LD_EXTRA)

I use this to wrap functions from the Core. Very useful.

add a $(CUSTOM_DEPENDS) for user dependecies

Add an empty variable like "$(CUSTOM_DEPENDS) $(ESP_LIBS) $(ARDUINO_LIBS)" $(SKETCH)) at the end of the LIBS := initialization so a user can include his custom libraries alongside the Arduino and ESP ones.

Personally, I thought that is what LIBS was for (specifying some general libs that may be a dependency ) , but looking at the source, LIBS is for the EXACT libs to be compiled.

finding libraries for project that compiles on the IDE

Hi, I am able to build and flash simple sketches (such as the "Blink") using a espmake. However I have trouble with projects of my own that use more libraries and that I can successfully build and flash with the IDE (I am on Raspbian if that matters).

Now I am stuck on some missing libraries (see below). I have this library in
/home/pi/bin/./arduino-1.8.3/hardware/arduino/avr/libraries/SoftwareSerial/src/SoftwareSerial.h
Any idea how to fix my makefile?

More in general would be nice to read ideas on how to derive a working makefile from the IDE compilation.

 In file included from /home/pi/Arduino/libraries/Adafruit_MQTT_Library/examples/mqtt_fona/fonahelper.cpp:1:0: 
 /home/pi/Arduino/libraries/Adafruit_SleepyDog_Library/Adafruit_SleepyDog.h:23:4: error: #error         Unsupported platform for the Adafruit Watchdog library! 
       #error Unsupported platform for the Adafruit Watchdog library!
 ^ 
 /home/pi/Arduino/libraries/Adafruit_MQTT_Library/examples/mqtt_fona/fonahelper.cpp:2:28: fatal   error: SoftwareSerial.h: No such file or directory 
  #include <SoftwareSerial.h> 
                       
 compilation terminated. 
 /home/pi/makeEspArduino/makeEspArduino.mk:194: recipe for target 
 '/tmp/mkESP/dht_temp_generic/fonahelper.cpp.o' failed 
  make: *** [/tmp/mkESP/dht_temp_generic/fonahelper.cpp.o] Error 1   
 make: *** Waiting for unfinished jobs.... 

Linking against libmain.a

How do I link against any specific .a file?
The reason why I'm asking this is because I have the following code:

#include "spi_flash.h"
void testSPIFlash() {
  uint32_t* buf = (uint32_t*)calloc(8, sizeof(uint32_t));
  uint32_t from_addr = 0x100000;
  uint32_t to_addr = from_addr + 0xfb000;

  for (uint32_t i = from_addr; i < to_addr; i+=8) {
    spi_flash_read(i, buf, 8*sizeof(uint32_t));
    Serial.print(i, HEX);
    Serial.print(":\t");
    for (size_t i = 0; i < 8; i++) {
      Serial.print(buf[i], HEX);
      Serial.print(" ");
    }
    Serial.println();
  }
}

void setup() {
 testSPIFlash();
}
void loop(){
}

The code compiles, but I get a linker error:

In function 'testSPIFlash()':
undefined reference to spi_flash_read(unsigned int, unsigned int*, unsigned int)

After demangling symbols in /esp8266_arduino/esp8266/tools/sdk/lib/*.a I found that libmain.a cointains a function named spi_flash_read. So it seems like the makefile does not link against libmain.a.

How do I use BUILD_EXTRA_FLAGS ?

I tried multiple variants, with =, with #, with #define STRINGIZE(x) #x #define STRINGIZE_VALUE_OF(x) STRINGIZE(x) in the .ino file and it either tells me macro not found or other errors .

.ino CODE

#define STRINGIZE(x) #x
#define STRINGIZE_VALUE_OF(x) STRINGIZE(x)

const char* update_username =  _UPDATE_USERNAME;
const char* update_password =  _UPDATE_PASSWORD;
const char* host =             _HOST;
const char* ssid =             _SSID;
const char* password =         _PASSWORD;
// const char* update_username =   STRINGIZE_VALUE_OF(_UPDATE_USERNAME);
// const char* update_password =   STRINGIZE_VALUE_OF(_UPDATE_PASSWORD);
// const char* host =              STRINGIZE_VALUE_OF(_HOST);
// const char* ssid =              STRINGIZE_VALUE_OF(_SSID);
// const char* password =          STRINGIZE_VALUE_OF(_PASSWORD);
const char* update_path =       "/update";
// const char* update_path =       _UPDATE_PATH;

Example outputs :

"/home/me/myproj/3rd-party/nodes-myproj/deploy-libs/esp8266/tools/xtensa-lx106-elf/bin/xtensa-lx106-elf-gcc" -g -w -Os -nostdlib -Wl,--no-check-sections -u call_user_start -u _printf_float -u _scanf_float -Wl,-static "-L/home/me/myproj/3rd-party/nodes-myproj/deploy-libs/esp8266/tools/sdk/lib" "-L/home/me/myproj/3rd-party/nodes-myproj/deploy-libs/esp8266/tools/sdk/ld" "-L/home/me/myproj/3rd-party/nodes-myproj/deploy-libs/esp8266/tools/sdk/libc/xtensa-lx106-elf/lib" "-Teagle.flash.4m1m.ld" -Wl,--gc-sections -Wl,-wrap,system_restart_local -Wl,-wrap,spi_flash_read  -o "/tmp/mkESP/OTA_local_to_ESP_d1_mini/OTA_local_to_ESP.elf" -Wl,--start-group "/tmp/mkESP/OTA_local_to_ESP_d1_mini/arduino.ar" -lhal -lphy -lpp -lnet80211 -llwip2 -lwpa -lcrypto -lmain -lwps -laxtls -lespnow -lsmartconfig -lairkiss -lmesh -lwpa2 -lstdc++ -lm -lc -lgcc -Wl,--end-group  "-L/tmp/mkESP/OTA_local_to_ESP_d1_mini"
"/home/me/myproj/3rd-party/nodes-myproj/deploy-libs/esp8266/tools/esptool/esptool" -eo "/home/me/myproj/3rd-party/nodes-myproj/deploy-libs/esp8266/bootloaders/eboot/eboot.elf" -bo "/tmp/mkESP/OTA_local_to_ESP_d1_mini/OTA_local_to_ESP.bin" -bm dio -bf 40 -bz 4M -bs .text -bp 4096 -ec -eo "/tmp/mkESP/OTA_local_to_ESP_d1_mini/OTA_local_to_ESP.elf" -bs .irom0.text -bs .text -bs .data -bs .rodata -bc -ec
"/home/me/myproj/3rd-party/nodes-myproj/deploy-libs/esp8266/tools/xtensa-lx106-elf/bin/xtensa-lx106-elf-size" -A "/tmp/mkESP/OTA_local_to_ESP_d1_mini/OTA_local_to_ESP.elf" | perl -e "$MEM_USAGE" "^(?:\.irom0\.text|\.text|\.data|\.rodata|)\s+([0-9]+).*" "^(?:\.data|\.rodata|\.bss)\s+([0-9]+).*"

Memory usage
  Ram:    35624 bytes
  Flash: 291447 bytes

printf "LwIPVariant: v2 Prebuilt (MSS=536)\n"
LwIPVariant: v2 Prebuilt (MSS=536)
printf "Flash size: 4M (1M SPIFFS)\n\n"
Flash size: 4M (1M SPIFFS)

perl -e 'print "Build complete. Elapsed time: ", time()-1515487954,  " seconds\n\n"'
Build complete. Elapsed time: 39 seconds

/home/me/myproj/3rd-party/nodes-myproj/deploy-libs/esptool -a soft_reset write_flash 0x00000 /tmp/mkESP/OTA_local_to_ESP_d1_mini/OTA_local_to_ESP.bin
make: execvp: /home/me/myproj/3rd-party/nodes-myproj/deploy-libs/esptool: Permission denied
/home/me/myproj/3rd-party/nodes-myproj/deploy-libs/makeEspArduino/makeEspArduino.mk:257: recipe for target 'flash' failed
make: *** [flash] Error 127

Warning: local() encountered an error (return code 2) while executing 'make -e -f /home/me/myproj/3rd-party/nodes-myproj/deploy-libs/makeEspArduino/makeEspArduino.mk BOARD="d1_mini" FLASH_DEF="4M1M" UPLOAD_PORT="/dev/ttyUSB0" SKETCH="/home/me/myproj/nodes-myproj/sketches/OTA_local_to_ESP.ino" ESP_ROOT="/home/me/myproj/3rd-party/nodes-myproj/deploy-libs/esp8266" ESPTOOL_PY="/home/me/myproj/3rd-party/nodes-myproj/deploy-libs/esptool" CUSTOM_LIBS="/home/me/myproj/3rd-party/nodes-myproj/sketch-libs /home/me/myproj/nodes-myproj/node-lib" BUILD_EXTRA_FLAGS='
 -D_UPDATE_USERNAME=XXXX 
 -D_UPDATE_PASSWORD=xxxx 
 -D_HOST=esp8266_wu 
 -D_SSID=sssssssss 
 -D_PASSWORD=pppppppppp 
 -D_UPDATE_PATH=update '  flash '

"/home/me/myproj/3rd-party/nodes-myproj/deploy-libs/esp8266/tools/xtensa-lx106-elf/bin/xtensa-lx106-elf-g++"
 -D__ets__
 -DICACHE_FLASH -U__STRICT_ANSI__ "-I/home/me/myproj/3rd-party/nodes-myproj/deploy-libs/esp8266/tools/sdk/include" "-I/home/me/myproj/3rd-party/nodes-myproj/deploy-libs/esp8266/tools/sdk/lwip2/include" "-I/home/me/myproj/3rd-party/nodes-myproj/deploy-libs/esp8266/tools/sdk/libc/xtensa-lx106-elf/include" "-I/tmp/mkESP/OTA_local_to_ESP_d1_mini/core"  -c -w -Os -g -mlongcalls -mtext-section-literals -fno-exceptions -fno-rtti -falign-functions=4 -std=c++11 -MMD -ffunction-sections -fdata-sections
 -DF_CPU=80000000L
 -DLWIP_OPEN_SRC
 -DTCP_MSS=536  
 -DARDUINO=10605
 -DARDUINO_ESP8266_WEMOS_D1MINI
 -DARDUINO_ARCH_ESP8266
 -DARDUINO_BOARD=\"ESP8266_WEMOS_D1MINI\"  
 -DESP8266
 -D_UPDATE_USERNAME \"XXXX\" 
 -D_UPDATE_PASSWORD \"xxxx\" 
 -D_HOST \"esp8266_wu\" 
 -D_SSID \"sssssssss\" 
 -D_PASSWORD \"pppppppppp\" 
 -D_UPDATE_PATH \"update\"  -I/home/me/myproj/3rd-party/nodes-myproj/deploy-libs/esp8266/cores/esp8266 -I/home/me/myproj/3rd-party/nodes-myproj/deploy-libs/esp8266/variants/d1_mini -I/tmp/mkESP/OTA_local_to_ESP_d1_mini -I/home/me/myproj/3rd-party/nodes-myproj/deploy-libs/esp8266/libraries/ArduinoOTA/ -I/home/me/myproj/3rd-party/nodes-I/home/me/myproj/3rd-party/nodes-myproj/deploy-libs/esp8266/libraries/Wire/ -I/home/me/myproj/3rd-party/nodes-myproj/deploy-libs/esp8266/libraries/esp8266/src/ -I/home/me/myproj/nodes-myproj/sketches/esp_ws28x_web/   /home/me/myproj/3rd-party/nodes-myproj/deploy-libs/esp8266/cores/esp8266/WMath.cpp -o /tmp/mkESP/OTA_local_to_ESP_d1_mini/WMath.cpp.o
xtensa-lx106-elf-g++: error: "XXXX": No such file or directory
xtensa-lx106-elf-g++: error: "xxxx": No such file or directory
xtensa-lx106-elf-g++: error: "esp8266_wu": No such file or directory
xtensa-lx106-elf-g++: error: "sssssssss": No such file or directory
xtensa-lx106-elf-g++: error: "pppppppppp": No such file or directory
xtensa-lx106-elf-g++: error: "update": No such file or directory
/home/me/myproj/3rd-party/nodes-myproj/deploy-libs/makeEspArduino/makeEspArduino.mk:215: recipe for target '/tmp/mkESP/OTA_local_to_ESP_d1_mini/WMath.cpp.o' failed
make: *** [/tmp/mkESP/OTA_local_to_ESP_d1_mini/WMath.cpp.o] Error 1

Warning: local() encountered an error (return code 2) while executing 'make -e -f /home/me/myproj/3rd-party/nodes-myproj/deploy-libs/makeEspArduino/makeEspArduino.mk BOARD="d1_mini" FLASH_DEF="4M1M" UPLOAD_PORT="/dev/ttyUSB0" SKETCH="/home/me/myproj/nodes-myproj/sketches/OTA_local_to_ESP.ino" ESP_ROOT="/home/me/myproj/3rd-party/nodes-myproj/deploy-libs/esp8266" ESPTOOL_PY="/home/me/myproj/3rd-party/nodes-myproj/deploy-libs/esptool" CUSTOM_LIBS="/home/me/myproj/3rd-party/nodes-myproj/sketch-libs /home/me/myproj/nodes-myproj/node-lib" BUILD_EXTRA_FLAGS='
 -D_UPDATE_USERNAME \"XXXX\" 
 -D_UPDATE_PASSWORD \"xxxx\" 
 -D_HOST \"esp8266_wu\" 
 -D_SSID \"sssssssss\" 
 -D_PASSWORD \"pppppppppp\" 
 -D_UPDATE_PATH \"update\" '  flash '

"/home/me/myproj/3rd-party/nodes-myproj/deploy-libs/esp8266/tools/xtensa-lx106-elf/bin/xtensa-lx106-elf-g++"
 -D__ets__
 -DICACHE_FLASH -U__STRICT_ANSI__ "-I/home/me/myproj/3rd-party/nodes-myproj/deploy-libs/esp8266/tools/sdk/include" "-I/home/me/myproj/3rd-party/nodes-myproj/deploy-libs/esp8266/tools/sdk/lwip2/include" "-I/home/me/myproj/3rd-party/nodes-myproj/deploy-libs/esp8266/tools/sdk/libc/xtensa-lx106-elf/include" "-I/tmp/mkESP/OTA_local_to_ESP_d1_mini/core"  -c -w -Os -g -mlongcalls -mtext-section-literals -fno-exceptions -fno-rtti -falign-functions=4 -std=c++11 -MMD -ffunction-sections -fdata-sections
 -DF_CPU=80000000L
 -DLWIP_OPEN_SRC
 -DTCP_MSS=536  
 -DARDUINO=10605
 -DARDUINO_ESP8266_WEMOS_D1MINI
 -DARDUINO_ARCH_ESP8266
 -DARDUINO_BOARD=\"ESP8266_WEMOS_D1MINI\"  
 -DESP8266
 -D_UPDATE_USERNAME#XXXX 
 -D_UPDATE_PASSWORD#xxxx 
 -D_HOST#esp8266_wu 
 -D_SSID#sssssssss 
 -D_PASSWORD#pppppppppp 
 -D_UPDATE_PATH#update  -I/home/me/myproj/3rd-party/nodes-myproj/deploy-libs/esp8266/cores/esp8266 -I/home/me/myproj/3rd-party/nodes-myproj/deploy-libs/esp8266/variants/d1_mini -I/tmp/mkESP/OTA_local_to_ESP_d1_mini -I/home/me/myproj/3rd-I/home/me/myproj/3rd-party/nodes-myproj/deploy-libs/esp8266/libraries/Wire/ -I/home/me/myproj/3rd-party/nodes-myproj/deploy-libs/esp8266/libraries/esp8266/src/ -I/home/me/myproj/nodes-myproj/sketches/esp_ws28x_web/   -x c++ -include /home/me/myproj/3rd-party/nodes-myproj/deploy-libs/esp8266/cores/esp8266/Arduino.h /home/me/myproj/nodes-myproj/sketches/OTA_local_to_ESP.ino -o /tmp/mkESP/OTA_local_to_ESP_d1_mini/OTA_local_to_ESP_.cpp.o
<command-line>:0:17: error: stray '#' in program
/home/me/myproj/nodes-myproj/sketches/OTA_local_to_ESP.ino:29:32: note: in expansion of macro '_UPDATE_USERNAME'
 const char* update_username =  _UPDATE_USERNAME;
                                ^
<command-line>:0:17: error: stray '#' in program
/home/me/myproj/nodes-myproj/sketches/OTA_local_to_ESP.ino:30:32: note: in expansion of macro '_UPDATE_PASSWORD'
 const char* update_password =  _UPDATE_PASSWORD;
                                ^
<command-line>:0:6: error: stray '#' in program
/home/me/myproj/nodes-myproj/sketches/OTA_local_to_ESP.ino:31:32: note: in expansion of macro '_HOST'
 const char* host =             _HOST;
                                ^
<command-line>:0:6: error: stray '#' in program
/home/me/myproj/nodes-myproj/sketches/OTA_local_to_ESP.ino:32:32: note: in expansion of macro '_SSID'
 const char* ssid =             _SSID;
                                ^
<command-line>:0:10: error: stray '#' in program
/home/me/myproj/nodes-myproj/sketches/OTA_local_to_ESP.ino:33:32: note: in expansion of macro '_PASSWORD'
 const char* password =         _PASSWORD;
                                ^
<command-line>:0:18: error: 'XXXX' was not declared in this scope
/home/me/myproj/nodes-myproj/sketches/OTA_local_to_ESP.ino:29:32: note: in expansion of macro '_UPDATE_USERNAME'
 const char* update_username =  _UPDATE_USERNAME;
                                ^
<command-line>:0:18: error: 'xxxx' was not declared in this scope
/home/me/myproj/nodes-myproj/sketches/OTA_local_to_ESP.ino:30:32: note: in expansion of macro '_UPDATE_PASSWORD'
 const char* update_password =  _UPDATE_PASSWORD;
                                ^
<command-line>:0:7: error: 'esp8266_wu' was not declared in this scope
/home/me/myproj/nodes-myproj/sketches/OTA_local_to_ESP.ino:31:32: note: in expansion of macro '_HOST'
 const char* host =             _HOST;
                                ^
<command-line>:0:7: error: 'sssssssss' was not declared in this scope
/home/me/myproj/nodes-myproj/sketches/OTA_local_to_ESP.ino:32:32: note: in expansion of macro '_SSID'
 const char* ssid =             _SSID;
                                ^
<command-line>:0:11: error: 'pppppppppp' was not declared in this scope
/home/me/myproj/nodes-myproj/sketches/OTA_local_to_ESP.ino:33:32: note: in expansion of macro '_PASSWORD'
 const char* password =         _PASSWORD;
                                ^
/home/me/myproj/3rd-party/nodes-myproj/deploy-libs/makeEspArduino/makeEspArduino.mk:219: recipe for target '/tmp/mkESP/OTA_local_to_ESP_d1_mini/OTA_local_to_ESP_.cpp.o' failed
make: *** [/tmp/mkESP/OTA_local_to_ESP_d1_mini/OTA_local_to_ESP_.cpp.o] Error 1

Warning: local() encountered an error (return code 2) while executing 'make -e -f /home/me/myproj/3rd-party/nodes-myproj/deploy-libs/makeEspArduino/makeEspArduino.mk BOARD="d1_mini" FLASH_DEF="4M1M" UPLOAD_PORT="/dev/ttyUSB0" SKETCH="/home/me/myproj/nodes-myproj/sketches/OTA_local_to_ESP.ino" ESP_ROOT="/home/me/myproj/3rd-party/nodes-myproj/deploy-libs/esp8266" ESPTOOL_PY="/home/me/myproj/3rd-party/nodes-myproj/deploy-libs/esptool" CUSTOM_LIBS="/home/me/myproj/3rd-party/nodes-myproj/sketch-libs /home/me/myproj/nodes-myproj/node-lib" BUILD_EXTRA_FLAGS='
 -D_UPDATE_USERNAME#XXXX 
 -D_UPDATE_PASSWORD#xxxx 
 -D_HOST#esp8266_wu 
 -D_SSID#sssssssss 
 -D_PASSWORD#pppppppppp 
 -D_UPDATE_PATH#update '  flash '


"/home/me/myproj/3rd-party/nodes-myproj/deploy-libs/esp8266/tools/xtensa-lx106-elf/bin/xtensa-lx106-elf-g++"
 -D__ets__
 -DICACHE_FLASH -U__STRICT_ANSI__ "-I/home/me/myproj/3rd-party/nodes-myproj/deploy-libs/esp8266/tools/sdk/include" "-I/home/me/myproj/3rd-party/nodes-myproj/deploy-libs/esp8266/tools/sdk/lwip2/include" "-I/home/me/myproj/3rd-party/nodes-myproj/deploy-libs/esp8266/tools/sdk/libc/xtensa-lx106-elf/include" "-I/tmp/mkESP/OTA_local_to_ESP_d1_mini/core"  -c -w -Os -g -mlongcalls -mtext-section-literals -fno-exceptions -fno-rtti -falign-functions=4 -std=c++11 -MMD -ffunction-sections -fdata-sections
 -DF_CPU=80000000L
 -DLWIP_OPEN_SRC
 -DTCP_MSS=536  
 -DARDUINO=10605
 -DARDUINO_ESP8266_WEMOS_D1MINI
 -DARDUINO_ARCH_ESP8266
 -DARDUINO_BOARD=\"ESP8266_WEMOS_D1MINI\"  
 -DESP8266
 -D_UPDATE_USERNAME=\"XXXX\" 
 -D_UPDATE_PASSWORD=\"xxxx\" 
 -D_HOST=\"esp8266_wu\" 
 -D_SSID=\"sssssssss\" 
 -D_PASSWORD=\"pppppppppp\" 
 -D_UPDATE_PATH=\"update\"  -I/home/me/myproj/3rd-party/nodes-myproj/deploy-libs/esp8266/cores/esp8266 -I/home/me/myproj/3rd-party/nodes-myproj/deploy-libs/esp8266/variants/d1_mini -I/tmp/mkESP/OTA_local_to_ESP_d1_mini -I/home/me/myproj/3rd-I/home/me/myproj/3rd-party/nodes-myproj/deploy-libs/esp8266/libraries/esp8266/src/ -I/home/me/myproj/nodes-myproj/sketches/esp_ws28x_web/  /tmp/mkESP/OTA_local_to_ESP_d1_mini/buildinfo.c++ -o /tmp/mkESP/OTA_local_to_ESP_d1_mini/buildinfo.c++.o
"/home/me/myproj/3rd-party/nodes-myproj/deploy-libs/esp8266/tools/xtensa-lx106-elf/bin/xtensa-lx106-elf-gcc" -g -w -Os -nostdlib -Wl,--no-check-sections -u call_user_start -u _printf_float -u _scanf_float -Wl,-static "-L/home/me/myproj/3rd-party/nodes-myproj/deploy-libs/esp8266/tools/sdk/lib" "-L/home/me/myproj/3rd-party/nodes-myproj/deploy-libs/esp8266/tools/sdk/ld" "-L/home/me/myproj/3rd-party/nodes-myproj/deploy-libs/esp8266/tools/sdk/libc/xtensa-lx106-elf/lib" "-Teagle.flash.4m1m.ld" -Wl,--gc-sections -Wl,-wrap,system_restart_local -Wl,-wrap,spi_flash_read  -o "/tmp/mkESP/OTA_local_to_ESP_d1_mini/OTA_local_to_ESP.elf" -Wl,--start-group /tmp/mkESP/OTA_local_to_ESP_d1_mini/buildinfo.c++.o "/tmp/mkESP/OTA_local_to_ESP_d1_mini/arduino.ar" -lhal -lphy -lpp -lnet80211 -llwip2 -lwpa -lcrypto -lmain -lwps -laxtls -lespnow -lsmartconfig -lairkiss -lmesh -lwpa2 -lstdc++ -lm -lc -lgcc -Wl,--end-group  "-L/tmp/mkESP/OTA_local_to_ESP_d1_mini"
"/home/me/myproj/3rd-party/nodes-myproj/deploy-libs/esp8266/tools/esptool/esptool" -eo "/home/me/myproj/3rd-party/nodes-myproj/deploy-libs/esp8266/bootloaders/eboot/eboot.elf" -bo "/tmp/mkESP/OTA_local_to_ESP_d1_mini/OTA_local_to_ESP.bin" -bm dio -bf 40 -bz 4M -bs .text -bp 4096 -ec -eo "/tmp/mkESP/OTA_local_to_ESP_d1_mini/OTA_local_to_ESP.elf" -bs .irom0.text -bs .text -bs .data -bs .rodata -bc -ec
"/home/me/myproj/3rd-party/nodes-myproj/deploy-libs/esp8266/tools/xtensa-lx106-elf/bin/xtensa-lx106-elf-size" -A "/tmp/mkESP/OTA_local_to_ESP_d1_mini/OTA_local_to_ESP.elf" | perl -e "$MEM_USAGE" "^(?:\.irom0\.text|\.text|\.data|\.rodata|)\s+([0-9]+).*" "^(?:\.data|\.rodata|\.bss)\s+([0-9]+).*"

Memory usage
  Ram:    35624 bytes
  Flash: 291447 bytes

printf "LwIPVariant: v2 Prebuilt (MSS=536)\n"
LwIPVariant: v2 Prebuilt (MSS=536)
printf "Flash size: 4M (1M SPIFFS)\n\n"
Flash size: 4M (1M SPIFFS)

perl -e 'print "Build complete. Elapsed time: ", time()-1515488975,  " seconds\n\n"'
Build complete. Elapsed time: 38 seconds

/home/me/myproj/3rd-party/nodes-myproj/deploy-libs/esptool -a soft_reset write_flash 0x00000 /tmp/mkESP/OTA_local_to_ESP_d1_mini/OTA_local_to_ESP.bin
make: execvp: /home/me/myproj/3rd-party/nodes-myproj/deploy-libs/esptool: Permission denied
/home/me/myproj/3rd-party/nodes-myproj/deploy-libs/makeEspArduino/makeEspArduino.mk:257: recipe for target 'flash' failed
make: *** [flash] Error 127

Warning: local() encountered an error (return code 2) while executing 'make -e -f /home/me/myproj/3rd-party/nodes-myproj/deploy-libs/makeEspArduino/makeEspArduino.mk BOARD="d1_mini" FLASH_DEF="4M1M" UPLOAD_PORT="/dev/ttyUSB0" SKETCH="/home/me/myproj/nodes-myproj/sketches/OTA_local_to_ESP.ino" ESP_ROOT="/home/me/myproj/3rd-party/nodes-myproj/deploy-libs/esp8266" ESPTOOL_PY="/home/me/myproj/3rd-party/nodes-myproj/deploy-libs/esptool" CUSTOM_LIBS="/home/me/myproj/3rd-party/nodes-myproj/sketch-libs /home/me/myproj/nodes-myproj/node-lib" BUILD_EXTRA_FLAGS='
 -D_UPDATE_USERNAME=\"XXXX\" 
 -D_UPDATE_PASSWORD=\"xxxx\" 
 -D_HOST=\"esp8266_wu\" 
 -D_SSID=\"sssssssss\" 
 -D_PASSWORD=\"pppppppppp\" 
 -D_UPDATE_PATH=\"update\" '  flash '

Automatic detection of library include path fails for Servo library

Servo library has header file in src/Servo.h, while source files are in src/esp8266/.
Include path which gets added is libraries/Servo/src/esp8266/, which causes #include <Servo.h> to fail.
Maybe path detection can be split into two parts: detect build directory separately from include directory, and use "*.h" find pattern when looking for include directory.

Make - no rule to make target

I know this error is a very basic one but I can't figure it out...

Your makefile is above my expertise too. Any ideas on this one? I'm trying to include a third party library. The error I get is:
make: *** No rule to make target 'SFE_BMP180.cpp', needed by '/tmp/mkESP/LoweWeather_nodemcuv2/SFE_BMP180.cpp.o'. Stop.

I think the path to that specific cpp is in my LIBS variable. I'm on OSX developing with a NodeMCU esp8266. My call is:
make -f ./makeEspArduino.mk SKETCH=./LoweWeather.ino BOARD=nodemcuv2
I tried to ignore the BOARD but on simpler sketches, it wouldn't upload at all...

License clarification

In the comment at the top of the makefile you say:

# License: GPL 2.1

But the included license file is LGPL. Which is it?

spaces in library directories

I am using the make file under linux (ubuntu), from a project originally set up with platformio (atom).

The libraries imported from platformio can include spaces:

.piolibdeps/Adafruit Unified Sensor_ID31

When adding the directory to the libraries (LIBS) to project, the directory is not fully recognized.

As a workaround I have renamed the directories not to have spces.

Is there a better way to do this?

Wrong pins_arduino.h used

I cannot get builds from the makefile to use the pin definitions for the specific board that I'm using (Node MCU 1.0). As you'll see below, I specified BOARD in the makefile as 'nodemcu' which as far as I can tell is the correct value.

My simple sketch to test that I get the same behavior using the makefile as I get with the IDE:

void setup() {
  pinMode(LED_BUILTIN, OUTPUT);

  Serial.begin(115200);
  delay(100);

  Serial.printf("LED_BUILTIN: %d", LED_BUILTIN);
}

void loop() {
  digitalWrite(LED_BUILTIN, HIGH);
  delay(250);
  digitalWrite(LED_BUILTIN, LOW);
  delay(250);
}

My makefile looks like:

SKETCH = esp8266_blink.ino

UPLOAD_PORT = /dev/tty.wchusbserial1420
BOARD = nodemcu

include $(HOME)/makeEspArduino/makeEspArduino.mk

When I build and upload that using the Arduino IDE the builtin LED blinks and the serial monitor tells me at LED_BUILTIN is pin 16. When I build and upload using the makefile, serial output tells me that it's using pin 1 (I assume from the default esp8266 version of pins_arduino.h rather than nodemcu). If I change the sketch to refer to 16 explicitly for the pin, it works as expected, so this is just the wrong pin definition header being used.

Q: does anybody have this working with the Wemos D1?

I can't seem to even get the initial example running - some cryptic error from ld. I suspect I forgot to adapt some settings for the Wemos D1 somewhere - any pointers are highly appreciated!

The error is:

collect2: error: ld returned 1 exit status

multiple definition of `_BuildInfo'

using "#include <buildinfo.h>", first make is ok.
subsequent fail with:

Linking ./getVcc-Udp_httpUpd_generic/getVcc-Udp_httpUpd.bin
Versions: f735ecd-dirty, 2.3.0
./getVcc-Udp_httpUpd_generic/buildinfo.cpp.o:(.data._BuildInfo+0x0): multiple definition of `_BuildInfo'
getVcc-Udp_httpUpd_generic/buildinfo.cpp.o:(.data._BuildInfo+0x0): first defined here
collect2: error: ld returned 1 exit status

work ok with:

--- makeEspArduino.mk.org 2016-09-08 11:35:27.703833609 +0200
+++ makeEspArduino.mk 2016-09-08 11:35:14.764098070 +0200
@@ -158,7 +158,7 @@

Automatically generated build information data

Makes the build date and git descriptions at the actual build event available as string constants in the program

BUILD_INFO_H = $(BUILD_DIR)/buildinfo.h
-BUILD_INFO_CPP = $(BUILD_DIR)/buildinfo.cpp
+BUILD_INFO_CPP = $(BUILD_DIR)/buildinfo.c++

LWIP2 support on ESP8266

since a few days the Arduino core for ESP8266 supports the new LWIP2 tcp/ip stack. If I understand correctly this new implementation can be switched to in the Arduino IDE menue.

esp8266/Arduino@4f93f7f

AFAICS there are 3 things necessary to link against LWIP2:

Trigger the build of the library
Add the correct include path
Add the archive to the static libs

LWIP2 should improve memory consumption and excution speed, so it could be worthwhile to add support to makeEspArduino.

Proposal: Progress bar during OTA upload

By adding -r to the parameters to OTA_TOOL we get a nice progress bar during upload instead of those pesky dots.

change line 246 from:

$(OTA_TOOL) -i $(ESP_ADDR) -p $(ESP_PORT) -a $(ESP_PWD) -f $(MAIN_EXE)

to:

$(OTA_TOOL) -r -i $(ESP_ADDR) -p $(ESP_PORT) -a $(ESP_PWD) -f $(MAIN_EXE)

Does not work on OSX

The project doesn't work on OSX: /proc isn't available there.

I would supply a patch but I don't fully understand how the section around full rebuild works, and what the STATE_INF initialisation tries to do. For the time being in my private copy I've disabled the whole bit with ifneq ($OS, Darwin), but that doesn't seem like a real solution.

`TOOLS_BIN` not correct when using ESP8266 core installed by Arduino Boards Manager

The Arduino Boards Manager installs tools under {TOOL_PATH}/{version}/{TOOL}, e.g esp8266/tools/xtensa-lx106-elf-gcc/1.20.0-26-gb404fb9-2 however the ESP8266 Arduino core get.py script installs them directly under {TOOL_PATH}/{TOOL}, e.g esp8266/tools/xtensa-lx106-elf.

This means the makefile is not able to find the required tools for compiling/uploading the sketch when ESP_ROOT is set to the path where the Arduino Boards Manager installs the ESP8266 package.

This is mostly caused by the ESP8266 core for Arduino script not installing the tools in the correct location, however IMO the way the Arduino Boards Manager installs tools should be considered the correct way, and should be supported by this makefile.

bits/c++config.h problem

I got this error with the last version of this project and the esp8266.

In file included from /home/patrick/git/ibex/tomadinhaFeliz/Arduino/tools/xtensa-lx106-elf/xtensa-lx106-elf/include/c++/4.8.2/tr1/cstdarg:32:0,
from /home/patrick/git/ibex/tomadinhaFeliz/Arduino/tools/xtensa-lx106-elf/xtensa-lx106-elf/include/c++/4.8.2/tr1/stdarg.h:32,
from Arduino/tools/sdk/libc/xtensa-lx106-elf/include/stdio.h:39,
from Arduino/cores/esp8266/umm_malloc/umm_malloc.c:494:
/home/patrick/git/ibex/tomadinhaFeliz/Arduino/tools/xtensa-lx106-elf/xtensa-lx106-elf/include/c++/4.8.2/cstdarg:41:28: fatal error: bits/c++config.h: No such file or directory
#include <bits/c++config.h>
^
compilation terminated.
make: *** [Makefile:194: /tmp/mkESP/blink_nodemcu/umm_malloc.c.o] Error 1

blink.ino

/*
 ESP8266 Blink by Simon Peter
 Blink the blue LED on the ESP-01 module
 This example code is in the public domain
 The blue LED on the ESP-01 module is connected to GPIO1
 (which is also the TXD pin; so we cannot use Serial.print() at the same time)
 Note that this sketch uses LED_BUILTIN to find the pin with the internal LED
*/

void setup() {
  pinMode(LED_BUILTIN, OUTPUT);     // Initialize the LED_BUILTIN pin as an output
}

// the loop function runs over and over again forever
void loop() {
  digitalWrite(LED_BUILTIN, LOW);   // Turn the LED on (Note that LOW is the voltage level
                                    // but actually the LED is on; this is because 
                                    // it is acive low on the ESP-01)
  delay(1000);                      // Wait for a second
  digitalWrite(LED_BUILTIN, HIGH);  // Turn the LED off by making the voltage HIGH
  delay(2000);                      // Wait for two seconds (to demonstrate the active low LED)
}
Makefile
#====================================================================================
# makeESPArduino
#
# A makefile for ESP8286 Arduino projects.
# Edit the contents of this file to suit your project
# or just include it and override the applicable macros.
#
# License: GPL 2.1
# General and full license information is available at:
#    https://github.com/plerup/makeEspArduino
#
# Copyright (c) 2016 Peter Lerup. All rights reserved.
#
#====================================================================================

#====================================================================================
# Project specfic values
#====================================================================================

# Include possible project makefile. This can be used to override the defaults below
-include $(firstword $(PROJ_CONF) $(dir $(SKETCH))config.mk)

#=== Default values

# Main source file (sketch).
# If this variable is not specified the first sketch in current directory will be used.
# If none is found there, a demo example will be used instead.
SKETCH ?= ./blink.ino

# Includes in the sketch file of libraries from within the ESP8266 Arduino directories can be automatically
# detected but if this is not enough, define this variable with all libraries or directories needed.
LIBS ?= $(ESP_LIBS)/Wire \
        $(ESP_LIBS)/ESP8266WiFi \
        $(ESP_LIBS)/ESP8266mDNS \
        $(ESP_LIBS)/ESP8266WebServer \

# Esp8266 Arduino git location
ESP_ROOT ?= Arduino

# Board specific definitions
BOARD ?= nodemcu
F_CPU ?= 80000000L
FLASH_DEF ?= 4M3M
FLASH_MODE ?= dio
FLASH_SPEED ?= 40

# Upload parameters
UPLOAD_PORT ?= /dev/ttyUSB0
UPLOAD_VERB ?= -v

# OTA parameters
ESP_ADDR ?= ESP_123456
ESP_PORT ?= 8266
ESP_PWD ?= 123

# HTTP update parameters
HTTP_ADDR ?= ESP_123456
HTTP_URI ?= /update
HTTP_PWD ?= user
HTTP_USR ?= password

# Output directory
BUILD_DIR ?= /tmp/mkESP/$(MAIN_NAME)_$(BOARD)

# File system source directory
FS_DIR ?= $(dir $(SKETCH))data

# Which include files to use from $(ESP_ROOT)/variants/
INCLUDE_VARIANT ?= generic

#====================================================================================
# Standard build logic and values
#====================================================================================

START_TIME := $(shell perl -e "print time();")

# ESP8266 Arduino directories
ifndef ESP_ROOT
  # Location not defined, find and use the version in the Arduino IDE installation
  OS ?= $(shell uname -s)
  ifeq ($(OS), Windows_NT)
    ARDUINO_DIR = $(shell cygpath -m $(LOCALAPPDATA)/Arduino15/packages/esp8266)
  else ifeq ($(OS), Darwin)
    ARDUINO_DIR = $(HOME)/Library/Arduino15/packages/esp8266
  else
    ARDUINO_DIR = $(HOME)/.arduino15/packages/esp8266
  endif
  ESP_ROOT := $(lastword $(wildcard $(ARDUINO_DIR)/hardware/esp8266/*))
  ifeq ($(ESP_ROOT),)
    $(error No installed version of ESP8266 Arduino found)
  endif
  ESP_ARDUINO_VERSION := $(notdir $(ESP_ROOT))
  # Find used version of compiler and tools
  COMP_PATH := $(lastword $(wildcard $(ARDUINO_DIR)/tools/xtensa-lx106-elf-gcc/*))
  ESPTOOL_PATH := $(lastword $(wildcard $(ARDUINO_DIR)/tools/esptool/*))
  MKSPIFFS_PATH := $(lastword $(wildcard $(ARDUINO_DIR)/tools/mkspiffs/*))
else
  # Location defined, assume it is git clone
  ESP_ARDUINO_VERSION = $(call git_description,$(ESP_ROOT))
endif
ESP_LIBS = $(ESP_ROOT)/libraries
SDK_ROOT = $(ESP_ROOT)/tools/sdk
TOOLS_ROOT = $(ESP_ROOT)/tools

# Search for sketch if not defined
SKETCH := $(realpath $(firstword  $(SKETCH) \
                         $(wildcard *.ino) \
                         $(ESP_LIBS)/ESP8266WebServer/examples/HelloServer/HelloServer.ino \
                       ) \
            )
ifeq ($(wildcard $(SKETCH)),)
  $(error Sketch $(SKETCH) not found)
endif
# Main output definitions
MAIN_NAME := $(basename $(notdir $(SKETCH)))
MAIN_EXE = $(BUILD_DIR)/$(MAIN_NAME).bin
FS_IMAGE = $(BUILD_DIR)/FS.spiffs

ifeq ($(OS), Windows_NT)
  # Adjust critical paths
  BUILD_DIR := $(shell cygpath -m $(BUILD_DIR))
  SKETCH := $(shell cygpath -m $(SKETCH))
endif

# Build file extensions
OBJ_EXT = .o
DEP_EXT = .d

# Special tool definitions
OTA_TOOL = $(TOOLS_ROOT)/espota.py
HTTP_TOOL = curl

# Core source files
CORE_DIR = $(ESP_ROOT)/cores/esp8266
CORE_SRC := $(shell find $(CORE_DIR) -name "*.S" -o -name "*.c" -o -name "*.cpp")
CORE_OBJ := $(patsubst %,$(BUILD_DIR)/%$(OBJ_EXT),$(notdir $(CORE_SRC)))
CORE_LIB = $(BUILD_DIR)/arduino.ar

# User defined compilation units and directories
ifeq ($(LIBS),)
  # Automatically find directories with header files used by the sketch
  LIBS := $(shell perl -e 'use File::Find;$$d = shift;while (<>) {$$f{"$$1"} = 1 if /^\s*\#include\s+[<"]([^>"]+)/;}find(sub {print $$File::Find::dir," " if $$f{$$_}}, $$d);'  $(ESP_LIBS) $(SKETCH))
  ifeq ($(LIBS),)
    # No dependencies found
    LIBS = /dev/null
  endif
endif

SKETCH_DIR = $(dir $(SKETCH))
USER_INC := $(shell find $(SKETCH_DIR) $(LIBS) -name "*.h")
USER_SRC := $(SKETCH) $(shell find $(SKETCH_DIR) $(LIBS) -name "*.S" -o -name "*.c" -o -name "*.cpp")
# Object file suffix seems to be significant for the linker...
USER_OBJ := $(subst .ino,.cpp,$(patsubst %,$(BUILD_DIR)/%$(OBJ_EXT),$(notdir $(USER_SRC))))
USER_DIRS := $(sort $(dir $(USER_SRC)))
USER_INC_DIRS := $(sort $(dir $(USER_INC)))

# Compilation directories and path
INCLUDE_DIRS += $(CORE_DIR) $(ESP_ROOT)/variants/$(INCLUDE_VARIANT) $(BUILD_DIR)
C_INCLUDES := $(foreach dir,$(INCLUDE_DIRS) $(USER_INC_DIRS),-I$(dir))
VPATH += $(shell find $(CORE_DIR) -type d) $(USER_DIRS)

# Automatically generated build information data
# Makes the build date and git descriptions at the actual build event available as string constants in the program
BUILD_INFO_H = $(BUILD_DIR)/buildinfo.h
BUILD_INFO_CPP = $(BUILD_DIR)/buildinfo.cpp
BUILD_INFO_OBJ = $(BUILD_INFO_CPP)$(OBJ_EXT)

$(BUILD_INFO_H): | $(BUILD_DIR)
    echo "typedef struct { const char *date, *time, *src_version, *env_version;} _tBuildInfo; extern _tBuildInfo _BuildInfo;" >$@

# Utility functions
git_description = $(shell git -C  $(1) describe --tags --always --dirty 2>/dev/null || echo Unknown)
time_string = $(shell date +$(1))

# The actual build commands are to be extracted from the Arduino description files
ARDUINO_MK = $(BUILD_DIR)/arduino.mk
ARDUINO_DESC := $(shell find $(ESP_ROOT) -maxdepth 1 -name "*.txt")
$(ARDUINO_MK): $(ARDUINO_DESC) $(MAKEFILE_LIST) | $(BUILD_DIR)
    perl -e "$$PARSE_ARDUINO" $(BOARD) $(FLASH_DEF) $(ARDUINO_DESC) >$(ARDUINO_MK)

-include $(ARDUINO_MK)

# Build rules
$(BUILD_DIR)/%.cpp$(OBJ_EXT): %.cpp $(BUILD_INFO_H) $(ARDUINO_MK)
    echo  $(<F)
    $(CPP_COM) $(CPP_EXTRA) $< -o $@

$(BUILD_DIR)/%.cpp$(OBJ_EXT): %.ino $(BUILD_INFO_H) $(ARDUINO_MK)
    echo  $(<F)
    $(CPP_COM) $(CPP_EXTRA) -x c++ -include $(CORE_DIR)/Arduino.h $< -o $@

$(BUILD_DIR)/%.c$(OBJ_EXT): %.c $(ARDUINO_MK)
    echo  $(<F)
    $(C_COM) $(C_EXTRA) $< -o $@

$(BUILD_DIR)/%.S$(OBJ_EXT): %.S $(ARDUINO_MK)
    echo  $(<F)
    $(S_COM) $(S_EXTRA) $< -o $@

$(CORE_LIB): $(CORE_OBJ)
    echo  Creating core archive
    rm -f $@
    $(AR_COM) $^

BUILD_DATE = $(call time_string,"%Y-%m-%d")
BUILD_TIME = $(call time_string,"%H:%M:%S")
SRC_GIT_VERSION := $(call git_description,$(dir $(SKETCH)))

$(MAIN_EXE): $(CORE_LIB) $(USER_OBJ)
    echo Linking $(MAIN_EXE)
    echo "  Versions: $(SRC_GIT_VERSION), $(ESP_ARDUINO_VERSION)"
    echo    '#include <buildinfo.h>' >$(BUILD_INFO_CPP)
    echo '_tBuildInfo _BuildInfo = {"$(BUILD_DATE)","$(BUILD_TIME)","$(SRC_GIT_VERSION)","$(ESP_ARDUINO_VERSION)"};' >>$(BUILD_INFO_CPP)
    $(CPP_COM) $(BUILD_INFO_CPP) -o $(BUILD_INFO_OBJ)
    $(LD_COM)
    $(ELF2BIN_COM)
    $(SIZE_COM) | perl -e "$$MEM_USAGE"
    perl -e 'print "Build complete. Elapsed time: ", time()-$(START_TIME),  " seconds\n\n"'

upload: all
    $(UPLOAD_COM)

ota: all
    $(OTA_TOOL) -i $(ESP_ADDR) -p $(ESP_PORT) -a $(ESP_PWD) -f $(MAIN_EXE)

http: all
    $(HTTP_TOOL) --verbose -F image=@$(MAIN_EXE) --user $(HTTP_USR):$(HTTP_PWD) http://$(HTTP_ADDR)$(HTTP_URI)
    echo "\n"

$(FS_IMAGE): $(wildcard $(FS_DIR)/*)
    echo Generating filesystem image...
    $(MKSPIFFS_COM)

fs: $(FS_IMAGE)

upload_fs: $(FS_IMAGE)
    $(FS_UPLOAD_COM)

clean:
    echo Removing all build files...
    rm  -rf $(BUILD_DIR)/*

list_lib:
    echo === User specific libraries ===
    perl -e 'foreach (@ARGV) {print "$$_\n"}' "* Include directories:" $(USER_INC_DIRS)  "* Library source files:" $(USER_SRC)

$(BUILD_DIR):
    mkdir -p $(BUILD_DIR)

.PHONY: all
all: $(BUILD_DIR) $(ARDUINO_MK) $(BUILD_INFO_H) prebuild $(MAIN_EXE)

prebuild:
ifdef USE_PREBUILD
    $(PREBUILD_COM)
endif

# Include all available dependencies
-include $(wildcard $(BUILD_DIR)/*$(DEP_EXT))

.DEFAULT_GOAL = all

ifndef SINGLE_THREAD
  # Use multithreaded builds by default
  MAKEFLAGS += -j
endif

ifndef VERBOSE
  # Set silent mode as default
  MAKEFLAGS += --silent
endif

# Inline Perl scripts

# Parse Arduino build commands from the descriptions
define PARSE_ARDUINO
my $$board = shift;
my $$flashSize = shift;
my %v;

$$v{'runtime.platform.path'} = '$$(ESP_ROOT)';
$$v{'includes'} = '$$(C_INCLUDES)';
$$v{'runtime.ide.version'} = '10605';
$$v{'build.arch'} = 'ESP8266';
$$v{'build.project_name'} = '$$(MAIN_NAME)';
$$v{'build.path'} = '$$(BUILD_DIR)';
$$v{'build.flash_freq'} = '$$(FLASH_SPEED)';
$$v{'object_files'} = '$$^ $$(BUILD_INFO_OBJ)';
$$v{'runtime.tools.xtensa-lx106-elf-gcc.path'} = '$$(COMP_PATH)';
$$v{'runtime.tools.esptool.path'} = '$$(ESPTOOL_PATH)';
$$v{'runtime.tools.mkspiffs.path'} = '$$(MKSPIFFS_PATH)';

foreach my $$fn (@ARGV) {
   open($$f, $$fn) || die "Failed to open: $$fn\n";
   while (<$$f>) {
      next unless /(\w[\w\-\.]+)=(.*)/;
      my ($$key, $$val) =($$1, $$2);
        $$board_defined = 1 if $$key eq "$$board.name";
      $$key =~ s/$$board\.menu\.FlashSize\.$$flashSize\.//;
        $$key =~ s/^$$board\.//;
      $$key =~ s/^tools\.esptool\.//;
      $$v{$$key} = $$val;
   }
   close($$f);
}
die "* Uknown board $$board\n" unless $$board_defined;
$$v{'build.flash_mode'} = '$$(FLASH_MODE)';
$$v{'build.f_cpu'} = '$$(F_CPU)';
$$v{'upload.verbose'} = '$$(UPLOAD_VERB)';
print "UPLOAD_RESET ?= $$v{'upload.resetmethod'}\n";
$$v{'upload.resetmethod'} = '$$(UPLOAD_RESET)';
print "UPLOAD_SPEED ?= $$v{'upload.speed'}\n";
$$v{'upload.speed'} = '$$(UPLOAD_SPEED)';
$$v{'serial.port'} = '$$(UPLOAD_PORT)';

foreach my $$key (sort keys %v) {
   while ($$v{$$key} =~/\{/) {
      $$v{$$key} =~ s/\{([\w\-\.]+)\}/$$v{$$1}/;
      $$v{$$key} =~ s/""//;
   }
   $$v{$$key} =~ s/ -o $$//;
   $$v{$$key} =~ s/(-D\w+=)"([^"]+)"/$$1\\"$$2\\"/g;
}

print "C_COM=$$v{'recipe.c.o.pattern'}\n";
print "CPP_COM=$$v{'recipe.cpp.o.pattern'}\n";
print "S_COM=$$v{'recipe.S.o.pattern'}\n";
print "AR_COM=$$v{'recipe.ar.pattern'}\n";
print "LD_COM=$$v{'recipe.c.combine.pattern'}\n";
print "ELF2BIN_COM=$$v{'recipe.objcopy.hex.pattern'}\n";
print "SIZE_COM=$$v{'recipe.size.pattern'}\n";
my $$flash_size = sprintf("0x%X", hex($$v{'build.spiffs_end'})-hex($$v{'build.spiffs_start'}));
print "MKSPIFFS_COM=$$v{'tools.mkspiffs.path'}/$$v{'tools.mkspiffs.cmd'} -b $$v{'build.spiffs_blocksize'} -s $$flash_size -c \$$(FS_DIR) \$$(FS_IMAGE)\n";
print "UPLOAD_COM=$$v{'upload.pattern'}\n";
my $$fs_upload_com = $$v{'upload.pattern'};
$$fs_upload_com =~ s/(.+ -ca) .+/$$1 $$v{'build.spiffs_start'} -cf \$$(FS_IMAGE)/;
print "FS_UPLOAD_COM=$$fs_upload_com\n";
my $$val = $$v{'recipe.hooks.core.prebuild.1.pattern'};
$$val =~ s/bash -c "(.+)"/$$1/;
$$val =~ s/(#define .+0x)(\`)/"\\$$1\"$$2/;
$$val =~ s/(\\)//;
print "PREBUILD_COM=$$val\n";
endef
export PARSE_ARDUINO

# Convert memory information
define MEM_USAGE
while (<>) {
  $$r += $$1 if /^\.(?:data|rodata|bss)\s+(\d+)/;
  $$f += $$1 if /^\.(?:irom0\.text|text|data|rodata)\s+(\d+)/;
}
print "\nMemory usage\n";
print sprintf("  %-6s %6d bytes\n" x 2 ."\n", "Ram:", $$r, "Flash:", $$f);
endef
export MEM_USAGE

Compiling for AT firmware OTA (user1.bin and user2.bin)

Is it possible to compile two binary files for the AT+CIUPDATE command?
http://espressif.com/sites/default/files/documentation/99c-esp8266_fota_guide_en_.pdf

To my knowledge the same object files are linked twice with different address offsets.

It would enable me to flash the Olimex MOD-WIFI-ESP8266 without changing the solder bridges. Would love to contribute this myself but I'm not a Makefile guru and haven't managed to get it running last night.

BTW the makefile worked out of the box, great work!

Can't compile .cpp and .c sketches

I have the following simple sketch:


//Pin declarations
static const uint8_t D0   = 16;
static const uint8_t D1   = 5;
static const uint8_t D2   = 4;
static const uint8_t D3   = 0;
static const uint8_t D4   = 2;
static const uint8_t D5   = 14;
static const uint8_t D6   = 12;
static const uint8_t D7   = 13;
static const uint8_t D8   = 15;
static const uint8_t D9   = 3;
static const uint8_t D10  = 1;

extern "C" {
#include "user_interface.h"
#include "ets_sys.h"
#include "osapi.h"
}
#include "Arduino.h" //include only when .c or .cpp
static uint8_t value = 0;
static uint8_t lastValue = 0;

void setup(){
    Serial.begin(115200);
    Serial.printf("Initializing pins ...\n");
    pinMode(D3, OUTPUT);
    pinMode(D5, OUTPUT);
    pinMode(D6, OUTPUT);
}
void loop() {
    lastValue = analogRead(A0);
    if (value > lastValue) {
        digitalWrite(D5, 1);
        delay(40);
        digitalWrite(D5, 0);
    }else if(value < lastValue){
        digitalWrite(D6, 1);
        delay(40);
        digitalWrite(D6, 0);
    }else if(value == lastValue){
        digitalWrite(D3, 1);
        delay(40);
        digitalWrite(D3, 0);
    }
    value = lastValue;
    Serial.println(value);
    delay(100);
}

If I save this sketch as analog.ino and then run espmake SKETCH=analog.ino then it compiles sucessfully. But if I chnge the extension to .cpp and then run espmake SKETCH=analog.cpp, I get
some linker errors:

CMakeFiles/3.6.2/CompilerIdCXX/CMakeCXXCompilerId.cpp:516: multiple definition of `main'
/cmake-build-debug/CMakeFiles/3.6.2/CompilerIdC/CMakeCCompilerId.c:542: first defined here
CMakeCXXCompilerId.cpp.o:(.data.info_arch+0x0): multiple definition of `info_arch'
CMakeCCompilerId.c.o:(.data.info_arch+0x0): first defined here
collect2: error: ld returned 1 exit status

WiFi firmware update support

Does the makefile support WiFi firmware upload?
It is much faster than the serial upload and also allows for automated updates.
The arduino WiFi upload works like a charm, and from what I gather it mostly uses external tools, so it should not be that hard to make it work on for makeEspArduino.

Question: How to set CPU frequency

Hi I am trying to set the cpu frequency to 160MHz instead of 80MHz.

Will setting F_CPU to 160000000l set the speed? The program uploads find but i'm not seeing anyway to verify the speed was actually set.

huzzah for BOARD defaults to 80MHz

# My makefile
LIBARAIES_DIR = $(HOME)/Documents/Arduino/libraries
SKETCH = $(LIBARAIES_DIR)/OpenBCI_Wifi/examples/DefaultBoard/DefaultBoard.ino
OPENBCI_WIFI_DIR = $(LIBARAIES_DIR)/OpenBCI_Wifi

UPLOAD_PORT = /dev/cu.usbserial-A104JV88
ESP_ROOT = $(HOME)/esp8266
ESP_LIBS = $(ESP_ROOT)/libraries

BOARD = huzzah

FLASH_DEF = 4M1M
F_CPU = 160000000l

LIBS = $(ESP_LIBS)/Wire $(ESP_LIBS)/ESP8266WiFi  $(ESP_LIBS)/DNSServer $(ESP_LIBS)/ESP8266SSDP $(ESP_LIBS)/ESP8266WebServer $(LIBARAIES_DIR)/WiFiManager $(ESP_LIBS)/SPISlave $(LIBARAIES_DIR)/ArduinoJson $(ESP_LIBS)/ESP8266mDNS $(ESP_LIBS)/ESP8266HTTPUpdateServer $(ESP_LIBS)/ArduinoOTA $(LIBARAIES_DIR)/PubSubClient $(LIBARAIES_DIR)/WebSockets $(ESP_LIBS)/Hash

EXCLUDE_DIRS = $(LIBARAIES_DIR)/ArduinoJson/test $(LIBARAIES_DIR)/ArduinoJson/third-party $(LIBARAIES_DIR)/ArduinoJson/fuzzing $(LIBARAIES_DIR)/WebSockets/examples $(LIBARAIES_DIR)/PubSubClient/tests

include $(HOME)/makeEspArduino/makeEspArduino.mk

add reset metod to esptool

to enable other reset methods I defined:

UPLOAD_RESET ?= nodemcu

and modified:

upload: all
$(ESP_TOOL) $(UPLOAD_VERB) -cd $(UPLOAD_RESET) -cb $(UPLOAD_SPEED) -cp $(UPLOAD_PORT) -ca 0x00000 -cf $(MAIN_EXE)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.