Reply by Brian C. Lane March 14, 20052005-03-14
Andrew Ness wrote:

>
> Thanks for your response, Brian. By stack word alignment are you meaning
> where the entire stack is placed, or the actual usage of the stack locations
> when the program is running? I tried adding an align statement to my .stack
> definition in SECTIONS, but it didn't help. Are the stack operations
> different when running through the emulator and when running in stand alone
> mode? It runs perfectly every time when the emulator is attached.
> Unfortunately a debug build of the program is >64kB so it won't fit in the
> EEPROM.
>

I mean the stack location when it is inside the subroutine. I'm not sure
that the .align statement does any good in this case. You should be able
to debug the code in eeprom by just loading symbols (or being familiar
enough with the code that you can tell where you are in it <G>) and then
looking at what happens after it returns from the call. You don't want
to use the debug code since it doesn't fail.
Brian

--
-----------------
Brian C. Lane (W7BCL) Programmer
www.shinemicro.com RF, DSP & Microcontroller Design


Reply by Igor Marnat March 14, 20052005-03-14

On 11 March 2005 20:50, wrote:
> sequence. The initialization function then returns to main this is
> where the problem occurs. When the program is run through the emulator it
> returns to _main without a problem and works properly, but not when loaded
> from the EEPROM. If I place some code within a while loop just prior to
> the return statement, it will happily execute indefinitely (Verified by
> toggling a general purpose I/O pin). I have analyzed the assembly
> statements and there appears to be no difference in the way things are
> handled in all cases far calls and returns are used. I have r ead back
> the EEPROM contents to ensure that things are stored correctly and that the
> entire table is present.

In order to debug this issue, you could try to use "goto" statement instead of
calling your functions and "goto back" as well instead of return statement,
and replace functions parameters and return values by global variables. This
way allow you at least to understand if this is really the stack issue or
something else.
Regards,
Igor



Reply by Jeff Brower March 13, 20052005-03-13
Andrew-

> Thanks for your response, Brian. By stack word alignment are you meaning
> where the entire stack is placed, or the actual usage of the stack locations
> when the program is running? I tried adding an align statement to my .stack
> definition in SECTIONS, but it didn't help. Are the stack operations
> different when running through the emulator and when running in stand alone
> mode? It runs perfectly every time when the emulator is attached.
> Unfortunately a debug build of the program is >64kB so it won't fit in the
> EEPROM.

How much larger? Normally debug builds may be a little larger, but not that much --
are you looking at the .out file, or ".etext" and other endpoints in code and data
space shown in the .map file?

-Jeff

> -----Original Message-----
> From: Brian C. Lane [mailto:]
> Sent: Friday, March 11, 2005 10:55 AM
> To:
> Subject: Re: [c54x] Code execution problems when using the boot loader
> (C5416).
>
> wrote:
> >
> > I am having problems running a program on the C5416 when it is not
> > connected to the emulator. We are using a serial EEPROM in SPI mode
> > to store the boot table. The boot table is read and then the code is
> > executed by the C5416 after power on, however at a specific point it
> > terminates. Program execution flows through _c_int_00 to _main and
> > then to our initialization function where several other functions are
> > called in sequence. The initialization function then returns to main
> > - this is where the problem occurs. When the program is run through
> > the emulator it returns to _main without a problem and works properly,
> > but not when loaded from the EEPROM. If I place some code within a
> > while loop just prior to the return statement, it will happily execute
> > indefinitely (Verified by toggling a general purpose I/O pin). I have
> > analyzed the assembly statements and there appears to be no difference
> > in the way things are handled - in all cases far calls and returns are
> > used. I have read back the EEPROM contents to ensure that things are
> > stored correctly and that the entire table is present.
> >
> > I've been trying to get help from TI about this issue but it seems
> > nobody has any experience with using boot loaders there. Today they
> > even suggested a modified command file for hex500 that is invalid.
> > Does anyone have any suggestions, or even an idea of who I might be
> > able to contact at TI about this issue? Any help will be greatly
> > appreciated, thank you.
>
> It may be a problem with Stack word alignment. Depending on which memory
> model you are using if your (far or near in x86 terms) doing a return
> with the stack not on an even word will result in odd failures. I've had
> similar problems when mixing C and assembly.
>
> Can you JTAG it after it has been loaded from the SPI? That may shed
> some light on it.
>
> Brian >



Reply by Andrew Ness March 11, 20052005-03-11

Thanks for your response, Brian. By stack word alignment are you meaning
where the entire stack is placed, or the actual usage of the stack locations
when the program is running? I tried adding an align statement to my .stack
definition in SECTIONS, but it didn't help. Are the stack operations
different when running through the emulator and when running in stand alone
mode? It runs perfectly every time when the emulator is attached.
Unfortunately a debug build of the program is >64kB so it won't fit in the
EEPROM.

Andrew -----Original Message-----
From: Brian C. Lane [mailto:]
Sent: Friday, March 11, 2005 10:55 AM
To:
Subject: Re: [c54x] Code execution problems when using the boot loader
(C5416).
wrote:
>
> I am having problems running a program on the C5416 when it is not
> connected to the emulator. We are using a serial EEPROM in SPI mode
> to store the boot table. The boot table is read and then the code is
> executed by the C5416 after power on, however at a specific point it
> terminates. Program execution flows through _c_int_00 to _main and
> then to our initialization function where several other functions are
> called in sequence. The initialization function then returns to main
> - this is where the problem occurs. When the program is run through
> the emulator it returns to _main without a problem and works properly,
> but not when loaded from the EEPROM. If I place some code within a
> while loop just prior to the return statement, it will happily execute
> indefinitely (Verified by toggling a general purpose I/O pin). I have
> analyzed the assembly statements and there appears to be no difference
> in the way things are handled - in all cases far calls and returns are
> used. I have read back the EEPROM contents to ensure that things are
> stored correctly and that the entire table is present.
>
> I've been trying to get help from TI about this issue but it seems
> nobody has any experience with using boot loaders there. Today they
> even suggested a modified command file for hex500 that is invalid.
> Does anyone have any suggestions, or even an idea of who I might be
> able to contact at TI about this issue? Any help will be greatly
> appreciated, thank you.

It may be a problem with Stack word alignment. Depending on which memory
model you are using if your (far or near in x86 terms) doing a return
with the stack not on an even word will result in odd failures. I've had
similar problems when mixing C and assembly.

Can you JTAG it after it has been loaded from the SPI? That may shed
some light on it.

Brian


Reply by Brian C. Lane March 11, 20052005-03-11
wrote:
>
> I am having problems running a program on the C5416 when it is not
> connected to the emulator. We are using a serial EEPROM in SPI mode
> to store the boot table. The boot table is read and then the code is
> executed by the C5416 after power on, however at a specific point it
> terminates. Program execution flows through _c_int_00 to _main and
> then to our initialization function where several other functions are
> called in sequence. The initialization function then returns to main
> this is where the problem occurs. When the program is run through
> the emulator it returns to _main without a problem and works
> properly, but not when loaded from the EEPROM. If I place some code
> within a while loop just prior to the return statement, it will
> happily execute indefinitely (Verified by toggling a general purpose
> I/O pin). I have analyzed the assembly statements and there appears
> to be no difference in the way things are handled in all cases far
> calls and returns are used. I have read back the EEPROM contents to
> ensure that things are stored correctly and that the entire table is
> present.
>
> Ive been trying to get help from TI about this issue but it seems
> nobody has any experience with using boot loaders there. Today they
> even suggested a modified command file for hex500 that is invalid.
> Does anyone have any suggestions, or even an idea of who I might be
> able to contact at TI about this issue? Any help will be greatly
> appreciated, thank you.

It may be a problem with Stack word alignment. Depending on which memory
model you are using if your (far or near in x86 terms) doing a return
with the stack not on an even word will result in odd failures. I've had
similar problems when mixing C and assembly.

Can you JTAG it after it has been loaded from the SPI? That may shed
some light on it.

Brian

--
-----------------
Brian C. Lane (W7BCL) Programmer
www.shinemicro.com RF, DSP & Microcontroller Design


Reply by March 11, 20052005-03-11

I am having problems running a program on the C5416 when it is not connected to the emulator. We are using a serial EEPROM in SPI mode to store the boot table. The boot table is read and then the code is executed by the C5416 after power on, however at a specific point it terminates. Program execution flows through _c_int_00 to _main and then to our initialization function where several other functions are called in sequence. The initialization function then returns to main this is where the problem occurs. When the program is run through the emulator it returns to _main without a problem and works properly, but not when loaded from the EEPROM. If I place some code within a while loop just prior to the return statement, it will happily execute indefinitely (Verified by toggling a general purpose I/O pin). I have analyzed the assembly statements and there appears to be no difference in the way things are handled in all cases far calls and returns are used. I have read back the EEPROM contents to ensure that things are stored correctly and that the entire table is present.

Ive been trying to get help from TI about this issue but it seems nobody has any experience with using boot loaders there. Today they even suggested a modified command file for hex500 that is invalid. Does anyone have any suggestions, or even an idea of who I might be able to contact at TI about this issue? Any help will be greatly appreciated, thank you.

Andrew