ESP8266 Webserver Project

Moderator: Sprite_tm

User avatar
By Stefan Ravn
#53789 Hi
I'm currently using esp-open-rtos for my project.
I would like to add a webserver and have been looking at libesphttpd which seems really promising. I do however have some trouble with getting libesphttpd to compile using esp-open-rtos. Preferably i would like to compile it as an "extra" component. My current attempt at an component.mk file is as follows:

Code: Select all# Component makefile for extras/libesphttpd

libesphttpd_CFLAGS += "-std=gnu99"
libesphttpd_CFLAGS += "-ggdb"
libesphttpd_CFLAGS += "-Werror"
libesphttpd_CFLAGS += "-Wpointer-arith"
libesphttpd_CFLAGS += "-Wundef"
libesphttpd_CFLAGS += "-Wall"
libesphttpd_CFLAGS += "-Wl,-EL"
libesphttpd_CFLAGS += "-fno-inline-functions"
libesphttpd_CFLAGS += "-nostdlib"
libesphttpd_CFLAGS += "-mlongcalls"
libesphttpd_CFLAGS += "-mtext-section-literals"
libesphttpd_CFLAGS += "-D__ets__"
libesphttpd_CFLAGS += "-DICACHE_FLASH"
libesphttpd_CFLAGS += "-DHTTPD_MAX_CONNECTIONS=4"
libesphttpd_CFLAGS += "-DHTTPD_STACKSIZE=2048"
libesphttpd_CFLAGS += "-DUSE_OPENSDK"
libesphttpd_CFLAGS += "-Wno-address"
libesphttpd_CFLAGS += "-DESPFS_HEATSHRINK"
libesphttpd_CFLAGS += "-DHTTPD_WEBSOCKETS"
libesphttpd_CFLAGS += "-DDEBUG=1"
libesphttpd_CFLAGS += "-DICACHE_FLASH_ATTR=__attribute__((section(\".irom0.text\")))"
libesphttpd_CFLAGS += "-DUSE_OPENSDK"


#INC_DIRS += $(libesphttpd_ROOT)include
#INC_DIRS += $(libesphttpd_ROOT)espfs
#INC_DIRS += $(libesphttpd_ROOT)core
#INC_DIRS += $(libesphttpd_ROOT)util
#INC_DIRS += $(libesphttpd_ROOT)espfs/include
#INC_DIRS += $(libesphttpd_ROOT)core/include
#INC_DIRS += $(libesphttpd_ROOT)util/include
#INC_DIRS += $(libesphttpd_ROOT)lib/heatshrink
libesphttpd_INC_DIR = /opt/Espressif/ESP8266_SDK/include
libesphttpd_INC_DIR += $(libesphttpd_ROOT)include
libesphttpd_INC_DIR += $(libesphttpd_ROOT)espfs
libesphttpd_INC_DIR += $(libesphttpd_ROOT)core
libesphttpd_INC_DIR += $(libesphttpd_ROOT)util
libesphttpd_INC_DIR += $(libesphttpd_ROOT)espfs/include
libesphttpd_INC_DIR += $(libesphttpd_ROOT)core/include
libesphttpd_INC_DIR += $(libesphttpd_ROOT)util/include
libesphttpd_INC_DIR += $(libesphttpd_ROOT)lib/heatshrink


# args for passing into compile rule generation

libesphttpd_SRC_DIR = $(libesphttpd_ROOT)espfs
libesphttpd_SRC_DIR += $(libesphttpd_ROOT)core
libesphttpd_SRC_DIR += $(libesphttpd_ROOT)util
libesphttpd_SRC_DIR += $(libesphttpd_ROOT)lib/heatshrink

$(eval $(call component_compile_rules,libesphttpd))



I currently get the following error when compiling a project which includes the libesphttpd module

Code: Select allCC /home/stefan/esp-open-rtos/extras/libesphttpd/espfs/espfs.c
/home/stefan/esp-open-rtos/extras/libesphttpd/espfs/espfs.c: In function 'espFsInit':
/home/stefan/esp-open-rtos/extras/libesphttpd/espfs/espfs.c:89:2: error: implicit declaration of function 'spi_flash_read' [-Werror=implicit-function-declaration]
  spi_flash_read((uint32)flashAddress, (uint32*)&testHeader, sizeof(EspFsHeader));
  ^
/home/stefan/esp-open-rtos/extras/libesphttpd/espfs/espfs.c:89:18: error: 'uint32' undeclared (first use in this function)
  spi_flash_read((uint32)flashAddress, (uint32*)&testHeader, sizeof(EspFsHeader));
                  ^
