Skip to content

Commit 66a50f6

Browse files
committed
Commands: reset command accepts reset type argument.
- Also cleaned up some read/write commands. - Regenerated command reference.
1 parent 2824cce commit 66a50f6

File tree

2 files changed

+63
-19
lines changed

2 files changed

+63
-19
lines changed

docs/command_reference.md

Lines changed: 38 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -196,9 +196,9 @@ Write DP register.
196196
<tr><td>
197197
<a href="#reset"><tt>reset</tt></a>
198198
</td><td>
199-
[halt|-halt|-h]
199+
[halt|-halt|-h] [TYPE]
200200
</td><td>
201-
Reset the target.
201+
Reset the target, optionally specifying the reset type.
202202
</td></tr>
203203

204204
<tr><td>
@@ -297,6 +297,15 @@ ADDR [LEN]
297297
Read 32-bit words.
298298
</td></tr>
299299

300+
<tr><td>
301+
<a href="#read64"><tt>read64</tt></a>,
302+
<a href="#read64"><tt>rd</tt></a>
303+
</td><td>
304+
ADDR [LEN]
305+
</td><td>
306+
Read 64-bit words.
307+
</td></tr>
308+
300309
<tr><td>
301310
<a href="#read8"><tt>read8</tt></a>,
302311
<a href="#read8"><tt>rb</tt></a>
@@ -332,6 +341,15 @@ ADDR DATA+
332341
Write 32-bit words to memory.
333342
</td></tr>
334343

344+
<tr><td>
345+
<a href="#write64"><tt>write64</tt></a>,
346+
<a href="#write64"><tt>wd</tt></a>
347+
</td><td>
348+
ADDR DATA...
349+
</td><td>
350+
Write 64-bit double-words to memory.
351+
</td></tr>
352+
335353
<tr><td>
336354
<a href="#write8"><tt>write8</tt></a>,
337355
<a href="#write8"><tt>wb</tt></a>
@@ -749,8 +767,8 @@ Write DP register.
749767

750768
##### `reset`
751769

752-
**Usage**: [halt|-halt|-h] \
753-
Reset the target.
770+
**Usage**: [halt|-halt|-h] [TYPE] \
771+
Reset the target, optionally specifying the reset type. The reset type must be one of 'default', 'hw', 'sw', 'hardware', 'software', 'sw_sysresetreq', 'sw_vectreset', 'sw_emulated', 'sysresetreq', 'vectreset', or 'emulated'.
754772

755773

756774
##### `unlock`
@@ -818,14 +836,21 @@ Load a binary file to an address in memory (RAM or flash). This command is depre
818836

819837
**Aliases**: `rh` \
820838
**Usage**: ADDR [LEN] \
821-
Read 16-bit halfwords. Optional length parameter is the number of bytes to read. It must be divisible by 2. If the length is not provided, one halfword is read. The address may be unaligned.
839+
Read 16-bit halfwords. Optional length parameter is the number of bytes (not half-words) to read. It must be divisible by 2. If the length is not provided, one halfword is read. The address may be unaligned.
822840

823841

824842
##### `read32`
825843

826844
**Aliases**: `rw` \
827845
**Usage**: ADDR [LEN] \
828-
Read 32-bit words. Optional length parameter is the number of bytes to read. It must be divisible by 4. If the length is not provided, one word is read. The address may be unaligned.
846+
Read 32-bit words. Optional length parameter is the number of bytes (not words) to read. It must be divisible by 4. If the length is not provided, one word is read. The address may be unaligned.
847+
848+
849+
##### `read64`
850+
851+
**Aliases**: `rd` \
852+
**Usage**: ADDR [LEN] \
853+
Read 64-bit words. Optional length parameter is the number of bytes (not double-words!) to read. It must be divisible by 8. If the length is not provided, one word is read. The address may be unaligned.
829854

830855

831856
##### `read8`
@@ -855,6 +880,13 @@ Write 16-bit halfwords to memory. The data arguments are 16-bit halfwords in big
855880
Write 32-bit words to memory. The data arguments are 32-bit words in big-endian format and are written as little-endian. The address may be unaligned. Can write to both RAM and flash. Flash writes are subject to minimum write size and alignment, and the flash page must have been previously erased.
856881

857882

883+
##### `write64`
884+
885+
**Aliases**: `wd` \
886+
**Usage**: ADDR DATA... \
887+
Write 64-bit double-words to memory. The data arguments are 64-bit words in big-endian format and are written as little-endian. The address may be unaligned. Can write to both RAM and flash. Flash writes are subject to minimum write size and alignment, and the flash page must have been previously erased.
888+
889+
858890
##### `write8`
859891

860892
**Aliases**: `wb` \

