Git Product home page Git Product logo

makeesparduino's Introduction

makeEspArduino

A makefile for ESP8266 and ESP32 Arduino projects.

The main intent for this project is to provide a minimalistic yet powerful and easy configurable makefile for projects using the ESP/Arduino framework available at: https://github.com/esp8266/Arduino and https://github.com/espressif/arduino-esp32

Using make instead of the Arduino IDE makes it easier to do more production oriented builds of software projects.

This makefile gives you a command line tool for easy building and loading of the ESP/Arduino examples as well as your own projects.

The makefile can use the ESP/Arduino environment either from the installation within the Arduino IDE or in a separate git clone of the environment. The latter can be useful in project where you want stringent control of the environment version e.g. by using it as a git submodule.

You basically just have to specify your main sketch file and the libraries it uses. The libraries can be from arbitrary directories without any required specific hierarchy or any of the other restrictions which normally apply to builds made from within the Arduino IDE. The makefile will find all involved header and source files automatically. The search is made starting at the main sketch and the recursively continued through all #include statements that are found. All source files found in directories where include files were found will automatically be added to the build.

Rules for building the firmware as well as upload it to the ESP board are provided.

It is also possible to let the makefile generate and upload a complete flash file system based on an arbitrary directory of files.

The intention is to use the makefile as is. Possible specific configuration is done via via makefile variables supplied on the command line or in separate companion makefiles.

The makefile can be used on Linux, Mac OSX, Microsoft Windows (Cygwin or WSL) and OpenBSD.

The actual build commands (compile, link etc.) are extracted from the Arduino description files (platform.txt etc.).

Uploading of the built binary can be made via serial channel (esptool), ota (espota.py) or http (curl). Which method to use is controlled by makefile target selection. By default the serial channel is used.

Configuration files for Visual Studio Code can be generated by this makefile as well.

Installing

First make sure that you have the environment installed as described at: https://github.com/esp8266/Arduino

and

https://github.com/espressif/arduino-esp32

If you don't want to use the environment installed in the Arduino IDE, then you can clone it into a separate directory instead, see below.

Then start cloning the makeEspArduino repository.

cd ~
git clone https://github.com/plerup/makeEspArduino.git

After this you can test it. Attach your ESP8266 board and execute the following commands:

cd makeEspArduino
make -f makeEspArduino.mk DEMO=1 flash

The DEMO definition makes the the makefile choose a typical demo sketch from the ESP examples. After this you will have the example downloaded onto in your ESP.

If you want to use a clone of the ESP/Arduino environment instead, then do something like this for esp8266:

cd ~
git clone https://github.com/esp8266/Arduino.git esp8266
cd esp8266

Determine which version you want to use. See releases. Example:

git checkout tags/3.0.0

Then install the required environment tools by issuing the following commands:

git submodule update --init
cd tools
python3 get.py

Please note that you have to rerun the commands above if you checkout another label or branch in the git.

To test this installation you have to specify the location of the environment when running make

cd ~/makeEspArduino
make -f makeEspArduino.mk ESP_ROOT=~/esp8266 DEMO=1 flash

For ESP32 just change esp8266 in the commands above to esp32, i.e:

cd ~
git clone https://github.com/espressif/arduino-esp32.git  esp32
cd esp32
git submodule update --init
cd tools
python3 get.py

When building ESP32 projects the variable CHIP must always be defined, example:

make -f makeEspArduino.mk ESP_ROOT=~/esp32 CHIP=esp32 DEMO=1 flash

If you want to minimize your typing henceforth then there is a rule in the makefile which can be used to generate shortcut commands in /usr/local/bin. These commands are named espmake and espmake32. To achieve this when using a git clone type:

make -f makeEspArduino.mk ESP_ROOT=~/esp8266 install

make -f makeEspArduino.mk ESP_ROOT=~/esp32 CHIP=esp32 install

Sudo access will be required for this operation.

Getting help

A description of all available makefile functions and variables is always available via the following command:

make -f makeEspArduino.mk help

Building projects

You can now use the makefile to build your own sketches or any of the examples in the ESP/Arduino environment. The makefile will automatically search for a sketch in the current directory and build it if found. It is also possible to specify the location of the sketch on the command line.

Some examples

In current directory:

cd ~/.arduino15/packages/esp8266/hardware/esp8266/2.3.0/libraries/Ticker/examples/TickerBasic
espmake

Explicit naming of a default directory:

espmake -C ~/.arduino15/packages/esp8266/hardware/esp8266/2.3.0/libraries/Ticker/examples/TickerBasic

Explicit naming of the sketch:

espmake SKETCH=~/.arduino15/packages/esp8266/hardware/esp8266/2.3.0/libraries/Ticker/examples/TickerBasic/TickerBasic.ino
# Or like this
espmake SKETCH="\$(ESP_ROOT)/libraries/Ticker/examples/TickerBasic/TickerBasic.ino"

Advanced usage

The makefile has several variables which control the build. There are different ways to change the defaults of these variables.

The simplest and most direct way to do this is by specifying the variables and their values on the command line.

The more permanent way is to create a special makefile with the appropriate values for the variables and then include this in the build. This can be achieved either by including makeEspArduino.mk in this file or the other way around by letting makeEspArduino.mk include it. The advantage with the latter method is that the makefile doesn't need to know the location of makeEspArduino.mk, more about this in the examples below.

The most important variables in the makefile are listed below:

SKETCH is the path to the main source file. As stated above, if this is missing then makeEspArduino will try to locate it in the current directory.

LIBS is a variable which is used to specify your own additional library source or linker archive files. As stated above, makeEspArduino will do an automatic search for header files used by all involved source files in the build. This is achieved by checking for #include statements and for each found such statement, search for a corresponding existing header file anywhere in a list of directories. The search is started in the sketch source file and then recursively following any found file which in turn will be searched for new #include statements. By default this list contains all the directories underneath the ESP/Arduino libraries root and possible standard Arduino libraries, but the list can be extended using this variable.

This way you can specify an additional list of directories which contains header and/or source files that you want to be included in the build. The different entries in the list are separated with space. If an entry contains a path to a directory then that directory and all its sub directories will be included in the search list for header files. If a header file is found in that directory then all source files (*.cpp, *.c, *.S) also found there will be added to the build. This is due to the fact that there is not always a one-to-one relationship between a header file name and the corresponding implementation source file.

It is also possible to specify an explicit source file or a wildcard in a list entry. In that case only the source files matching this will be added and the corresponding directory will added to the header file directory search list.

Library files (.a or .lib) can also be specified here and these will be added to the linker command.

If the sketch is located in an /example/ directory the possible corresponding /src/ directory will automatically be added to the directory search list.

Example:

