summaryrefslogtreecommitdiff
path: root/OlimexLPC2148Setup.mdwn
blob: 44b2ce1b655aec51a91c85a9a759a76e5f0cd3e5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
## Background Reading and Useful Links:

- Good detailed instruction on ARM/Eclipse Development by James Lynch. The details aren't particularly relivent to how were doing it, but it's good for getting a conceptual understanding if you've never messed with it. [http://www.sparkfun.com/tutorial/ARM/ARM\_Cross\_Development\_with\_Eclipse.pdf](http://www.sparkfun.com/tutorial/ARM/ARM_Cross_Development_with_Eclipse.pdf)
- LPC2148 Datasheets: <http://www.keil.com/dd/chip/3880.htm>
- LPC 2148 Manual (Rev. 02) [[user.manual.lpc2141.lpc2142.lpc2144.lpc2146.lpc2148.pdf]]
- LPC 2148 Manual (Rev. 01) <http://www.keil.com/dd/docs/datashts/philips/user_manual_lpc214x.pdf>
- Instruction set high level description <http://www.simplemachines.it/doc/arm_inst.pdf>
- Arm Instruction Set Reference <http://infocenter.arm.com/help/topic/com.arm.doc.qrc0001l/QRC0001_UAL.pdf>
- Arm Thumb Instruction Set Reference <http://infocenter.arm.com/help/topic/com.arm.doc.qrc0006d/QRC0006_UAL16.pdf>
- Arm7TDMI Technical Reference Manual <http://infocenter.arm.com/help/topic/com.arm.doc.ddi0210c/DDI0210B.pdf>
- Info on Olimex ARM-USB-OCD Programming with OpenOCD [http://www.openhardware.net/Embedded\_ARM/OpenOCD\_JTAG/](http://www.openhardware.net/Embedded_ARM/OpenOCD_JTAG/)
- Schematic for Olimex Dev Board: <http://www.olimex.com/dev/images/lpc-p2148-sch.gif>
- Yahoo group on LPC Development: <http://tech.groups.yahoo.com/group/lpc2000/>
- OpenOCD Quick Reference Command Card: <http://www.fh-augsburg.de/~hhoegl/proj/openocd/oocd-quickref.pdf>
- Free e-book book, "Insiders Guide to the Philips Arm 7", I haven't read it but it was reccomended: <http://www.hitex.co.uk/arm/lpc2000book/>
- Olimex ARM-USB-OCD Programmer <http://www.olimex.com/dev/arm-usb-ocd.html>
- 2148 FreeRTOS Port [[lpc2148_freertos.zip]]
- GNU-ARM Utilities (including Linux): <http://www.gnuarm.com/>
- Download openocd for windows here: <http://www.yagarto.de/howto/openocd/index.html#install>
    
## General Physical Setup:

- Set the jumpers on the ARM-USB-OCD JTAG programmer to 9 volt DC. See <http://www.olimex.com/dev/pdf/ARM-USB-OCD.pdf> for instrucitons
- Both dip-switches on the board should be in the `off` position
- Make sure the debug jumper is jumpered (next to the JTAG port on the Olimex LPC2148 dev board)

## Setup under Linux

- Install the FTDI library, do this as `root`. Note, the library provided by FTDI is libc6, i386-32bit. I was not able to get this working on my x86-64bit linux install. I instead installed on a 32 bit linux install.
  1. Download this: <http://www.ftdichip.com/Drivers/D2XX/Linux/libftd2xx0.4.13.tar.gz>
  2. Decompress and untar: tar -zxf libftd2xx0.4.13.tar.gz
  3. Their official instructions are in the 'README.dat' file.
  4. Copy the header files: `cp \*.h /usr/local/include/`
  5. Copy the library file: `cp libftd2xx.so.0.4.13 /usr/local/lib`
  6. `cd /usr/local/lib`
  7. `ln -s libftd2xx.so.0.4.13 libftd2xx.so`
  8. `cd /usr/lib`
  9. `ln -s /usr/local/lib/libftd2xx.so.0.4.13 libftd2xx.so`
    1. For a 2.6 kernel: add this to /etc/fstab `none /proc/bus/usb usbfs defaults,mode=0666 0 0`
    2. For a 2.4 kernel: add this to /etc/fstab `none /proc/bus/usb usbdevfs defaults,mode=0666 0 0`
  10. Make sure `/usr/local/lib` is in /etc/ld.so.conf
  11. Run `ldconfig`
  12. run `mount -a` (it might spew out some warnings)
- Install openocd - Additional Info <http://bec-systems.com/web/content/view/74/9/>, [http://www.openhardware.net/Embedded\_ARM/OpenOCD\_JTAG/](http://www.openhardware.net/Embedded_ARM/OpenOCD_JTAG/)
  1. svn checkout svn://svn.berlios.de/openocd/trunk openocd
  2. cd openocd
  3. ./bootstrap
  4. ./configure --enable-ft2232\_ftd2xx
  5. make
  6. make install
- Try openOCD
   - If your using a newer version of open ocd (approx >0.3)
      - openocd -f interface/olimex-arm-usb-ocd.cfg -f target/lpc2378.cfg
      - You should see somthing like the following:

                openocd -f interface/olimex-arm-usb-ocd.cfg -f target/lpc2378.cfg
                Open On-Chip Debugger 0.3.1 (2009-11-25-12:22)
                $URL$
                For bug reports, read
                	http://openocd.berlios.de/doc/doxygen/bugs.html
                jtag_nsrst_delay: 200
                jtag_ntrst_delay: 200
                trst_and_srst srst_pulls_trst srst_gates_jtag trst_push_pull srst_open_drain
                500 kHz
                Info : clock speed 500 kHz
                Info : JTAG tap: lpc2378.cpu tap/device found: 0x4f1f0f0f (mfg: 0x787, part: 0xf1f0, ver: 0x4)
                Info : Embedded ICE version 7
                Error: EmbeddedICE v7 handling might be broken


   - If you using an older version of OpenOCD
      - create the file `lpc2xxx\_armusbocd.cfg`, and copy and paste the contents as listed at the bottom of this page.
      - run `openocd -f&lt;path-to-config-file&gt;` You should see it start up and stay running. If it spews out errors and exits you have a problem. So long as you get a state back, it's working.

                root@jtag:~# openocd -flpc2xxx_armusbocd.cfg
                Info:    openocd.c:92 main(): Open On-Chip Debugger (2007-07-15 13:15 CEST)
                Info:    configuration.c:50 configuration_output_handler(): Command swbkpts not found
                Warning: arm7_9_common.c:684 arm7_9_assert_reset(): srst resets test logic, too

   - In a separate terminal, run `telnet localhost 4444`
      - type `poll`. You should see it may be in a 'halted' state or 'running' state

                root@jtag:~# telnet localhost 4444
                Trying 127.0.0.1...
                Connected to localhost.
                Escape character is '^]'.
                Open On-Chip Debugger
                \> poll
                target state: halted
                target halted in Thumb state due to debug request, current mode: Supervisor
                cpsr: 0xa00000f3 pc: 0x7fffd2c4
                \>    

- Install GNU-Arm utilities
  - Pre-compiled utilities are available from <http://www.gnuarm.com/>. I used the 64 bit binary utils: [http://www.gnuarm.com/bu-2.16.1\_gcc-4.0.2-c-c++\_nl-1.14.0\_gi-6.4\_x86-64.tar.bz2](http://www.gnuarm.com/bu-2.16.1_gcc-4.0.2-c-c++_nl-1.14.0_gi-6.4_x86-64.tar.bz2). They also have 32 bit utils: [http://www.gnuarm.com/bu-2.15\_gcc-3.4.3-c-c++-java\_nl-1.12.0\_gi-6.1.tar.bz2](http://www.gnuarm.com/bu-2.15_gcc-3.4.3-c-c++-java_nl-1.12.0_gi-6.1.tar.bz2). If you picky about versions, you can download all the latest source code versions and compile whatever you like.
  - Decompress and un-tar the file.
  - Move the extracted directory to /usr/local/gnuarm-4.0.2 (or another appropiate location)
  - Note: to use the stuff, you'll need to change your path: 'export PATH="/usr/local/gnuarm-4.0.2/bin:$PATH"'
- Setup Eclipse
  - I'll refer you to James Lynch's instructions for project setup (link at top of this page)
- Modifications to FreeRTOS make file once it's in eclipse
  - Add the 'all' target: all: $(PROJECT).hex
  - Have the make file create a 'bin' file: add '$(OBJCOPY) $(PROJECT).elf -O binary $(PROJECT).bin' under the '$(PROJECT).hex : $(PROJECT).elf' section
  - Find 'arm-elf-size.exe' and replace with 'arm-elf-size'
  - Add the following around line 46:
    - USE_THUMB_MODE=NO
    DEBUG=
    OPTIM=-O3
    RUN_MODE=RUN_FROM_ROM
    LDSCRIPT=lpc2148-rom.ld
  - Change the project PATH enviromental variable (Note: If you did this change in your default profile you need not modify the eclipse variable.)
    - Right click on the project, goto properties, goto "C/C++ Make Project", click the 'Enviroment' tab. Click the 'New' button. Set the variable name to 'PATH' and the value to '/usr/local/gnuarm-4.0.2/bin:$PATH' (or whatever your arm-gcc install bin directory is.
- Programming
  - Create the file 'oocd\_flash\_lpc2148.script' (contents at bottom of this page). Note: Be sure to change the path of the 'bin' file to where you compiled FreeRTOS.
  - Modify your 'lpc2xxx\_armusbocd.cfg' and un-comment the 'target\_script \*' line, be sure to mofify the location of the script file to where you have saved your script.
  - Set the ICSP dip switch 1 to 'on' on the Olimex board. Hit the reset button
  - Startup OpenOCD
  - You may need to telnet into port 4444 and type 'halt' to get it to re-program
  - You should see somthing like this on the output of openocd

            root@jtag:~# openocd -flpc2xxx_armusbocd.cfg
            Info:    openocd.c:92 main(): Open On-Chip Debugger (2007-07-15 13:15 CEST)    
            Info:    configuration.c:50 configuration_output_handler(): Command swbkpts not found
            Warning: arm7_9_common.c:684 arm7_9_assert_reset(): srst resets test logic, too
            Info:    target.c:231 target_init_handler(): executing reset script 'oocd_flash_lpc2148.script'
            Info:    configuration.c:50 configuration_output_handler(): dcc downloads are enabled
            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 Thumb state due to debug request, current mode: Supervisor
            Info:    configuration.c:50 configuration_output_handler(): cpsr: 0xa00000f3 pc: 0x7fffd2c0
            Info:    configuration.c:50 configuration_output_handler(): flash 'lpc2000' found at 0x00000000
            Info:    configuration.c:50 configuration_output_handler(): erased sectors 0 through 26 on flash bank 0 in 0s 599613us
            Info:    configuration.c:50 configuration_output_handler(): wrote 11008 byte from file /drives/sdd1/Incoming/lpc2148_freertos.bin to flash bank 0 at offset 0x00000000 in 0s 863727us (12.446062 kb/s)
            Warning: arm7_9_common.c:684 arm7_9_assert_reset(): srst resets test logic, too
            root@jtag:~#

  - Set the ICSP dip switch to 'off' and hit reset.
  - The MCU should now run what you've programmed.

## Alternate Setup under Debian Linux (courtesy of Bdale Garbee, thanks Bdale!)

Fetch upstream bits, and populate a Dist/ directory

       export MYSRCPATH=/home/bdale/src/cross-tools
       export MYPREFIX=/opt/cross

       mkdir -p $MYSRCPATH/Dist
       cd $MYSRCPATH/Dist

       wget ftp://ftp.gnu.org/gnu/gcc/gcc-4.2.1/gcc-4.2.1.tar.bz2
       wget ftp://ftp.gnu.org/gnu/gcc/gcc-4.2.1/gcc-4.2.1.tar.bz2.sig
       gpg --verify gcc-4.2.1.tar.bz2.sig

       wget ftp://ftp.gnu.org/gnu/binutils/binutils-2.17.tar.bz2
       wget ftp://ftp.gnu.org/gnu/binutils/binutils-2.17.tar.bz2.sig
       gpg --verify binutils-2.17.tar.bz2.sig

       wget ftp://ftp.gnu.org/gnu/gdb/gdb-6.6.tar.bz2
       wget ftp://ftp.gnu.org/gnu/gdb/gdb-6.6.tar.bz2.sig
       gpg --verify gdb-6.6.tar.bz2.sig

       wget ftp://sources.redhat.com/pub/newlib/newlib-1.15.0.tar.gz

       wget http://www.gnuarm.com/t-arm-elf

 Unpack upstream bits, and prepare build environment.  Resurrecting the
 "one-tree" script would make this more efficient, but compile cycles are
 cheap enough that it's probably not worth worrying about...

       cd $MYSRCPATH

       tar xvjf Dist/binutils-2.17.tar.bz2
       tar xvjf Dist/gcc-4.2.1.tar.bz2
       tar xvjf Dist/gdb-6.6.tar.bz2
       tar xvzf Dist/newlib-1.15.0.tar.gz
       cp Dist/t-arm-elf gcc-4.2.1/gcc/config/arm/t-arm-elf

 Resolve build dependencies (incomplete)

       sudo apt-get install texinfo libexpat1 libexpat1-dev

 Build it all...

       mkdir -p $MYSRCPATH/target/arm-elf/binutils
       cd $MYSRCPATH/target/arm-elf/binutils
       ../../../binutils-2.17/configure \
               --target=arm-elf --prefix=$MYPREFIX \
               --enable-interwork --enable-multilib --with-float=soft
       make all
       sudo make install

       export PATH=$PATH:$MYPREFIX/bin

       mkdir -p $MYSRCPATH/target/arm-elf/gcc
       cd $MYSRCPATH/target/arm-elf/gcc
       # following must be run as root to allow dir creation in /opt/cross!
       sudo ../../../gcc-4.2.1/configure \
               --target=arm-elf --prefix=$MYPREFIX --enable-interwork \
               --enable-multilib --with-float=soft \
               --enable-languages="c,c++" --with-newlib \
               --with-headers=../../../newlib-1.15.0/newlib/libc/include
       make all-gcc
       sudo make install-gcc

       mkdir -p $MYSRCPATH/target/arm-elf/newlib
       cd $MYSRCPATH/target/arm-elf/newlib
       ../../../newlib-1.15.0/configure --target=arm-elf --prefix=$MYPREFIX \
               --enable-interwork --enable-multilib --with-float=soft
       make all
       # pass PATH into sudo environment so /opt/cross/bin is included
       sudo env PATH=$PATH make install

       cd $MYSRCPATH/target/arm-elf/gcc
       make all
       sudo make install

       mkdir -p $MYSRCPATH/target/arm-elf/gdb
       cd $MYSRCPATH/target/arm-elf/gdb
       ../../../gdb-6.6/configure --target=arm-elf --prefix=$MYPREFIX \
                --enable-interwork --enable-multilib --with-float=soft
       make all
       sudo make install

Get the Olimex USB jtag dongle working with the Debian openocd package

       mkdir -p $MYSRCPATH/jtag
       cd  $MYSRCPATH/jtag

       sudo apt-get install openocd

       # create lpc2xxx_armusbocd.cfg containing content found below, which
       # was copied from somewhere I neglected to make note of, and may not
       # be *entirely* correct for this target yet!

       # power up target board, *then* the Olimex USB jtag widget, then run:
       sudo openocd -f ./lpc2xxx_armusbocd.cfg
               telnet localhost 4444
                       poll
                       halt
                       poll

Take gdb for a quick test drive

       cd  $MYSRCPATH/jtag
       # create init.gdb file containing
               target remote localhost:3333
               # monitor arm7_9 sw_bkpts enable
               monitor poll

       arm-elf-gdb --command init.gdb
                info registers




## Setup on Windows 2K/XP

First, install the Olimex ARM-USB-OCD drivers and connect to the LPC2148.

1. You can install the 2006 drivers off the Olimex CD, but we're going to recommend you grab the 2007 drivers from the web. It's actually attached below, but it might not be the absolute latest version - for that, see: <http://openocd.berlios.de/web/>
  1. After you install the drivers, plug in the ARM-USB-OCD. Windows will then freak out and ask you a bzillion times for drivers. This is normal. Keep pointing the new hardware wizard to: `C:\Program Files\openocd-2007re141\driver\arm_usb_ocd`
  2. Overwrite the `lpc2xxx_armusbocd.cfg` file in `C:\Program Files\openocd-2007re141\bin\configs\` with the one that Dave reworked for us (see below!).
  3. Once this stuff is running, it's helpful to make sure that you can communicate with the LPC2148 via OpenOCD. Plug in the hardware (make sure you've read the proper order in which to do this), then in the `bin` directory of the openocd folder run `./openocd-ftd2xx.exe -fconfigs/lpc2xxx_armusbocd.cfg` and you should see something like the following. If you don't see something similar, something isn't working.
    BASH-3.00$ ./openocd-ftd2xx.exe -fconfigs/lpc2xxx_armusbocd.cfg
    Info:    openocd.c:86 main(): Open On-Chip Debugger (2007-04-16 19:30 CEST)
    Info:    configuration.c:50 configuration_output_handler(): Command swbkpts not found
    Warning: arm7_9_common.c:685 arm7_9_assert_reset(): srst resets test logic, too
2. Next, type `telnet localhost 4444` to telnet to port 4444 and type "flash banks" and/or "poll", and you should see something like this (yours may look different):
    Open On-Chip Debugger
    > flash banks
    #0: lpc2000 at 0x00000000, size 0x0007d000, buswidth 0, chipwidth 0
    > poll
    target state: halted
    target halted in ARM state due to debug request, current mode: Undefined
    cpsr: 0x800000db pc: 0x00000034
    >
3. Assuming you see something like this, then you have OpenOCD communicating with the programmer, which is communicating with the MCU. That's good!

Next, let's try programming an already compiled program which will blink the LEDs on the board!

1. Grab the `oocd_flash_lpc2148.script` from below and put it in the `scripts` directory in the openocd folder.
2. Switch the binary that the script points to in the script file (and don't forget to switch it back if you do freertos stuff later!):
     #flash write 0 scripts/lpc2148_freertos.bin 0x0
     flash write 0 scripts/main.bin 0x0
3. Download [http://www.olimex.com/dev/soft/arm/projects\_eclipse\_web.rar](http://www.olimex.com/dev/soft/arm/projects_eclipse_web.rar).
4. Extract `main.bin`.
5. Edit `config/lpc2xxx_armusbocd.cfg` and uncomment the `target_script 0 reset scripts/oocd_flash_lpc2148.script` line.
6. Startup (or restart) openOCD like above.
7. In another terminal, startup OpenOCD (`telnet localhost 4444`) and type `halt`. In the OpenOCD terminal, you should see some stuff saying that it's erasing the flash and re-programming it. You should not see the word "error" :)
8. Switch the DIP switch pin 1 to off (which is away from the 'dash' on the case) and hit the reset button.
9. The MCU should reset and start blinking the lights!!!!! OMG!! OMG!!!111!

OK, you're ready to start compiling.

1. You'll need to the GNUARM tools for Windows/Cygwin. You can get that from <http://www.gnuarm.org/> or you can grab it from the ARM-USB-OCD CD.
2. Install that and restart all your terminals so the path updates.
3. Download FreeRTOS (attached to this page, see above) and unzip it it.
4. Edit the Makefile and add ' $(OBJCOPY) $(PROJECT).elf -O binary $(PROJECT).bin' right below (mind the TAB!) `$(OBJCOPY) $(PROJECT).elf -O ihex $(PROJECT).hex` around line 93 of the makefile. This will make a .BIN out of the .HEX.
5. Also, while you're at it, fix a Makefile bug that they left for us by changing `PROJECT=lpc4148_freertos` to `PROJECT=lpc2148_freertos`. :)
6. Now switch the binary that the config script points to in the script file:
     flash write 0 path/to/lpc2148_freertos.bin 0x0
  1. Go ahead and switch the JTAG switch back to 'ON' on the DIP switch and hit reset.
  2. In another terminal, startup OpenOCD (`telnet localhost 4444`) and type `halt`. In the OpenOCD terminal, you should see some stuff saying that it's erasing the flash and re-programming it. You should not see the word "error" :)
  3. Switch the DIP switch pin 1 to off (which is away from the 'dash' on the case) and hit the reset button.
  4. The MCU should reset and start blinking the lights!!!!! Again, "OMG!! OMG!!!111!".

Final notes:

- One oddity about FreeRTOS on these boards is that it seems to disable the JTAG debugging interface while FreeRTOS is executing. In particular, while FreeRTOS is running, when you start OpenOCD, it gets a JTAG communication failure. I found that if you un plug power, set the ICSP dip swich #1 to on, plug in power again the re-program and turn off the dip switch again it will work. This is caused by the CPU going into low power/sleep mode in the FreeRTOS idle loop. You can stop that from happening by commenting out that line of code in the idle call.

## Setting up Eclipse + GDB (initial instructions, to be revised and elaborated on)

Install Necessary eclipse Gallaleo/Europa/v3.2 plugins:

Zylin Plugin: Install the Zylin plugin, using the eclipse software update functionality, per instructions given here: [[http://opensource.zylin.com/embeddedcdt.html]]

1. startup eclipse, make sure it's version Gallaleo/v3.2/Europa
2. create FreeRTOS eclipse project
  1. new project  
  2. choose C++ Project
  3. choose "Makefile Project", and "--other toolchain--"
  4. select the directory with the FreeRTOS source code (top part of the prompt)
3. goto project menu, make sure build automatically is unchecked
4. select properties on newly created project
  1. select C/C++ build
  2. select "Discovery options"
  3. Find compiler invocation command and change it to arm-elf-gcc
  4. got to settings section
  5. check "GNU Elf Parser"

5. to setup a debug config
  1. Goto debug and open debug dialog
  2. double click Embedded debug (Native)
  3. select elf file of program you want to debug
  4. goto debugger tab, remove .gdbinit reference
  5. replace debugger (gdb) with arm-elf-gdb
  6. goto commands tab and paste in the following:

SPECIAL NOTE: the following command list includes line breaks and underscores that markdown may or may not display correctly. Click on "Edit" at the top of this page, and view the source for this page, then copy and paste the following commands - *with the line breaks* - into the commands tab of the open debug dialog. Hint: if you see eleven lines of code here, and not one giant paragraph, and can verify that the "soft_reset_halt" includes the underscores, then you can just copy and paste this code as-is into the commands tab.
    

For newer versions of openocd

    target extended-remote localhost:3333
    monitor reset
    monitor sleep 500
    monitor poll
    monitor soft_reset_halt
    monitor gdb_breakpoint_override enable
    monitor mww 0xE01FC040 0x0001
    monitor mdw 0xE01FC040
    break main
    load
    continue

For older versions of openocd

    target extended-remote localhost:3333
    monitor reset
    monitor sleep 500
    monitor poll
    monitor soft_reset_halt
    monitor arm7_9 force_hw_bkpts enable
    monitor mww 0xE01FC040 0x0001
    monitor mdw 0xE01FC040
    break main
    load
    continue


Hit the "Debug" button, making sure that openOCD is already running in the background.







----

**Tested with release 260 of OpenOCD. Proably wont work with pre r189 releases.**
## ARM-USB-OCD Configuration File: lpc2xxx\_armusbocd.cfg
    #daemon configuration
    telnet_port 4444
    gdb_port 3333
    #interface
    interface ft2232
    ft2232_device_desc "Olimex OpenOCD JTAG"
    ft2232_layout "olimex-jtag"
    ft2232_vid_pid 0x15BA 0x0003
    jtag_speed 3
    #use combined on interfaces or targets that can't set TRST/SRST separately
    #reset_config trst_and_srst separate
    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
    #ft2232_latency 10
    
    #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 arm7tdmi little run_and_init 0
    run_and_halt_time 0 30
    
    #target_script 0 reset oocd_flash_lpc2148.script
    
    working_area 0 0x40000000 0x80000 nobackup
    #flash configuration
    flash bank lpc2000 0x0 0x7D000 0 0 0 lpc2000_v2 14765 calc_checksum
    
    #arm7_9 swbkpts enable
    # For more information about the configuration files, take a look at:
    # http://openfacts.berlios.de/index-en.phtml?title=Open+On-Chip+Debugger



**Tested with release 260 of OpenOCD. Proably wont work with pre r189 releases.**
## ARM-USB OCD FLashing Script: oocd\_flash\_lpc2148.script
    #
    # The following commands will be executed on
    # reset (because of run_and_init in the config-file)
    # - wait for target halt
    # - erase memory
    # - flash content of file main.bin into target-memory
    # - shutdown openocd
    #
    # created by Martin Thomas
    # http://www.siwawi.arubi.uni-kl.de/avr_projects/arm_projects
    # based on information from Dominic Rath
    #
    halt
    arm7_9 dcc_downloads enable
    wait_halt
    sleep 10
    poll
    mdh 0x0 100
    flash probe 0
    # erase first bank only:
    flash erase 0 0 26
    mdh 0x0 100
    flash write 0 scripts/lpc2148_freertos.bin 0x0
    #flash write 0 scripts/main.bin 0x0
    mdh 0x0 100
    reset run
    sleep 10
    #shutdown




----
**Tested with pre release-188 of openOCD - proably won't work with r189 or later**
## ARM-USB-OCD Configuration File: lpc2xxx\_armusbocd.cfg

    #daemon configuration
    telnet_port 4444
    gdb_port 3333
    #interface
    interface ft2232
    ft2232_device_desc "Olimex OpenOCD JTAG A"
    ft2232_layout "olimex-jtag"
    ft2232_vid_pid 0x15BA 0x0003
    jtag_speed 3
    #use combined on interfaces or targets that can't set TRST/SRST separately
    #reset_config trst_and_srst separate
    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
    run_and_halt_time 0 30
    #target_script 0 reset scripts/oocd_flash_lpc2148.script
    working_area 0 0x40000000 0x40000 nobackup
    #flash configuration
    flash bank lpc2000 0x0 0x7D000 0 0 lpc2000_v2 0 14765 calc_checksum
    arm7_9 swbkpts enable
    # For more information about the configuration files, take a look at:
    # http://openfacts.berlios.de/index-en.phtml?title=Open+On-Chip+Debugger


**Tested with pre release-188 of openOCD - proably won't work with r189 or later**

## ARM-USB OCD FLashing Script: oocd\_flash\_lpc2148.script

    #
    # The following commands will be executed on
    # reset (because of run_and_init in the config-file)
    # - wait for target halt
    # - erase memory
    # - flash content of file main.bin into target-memory
    # - shutdown openocd
    #
    # created by Martin Thomas
    # http://www.siwawi.arubi.uni-kl.de/avr_projects/arm_projects
    # based on information from Dominic Rath
    #
    arm7_9 dcc_downloads enable
    wait_halt
    sleep 10
    poll
    flash probe 0
    # erase first bank only:
    flash erase 0 0 26
    flash write 0 scripts/lpc2148_freertos.bin 0x0
    #flash write 0 scripts/main.bin 0x0
    reset run
    sleep 10
    shutdown

----
Attachments:

- [[openocd-2007re141-setup-rc01.exe]]