Файл: ARM cross development with Eclipse, version 2 (J.P. Lynch, 2005).pdf

ВУЗ: Не указан

Категория: Не указан

Дисциплина: Не указана

Добавлен: 12.06.2025

Просмотров: 680

Скачиваний: 1

ВНИМАНИЕ! Если данный файл нарушает Ваши авторские права, то обязательно сообщите нам.

ARM Cross Development with Eclipse Version 2

By: James P. Lynch

September 10, 2005

Preface to Version 2

When I developed this tutorial in June 2005, Eclipse was at release 3.0.2 and the CDT

(C Development Toolkit) was at version 2.1.1. Preview versions of the next releases of these components were available at that time, but I prefer to stick with official releases in my tutorials for beginners.

Also, the Eclipse debugger worked well when the application was targeted for a PC platform, but it was nearly useless in a “remote debugging” environment where the target is, for example, an ARM microprocessor connected through a JTAG interface. A Norwegian company, Zylin, developed a “custom” version of CDT that modified the debugger for proper operation in a “remote debugging” environment. I found the Zylin version that I downloaded in June 2005 to be a bit unreliable and fairly easy to lock up. For that reason, I wrote the original tutorial with the classic Redhat Insight debugger as the principal debugging agent; it’s simple and reliable.

In just two months, Eclipse has released Version 3.1 and CDT released Version 3.0 as a companion edition to the new Eclipse release. Zylin also updated their “custom” version of CDT 3.0 (an effort done with the cooperation of the Eclipse CDT team).

I tested the new Zylin CDT 3.0 release and found that the remote debugging feature now works fairly well. Therefore, it seemed to be a good idea to republish the “ARM Cross Development with Eclipse” tutorial with the new Eclipse and Zylin/CDT components.

The original tutorial is still usable; Eclipse and CDT will always have their legacy versions archived. You will have to browse their web sites to find them.

1 Introduction

I credit my interest in science and electronics to science fiction movies in the fifties. Robbie the Robot in the movie “Forbidden Planet” especially enthralled me and I watched every episode of Rocky Jones, Space Ranger on television. In high school, I built a robot and even received a ham radio operator license at age 13.

Electronic kits were popular then and I built many Heath kits and Knight kits, everything from ham radio gear to televisions, personal computers and robots.

These kits not only saved money at the time, but the extensive instruction manuals taught the basics of electronics.

Unfortunately, surface mount technology and pick-and-place machines obliterated any cost advantage to “building it yourself” and Heath and Allied

Radio all dropped out of the kit business.

What of our children today? They have home computers to play with, don’t they? Do you learn anything by playing a Star Wars game or downloading music? I think not, while these pastimes may be fun they are certainly not intellectually creative.

A couple years ago, there were 5 billion microcomputer chips manufactured planet-wide. Only 300 million of these went into desktop computers. The rest went into toasters, cars, fighter jets and Roomba vacuum cleaners. This is where the real action is in the field of computer science and engineering.

Can today’s young student or home hobbyist tired of watching Reality Television dabble in microcomputer electronics? The answer is an unequivocal YES!

Most people start out with projects involving the Microchip PIC series of microcontrollers. You may have seen these in Nuts and Volts magazine or visited the plethora of web sites devoted to PIC computing. PIC microcomputer chips are very cheap (a couple of dollars) and you can get an IDE (Integrated Development Environment), compilers and emulators from Microchip and others for a very reasonable price.

Another inexpensive microcontroller for the hobbyist to work with is the Rabbit microcomputer. The Rabbit line is an 8-bit microcontroller with development packages (board and software) costing less that $140.

I’ve longed for a real, state-of-the-art microcomputer to play with. One that can do 32-bit arithmetic as fast as a speeding bullet and has all the on-board RAM and EPROM needed to build sophisticated applications. My prayers have been answered recently as big players such as Texas Instruments, Philips and Atmel have been selling inexpensive microcontroller chips based on the 32-bit ARM architecture. These chips have integrated RAM and FLASH memory, a rich set of peripherals such as serial I/O, PWM, I2C, SSI, Timers etc. and high performance at low power consumption.

A very good example from this group is the Philips LPC2000 family of microcontrollers. The LPC2106 has the following features, all enclosed in a 48-pin package costing about $11.80 (latest price from Digikey for one LPC2106).

