David Brownell wrote:
> So there I am, trying to do basic PLL init code using TCL.
>
> All I have to do is read a register, modify the result, and
> write it back ... write a register ... read a register and
> do something based on a bitfield ... etc.  Not what I'd call
> pretty TCL code (is there such a thing?), but workable.
>
> Except ... OpenOCD doesn't cooperate:
>
>   - "mdw 0x10000" doesn't return a value:
>       > set x [mdw 0x10000]
>       ... spam
>       > puts $x
>       ... nothing!
>       >
>
>   - But it does spew it into the server output log.
>
> Ideally, neither of those should happen.
>
> Is there a preferred approach here?  My first thought is
> to define "mrw" (etc) to read a single word and return
> its value in the TCL-standard way, since "mdw" seems to
> be overloaded with legacy prettyprint semantics.
>
> - Dave
>
> _______________________________________________
> Openocd-development mailing list
> [email protected]
> https://lists.berlios.de/mailman/listinfo/openocd-development
>   
Hi,

After trying to do some of this I found the following way of handling 
reading  for tcl processing, the magic is  ocd_mem2array.

#set base addres
set base_addr $0x1000
# add offset and read 4 32 bit words into array variable comp_cid
ocd_mem2array comp_cid 32 [expr $comp_base + 0xFF0] 4
# test if this worked
puts "memarray: $comp_cid , first element:  $comp_cid(0)\n"
# Loop over array elements to format as hex strings
foreach {i x} [set comp_cid] {set comp_cid($i) [format "%#010x" $x]}

Then you can use mww to write back values

 mww $addr $value

There is also  ocd_array2mem that I have not tested.

Best regards,
Magnus


_______________________________________________
Openocd-development mailing list
[email protected]
https://lists.berlios.de/mailman/listinfo/openocd-development

Reply via email to