Author Topic: Using Open Source Tools with SAM7X and uTasker project  (Read 49536 times)

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3234
    • View Profile
    • uTasker
Using Open Source Tools with SAM7X and uTasker project
« on: August 09, 2007, 11:16:12 PM »
Hi All

I am in the process of porting the uTasker SAM7X project to work with the tool chain as decribed by James Lynch in his article "Using Open Source Tools for AT91SAM7S Cross Development revision C".

This article and some tutorial files can be loaded from the ATMEL web site - the article is very readable and gives some background to the development of the various tools and a clear step-by-step of installing and getting them running. Therefore it is not worth me giving too much detail here since it is all available in neat and tidy form there. To get the document and the files simply do the following:
1. Go to the web site www.at91.com
2. Click on the register "Documents"
3. Find the document "Using Open Source Tools for AT91SAM7S Cross Development" and click on it.
4. It appears by itself under the title "Key Resources" so click on it again.
5. This will cause "Source package" as download option to appear. Click on this to download a 12.4MByte ZIP file.
In the zip file you will find the famous document (8.6M) which you can follow to obtain all software and install the Eclipse IDE.

This uses the YAGARTO package which is an extremely simple set of 4 executables which install the GCC compiler and libraries, plus all other bits and pieces necessary. It works under Windows without the need for Cygwin or any tedious searching for the various components needed. You can read more about the history of this in James Lynch's article - but it is really easy to use so do have ago.

In fact I have used Eclipse before (for the Coldfire) and I have also compiled the uTasker project with GCC but this path seems the best way to go to ensure that the complete package is really simple and useable.

I can't say how long that it will take until everything is finalised. The uTasker project will run on the ATMEL EVAL board when built with GCC but I know that Emerson had difficulties with this package so it is an oppertunity to clean up and solve any special problems involved.

One important subject is the JTAG debugger used. I studied the various options which are supported by the package and found that the Segger J-Link which I use together with my IAR compiler and IDE will work but it requires another license to work with the debugger [GDB server software]. This license costs $261 (on top of the J-Link price which retails stand-alone for $327). It is repackaged as the ATMEL SAM-ICE JTAG for $129, including the necessary GDB server software. So if you don't have one and want to use it then it seems logical to get the ATMEL offerings. One strange thing about the J-Link GBD server is that it can not program FLASH and so needs either another J-Flash software for $525 or the ATMEL SAM-BA utility.

Anyway I decided that it would be a good idea to try out another solution so have ordered the Olimex ARM-USB-OCD which also works very well (according to James) and is compatible with the OpenOCD daemon which is included in the package. This costs $69.95 and there is a smaller Hobbyist/Student version called the ARM-USB-Tiny for $49.95 (without the serial interface and 5V supply output that the OCD version has). I hope that this will arrive shortly so that I can confirm that it works correctly. In any case it seems to be a more sensible choice seeing as the SAM7X is most popular in the educational world and so will probably be the preferred parts due to its affordable price.

I will report here again as soon as I have some results. If anyone else is interested in being involved just let me known.

Regards

Mark


« Last Edit: August 14, 2007, 09:27:03 PM by mark »

Offline tecnoemerson

  • Newbie
  • *
  • Posts: 13
    • View Profile
Re: Using Open Source Tools with SAM7X and uTasker project
« Reply #1 on: August 10, 2007, 02:57:36 AM »
Marker

Congratulation by to dedicate your time in utasker to Open Source tools! Atmel has believed in Open Source tools.

I had problem in porting it,  i changed my tools, before i used WINARM, now i use Yagarto in tool chain as decribed by James Lynch in his article, i recomend all people that want use sam7x to install and test it, pretty good tools, excellent!

Excellent use GDB in Eclipse software, but i have used arm-jtag from Olimex, it use parallel port, it has worked well in simple examples code  by james Lynch, what do you think about it?

Well, i am working to porting uTasker, i hope that you can porting it!

Thank you, good job!

Sincerely.

Emerson M A Alves
Brazil
« Last Edit: August 10, 2007, 12:52:29 PM by tecnoemerson »

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3234
    • View Profile
    • uTasker
Re: Using Open Source Tools with SAM7X and uTasker project
« Reply #2 on: August 10, 2007, 12:45:45 PM »
Emerson

James Lynch says that all of the JTAG tools he tried work well. The 'Wiggler' using the parallel port is however somewhat slower than the USB types - it can sometimes have problems with ground loops. The wiggler is however the least expensive solution (as long as your PC still has a parallel port) and it is possible to also build one yourself - there are probably various circuits for it in the Internet. In my case I have ordered the USB one because it should allow faster work.

Regards

Mark
« Last Edit: August 14, 2007, 09:30:26 PM by mark »

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3234
    • View Profile
    • uTasker
Re: Using Open Source Tools with SAM7X and uTasker project
« Reply #3 on: August 13, 2007, 11:50:32 PM »
Hi All

I have successfully compiled one of the demo projects in James Lynch's tutorial package but am still waiting to receive the Olimex JTAG debugger. I have had to change for the ARM-USB-Tiny (rather than the ARM-USB-OCD) due to the fact that the local supplier has only the Tiny in stock and Olimex is on holiday until the beginning of September. Never mind - I don't expect any disadvantages with it.

Here is a guide as to how to create a project in Eclipse for the uTasker. There are in fact different ways to do it (like importing all files to the Eclipse workspace) but this is the one that I prefer because it uses the project files directly - one word of warning is that the project view in Eclipse is not a project view as in VisualStudio (which users' of the uTasker simulator know well) where the project folders are virtual folders and the files are those included in the project (their actual location can be anywhere), but this is the REAL FILE SYSTEM on your PC. If you delete a file from the project it will be deleted from your hard disk, and not simply removed from the project!! You need to be a bit careful at the beginning but once you realise this you can use it as a sort of explorer to manipulate things on the hard drive.

1. Start Eclipe and set the working directory to anywher you would like it to be (this will be used as scratch pad and not for real project files).

2. File | New | Project...
Choose standard make C project

3. Enter the project name - such as "uTaskerV1.3"  (without the quotes)
but uncheck "use default location" and set the  uTasker directory as location. This will use the real directory directly rather than making a copy to the local workspace.

4. The further settings seem to be fine without any further configuration changes so click on "Finish" and the uTasker project will magically appear in the project view.
If you expand the project directory you will see that it contains all files and documents, etc. Don't worry that the project is going to build everything seen there because we will specify a make file to be used which defines the build details.

5. If you expand the sub-directories in the project view: Applications .. uTaskerV1.3 .. GNU_SAM7X the make file will be seen (it is called makefile and must have this name to work with Eclipse - as far as I can see).
Unless you have received a version of the project with GNU support from me directly (this is not yet included in the standard project and service packs) the GNU_SAM7X sub-directory will not be there. You can get a zipped version of this directory from the following link: http://www.uTasker.com/software/SAM7X/GNU_YAGARTO.zip
This also includes a startup file for use with GNN called startup_gnu.s and a development version of SAM7X.c. Place these in your directory \Hardware\SAM7X

To set this as the make file for building the project do the following:
In the make view (on the right hand side) expand the sub-directories again to the GNU_SAM7X directory and then right click your mouse.
Choose "Add make target" to make an 'all' build. This will allows a standard build, which will involve compiling only files which need to be compiled since they have either been modified or a header that they depend on has.
A green target will appear with the name 'all'
Then repeat but name the make taget 'clean' (make name and make target in the create dialog).
A second green target will appear with the name 'clean' and can be used to delete all objects in preparation for a re-build of the project.

6. Double click on the 'all' to build the uTasker project using the GNU compiler.

This will generate an S19 output and a binary output and show the size of the code and RAM use.
It also creates a project map file in the target directory Applications\uTaskerV1.3\GNU_SAM7X
The memory script file used for the build is called uTaskerV1.3.ld, also in the target directory.

Note that you may get a warning or two when compiling the standard project, which have been resolved in my working version. These are not serious warnings and just point out that parentheses could be used to help code clarity.
I don't know yet whether this build actually runs on the target - this will be the next thing to find out!

Good luck!!

Mark

Added note on 14.8.2007:

One small change to the standard Eclipse set up which I found useful was the following:
Initially changed files were not being saved when I compiled, and this can cause silly operator errors when not noticed (new build not including latest changes...).
So that modified files are automatically saved when rebuilding, the set up can be modified by opening
Windows | Preferences -> in Preferences dialog expand "General" and select "Workspace" then check "Save automatically before build".

Save this setting and then modified files are automatically saved when the project is built.
« Last Edit: August 14, 2007, 12:24:48 PM by mark »

Offline tecnoemerson

  • Newbie
  • *
  • Posts: 13
    • View Profile
Re: Using Open Source Tools with SAM7X and uTasker project
« Reply #4 on: August 14, 2007, 06:43:13 AM »
Marker

What pack did you use in project? I have uTaskerBeta_ref_Rowley.zip packs !

You sent me makefile to compile utasker, i had problem in to compile it, the makefile and ld file in GNU_YAGARTO.zip  are different?

Didn`t you get error in make it? Error like this:

libarm_enable_irq() and libarm_disable_irq() in sam7x.c file! ???????


In:  hardware\sam7x\sam7x.c

// Routine to re-enable interrupts on leaving a critical region (IAR uses intrinsic function)
//
extern void uEnable_Interrupt(void)                                      // {3}
{
#ifdef _WINDOWS
    if (!iInterruptLevel) {
        *(int *)0 = 0;                                                   // basic error - cause simulator exception
        // A routine is enabling interrupt although they are presently off. This may not be a serious error but it is unexpected so best check why...
    }
#endif
    if (!(--iInterruptLevel)) {                                          // only when no more interrupt nesting,
    #if defined (COMPILE_IAR)
        __enable_interrupt();                                            // IAR intrinsic routine
    #elif defined (_GNU)
     libarm_enable_irq();
    #endif
    }
}


How did you fix this problem?

What is password to unzip GNU_YAGARTO.zip ?

May you send me bin file to me test it in board?


Thank you


Emerson M A Alves
Brazil


« Last Edit: August 14, 2007, 07:00:59 AM by tecnoemerson »

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3234
    • View Profile
    • uTasker
Re: Using Open Source Tools with SAM7X and uTasker project
« Reply #5 on: August 14, 2007, 12:16:00 PM »
Hi Emerson

The Rowley project uses libarm_enable_irq() but these are not found in the GCC as installed by YAGARTO - they are probably routines special to the Rowley libraries (although I haven't studied this).
Therefore SAM7X.c uses __irq_dis() and __irq_en() which are then supplied in the startup_gnu.s file.

I have just added my (development) version of sam7x.c, which I used to compile, to the zip file. The file is protected by the standard SAM7X project password so can be opened by all uTasker SAM7X users.

I just loaded the bin file to my AT91SAM7X-EK to see whether there is life and it started. I could load the web pages to its FTP server and then browse to its web server. So it doesn't look too bad at all. (Just as well since I haven't received the JTAG debugger yet...!)

I have rebuilt for the Olimex board (which you are using) and sent a binary to your private Email address - I don't have such a board here so couldn't check - you can load it using SAM-BA to see whether it also runs.

Good luck

Mark


P.S. For the YAGARTO build use the standard SAM7X project and service packs!



« Last Edit: August 14, 2007, 03:05:55 PM by mark »

Offline tecnoemerson

  • Newbie
  • *
  • Posts: 13
    • View Profile
Re: Using Open Source Tools with SAM7X and uTasker project
« Reply #6 on: August 14, 2007, 07:12:00 PM »
Hi Marker

I got file to uTaskerBeta_ref_Rowley.zip, so i overried it with new files from uTaskerV1.3.0_SAM7X_SP1.zip and GNU_YAGARTO.zip, and made step by step in Eclipse, but i still got a error.

Sounds Good now, but i had a little error look:

make -k all
arm-elf-gcc -march=armv4t -mlittle-endian -mthumb -mthumb-interwork -Wall -Wstrict-prototypes -I..\..\uTaskerV1.3 -D _GNU -D _HW_SAM7X -g -c -Os ..\..\..\Hardware\SAM7X\SAM7X.c -o Build\SAM7X.o
..\..\..\Hardware\SAM7X\SAM7X.c:150: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'int'
..\..\..\Hardware\SAM7X\SAM7X.c: In function 'EMAC_Interrupt':
..\..\..\Hardware\SAM7X\SAM7X.c:629: warning: suggest parentheses around assignment used as truth value
make: *** [Build\SAM7X.o] Error 1
make: Target `all' not remade because of errors.


What can i do?

Thanks

Emerson
« Last Edit: August 14, 2007, 07:21:47 PM by tecnoemerson »

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3234
    • View Profile
    • uTasker
Re: Using Open Source Tools with SAM7X and uTasker project
« Reply #7 on: August 14, 2007, 07:40:35 PM »
Emerson

I have the feeling that you are still not using the SAM7X.c file in the GNU_YAGARTO.zip.
Have you copied the sam7x.c to the hardware\sam7x directory?

If I open the file sam7x.c I find the following lines there where it is flagging an error and a warning:
Line 150 -   //#endif
Line 629 -                 else {
Line 629 is also in the interrupt routine PortB_Interrupt() and not in EMAC_Interrupt(), which begins at line 673.

Therefore it does look as you are compiling a different version of the code.

I will be Skype-Online this evening if it helps.

Regards

Mark
PS. Did the Olimex binary run on your board?

Offline tecnoemerson

  • Newbie
  • *
  • Posts: 13
    • View Profile
Re: Using Open Source Tools with SAM7X and uTasker project
« Reply #8 on: August 15, 2007, 05:40:25 AM »
Marker

I changed sam7x.c file by sam7x.c from GNU_YAGARTO.zip. The first time that i download it, didn't have sam7x.c in zip pack.

I have copied new  sam7x.c to the hardware\sam7x directory.

I solved all problems, so i already compiled uTasker with GCC, excellent!

The code is small! I will test all functions!

Thanks a lot Marker, this work will motivate many developer use uTasker, open tools is a great idea!

Sincerely


Emerson M A Alves
tecnoemerson@interpira.com.br

Offline Stan

  • Newbie
  • *
  • Posts: 18
    • View Profile
Re: Using Open Source Tools with SAM7X and uTasker project
« Reply #9 on: December 12, 2007, 06:02:17 PM »
Hello everyone,
Today I tried to build the uTasker project with Eclipse but with no success. I followed the steps described described in
"Using Open Source Tools for AT91SAM7S Cross Development revision C.pdf" downloaded from Atmel website. So What I did is:
-Install OpenOCD;
-Install YAGARTO Tool Chain;
-Install Eclipse IDE;
-Install YAGARTO Tools;
-Install the Olimex ARM-USB-OCD USB Drivers; (I have other debuggers too but wanted to try this);
-Set Up OpenOCD as an Eclipse External Tool (ARM-USB-OCD);
and after that I followed the steps described from Mark. So after I finish with "add make target" for "all" and "clean" I recieve an error saying the following:

Severity and Description                           Resource         Path         Location        Creation Time        Id
make: *** [uTasker/Driver.o] Error 127      uTaskerV1.3                     line 0           1197477366656      121


And don't know what to do know :] Please help, thanks!

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3234
    • View Profile
    • uTasker
Re: Using Open Source Tools with SAM7X and uTasker project
« Reply #10 on: December 12, 2007, 08:50:44 PM »
Hi Stan

I find the error messages which are generated by the make utility rather confusing, and never know whether it is an error in the make file, in the GCC installation or elsewhere. Therefore this error message also doesn't give any real indication of what is wrong, apart from the fact that the make was being executed at the time and perhaps the driver.c file is involved, or a line which has something to do with this file(?).

The first thing to remember is that Eclipse is not actually compiling anything but rather calls the utilities used to compile. To be able to do this, it must be set up correctly and also the utilities installed correctly. Eclipse is working as editor, launcher for the utilities and, once everything is building correctly, as debugger interface.

I suggest first making sure that the project compiles correctly without Eclipse. To do this, simply go to the directory \Applications\uTaskerV1.3\GNU_SAM7X\ and double click the bat file Build_SAM7X.bat. First check that the GCC path in the file is correct for your PC (matches where you have installed the GNU compiler for ARM).

If the project doesn't build you will first have to solve this problem by checking that the paths are correct, the GNU compiler has been installed correctly and the uTasker project is complete. Once this standalone build works you can go back to Eclipse and try to work out why Eclipse is not doing the same - check that it knows which make file to call and that it is at the correct location.

Good luck

Regards

Mark

Offline Stan

  • Newbie
  • *
  • Posts: 18
    • View Profile
Re: Using Open Source Tools with SAM7X and uTasker project
« Reply #11 on: December 13, 2007, 02:42:02 PM »
Hi Mark
I saw that in Build_SAM7X.bat is written the following:

SET PATH=%PATH%;C:\Programme\CodeSourcery\Sourcery G++\bin
cs-make -f make_uTaskerV1.3_GNU_SAM7X all

but I haven't installed CodeSourcery(I didn't know and I saw that it's not free), I installed everything about Yagarto and I thought that it includes these utilities, I have in my PATH:
C:\Program Files\openocd-2007re204\bin;
C:\Program Files\openocd-2007re204\utils\bin;
C:\Program Files\yagarto\bin;
C:\Program Files\yagarto-tools-20070303\bin;

so I don't know why the .bat can't find the necessary rule for "make" command. When I run it, I have:

D:\...\uTasker v 1.3.0\Applications\uTaskerV1.3\GNU_SAM7X>cs-make -f make_uTaskerV1.3_GNU_SAM7X all
'cs-make' is not recognized as an internal or external command,
operable program or batch file.

I've already tried to uninstall and then install again everything , so I don't think there is something wrong with the installation. From where can I find the necessary tools for the compilation? Thanks!

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3234
    • View Profile
    • uTasker
Re: Using Open Source Tools with SAM7X and uTasker project
« Reply #12 on: December 13, 2007, 05:59:13 PM »
Hi Stan

The stand alone "bat" based build is set up for the Code Sourcery compiler but this is also 'just' the GNU compiler. If you set the path for your installation as performed with Yagarto it should be equivalent.

Code Sourcery offers also a free version as well as a "supported" version with better debug support (for a fee). I don't know which version is 'best' but I expect they are both perfectly useable!

I suggest searching your "C:\Program Files" directory for "make.exe". Note that "cs-make" is the CodeSourcery version so you will probably have to change this to "make". Then set the path in the bat file to the location where it exists.

Good luck

Regards

Mark

Offline Tino

  • Newbie
  • *
  • Posts: 12
    • View Profile
Re: Using Open Source Tools with SAM7X and uTasker project
« Reply #13 on: January 02, 2008, 08:53:59 PM »
Hi!

I also tried to compile µTasker with Eclipse and it worked fine. Some errors came as described but it compiled.
Then I uploaded the bin with SAM-BA to the Olimex SAM7X-EX256 Board. I executed the GPNVM script, quit SAM-BA and reset the Olimex Board. Now the LCD backlight is blinking and the device is not responding.
I am quite sure that all defines are correct and I copied all given files. I am using SP1 (not Rowley, but that makes the same).
I cannot ping the board nor connect with a browser. I deleted my arp cache with arp -d.
When I start the simulation from the same project (Eclipse works in the same directory as VS) it works perfectly.
What to do??
I tried several thing but always with the same outcome.
Mark, do you have an idea or can you send me the bin?

Thanks,
Tino

Edit: The cable connection also seems correct. The green led sometimes blinks and the yellow one is on.
« Last Edit: January 03, 2008, 12:08:37 AM by Tino »

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3234
    • View Profile
    • uTasker
Re: Using Open Source Tools with SAM7X and uTasker project
« Reply #14 on: January 02, 2008, 10:07:08 PM »
Hi Tino

The SP1 doesn't include GNU support - although the SP1 Rowley does.

GNU is a bit special because you have to be very careful about how it works with struc packing. What you probably could observe is that it is sending a corrupted response to ARP requests (as LAN LEDs are blinking) which was the case originally since it inserts holes in some of the IP structs.

A version with GNU support will have the following in tcpip.h:

Code: [Select]
#define _PACK               __attribute__((__packed__))

typedef struct _PACK stARP_FRAME                                         
{
    unsigned char ucHardwareType[2];
    unsigned char ucProtocolType[2];
    unsigned char ucHardware_size;
    unsigned char ucProtocolSize;
    unsigned char ucOpCode[2];
    unsigned char ucSenderMAC_address[MAC_LENGTH];
    unsigned char ucSender_IP_address[IPV4_LENGTH];
    unsigned char ucTargetMAC_address[MAC_LENGTH];
    unsigned char ucTarget_IP_address[IPV4_LENGTH];
} ARP_FRAME;

I don't actually have an Olimex board but there have been various confirmations that the project operates correctly on it. The RUNLED output is connected to the backlight (I don't think that there are any LEDs) so if this is flashing it is a good sign.

There is in fact a new SP (SP2) available - this will be announced later - but you could already try it (http://www.utasker.com/software/V1.3/uTaskerV1.3.0_SAM7X_SP2.zip) since it includes GNU support in form of integrated Eclipse, stand-along and Rowley projects.

Regards

Mark