[Openocd-development] [Fwd: tcl questions.]

2009-08-30 Thread michal smulski


I have a couple questions about tcl:
1. How do you make variables defined as global (see c100regs.tcl &
c100helper.tcl) visible in procedures? I would like to reuse defines in
c100regs.tcl. Otherwise, I need to define them every time I want to use
them. I tried 'global' but it does not work.
2. How to I transfer register (say cpsr or r0) to a tcl variable
(similar to memory -> tcl in mmw())?
3. I can't add comments wth # at the same line as the tcl command. This
is not a big deal but it would be nice to have.

Thanks,
Michal

# mrw,mmw from davinci.cfg
# mrw: "memory read word", returns value of $reg
proc mrw {reg} {
	set value ""
	ocd_mem2array value 32 $reg 1
	return $value(0)
}

# mmw: "memory modify word", updates value of $reg
#	$reg <== ((value & ~$clearbits) | $setbits)
proc mmw {reg setbits clearbits} {
	set old [mrw $reg]
	set new [expr ($old & ~$clearbits) | $setbits]
	mww $reg $new
}




proc setupNOR {} {
puts "Setting up NOR: 16MB, CS0"
# this is taken from u-boot/boards/mindspeed/ooma-darwin/board.c:nor_hw_init()

# this really belongs to c100regs.tcl
# can't get the global var. working
set APB_BASEADDR	0x1000
set EBUS_BASEADDR		[expr $APB_BASEADDR + 0x1A]
set EX_CSEN_REG		[expr $EBUS_BASEADDR + 0x04]
set EX_CS0_SEG_REG		[expr $EBUS_BASEADDR + 0x08]
set EX_CS0_CFG_REG		[expr $EBUS_BASEADDR + 0x1C]
set EX_CS0_TMG1_REG		[expr $EBUS_BASEADDR + 0x30]
set EX_CS0_TMG2_REG		[expr $EBUS_BASEADDR + 0x44]
set EX_CS0_TMG3_REG		[expr $EBUS_BASEADDR + 0x58]
set EX_CLOCK_DIV_REG	[expr $EBUS_BASEADDR + 0x6C]
set EX_MFSM_REG		[expr $EBUS_BASEADDR + 0x100]
set EX_MFSM_REG		[expr $EBUS_BASEADDR + 0x100]
set EX_CSFSM_REG		[expr $EBUS_BASEADDR + 0x104]
set EX_WRFSM_REG		[expr $EBUS_BASEADDR + 0x108]
set EX_RDFSM_REG		[expr $EBUS_BASEADDR + 0x10C]

#	/* set GPIO5 as output */
#	SoC_gpio_cfg(5, GPIO_TYPE_OUTPUT);
#
#	/* Select lower 8MiB of flash device */
#	SoC_gpio_set_0(SoC_gpio_mask(5));

#	*(volatile u32 *)EX_CS0_SEG_REG = 0x7FF;
#/* adjust EXP bus configuration registers */
#*(volatile u32 *)EX_CLOCK_DIV_REG = 0x5;
#*(volatile u32 *)EX_CS0_TMG1_REG = 0x03034006;
#*(volatile u32 *)EX_CS0_TMG2_REG = 0x04040002;


# enable Expansion Bus Clock + CS0 (NOR)
mww $EX_CSEN_REG 0x3
# set the address space for CS0=16MB
mww $EX_CS0_SEG_REG 0x7ff
# set the CS0 bus width to 16-bit
mww $EX_CS0_CFG_REG 0x202
# set timings to NOR
mww $EX_CS0_TMG1_REG 0x03034006
mww $EX_CS0_TMG2_REG 0x04040002
#mww $EX_CS0_TMG3_REG 
# set EBUS clock 165/5=33MHz
mww $EX_CLOCK_DIV_REG 0x5
# everthing else is OK with default
}