LIBS = $(MY_ROOT)/lib1 $(MY_ROOT)/lib2/my_file.cpp $(MY_ROOT)/lib3/*.c $(MY_ROOT)/lib3/my_lib.a

You can always use the rule list_lib to check what include directories and source files that was found during the search.

The automatic search for used files via included header files does not work if the corresponding implementation source file are located in another directory than the header file. If you have problem with this, you can set the variable EXPAND_LIBS and then all source files in the directories specified via the LIBS variable will be added to the build. This may lead to compiling unnecessary files though.

If you for some reason want to exclude some sub directories from the search list you can specify this using the variable EXCLUDE_DIRS. The value is interpreted a regular expressions so multiple directories must be separated with | .

CHIP Set to either esp8266 (default) or esp32

BOARD The type of ESP8266 or ESP32 board you are using, use the rule list_boards to show what's available

BUILD_DIR All intermediate build files (object, map files etc.) are stored in a separate directory controlled by this variable. By default this is set to a name consisting of the project and board names. This is just the directory name, the root of this directory is controlled by the variable BUILD_ROOT. Default for this is /tmp/mkESP but it can be set to a non-temporary location if so is desired.

BUILD_EXTRA_FLAGS this variable can be setup to add additional parameters for the compilation commands. It will be placed last and thereby it is possible to override the preceding default ones.

It is also possible to set file specific compilation parameters by defining a variable which starts with the name of the actual source file followed by the string _CFLAGS. Example:

my_class.cpp_CFLAGS = -DOPTION=1

In this case the parameter -DOPTION=1 will be applied when compiling the file m_class.cpp. Please note that just the file name, not the path, should be used.

There are some other important variables which corresponds to the settings which you normally do in the "Tools" menu in the Arduino IDE. The makefile will parse the Arduino IDE configuration files and use the same defaults as you would get when after selecting a board in the "Tools" menu.

The result of the parsing is stored as variables in a separate intermediate makefile named 'arduino.mk' in the directory defined by the variable BUILD_DIR. Look into this file if you need to control even more detailed settings variables.

VERBOSE Define this variable if you want to trace all the executed operations in the build

As stated above you can always get a description of all makefile operations, configuration variables and their default values via the 'help' function

espmake help
Build time and version information

makeESPArduino will also automatically produce header and c files which contain information about the time when the build (link) was performed. This file also includes the git descriptions (tag) of the used version of the ESP/Arduino environment and the project source (when applicable). This can be used by the project source files to provide stringent version information from within the software. The information is put into a global struct variable named "_BuildInfo" with the following string constant fields:

Name Value
src_version Source code git version
date Build date
time Build time
env_version ESP Arduino version
Including the makefile

The easiest way to control the makefile is by defining the desired values of the control variables in your own makefile and then include makeEspArduino.mk. Example:

# My makefile
SKETCH = $(ESP_ROOT)/libraries/Ticker/examples/TickerBasic/TickerBasic.ino

UPLOAD_PORT = /dev/ttyUSB1
BOARD = esp210

include $(HOME)/makeEspArduino/makeEspArduino.mk

Another possibility is to do this the other way around, i.e. let makeEspArduino include your makefile instead. This can be achieved by naming your makefile "config.mk". makeEspArduino will always check for a file with this name in the current directory or in the same directory as the sketch. If you want to use another name for your makefile you can specify this via the variable PROJ_CONF on the command line. Example of such a makefile:

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

UPLOAD_SPEED = 115200

It is of course also always possible to control the variable values in the makefile by defining them as environment variables in the shell. Example:

export UPLOAD_PORT=/dev/ttyUSB2

A global config file which will apply to all builds can also be defined. The name of this file is also "config.mk". The location of this file can be defined via the variable MAKEESPARDUINO_CONFIGS_ROOT The default value is the OS specific standard config directory, i.e.

Linux:  $(HOME)/.config/makeEspArduino (or $(XDG_CONFIG_HOME)/makeEspArduino)
Mac:    $(HOME)/Library/makeEspArduino
CygWin: $(LOCALAPPDATA)/makeEspArduino

Please note that the local config file can always override definitions in the global one.

Flash operations for esp8266

Recent versions of esp8266 and esp32 Arduino includes the esptool Python script for flashing operations. This script is stored in the tools subdirectory of the repo structure. For esp8266 a Python3 executable (or symblink) is also included here. These are used by makeEspArduino during the build. A special wrapper script is used to avoid the need for explicit installation of the Python modules.

Esptool does however depend on the pyserial module which is also included in the tools directory for esp8266. This is (currently) not the case for esp32 so here you have to install it manually in your system via

pip3 install pyserial

The used serial port for the flashing operations is controlled by the variable UPLOAD_PORT. If not explicitly specified then makeEspArduino tries to find a suitable one. The pattern used for this search is depending on the actual operating system.

The baud rate used is controlled by the variable UPLOAD_SPEED. The maximum possible speed may vary between boards and operations. The default is taken from the first value in the board definition and is usually quite low. You can normally increase this but the maximum speed 921600 may or may not work. You have to test out the maximum possible value for your board. The typical error message for too high speed is:

Invalid head of packet

Building a file system

There are also rules in the makefile which can be used for building and uploading a complete flash file system to the ESP. This is basically the same functionality as the one available in the Arduino IDE, https://github.com/esp8266/Arduino/blob/master/doc/filesystem.rst#uploading-files-to-file-system

Both SPIFFS and LittleFS file systems are supported and which type to use is specified via the FS_TYPE variable.

The size and flash location parameters are taken from boards.txt for esp8266 and from the partition table for esp32.

The file system content is made up of everything within a directory specified via the variable FS_DIR. By default this variable is set to a subdirectory named data in the sketch directory.

Use the rule flash_fs or ota_fs to generate a file system image and upload it to the ESP.

All the settings for the file system are taken from the selected board's configuration.

It is also possible to dump and recreate the complete file system from the device via the rule dump_fs. The corresponding flash section will be extracted and the individual files recreated in a directory in the build structure.

Specifying custom partition schemes

You may wish to specify a custom partitioning table, as defined in the ESP32 docs. You can do this by changing the PART_FILE variable in your make file. By default $(ESP_ROOT)/tools/partitions/default.csv will be used.

Additional flash I/O operations

The makefile has rules for dumping and restoring the whole flash memory contents to and from a file. This can be convenient for saving a specific state or software for which no source code is available.

The rules are named dump_flash and restore_flash. The name of the output/input file is controlled by the variable FLASH_FILE. The default value for this is "esp_flash.bin". All required parameters for the operations are taken from the variables mentioned above for flash size, serial port and speed etc.

Example:

espmake dump_flash FLASH_FILE=my_flash.bin

Building an object file library

It is also possible to build a library containing all the object files referenced in the build (excluding the sketch itself). This can e.g. be used to build separately compiled version controlled libraries which are then used in other build projects.

Example:

espmake lib

Monitor

makeEspArduino also has a monitor function, i.e. connecting a terminal program to the esp board serial port. By default it will use the miniterm tool of the Python serial package. This can however be changed to any other terminal emulation program via the variable MONITOR_COM

The used port is by default same as the upload port and the default baud rate is 115200.

The run rule of the makefile will do a combined flash and monitor operation.

Misc build features

Using ccache

If you want to speed up your builds with makeEspArduino you can install ccache on your system, https://ccache.dev/

Once installed makeEspArduino will automatically use if during the build by preceding all C and C++ compilation commands with ccache.

In case you have ccache installed but don't want to use it for the build, you can set the variable USE_CCACHE=0

Cross compilation

If you want some other prefix to the C compiler command line the following variables are available: C_COM_PREFIX and CPP_COM_PREFIX

Parallel builds

The actual make operation is performed using parallel build compilation threads. By default all the cores of the machine is used. You can however limit the number of compilation threads started by setting the BUILD_THREADS variable to a desired alternate number.

Automatic rebuild

A record of the command line parameters and git versions used in the last build is stored in the build directory. If any of these are changed during the next build, e.g. changing a variable definition, a complete rebuild is made in order to ensure that all possible changes are applied. If you don't want this function just define the variable IGNORE_STATE.

Intermediate object archive

By default all object files are put into an archive as this seems to enable the linker to remove 5 kB RAM of unused variables. This is the same method that is used by the Arduino IDE. Unfortunately this might break some builds i.g. if some special linker flags are used. To disable this feature set the NO_USER_OBJ_LIB to 1.

User defined make rules

makeEspArduino has make rules for all the type of input files that are normally part of a build of Arduino for esp. If you want to add other type of files there are two variables which can be used for this purpose.

USER_SRC_PATTERN Files matching this pattern will be included in the automatic search for source files. Must be prefixed with a "|". Example:

USER_SRC_PATTERN = |my_ext

USER_RULES This variable is used to define the path to a makefile which contains the actual make rules for the user specific source files. Example of contents for such a file:

$(BUILD_DIR)/%.my_ext.o: %.my_ext
  echo Running my make rule for $<
  my_command $<

Setting used version of ESP Arduino

The rule set_git_version can be used to control which version tag to be used in the git repo specified via ESP_ROOT. It will perform the necessary git and copy operations to ensure that the repo is setup correctly for the tag specified via the variable REQ_GIT_VERSION. Example:

espmake set_git_version REQ_GIT_VERSION=2.6.3

Using Visual Studio Code

Visual Studio Code is a great editor which can be used together with makeEspArduino. The makefile contains a rule named "vscode". When invoked it will generate a config file for the C/C++ addin. This will contain all the required definitions for the IntelliSense function. The information is based on the parameters of the c/c++ compilation command.

It will also generate contents in the "tasks" configuration file which enables building with makeEspArduino from within the editor. This is convenient for stepping through compilation errors for instance.

The configuration files will have settings with the name of the main sketch.

The workspace directory for the settings files will be ".vscode" and this can either be automatically detected by makeEspArduino or be specified via the variable VS_CODE_DIR. Automatic here means checking the parent directories of the sketch for a config directory and if doesn't exist then the sketch directory itself will be used and created if not found. If an existing project file (*.code-workspace) is found in that directory it will be used as input for the launch of VS Code.

After generating the configuration files makeEspArduino will launch Visual Studio (if available in the path)

Crash analysis

The rule crash will enable you to paste the output of a program crash for esp8266 or esp32. Explanatory reason and call stack traceback will be listed with source file and line number for each call found.

Compiler preprocessor

Sometimes it can be useful to see the actual full source file content once all include files and macros have been expanded. The rule preproc is available for this purpose. The path of the source file to be analyzed is specified via the variable SRC_FILE. Example:

espmake preproc SRC_FILE=my_file.ino

Memory usage analysis

There are two rules which can be used for analyzing the memory usage of a build.

ram_usage will show the names of the variables in ram together with their size sorted in descending size order

obj_info will show the flash and RAM memory usage for each individual object file. The different portions of the RAM usage will also be shown. A listing is produced with columns for the different values. The listing is formated by space separated constant width fields but this can be change to tab separated instead by defining the variable OBJ_INFO_FORM to 1. The listing is by default sorted by descending RAM values but this can be also be changed by defining the variable OBJ_INFO_SORT to a value between 0 and 4.

Operating system specifics

makeEspArduino is intended to work completely on all the operating systems specified above. All the required specific setting for the actual operating system is stored in separate makefiles in the sub director /os.

Please note that Cygwin have some special considerations as most executed commands expect Windows notations, e.g. COMx for serial port specification. All paths should also be given in the forward slash format.

Newer versions of Mac OS Big Sur don't work with the pyserial version included in older versions of esp 8266 Arduino. This can be fixed by installing pyserial as described earlier and then set the variable NO_PY_WRAP=1

If your project have additional specific requirements you can add them under conditional statements of $(OS) in your project makefiles

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

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?

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.

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!

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.

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))

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

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?

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.

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 '

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.... 

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++

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)

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 ?

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)

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.

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>

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?

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.

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 ?

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

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....

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.

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?

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

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.

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...

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!

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

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.

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

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.

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...

`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.

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.

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..

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?

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.

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

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.

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.

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.

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.

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.

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

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

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

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

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?

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.