Sming - Open Source framework for high efficiency native ESP8266 development

User avatar
By piperpilot
#24596 OK...as mentioned in another post, I'm trying to get rboot working properly for OTA updates. I am using an ESP-12 which has a 4MB flash, but I have not enabled the largeFlash options as I'm trying for the more simple approach first. I have the makefile worked out and generating the two firmware files. I have their locations set per the instructions for a 1MB chip at:

bootloader -> 0x00 (0x00 in esptool as flash location)
rom0 -> 0x40202010 (0x2000 in esptool as flash location)
rom1 -> 0x40282010 (0x82000 in esptool as flash location)

That all seems right and the program is running properly...the web server will return ajax information when I hit one of those endpoints.

Now onto SPIFFS. The Makefile has the following line of code:

Code: Select allSPIFF_START_OFFSET = $(shell printf '0x%X\n' $$(( ($$($(GET_FILESIZE) $(FW_BASE)/rom1.bin) + 16384 + 36864) & (0xFFFFC000) )) )


I'm not sure that is calculating the the start position of the SPIFFS filesystem correctly. If I look at the size of the rom1.bin, it is 273952 so its using a much smaller size to calculate... and its setting it at 0x4C000 which is obviously on top of the 1st rom.

So I figure if I want the SPIFFS filesystem to start in the 2nd MB, then I should put it at 0x100000. When I do that, it can't find my files. Is there a config option somewhere that tells the SPIFFS where to look on the flash? I can't seem to find it.

Any help or pointers to the right location would be appreciated.
User avatar
By piperpilot
#24628 OK...looking at some debugging it looks like SPIFFS is looking for the SPIFF file system at:

fs.start: size:752 Kb, offset:0x40000

flashmem_get_first_free_block_address() is using _flash_code_end to figure out where the filesystem is. It looks like that variable is set in the linker here:
Code: Select all .irom0.text : ALIGN(4)
  {
    _irom0_text_start = ABSOLUTE(.);
    *(.irom0.literal .irom.literal .irom.text.literal .irom0.text .irom.text)
   out/build/app_app.a:*(.literal .text .literal.* .text.* .stub .gnu.warning .gnu.linkonce.literal.* .gnu.linkonce.t.*.literal .gnu.linkonce.t.*)
  *libsming.a:*(.literal .text .literal.* .text.* .stub .gnu.warning .gnu.linkonce.literal.* .gnu.linkonce.t.*.literal .gnu.linkonce.t.*)
    _irom0_text_end = ABSOLUTE(.);
   _flash_code_end = ABSOLUTE(.);
  } >irom0_0_seg :irom0_0_phdr


Now the question is...how do I modify the linker to show _flash_code_end at the end of BOTH ROMS and then put the SPIFF filesystem at that location?
User avatar
By piperpilot
#24639 OK...I can report back some more progress. I really need one of the core Sming developers to jump in and explain how to fix this though as I don't quite understand some of the assumptions that must be being made in the code.

First, I was able to add the following to my code:

Code: Select all   debugf("_flash_code_end:%08x\n", (uint32_t)_flash_code_end);
   debugf("_flash_end:%08x\n", (uint32_t)flashEnd);


This printed out the value that was set in the linker. From that, I hardcoded the value into BOTH of my linker files so that the first one would have the proper value for the end of ALL code.

Code: Select all   _flash_code_end = ABSOLUTE(0xbce66);


Next, I needed to figure out where to put the SPIFF file system. I figure since it was at 0xbce66 that 0xC0000 was probably the next logical location on the right boundary. So I set the makefile to:

Code: Select allSPIFF_START_OFFSET = $(shell printf '0x%X\n' $$(( (0xC0000) & (0xFFFFC000) )) )


So all of that seems to work. I THINK I'm just getting lucky though. There's some magical formula that I'm missing in the code that tells the SPIFF where to look for the files...at some point I'll probably decode it..I've tried lots of different "guesses" but the one above is the only one that seems to work.

If there is a Sming dev that is more familiar with the inner workings of SPIFF and can comment and make a suggestion on how to put the FS at a fixed location on the flash using the config files, that would be great! Once I get all of this working, I would love to contribute a working rboot example based on the HttpServer_ConfigNetwork example.

Thanks,
Curtis
User avatar
By alonewolfx2
#24642 maybe it can help. here is spiffs start offsett definition. normally its dynamic but you can use with static offset. https://github.com/anakod/Sming/blob/ma ... iffs.c#L48