proc showNOR {} {
puts "This is the current NOR setup"
# this really belongs to c100regs.tcl
# can't get the global var. working
set APB_BASEADDR	0x1000
set EBUS_BASEADDR		[expr $APB_BASEADDR + 0x1A]
set EX_CSEN_REG		[expr $EBUS_BASEADDR + 0x04]
set EX_CS0_SEG_REG		[expr $EBUS_BASEADDR + 0x08]
set EX_CS0_CFG_REG		[expr $EBUS_BASEADDR + 0x1C]
set EX_CS0_TMG1_REG		[expr $EBUS_BASEADDR + 0x30]
set EX_CS0_TMG2_REG		[expr $EBUS_BASEADDR + 0x44]
set EX_CS0_TMG3_REG		[expr $EBUS_BASEADDR + 0x58]
set EX_CLOCK_DIV_REG	[expr $EBUS_BASEADDR + 0x6C]
set EX_MFSM_REG		[expr $EBUS_BASEADDR + 0x100]
set EX_MFSM_REG		[expr $EBUS_BASEADDR + 0x100]
set EX_CSFSM_REG		[expr $EBUS_BASEADDR + 0x104]
set EX_WRFSM_REG		[expr $EBUS_BASEADDR + 0x108]
set EX_RDFSM_REG		[expr $EBUS_BASEADDR + 0x10C]


puts [format "EX_CSEN_REG  (0x%x): 0x%x" $EX_CSEN_REG [mrw $EX_CSEN_REG]]
puts [format "EX_CS0_SEG_REG   (0x%x): 0x%x" $EX_CS0_SEG_REG [mrw $EX_CS0_SEG_REG]]
puts [format "EX_CS0_CFG_REG   (0x%x): 0x%x" $EX_CS0_CFG_REG [mrw $EX_CS0_CFG_REG]]
puts [format "EX_CS0_TMG1_REG  (0x%x): 0x%x" $EX_CS0_TMG1_REG [mrw $EX_CS0_TMG1_REG]]
puts [format "EX_CS0_TMG2_REG  (0x%x): 0x%x" $EX_CS0_TMG2_REG [mrw $EX_CS0_TMG2_REG]]
puts [format "EX_CS0_TMG3_REG  (0x%x): 0x%x" $EX_CS0_TMG3_REG [mrw $EX_CS0_TMG3_REG]]
puts [format "EX_CLOCK_DIV_REG (0x%x): 0x%x" $EX_CLOCK_DIV_REG [mrw $EX_CLOCK_DIV_REG]]
puts [format "EX_MFSM_REG  (0x%x): 0x%x" $EX_MFSM_REG [mrw $EX_MFSM_REG]]
puts [format "EX_CSFSM_REG (0x%x): 0x%x" $EX_CSFSM_REG [mrw $EX_CSFSM_REG]]
puts [format "EX_WRFSM_REG (0x%x): 0x%x" $EX_WRFSM_REG [mrw $EX_WRFSM_REG]]
puts [format "EX_RDFSM_REG (0x%x): 0x%x" $EX_RDFSM_REG [mrw $EX_RDFSM_REG]]
}

