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

usbus/dfu: do not create alt interface if NUM_SLOTS=1 #19386

Merged
merged 1 commit into from Mar 14, 2023

Conversation

dylad
Copy link
Member

@dylad dylad commented Mar 13, 2023

Contribution description

In some cases, it is really useful to build riotboot with NUM_SLOTS=1.
When use in combination with riotboot_dfu, there is no need to export the second slot if riotboot is built with NUM_SLOTS=1.
Thus, prevent the alt interface declaration in dfu if NUM_SLOTS=1 so that only slot0 can be used to flash.

Testing procedure

Add NUM_SLOTS=1 to bootloaders/riotboot_dfu/Makefile
Flash the riotboot DFU bootloader to any board supported by USBUS:
make BOARD=xxx -C bootloaders/riotboot_dfu flash
and run
dfu-util -l

With NUM_SLOTS=2 you will get:

dfu-util -l  
dfu-util 0.11

Copyright 2005-2009 Weston Schmidt, Harald Welte and OpenMoko Inc.
Copyright 2010-2021 Tormod Volden and Stefan Schmidt
This program is Free Software and has ABSOLUTELY NO WARRANTY
Please report bugs to http://sourceforge.net/p/dfu-util/tickets/

Found DFU: [1209:7d02] ver=0100, devnum=11, cfg=1, intf=0, path="1-4", alt=1, name="RIOT-OS Slot 1", serial="AB88DCAE80893484"
Found DFU: [1209:7d02] ver=0100, devnum=11, cfg=1, intf=0, path="1-4", alt=0, name="RIOT-OS Slot 0", serial="AB88DCAE80893484"

with NUM_SLOTS=1 you will get:

dfu-util -l 
dfu-util 0.11

Copyright 2005-2009 Weston Schmidt, Harald Welte and OpenMoko Inc.
Copyright 2010-2021 Tormod Volden and Stefan Schmidt
This program is Free Software and has ABSOLUTELY NO WARRANTY
Please report bugs to http://sourceforge.net/p/dfu-util/tickets/

Found DFU: [1209:7d02] ver=0100, devnum=14, cfg=1, intf=0, path="1-4", alt=0, name="RIOT-OS Slot 0", serial="AB88DCAE80893484"

Issues/PRs references

@dylad dylad added the CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR label Mar 13, 2023
@github-actions github-actions bot added Area: sys Area: System Area: USB Area: Universal Serial Bus labels Mar 13, 2023
sys/usb/usbus/dfu/dfu.c Outdated Show resolved Hide resolved
If riotboot is built with NUM_SLOTS=1, there is no reason to advertise a second slot in the bootloader

Signed-off-by: Dylan Laduranty <dylan.laduranty@mesotic.com>
@dylad dylad force-pushed the pr/dfu/limit_slot1_exposition branch from eb41368 to 65475af Compare March 13, 2023 20:52
@riot-ci
Copy link

riot-ci commented Mar 13, 2023

Murdock results

✔️ PASSED

65475af usbus/dfu: do not create alt interface if not needed

Success Failures Total Runtime
6882 0 6882 09m:05s

Artifacts

@benpicco
Copy link
Contributor

bors merge

bors bot added a commit that referenced this pull request Mar 13, 2023
19382: tests/pkg_nanors: use static allocation r=benpicco a=benpicco



19386: usbus/dfu: do not create alt interface if NUM_SLOTS=1 r=benpicco a=dylad

### Contribution description

In some cases, it is really useful to build `riotboot` with `NUM_SLOTS=1`.
When use in combination with `riotboot_dfu`, there is no need to export the second slot if `riotboot` is built with `NUM_SLOTS=1`.
Thus, prevent the alt interface declaration in dfu if `NUM_SLOTS=1` so that only slot0 can be used to flash.


### Testing procedure
Add `NUM_SLOTS=1` to `bootloaders/riotboot_dfu/Makefile`
Flash the riotboot DFU bootloader to any board supported by USBUS:
`make BOARD=xxx -C bootloaders/riotboot_dfu flash`
and run
`dfu-util -l`

