Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions docs/snagflash.md
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ snagflash -P ums -s binaries/u-boot.stm32 -d /mnt/u-boot.stm32
```

**Note:** If you want a static block device path, you can use the following udev
rules to create symlinks when a certain VID:PID pair is detected:
rules to create symlinks when a certain VID:PID pair is detected:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

stray whitespace

- For a parent block device: `SUBSYSTEM=="block", KERNEL!="*[0-9]",
SUBSYSTEMS=="usb", ATTRS{idVendor}=="...", ATTRS{idProduct}=="...",
MODE="0660", TAG+="uaccess", SYMLINK+="myblockdev"`
Expand All @@ -182,8 +182,9 @@ In DFU mode, snagflash takes additional arguments :
The USB address of the DFU device exposed by U-Boot
* `-D --dfu-config altsetting:path`
The altsetting and path of a file to download to the board. This should match
the value specified in dfu\_alt\_info in U-Boot. This flag can be passed
multiple times, to specify multiple files to download.
the value specified in dfu\_alt\_info in U-Boot.
It may match either the numerical altsetting or the name of the altsetting.
This flag can be passed multiple times, to specify multiple files to download.
* `--dfu-keep`
An optional argument to avoid detaching DFU mode after download and keep the mode active
* `--dfu-detach`
Expand All @@ -196,6 +197,8 @@ Example:
# in U-Boot: setenv dfu_alt_info "mmc=uboot part 0 1"
# in U-Boot: dfu 0 mmc 0
snagflash -P dfu -p 0483:df11 -D 0:binaries/u-boot.stm32
or
snagflash -P dfu -p 0483:df11 -D uboot:binaries/u-boot.stm32
```

For instructions on how to setup DFU in U-Boot, please refer to the [U-Boot
Expand Down
9 changes: 7 additions & 2 deletions src/snagflash/dfu.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,13 @@ def dfu_cli(args):
altsetting = 0
if args.dfu_config:
for dfu_config in args.dfu_config:
(altsetting, sep, path) = dfu_config.partition(":")
altsetting = int(altsetting)
(partname, sep, path) = dfu_config.partition(":")
try:
altsetting = int(partname)
except ValueError:
altsetting = dfu.search_partid(dev, partname)
Comment thread
rgantois marked this conversation as resolved.
Resolved
if altsetting is None:
cli_error(f"u-boot does not support partition '{partname}")
dfu_download(dev, altsetting, path)
if not args.dfu_keep or args.dfu_detach or args.dfu_reset:
dfu_detach(dev, altsetting)
Expand Down
Loading