AZURE RTOS: FileX: send web page from MCU flash without FAT - a missing feature?
Meanwhile STM goes with Microsoft AZURE RTOS - ok, fine, feature rich, obvious!
But "I miss a feature": open and read a file from the MCU internal flash memory (as a const file content, as array of characters, without a need for a sector based, FAT based, a file system).
In the past, on STM MCUs and FW (CubeMX drivers and demos) - it was possible to have web pages for a HTTPD daemon (web server) located in MCU Flash memory and read the file data bytes and send it as browser response.
Now, with AZURE RTOS - all seems to be stored on a FAT (sector based) file system. Why so complicated?!
Details:
I have ported the STM32U575-EV USB_ECM project to a NUCLEO-U575ZI-Q board. It needs the external SD Card! So, I had to put the web page files on external SD Card (with external SD Card adapter for a NUCELO board). I want to get rid of this SD Card and have my web pages sitting in the MCU Flash memory.
OK, I understand, AZURE FileX is very flexible, it can also support SDRAM as file system MEDIA, even flash memories (NAND/NOR), e.g via levelX. I know all this, e.g.:
Introduction to FILEX - stm32mcu
I know: AZURE FileX can use SRAM, Flash Memories NAND/NOR (assuming also MCU internal flash - but very delicate to use MCU Flash with code in parallel) as File System Storage. But it remains a fact: it is handled as a sector based, FAT (or exFAT) file system (on every media).
But it means also: you have to "format", "partition" such a file system: and you had to copy the web pages from MCU flash into the SRAM/SDRAM/Flash file system storage (wasting memory: already available in Flash - why to "copy"?).
And it consumes a lot of time, it wastes a lot of space (e.g. needing a Boot record, a FAT directory table, files allocating "clusters" (numbers of sectors) etc. And my web page would be "doubled": it sits already in MCU Flash, but I had to copy it into a (formatted) file system on boot time, e.g. to SRAM media.
I miss this:
The web browser (in NetXDuo - Addons Web Server) uses (only) functions like:
fx_file_open(), fx_file_read(), fx_file_close() and fx_directory_information_get()
Technically, the web server just wants to open a file (in order to send as a request response), it needs to know the size of the file and it might read the file in chunks (splitting into smaller packets via network).
But all these functions require a FAT file system: it goes at the end to a media for the file system (SRAM, NAND/NOR or SD Card). And it is slow (going through the FAT system).
I do not need this "complexity": instead: the "file" sits already in my Flash Memory (MCU), without any overhead, e.g. without having a FAT table, Boot sector, organized in "clusters" and "sectors". The function should read just the bytes of a string (which acts like the content of a "file", a byte stream reading from).
Solution/intention
Due to fact, that AZURE FileX does not support to read a "file" - without a FAT system - from a read-only memory (as a stream of bytes) - I am tending towards this approach:
- I will implement all the functions needed by the web server, e.g. fx_file_open(), fx_file_read(), fx_file_close() and fx_directory_information_get() - again
- but instead of using a FAT file system (with sectors) - I read just a stream of bytes (from a "file", stored in MCU flash, from a byte array as a const string)
- no need to have a FAT File System, no need to have sectors - save the space by just allocating the Flash memory for the "file" content (as done in the past)
- all these functions are "high-level" and "abstracted" from a real FAT system: a fx_file_read() could read also my byte string from flash memory, without to go via FAT, sector numbers etc.
I want to have a web browser, dealing with "files" but not with the overhead to have a real FAT file system, not wasting memory space, not delaying boot time by copying files from MCU flash into File System Media, not delaying real-time response by going through a file system...
It should not be a big deal, to implement these "few" functions to read a "file" as a stream of characters from my MCU flash: the function calls can work in the same way, with same parameters and behavior (but bypassing any FAT file system).
It was possible before in STM FW to do this approach - now, with changing to AZURE RTOS, this feature is gone.
Why is such real-time (and memory space optimized) "feature" missing (in AZURE RTOS)?
