@Sawik I had changed the memory map in the compiler options to reflect the final destination of the code. (I may be wrong but without that I dont think the program would even go beyond the initialisation stages as function calls need stacks in the proper places).
I am somewhat a beginner so will describe in detail what all I have done to make sure I am not missing something obvious.
The controller is LH79520 ARM7TDMI based controller.
My boot loader is very simplistic.What it is doing is just copy the binary file coming over the serial port to appropriate memory location in SDRAM, verify if it has been copied correctly (by reading the image from the sdram and putting it back on the serial port so that the pc can compare the two binary files ), and pass control to the specified location.
@Lanarcam I did not initialise the variables AFTER copying the code to SDRAM. How do you do that? Why do you need to do that? Should not the binary image generated by the compiler/linker handle any initialisations? Downloading the same program to the internal SRAM through JTAG works, so are extra initialisations needed for SDRAM?
I tried putting in a few dummy statements and some nops, and the program seems to work correctly for some time (has correct variable values) but it also hangs all the same after some time (the point at which it hangs is different for evry run). Is this a problem with aligning the code?
The program is accessing a MMC card using the SPI mode. I dont think the problem is with the program, because as I said earlier, it works correctly from the SRAM.
Lanarcam and Sawik, thanks for the prompt replies.
Any further pointers or solutions are welcome.