@@ -913,6 +913,25 @@ async def console(self, place, target):
913913 await asyncio .sleep (1.0 )
914914 console .needs_target = True
915915
916+ def dfu (self ):
917+ place = self .get_acquired_place ()
918+ target = self ._get_target (place )
919+ if self .args .action == 'download' and not self .args .filename :
920+ raise UserError ('not enough arguments for dfu download' )
921+ from ..driver .dfudriver import DFUDriver
922+ try :
923+ drv = target .get_driver (DFUDriver )
924+ except NoDriverFoundError :
925+ drv = DFUDriver (target , name = None )
926+ drv .dfu .timeout = self .args .wait
927+ target .activate (drv )
928+ if self .args .action == 'download' :
929+ drv .download (self .args .altsetting , os .path .abspath (self .args .filename ))
930+ if self .args .action == 'detach' :
931+ drv .detach (self .args .altsetting )
932+ if self .args .action == 'list' :
933+ drv .list ()
934+
916935 def fastboot (self ):
917936 place = self .get_acquired_place ()
918937 args = self .args .fastboot_args
@@ -1697,6 +1716,15 @@ def main():
16971716 subparser .add_argument ('--logfile' , metavar = "FILE" , help = "Log output to FILE" , default = None )
16981717 subparser .set_defaults (func = ClientSession .console )
16991718
1719+ subparser = subparsers .add_parser ('dfu' ,
1720+ help = "communicate with device in DFU mode" )
1721+ subparser .add_argument ('action' , choices = ['download' , 'detach' , 'list' ], help = 'action' )
1722+ subparser .add_argument ('altsetting' , help = 'altsetting name or number (download, detach only)' ,
1723+ nargs = '?' )
1724+ subparser .add_argument ('filename' , help = 'file to write into device (download only)' , nargs = '?' )
1725+ subparser .add_argument ('--wait' , type = float , default = 10.0 )
1726+ subparser .set_defaults (func = ClientSession .dfu )
1727+
17001728 subparser = subparsers .add_parser ('fastboot' ,
17011729 help = "run fastboot" )
17021730 subparser .add_argument ('fastboot_args' , metavar = 'ARG' , nargs = argparse .REMAINDER ,
0 commit comments