Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mkromfs segfault #426

Open
progerstar opened this issue Sep 21, 2023 · 2 comments
Open

mkromfs segfault #426

progerstar opened this issue Sep 21, 2023 · 2 comments

Comments

@progerstar
Copy link

progerstar commented Sep 21, 2023

If there is more than one file in a mkromfs src folder, I get a segfault error in a "romfs_file_seek_internal" function due to access to "entry->file.content".
Am I violating any rules for creating the src folder?

OS: Linux Mint x64

@the0ne
Copy link
Collaborator

the0ne commented Sep 24, 2023

The Wiki states about the ROMFS:

ROMFS is a file system, developed by the Lua RTOS team from the scratch, in which all it's data is stored together with the Lua RTOS firmware.

Although you can use other general-purpose file systems, such as SPIFFS or LFS (and mount them as read-only), the use of ROMFS has the following advantages:

There is no wasted space, since in ROMFS each file consists of a single block of data, that has the same size as the file content.
As the file system is builded and linked together with the firmware, it can be updated through OTA.
Small footprint, and minimal RAM usage (usually 1K per opened file).
ESP32 firmwares based on Lua RTOS and Lua scripts are deployed in the same way as firmwares enterely written in C.

As it says [...] each file consists of [...] the issue can't be that you include more than one file.
I've never tried to use the ROMFS so I can't give more advise than this.

@progerstar
Copy link
Author

progerstar commented Sep 24, 2023

I've fixed it.

I've found a first strange thing in an add_entry() function
memcpy(pa_new_entry->name, name, name_len);
where name_len - filename length, but pa_new_entry->name has only 1 byte size.
so i've changed romfs_entry_t's field char name[1] to name[32]; (I didn't understand the idea, so I'm not sure I didn't break something).

And have changed the following things in the traverse() function (I think they depend on the compiler - mkromfs executes on a pc):
if (!centry) -> if (centry == NULL)
and
if (!rest) -> if (strlen(rest) == 0)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants