New Tutorial: ARM Development with Eclipse

I’m trying to adapt the following fully-functional demo program using the LPC2148 on Keil’s MCB2140 eval board for use with Eclipse/GNUARM IDE with Zylin plug-in.

The demo program is called USBAudio, and is downloadable from www.keil.com. I can build it from the Keil IDE and can serially download it using Philips LPC2000 Flash Utility 2.2.3. No problems. After downloading & cycling power using my PC’s USB connection for power, I get “New hardware found.” My PC recognizes the new hardware as a speaker and magically sets it up as the default audio output. If I play a .wav file, the audio signal gets delivered via USB to the Keil board and is played on the on-board speaker. It is a very impressive demo.

Using Mr. Lynch’s LPC2148 Blinky project as a base, I can at least build the new USBaudio project. The result, however, is “USB device not recognized.” on the PC end when I boot the MCB2140. I have fixed some compile errors, and have dealt with semantic differences along the way as best I could, but am afraid I’m still missing something.

I’m going to need to abandon ship on this pretty soon. I’ve spent many hours on this, to no avail as of yet. I’m thinking of now getting the OCDremote debugger up and running next, and trying to go ahead and try and use it to help solve my original problem. In the meantime, I really have no idea how long it’s going to take, or IF I’ll eventually get there with Eclipse/GNUARM at all, since it is unknown territory. It would be one thing if I could quickly find a working USB demo, already built under the Eclipse environment, but as yet, I have not.

[ The bigger, looming question is this. Is it better for me to continue on the path that I’m on, or should I recommend to my boss that we spring for the full blown Keil JTAG debugger to the tune of $5K, a figure that I’m now rapidly approaching? ]

The top of my menory map looks like :

/* | 0x40008000 */

/* .-------->|--------------------------| */

/* . | variables and stack |0x40007FFF */

/* ram_isp_high | for Philips boot loader */

/* . | 32 + 256 = 288 bytes | */

/* . | | */

/* . | Do not put anything here 0x40007EE0 */

/* .-------->|---------------------------------| */

/* | | 0x40007EDF */

/* | UDF Stack 4 bytes | 0x40007EDC <----_stack_end */

/* .-------->|---------------------------------| */

/* | |0x40007EDB */

/* | ABT Stack 4 bytes |0x40007ED8 */

/* .-------->|---------------------------------| */

/* | |0x40007ED7 */

/* | FIQ Stack 4 bytes |0x40007ED4 */

/* .-------->|---------------------------------| */

/* | |0x40007ED3 */

/* | IRQ Stack 128 bytes |0x40007E54 */

/* .-------->|---------------------------------| */

/* | |0x40007E53 */

/* | SVC Stack 4 bytes |0x40007E50 */

/* .-------->|---------------------------------| */

/* | |0x40007E4F */

/* | USR Stack 1024 bytes |0x40007A50 stack area for user program */

/* .-------->|---------------------------------| */

/* . | |0x40007A4f */

/* . | | */

/* . | |

  1. Should _stack_end be set to 0x40007EDC or 0x40007EDF ?

  2. If anyone is interested in helping out a fellow down on his luck, I’ll be happy to email you my project in zip file format, if you could give it a glance and try and figure this one out…

Hello again, Icktheslick.

If you read the very beginning of my tutorials, I point out that, for the professionsal, purchase of a high-end compiler like the Keil or Rowley is sensible since “time is money”. I addressed my tutorials for the students and hobbiests that can not afford a $5000 price tag. For that $5000, you get a turn-key solution with a lot of extras, such as the ability to specify subroutines to be loaded and executed out of RAM, etc. For what you are trying to do, I suspect that turning to the Keil toolset might be the most sensible thing to do.

For stack settings on a 32-bit machine, the stack address should be divisible by four, such as 0x40007EDC.

Happy New Year,

Jim Lynch

icktheslick also check out : http://sourceforge.net/projects/lpcusb/

Good luck!

where i can find the version pdf file of this tutorials ? the link at olimex seam to be dead

Dumarjo

dumarjo:
where i can find the version pdf file of this tutorials ? the link at olimex seam to be dead

I got my copy from http://www.atmel.com/dyn/resources/prod … source.zip. A few of the screenshots are slightly out of date with the latest versions of the software, but not enough to affect the tutorial. I just completed the tutorial and it has given me a big head start getting up to speed on the AT91SAM7 family. Many thanks Jim for taking the time to share this with everyone!

Dave

dumarjo:
where i can find the version pdf file of this tutorials ? the link at olimex seam to be dead

Dumarjo

if you go to our ARM-JTAG web page you will see instructions how to download the Jim Lynch tutorial, we had to move it to Yahoo Briefcase as it generates enormous traffic to our web (got US $650 bill for traffic in January from our web host provider) I still can’t imagine who is downloading 3000 times per day this 10 MB tutorial!

lol,

thats ok. I will try to find it !

regards

dumarjo

Hello Mr.Lynch,

I am a BE student of Electronics and Communications and a newbie to both ARM as well as Eclipse. I have chosen the LPC2119 architecture for my final year project and I MUST say that your tutorial is ABSOLUTELY FANTASTIC. I don’t think a tutorial can get EASIER than this. Thank you very very very much for taking your precious time off to write this tutorial. I have forward this tutprial to 3 of my friends and they have the same opinion about it.

But just one thing, I am not able to figure out how to start (create) a completely new project. I have written a few code modules in Keil (student version). How do I use the existing .c and .h files to create a new project in Eclipse.

Please do reply soon. Thank you for your time.

Regards.

Suhas

Just a thought about the distribution of this great tutorial. I’ve always seen different links, and many didnt work after some time, because apparently the site owners removed the tutorial because of the huge amount of traffic that it produced.

For this reason i suggest adding a torrent distribution for the next release, will make things simpler.

Hi Suhas.

Thank you so much for your kind comments about my tutorials.

Just in case you are referring to my older tutorial regarding the Philips LPC2000 processors, here’s a link to my most recent tutorial on the Atmel SAM7 devices.

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

I create new projects all the time - it always goes like this:

  1. close the current project

  2. use “File - New - Project” and then select “standard make C project” followed by “Next”

  3. In the “New Project” window that follows, enter a suitable name for your new project.

  4. Click “Finish” and you now have a new project.

At this point, you have a legitimate Eclipse project but it has no files… You know you’re going to need at least these files to start out:

crt.s

at91sam7s256.h

board.h

lowlevelinit.c

main.c

projectname.cmd

makefile

script.ocd

The simplest way to get the above files into your empty project is to import them. The best way is to borrow them from a previous project that you know that works.

  1. use “File - Import - File System” to bring up the file importer.

  2. Use the “browse” button in the “From Directory” to find your previous project. Then click on the check boxes for the files you want.

  3. Click “Finish” and those files are now part of your project.

  4. Change the name of the linker script file (xxxxx.cmd) to reflect the name of the new project.

  5. Go into the makefile and find those two places where the linker script file is mentioned; edit the references to the new linker command file name.

  6. At this point, you should be able to build the project.

Now if you want to add some completely new C or H files, just click “File - New - Source Files” and give the new file a name. Click “Finish” and the empty file has been added to your project.

You will have to go into the makefile and add the new file to the list of object files and also add a compilation step at the bottom!

Hope this helps,

Jim Lynch

Hi BluPhenix:

To show just how out of it I am, what is a bit torrent distribution?

Will the RIAA come after me?

Cheers,

JIm Lynch

Thanks a lot for the immediate reply Mr.Lynch. Now I do not have any problems creating new projects. But as I told you I am new to ARM, eclipse and the concept of make files too. I am working on windows, using LPC2119 and Yagarto CDT. Since I am using LPC2119, I downloaded LPC2119.h from

http://www.aeolusdevelopment.com/Articles/download.html pasted it into my project folder and changed #include “LPC210x.h” to #include “LPC2119.h” but it gives the following error:

main.o: In function `Initialize’:

D:\Afflatus Techtronics\Project consulting\Electronics\ARM\Codes & Projects\Unvalidated\led/main.c:136: undefined reference to `PLLCFG’

D:\Afflatus Techtronics\Project consulting\Electronics\ARM\Codes & Projects\Unvalidated\led/main.c:136: undefined reference to `PLLFEED’

D:\Afflatus Techtronics\Project consulting\Electronics\ARM\Codes & Projects\Unvalidated\led/main.c:136: undefined reference to `PLLCON’

D:\Afflatus Techtronics\Project consulting\Electronics\ARM\Codes & Projects\Unvalidated\led/main.c:136: undefined reference to `PLLSTAT’

D:\Afflatus Techtronics\Project consulting\Electronics\ARM\Codes & Projects\Unvalidated\led/main.c:136: undefined reference to `MAMCR’

D:\Afflatus Techtronics\Project consulting\Electronics\ARM\Codes & Projects\Unvalidated\led/main.c:136: undefined reference to `MAMTIM’

D:\Afflatus Techtronics\Project consulting\Electronics\ARM\Codes & Projects\Unvalidated\led/main.c:136: undefined reference to `VPBDIV’

main.o: In function `feed’:

D:\Afflatus Techtronics\Project consulting\Electronics\ARM\Codes & Projects\Unvalidated\led/main.c:143: undefined reference to `PLLFEED’

main.o: In function `main’:

D:\Afflatus Techtronics\Project consulting\Electronics\ARM\Codes & Projects\Unvalidated\led/main.c:54: undefined reference to `PLLCFG’

D:\Afflatus Techtronics\Project consulting\Electronics\ARM\Codes & Projects\Unvalidated\led/main.c:54: undefined reference to `PLLFEED’

D:\Afflatus Techtronics\Project consulting\Electronics\ARM\Codes & Projects\Unvalidated\led/main.c:54: undefined reference to `PLLCON’

D:\Afflatus Techtronics\Project consulting\Electronics\ARM\Codes & Projects\Unvalidated\led/main.c:54: undefined reference to `PLLSTAT’

D:\Afflatus Techtronics\Project consulting\Electronics\ARM\Codes & Projects\Unvalidated\led/main.c:54: undefined reference to `MAMCR’

D:\Afflatus Techtronics\Project consulting\Electronics\ARM\Codes & Projects\Unvalidated\led/main.c:54: undefined reference to `IODIR’

D:\Afflatus Techtronics\Project consulting\Electronics\ARM\Codes & Projects\Unvalidated\led/main.c:54: undefined reference to `MAMTIM’

D:\Afflatus Techtronics\Project consulting\Electronics\ARM\Codes & Projects\Unvalidated\led/main.c:54: undefined reference to `VPBDIV’

D:\Afflatus Techtronics\Project consulting\Electronics\ARM\Codes & Projects\Unvalidated\led/main.c:54: undefined reference to `IOSET’

D:\Afflatus Techtronics\Project consulting\Electronics\ARM\Codes & Projects\Unvalidated\led/main.c:54: undefined reference to `IOCLR’

make: *** [main.out] Error 1

make: Target `all’ not remade because of errors.

Please help me.

Regards,

Suhas

Hello again, Suhas.

I created a blank Eclipse project, downloaded the zip file: http://www.aeolusdevelopment.com/Files/ … rel_5a.zip to a empty folder and imported every file into the Eclipse project.

I then ran the Eclipse indexer and set out to search for one of your unresolved references PLLCFG. The search showed four matches, two externs and two usages of the variable but no single definition of the variable anywhere. It is missing from the Aeolus download.

I’d say that the guy’s work is missing a few bits.

Possibly you should consider getting a simple example to work first rather than jumping into a huge project like the Aeolus download?

Cheers,

Jim Lynch

I think the actual definition of the of the register variables are in the loader file:

LPC2119.ld

Regards,

Magnus

Quite right, Magnus.

I only searched the .c and .h files.

I’m not sure that the intent of the Provide command was to set 50 plus symbols in the linker script. It’s an unusual usage; most people set a large number of symbols in the .h file.

I suspect that you have to use the gcc command for everything (compiling, assembling, linking, etc) for the provide commands to work.

Cheers,

Jim Lynch

lynchzilla:
Hi BluPhenix:

To show just how out of it I am, what is a bit torrent distribution?

Will the RIAA come after me?

Cheers,

JIm Lynch

Bittorrent is simply a way of distributing files over the internet from other users instead of the traditional download from a server. Using a bittorrent client, such as uTorrent, you download a very small file (a .torrent file) that gives instructions to the client of how to reach a “tracker”. This tracker then gives details of other users who have the file or are currently downloading it. You then receive pieces of the file from many different users until you yourself have a full copy.

It’s not illegal to distribute material that you own/allow to be distributed in such a way.

That’s probably not the best way to describe how it works but as a previous user pointed out, it saves relying on any hosting company’s bandwidth to provide the tutorial.

Also, the R.I.A.A. are only interested (imo, unfairly) in people who use bittorrent in order to distribute and share copyrighted music files

jonloveslou maybe had to mention that if no one else is “seeding” ( i.e. providing for upload ) the file only the initial “uploader” will upload the file.

I.e. if JIm Lynch for example starts uploading the file,as soon as someone else downloads the file there will be 2 uploaders,with the next one who downloads the file there will be 3 uploaders,etc.

But if no one is keeping the torrent program running no one else will be able to download the file. The file doesn’t “stay” on server,but users’ hard drive.So it is vital for this way of spreading information to keep your PC running,so others will be able to reach the files on your PC.

Also a bad part of that torrent system is that you need tracker to upload the file ( i.e. “say” you got a file for sharing ),but those “systems” have “time to live” for their stuff,so after some time the link/info about the availability of the file will be dead and no one will be able to download it unless the information is “refreshed”,i.e. uploaded again.

Dear Mr. Lynch,

I am a student and an intern right now working on the at91sam9261 32 bit mcu. First off, I would like to say that I really appreciate the tutorial that you’ve made. It’s been of great help; however, because I am using an arm9 microcontroller I’m not too sure as to where I need to make adjustments in the setup for the mcu to properly load and debug.

I’ve been using the IAR IDE with the IAR jlink to communicate with the mcu, but because my program is fairly large I’ve hit the 32 kb code limit. Right now, I am in the process of transitioning to the yagarto/eclipse IDE.

I’ve imported your demo_at91sam_blink_ram’s makefile and projectname.cmd and replaced the name with the appropriate name. Right now I’m just trying to create a helloworld type project on my arm9. Ive imported the provided atmel header files that are necessary for the UART implementation that I have.

I noticed that in your blink example, you have the AT91SAM7S256.h file. I’ve imported the similar lib_at91sam9261.h but I get hundreds of errors regarding undeclared variable names. “error: ‘AT91C_BASR_PIOA’ undeclared (first use in function)”. I’ve included the other header file that routes all the registers to the definitions, but for some reason they don’t seem to link correctly. Does atmel have a set library that I can import from?

One last thing, I also get a strange warning: error launching external scanner info generator (gcc -E -P -v -dD c:/…). any insights?

sincerely,

Andrew

Hi Andrew.

I don’t have any ARM9 boards, so I can’t be too much help on the porting of my ARM7 tutorial.

I found a copy of the official AT91SAM9261.h file on the Atmel web site:

http://www.atmel.com/dyn/resources/prod … _2-1_1.zip

Try using that one instead of the lib_AT91SAM9261.h file.

About the “error launching external scanner” warning, this problem can be avoided by the following Eclipse setting:

Go to the Project Properties and then select “C/C++ Make Project”.

There go to the tab “Discovery options” and disable the last check box (“Enable generate scanner info command”).

Give that a try and let me know how it turned out.

Cheers,

Jim Lynch

You will probably want:

-mcpu=arm926ej-s

as part of CFLAGS.

You will also need to include AT91SAM9261.h as Jim Lynch suggests.

But, the GPIO ports are programmed differently in the AT91SAM7 vs AT91SAM9 - there is no AT91C_BASR_PIOA, so you’ll need to spend some time figuring out how to convert the GPIO accesses in the blink demo to work for the SAM9, or just remove them all if you just want an endless loop (which might be OK place to start).

The SAM9 has a whole bunch of more complicated memory, bus and clock management compared to SAM7, and you’ll need to get that code written and linked in too (I suspect the IAR tools are providing that for you at present). Look at u-boot sources for the AT91SAM9261EK to see what’s required …

Good luck - you’ve bitten off quite a lot of work …

Robin

P.S. You might want to consider a quick and dirty approach to getting the hardware initialised - write a small boot loader with the IAR tool chain and load that onto the board first - it can then download (or read from FLASH/disk/whatever you have) your new application binary built with GCC and just jump to it - as all clocks, SDRAM, etc., are all configured already, your code can concentrate on doing whatever your application needs to do.

P.P.S. Better still, get u-boot working on your board (if it’s something like the AT91SAM9261EK, then u-boot is already available).