IOT Platform Sample - espfs alignment error

vinicius.vbf
Posts: 5
Joined: Wed Mar 02, 2016 10:06 am

IOT Platform Sample - espfs alignment error

Postby vinicius.vbf » Wed Mar 02, 2016 10:15 am

Hello! I'm trying to make the IOT Platform Sample (Plug) work, but I'm getting an error regarding the filesystem alignment. When I try to access the page /index.html, I get the error 404 not found. In the serial log, the following error is shown:

should call espfsint first


The call is made in user_init(), as shown:

Code: Select all

void user_init(void)
{
   ...
   /*Initialize espfs containing static webpages*/
   espFsInit((void*)(webpages_espfs_start));
   ...
}


But this call is resulting in "ESPFS_INIT_RESULT_BAD_ALIGN", because of this first condition:

Code: Select all

EspFsInitResult espFsInit(void *flashAddress) {
   // base address must be aligned to 4 bytes
   if (((int)flashAddress & 3) != 0) {
      return ESPFS_INIT_RESULT_BAD_ALIGN;
   }
   ...
}


webpages_espfs_start has a value of 1076086519.

I'm kind of lost. Can anyone help? What am I doing wrong? I'll be happy to provide any other information that you may find useful to know in order to help.

Thanks!!

vinicius.vbf
Posts: 5
Joined: Wed Mar 02, 2016 10:06 am

Re: IOT Platform Sample - espfs alignment error

Postby vinicius.vbf » Tue Apr 12, 2016 11:52 am

Just found a way to fix it: in your libesphttpd/Makefile file, change the following lines:

Code: Select all

libwebpages-espfs.a: webpages.espfs
   $(Q) $(OBJCOPY) -I binary -O elf32-xtensa-le -B xtensa --rename-section .data=.irom0.literal \
      --redefine-sym _binary_webpages_espfs_start=webpages_espfs_start \
      --redefine-sym _binary_webpages_espfs_end=webpages_espfs_end \
      --redefine-sym _binary_webpages_espfs_size=webpages_espfs_size \
      webpages.espfs build/webpages.espfs.o
   $(Q) $(AR) cru $@ build/webpages.espfs.o

to:

Code: Select all

libwebpages-espfs.a: webpages.espfs
   $(Q) $(OBJCOPY) -I binary -O elf32-xtensa-le -B xtensa --rename-section .data=.irom0.literal \
      webpages.espfs build/webpages.espfs.o.tmp
   $(Q) $(LD) -nostdlib -Wl,-r build/webpages.espfs.o.tmp -o build/webpages.espfs.o -Wl,-T webpages.espfs.ld
   $(Q) $(AR) cru $@ build/webpages.espfs.o

Then, create a new file called webpages.espfs.ld in the same folder (directory) of the aforementioned Makefile. The file content should be the following. Notice that the alignment is now correctly defined in this linker file:

Code: Select all

OUTPUT_FORMAT("elf32-xtensa-le")

SECTIONS
{
   .irom0.literal : ALIGN(4) SUBALIGN(4) {
      webpages_espfs_start = .;
      *(*)
      webpages_espfs_end = .;
      webpages_espfs_size = webpages_espfs_end - webpages_espfs_start;
   }
}


I've found this workaround on what it seems to be the official libesphttd repository: https://github.com/Spritetm/libesphttpd ... r/Makefile

Who is online

Users browsing this forum: No registered users and 14 guests