@@ -96,7 +96,26 @@ def display(self, args):
9696 for i , core in self .context .target .cores .items ():
9797 self .context .writei ("Core %d type: %s%s" , i ,
9898 coresight .core_ids .CORE_TYPE_NAME [core .core_type ],
99- " (selected)" if (self .context .selected_core .core_number == i ) else "" )
99+ " (selected)" if ((self .context .selected_core is not None ) \
100+ and (self .context .selected_core .core_number == i )) else "" )
101+
102+ class APsValue (ValueBase ):
103+ INFO = {
104+ 'names' : ['aps' ],
105+ 'group' : 'standard' ,
106+ 'category' : 'target' ,
107+ 'access' : 'r' ,
108+ 'help' : "List discovered Access Ports." ,
109+ }
110+
111+ def display (self , args ):
112+ if self .context .target .is_locked ():
113+ self .context .write ("Target is locked" )
114+ else :
115+ self .context .writei ("%d APs:" , len (self .context .target .aps ))
116+ for addr , ap in sorted (self .context .target .aps .items (), key = lambda x : x [0 ]):
117+ self .context .writei ("%s: %s%s" , addr , ap .type_name ,
118+ " (selected)" if (self .context .selected_ap_address == addr ) else "" )
100119
101120class MemoryMapValue (ValueBase ):
102121 INFO = {
@@ -108,6 +127,10 @@ class MemoryMapValue(ValueBase):
108127 }
109128
110129 def display (self , args ):
130+ if self .context .selected_core is None :
131+ self .context .write ("No core is selected" )
132+ return
133+
111134 pt = prettytable .PrettyTable (["Region" , "Type" , "Start" , "End" , "Size" , "Access" , "Sector" , "Page" ])
112135 pt .align = 'l'
113136 pt .border = False
@@ -205,6 +228,10 @@ def print_fields(regname, value, fields, showAll):
205228 if showAll or bit != 0 :
206229 self .context .writei (" %s = 0x%x" , name , bit )
207230
231+ if self .context .selected_core is None :
232+ self .context .write ("No core is selected" )
233+ return
234+
208235 cfsr = self .context .selected_core .read32 (CFSR )
209236 mmfsr = cfsr & 0xff
210237 bfsr = (cfsr >> 8 ) & 0xff
@@ -292,6 +319,9 @@ class MemApValue(ValueBase):
292319 }
293320
294321 def display (self , args ):
322+ if self .context .selected_ap is None :
323+ self .context .write ("No MEM-AP is selected" )
324+ return
295325 self .context .writef ("{} is selected" , self .context .selected_ap .short_description )
296326
297327 def modify (self , args ):
@@ -322,6 +352,9 @@ class HnonsecValue(ValueBase):
322352 }
323353
324354 def display (self , args ):
355+ if self .context .selected_ap is None :
356+ self .context .write ("No MEM-AP is selected" )
357+ return
325358 self .context .writef ("{} HNONSEC = {} ({})" ,
326359 self .context .selected_ap .short_description ,
327360 self .context .selected_ap .hnonsec ,
@@ -330,6 +363,9 @@ def display(self, args):
330363 def modify (self , args ):
331364 if len (args ) == 0 :
332365 raise exceptions .CommandError ("missing argument" )
366+ if self .context .selected_ap is None :
367+ self .context .write ("No MEM-AP is selected" )
368+ return
333369 value = int (args [0 ], base = 0 )
334370 self .context .selected_ap .hnonsec = value
335371
@@ -343,6 +379,9 @@ class HprotValue(ValueBase):
343379 }
344380
345381 def display (self , args ):
382+ if self .context .selected_ap is None :
383+ self .context .write ("No MEM-AP is selected" )
384+ return
346385 hprot = self .context .selected_ap .hprot
347386 self .context .writef ("{} HPROT = {:#x}" ,
348387 self .context .selected_ap .short_description ,
@@ -359,6 +398,9 @@ def display(self, args):
359398 def modify (self , args ):
360399 if len (args ) == 0 :
361400 raise exceptions .CommandError ("missing argument" )
401+ if self .context .selected_ap is None :
402+ self .context .write ("No MEM-AP is selected" )
403+ return
362404 value = int (args [0 ], base = 0 )
363405 self .context .selected_ap .hprot = value
364406
@@ -399,6 +441,9 @@ class RegisterGroupsValue(ValueBase):
399441 }
400442
401443 def display (self , args ):
444+ if self .context .selected_core is None :
445+ self .context .write ("No core is selected" )
446+ return
402447 for g in sorted (self .context .selected_core .core_registers .groups ):
403448 self .context .write (g )
404449
@@ -415,6 +460,10 @@ class VectorCatchValue(ValueBase):
415460 }
416461
417462 def display (self , args ):
463+ if self .context .selected_core is None :
464+ self .context .write ("No core is selected" )
465+ return
466+
418467 catch = self .context .selected_core .get_vector_catch ()
419468
420469 self .context .write ("Vector catch:" )
@@ -426,6 +475,10 @@ def display(self, args):
426475 def modify (self , args ):
427476 if len (args ) == 0 :
428477 raise exceptions .CommandError ("missing vector catch setting" )
478+
479+ if self .context .selected_core is None :
480+ self .context .write ("No core is selected" )
481+ return
429482
430483 try :
431484 self .context .selected_core .set_vector_catch (convert_vector_catch (args [0 ]))
0 commit comments