New Tutorial: ARM Development with Eclipse

Hi Suyash.

The very latest version of the tutorial is Revison 4 which was written as a “Eclipse Corner” article. I have held that in abeyance until the new Eclipse Calisto release becomes official, then I’ll upgrade to that release and re-submit the article to Eclipse.

Until then, you are free to have a peek at it. You can download this Revision 4 tutorial plus a fairly complete zip file of download materials from:

http://gnuarm.alexthegeek.com/ARM_Cross … 7_2006.zip

Note Suyash that the revison 4 tutorial uses Dominic Rath’s OpenOCD JTAG debugger. This replaces the Macraigor OCDRemote driver. You can still use the inexpensive wiggler.

With the big zip file from the Austrailian site “Alex the Geek”, you have the latest tutorial draft and a zip file of compatible and harmonious software components. You still have to download the Cygwin part in this tutorial, but everything else is in that zip file.

Please review the Revison 4 draft tutorial and let me know if you agree that it might be better to use that methodology since it uses a superior JTAG debugger.

Cheers,

Jim Lynch

p.s. that zip file also has the Revison 3 tutorial which is on the Spark Fun and Olimex web sites. It looks like that is the one you are reading.

hello Jim

I am working on olimex’s LPC E2294.

I had written program for simple IO toggling on portpins p0.18 n p0.19.

I modified the linker script as

flash : ORIGIN = 0, LENGTH = 256K

ram_isp_low(A) : ORIGIN = 0x40000120, LENGTH = 223

ram : ORIGIN = 0x40000200, LENGTH = 15841

ram_isp_high(A) : ORIGIN = 0x40003FDF, LENGTH = 32

_stack_end = 0x40003FDB;

alomg with I didn’t changed te crt.s(startup code)file.

but still my code is not working on hardware target. I wants to fin out what may be the reason?

with this I have 2 more doubts.

  1. how I can ensure that all my PLL calculations are correct.(I left them unchanged as in the tutorial)

  2. I got openOCD working with the blinky_flash(for my own target) running.when I launched the debugger it started and halted at the breakpoint I mentioned.

(console view)

gdb) target remote localhost:3333

0x7fffef38 in ?? ()

(gdb) monitor soft_reset_halt

requesting target halt and executing a soft reset

(gdb) monitor arm7_9 force_hw_bkpts enable

Command force_hw_bkpts not found

(gdb) symbol-file main.out

(gdb) thbreak main

Hardware assisted breakpoint 1 at 0xe8: file main.c, line 49.

(gdb) continue

main () at main.c:49

49 Initialize();

(gdb)

but after this when iI steped in the function it gives an error saying

(console view)

Info: server.c:62 add_connection(): accepted ‘gdb’ connection from 0

Info: arm7_9_common.c:213 arm7_9_add_breakpoint(): sw breakpoint requested, but software breakpoints not enabled

Info: breakpoints.c:63 breakpoint_add(): can’t add software breakpoint, resource not available

Info: arm7_9_common.c:213 arm7_9_add_breakpoint(): sw breakpoint requested, but software breakpoints not enabled

Info: breakpoints.c:63 breakpoint_add(): can’t add software breakpoint, resource not available

Info: arm7_9_common.c:213 arm7_9_add_breakpoint(): sw breakpoint requested, but software breakpoints not enabled

Info: breakpoints.c:63 breakpoint_add(): can’t add software breakpoint, resource not available

I just could not figureout the problem?

what may be the reason orwhat more should Itry to get my board working.

SW breakpoints are disabled by default, as they consume one of the two available hardware breakpoints, but GDB uses SW breakpoints for source-level stepping. To enable sw bkpts, issue the “monitor arm7_9 sw_bkpts enable” command, or use the “monitor arm7_9 force_hw_bkpts enable” command to force the use of HW bkpts, even if GDB requested a SW bkpt.

Regards,

Dominic

Hi Suyash.

The first thing that jumps out is the warning after the force hw breakpoints command, such as:

(gdb) monitor arm7_9 force_hw_bkpts enable

Command force_hw_bkpts not found

Without this command, Eclipse will issue software breakpoints when you single-step, etc. Make sure that there are no “unprintable” characters in the OpenOCD command line and make sure that there’s just one whitespace between the elements (was a bug in OpenOCD)

You need to use the PLL setup as Olimex suggests in their test code rather than the one in the tutorial which was designed for a LPC2106. The Olimex version of this function looks like this:

//

// System initialization.

//

void LPC210xSystemInit()

{

// Set PLL 58.96 M = 4; P = 2

PLLCFG_bit.MSEL = 3;

PLLCFG_bit.PSEL = 1;

// Connect and enable PLL

PLLCON_bit.PLLE = PLLCON_bit.PLLC = 1;

// Write FEED

// First disable interrupts.

__disable_interrupt();

PLLFEED_bit.FEED = FIRST_PLL_FEED;

PLLFEED_bit.FEED = SECOND_PLL_FEED;

// Wait to PLL lock frequency

while(!PLLSTAT_bit.PLOCK);

// VPB Initialization

// Not implement in header file

// VPBDIV_bit.VPBDIV = 1; // pclk = cclk

// VPBDIV_bit.XCLKDIV = 1; // xclk = cclk

VPBDIV = 0x11;

// Initialization of MAM

// Initialization of EMC

// FLASH 16bit; IDCY = F; WST1 = 4; RBLE = 1; WST2 = 6

BCFG0=0x1000348F;

// SRAM 32bit; IDCY = F; WST1 = 0; RBLE = 1; WST2 = 0

BCFG1=0x2000040F;

#ifdef JTAG_DEBUG

// Map lowest 64 bytes of the address space to bottom of internal RAM.

// This will move the exception vectors in place.

MEMMAP = 2;

#endif

MAMCR_bit.MODECTRL = 0;

MAMTIM_bit.CYCLES = 4;

MAMCR_bit.MODECTRL = 1;

}

Get on their web site and download and plug in the above routine and any necessary h files to support it.

I think you’re 98% there; keep plugging away!

Jim Lynch

hello Jim,

Finally I got my E2294 board working.

The mistakes I made was in linker script the calculation for locating ram_isp_high(A) was overlapping, and also I was not sure about the JRST jumper. But when I removed it while execution iI got my program running.

Still I am not getting my JTAG debugger working .

It is giving some errors like memory read/write data abort.

I need to go through the documentation of OpenOCD as well as the debugging part of the tutorial, and then I’ll start again. Let me know, if you know any good references which’ll help me to learn the process fast.

I must Thank you for the help and suggestion you provided and also to all of them who replied to my post.

Thanks and regards.

Suyash.

at the command section:

"

target remote localhost:3333

monitor halt

monitor arm7_9 sw_bkpts disable

monitor arm7_9 force_hw_bkpts enable

symbol-file main.out

set $pc = 0x0

thbreak main

continue

"

After I finished setup the toolchain as James’s example, I tested demo LED program. The LED works.

