@@ -337,3 +337,67 @@ def load(self, filename=None, phase=None):
337337 @step ()
338338 def execute (self ):
339339 pass
340+
341+
342+ @target_factory .reg_driver
343+ @attr .s (eq = False )
344+ class SamsungUSBDriver (Driver , BootstrapProtocol ):
345+ bindings = {
346+ 'loader' : {'SamsungUSBLoader' , 'NetworkSamsungUSBLoader' },
347+ }
348+
349+ bl1 = attr .ib (validator = attr .validators .instance_of (str ))
350+ bl1_loadaddr = attr .ib (validator = attr .validators .instance_of (int ))
351+ spl_loadaddr = attr .ib (validator = attr .validators .instance_of (int ))
352+ loadaddr = attr .ib (validator = attr .validators .instance_of (int ))
353+ image = attr .ib (default = None )
354+
355+ def __attrs_post_init__ (self ):
356+ super ().__attrs_post_init__ ()
357+ # FIXME make sure we always have an environment or config
358+ if self .target .env :
359+ self .tool = self .target .env .config .get_tool ('smdk-usbdl' )
360+ else :
361+ self .tool = 'smdk-usbdl'
362+
363+ def on_activate (self ):
364+ pass
365+
366+ def on_deactivate (self ):
367+ pass
368+
369+ @Driver .check_active
370+ @step (args = ['filename' ])
371+ def load (self , filename = None , phase = None ):
372+ if filename is None and phase == 'bl1' :
373+ filename = self .bl1
374+ if filename is None and self .image is not None :
375+ filename = self .target .env .config .get_image_path (self .image )
376+ mf = ManagedFile (filename , self .loader )
377+ mf .sync_to_resource ()
378+
379+ if phase == 'bl1' :
380+ addr = self .bl1_loadaddr
381+ elif phase == 'spl' :
382+ addr = self .spl_loadaddr
383+ elif phase in (None , 'u-boot' ):
384+ addr = self .loadaddr
385+ else :
386+ raise ValueError (f"Unknown phase '{ phase } '" )
387+ pathname = mf .get_remote_path ()
388+ #time.sleep(0.5)
389+
390+ args = [self .tool , '-a' , f'{ addr :x} ' ,
391+ '-b' , f'{ self .loader .busnum :03d} ' ,
392+ '-d' , f'{ self .loader .devnum :03d} ' ,
393+ '-f' , pathname ]
394+
395+ processwrapper .check_output (
396+ self .loader .command_prefix + args ,
397+ #print_on_silent_log=True
398+ )
399+
400+ @Driver .check_active
401+ @step ()
402+ def execute (self ):
403+ pass
0 commit comments