cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F746 Disco board - How to enable external SDRAM

davidra7
Associate II

Hi,

I am new to STM32 systems and CubeMX5 and have several questions.

I am using STM32F746 disco board with TrueStudio , I am trying to work with external SDRAM (first time working with external RAM) I configured the FMC and generate the code but all the memory not in extenal SDRAM (the address is not 0xC0000000 and above).

  1. What should I do or change to make work ?
  2. I understand that external ram change the internal or at least make it bigger, Am I right?
  3. It will be great if I can move the heap to the external RAM

Thanks for the help!!!

David

8 REPLIES 8

Can't help you with CubeMX driving issues, seem to recall your should be able to select the board and output a maximal framework enabling all peripherals.

Perhaps get familiar with some of the other examples provided

STM32Cube_FW_F7_V1.14.0\Projects\STM32746G-Discovery\Examples\FMC\FMC_SDRAM

2) External memory does not change the size of Internal memory. 32-bit addressing within the processor permits decoding of 4GB of space, the external memory exists WITHIN that addressable space.

3) GNU/GCC has a more amateurish memory allocator, at least as provided here. In KEIL you'd just direct the HEAP into an SDRAM section (scatter file aka linker script), and make sure you get the SDRAM configured in SystemInit(). For GNU/GCC you'd need to rework _sbrk (syscalls.c) to separate the HEAP/STACK relationship

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
davidra7
Associate II

Hi,

Thanks for the answer !!

About 2 , if I enter to 0xC0000004 space it will know to enter to the SDRAM ?

About 3, it always enter to _sbrk ? and How to configure SDRAM in SystemInit ?

Thanks,

David

2) Well that's how the logic of the address decoder and FMC manage the bank the SDRAM is wired too.

3) In GNU/GCC _sbrk is behind malloc()/calloc() etc. In a similar fashion as in main() but earlier so you can have the runtime code in startup.s initialize statics/variables into it. I've previously posted working examples.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
davidra7
Associate II

OK. THanks for the help .

I found the examples and compiled them and they are working, but in the example FMC SDRAM DataMemory which I need have a big issue , malloc is not working there.. it gives HardFault, Any Ideas?

I don't familiar with STM32 so much but in microcontrollers from different companies have much better tools :(

>>I don't familiar with STM32 so much but in microcontrollers from different companies have much better tools

CubeMX and TrueStudio, not things I'd choose to use.

The STM32 is much like any other micro-controller, the means/methods of the GNU/GCC heap allocator are not really specific to ST. Similarly the CMSIS start up methods, where the expectation is that hardware the C runtime needs has to be initialized using SystemInit() before the statics/globals are copied over.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
davidra7
Associate II

Hi,

Thanks for the help.

SystemInit called before the statics and globals , I am using the STM32F746-Disco example for FMC with Data Memory ... and malloc still don't work.

malloc() returns what? Check the pointer.

If an access to 0xC0000000.. memory space Hard Faults, then the SDRAM/FMC is not setup for the region properly.

If malloc() returns other values, perhaps you need to review the _sbrk code in syscalls.c (or whatever)

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
davidra7
Associate II

Hi ,

The FMC/SDRAM setup correctly because inside stack point to address above 0xC0000000.

 int * ptr = (int* )malloc(sizeof(int) * 8);

I tried to do really simple malloc command , and after that it halted in hard fault , it shows that it was in _malloc_r function... I tried to check _sbrk and I didn't get in to it..

I read somewhere that it might be gnu problem and updated to the new version and still the same :(

I am trying to find our why _sbrk don't get called and what is _malloc_r ..

Any ideas ?