AT91SAM7S256 + 128 problem

Hi,

I have been using the code from Jim Lynches ARM eclipse Tutorial (demo_at91sam7s_flash). I added some of my own basic UART routines to the code and have been running it fine on my Olimex development board running a AT91SAM7S256. When I try and run it on my 128 processor and manually step through the code it enters the blinker.c rountine randomly after a couple of lines of code. If I Leave it running then pause it and then try and step into a line of code it crashes the debugger.

Can you think of why this would work so well on the 256 processor and not the 128? If I change the *.cmd file end of stack reference is this all that I have to do? I am fairly sure that the hardware itself is ok and the code size is really small and no where near the smaller devices limitation.

Thanks in advance for any help you may be able to give me,

David

Hi,

I am quite sure all I need to do is change these values in my .cmd file. Currently for the AT91SAM7S256 I have this setup:

/* specify the AT91SAM7S256 memory areas */

MEMORY

{

flash : ORIGIN = 0, LENGTH = 256K /* FLASH EPROM */

ram : ORIGIN = 0x00200000, LENGTH = 64K /* static RAM area */

}

/* define a global symbol _stack_end (see analysis in annotation above) */

_stack_end = 0x20FFFC;

This works great although when I tried to calculate the values for the 128 I think I got things horribly wrong. Nothing seems to be working. If someone has some known values for running code from the 128 flash can you please tell me.

I have spent a lot of time trying to get this to work, so far with no luck.

Thanks in advance!

David, I’ll repeat my answer in the WinArm forum. You have to change your flash and ram limits and spot the end-of-stack four bytes from the end of RAM, as shown below:

/* specify the AT91SAM7S128 memory areas */
MEMORY
{
flash : ORIGIN = 0, LENGTH = 128K /* FLASH EPROM */
ram : ORIGIN = 0x00200000, LENGTH = 32K /* static RAM area */
}
/* define a global symbol _stack_end (see analysis in annotation above) */
_stack_end = 0x207FFC;

Cheers,

Jim Lynch

Thank you very much Jim. The value I calculated was incorrect and has been causing me a lot of problems.

Your help is most appreciated!

Well I tried those new values in the cmd file. Still no luck unfortunately. Every time I run the code on the 128 it goes into the blinker.c routine. When I run it on the 256 though with the original cmd file it works perfectly…

I am really stuck/confused here!

Hi David - sorry for your continuing travail.

It looks like it’s time to fire up the debugger.

Run your compile/build and use either SAM-BA or OpenOCD to program the application into flash. Now set up the Eclipse/GDB debugger as shown in my tutorial.

Does it break at main? That would indicate that it got through the assembler start-up routine.

Set a single breakpoint after the call to lowlevelinit(). This would indicate that the machine is capable of running at full speed.

Now start working your way through main() until you detect where it is “jumping into the weeds”. You need a clue here to diagnose what is happening.

Let us know what you are finding out - I’m very curious about what is happening here.

Cheers,

Jim Lynch

I have tried stepping through the code with the debugger. It seems to crash on the following lines after one or two iterations through the loop.

for (i=1;i < 31; i++)

{

AT91C_BASE_AIC->AIC_SVR = (int) AT91F_Default_IRQ_handler;
}
I don’t think it always seems to crash in the same place but the last two times I have stepped through it does so here.
Does this help at all?

Hi David.

That loop looks pretty benign.

Could you zip up your whole project (be sure to rename the xxxxx.cmd file to xxxxx.cm_ to get by Google filters) and email it to me?

I don’t have this board, but I’d like to look at your work.

My brother is visiting so I can’t look at it until Thursday evening.

Send it to: lynch007@gmail.com

Thanks,

Jim Lynch

Email sent. Thanks!