Hello!
I have managed to load and execute a program to erase and program the flash. For this, I use the following script:
halt
armv4_5 core_state arm # make sure we are in ARM mode
reg cpsr 0x600000df # disable interrupts
load_binary flash.bin 0x81000000 # load the program
# that's the dohalt() function. The target calls this function when it has
# done its work, giving control back to this script.
#
bp 0x81000000 4 hw
# First, erase the chip
#
reg r0 0x80000000 # address of flash chip
resume 0x81000004 # doerase() function
wait_halt
poll
mdw 0x80000000 0x10 # Check whether it is really erased
# Now load kernel and root-fs and program it all in one go.
#
load_binary ../uClinux-dist-20051014/images/linux.bin 0x81001000
load_binary ../uClinux-dist-20051014/images/cramfs.bin 0x81161000
reg r0 0x80000000 # address of chip
reg r1 0x81001000 # here was the binary loaded
reg r2 0x200000 # the length of the binary
resume 0x81000008 # doprogram()
wait_halt
poll
dump_binary fl 0x80000000 2097152 # Look what we've done
shutdown
Everything works as expected, as long as the length of the flash region (loaded into r2) is less than 0x85800. But if I load a bigger value, I get the following:
time ../openocd/src/openocd -f arm7_ft2232.cfg
Info: openocd.c:84 main(): Open On-Chip Debugger (2006-11-22 14:00 CEST)
Info: target.c:221 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(): core state: ARM
Info: configuration.c:50 configuration_output_handler(): cpsr (/32): 0x600000df
Info: configuration.c:50 configuration_output_handler(): downloaded 264 byte in 0s 15845us
Info: configuration.c:50 configuration_output_handler(): breakpoint added at address 0x81000000
Info: configuration.c:50 configuration_output_handler(): r0 (/32): 0x80000000
Info: configuration.c:50 configuration_output_handler(): waiting for target halted...
Info: configuration.c:50 configuration_output_handler(): target halted
Info: configuration.c:50 configuration_output_handler(): target state: halted
Info: configuration.c:50 configuration_output_handler(): target halted in ARM state due to breakpoint, current mode: System
Info: configuration.c:50 configuration_output_handler(): cpsr: 0x600000df pc: 0x81000000
Info: configuration.c:50 configuration_output_handler(): 0x80000000: ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff
Info: configuration.c:50 configuration_output_handler(): 0x80000020: ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff
Info: configuration.c:50 configuration_output_handler(): downloaded 1311136 byte in 47s 178603us
Info: configuration.c:50 configuration_output_handler(): downloaded 614400 byte in 22s 364636us
Info: configuration.c:50 configuration_output_handler(): r0 (/32): 0x80000000
Info: configuration.c:50 configuration_output_handler(): r1 (/32): 0x81001000
Info: configuration.c:50 configuration_output_handler(): r2 (/32): 0x00200000
Info: configuration.c:50 configuration_output_handler(): r2 (/32): 0x00086000
Info: configuration.c:50 configuration_output_handler(): waiting for target halted...
Info: configuration.c:50 configuration_output_handler(): timed out while waiting for target halt
Error: target.c:1241 handle_wait_halt_command(): timed out while waiting for target halt
Info: configuration.c:50 configuration_output_handler(): target state: running
Warning: arm7_9_common.c:1680 arm7_9_read_memory(): target not halted
Warning: arm7_9_common.c:1680 arm7_9_read_memory(): target not halted
Warning: arm7_9_common.c:1680 arm7_9_read_memory(): target not halted
[ ... several thousand identical lines deleted ... ]
Warning: arm7_9_common.c:1680 arm7_9_read_memory(): target not halted
Warning: arm7_9_common.c:1680 arm7_9_read_memory(): target not halted
Warning: arm7_9_common.c:1680 arm7_9_read_memory(): target not halted
Info: configuration.c:50 configuration_output_handler(): dumped 2097152 byte in 0s 302944us
Nevertheless, the requested region of the flash is still programmed properly.
Even more interesting: with a size of 0x85e00, the target times out exactly once and seems to resume proper operation again.
What might go wrong here?