STM32f429: problem with using external SDRAM as an additional data memory

1k views Asked by At

I can read/write an external sdram using fmc in stm32f429. But working with address and read/write functions is not proper for my purpose. I want to introduce external sdram as if internal sram is clearly extended and whenever I define a big variable it is projected to external sdram automatically.

I checked stm32f4 cubemx repository examples (SDRAM+DATAMEMORY) and searched a lot but it seems this is not straightforward.

Following these steps based on what I found, I get hardfault after system_init.

  1. Defining external sdram address and size in the linker (off-chip ram)

  2. Adding some code in startup_stm32f420xx.s

  3. Defining DATA_IN_ExtSDRAM for initializing sdram before main function

  4. Enabling system clock before main function

My external sdram is connected to SDRAM1 in stm32f429.

What is the correct procedure? Is SystemInit_ExtMemCtl() function implemented correctly? Is any modification needed? Is enabling clock before main function and after system_init needed?

Can anyone tell what is the correct code step by step?

Thanks in advance.

1

There are 1 answers

0
Tom V On

What you are asking for is not really possible.

The internal SRAM and external SDRAM are not contiguous; their addresses are a long way apart and variables cannot simply overflow automatically from one to the other.

The correct steps for using the external memory are exactly as given in the example projects, it would be meaningless to repeat them here.

The work you have to do yourself is to decide which variables go in which memory. You can assign a variable to a section using the gcc section attribute or a similar feature of another compiler. There are examples of this in the STM32Cube package.