With NUM_SLOTS=2 you will get:
```
dfu-util -l  
dfu-util 0.11

Copyright 2005-2009 Weston Schmidt, Harald Welte and OpenMoko Inc.
Copyright 2010-2021 Tormod Volden and Stefan Schmidt
This program is Free Software and has ABSOLUTELY NO WARRANTY
Please report bugs to http://sourceforge.net/p/dfu-util/tickets/

Found DFU: [1209:7d02] ver=0100, devnum=11, cfg=1, intf=0, path="1-4", alt=1, name="RIOT-OS Slot 1", serial="AB88DCAE80893484"
Found DFU: [1209:7d02] ver=0100, devnum=11, cfg=1, intf=0, path="1-4", alt=0, name="RIOT-OS Slot 0", serial="AB88DCAE80893484"
```

with NUM_SLOTS=1 you will get:
```
dfu-util -l 
dfu-util 0.11

Copyright 2005-2009 Weston Schmidt, Harald Welte and OpenMoko Inc.
Copyright 2010-2021 Tormod Volden and Stefan Schmidt
This program is Free Software and has ABSOLUTELY NO WARRANTY
Please report bugs to http://sourceforge.net/p/dfu-util/tickets/

Found DFU: [1209:7d02] ver=0100, devnum=14, cfg=1, intf=0, path="1-4", alt=0, name="RIOT-OS Slot 0", serial="AB88DCAE80893484"
```





### Issues/PRs references



Co-authored-by: Benjamin Valentin <benpicco@beuth-hochschule.de>
Co-authored-by: Dylan Laduranty <dylan.laduranty@mesotic.com>
bors bot added a commit that referenced this pull request Mar 13, 2023
19382: tests/pkg_nanors: use static allocation r=benpicco a=benpicco



19386: usbus/dfu: do not create alt interface if NUM_SLOTS=1 r=benpicco a=dylad

### Contribution description

In some cases, it is really useful to build `riotboot` with `NUM_SLOTS=1`.
When use in combination with `riotboot_dfu`, there is no need to export the second slot if `riotboot` is built with `NUM_SLOTS=1`.
Thus, prevent the alt interface declaration in dfu if `NUM_SLOTS=1` so that only slot0 can be used to flash.


### Testing procedure
Add `NUM_SLOTS=1` to `bootloaders/riotboot_dfu/Makefile`
Flash the riotboot DFU bootloader to any board supported by USBUS:
`make BOARD=xxx -C bootloaders/riotboot_dfu flash`
and run
`dfu-util -l`

With NUM_SLOTS=2 you will get:
```
dfu-util -l  
dfu-util 0.11

Copyright 2005-2009 Weston Schmidt, Harald Welte and OpenMoko Inc.
Copyright 2010-2021 Tormod Volden and Stefan Schmidt
This program is Free Software and has ABSOLUTELY NO WARRANTY
Please report bugs to http://sourceforge.net/p/dfu-util/tickets/

Found DFU: [1209:7d02] ver=0100, devnum=11, cfg=1, intf=0, path="1-4", alt=1, name="RIOT-OS Slot 1", serial="AB88DCAE80893484"
Found DFU: [1209:7d02] ver=0100, devnum=11, cfg=1, intf=0, path="1-4", alt=0, name="RIOT-OS Slot 0", serial="AB88DCAE80893484"
```

with NUM_SLOTS=1 you will get:
```
dfu-util -l 
dfu-util 0.11

Copyright 2005-2009 Weston Schmidt, Harald Welte and OpenMoko Inc.
Copyright 2010-2021 Tormod Volden and Stefan Schmidt
This program is Free Software and has ABSOLUTELY NO WARRANTY
Please report bugs to http://sourceforge.net/p/dfu-util/tickets/

Found DFU: [1209:7d02] ver=0100, devnum=14, cfg=1, intf=0, path="1-4", alt=0, name="RIOT-OS Slot 0", serial="AB88DCAE80893484"
```





### Issues/PRs references



Co-authored-by: Benjamin Valentin <benpicco@beuth-hochschule.de>
Co-authored-by: Dylan Laduranty <dylan.laduranty@mesotic.com>
@bors
Copy link
Contributor

bors bot commented Mar 14, 2023

Build failed (retrying...):

@bors
Copy link
Contributor

bors bot commented Mar 14, 2023

Build succeeded:

@bors bors bot merged commit 5b61449 into RIOT-OS:master Mar 14, 2023
23 checks passed
@dylad dylad deleted the pr/dfu/limit_slot1_exposition branch March 14, 2023 06:46
@MrKevinWeiss MrKevinWeiss added this to the Release 2023.04 milestone Apr 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: sys Area: System Area: USB Area: Universal Serial Bus CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants