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.

AM3358: Writing to DDR in bootloader

Part Number: AM3358
Other Parts Discussed in Thread: SYSBIOS

Hello again.

I am trying to write (re-write) the bootloader, because:

  1. It would be educational
  2. The current one in the PDK is inadequate

I studied the original bootloader from Starterware 2.0.1.1, but it doesn't support the eMMC.

I tried to study the PDK version of the bootloader, but the projects are structured incomprehensible.

So, I wrote my own using the PDK libs which allow access to eMMC memory, and migrated the code from the old bootloader function "BlPlatformConfig()"  and support functions in bl_platform.c source code file.  (it is 2000+ lines, I'm not gonna take up bandwidth posting all of it in this text - the project is atatched).

This is NOT done in RTOS, it's a basic project, linking to PDK libs directly.  And there is no SysBios or XDC.

Essentially I appear to have everything working, except when this code it called, nothing happens:

    toRead -= count;

    while (toRead) {
        if (toRead > 512) {
            thisRead = 512;
        } else {
            thisRead = toRead;
        }

        result = f_read(&fp,appBuffer,thisRead,&count);

        toRead -= count;
        src = appBuffer;
        for (x = 0; x < count; x += 4) {
            *target = *src;
            target++;
            src++;
        }

    }
    f_close(&fp);

(appBuffer and target are pointers to unsigned int, 4 bytes - I also did this with unsigned char pointers, no change)

When I say nothing happens, I mean the bytes being read in are there and they match perfectly the original file that is on the eMMC RAM. And the loop executes which copies each word (4 bytes) to the target address, but the bytes at the target address NEVER CHANGE.

For your viewing pleasure, here is a screen shot of the "expressions" in CCS, which shows that the TI Header is correctly read, the target address started in the right place, and incremented as the loop executed, and even that the entry vector for the boot strapped application is correctly set to 0x80000000.

However, here is the screen shot of the target memory after looping through the file read...  Nothing was copied. (And there was no exception trap (data bus) attempting to copy the bytes into that target, they just didn't get copied)

Naturally, as soon as it attempts to BL to the entry point, the MCU traps with an undefined instruction fault.

So, my question is:

What is going on? What are the required settings to cause a boot loader program in SRAM to write to DDR memory?

MEMORY
{
    SRAM :     o = 0x402F0400,  l = 0x0001FBFF  /* 127kB internal SRAM */
    L3OCMC0 :  o = 0x40300000,  l = 0x00010000  /* 64kB L3 OCMC SRAM */
    M3SHUMEM : o = 0x44D00000,  l = 0x00004000  /* 16kB M3 Shared Unified Code Space */
    M3SHDMEM : o = 0x44D80000,  l = 0x00002000  /* 8kB M3 Shared Data Memory */
    DDR0 :     o = 0x80000000,  l = 0x40000000  /* 1GB external DDR Bank 0 */
}

I have everything else working, including GPIO access to provide me feedback, avoiding the UART.

Entire project is attached.

eMMcBootLoad.zip

  • The RTOS team have been notified. They will respond here.
  • Well, I managed to get it working.

    There is this code from the bootloader, bl_platform.c, on line 1882, which I used in StarterWare 2.0.1.1:

        /* DDR Initialization */
    
    #ifdef evmskAM335x
        /* Enable DDR_VTT */
        DDRVTTEnable();
        DDR3Init();
    #elif evmAM335x
        if(BOARD_ID_EVM_DDR3 == BoardIdGet())
        {
            DDR3Init();
        }
        else if(BOARD_ID_EVM_DDR2 == BoardIdGet())
        {
            DDR2Init();
        }
    #else
        DDR2Init();
    #endif
    

    And since I have a Beaglebone which is neither of the EVM boards, I assume it is supposed to initialize the DDR2 memory.

    Imagine my surprise that the BBB is DDR3.  I removed my call to DDR2Init(), and replaced it with DDR3Init() which I also copied in from the StarterWare (No, I didn't #define evmAM335x  that would have generated other unintended results), and it is now working.  I guess the StarterWare 2.0.1.1 was too old to know that BB "Black" units are DDR3.

    The BBB reference manual identified it as DDR3.  Also, the StarterWare in PDK 1.0.7 made some reference to the "Black" being different as well.

  • Thanks for sharing the fix Christopher. Sorry for the delay in getting to this issue.
  • "Delay" ? It has only been 5 hours.

    I don't thing I've ever gotten a reply (except from Biser) in less than a day.