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

User avatar
By iHaveESP
#9601 @ ByCHERTS

Many thanks for putting this all together, it's working great. I was using "esp-open-sdk"; that worked fine but I got tired of messing with Makefile.

My projects are using "tuanpmt" great MQTT implementation https://github.com/tuanpmt/esp_mqtt

With so many code bases out there and different make files, this sdk is easy to adopt to them.

I've attached a working Makefile for "esp_mqtt".

-Cheers!
You do not have the required permissions to view the files attached to this post.
User avatar
By BarryP
#9605 Howdy,
I would like to add functionality to the dhcpserver .
After a lot of messing around , I managed to get lwip compiling with a project & not using the liblwip .
BUT , it doesn't work properly when loaded into the modules.
Logs report it connecting to an AP successfully then I get
Code: Select all14:53:08.630 connected with Barry, channel 13
14:53:08.634 dhcp client start...
14:53:09.415 ip:192.168.1.137,mask:255.255.255.0,gw:192.168.1.1
14:53:10.125 LmacRxBlk:1
14:53:11.125 LmacRxBlk:1
14:53:12.125 LmacRxBlk:1
14:53:12.240 beacon timeout
14:53:12.243 rm match
14:53:12.246 pm close 7 0 0/3666632
14:53:13.125 LmacRxBlk:1
14:53:14.125 LmacRxBlk:1
14:53:14.366 scandone
14:53:14.369 no Barry found, reconnect after 1s
14:53:15.125 LmacRxBlk:1
14:53:15.366 reconnect
14:53:16.125 LmacRxBlk:1
14:53:17.126 LmacRxBlk:1
14:53:17.492 scandone
14:53:17.494 no Barry found, reconnect after 1s
14:53:18.126 LmacRxBlk:1
14:53:18.492 reconnect
14:53:19.126 LmacRxBlk:1
14:53:20.127 LmacRxBlk:1
14:53:20.618 scandone
14:53:20.621 no Barry found, reconnect after 1s

etc ....

I believe the LmacRxBlk entries are generated from functions in libpp but I don't have the code for that .
Has anyone got lwip compiling & working with the DevKit ?
User avatar
By kadamski
#9619 Your messages looks like you did something wrong with regards to lwip ABI compatibility with SDK. I guess you changed something in LWIP code or configuration? You should first try to get unmodified lwip working, then change it.

You can take a look at my https://github.com/kadamski/esp-lwip I haven't tried compiling it on Windows but it has very simple Makefile so it should be quite easy to adopt (and patches/instructions for that are welcome). Maybe that will help?
User avatar
By BarryP
#9668 Brilliant !! Thanks .
Got it working in eclipse .. Ye Ha !
Here is my modified Makefile .
Code: Select allXTENSA_TOOLS_ROOT    ?= c:/Espressif/xtensa-lx106-elf/bin
SDK_BASE         ?= c:/Espressif/ESP8266_SDK
SDK_INCDIR         = include
# I use a separate DIR for the includes that are not part of the official SDK
USER_INC_BASE      ?= C:/Espressif/ThirdParty/include

CC      := $(XTENSA_TOOLS_ROOT)/xtensa-lx106-elf-gcc
AR      := $(XTENSA_TOOLS_ROOT)/xtensa-lx106-elf-ar
OBJCOPY := $(XTENSA_TOOLS_ROOT)/xtensa-lx106-elf-objcopy



SDK_LIB_DIR ?= $(SDK_BASE)/lib

SDK_INCDIR   := $(addprefix -I$(SDK_BASE)/,$(SDK_INCDIR))

# The dir structuredoesn't play nice with eclipse so added -Isrc/include/ipv4/
CFLAGS = -Os -mlongcalls -Isrc/include/ipv4/ -Isrc/include/ -Iconfig/ -Iespressif/include/

CFLAGS += -DLWIP_OPEN_SRC
CFLAGS += -D__ets__

OBJS = \
src/api/api_lib.o \
src/api/api_msg.o \
src/api/err.o \
src/api/netbuf.o \
src/api/netdb.o \
src/api/netifapi.o \
src/api/sockets.o \
src/api/tcpip.o \
src/core/ipv4/autoip.o \
src/core/ipv4/icmp.o \
src/core/ipv4/igmp.o \
src/core/ipv4/inet.o \
src/core/ipv4/inet_chksum.o \
src/core/ipv4/ip.o \
src/core/ipv4/ip_addr.o \
src/core/ipv4/ip_frag.o \
src/core/dhcp.o \
src/core/dns.o \
src/core/def.o \
src/core/init.o \
src/core/netif.o \
src/core/mem.o \
src/core/memp.o \
src/core/pbuf.o \
src/core/raw.o \
src/core/stats.o \
src/core/sys.o \
src/core/tcp.o \
src/core/tcp_in.o \
src/core/tcp_out.o \
src/core/timers.o \
src/core/udp.o \
src/netif/etharp.o \
espressif/espconn.o \
espressif/espconn_tcp.o \
espressif/espconn_udp.o \
espressif/sys_arch.o \
espressif/netio.o \
espressif/dhcpserver.o \
espressif/ping.o \

.PHONY: all remove_user_includes copy_liblwip_to_sdk_lib_dir make_user_inc_dirs copy_includes_to_user_inc_dir

%.o: %.c
   $(CC) -c  $(SDK_INCDIR) $(CFLAGS) -o $@ $<
   $(OBJCOPY) --rename-section .text=.irom0.text --rename-section .literal=.irom0.literal $@

all: liblwip.a copy_liblwip_to_sdk_lib_dir

liblwip.a: $(OBJS)
   $(AR) rcs liblwip.a $(OBJS)
   
copy_liblwip_to_sdk_lib_dir:
   cp liblwip.a $(SDK_LIB_DIR)

make_user_inc_dirs:
   -mkdir $(USER_INC_BASE)/pp
   -mkdir $(USER_INC_BASE)/netif
   -mkdir $(USER_INC_BASE)/arch
   -mkdir $(USER_INC_BASE)/lwip
   -mkdir $(USER_INC_BASE)/lwip/app
   
copy_includes_to_user_inc_dir: make_user_inc_dirs
   cp ./src/include/ipv4/lwip/*.* $(USER_INC_BASE)/lwip/
   cp ./src/include/lwip/*.* $(USER_INC_BASE)/lwip/
   cp ./espressif/include/lwip/app/*.* $(USER_INC_BASE)/lwip/app/
   cp ./src/include/netif/*.* $(USER_INC_BASE)/netif/   
   cp ./espressif/include/arch/*.* $(USER_INC_BASE)/arch/
   cp ./espressif/include/pp/*.* $(USER_INC_BASE)/pp/

   
#-Isrc/include/ -Iconfig/ -Iespressif/include/
   
remove_user_includes:
   rm -rf $(USER_INC_BASE)/pp
   rm -rf $(USER_INC_BASE)/netif
   rm -rf $(USER_INC_BASE)/arch
   rm -rf $(USER_INC_BASE)/lwip/app
   rm -rf $(USER_INC_BASE)/lwip
   
clean:
   rm $(OBJS) liblwip.a