Skip to content

snagflash fastboot-uboot: flash cannot take an image path containing a space (quoting does not help) #112

Open

Description

@caewa

Version: snagboot 3.0.1 (git a86aa42, "Merge pull request #111"), also 2.6.1 from PyPI.

What happens

FastbootUboot.cmd_flash() (src/snagflash/fastboot_uboot.py, around line 238) splits the
arguments at the first space before removing quotes:

path, sep, rest = args.partition(" ")
path = path.strip('"').strip('"')

So any image path with a space is cut in two, whether it is quoted or not:

# cmdfile, used with: snagflash -P fastboot-uboot -p 0000:0000 -I cmdfile
set target mmc2
flash "/home/op/Images 2026/flash.bin" 0 hwpart 1

→ path = '/home/op/Images' and rest = '2026/flash.bin" 0 hwpart 1', then
int(offset, 0) raises ValueError: invalid literal for int() with base 0: '2026/flash.bin"'.
Interactive mode (-i) goes through the same code.

Side note: .strip('"').strip('"') strips the same character twice; it probably
meant to strip single quotes as well.

Why it matters to us

We drive snagflash from a production flashing station. By the time snagflash runs, the
board's previous bootloader has already been erased so that the ROM falls back to USB
download. A cmdfile that fails to parse leaves a board that boots nothing. We now refuse
such paths on our side, but it would be better if snagflash accepted them.

Suggested fix

Tokenise the arguments with shlex.split(args) (or at least honour double quotes) in
cmd_flash, and in the other commands that use partition(" ") (hwpart handling in
flash_mmc). Documented syntax: flash <image_path> <image_offset> [<partition_name>].
Also, it would help to validate the whole cmdfile (syntax, files present, offsets parse)
before the first command is sent to the device, so a typo on a later line cannot fail
halfway through a flash.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions