Initial filesystem creation

C programming, build, interpreter/VM.
Target audience: MicroPython Developers.
Post Reply
quax
Posts: 3
Joined: Sat Jun 22, 2019 6:45 am

Initial filesystem creation

Post by quax » Sat Jun 22, 2019 6:47 am

Is there a way to create an initial filesystem that contains custom files (eg. index.html, .css, ...)?

User avatar
pythoncoder
Posts: 3711
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: Initial filesystem creation

Post by pythoncoder » Sat Jun 22, 2019 7:56 am

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.
Peter Hinch

quax
Posts: 3
Joined: Sat Jun 22, 2019 6:45 am

Re: Initial filesystem creation

Post by quax » Sat Jun 22, 2019 12:47 pm

Thanks. Yes, this works. But I need to build an image that can be flashed alongside the firmware.

User avatar
jimmo
Posts: 885
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia

Re: Initial filesystem creation

Post by jimmo » Sat Jun 22, 2019 1:30 pm

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.


Post Reply