Key features

16/32-bit ARM7TDMI-S processor.

64 kB on-chip Static RAM.

128 kB on-chip Flash Program Memory. In-System Programming (ISP) and In-

Application Programming (IAP) via on-chip boot-loader software.

Vectored Interrupt Controller with configurable priorities and vector addresses.

JTAG interface enables breakpoints and watch points.

Multiple serial interfaces including two UARTs (16C550), Fast I²C (400 kbits/s) and SPI™.

Two 32-bit timers (7 capture/compare channels), PWM unit (6 outputs), Real

Time Clock and Watchdog.

Up to thirty-two 5 V tolerant general-purpose I/O pins in a tiny LQFP48 (7 x 7 mm2) package.

60 MHz maximum CPU clock available from programmable on-chip Phase-

Locked Loop with settling time of 100 us.

On-chip crystal oscillator with an operating range of 1 MHz to 30 MHz.

Two low power modes: Idle and Power-down.

Processor wake-up from Power-down mode via external interrupt.

Individual enable/disable of peripheral functions for power optimization.

Dual power supply:

o CPU operating voltage range of 1.65 V to 1.95 V (1.8 V +- 8.3 pct.).

oI/O power supply range of 3.0 V to 3.6 V (3.3 V +- 10 pct.) with 5 V tolerant I/O pads.

Several companies have come forward with the LPC2000 microcontroller chips placed on modern surface-mount boards, ready to use. Olimex and New Micros have a nice catalog of inexpensive boards using the Philips ARM family. I wrote a similar tutorial for the New Micros TiniARM nine months ago and you can see it on their web site www.newmicros.com.


Olimex, an up-and-coming electronics company in Bulgaria, offers a family of Philips LPC2100 boards. Specifically they offer three versions with the LPC2106 CPU. You can buy these from Spark Fun Electronics in Colorado; their web site is www.sparkfun.com The Olimex boards are also carried by Microcontroller Pros in California, their web site is www.microcontrollershop.com

This is the Olimex LPC-H2106 header board. You can literally solder this tiny board onto Radio Shack perfboard, attach a power supply and serial cable and start programming. It costs about $49.95 Obviously, it requires some soldering to get started.

This is the Olimex LPC-P2106 prototype board. Everything is done for you. There’s a power connector for a wall-wart power supply, a DB-9 serial connector and a JTAG port. It costs about $59.95 plus $2.95 for the wall-wart power supply.

This is the Olimex LPT-MT development board; it has everything the prototype board above includes plus a LCD display and four pushbuttons to experiment with. It costs about $79.95 plus $2.95 for the wall-wart power supply.

For starting out, I would recommend the LPC-P2106 prototype board since it has an open prototype area for adding I2C chips and the like for advanced experimentation.

When you do design and develop something really clever, you could use the LPC-

H2106 header board soldered into a nice Jameco or Digikey prototype board and know that the CPU end of your project will work straight away. If you need to build multiple copies of your design, Spark Fun can get small runs of blank circuit boards built for $5.00 per square inch. You can acquire the Eagle-Lite software from CadSoft for free to design the schematic and PCB masks.

So the hardware to experiment with 32-bit ARM microprocessors is available and affordable. What about the software required for editing, compiling, linking and downloading applications for the LPC2106 board?

Embedded microcomputer development software has always been considered “professional” and priced accordingly. It’s very common for an engineer in a technical company to spend $1000 to $5000 for a professional development package. I once ordered $18,000 of compilers and emulators for a single project. In the professional engineering world, time is money. The commercial software development packages for the ARM architecture install easily, are well supported and rarely have bugs. In fact, most of them can load your program into either RAM or FLASH and you can set breakpoints in either. The professional compiler packages are also quite efficient; they generate compact and speedy code.

The Rowley CrossWorks recommended by Olimex is $904.00, clearly out of the range for the student or hobby experimenter. I’ve seen other packages going up as high as $3000. A professional would not bat an eyelash about paying this – time is money.

There is a low cost alternative to the high priced professional software development packages, the GNU toolset. GNU is the cornerstone of the open-source software movement. It was used to build the LINUX operating system. The GNU Toolset includes compilers, linkers, utilities for all the major microprocessor platforms, including the ARM architecture. The GNU toolset is free.

