Hello,
i have the following problem:
I would like to access the external SDRAM on the STM32F429 Discovery. I could access the external SDRAM, that is not the main problem. The problem is, that i have to access the external SDRAM as the following:
/* SDRAM Initialization */ SDRAM_Init(); /* FMC SDRAM GPIOs Configuration */ SDRAM_GPIOConfig(); //Write SDRAM for (counter = 0; counter < TRANSFERS; counter++) { *(__IO uint16_t*) (SDRAM_BANK_ADDR + 2*counter) = (uint16_t)(uhWritedata_16b + counter); }
Here i havé to add the Address "SDRAM_BANK_ADDR" if i would like to write into the external SDRAM. Now i should configure the Scatter - File that i doesn't need that Section. How must be the changes? Is it possible to auto - configure this Section as external SDRAM?
My Scatter File looks like this:
; ************************************************************* ; *** Scatter-Loading Description File generated by uVision *** ; ************************************************************* LR_IROM1 0x08000000 0x00200000 { ; load region size_region ER_IROM1 0x08000000 0x00200000 { ; load address = execution address *.o (RESET, +First) *(InRoot$$Sections) .ANY (+RO) } RW_IRAM1 0x20000000 0x00030000 { ; RW data .ANY (+RW +ZI) } } ;LR_ERAM1 0xD0000000 0xD0400000 { ;ER_ERAM1 0xD0000000 0xD0400000 { ;.ANY (+RW +ZI) ;} ;}
Thanks for your help.
Hello Clive,
i know its irritating - but can you explain how i should change this section?
Thanks / The solution of your Link / google link i can not transfer for me. I'm not so familiar with the SDRAM and Scatterfile / Mappings ...
I just don't understand why it needs to be explained in such painful detail, may be if you're a student, or have no programming experience, perhaps you can provide some context. May be you need to experiment and think a bit, read associated documentation, and CS texts.
So let's recap:
The heap here is set for 512 bytes, as you've got 4MB or so, perhaps you can expand this to a much bigger number of bytes which you can allocate with malloc(), calloc(), etc. Dynamic memory in this context is helpful because it's large, the memory is slow, and it won't eat into the "size" the evaluation copies of Keil limit you too. You have to make decisions on how you best use the resources you have available, and there suitability to specific tasks.
You can direct the HEAP, and specific static allocations into SDRAM using the earlier supplied scatter-file or equivalent. You probably want most static allocations into regular SRAM, along with the STACK, because it's materially faster the SDRAM in the cacheless Cortex-Mx family. Also if your statics have initializers that's going to eat into the FLASH load region which must copy out to SDRAM/SRAM at startup. That initialization is done in __main, before your main() is called, and after you've initialize the external memory and buses in SystemInit().
; ************************************************************* ; *** Scatter-Loading Description File generated by uVision *** ; ************************************************************* LR_IROM1 0x08000000 0x00200000 { ; load region size_region (2M) ER_IROM1 0x08000000 0x00200000 { ; load address = execution address *.o (RESET, +First) *(InRoot$$Sections) .ANY (+RO) } RW_IRAM1 0x20000000 0x00030000 { ; RW data (192K) .ANY (+RW +ZI) } RW_IRAM2 0xD0000000 0x00400000 { ; SDRAM (4M) the name is arbitrary startup_stm32f429_439xx.o (HEAP) ; Name of Object matching your startup_xxx.s name *(.sdram) ; All sections tagged as .sdram from All objects } }
char buf[256] __attribute__ ((section(".sdram"))); // static allocation from SDRAM
unsigned char *sdrambuf = malloc(1024 * 1024); // dynamic allocation from HEAP in SDRAM
i did the following changes. I changed the value from the HEAP_SIZE to more or less 4MB. My Map-File looks now like the following, it's only a piece from it:
//Buf is the Variable which should be located in SDRAM -> The Adress 0xd000... is correct buf 0xd0000000 Data 256 system_stm32f4xx.o(.sdram) Execution Region RW_IRAM2 (Base: 0xd0000000, Size: 0x00400000, Max: 0x00400000, ABSOLUTE) Base Addr Size Type Attr Idx E Section Name Object 0xd0000000 0x00000100 Data RW 3019 .sdram system_stm32f4xx.o 0xd0000100 0x003fff00 Zero RW 2 HEAP startup_stm32f429_439xx.o
Now Im trying to debug the Project step by step to try to understand the problems like you told me. Im started by the startup file and then i go through the SystemInit Function called in the Startup - File / everything works fine. In this function is the ExtMem_Ctl() called. When im debugging there step by step, the error occures in the following line:
FMX_Bank5_6->SDCR[0] = 0x000029D0
The Error which occures is: Cannot access target. Shutting down debug session.
The SDRAM works fine jet. Thanks for your support clive, but my mistake was a wrong define. One last question, how fast is the external SDRAM?
Is there a big difference between the internal local Storage and the external SDRAM ?
Thanks