Execution of wrong code

Do you have a question? Post it now! No Registration Necessary

Translate This Thread From English to

I am using the Nios Gnupro tools on an embedded design. Using some
default build script, the code is compiled & linked to execute SRAM but
is stored in Flash. The Flash image also has a small copy routine that
copies everything to SRAM on boot and hops over.

So staring with the same srec file, I can either use GDB to download
direct to SRAM and step thru the execution, or use a utility to burn the
image (plus copy loop) to Flash. Standard embedded stuff.

Either way, what is strange is that while running, the mainline code is
clearly being executed from SRAM, but every function call (or ISR) jumps
from an SRAM address to a Flash address instead of remaining in SRAM.

The objdump output and nm output show only SRAM addresses for all
functions. The code was linked with the -Ttext flag with the SRAM base.
Aside from the short Flash copy routine (that is only part of the Flash
image), the SRAM image should not even know about Flash, so how the heck
is it getting there?

There has got to be something in the build script that is linking
incorrectly or using the wrong libraries. Other ideas?


Site Timeline