aboutsummaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorAntonio Borneo <borneo.antonio@gmail.com>2022-01-12 17:59:12 +0100
committerAntonio Borneo <borneo.antonio@gmail.com>2022-01-22 10:13:36 +0000
commit5a8d32fcb92f179445da6d3f7b0ceeec4efbcc6f (patch)
treec67a4c73d294f034aa72e2967e22f895c0818efc /doc
parentaad87180586a43500f8af1cf79255c7293bb258b (diff)
downloadriscv-openocd-5a8d32fcb92f179445da6d3f7b0ceeec4efbcc6f.zip
riscv-openocd-5a8d32fcb92f179445da6d3f7b0ceeec4efbcc6f.tar.gz
riscv-openocd-5a8d32fcb92f179445da6d3f7b0ceeec4efbcc6f.tar.bz2
doc: use the new jimtcl syntax for 'expr'
With jimtcl 0.81 the syntax of the TCL command 'expr' requires the multiple arguments to be within curly brackets. Update the examples in the documentation to follow the new syntax. While there, split one example to avoid it to exceed the line size during pdf document generation. Change-Id: I91cca419f8273415ccb0c2ce369fc6ac476e34e5 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/6809 Tested-by: jenkins
Diffstat (limited to 'doc')
-rw-r--r--doc/manual/primer/tcl.txt2
-rw-r--r--doc/openocd.texi24
2 files changed, 14 insertions, 12 deletions
diff --git a/doc/manual/primer/tcl.txt b/doc/manual/primer/tcl.txt
index 868a75b..eba2f55 100644
--- a/doc/manual/primer/tcl.txt
+++ b/doc/manual/primer/tcl.txt
@@ -174,7 +174,7 @@ them. It is similar to this bash statement.
EXPORT vn=`date`
LINE 2 & 3
- set $vn [expr (1024 * $x)]
+ set $vn [expr {1024 * $x}]
global $vn
In line 1, we dynamically created a variable name. Here, we are
diff --git a/doc/openocd.texi b/doc/openocd.texi
index 4d5a844..cee54eb 100644
--- a/doc/openocd.texi
+++ b/doc/openocd.texi
@@ -2009,9 +2009,9 @@ proc setc15 @{regs value@} @{
echo [format "set p15 0x%04x, 0x%08x" $regs $value]
- arm mcr 15 [expr ($regs>>12)&0x7] \
- [expr ($regs>>0)&0xf] [expr ($regs>>4)&0xf] \
- [expr ($regs>>8)&0x7] $value
+ arm mcr 15 [expr @{($regs >> 12) & 0x7@}] \
+ [expr @{($regs >> 0) & 0xf@}] [expr @{($regs >> 4) & 0xf@}] \
+ [expr @{($regs >> 8) & 0x7@}] $value
@}
@end example
@@ -3157,7 +3157,9 @@ the target's supply voltage.
The result can be converted to Volts (ignoring the most significant bytes, always zero)
@example
> set a [st-link cmd 8 0xf7 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]
-> echo [expr 2*1.2*([lindex $a 4]+256*[lindex $a 5])/([lindex $a 0]+256*[lindex $a 1])]
+> set n [expr @{[lindex $a 4] + 256 * [lindex $a 5]@}]
+> set d [expr @{[lindex $a 0] + 256 * [lindex $a 1]@}]
+> echo [expr @{2 * 1.2 * $n / $d@}]
3.24891518738
@end example
@end deffn
@@ -4523,13 +4525,13 @@ where the mask bit is 1. The following example sets HPROT3 (cacheable)
and leaves the rest of the pattern intact. It configures memory access through
DCache on Cortex-M7.
@example
-set CSW_HPROT3_CACHEABLE [expr 1 << 27]
+set CSW_HPROT3_CACHEABLE [expr @{1 << 27@}]
samv.dap apcsw $CSW_HPROT3_CACHEABLE $CSW_HPROT3_CACHEABLE
@end example
Another example clears SPROT bit and leaves the rest of pattern intact:
@example
-set CSW_SPROT [expr 1 << 30]
+set CSW_SPROT [expr @{1 << 30@}]
samv.dap apcsw 0 $CSW_SPROT
@end example
@@ -8620,7 +8622,7 @@ In addition the following arguments may be specified:
proc load_image_bin @{fname foffset address length @} @{
# Load data from fname filename at foffset offset to
# target at address. Load at most length bytes.
- load_image $fname [expr $address - $foffset] bin \
+ load_image $fname [expr @{$address - $foffset@}] bin \
$address $length
@}
@end example
@@ -10402,7 +10404,7 @@ trivial challenge-response protocol could be implemented as follows in a
configuration file, immediately following @command{init}:
@example
set challenge [riscv authdata_read]
-riscv authdata_write [expr $challenge + 1]
+riscv authdata_write [expr @{$challenge + 1@}]
@end example
@deffn {Command} {riscv authdata_read}
@@ -12111,7 +12113,7 @@ it reads a file and executes as a script.
@example
set x 6
set y 7
- puts [format "The answer: %d" [expr $x * $y]]
+ puts [format "The answer: %d" [expr @{$x * $y@}]]
@end example
@enumerate
@item The SET command creates 2 variables, X and Y.
@@ -12182,13 +12184,13 @@ proc myproc @{ @} @{
@b{Dynamic variable creation}
@example
# Dynamically create a bunch of variables.
-for @{ set x 0 @} @{ $x < 32 @} @{ set x [expr $x + 1]@} @{
+for @{ set x 0 @} @{ $x < 32 @} @{ set x [expr @{$x + 1@}]@} @{
# Create var name
set vn [format "BIT%d" $x]
# Make it a global
global $vn
# Set it.
- set $vn [expr (1 << $x)]
+ set $vn [expr @{1 << $x@}]
@}
@end example
@b{Dynamic proc/command creation}