The editor of choice these days is the Eclipse open-source Integrated Development

Environment (IDE). By adding the CDT plugin (C/C++ Development Toolkit), you can edit and build C programs using the GNU compiler toolkit. Eclipse is also free.

Philips provides a Windows flash programming utility that allows you to transfer the hex file created by the GNU compiler/linker into the onboard flash EPROM on the LPC2106 microprocessor chip. The Philips tool is also free.

Macraigor has made available a free Windows utility called OCDremote that allows the Eclipse/GDB (GNU Debugger) to access the Philips LPC2106 microprocessor via the JTAG port using an expensive device called the “wiggler”. The Norwegian company Zylin has created a custom version of CDT that enables the debugger to work better with cross-development applications; however it’s only usable for programs running from RAM memory.

At this point, you’re probably saying “this is great – all these tools and they’re FREE!” In the interest of honesty and openness, let’s delineate the downside of the free open software GNU tools.

The GNU tools do not currently generate as efficient code as the professional compilers.

The Eclipse CDT Debugger cannot set a software breakpoint in FLASH since it can’t erase and reprogram the FLASH.


The OCDRemote JTAG utility does not support hardware breakpoints.

If you were a professional programmer, you would not accept these limitations. For the student or hobbyist, the Eclipse/GNU toolset still gives fantastic capabilities for zero cost.

The Eclipse/GNU Compiler toolset we will be creating in this tutorial operates in two modes.

A. Application programmed into FLASH

COM1

Short the BSL jumper to download and program into flash.

Remove the BSL jumper to execute

You can use a standard 9-pin PC serial cable to connect COM1 to the

Olimex board.

DB-9

Serial Port

In this mode, the Eclipse/GNU development system assembles, compiles and links your application for loading into FLASH memory. The output of the compiler/linker suite is an Intel hex file, e.g. main.hex.

The Philips In-System Programming (ISP) utility is started within Eclipse and will download your hex file and program the flash memory through the standard COM1

serial cable. The Boot Strap Loader (BSL) jumper must be shorted (installed) to run the ISP flash programming utility.

To execute the application, you remove the BSL jumper and push the RESET button to start the application.

Unfortunately, the Insight debugger cannot set a software breakpoint (it can’t program FLASH) and it also doesn’t support hardware breakpoints. This effectively renders the debugger useless in this mode.

B. Application programmed into RAM

Olimex ARM JTAG Adapter

( WIGGLER )

Install the Debug JTAG jumper while running from RAM

LPT1

20-pin

JTAG

The BSL jumper Port generally doesn’t

matter while using JTAG

In this mode, the Eclipse/GNU development system assembles, compiles and links your application for loading into RAM memory. The output of the compiler/linker suite is a GNU main.out file.

The PC is connected from the PC’s printer port LPT1 to the JTAG port through the Olimex ARM JTAG interface (costs about $19.95 from Spark Fun

Electronics). The Olimex ARM JTAG is a clone of the Macraigor Wiggler.

You can run the OCDRemote program as an external tool from within Eclipse. The CDT debugger (started from within Eclipse) communicates with the Macraigor OCDRemote program that operates the JTAG port using the

Wiggler. With the CDT debugger, you can connect to the Wiggler and load the GNU main.out file into RAM. From this point on, you can set software breakpoints, view variables and structures and, of course, run the application.

The drawback is that the application must fit within RAM memory on the LPC2106, which is 64 Kbytes. Still, it’s better than nothing.

My purpose in this tutorial is to guide the student or hobbyist through the myriad of documentation and web sites containing the necessary component parts of a working ARM software development environment. I’ve devised a simple sample program that blinks an LED that is compatible in every way with the GNU assembler, compiler and linker. There are two variants of this program; a FLASH-based version and a RAM-based version.

If you get this to work, you are well on your way to the fascinating world of embedded software development. Take a deep breath and HERE WE GO!


If you are very new to ARM microcomputers, there’s no better introductory book than “The Insider’s Guide to the Philips ARM7-Based Microcontrollers” by Trevor Martin. Martin is an executive of Hitex, a UK vendor of embedded microcomputer development software and hardware and he obviously understands his material.

You can download this e-book for free from the Hitex web site.

http://www.hitex.co.uk/arm/lpc2000book/index.html

