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

User avatar
By kelsayed
#16545 I can compile node-mcu
I can compile blinky, interrupt_example
However, none of the examples in ESP8266_SDK/examples like IoT_Demo or at can be compiled: I get the following

Code: Select allmake
../../Makefile:151: warning: overriding commands for target `clean'
../Makefile:258: warning: ignoring old commands for target `clean'
You cloned without --recursive, fetching submodules for you.
git submodule update --init --recursive
make -C crosstool-NG -f ../Makefile _ct-ng
make: *** crosstool-NG: No such file or directory.  Stop.
make: *** [crosstool-NG/ct-ng] Error 2


Why is that thing trying to go to the crosstool again and build it. Why that very complex makefile structure and going up again one level up and trying to so things there???
It just needs to go the source files in the usr include and so on and just compile them using the xtensa toolchain that is already there and produce the bin images.

I am not expert in makefile, but was anyone able to compile the IoT_Demo code?
User avatar
By kelsayed
#16551
kelsayed wrote:Why is that thing trying to go to the crosstool again and build it. Why that very complex makefile structure and going up again one level up and trying to so things there???
It just needs to go the source files in the usr include and so on and just compile them using the xtensa toolchain that is already there and produce the bin images.

I am not expert in makefile, but was anyone able to compile the IoT_Demo code?


I was able to use the sample makefile from https://github.com/pfalcon/esp-open-sdk/issues/6
to compile th IoTDemo on SDK esp_iot_sdk_v0.9.5_15_01_23
Here is it. Make sure your makefile lines in lines with $(CC) esptool and so on are preceded by tabs not spaces.

Code: Select allCC = xtensa-lx106-elf-gcc
CFLAGS = -Os -Iinclude -mlongcalls -DICACHE_FLASH
LDLIBS = -nostdlib -Wl,--start-group -lmain -lupgrade -lnet80211 -lwpa -llwip -lpp -lphy -Wl,--end-group -ljson -lcirom -lgcc
LDFLAGS = -Teagle.app.v6.ld

iot-demo-0x00000.bin: iot-demo
   esptool.py  elf2image $^

iot-demo: user/user_devicefind.o \
   user/user_esp_platform.o \
   user/user_esp_platform_timer.o \
   user/user_json.o \
   user/user_light.o \
   user/user_main.o \
   user/user_plug.o \
   user/user_sensor.o \
   user/user_webserver.o \
   driver/gpio16.o \
   driver/i2c_master.o \
   driver/key.o \
   driver/pwm.o \
   driver/spi.o \
   driver/uart.o
   $(CC) $(LDFLAGS) $^ -o $@ $(LDLIBS)

flash: iot-demo-0x00000.bin
   esptool.py write_flash 0 iot-demo-0x00000.bin 0x40000 iot-demo-0x40000.bin

connect:
   picocom -b 115200 --omap crcrlf /dev/ttyUSB0



User avatar
By eriksl
#16763 Regarding the esptool "issue". It's not included in the sdk, also iirc the source isn't even available. Simple solution: use esptool.py, it also knows how to make image files and is included in the sdk. It beeds a small change to the Makefile though.
User avatar
By cchuter
#23511 Thanks to @kelsayed, I was able to make a Makefileto build the IotDemo that works with the latest sdk as of this post (esp_iot_sdk_v1.2.0). Espressif moved a lot around, removed the pwm source, and did some other random things.

Here it is, if anyone wants it. Replace the Espressif broken Makefile and remember to change spaces to tabs if you cut and paste.

Code: Select allCC = xtensa-lx106-elf-gcc
CFLAGS = -Os -Iinclude -mlongcalls -DICACHE_FLASH
LDLIBS = -nostdlib -Wl,--start-group -lmain -lupgrade -lnet80211 -lpwm -lwpa -llwip -lpp -lphy -Wl,--end-group -ljson -lcirom -lgcc
LDFLAGS = -Teagle.app.v6.ld
INCLUDES = -Iinclude -I../driver_lib/include

iot-demo-0x00000.bin: iot-demo
        esptool.py  elf2image $^

iot-demo: user/user_devicefind.o \
   user/user_light.o \
   user/user_light_adj.o \
   user/user_esp_platform.o \
   user/user_esp_platform_timer.o \
   user/user_json.o \
   user/user_main.o \
   user/user_plug.o \
   user/user_sensor.o \
   user/user_webserver.o \
   ../driver_lib/driver/gpio16.c \
   ../driver_lib/driver/hw_timer.c \
   ../driver_lib/driver/i2c_master.c \
   ../driver_lib/driver/key.c \
   ../driver_lib/driver/spi.c \
   ../driver_lib/driver/spi_overlap.c \
   ../driver_lib/driver/uart.c
        $(CC) $(CFLAGS) $(INCLUDES) $(LDFLAGS) $^ -o $@ $(LDLIBS)

flash: iot-demo-0x00000.bin
        esptool.py write_flash 0 iot-demo-0x00000.bin 0x40000 iot-demo-0x40000.bin

connect:
        picocom -b 115200 --omap crcrlf /dev/ttyUSB0