pyocd/commands/commands.py

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,10 @@
2929
from ..flash.file_programmer import FileProgrammer
3030
from ..gdbserver.gdbserver import GDBServer
3131
from ..utility import conversion
32-
from ..utility.cmdline import UniquePrefixMatcher
32+
from ..utility.cmdline import (
33+
UniquePrefixMatcher,
34+
convert_reset_type,
35+
)
3336
from ..utility.hex import (
3437
format_hex_width,
3538
dump_hex_data_to_str,
@@ -328,20 +331,29 @@ class ResetCommand(CommandBase):
328331
'names': ['reset'],
329332
'group': 'standard',
330333
'category': 'device',
331-
'nargs': [0, 1],
332-
'usage': "[halt|-halt|-h]",
333-
'help': "Reset the target.",
334+
'nargs': [0, 1, 2],
335+
'usage': "[halt|-halt|-h] [TYPE]",
336+
'help': "Reset the target, optionally specifying the reset type.",
337+
'extra_help': "The reset type must be one of 'default', 'hw', 'sw', 'hardware', 'software', "
338+
"'sw_sysresetreq', 'sw_vectreset', 'sw_emulated', 'sysresetreq', 'vectreset', "
339+
"or 'emulated'.",
340+
334341
}
335342

336343
def parse(self, args):
337344
self.do_halt = False
338-
if len(args) == 1:
345+
self.reset_type = None
346+
if len(args) >= 1:
339347
self.do_halt = (args[0] in ('-h', '--halt', 'halt'))
348+
if self.do_halt:
349+
args.pop(0)
350+
if len(args) == 1:
351+
self.reset_type = convert_reset_type(args[0])
340352

341353
def execute(self):
342354
if self.do_halt:
343355
self.context.write("Resetting target with halt")
344-
self.context.selected_core.reset_and_halt()
356+
self.context.selected_core.reset_and_halt(self.reset_type)
345357

346358
status = self.context.selected_core.get_state()
347359
if status != Target.State.HALTED:
@@ -350,7 +362,7 @@ def execute(self):
350362
self.context.write("Successfully halted device on reset")
351363
else:
352364
self.context.write("Resetting target")
353-
self.context.selected_core.reset()
365+
self.context.selected_core.reset(self.reset_type)
354366

355367
class DisassembleCommand(CommandBase):
356368
INFO = {
@@ -428,7 +440,7 @@ class Read16Command(ReadCommandBase):
428440
'nargs': [1, 2],
429441
'usage': "ADDR [LEN]",
430442
'width': 16,
431-
'help': "Read 16-bit halfwords",
443+
'help': "Read 16-bit halfwords.",
432444
'extra_help': "Optional length parameter is the number of bytes (not half-words) to read. It "
433445
"must be divisible by 2. If the length is not provided, one halfword is read. "
434446
"The address may be unaligned."
@@ -442,21 +454,21 @@ class Read32Command(ReadCommandBase):
442454
'nargs': [1, 2],
443455
'usage': "ADDR [LEN]",
444456
'width': 32,
445-
'help': "Read 32-bit words",
457+
'help': "Read 32-bit words.",
446458
'extra_help': "Optional length parameter is the number of bytes (not words) to read. It must be "
447459
"divisible by 4. If the length is not provided, one word is read. "
448460
"The address may be unaligned.",
449461
}
450462

451463
class Read64Command(ReadCommandBase):
452464
INFO = {
453-
'names': ['read64', 'r64', 'rd'],
465+
'names': ['read64', 'rd'],
454466
'group': 'standard',
455467
'category': 'memory',
456468
'nargs': [1, 2],
457469
'usage': "ADDR [LEN]",
458470
'width': 64,
459-
'help': "Read 64-bit words",
471+
'help': "Read 64-bit words.",
460472
'extra_help': "Optional length parameter is the number of bytes (not double-words!) to read. "
461473
"It must be divisible by 8. If the length is not provided, one word is read. "
462474
"The address may be unaligned."
@@ -549,13 +561,13 @@ class Write32Command(WriteCommandBase):
549561

550562
class Write64Command(WriteCommandBase):
551563
INFO = {
552-
'names': ['write64', 'w64', 'wd'],
564+
'names': ['write64', 'wd'],
553565
'group': 'standard',
554566
'category': 'memory',
555567
'nargs': '*',
556568
'usage': "ADDR DATA...",
557569
'width': 64,
558-
'help': "Write 64-bit double-words to memory",
570+
'help': "Write 64-bit double-words to memory.",
559571
'extra_help': "The data arguments are 64-bit words in big-endian format and are written as "
560572
"little-endian. The address may be unaligned. Can write to both RAM and flash. "
561573
"Flash writes are subject to minimum write size and alignment, and the flash "

0 commit comments

Comments
 (0)