There is a controversial section in Chapter 2 with benchmarks showing that the GNU toolset is 4 times slower in execution performance and 3.5 times larger in code size than other professional compiler suites for the ARM microprocessors. Already Mr. Martin has been challenged about these benchmarks on the internet message boards; see “The Dhrystone benchmark, the LPC2106 and GNU GCC” at this web address:

http://www.compuphase.com/dhrystone.htm

Well, we can’t fault Trevor Martin for tooting his own horn! In any case, Martin’s book is a magnificent work and it would behoove you to download and spend a couple hours reading it. I’ve used Hitex tools professionally and can vouch for their quality and value. Read his book! Better yet, it’s required reading.

2 Installing the Necessary Components

To set up an ARM cross-development environment using Eclipse, you need to download and install several components. The required parts of the Eclipse/ARM cross development system are:

1.SUN Java Runtime

2.Eclipse IDE

3.Eclipse CDT Plug-in for C++/C Development (Zylin custom version)

4.CYGWIN GNU C++/C Compiler and Toolset for Windows

5.GNUARM GNU C++/C Compiler for ARM Targets

6.Philips Flash Programmer for LPC2100 Family CPUs

7.Macraigor OCDremote for JTAG debugging

3 JAVA Runtime

The Eclipse IDE was written entirely in JAVA. Therefore, you must have the JAVA runtime installed on your Windows computer to run Eclipse. Most people already have JAVA set up in their Windows system, but just in case you don’t have JAVA installed, here’s how to do it.

The JAVA runtime is available free at www.sun.com. The following screen will appear. Click on “Downloads – Java 2 Standard Edition” to continue.


Select the “latest and greatest” Java runtime system by clicking on J2SE 5.0.

Specifically, we need only the Java Runtime Environment (JRE). Click on “Download JRE 5.0 Update 3.

The Sun “Terms of Use” screen appears first. You have to accept the Sun binary code license to proceed. If you develop a commercial product using the Sun JAVA tools, you will have to pay royalties to them.

Select the “accept” radio button and click “continue” to proceed.

One more choice to decide on – we want the “online” installation for Windows.

Here’s a blow-up of the line we must click on. We select “online” so we can install immediately.

Finally the “file download” window appears. Click on “Run” to download and run the installation.

`

Now the downloading will start.

After downloading, the installation will proceed automatically.

When the Java Runtime Environment installation completes, you will see this display. Click on “Finish.”

As a quick check, go to the Windows Start menu and select “Start – Control Panel – Add or Remove Programs.” Scroll down the list of installed programs and see if the Java J2SE Runtime Environment was indeed installed!

The Sun Microsystems web site is very dynamic, changing all the time. Don’t be surprised if some of the example displays shown here are a bit different.

4 Eclipse IDE

The Eclipse IDE is a complete integrated development platform similar to Microsoft’s Visual Studio. Originally developed by IBM, it has been donated to the Open-Source community and is now a massive world-wide Open-Source development project.

Eclipse, by itself, is configured to edit and debug JAVA programs. By installing the CDT plug-ins, you can use Eclipse to edit and debug C/C++ programs (more on that later).

When properly setup, you will have a sophisticated programmer’s editor, compilers and debugger sufficient to design, build and debug ARM applications.

You can download Eclipse for free at the following web site.

www.eclipse.org

The following Eclipse welcome page will display. Expect some differences from my example below since the Eclipse web site is very dynamic.

Click on “downloads” to get the latest versions of Eclipse.

Click on “downloads”

The Eclipse download window will appear. Eclipse is constantly being improved and new releases come several times a year. Usually the safest thing to download is the “official” latest release. When this tutorial was created, the latest release was Eclipse SDK 3.1

Click on “Downloads” to get things started.

Click on Eclipse SDK 3.1 to start download

When working with the Eclipse and CDT, it’s important to be sure that the CDT plugin you’ve selected is compatible with the Eclipse revision you also selected. Be sure to study the Eclipse web sites to be sure that you have compatible revisions selected.

If you click on Eclipse SDK 3.1 where it says “Download Now:” shown above, this is the Windows version of the download.

What appears next is a list of download mirror sites that host the Eclipse components. I selected the University of Buffalo in my home town (and where I got my Master’s degree).

Great! This mirror site is in my home town.