Page 1 of 1

Initial filesystem creation

Posted: Sat Jun 22, 2019 6:47 am
by quax
Is there a way to create an initial filesystem that contains custom files (eg. index.html, .css, ...)?

Re: Initial filesystem creation

Posted: Sat Jun 22, 2019 7:56 am
by pythoncoder
You can copy data files to the target's filesystem exactly as per MicropPython programs. There are various tools available to do this. I favour rshell.

Re: Initial filesystem creation

Posted: Sat Jun 22, 2019 12:47 pm
by quax
Thanks. Yes, this works. But I need to build an image that can be flashed alongside the firmware.

Re: Initial filesystem creation

Posted: Sat Jun 22, 2019 1:30 pm
by jimmo
I'm not aware that this is a feature that exists. I do wonder if you were to make a FAT filesystem image, and add that to the .dfu file with the right offsets, it might actually be quite close to working.

The closest you can get with current features is to extend what the firmware currently does to generate the default boot.py e.g. look at ports/stm32/factoryreset.c
The disadvantage is that you'll now have two copies of your static resources in flash (once in the code ROM, and then in the filesystem too).

One (fairly terrible but less wasteful) option might be to write a tool to bundle up your static resources into a Python file (e.g. static.py), then add that as a frozen module to the build. Then serve those resources directly from `static.INDEX_HTML` or something.

Re: Initial filesystem creation

Posted: Sat Jun 22, 2019 9:38 pm
by dhylands