/home/stefan/esp-open-rtos/extras/libesphttpd/espfs/espfs.c:89:18: note: each undeclared identifier is reported only once for each function it appears in
/home/stefan/esp-open-rtos/extras/libesphttpd/espfs/espfs.c:89:25: error: expected ')' before 'flashAddress'
  spi_flash_read((uint32)flashAddress, (uint32*)&testHeader, sizeof(EspFsHeader));
                         ^
/home/stefan/esp-open-rtos/extras/libesphttpd/espfs/espfs.c: In function 'readFlashUnaligned':
/home/stefan/esp-open-rtos/extras/libesphttpd/espfs/espfs.c:108:18: error: 'uint32' undeclared (first use in this function)
  spi_flash_read((uint32)src_address, (uint32*)tmp_buf, len+src_offset);
                  ^
/home/stefan/esp-open-rtos/extras/libesphttpd/espfs/espfs.c:108:25: error: expected ')' before 'src_address'
  spi_flash_read((uint32)src_address, (uint32*)tmp_buf, len+src_offset);
                         ^
/home/stefan/esp-open-rtos/extras/libesphttpd/espfs/espfs.c:109:2: error: implicit declaration of function 'memcpy' [-Werror=implicit-function-declaration]
  memcpy(dst, ((uint8_t*)tmp_buf)+src_offset, len);
  ^
/home/stefan/esp-open-rtos/extras/libesphttpd/espfs/espfs.c:109:2: error: incompatible implicit declaration of built-in function 'memcpy' [-Werror]
/home/stefan/esp-open-rtos/extras/libesphttpd/espfs/espfs.c:105:11: error: unused variable 'src_address' [-Werror=unused-variable]
  uint32_t src_address = ((uint32_t)src) - src_offset;
           ^
/home/stefan/esp-open-rtos/extras/libesphttpd/espfs/espfs.c: In function 'espFsFlags':
/home/stefan/esp-open-rtos/extras/libesphttpd/espfs/espfs.c:118:3: error: implicit declaration of function 'httpd_printf' [-Werror=implicit-function-declaration]
   httpd_printf("File handle not ready\n");
   ^
/home/stefan/esp-open-rtos/extras/libesphttpd/espfs/espfs.c: In function 'espFsOpen':
/home/stefan/esp-open-rtos/extras/libesphttpd/espfs/espfs.c:144:19: error: 'uint32' undeclared (first use in this function)
   spi_flash_read((uint32)p, (uint32*)&h, sizeof(EspFsHeader));
                   ^
/home/stefan/esp-open-rtos/extras/libesphttpd/espfs/espfs.c:144:26: error: expected ')' before 'p'
   spi_flash_read((uint32)p, (uint32*)&h, sizeof(EspFsHeader));
                          ^
/home/stefan/esp-open-rtos/extras/libesphttpd/espfs/espfs.c:156:26: error: expected ')' before 'p'
   spi_flash_read((uint32)p, (uint32*)&namebuf, sizeof(namebuf));
                          ^
/home/stefan/esp-open-rtos/extras/libesphttpd/espfs/espfs.c:159:3: error: implicit declaration of function 'strcmp' [-Werror=implicit-function-declaration]
   if (strcmp(namebuf, fileName)==0) {
   ^
/home/stefan/esp-open-rtos/extras/libesphttpd/espfs/espfs.c:162:4: error: implicit declaration of function 'malloc' [-Werror=implicit-function-declaration]
    r=(EspFsFile *)malloc(sizeof(EspFsFile)); //Alloc file desc mem
    ^
/home/stefan/esp-open-rtos/extras/libesphttpd/espfs/espfs.c:162:19: error: incompatible implicit declaration of built-in function 'malloc' [-Werror]
    r=(EspFsFile *)malloc(sizeof(EspFsFile)); //Alloc file desc mem
                   ^
/home/stefan/esp-open-rtos/extras/libesphttpd/espfs/espfs.c: In function 'espFsClose':
/home/stefan/esp-open-rtos/extras/libesphttpd/espfs/espfs.c:272:2: error: implicit declaration of function 'free' [-Werror=implicit-function-declaration]
  free(fh);
  ^
/home/stefan/esp-open-rtos/extras/libesphttpd/espfs/espfs.c:272:2: error: incompatible implicit declaration of built-in function 'free' [-Werror]
cc1: all warnings being treated as errors
make: *** [../../extras/libesphttpd/component.mk:55: build/libesphttpd//espfs/espfs.o] Error 1



Do anyone have any experience with using libesphttpd together with esp-open-rtos and know how to write the component.mk in a sensible way? If so, any help will be very much appreciated.

Regards
Stefan