littlefs-python icon indicating copy to clipboard operation
littlefs-python copied to clipboard

How to create a new file or directory in a file generated using LFS?

Open pine-fish opened this issue 1 year ago • 9 comments

I only found a way to create a new LFS file in the example, without adding content to the existing LFS file, I think this should be achievable, If possible, please give me a demonstration. Thank you

pine-fish avatar Jun 29 '24 06:06 pine-fish

I have found a way to manipulate the contents of the lfs file. I export the data from the LFS partition on the device to bin and put it into this library. The library can correctly recognize the files in bin, and then I use the library to add files to bin. When I recognize it again, it shows that it has been successfully added, which means that this bin contains both the device's own files and the newly created files using the library. Next, I will rewrite this bin into the device's flash. When I start the device, it prompts a mount failure and receives an -84 error code. Why did this issue occur

pine-fish avatar Jun 29 '24 08:06 pine-fish

What version of littlefs are you running on your microcontroller? Newer version of littlefs are not backwards compatible with older versions (~1yr old).

BrianPugh avatar Jun 30 '24 12:06 BrianPugh

2.5.0,I tried to upgrade the device's LFS to 2.9.0 today, which is the same as the version of this library, but it still failed In addition, my previous tests were not completely unsuccessful. There were a few times when the LFS on the device could recognize the files and data contained in the library generated files, but only those few times. Afterwards, either the mount failed or the mount succeeded but the files inside were not recognized I took a look and the biggest difference is that in the files generated by the library, the operation records start from super block 3, while the device's LFS starts recording operations from super block 2. I tried to have the device write data repeatedly, bring the operation records to super block 3, and then rewrite them to flash, but it still failed These are the two LFS files I am using. Can you help me analyze this issue? thank you bin.zip

pine-fish avatar Jul 01 '24 09:07 pine-fish

what is the block_size that created these files?

BrianPugh avatar Jul 01 '24 14:07 BrianPugh

4096

pine-fish avatar Jul 02 '24 01:07 pine-fish

I was unable to unpack the Library generated.bin you uploaded. I unpacked the device-generated and repacked it, does the following work for you? The contents should be (all 0 bytes in size):

111.bin
2222.hex
33333.jpg

library-generated.bin.zip

BrianPugh avatar Jul 02 '24 14:07 BrianPugh

related: I just opened a PR reworking the CLI to be a bit more intuitive, you can try playing around with it if you'd like:

https://github.com/jrast/littlefs-python/pull/96

BrianPugh avatar Jul 02 '24 14:07 BrianPugh

I was unable to unpack the Library generated.bin you uploaded. I unpacked the device-generated and repacked it, does the following work for you? The contents should be (all 0 bytes in size):

111.bin
2222.hex
33333.jpg

library-generated.bin.zip

I wrote this bin into the device's flash, but it still returns -84. The super block number in this bin still starts from 3. Do you have a way to make it start from 2? Because my device starts recording from Super Block 2, which can also be seen in the bin I uploaded

pine-fish avatar Jul 03 '24 02:07 pine-fish

@pine-fish did you ever resolve your issue?

BrianPugh avatar Mar 20 '25 13:03 BrianPugh