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.

TM4C1294NCPDT: TM4C1294NCPDT EPI EXTERNAL MEMORY WRITING PROBLEM

Part Number: TM4C1294NCPDT

Tool/software:

Hi team

I am trying to store the firmware upgrade package in External RAM connected with controller using EPI0 module 

I could access the external RAM memory and able to write the a  single 32 byte  data

but could not write multiple data continuously in for loop 

can you please help me to review the code any changes to be made in it or any configuration need to be made

Please help me to sort this issue

 

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#if 1
//#pragma DATA_SECTION(my_sdram_data, "SDRAM") // Allocate variable to SDRAM section
//*****************************************************************************
//
// The stack size for the LED toggle task.
//
//*****************************************************************************
#define LEDTASKSTACKSIZE 128 // Stack size in words
#define PRIORITY_LED_TASK 1
//! - GPIO Port A peripheral (for EPI0 pins)
//! - GPIO Port B peripheral (for EPI0 pins)
//! - GPIO Port P peripheral (for EPI0 pins)
//! - GPIO Port C peripheral (for EPI0 pins)
//! - GPIO Port G peripheral (for EPI0 pins)
//! - GPIO Port H peripheral (for EPI0 pins)
//! - GPIO Port K peripheral (for EPI0 pins)
//! - GPIO Port L peripheral (for EPI0 pins)
//! - GPIO Port M peripheral (for EPI0 pins)
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

PFA of the external RAM datasheet

