From: Freddie C. <fre...@op...> - 2011-11-18 21:24:10
|
Hi! A bug in script handling was found on our Polish electronics forum. The problem was found when using LPC2xxx files (these are somewhat generic from some time), but it's not a problem with the files themselves but with the construct used in them. Some time ago a idea of "initialization function" was introduced - the config file for target does not need to have any "linear code" in it, but an "init_targets" procedure is sufficient - this will be called during OpenOCD startup. LPC2xxx files are the only ones that use this sheme. When OpenOCD is started normally everything works fine: > >openocd-0.5.0 -f interface/jtagkey.cfg -f target/lpc2103.cfg > Open On-Chip Debugger 0.5.0 (2011-08-09-23:21) > Licensed under GNU GPL v2 > For bug reports, read > http://openocd.berlios.de/doc/doxygen/bugs.html > Info : only one transport option; autoselect 'jtag' > init_targets > Warning - assuming default core clock 12MHz! Flashing may fail if actual core cl > ock is different. > trst_and_srst separate srst_gates_jtag trst_push_pull srst_open_drain > adapter_nsrst_delay: 100 > jtag_ntrst_delay: 100 > 1500 kHz > Info : clock speed 1500 kHz > Info : JTAG tap: lpc2103.cpu tap/device found: 0x4f1f0f0f (mfg: 0x787, part: 0xf > 1f0, ver: 0x4) > Info : Embedded ICE version 4 > Info : lpc2103.cpu: hardware has 2 breakpoint/watchpoint units You can connect via telnet or whatever and do whatever you want. The problem starts when you'd like to have some commands in the call or use a config script with commands (e.g. for flashing). Even the most trivial example fails with strange errors: > >openocd-0.5.0 -f interface/jtagkey.cfg -f target/lpc2103.cfg -c "init" > Open On-Chip Debugger 0.5.0 (2011-08-09-23:21) > Licensed under GNU GPL v2 > For bug reports, read > http://openocd.berlios.de/doc/doxygen/bugs.html > Info : only one transport option; autoselect 'jtag' > init_targets > Error: An adapter speed is not selected in the init script. Insert a call to ada > pter_khz or jtag_rclk to proceed. > in procedure 'init' Adding any number of commands after init changes nothing... So maybe calling init_targets directly? > >openocd-0.5.0 -f interface/jtagkey.cfg -f target/lpc2103.cfg -c "init_targets" > Open On-Chip Debugger 0.5.0 (2011-08-09-23:21) > Licensed under GNU GPL v2 > For bug reports, read > http://openocd.berlios.de/doc/doxygen/bugs.html > Info : only one transport option; autoselect 'jtag' > init_targets > Warning - assuming default core clock 12MHz! Flashing may fail if actual core cl > ock is different. > trst_and_srst separate srst_gates_jtag trst_push_pull srst_open_drain > adapter_nsrst_delay: 100 > jtag_ntrst_delay: 100 > 1500 kHz > Warning - assuming default core clock 12MHz! Flashing may fail if actual core cl > ock is different. > trst_and_srst separate srst_gates_jtag trst_push_pull srst_open_drain > adapter_nsrst_delay: 100 > jtag_ntrst_delay: 100 > 1500 kHz > Runtime Error: embedded:startup.tcl:20: Command/target: lpc2103.cpu Exists > in procedure 'init_targets' > in procedure 'setup_lpc2103' called at file "D:\openocd-dev\openocd-0.5.0\bin\.. > /target/lpc2103.cfg", line 20 > in procedure 'setup_lpc2xxx' called at file "D:\openocd-dev\openocd-0.5.0\bin\.. > /target/lpc2103.cfg", line 12 > in procedure 'target' called at file "D:\openocd-dev\openocd-0.5.0\bin\../target > /lpc2xxx.cfg", line 28 > in procedure 'ocd_bouncer' > at file "embedded:startup.tcl", line 20 > Info : clock speed 1500 kHz > Info : JTAG tap: lpc2103.cpu tap/device found: 0x4f1f0f0f (mfg: 0x787, part: 0xf > 1f0, ver: 0x4) > Info : JTAG tap: lpc2103.cpu tap/device found: 0x000000ff (mfg: 0x07f, part: 0x0 > 000, ver: 0x0) > Warn : JTAG tap: lpc2103.cpu UNEXPECTED: 0x000000ff (mfg: 0x07f, part: 0x0 > 000, ver: 0x0) > Error: JTAG tap: lpc2103.cpu expected 1 of 1: 0x4f1f0f0f (mfg: 0x787, part: 0xf > 1f0, ver: 0x4) > Error: Trying to use configured scan chain anyway... > Error: lpc2103.cpu: IR capture error; saw 0x0f not 0x01 > Warn : Bypassing JTAG setup events due to errors > Info : Embedded ICE version 0 > Error: unknown EmbeddedICE version (comms ctrl: 0x00000000) > Info : lpc2103.cpu: hardware has 2 breakpoint/watchpoint units This way the target is initialized twice, something works, adding some useful commands works but there are still a ton of errors... > >openocd-0.5.0 -f interface/jtagkey.cfg -f target/lpc2103.cfg -c "init_targets; init; reset halt" > Open On-Chip Debugger 0.5.0 (2011-08-09-23:21) > Licensed under GNU GPL v2 > For bug reports, read > http://openocd.berlios.de/doc/doxygen/bugs.html > Info : only one transport option; autoselect 'jtag' > init_targets > Warning - assuming default core clock 12MHz! Flashing may fail if actual core cl > ock is different. > trst_and_srst separate srst_gates_jtag trst_push_pull srst_open_drain > adapter_nsrst_delay: 100 > jtag_ntrst_delay: 100 > 1500 kHz > Info : clock speed 1500 kHz > Info : JTAG tap: lpc2103.cpu tap/device found: 0x4f1f0f0f (mfg: 0x787, part: 0xf > 1f0, ver: 0x4) > Info : Embedded ICE version 4 > Info : lpc2103.cpu: hardware has 2 breakpoint/watchpoint units > Info : JTAG tap: lpc2103.cpu tap/device found: 0x4f1f0f0f (mfg: 0x787, part: 0xf > 1f0, ver: 0x4) > target state: halted > target halted in ARM state due to debug-request, current mode: Supervisor > cpsr: 0x000000d3 pc: 0x00000000 > Warn : NOTE! DCC downloads have not been enabled, defaulting to slow memory writ > es. Type 'help dcc'. > Warn : NOTE! Severe performance degradation without fast memory access enabled. > Type 'help fast'. > Warning - assuming default core clock 12MHz! Flashing may fail if actual core cl > ock is different. > trst_and_srst separate srst_gates_jtag trst_push_pull srst_open_drain > adapter_nsrst_delay: 100 > jtag_ntrst_delay: 100 > 1500 kHz > Runtime Error: embedded:startup.tcl:20: Command/target: lpc2103.cpu Exists > in procedure 'init_targets' > in procedure 'setup_lpc2103' called at file "D:\openocd-dev\openocd-0.5.0\bin\.. > /target/lpc2103.cfg", line 20 > in procedure 'setup_lpc2xxx' called at file "D:\openocd-dev\openocd-0.5.0\bin\.. > /target/lpc2103.cfg", line 12 > in procedure 'target' called at file "D:\openocd-dev\openocd-0.5.0\bin\../target > /lpc2xxx.cfg", line 28 > in procedure 'ocd_bouncer' > at file "embedded:startup.tcl", line 20 I think that init_targets procedure is called wrong when "init" command is passed to OpenOCD. It is called (the "init_targets" line in output), but somehow does not work... Any ideas how to fix that? 4\/3!! |