proc showGPIO {} {
puts "This is the current GPIO register setup"
# this really belongs to c100regs.tcl
# can't get the global var. working
set APB_BASEADDR	0x1000
set GPIO_BASEADDR		[expr $APB_BASEADDR + 0x07]
# GPIO outputs register
set GPIO_OUTPUT_REG		[expr $GPIO_BASEADDR + 0x00] 
# GPIO Output Enable register
set GPIO_OE_REG		[expr $GPIO_BASEADDR + 0x04] 
set GPIO_HI_INT_ENABLE_REG	[expr $GPIO_BASEADDR

Re: [Openocd-development] [Fwd: tcl questions.]

2009-08-31 Thread Duane Ellis

michal smulski wrote:

I have a couple questions about tcl:
1. How do you make variables defined as global (see c100regs.tcl &
c100helper.tcl) visible in procedures? I would like to reuse defines in
c100regs.tcl. Otherwise, I need to define them every time I want to use
them. I tried 'global' but it does not work.
  


Take a look at:   ${openocd}/tcl/chip/atmel/at91/aic.tcl - there are 
numerous examples.
You basically need to say "GLOBAL" everywhere... even at the "level0" 
(global) scope area.



2. How to I transfer register (say cpsr or r0) to a tcl variable
(similar to memory -> tcl in mmw())?
  

Not done yet :-( - that needs to be added to OpenOCD's version of TCL.

If you are interested in doing this work, I can help point to the path 
through the code.



3. I can't add comments wth # at the same line as the tcl command. This
is not a big deal but it would be nice to have.
  

This is a parsing problem with the way this version of  Tcl works.
Understand that "JimTCL" is a very stripped down and self contained Tcl 
implementation.

Thanks,
Michal
  



___
Openocd-development mailing list
Openocd-development@lists.berlios.de
https://lists.berlios.de/mailman/listinfo/openocd-development


___
Openocd-development mailing list
Openocd-development@lists.berlios.de
https://lists.berlios.de/mailman/listinfo/openocd-development


Re: [Openocd-development] [Fwd: tcl questions.]

2009-08-31 Thread michal smulski
When I run this code:

set CONFIG_SYS_HZ_CLOCK16500
global CONFIG_SYS_HZ_CLOCK

proc showAmbaPLL {} {
global CONFIG_SYS_HZ_CLOCK
puts [format "CONFIG_SYS_HZ_CLOCK %d" $CONFIG_SYS_HZ_CLOCK]
}

I get this message:
Runtime error, file "t.tcl", line 198:
can't read "CONFIG_SYS_HZ_CLOCK": no such variable
in procedure 'showAmbaPLL' called at file "command.c", line 473
> 

What am I doing wrong?
Thanks,
Michal


On Mon, 2009-08-31 at 08:20 -0400, Duane Ellis wrote:
> chip/atmel/at91/

___
Openocd-development mailing list
Openocd-development@lists.berlios.de
https://lists.berlios.de/mailman/listinfo/openocd-development


Re: [Openocd-development] [Fwd: tcl questions.]

2009-09-01 Thread Duane Ellis
michal smulski wrote:
> When I run this code:
>
> set CONFIG_SYS_HZ_CLOCK16500
> global CONFIG_SYS_HZ_CLOCK  
>
> proc showAmbaPLL {} {
> global CONFIG_SYS_HZ_CLOCK
> puts [format "CONFIG_SYS_HZ_CLOCK %d" $CONFIG_SYS_HZ_CLOCK]
> }
>
> I get this message:
> Runtime error, file "t.tcl", line 198:
> can't read "CONFIG_SYS_HZ_CLOCK": no such variable
> in procedure 'showAmbaPLL' called at file "command.c", line 473
>   
>
> What am I doing wrong?
>   

Not sure, it works for me as follows (below are cut & paste directly 
from my cygwin terminal)

 my openocd.cfg =
[NOTE: I am not configuring taps, or anything]

du...@desk ~/ocd/bare
$ cat openocd.cfg
source [find interface/olimex-jtag-tiny.cfg]

telnet_port 
gdb_port 

 my simple 't.tcl' =
du...@desk ~/ocd/bare
$ cat t.tcl

set CONFIG_SYS_HZ_CLOCK  1650
global CONFIG_SYS_HZ_CLOCK

proc duane {} {
global CONFIG_SYS_HZ_CLOCK
puts [format "The value is %d" $CONFIG_SYS_HZ_CLOCK]
}

du...@desk ~/ocd/bare
$
== telnet session===
Open On-Chip Debugger
 > source t.tcl
 >
 > info globals CONFIG_SYS_HZ_CLOCK
CONFIG_SYS_HZ_CLOCK
 > info globals
CONFIG_SYS_HZ_CLOCK ocd_cpu_list ocd_helptext jim_libpath ocd_HOSTOS 
jim_interac
tive
 >
 > duane
The value is 1650
 > exit


Connection to host lost.

du...@desk ~
$

___
Openocd-development mailing list
Openocd-development@lists.berlios.de
https://lists.berlios.de/mailman/listinfo/openocd-development