Skip to content

Conversation

@amgross
Copy link
Contributor

@amgross amgross commented Jan 14, 2026

Bug in REPL

Found bug in repl, that it sends block_count to littlefs based on the file size, but in compacted image the file sze is not really the correct size hence getting error from littlefs.
This is in different than list and extract commands which not sending block_count, and when littlefs getting 0 it ignores it.

(Try run the test file I added with current master and see the failure)

Solution

Make behavior of list+extract+repl same by using same function

great side effects

having code not duplicated is less error prone...
Now also repl getting LittleFS Configuration: which was missing
Have print that tell the Image Size: size and the Input Image Size (compacted):
Have new test that catching this issue (according beyonce rule)
Now that all creation of littlefs pass through _fs_from_args it will be easier for me to implement #150

Left issue

Now REPL succeed to mount and work with compacted image, but when changing the image (with put command for example) it works but the image is being partially compacted (depends on where littlefs decide to put the data). Need design decision here what is expected behaviour, anyway I think it is different task and this one should be merged as is.

2. Add test for creating a compacted image and opening it in REPL
3. Aggragate duplicate code to functions
@BrianPugh
Copy link
Collaborator

Hey @amgross! I should find time either tomorrow or this weekend to review!

@amgross
Copy link
Contributor Author

amgross commented Jan 26, 2026

@BrianPugh reminder

@BrianPugh
Copy link
Collaborator

so sorry this slipped through the cracks; looking now 🙈

Copy link
Collaborator

@BrianPugh BrianPugh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a few small comments, thanks!

if args.verbose:
fs_size = len(fs.context.buffer)
input_image_size = len(fs.context.buffer)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is broken:

$ littlefs-python repl -v foo.bin --block-size 512
Traceback (most recent call last):
  File "/Users/brianpugh/projects/littlefs-python/.venv/bin/littlefs-python", line 10, in <module>
    sys.exit(main())
  File "/Users/brianpugh/projects/littlefs-python/src/littlefs/__main__.py", line 364, in main
    return args.func(parser, args)
  File "/Users/brianpugh/projects/littlefs-python/src/littlefs/__main__.py", line 218, in repl
    fs = _mount_from_context(parser, args, context)
  File "/Users/brianpugh/projects/littlefs-python/src/littlefs/__main__.py", line 138, in _mount_from_context
    input_image_size = len(fs.context.buffer)
AttributeError: 'UserContextFile' object has no attribute 'buffer'

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are correct of course, fixed and added test to catch it.
I tested those prints with the list/extract CLI which don't have this issue.

try:
shell.do_mount()
except LittleFSError as exc:
parser.error(f"Failed to mount '{source}': {exc}")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we lost this error message in this PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

name_max=args.name_max,
mount=False,
)
shell.cmdloop()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need a try/finally around this to unmount the filesystem if it's mounted?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@amgross
Copy link
Contributor Author

amgross commented Jan 26, 2026

@BrianPugh any idea why all tests failed/canceled?

@BrianPugh
Copy link
Collaborator

it was probably CI fail-early with failed linting. Run pre-commit install in the root of this repo to install the pre-commit hooks for linting and the like.

@BrianPugh
Copy link
Collaborator

beyond that, i think there's some github actions runner issues at the moment, ill rerun in a bit (I think it's a transient issue).

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

Successfully merging this pull request may close these issues.

2 participants