ESP8266 Webserver Project

Moderator: Sprite_tm

User avatar
By prozac
#11225 ok, so I modded the makefile http://pastebin.com/Tv110xFG that generates the user1 and user2 files. "make cloud" will also flash the bootloader (update the path in the makefile to your env), user1 and the espfs. I have not gotten the web update to work properly, but that might be the webserver I am running. because of this, I have not been able to test booting from partition #2, so YMMV.

I also modified the espfs.c file

Code: Select allEspFsFile ICACHE_FLASH_ATTR *espFsOpen(char *fileName) {
#ifdef __ets__
        char *p=(char *)(ESPFS_POS+0x40200000);
        EspFsHeader j;
        os_memcpy(&j, p, sizeof(EspFsHeader));
        if (j.magic!=0x73665345) {
          char *p=(char *)(ESPFS_POS2+0x40200000);
          os_memcpy(&j, p, sizeof(EspFsHeader));
          if (j.magic!=0x73665345) {
            os_printf("Unable to locate EspFS. EspFS image broken.\n");
            return NULL;
          }
        }
#else
        char *p=espFsData;
#endif


and the include/httpdconfig.h

Code: Select all#ifndef ESPFS_POS
#define ESPFS_POS 0x41000
#define ESPFS_POS2 0x01000
#endif


The next step is to check on boot for the boot "partition" and try to verify the espfs exists. If not, I would like it to try to dl and flash it. Secondarily, I would like to have a static page builtin that instead of erroring out would present a form to allow you to upload an espfs file for flashing.
User avatar
By bjpirt
#11247 @prozac that's great - I was hoping to do exactly the same thing.

One of the things that needs modifying is for esp-httpd to be able to handle streaming post bodies so that you can push in enough data to be able to do something like this. Currently it buffers all of the post body before triggering the handler which means it will fail if the post body is > 1k. I've modified httpd.c to be able to do this and it would be nice to try to get it merged into the main esp-httpd source. I think an example handler that will do exactly this would be very useful as a lot of people will want to be able to update their web pages without having to pull the module and reprogram it via serial. I'll try and clean up my changes and push them to GitHub so they can be pulled in from there.

If you're able to share your routines for writing to the memory then I'll try to incorporate them. Maybe push a project to GitHub so I can pull it and take a look if that's something you're willing to do.

@Sprite_tm how does this sound to you? Just want to make sure I don't waste my time preparing modifications that aren't something you would want anyway :-)

For the static page, that should be pretty straightforward - just take a look at cgiReadFlash as an example for how to do this.
User avatar
By bjpirt
#11250 @prozac @sprite_tm In case you're interested I've pushed my changes here ( https://github.com/bjpirt/esphttpd/tree/streaming ). It hasn't been tested since I rebased it on the changes that happened since I wrote it, but it should give you an idea of the approach I took.

@prozac feel free to pull request into this branch if you want to add support for writing to flash :-)
User avatar
By Sprite_tm
#11438 @bjpirt Looks good! I think I'll make some small changes (eg make the stream flag into some more general-purpose bitfield) but otherwise I'll integrate your code... well, when I get around to it, I'm somewhat busy these days and I also want to test it well.