cancel
Showing results for 
Search instead for 
Did you mean: 

EXTERNAL RAM WITH STM32F429DISCO

gerson74
Associate II
Posted on May 14, 2014 at 09:37

Hi!

I would like to use the external RAM IS42S16400 present into the demo board STM32F429DISCO to store program variables.

To do that i modify the linker script 

MEMORY

{

FLASH (rx) : ORIGIN =

0x08000000

, LENGTH =

2048K

RAM (xrw) : ORIGIN =

0x20000000

, LENGTH =

192K

MEMORY_B

1

(rx) : ORIGIN =

0x60000000

, LENGTH =

0

K

CCMRAM (rw) : ORIGIN =

0x10000000

, LENGTH =

64K

SDRAM(xrw) : ORIGIN =

0xD0000000

, LENGTH =

4096K

}

.....

.....

.....

.sdram

:

{

*(

.sdram

)

*(

.sdram

*)

*(

.sdram_rodata

)

*(

.sdram_rodata

*)

} >SDRAM

In the main program 

SDRAM_Init();

/* FMC SDRAM GPIOs Configuration */

SDRAM_GPIOConfig();

/* Disable write protection */

FMC_SDRAMWriteProtectionConfig(

FMC_Bank2_SDRAM

,

DISABLE

);

Up to here it seems to work correctly.

Can i define a variable in this way??

uint8_t my_data[1000]

__attribute__ ((section (''.sdram'')));

If i put this instruction, the compiler generates a .bin too large and the system does not work.

Thanks!!!

#metoo #external-ram #stm32f429disco
8 REPLIES 8
Posted on May 14, 2014 at 13:01

The SDRAM is 8MB (64Mbit)

Unless you plan to have the loader region for the SDRAM in FLASH, and to add/manage initialization code for the C runtime, then you might want to describe the area as NOLOAD

..
.sdram (NOLOAD) :
{
..

The code to initialize the SDRAM should be put into the SystemInit() function

SDRAM_Init(); // calls SDRAM_GPIOConfig()
FMC_SDRAMWriteProtectionConfig(FMC_Bank2_SDRAM,DISABLE);

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
gerson74
Associate II
Posted on May 14, 2014 at 15:31

Thank you Clive1!!

Now the .bin file is correct but i still have problem with the external RAM!!

With this simple test program, the ram seems working correctly.

#define SDRAM_BANK_ADDR     ((uint32_t)0xD0000000)

/* Erase SDRAM memory */

    for (counter = 0x00; counter < IS42S16400J_SIZE; counter++)

    {

      *(__IO uint8_t*) (SDRAM_BANK_ADDR + counter) = (uint8_t)0x0;

    }

    /* Write data value to all SDRAM memory */

    for (counter = 0; counter < IS42S16400J_SIZE; counter++)

    {

      *(__IO uint8_t*) (SDRAM_BANK_ADDR + counter) = (uint8_t)(ubWritedata_8b + counter);

    }

    /* Read back SDRAM memory and check content correctness*/

    counter = 0;

    uwReadwritestatus = 0;

    while ((counter < IS42S16400J_SIZE) && (uwReadwritestatus == 0))

    {

      ubReaddata_8b = *(__IO uint8_t*)(SDRAM_BANK_ADDR + counter);

      if ( ubReaddata_8b != (uint8_t)(ubWritedata_8b + counter))

      {

        uwReadwritestatus = 1;

        //STM_EVAL_LEDOn(LED4);

        //STM_EVAL_LEDOff(LED3);

      }

      else

      {

        //STM_EVAL_LEDOn(LED3);

        //STM_EVAL_LEDOff(LED4);

      }

      counter++;

    }

but if i use the external ram in my program variable 

uint8_t    my_var1    __attribute__ ((section (''.sdram'')));

uint32_t   my_var2    __attribute__ ((section (''.sdram'')));

my_var1 = 10;

if ( my_var1 != 10 ) 

{

    printf(''ERROR!!'');

}

the ram seems working not correctly ( the program executes the printf!!).

Thank's  

swrhee
Associate II
Posted on July 30, 2014 at 00:46

Hi Gerson74,

Were you able to solve this issue?

I am having quite similar problem and wonder if you could share the resolution.

Posted on July 30, 2014 at 01:12

Were you able to solve this issue?I am having quite similar problem and wonder if you could share the resolution.

Some of us aren't having as many problems, perhaps you can describe YOUR failure scenario, including the development environment, and symptoms. Include a complete/concise example that demonstrates the problem.

Review some of the examples for the board

STM32F429I-Discovery_FW_V1.0.1\Projects\Peripheral_Examples\FMC_SDRAM\readme.txt

And perhaps some start up examples which initialize external bused memories before the C run time code attempts to copy/zero statics.
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
swrhee
Associate II
Posted on July 31, 2014 at 03:14

Hi Clive1,

Thank you so much for getting back to this thread.

My environment.

HW: STM32F429I-DISCO MB1075B

SW: STM32F429I-Discovery_FW_V1.0.1

      ( I replaced system_stm32f4xx.c with the one you provided. )

Tool: Keil uVision V5.10.0.2

What I'd like to do:

Use external SDRAM instead of internal SRAM or at least use external SDRAM to put ZI data.

-> Is this something that is even possible?

What I did:

0. I was able to run FMC_SDRAM example program. cool.

1. Activated #define DATA_IN_ExtSDRAM line in system_stm32f4xx.c

2. In uVision -> Options for Target 'FMC_SDRAM' -> Read/Write Memory Area,

        I wrote 0xD0000000 for RAM1 Start, 0x400000 for Size and checked 'default' option.

   2.1 When I start debug session, before it goes to main(), it stucks at HardFault_Handler().

3. From step 1 above, I did same as step 2 except checking 'default' option.

      (So 'default' is checked at IRAM1)

      Instead of checking 'default' option, I went to 'Options for File 'xxxxxx' ' and assigned RAM1 for Zero Initialized Data.

   3.1 When I start debug session, result is same as 2.1.

4. I tried to use ''FMC memory mapping swap''

   4.1 Inserted below 2 lines in the beginning of SystemInit()

        RCC->APB2ENR  |= ((uint32_t)0x00004000);

        SYSCFG->MEMRMP = ((uint32_t)0x00000400);

   4.2 In stm32f429i_discovery_sdram.h, changed SDRAM_BANK_ADDR to 0x90000000

   4.3 Repeated step 2. Of course in this time I used 0x90000000 instead of 0xD0000000.

        And got same result

   4.4 Repeated step 3. And got same result.

5. I am stucked here for about a week.

Your help will be so much appreciated.

Posted on July 31, 2014 at 04:40

Attached is a Keil uV 4.7 project that builds under

STM32F429I-Discovery_FW_V1.0.1\Projects\SDRAM-DEMO2

Debug output is output via SWV (make solder bridge SB9), with the trace set for 180 MHz, and View -> Serial Window -> Debug (printf) Viewer

________________

Attachments :

SDRAM-DEMO2.zip : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006I01a&d=%2Fa%2F0X0000000bSK%2F8lZlQgoo3wkmFt_arQ1boHiBU_7uv08ZMUNaUo6BrpM&asPdf=false
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
swrhee
Associate II
Posted on August 07, 2014 at 21:49

Hi Clive,

Thank you so much.

I was able to do what I wanted to do.

I failed to findout what was wrong though.

Anyway thanks again.

Posted on August 07, 2014 at 22:21

I failed to find out what was wrong though

Probably that your initial stack pointer was set to memory in the SDRAM which was not yet initialized.
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..