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.

RM48 EMIF Module in Halcogen

Other Parts Discussed in Thread: HALCOGEN

Hi,

I'm trying to use the EMIF module of the RM48 using halcogen in order to use the 8MB SDRAM.

To configure it I've done the following steps:

1. Create a RM4x, TMDXRM48HDK project.

2.  Set EMIF driver in Driver Enable Tab

3. Enable EMIF SDRAM in EMIF General

4. Set EMIF SDRAM Config with the ISSI datasheet

In CCS:

In sys_link.cmd:

I add -heap 0x7F0000

 in MEMORY : SDRAM (RW) : origin=0x80000020 length=0x007FFFE0

and in SECTIONS : .sysmem : {} > SDRAM  like in the RM48 Hercules Demo project.

in sys_main.c

I call emif_SDRAMInit() before the dynamic allocations.

The dynamic allocation seem work perfectly. However, the realloc function responds "NULL"

What can I do to solve this problem ?

Any help would be appreciated.

Martin V.

  • Martin,

    In order to help you the best, can you post the Halcogen configuration file you are using.
    The sys_main.c file you are using may also be useful to me.

    I would like to reproduce the problem in the same conditions.

    Thanks and Regards,

    Jean-Marc

  • Hi Jean-Marc,

    Thank you for the prompt response.

    The files :

    0116.emif_test.zip

    Martin V.

  • Martin,

    I was able to test your code and I have some question and comments.

    Which version of Halcogen are you using?

    Concerning the heap size, when I've first try your sys_main, I was facing the same problem.
    The calloc() are working fine, but after calling the realloc I was getting NULL pointer.

    In my case, I did not specify any particular heap size. By default the linker uses 0x800 (bytes)
    So that was my problem.

    1] calloc(100, sizeof(int)) for tab you need 100 words (400 bytes)
    2] calloc(100, sizeof(int)) for tab2 you need 100 words (400 bytes)
    3] calloc(100, sizeof(int)) for tab3 you need 100 words (400 bytes)
    4] calloc(100, sizeof(int)) for tab2 you need 100 words (400 bytes)
    5] free(tab) deallocate 100 words
    6] calloc(2, sizeof(int)) for tab you need 2 words (8 bytes) The pointer stays the same as per old tab.
    7] realloc(150, sizeof(int)) for tab you need 150 words (600 bytes) This time the pointer has to move to a higher address.
    8] realloc(150, sizeof(int)) for tab2 you need 150 words (600 bytes) This time the pointer has to move to a higher address.
    now there is 100 + 100 words available at the address of first allocation for tab.
    9] realloc(150, sizeof(int)) for tab3 you need 150 words (600 bytes) This time the pointer has to move to a higher address.
    10] realloc(150, sizeof(int)) for tab4 you need 150 words (600 bytes) This time the pointer will be assigned at an address between the original tab2 and tab3.

    So for the worst case, you need 400 + 300 words of heap (700 words -> 2800 bytes -> 0xAF0)

    I think the runtime library also needs so heap size. In my test, I defined the heap to be 0xd00 and the code works fine.

    In your original post, you defined a heapsize way bigger than the physical ram size on this device. I don't know why you are doing that.

    In the sys_link, you should have:

    /*----------------------------------------------------------------------------*/
    /* Memory Map                                                                 */

    MEMORY
    {
        VECTORS (X)  : origin=0x00000000 length=0x00000020
        FLASH0  (RX) : origin=0x00000020 length=0x0017FFE0
        FLASH1  (RX) : origin=0x00180000 length=0x00180000
        STACKS  (RW) : origin=0x08000000 length=0x00001500
        RAM     (RW) : origin=0x08001500 length=0x00026B00

    /* USER CODE BEGIN (2) */
    /* USER CODE END */
    }

    /* USER CODE BEGIN (3) */
    --heap_size 0xd00

    /* USER CODE END */


    /*----------------------------------------------------------------------------*/
    /* Section Configuration                                                      */

    SECTIONS
    {
        .intvecs : {} > VECTORS
        .text    : {} > FLASH0 | FLASH1
        .const   : {} > FLASH0 | FLASH1
        .cinit   : {} > FLASH0 | FLASH1
        .pinit   : {} > FLASH0 | FLASH1
        .bss     : {} > RAM
        .data    : {} > RAM

    /* USER CODE BEGIN (4) */
        .sysmem  : {} > RAM
    /* USER CODE END */
    }

    Can you have a try with this definition and let me know the result?

    Thanks and Regards,

  • Jean-Marc,

    I use Halcogen 03.00.01

    I tried your code and it work, but I did the same modification before activating EMIF module to use the 8MB of SDRAM.

    This code is juste a try to reproduce problem with SDRAM.

    I need to allocate dynamically the whole SDRAM.

    I apologize for the lack of clarity in my first post.

    In the sys_link, I have:

    /*----------------------------------------------------------------------------*/
    /* Memory Map                                                                 */

    MEMORY
    {
        VECTORS (X)  : origin=0x00000000 length=0x00000020
        FLASH0  (RX) : origin=0x00000020 length=0x0017FFE0
        FLASH1  (RX) : origin=0x00180000 length=0x00180000
        STACKS  (RW) : origin=0x08000000 length=0x00001500
        RAM     (RW) : origin=0x08001500 length=0x00026B00

        SDRAM (RW) : origin=0x80000020 length=0x007FFFE0

    /* USER CODE BEGIN (2) */
    /* USER CODE END */
    }

    /* USER CODE BEGIN (3) */
    --heap_size 0x7F0000

    /* USER CODE END */


    /*----------------------------------------------------------------------------*/
    /* Section Configuration                                                      */

    SECTIONS
    {
        .intvecs : {} > VECTORS
        .text    : {} > FLASH0 | FLASH1
        .const   : {} > FLASH0 | FLASH1
        .cinit   : {} > FLASH0 | FLASH1
        .pinit   : {} > FLASH0 | FLASH1
        .bss     : {} > RAM
        .data    : {} > RAM

    /* USER CODE BEGIN (4) */
        .sysmem  : {} > SDRAM
    /* USER CODE END */
    }

  • Martin,

    I did try your code, and after EMIF init, I'm not able to access the SDRAM memory correctly.
    Because the SDRAM is not working, the CALLOC and REALLOC are not working.

    In your HAlcogen project, the EMIF config is not specified (all timing are 0)

    I've modified the configuration for EMIF and PINMUX (a good number of EMIF signals are multiplexed with other function), generated and compiled the code and now it works.

    In my case, the EMIF.h file seems to have a problem.

    enum emif_pins
    {
        emif_PIN_0 = 0,
        emif_PIN_0 = 1
    };

    to be changed as

    enum emif_pins
    {
        emif_PIN_0 = 0,
        emif_PIN_1 = 1
    };

    After this modification, the code compiles and links correctly and the runtime functionality is the one you expect.

    I've informed the HalcoGen team about this problem and it will be fixed in the next release.

    I want to remind you that inside Halcogen, you can check for update. (Help->Check for Update).

    Here is the full 7215.EMIF.zip. Have a try and let me know.

    Regards,

    Jean-Marc

  • Jean-Marc,

    Thank you very much for your help.

    It works fine now.

    Regards,

    Martin.

  • Hi Jean-Marc,

    I'm also unable to get SDRAM working on a TMS570LS31HDK board.  I'd like to see the referenced 7215.EMIF.zip file to verify my settings, but can't download it.  Is it possible to provide me with the file or a link to it please?

    Thanks very much,

    Bill Naro

  • Hi,

    I'd like to refer to 7215.EMIF.zip, but failed to access it.

    Please help!

    Thanks!

    Simon