My code runs with ARMulator, but not on hardware

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

Translate This Thread From English to

Hello ARM gurus,

I'm new to the ARM world, and am here to ask some novice questions.
It's going to be a long post; please bear with me.

I'm having trouble making my code run on an ARM board. It's a Samsung
S3C2410 TK (Training Kit) board with an ARM920T core. The development
tool is ARM's RealView Developer Suite v2.2.

Within the RVDS IDE, I compile, link, and fromelf to generate a binary
file. Its output format is plain binary. I then download the binary
file via USB into the board. The downloading tool is DNW v0.49 provided
by Samsung. I'm using scatter-loading.

My code and scatter-loading description file are listed below:

/****************************************************************
/*                        My code
int main()
{
    int    i, j;
    rGPFCON = 0x55aa;
    rGPFUP  = 0xff;

    // I copied these two from an example without understanding
    // what they do.
    ChangeClockDivider(1,1);          // 1:2:4
    ChangeMPllValue(0xa1,0x3,0x1);    // FCLK20%2.8MHz

    Port_Init();
    Uart_Init(0,115200);
    Uart_Select(0);

    Uart_Printf("Hello ARM world from Samsung S3C2410 TK board\n");

    // The following code snippet will be replaced by my
    // application code.
    Uart_Printf("LED starts flashing\n");
    for (j=0; j<10; j++)
    {
        for(i=0; i<2500000; i++);
        rGPFDAT = 0x80;
        for(i=0; i<2500000; i++);
        rGPFDAT = 0x08;
    }
    Uart_Printf("LED stops flashing\n");
    // My application will end here.

    Uart_Printf("Goodbye ARM world\n");

    return 0;
}
*****************************************************************/

;****************************************************************
;           My scatter-loading description file
;; Simple scatter file
;; RAM starts at address 0x30000000

RAM_LOAD 0x30000000
{
    CODE_EXEC 0x30000000
    {
        * (+RO)
    }

    DATA_EXEC +0
    {
        * (+RW,+ZI)
    }
}
;***************************************************************

When I download & run the code above, everything looks OK. The only
issue is that the main() function never returns. The UART terminal
looks like this:

DNW v0.49 [COM1,115200bps][USB:OK]
------------------------------------------------------
USB host is connected. Waiting a download.
Now, Downloading [ADDRESS:30000000h, TOTAL:608138]
RECEIVED FILE SIZE:  608138(773.5KB/S,0.8S]
Now, Checksum calculation
Download O.K.


Hello ARM world from Samsung S3C2410 TK board
LED starts flashing
LED stops flashing
Goodbye ARM world

Hello ARM world from Samsung S3C2410 TK board
LED starts flashing
LED stops flashing
Goodbye ARM world

Hello ARM world from Samsung S3C2410 TK board
LED starts flashing
LED stops flashing
Goodbye ARM world

... ... ...
(Loops forever)
------------------------------------------------------

However, when I replace the LED fashing part with a call to my
application, and repeat the procedure. I only get this:

DNW v0.49 [COM1,115200bps][USB:OK]
------------------------------------------------------
USB host is connected. Waiting a download.
Now, Downloading [ADDRESS:30000000h, TOTAL:608138]
RECEIVED FILE SIZE:  608138(773.5KB/S,0.8S]
Now, Checksum calculation
Download O.K.

------------------------------------------------------

After successful downloading, nothing happens. Looks like a crash or
loop-forever. The application is a big library with some
600KB code + const. The library is good as I can run it in ARMulator
mode without any problem. Here are my questions:

1. Any idea about what may cause the apparent freeze?
2. How can I check the stack and memory, as I doubt the stack may get
corrupted (I don't have an ICE)?

Any suggestions or hints are greatly appreciated. Thanks for your
patience!

Robby Sun
--The ARM novice and guru wanna-be


Site Timeline