Discuss here different C compiler set ups, and compiling executables for the ESP8266

User avatar
By MrDeenis
#57772 Hello guys,

So, I've found a lot of different Makefiles for compiling, flashing and cleaning with the Espressif SDK. However, none of these seem to work for me (always errors, that lead to new errors, until stuck), and (from a newbie's perspective) they look overly engineered. So I decided to read up and try out some things on my own, to make a simple Makefile that I understand myself.

What I have managed so far, is to make this:

Code: Select all# base directory for the compiler
XTENSA_TOOLS_ROOT ?= /Volumes/case-sensitive/esp-open-sdk/xtensa-lx106-elf/bin
 
# base directory of the ESP8266 SDK package, absolute
SDK_BASE    ?= /Volumes/case-sensitive/esp-open-sdk/ESP8266_NONOS_SDK_V1.5.4_16_05_20
 
CC      := $(XTENSA_TOOLS_ROOT)/xtensa-lx106-elf-gcc
CXX     := $(XTENSA_TOOLS_ROOT)/xtensa-lx106-elf-g++
AR      := $(XTENSA_TOOLS_ROOT)/xtensa-lx106-elf-ar
LD      := $(XTENSA_TOOLS_ROOT)/xtensa-lx106-elf-gcc
 
# esptool.py path and port
ESPTOOL     ?= /Volumes/case-sensitive/esp-open-sdk/xtensa-lx106-elf/bin/esptool.py
ESPPORT     ?= /dev/cu.usbserial-AH03LOFU
 
# name for the target project
TARGET      = client
 
CFLAGS = -I. -mlongcalls
LDLIBS = -nostdlib -Wl,--start-group -lmain -lnet80211 -lwpa -llwip -lpp -lphy -Wl,--end-group -lgcc
LDFLAGS = -Teagle.app.v6.ld
 
 
$(TARGET)-0x00000.bin: $(TARGET)
    $(ESPTOOL) elf2image $^
 
$(TARGET): station.o $(TARGET).o
 
$(TARGET).o: *.c
 
flash:
    $(ESPTOOL) --port $(ESPPORT) write_flash 0x00000 $(TARGET)-0x00000.bin 0x40000 $(TARGET)-0x40000.bin
 
clean:
    rm -f $(TARGET) $(TARGET).o $(TARGET)-0x00000.bin $(TARGET)-0x40000.bin station.o


http://pastebin.com/PDssVbGv

Which seems to work just fine. However, two things that I've spend hours on, and still cannot implement:
* Put my include files into a include folder, and make the Makefile automatic include these (right now, my include files are in the same folder as the main file, and I manually have to define them in my Makefile).
* Support for C++ compiling (I might be wrong about this, but it should be possible to compile C++, right?)

Additional information: I'm using OSX, and my simple project only consist of a main client.c file, and station.c.

Thank you for your time.
User avatar
By MrDeenis
#57800 Update:
I've tried with all makefiles I can find, however, I got far with this one:
https://raw.githubusercontent.com/esp82 ... e.Makefile

Until next error:
Code: Select all/Volumes/case-sensitive/esp-open-sdk/ESP8266_NONOS_SDK_V1.5.4_16_05_20/lib/libmain.a(app_main.o): In function `user_uart_wait_tx_fifo_empty':
(.irom0.text+0x5d0): undefined reference to `user_init'
/Volumes/case-sensitive/esp-open-sdk/ESP8266_NONOS_SDK_V1.5.4_16_05_20/lib/libmain.a(app_main.o): In function `user_rf_pre_init':
(.irom0.text+0x8bb): undefined reference to `user_init'
collect2: error: ld returned 1 exit status


Well .... Now what ..