2019-01-03 04:19 AM
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).
Thanks for the help!!!
David
2019-01-03 06:47 AM
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
2019-01-03 07:08 AM
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
2019-01-03 07:40 AM
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.
2019-01-06 05:31 AM
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 :(
2019-01-06 07:22 AM
>>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.
2019-01-06 07:51 AM
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.
2019-01-06 09:11 AM
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)
2019-01-07 07:51 AM
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 ?