Then I changed code to have a floating point division (tried two integer division too, same thing) in the code and find compiler/linker error: “undefined reference to `__divsi3’?”. I tried to add linker option “-lgcc” or “-LC:\Program Files\GNUARM\lib\gcc\4.1.1\libgcc.a” since it looks like the __divsi3.o is not linked (I found the symbol __divsi3 in libgcc.a) into final object file. But it does not work. I tried all teh libgcc.a in the lib\ folder and not luck. I also tried gcc4.0.2 and gcc4.1.0 installation, all have the same thing.

If this compiler/linker tool can not do integer/floating point division and multiplying, a lot of interesting complex project will face difficulty.

What is the problem? Can anyone help? Thanks.

Hi Albert.

Attempting to keep my tutorial simple has these side effects that you mention. You are right that the library libgcc.a has to be linked in.

I created a “mini-tutorial” for some readers who contacted me about this; at least it will give you an idea of how I selected and linked in libgcc.a

You can download this short pdf file here (be forewarned that megaupload.com is not exactly a family-friendly site). The name of the pdf file (4 pages) is “Adding Library to Eclipse C.pdf

http://www.megaupload.com/?d=F7RSE2YM

Give this a try and let me know how you got along.

Cheers,

Jim Lynch

James, no __divsi3 problem any more. Thanks a lot.

Hi Jim,

I’m a bit of a “born again” embedded guy (did lots with Z80s years ago when the world seemed somewhat simpler…) I’m quite new to the ARM and Gnu world and finding it confusing as hell (I guess lots of others do too (or maybe my intellect is just on the wane…)

I used your original tutorial to good effect and now have stuff coming out of the serial port on my Olimex/Sparkfun LPC-MT-2106. I also read your info on adding libraries to allow functions like divide etc and used this to good efect too.

The problem I now have is my lack of familiarity with gnuarm and the gcc family makes it difficult to know which libraies to add to get certain functionality.

For example I would like to format strings a little more easily than at present using say sprintf() (hopefully in a compact form) so I can add #include <stdio.h> but then have no idea which library to link in to get it to function. The gnuarm directories seem to have multiple versions of all sorts. Can you point me in the direction of any utilities or documentation as to which libraries to use and what they contain. Its just that getting started on this seems a bit of a nightmare to the uninitiated.

Hope you or someone can throw a bit of light.

Cheers - John

I am no expert either but I think I can help a little here.

The great thing about librarys is that if you include too many it will not change the size of your code as the linker will only pull in the functions you need to run your code. So this is not such a big deal. It is usually harder to find out which header to include but grep or other file searchers ususally sort this out.

I had bit trouble with libraries myself and I think I tracked it down to a problem with a make file I was using as a template for my own.

So check out these links too :-

http://en.mikrocontroller.net/topic/80824#new

and

http://en.mikrocontroller.net/topic/64975#new

If Jim is reading this I hope we can improve your next version of the tutorial to make it a better template for onward development.

This will involve off the top of my head :-

  1. Allocating Stacks suitable for a bigger app (including the IRQ Stack)

  2. Enabling of Fast IO

  3. Including a minimal Interrupt/Timer driven LED Flashing routine.

  4. Add a small routine to drive the serial port (great for debugging).

  5. Including a comprehensive chip header file.

In the meantime good luck David!

Thanks to Fordp for those references I’ll have a look and see if they help.

It would still be great if anyone could throw some light on library content (and which set to use) or a reference to some documentation on the subject.

I’ve had a look at some of the GNU GCC docs but nothing totally relevant has caught my eye (maybe I need to read more carefully rather than in quick scan mode!)

Incidentally I managed to get the serial port outputting debug information without too much trouble and after a liitle more of a fight (during which the serial port debug info was invaluable) am able to output to the LCD also! Hence the need for the library info to avoid having to re-invent stuff to format these outputs.

Will try getting JTAG debugging “real soon now”

Cheers - John

(from Surrey - next door to the “Garden of England”!)

I am a newbie to the ARM7 world, committed to developing the LPC214X (planning on ultimately implementing 2142) and the USB peripheral.

We did purchase the Keil MCB2140, but are actively pursuing the GNU path. I’m working my way through Mr. James Lynch’s document entitled “ARM Cross Development with Eclipse version 3.” I downloaded and compiled the project called Demo2148_Blink_Flash, and am now sitting on page 106 of Lynch’s doc. I have the wiggler connected from my PC’s LPT port to the JTAG port of the MCB2140. I have a serial connection from my PC’s COM1 to MCB’s COM0 (I also tried COM1). I have version 2.2.3 of Philips’ Flash Utility. I have a USB cable connected which is simply providing power to my MCB2140 for the time being. 1) The flash utility won’t let me change the device type to anything other than LPC2106, and 2) no matter which button I press, the result is ultimately “Cannot communicate with test board.” Any suggestions would be greatly appreciated…

Hello,

I had the same problem with the new flash utility.

Try the older one:

http://www.nxp.com/files/markets/microc … tility.zip

Regards,

Michael

The 2.23 Version of the Flash Utility is confusing.

On this version YOU DO NOT NEED TO TELL IT THE CHIP!

It will get that information from the chip itself.

I have been using 2.2.3 on LPC2103 and it is very reliable. I use it with the Control BSL and Reset Lines option ticked.

If it is not working you need to check the BSL line and Reset are hooked up properly.

Another thing to try is to pull out any JTAG interface when trying to program by serial as I have found thses can interfere with programming.

By all means try an older version but I suspect the result will be the same.

All the best.

What an amazing work it is!:o !! Ideal for Newbie uC programmers. Thanx a lot for the author!!!

OST

Had to take a 4 month break. I’m back now.

Does the Philips download utility require that a particular bootloader be running? Trying to download to Keil MCB2140 demo board with LPC2148 ARM on it. I have a straight-through DB9 serial cable hooked up (wiggler not attached).

Should I just bag out on the serial downloader for now, and just try to get the wiggler download working?

I would stick with the serial port downloading to start with.

Dive in the data sheet at check how get the chip into Bootloader mode.

I have no experience of your chip but you must drive BSL low during Reset on the LPC2103.

Good Luck!

Thank you, folks. I have Philips Flash Utility serially downloading without a hitch. I was able to download Keil’s USB audio demo to the keil MCB2140 eval board without a hitch.

I have 2 major milestones yet to achieve.

  1. Conquer JTAG debugging using the wiggler. haven’t gotten that far in Lynch’s tutorial yet, since I’m currently focusing on item 2:

  2. Use the Cygwin GNU compiler with the Eclipse IDE per Lynch’s famous doumentation to download some version of Keil’s very impressive USB audio demo program. I’m finding that GNU seems to want different syntax for ISR prototypes, and unfortunately the Blink LED demo doesn’t use interrupts, and I’m having trouble finding an example that does and will compile under Eclipse/GNU without errors.

Earlier, you mentioned a “minimal Interrupt/Timer driven LED Flashing routine.” Does anyone have one or these, or know where I can find something equally useful?

Hi IckTheSlick (I love that, by the way).

I did write an open-source tutorial called “Using Open Source Tools for Atmel AT91SAM7 Cross Development” three months ago. You can download a zip file of the tutorial and the sample projects, etc from the following URL.

http://www.atmel.com/dyn/resources/prod … source.zip

The example I used in that tutorial is for the Atmel AT91SAM7 chip, but it does demonstrate interrupts and you might find it illuminating.

Cheers,

Jim Lynch