This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Debugging x-loader for OMAP35xx

Hey folks,

A real newbie question and possibly a very stupid one.

My x-loader is not working the way it should from NAND flash and I'm trying to debug it.  I'm using a custom board.

I've attached an LED to my board and I'm trying to blink it at various stages inside the x-loader source.  I made a function called blinkTwice() (which blinks the LED twice), and that function contains some instances of delay(1000);.

However, when I launch my x-loader from MMC, just to test the LED flashing, x-loader appears to ignore all my calls to delay(1000) and blasts straight into u-boot and beyond.

For example:

                printf("before delay... \n");
                delay(1000);
                printf("after delay... \n");

Happens in the blink of an eye.

Thankyou all!




  • Okay, I found the solution.

    It turns out that delay() was just very, very fast.

    It executes a few assembly instructions each iteration, so it is even hard to catch with delay(1000);

    /*******************************************************
     * Routine: delay
     * Description: spinning delay to use before udelay works
     ******************************************************/
    static inline void delay(unsigned long loops)
    {
            __asm__ volatile ("1:\n" "subs %0, %1, #1\n"
                              "bne 1b":"=r" (loops):"0"(loops));
    }

    By defining a new function, you can increase the delay up to a duration useful for debugging x-loader:

    static inline void pDelay(unsigned long us)
    {
            delay(us * 200 * 1000); /* approximate */
    }

    pDelay(1000) lasts for about 1 second.