42-45S16100H.pdf

  • Hi,

      - Where is your RAMFMD mapped to?

      - Why do you reset g_pui16EPISdram to 0 at line 264? g_pui16EPISdram is supposed to be a pointer to 0x60000000 if your RAMFMD is mapped to this address. You are supposed to write to 0x60000000 and 0x60000004 and so on but are you not writing to 0x0 instead? Unless you pass 0x60000000 for u8ptr_Loc_Data when you call Ram_vWriteByteData. 

      - Why don't you simplify your program and do some simple accesses to the SDRAM like in the TivaWare example. Can you get it to work? See below.

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    //
    // Set the EPI memory pointer to the base of EPI memory space. Note that
    // g_pui16EPISdram is declared as volatile so the compiler should not
    // optimize reads out of the memory. With this pointer, the memory space
    // is accessed like a simple array.
    //
    g_pui16EPISdram = (uint16_t *)0x60000000;
    //
    // Read the initial data in SDRAM, and display it on the console.
    //
    UARTprintf(" SDRAM Initial Data:\n");
    UARTprintf(" Mem[0x6000.0000] = 0x%4x\n",
    g_pui16EPISdram[SDRAM_START_ADDRESS]);
    UARTprintf(" Mem[0x6000.0001] = 0x%4x\n",
    g_pui16EPISdram[SDRAM_START_ADDRESS + 1]);
    UARTprintf(" Mem[0x603F.FFFE] = 0x%4x\n",
    g_pui16EPISdram[SDRAM_END_ADDRESS - 1]);
    UARTprintf(" Mem[0x603F.FFFF] = 0x%4x\n\n",
    g_pui16EPISdram[SDRAM_END_ADDRESS]);
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    - I will strongly suggest you use a logic analyzer to probe the IS42S16100H SDRAM chip inputs. The tool should provide tips if the signals are correct. 

  • can you please share EPI burst write and read sample code 

  • Have you looked at this reference design? https://www.ti.com/tool/TIDM-TM4C129XSDRAM

    The SDRAM software example can be found at https://www.ti.com/tool/download/TIDCA22.

  • Hi charles 

    I tried the code shared with me,

    It is working fine only when we directly assign the hardcoded value in the memory

    but when i tried to assign a loop of 32 bit hex value over Ethernet it is always skipping 4 data
    like below snippets

       

    I also shared my code can you please help me check the code what is causing the issue for this skipping 

    PFB my code snippets

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    // Define base addresses for the EPI registers
    #define EPI_BASE 0x400D0000 // EPI base address
    #define EPI_ADDR_0 0x60000000 // Example external address (could be an SRAM or Flash base)
    uint32_t addr = 0x60000000;
    // Define memory size
    #define MEM_SIZE 1024
    #define NUM_SDRAM_FREQ (sizeof(g_psSDRAMFreq) / sizeof(tSDRAMFreqMapping))
    //*****************************************************************************
    //
    // The starting and ending address for the 64MB SDRAM chip (32Meg x 16bits) on
    // the SDRAM daughter board.
    //
    //*****************************************************************************
    #define SDRAM_START_ADDRESS 0x00000000
    #define SDRAM_END_ADDRESS 0x01FFFFFF
    #define NO_OF_RAM_LOC 4096
    volatile uint32_t g_ui32InternalRamArray[NO_OF_RAM_LOC/4];
    //*****************************************************************************
    //
    // The Mapping address space for the EPI SDRAM.
    //
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    These are the value iam getting from ethernet but it is skipping while written external SDRAM 

    ...

    can you please look into this and help me to sort out the issue 

  • 8585.42-45S16100H.pdf

    this is the external SDRAM part number 

    IS42S16100H
    IS45S16100H

    512K Words x 16 Bits x 2 Banks
    16Mb SYNCHRONOUS DYNAMIC RAM

  • but if we are directly assigning the sequential data like this

    it is perfectly writing 

    I could not understand how it is happening can you please check and tell what is the problem when i writing a custom value  to external SDRAM

  • Bala Sund, If you don't care about data endiness, just use memcpy((u8 *)SDRAM_MAPPING_ADDRESS, data, length).

    I think you are trying to assemble u8[] data that you received to u32[] before wring to SDRAM, why? 

    If SDRAM interface is 32-bit access only OR you are trying to optimize writes why not assemble just one u32 at a time just before you do the write to SDRAM.

    u32 *pDest = (u32 *)SDRAM_MAPPING_ADDRESS;

    i32 iLen = (i32) (length/4);

    while (iLen-- > 0)

    {

     u32 temp = *data++;

     temp |=   ((u32) *data++) << 8;

     temp |=   ((u32) *data++) << 16;

     temp |=   ((u32) *data++) << 24;

     *pDest++ = temp;

    }

    You need to cast u8 to u32 before you left-shift - is the issue causing you loosing 3 out of 4 bytes in each loop.

    Check your Sdram_vWriteByteData() method and how you use it. You are passing in a stack location (500 u32) as a dest. you are lucky that you are not overwriting your own stack which will crash your system. Currently you are writing junk to SDRAM since you are assembling u32 wrong AND reading the stack buffer beyond its limits (500 vs 1024)!

    -Joe

  • Hi Joe

    Thanks for the support 

    I could able write the first 500 bytes of firmware binary but the problem it is looping in the memory like when i write first 500 bytes some how it writing in the next section like this how it is writing can you please help me with this issue  It is like mirroring

    ...

    and another issue is when i add this external ram to linker like this it is showing the error

    #pragma DATA_SECTION(g_pui32EPISdram, ".sdram")

    --retain=g_pfnVectors

    /* The following command line options are set as part of the CCS project. */
    /* If you are building using the command line, or for some reason want to */
    /* define them here, you can uncomment and modify these lines as needed. */
    /* If you are using CCS for building, it is probably better to make any such */
    /* modifications in your CCS project and leave this file alone. */
    /* */
    /* --heap_size=0 */
    /* --stack_size=256 */
    /* --library=rtsv7M3_T_le_eabi.lib */

    /* The starting address of the application. Normally the interrupt vectors */
    /* must be located at the beginning of the application. */
    #define APP_BASE 0x00000000
    #define RAM_BASE 0x20000000
    #define APP_LENGTH 0x010000000
    #define EXSRAM_BASE 0x60000000

    /* System memory map */

    MEMORY
    {
    /* Application stored in and executes from internal flash */
    FLASH (RX) : origin = APP_BASE, length = APP_LENGTH
    /* Application uses internal RAM for data */
    SRAM (RWX) : origin = RAM_BASE, length = 0x00040000

    SDRAM (RWX) : origin = EXSRAM_BASE, length = 0x00040000


    }

    /* Section allocation in memory */

    SECTIONS
    {
    .intvecs: > APP_BASE
    .text : > FLASH
    .const : > FLASH
    .cinit : > FLASH
    .pinit : > FLASH
    .init_array : > FLASH

    .vtable : > RAM_BASE
    .data : > SRAM
    .bss : > SRAM
    .sysmem : > SRAM
    .stack : > SRAM

    .sdram : > EXSRAM_BASE


    #ifdef __TI_COMPILER_VERSION__
    #if __TI_COMPILER_VERSION__ >= 15009000
    .TI.ramfunc : {} load=FLASH, run=SRAM, table(BINIT)
    #endif
    #endif
    }

    iam getting the following error 

    No green  play button visible with this error 

    but i loaded the gel file correctly only

    please help me resolve this issue

    The original requirement is to write the hex file to external RAM and need to boot from the external RAM 

    for this what i need to do in .cmd or linker file 


    ......

  • Hi Joe 

    When I write only first 500 bytes it is writing correctly and mirroring is happening  like this 

    but when i write more than 500 bytes chunk by chunk 
    nothing is getting written only junk is there fully the memory is not getting updated 

    like below


    please help where the issue will be 


    below is my code 

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    static uint16_t count =0;
    void Sdram_vWriteByteData(uint8_t* u8ptr_Loc_Data,uint32_t u32_Loc_dataLength, uint32_t u32_data )
    {
    uint32_t len = 0;
    len = (u32_Loc_dataLength/4);
    uint16_t datacount =0;
    g_pui32EPISdram = (g_pui32EPISdram + count);
    for(datacount=0; datacount < len; datacount++)
    {
    u32_data |= ((uint32_t) *u8ptr_Loc_Data++) << 0;
    u32_data |= ((uint32_t) *u8ptr_Loc_Data++) << 8;
    u32_data |= ((uint32_t) *u8ptr_Loc_Data++) << 16;
    u32_data |= ((uint32_t) *u8ptr_Loc_Data++) << 24;
    SysCtlDelay(20);
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

  • ut if we are directly assigning the sequential data like this

    it is perfectly writing 

    I could not understand how it is happening can you please check and tell what is the problem when i writing a custom value  to external SDRAM

    Glad to see this is working. Joe has very good tips on your type casting issues. Please note that the EPI is 16 bits, not 32 bits. 

    In your earlier code, you declare g_pui32EPISdram as a 32 bits integer pointer.   Why don't you make g_pui32EPISdram a 16-bit pointer just like the example does and write to SDRAM 16-bit at a time. 

  • Hi charles

    I changed it still it writing junk only no correct data is not writing 

  • can you help to identify the issue here

    #pragma DATA_SECTION(g_pui32EPISdram, ".sdram")

    --retain=g_pfnVectors

    /* The following command line options are set as part of the CCS project. */
    /* If you are building using the command line, or for some reason want to */
    /* define them here, you can uncomment and modify these lines as needed. */
    /* If you are using CCS for building, it is probably better to make any such */
    /* modifications in your CCS project and leave this file alone. */
    /* */
    /* --heap_size=0 */
    /* --stack_size=256 */
    /* --library=rtsv7M3_T_le_eabi.lib */

    /* The starting address of the application. Normally the interrupt vectors */
    /* must be located at the beginning of the application. */
    #define APP_BASE 0x00000000
    #define RAM_BASE 0x20000000
    #define APP_LENGTH 0x010000000
    #define EXSRAM_BASE 0x60000000

    /* System memory map */

    MEMORY
    {
    /* Application stored in and executes from internal flash */
    FLASH (RX) : origin = APP_BASE, length = APP_LENGTH
    /* Application uses internal RAM for data */
    SRAM (RWX) : origin = RAM_BASE, length = 0x00040000

    SDRAM (RWX) : origin = EXSRAM_BASE, length = 0x00040000


    }

    /* Section allocation in memory */

    SECTIONS
    {
    .intvecs: > APP_BASE
    .text : > FLASH
    .const : > FLASH
    .cinit : > FLASH
    .pinit : > FLASH
    .init_array : > FLASH

    .vtable : > RAM_BASE
    .data : > SRAM
    .bss : > SRAM
    .sysmem : > SRAM
    .stack : > SRAM

    .sdram : > EXSRAM_BASE


    #ifdef __TI_COMPILER_VERSION__
    #if __TI_COMPILER_VERSION__ >= 15009000
    .TI.ramfunc : {} load=FLASH, run=SRAM, table(BINIT)
    #endif
    #endif
    }

    iam getting the following error 

    No green  play button visible with this error 

    but i loaded the gel file correctly only

    please help me resolve this issue

    The original requirement is to write the hex file to external RAM and need to boot from the external RAM 

    for this what i need to do in .cmd or linker file 

  • It is trying to open a GEL file. Your log is incomplete. You need to find that file in your file system. 

    First answer me if you can write to the SDRAM now before looking at your new problem as to execute code from SDRAM? Let's focus on one problem at a time. 

    Also refer to the below post which contains a .cmd file that will execute code out of SDRAM. 

    https://e2e.ti.com/support/microcontrollers/arm-based-microcontrollers-group/arm-based-microcontrollers/f/arm-based-microcontrollers-forum/1401367/tm4c1299nczad-tm4c1299/5366218#5366218

  • Hi Charles 

    I could able to write the hex file in the ram 

    but it is not booting

    can you help how to add this address to linker file to boot

     like

     below

    #pragma DATA_SECTION(g_pui32EPISdram, ".sdram")

    --retain=g_pfnVectors

    /* The following command line options are set as part of the CCS project. */
    /* If you are building using the command line, or for some reason want to */
    /* define them here, you can uncomment and modify these lines as needed. */
    /* If you are using CCS for building, it is probably better to make any such */
    /* modifications in your CCS project and leave this file alone. */
    /* */
    /* --heap_size=0 */
    /* --stack_size=256 */
    /* --library=rtsv7M3_T_le_eabi.lib */

    /* The starting address of the application. Normally the interrupt vectors */
    /* must be located at the beginning of the application. */
    #define APP_BASE 0x00000000
    #define RAM_BASE 0x20000000
    #define APP_LENGTH 0x010000000
    #define EXSRAM_BASE 0x60000000

    /* System memory map */

    MEMORY
    {
    /* Application stored in and executes from internal flash */
    FLASH (RX) : origin = APP_BASE, length = APP_LENGTH
    /* Application uses internal RAM for data */
    SRAM (RWX) : origin = RAM_BASE, length = 0x00040000

    SDRAM (RWX) : origin = EXSRAM_BASE, length = 0x00040000


    }

    /* Section allocation in memory */

    SECTIONS
    {
    .intvecs: > APP_BASE
    .text : > FLASH
    .const : > FLASH
    .cinit : > FLASH
    .pinit : > FLASH
    .init_array : > FLASH

    .vtable : > RAM_BASE
    .data : > SRAM
    .bss : > SRAM
    .sysmem : > SRAM
    .stack : > SRAM

    .sdram : > EXSRAM_BASE


    #ifdef __TI_COMPILER_VERSION__
    #if __TI_COMPILER_VERSION__ >= 15009000
    .TI.ramfunc : {} load=FLASH, run=SRAM, table(BINIT)
    #endif
    #endif
    }

    iam getting the following error 

    No green  play button visible with this error 

    but i loaded the gel file correctly only

    please help me resolve this issue

    The original requirement is to write the hex file to external RAM and need to boot from the external RAM 

    for this what i need to do in .cmd or linker file 

  • I could able to write the hex file in the ram 

    Ok. Good to hear.

    No green  play button visible with this error 

    but i loaded the gel file correctly only

    The CortexM3_util.gel is normally at your CCS installation under ccs/ccs_base/emulation/gel. See below. The CCS seems to have problem finding the GEL files. Why are having the GEL files on your Desktop?

  • can you please tell how to include this variable stored in RAM to .cmd file 

    pragma DATA_SECTION(g_pui32EPISdram, ".sdram")

    #define APP_BASE 0x00000000
    #define RAM_BASE 0x20000000
    #define APP_LENGTH 0x010000000
    #define EXSRAM_BASE 0x60000000

    /* System memory map */

    MEMORY
    {
    /* Application stored in and executes from internal flash */
    FLASH (RX) : origin = APP_BASE, length = APP_LENGTH
    /* Application uses internal RAM for data */
    SRAM (RWX) : origin = RAM_BASE, length = 0x00040000

    SDRAM (RWX) : origin = EXSRAM_BASE, length = 0x00040000


    }

    /* Section allocation in memory */

    SECTIONS
    {
    .intvecs: > APP_BASE
    .text : > FLASH
    .const : > FLASH
    .cinit : > FLASH
    .pinit : > FLASH
    .init_array : > FLASH

    .vtable : > RAM_BASE
    .data : > SRAM
    .bss : > SRAM
    .sysmem : > SRAM
    .stack : > SRAM

    .sdram : > EXSRAM_BASE


    #ifdef __TI_COMPILER_VERSION__
    #if __TI_COMPILER_VERSION__ >= 15009000
    .TI.ramfunc : {} load=FLASH, run=SRAM, table(BINIT)
    #endif
    #endif
    }

    IS THE ABOVE METHOD IS CORRECT WAY TO ADD EXTERNAL SDRAM VARIABLE  TO .CMD FILE 
    IF IT IS WRONG CAN YOU SUGGEST THE CORRECT WAY TO ADD THE VARIABLE IN .CMD FILE

     

     

  • First of all, is your GEL issue resolved?

    pragma DATA_SECTION(g_pui32EPISdram, ".sdram")

    In which file do you have the above line for the .sdram section?

    #define APP_BASE 0x00000000
    #define RAM_BASE 0x20000000
    #define APP_LENGTH 0x010000000
    #define EXSRAM_BASE 0x60000000

    /* System memory map */

    MEMORY
    {
    /* Application stored in and executes from internal flash */
    FLASH (RX) : origin = APP_BASE, length = APP_LENGTH
    /* Application uses internal RAM for data */
    SRAM (RWX) : origin = RAM_BASE, length = 0x00040000

    SDRAM (RWX) : origin = EXSRAM_BASE, length = 0x00040000


    }

    /* Section allocation in memory */

    SECTIONS
    {
    .intvecs: > APP_BASE
    .text : > FLASH
    .const : > FLASH
    .cinit : > FLASH
    .pinit : > FLASH
    .init_array : > FLASH

    .vtable : > RAM_BASE
    .data : > SRAM
    .bss : > SRAM
    .sysmem : > SRAM
    .stack : > SRAM

    .sdram : > EXSRAM_BASE


    #ifdef __TI_COMPILER_VERSION__
    #if __TI_COMPILER_VERSION__ >= 15009000
    .TI.ramfunc : {} load=FLASH, run=SRAM, table(BINIT)
    #endif
    #endif
    }

    It looks like you want the g_pui32EPISdram to be written to the SDRAM automatically during boot time. But if the EPI and SDRAM are not yet initialized, this won't work. 

    Have you checked this post I sent yesterday? https://e2e.ti.com/support/microcontrollers/arm-based-microcontrollers-group/arm-based-microcontrollers/f/arm-based-microcontrollers-forum/1401367/tm4c1299nczad-tm4c1299/5366218#5366218. The poster initializes his EPI/SDRAM by calling drv_epinit() function before _c_init00 is entered to initialize the global variables. Why don't you take a look at this post. The poster also has the .cmd file. 

    void
    ResetISR(void)
    {
    // Has to initialize EPI before _c_int00
    // Otherwise will go to Hardfault directly
    // Initialize the stack pointer
    __set_MSP((uint32_t)&__STACK_END);

    // Initialize the EPI and SDRAM
    drv_epiInit();

    //
    // Jump to the CCS C initialization routine. This will enable the
    // floating-point unit as well, so that does not need to be done here.
    //
    __asm(" .global _c_int00\n"
    " b.w _c_int00");
    }