Hello!
I have basic memory access working with the amontec jtagkey. Now I’d like to download and run a program. I have this configuration:
#daemon configuration
telnet_port 4444
gdb_port 3333
#interface
interface ft2232
ft2232_device_desc "Amontec JTAGkey A"
ft2232_layout jtagkey
ft2232_vid_pid 0x0403 0xcff8
jtag_speed 1
#use combined on interfaces or targets that can't set TRST/SRST separately
reset_config trst_and_srst srst_pulls_trst
#jtag scan chain
#format L IRC IRCM IDCODE (Length, IR Capture, IR Capture Mask, IDCODE)
jtag_device 4 0x1 0xf 0xe
#target configuration
daemon_startup reset
#target <type> <startup mode>
#target arm7tdmi <reset mode> <chainpos> <endianness> <variant>
target arm7tdmi little run_and_init 0 arm7tdmi-s_r4
target_script 0 reset h2292_init.script
run_and_halt_time 0 30
working_area 0 0x40000000 0x40000 nobackup
#flash configuration
#flash bank lpc2000 0x0 0x40000 0 0 lpc2000_v1 0 14765 calc_checksum
flash bank cfi 0x80000000 0x200000 2 2 0
This is my test program:
# define CHIP_WR(baseadr,cadr,val) \
*((volatile unsigned short *)((baseadr)+(cadr)))=(val)
# define CHIP_RD(baseadr,cadr) \
(*(1+(volatile unsigned char *)((baseadr)+(cadr))))
static void chipcmd (unsigned char *addr, unsigned cmd)
{
unsigned int u1=0x5555;
unsigned int u2=0x2aaa;
CHIP_WR(addr, u1, 0xaaaa); /* unl1 */
CHIP_WR(addr, u2, 0x5555); /* unl2 */
CHIP_WR(addr, u1, cmd);
}
static void erase (unsigned char *addr)
{
unsigned char rval;
CHIP_WR(addr, 0x000, 0xf0f0); /* reset */
chipcmd(addr, 0x8080); /* erase */
chipcmd(addr, 0x1010); /* chip erase */
while ((rval = CHIP_RD (addr, 0)) != 0xff) {
/* FIXME: check timeout */
}
while (1)
;
}
void dohalt (void)
{
}
void doerase (void)
{
erase ((unsigned char *)0x80000000);
dohalt ();
}
This is how I compile the test program:
arm-elf-gcc -c -Wall -nostartfiles -fomit-frame-pointer -fpic test.c
arm-elf-gcc -Wall -nostartfiles -fomit-frame-pointer -fpic -Wl,-Map -Wl,map test.o -o test.elf
arm-elf-objcopy -O binary test.elf test.bin
This is the script to load/execute the program:
halt
# Load binary into external RAM
#
load_binary test.bin 0x81000000
# Check whether binary was loaded properly
#
dump_binary test.bla 0x81000000 272
# Linker's memory map says my entry point is located on 0x000080fc, but since
# it is compiled with -fpic, we should be able to move the code to 0x81000000,
# thus the entry point moves 32kb downward.
reg pc 0x810000fc
poll
mdw 0x81000000 70
reg
step
reg
shutdown
I would have expected that exactly one instruction would be executed and the processor would halt after that. But this is what happens:
Info: openocd.c:84 main(): Open On-Chip Debugger (2006-11-22 14:00 CEST)
Warning: arm7_9_common.c:683 arm7_9_assert_reset(): srst resets test logic, too
Info: target.c:219 target_init_handler(): executing reset script 'h2222_init.script'
Info: configuration.c:50 configuration_output_handler(): requesting target halt...
Warning: arm7_9_common.c:842 arm7_9_halt(): target was already halted
Info: configuration.c:50 configuration_output_handler(): target already halted
Info: configuration.c:50 configuration_output_handler(): downloaded 272 byte in 0s 13318us
Info: configuration.c:50 configuration_output_handler(): dumped 272 byte in 0s 20778us
Info: configuration.c:50 configuration_output_handler(): pc (/32): 0x810000fc
Info: configuration.c:50 configuration_output_handler(): target state: halted
Info: configuration.c:50 configuration_output_handler(): target halted in Thumb state due to debug request, current mode: System
Info: configuration.c:50 configuration_output_handler(): cpsr: 0x4000001f pc: 0x810000fc
Info: configuration.c:50 configuration_output_handler(): 0x81000000: e24dd010 e58d000c e58d1008 e3a03c55 e2833055 e58d3004 e3a03daa e283302a
Info: configuration.c:50 configuration_output_handler(): 0x81000020: e58d3000 e59d300c e59d2004 e0833002 e3e02c55 e2422055 e1a01002 e1c310b0
Info: configuration.c:50 configuration_output_handler(): 0x81000040: e59d300c e59d2000 e0833002 e3a02c55 e2822055 e1a01002 e1c310b0 e59d300c
Info: configuration.c:50 configuration_output_handler(): 0x81000060: e59d2004 e0833002 e1dd20b8 e1c320b0 e28dd010 e1a0f00e e92d4000 e24dd008
Info: configuration.c:50 configuration_output_handler(): 0x81000080: e58d0004 e59d3004 e3e02c0f e242200f e1a01002 e1c310b0 e59d0004 e3a01902
Info: configuration.c:50 configuration_output_handler(): 0x810000a0: e2811080 ebffffd5 e59d0004 e3a01a01 e2811010 ebffffd1 e3a03001 e59d2004
Info: configuration.c:50 configuration_output_handler(): 0x810000c0: e2823001 e5d32000 e5cd2003 e20230ff e35300ff 1a000000 ea000000 eafffff5
Info: configuration.c:50 configuration_output_handler(): 0x810000e0: e1a00000 ea000000 ea000000 eafffffc e28dd008 e8bd8000 e1a0f00e e92d4000
Info: configuration.c:50 configuration_output_handler(): 0x81000100: e3a00102 ebffffdb ebfffffa e8bd8000 00000000 00000000
Info: configuration.c:50 configuration_output_handler(): (0) r0 (/32): 0x000000ff (dirty: 1, valid: 1)
Info: configuration.c:50 configuration_output_handler(): (1) r1 (/32): 0x00003df3 (dirty: 1, valid: 1)
Info: configuration.c:50 configuration_output_handler(): (2) r2 (/32): 0x00000000 (dirty: 1, valid: 1)
Info: configuration.c:50 configuration_output_handler(): (3) r3 (/32): 0xe0020004 (dirty: 1, valid: 1)
Info: configuration.c:50 configuration_output_handler(): (4) r4 (/32): 0x000001d0 (dirty: 1, valid: 1)
Info: configuration.c:50 configuration_output_handler(): (5) r5 (/32): 0x0001c000 (dirty: 1, valid: 1)
Info: configuration.c:50 configuration_output_handler(): (6) r6 (/32): 0x40000d8c (dirty: 1, valid: 1)
Info: configuration.c:50 configuration_output_handler(): (7) r7 (/32): 0x400035d0 (dirty: 1, valid: 1)
Info: configuration.c:50 configuration_output_handler(): (8) r8 (/32): 0x400036c4 (dirty: 1, valid: 1)
Info: configuration.c:50 configuration_output_handler(): (9) r9 (/32): 0xe5cd2003 (dirty: 1, valid: 1)
Info: configuration.c:50 configuration_output_handler(): (10) r10 (/32): 0x400034a8 (dirty: 1, valid: 1)
Info: configuration.c:50 configuration_output_handler(): (11) r11 (/32): 0x400036e8 (dirty: 1, valid: 1)
Info: configuration.c:50 configuration_output_handler(): (12) r12 (/32): 0x000012a9 (dirty: 1, valid: 1)
Info: configuration.c:50 configuration_output_handler(): (13) r13_usr (/32): 0x40003590 (dirty: 1, valid: 1)
Info: configuration.c:50 configuration_output_handler(): (14) lr_usr (/32): 0x00003df3 (dirty: 1, valid: 1)
Info: configuration.c:50 configuration_output_handler(): (15) pc (/32): 0x810000fc (dirty: 1, valid: 1)
Info: configuration.c:50 configuration_output_handler(): (16) r8_fiq (/32): 0x00000000 (dirty: 0, valid: 0)
Info: configuration.c:50 configuration_output_handler(): (17) r9_fiq (/32): 0x00000000 (dirty: 0, valid: 0)
Info: configuration.c:50 configuration_output_handler(): (18) r10_fiq (/32): 0x00000000 (dirty: 0, valid: 0)
Info: configuration.c:50 configuration_output_handler(): (19) r11_fiq (/32): 0x00000000 (dirty: 0, valid: 0)
Info: configuration.c:50 configuration_output_handler(): (20) r12_fiq (/32): 0x00000000 (dirty: 0, valid: 0)
Info: configuration.c:50 configuration_output_handler(): (21) r13_fiq (/32): 0x00000000 (dirty: 0, valid: 0)
Info: configuration.c:50 configuration_output_handler(): (22) lr_fiq (/32): 0x00000000 (dirty: 0, valid: 0)
Info: configuration.c:50 configuration_output_handler(): (23) r13_irq (/32): 0x00000000 (dirty: 0, valid: 0)
Info: configuration.c:50 configuration_output_handler(): (24) lr_irq (/32): 0x00000000 (dirty: 0, valid: 0)
Info: configuration.c:50 configuration_output_handler(): (25) r13_svc (/32): 0x00000000 (dirty: 0, valid: 0)
Info: configuration.c:50 configuration_output_handler(): (26) lr_svc (/32): 0x00000000 (dirty: 0, valid: 0)
Info: configuration.c:50 configuration_output_handler(): (27) r13_abt (/32): 0x00000000 (dirty: 0, valid: 0)
Info: configuration.c:50 configuration_output_handler(): (28) lr_abt (/32): 0x00000000 (dirty: 0, valid: 0)
Info: configuration.c:50 configuration_output_handler(): (29) r13_und (/32): 0x00000000 (dirty: 0, valid: 0)
Info: configuration.c:50 configuration_output_handler(): (30) lr_und (/32): 0x00000000 (dirty: 0, valid: 0)
Info: configuration.c:50 configuration_output_handler(): (31) cpsr (/32): 0x4000001f (dirty: 0, valid: 1)
Info: configuration.c:50 configuration_output_handler(): (32) spsr_fiq (/32): 0x00000000 (dirty: 0, valid: 0)
Info: configuration.c:50 configuration_output_handler(): (33) spsr_irq (/32): 0x00000000 (dirty: 0, valid: 0)
Info: configuration.c:50 configuration_output_handler(): (34) spsr_svc (/32): 0x00000000 (dirty: 0, valid: 0)
Info: configuration.c:50 configuration_output_handler(): (35) spsr_abt (/32): 0x00000000 (dirty: 0, valid: 0)
Info: configuration.c:50 configuration_output_handler(): (36) spsr_und (/32): 0x00000000 (dirty: 0, valid: 0)
Info: configuration.c:50 configuration_output_handler(): (37) debug_ctrl (/6): 0x05 (dirty: 0, valid: 0)
Info: configuration.c:50 configuration_output_handler(): (38) debug_status (/5): 0x09 (dirty: 0, valid: 0)
Info: configuration.c:50 configuration_output_handler(): (39) comms_ctrl (/32): 0x00000000 (dirty: 0, valid: 0)
Info: configuration.c:50 configuration_output_handler(): (40) comms_data (/32): 0x00000000 (dirty: 0, valid: 0)
Info: configuration.c:50 configuration_output_handler(): (41) watch 0 addr value (/32): 0x00000000 (dirty: 0, valid: 0)
Info: configuration.c:50 configuration_output_handler(): (42) watch 0 addr mask (/32): 0x00000000 (dirty: 0, valid: 0)
Info: configuration.c:50 configuration_output_handler(): (43) watch 0 data value (/32): 0x00000000 (dirty: 0, valid: 0)
Info: configuration.c:50 configuration_output_handler(): (44) watch 0 data mask (/32): 0x00000000 (dirty: 0, valid: 0)
Info: configuration.c:50 configuration_output_handler(): (45) watch 0 control value (/32): 0x00000000 (dirty: 0, valid: 0)
Info: configuration.c:50 configuration_output_handler(): (46) watch 0 control mask (/32): 0x00000000 (dirty: 0, valid: 0)
Info: configuration.c:50 configuration_output_handler(): (47) watch 1 addr value (/32): 0x00000000 (dirty: 0, valid: 0)
Info: configuration.c:50 configuration_output_handler(): (48) watch 1 addr mask (/32): 0x00000000 (dirty: 0, valid: 0)
Info: configuration.c:50 configuration_output_handler(): (49) watch 1 data value (/32): 0x00000000 (dirty: 0, valid: 0)
Info: configuration.c:50 configuration_output_handler(): (50) watch 1 data mask (/32): 0x00000000 (dirty: 0, valid: 0)
Info: configuration.c:50 configuration_output_handler(): (51) watch 1 control value (/32): 0x00000000 (dirty: 0, valid: 0)
Info: configuration.c:50 configuration_output_handler(): (52) watch 1 control mask (/32): 0x00000000 (dirty: 0, valid: 0)
Info: target.c:219 target_init_handler(): executing reset script 'h2222_init.script'
Info: configuration.c:50 configuration_output_handler(): requesting target halt...
Warning: arm7_9_common.c:842 arm7_9_halt(): target was already halted
Info: configuration.c:50 configuration_output_handler(): target already halted
Info: configuration.c:50 configuration_output_handler(): downloaded 272 byte in 0s 11907us
Info: configuration.c:50 configuration_output_handler(): dumped 272 byte in 0s 19976us
Info: configuration.c:50 configuration_output_handler(): pc (/32): 0x810000fc
Info: configuration.c:50 configuration_output_handler(): target state: halted
Info: configuration.c:50 configuration_output_handler(): target halted in Thumb state due to single step, current mode: System
Info: configuration.c:50 configuration_output_handler(): cpsr: 0x0000001f pc: 0x810000fc
Info: configuration.c:50 configuration_output_handler(): 0x81000000: e24dd010 e58d000c e58d1008 e3a03c55 e2833055 e58d3004 e3a03daa e283302a
Info: configuration.c:50 configuration_output_handler(): 0x81000020: e58d3000 e59d300c e59d2004 e0833002 e3e02c55 e2422055 e1a01002 e1c310b0
Info: configuration.c:50 configuration_output_handler(): 0x81000040: e59d300c e59d2000 e0833002 e3a02c55 e2822055 e1a01002 e1c310b0 e59d300c
Info: configuration.c:50 configuration_output_handler(): 0x81000060: e59d2004 e0833002 e1dd20b8 e1c320b0 e28dd010 e1a0f00e e92d4000 e24dd008
Info: configuration.c:50 configuration_output_handler(): 0x81000080: e58d0004 e59d3004 e3e02c0f e242200f e1a01002 e1c310b0 e59d0004 e3a01902
Info: configuration.c:50 configuration_output_handler(): 0x810000a0: e2811080 ebffffd5 e59d0004 e3a01a01 e2811010 ebffffd1 e3a03001 e59d2004
Info: configuration.c:50 configuration_output_handler(): 0x810000c0: e2823001 e5d32000 e5cd2003 e20230ff e35300ff 1a000000 ea000000 eafffff5
Info: configuration.c:50 configuration_output_handler(): 0x810000e0: e1a00000 ea000000 ea000000 eafffffc e28dd008 e8bd8000 e1a0f00e e92d4000
Info: configuration.c:50 configuration_output_handler(): 0x81000100: e3a00102 ebffffdb ebfffffa e8bd8000 00000000 00000000
Info: configuration.c:50 configuration_output_handler(): (0) r0 (/32): 0x000000ff (dirty: 1, valid: 1)
Info: configuration.c:50 configuration_output_handler(): (1) r1 (/32): 0x00003df3 (dirty: 1, valid: 1)
Info: configuration.c:50 configuration_output_handler(): (2) r2 (/32): 0x00000000 (dirty: 1, valid: 1)
Info: configuration.c:50 configuration_output_handler(): (3) r3 (/32): 0xe0020004 (dirty: 1, valid: 1)
Info: configuration.c:50 configuration_output_handler(): (4) r4 (/32): 0x000001d0 (dirty: 1, valid: 1)
Info: configuration.c:50 configuration_output_handler(): (5) r5 (/32): 0x0001c000 (dirty: 1, valid: 1)
Info: configuration.c:50 configuration_output_handler(): (6) r6 (/32): 0x40000d8c (dirty: 1, valid: 1)
Info: configuration.c:50 configuration_output_handler(): (7) r7 (/32): 0x400035d0 (dirty: 1, valid: 1)
Info: configuration.c:50 configuration_output_handler(): (8) r8 (/32): 0x400036c4 (dirty: 1, valid: 1)
Info: configuration.c:50 configuration_output_handler(): (9) r9 (/32): 0xe5cd2003 (dirty: 1, valid: 1)
Info: configuration.c:50 configuration_output_handler(): (10) r10 (/32): 0x400034a8 (dirty: 1, valid: 1)
Info: configuration.c:50 configuration_output_handler(): (11) r11 (/32): 0x400036e8 (dirty: 1, valid: 1)
Info: configuration.c:50 configuration_output_handler(): (12) r12 (/32): 0x000012a9 (dirty: 1, valid: 1)
Info: configuration.c:50 configuration_output_handler(): (13) r13_usr (/32): 0x40003590 (dirty: 1, valid: 1)
Info: configuration.c:50 configuration_output_handler(): (14) lr_usr (/32): 0x00003df3 (dirty: 1, valid: 1)
Info: configuration.c:50 configuration_output_handler(): (15) pc (/32): 0x810000fc (dirty: 1, valid: 1)
Info: configuration.c:50 configuration_output_handler(): (16) r8_fiq (/32): 0x00000000 (dirty: 0, valid: 0)
Info: configuration.c:50 configuration_output_handler(): (17) r9_fiq (/32): 0x00000000 (dirty: 0, valid: 0)
Info: configuration.c:50 configuration_output_handler(): (18) r10_fiq (/32): 0x00000000 (dirty: 0, valid: 0)
Info: configuration.c:50 configuration_output_handler(): (19) r11_fiq (/32): 0x00000000 (dirty: 0, valid: 0)
Info: configuration.c:50 configuration_output_handler(): (20) r12_fiq (/32): 0x00000000 (dirty: 0, valid: 0)
Info: configuration.c:50 configuration_output_handler(): (21) r13_fiq (/32): 0x00000000 (dirty: 0, valid: 0)
Info: configuration.c:50 configuration_output_handler(): (22) lr_fiq (/32): 0x00000000 (dirty: 0, valid: 0)
Info: configuration.c:50 configuration_output_handler(): (23) r13_irq (/32): 0x00000000 (dirty: 0, valid: 0)
Info: configuration.c:50 configuration_output_handler(): (24) lr_irq (/32): 0x00000000 (dirty: 0, valid: 0)
Info: configuration.c:50 configuration_output_handler(): (25) r13_svc (/32): 0x00000000 (dirty: 0, valid: 0)
Info: configuration.c:50 configuration_output_handler(): (26) lr_svc (/32): 0x00000000 (dirty: 0, valid: 0)
Info: configuration.c:50 configuration_output_handler(): (27) r13_abt (/32): 0x00000000 (dirty: 0, valid: 0)
Info: configuration.c:50 configuration_output_handler(): (28) lr_abt (/32): 0x00000000 (dirty: 0, valid: 0)
Info: configuration.c:50 configuration_output_handler(): (29) r13_und (/32): 0x00000000 (dirty: 0, valid: 0)
Info: configuration.c:50 configuration_output_handler(): (30) lr_und (/32): 0x00000000 (dirty: 0, valid: 0)
Info: configuration.c:50 configuration_output_handler(): (31) cpsr (/32): 0x0000001f (dirty: 0, valid: 1)
Info: configuration.c:50 configuration_output_handler(): (32) spsr_fiq (/32): 0x00000000 (dirty: 0, valid: 0)
Info: configuration.c:50 configuration_output_handler(): (33) spsr_irq (/32): 0x00000000 (dirty: 0, valid: 0)
Info: configuration.c:50 configuration_output_handler(): (34) spsr_svc (/32): 0x00000000 (dirty: 0, valid: 0)
Info: configuration.c:50 configuration_output_handler(): (35) spsr_abt (/32): 0x00000000 (dirty: 0, valid: 0)
Info: configuration.c:50 configuration_output_handler(): (36) spsr_und (/32): 0x00000000 (dirty: 0, valid: 0)
Info: configuration.c:50 configuration_output_handler(): (37) debug_ctrl (/6): 0x05 (dirty: 0, valid: 0)
Info: configuration.c:50 configuration_output_handler(): (38) debug_status (/5): 0x09 (dirty: 0, valid: 0)
Info: configuration.c:50 configuration_output_handler(): (39) comms_ctrl (/32): 0x00000000 (dirty: 0, valid: 0)
Info: configuration.c:50 configuration_output_handler(): (40) comms_data (/32): 0x00000000 (dirty: 0, valid: 0)
Info: configuration.c:50 configuration_output_handler(): (41) watch 0 addr value (/32): 0x00000000 (dirty: 0, valid: 0)
Info: configuration.c:50 configuration_output_handler(): (42) watch 0 addr mask (/32): 0x00000000 (dirty: 0, valid: 0)
Info: configuration.c:50 configuration_output_handler(): (43) watch 0 data value (/32): 0x00000000 (dirty: 0, valid: 0)
Info: configuration.c:50 configuration_output_handler(): (44) watch 0 data mask (/32): 0x00000000 (dirty: 0, valid: 0)
Info: configuration.c:50 configuration_output_handler(): (45) watch 0 control value (/32): 0x00000000 (dirty: 0, valid: 0)
Info: configuration.c:50 configuration_output_handler(): (46) watch 0 control mask (/32): 0x00000000 (dirty: 0, valid: 0)
Info: configuration.c:50 configuration_output_handler(): (47) watch 1 addr value (/32): 0x00000000 (dirty: 0, valid: 0)
Info: configuration.c:50 configuration_output_handler(): (48) watch 1 addr mask (/32): 0x00000000 (dirty: 0, valid: 0)
Info: configuration.c:50 configuration_output_handler(): (49) watch 1 data value (/32): 0x00000000 (dirty: 0, valid: 0)
Info: configuration.c:50 configuration_output_handler(): (50) watch 1 data mask (/32): 0x00000000 (dirty: 0, valid: 0)
Info: configuration.c:50 configuration_output_handler(): (51) watch 1 control value (/32): 0x00000000 (dirty: 0, valid: 0)
Info: configuration.c:50 configuration_output_handler(): (52) watch 1 control mask (/32): 0x00000000 (dirty: 0, valid: 0)
Info: target.c:219 target_init_handler(): executing reset script 'h2222_init.script'
[ ... ]
As you can see, the reset script is executed over and over again when the “step” command is executed. Looks like executing the instruction 0xe92d4000 resets the target. I am sure I’m doing something very stupid, but I can’t figure out what. Any ideas?