@@ -54,7 +54,7 @@ def __init__(self, cfg, device, dev_id=None,
54
54
commander = DEFAULT_JLINK_EXE ,
55
55
dt_flash = True , erase = True , reset = False ,
56
56
iface = 'swd' , speed = 'auto' , flash_script = None ,
57
- loader = None ,
57
+ loader = None , flash_sram = False ,
58
58
gdbserver = 'JLinkGDBServer' ,
59
59
gdb_host = '' ,
60
60
gdb_port = DEFAULT_JLINK_GDB_PORT ,
@@ -73,6 +73,7 @@ def __init__(self, cfg, device, dev_id=None,
73
73
self .commander = commander
74
74
self .flash_script = flash_script
75
75
self .dt_flash = dt_flash
76
+ self .flash_sram = flash_sram
76
77
self .erase = erase
77
78
self .reset = reset
78
79
self .gdbserver = gdbserver
@@ -173,6 +174,9 @@ def do_add_parser(cls, parser):
173
174
help = 'RTT client, default is JLinkRTTClient' )
174
175
parser .add_argument ('--rtt-port' , default = DEFAULT_JLINK_RTT_PORT ,
175
176
help = f'jlink rtt port, defaults to { DEFAULT_JLINK_RTT_PORT } ' )
177
+ parser .add_argument ('--flash-sram' , default = False , action = 'store_true' ,
178
+ help = 'if given, flashing the image to SRAM and '
179
+ 'modify PC register to be SRAM base address' )
176
180
177
181
parser .set_defaults (reset = False )
178
182
@@ -182,6 +186,7 @@ def do_create(cls, cfg, args):
182
186
dev_id = args .dev_id ,
183
187
commander = args .commander ,
184
188
dt_flash = args .dt_flash ,
189
+ flash_sram = args .flash_sram ,
185
190
erase = args .erase ,
186
191
reset = args .reset ,
187
192
iface = args .iface , speed = args .speed ,
@@ -386,7 +391,9 @@ def get_default_flash_commands(self):
386
391
if self .file_type == FileType .HEX :
387
392
flash_cmd = f'loadfile "{ self .file } "'
388
393
elif self .file_type == (FileType .BIN or FileType .MOT ):
389
- if self .dt_flash :
394
+ if self .flash_sram :
395
+ flash_addr = self .sram_address_from_build_conf (self .build_conf )
396
+ elif self .dt_flash :
390
397
flash_addr = self .flash_address_from_build_conf (self .build_conf )
391
398
else :
392
399
flash_addr = 0
@@ -407,7 +414,9 @@ def get_default_flash_commands(self):
407
414
flash_cmd = f'loadfile { self .mot_name } '
408
415
# Preferring .bin over .elf
409
416
elif self .bin_name is not None and os .path .isfile (self .bin_name ):
410
- if self .dt_flash :
417
+ if self .flash_sram :
418
+ flash_addr = self .sram_address_from_build_conf (self .build_conf )
419
+ elif self .dt_flash :
411
420
flash_addr = self .flash_address_from_build_conf (self .build_conf )
412
421
else :
413
422
flash_addr = 0
@@ -429,6 +438,10 @@ def get_default_flash_commands(self):
429
438
if self .reset :
430
439
lines .append ('r' ) # Reset and halt the target
431
440
441
+ if self .flash_sram :
442
+ sram_addr = self .sram_address_from_build_conf (self .build_conf )
443
+ lines .append (f'WReg PC 0x{ sram_addr :x} ' ) # Change PC to start of SRAM
444
+
432
445
lines .append ('g' ) # Start the CPU
433
446
434
447
# Reset the Debug Port CTRL/STAT register
0 commit comments