2018-05-14 08:45 AM
Hi,
I have been working with a Waveshare Core 429I board, essentially an STM32F429IGT6 & IS42S16400J and Keil.
I am trying to store a large array in the SDRAM using the int32_t Array[xxxxx] __attribute__((at(0xD000000))); command, and have FMC and SDRAM functions initiated first.
I can declare a very large array okay and write to individual elements fine, but when I try to fill it using a for loop the program hard faults and 'Cannot access Memory' is displayed. I don't think the for loop requires the array to be in the heap?
I have done lots of reading, I believe there is no reason to need a scatter file, increase the heap size or call the ram functions in the Systeminit routine when using SDRAM in main? I am a complete novice with Keil and my C experience is fairly limited.
Thanks
2018-06-01 11:45 AM
Hi Clive,
I've got my hands on a 32f429I-Discovery board but still having problems.
I've attached the entire project, you will see what I'm trying to achieve is quite simple so something is probably incorrectly configured.
I have not used a scatter file but entered the external RAM address and size into target options.
Thanks again
________________ Attachments : DISCO.zip : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006HxXn&d=%2Fa%2F0X0000000azf%2FAXsjRHHgirof6qt77eVCO3.dnw2sNzkamP1Zc9u3ttA&asPdf=false2018-06-02 08:12 AM
STM32F429I-DISCO
Core=180000000, 180 MHz
CPUID 410FC241 DEVID 419 REVID 1003 Cortex M4 r0p1 STM32F429 or F439 C0000000 00000000 00000000 10110021 11000011 00000000 FPU-S Single-precision only APB1=45000000 APB2=90000000 RAM OK 80000 50000 1000 ________________ Attachments : DISCO-002.zip : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006HxXZ&d=%2Fa%2F0X0000000azd%2FaZF3._rWULhTbBU86zvLyXQwytrkAS_j27rHoCefojQ&asPdf=false2018-06-04 06:01 AM
Hi Clive,
Thank you so much for the resolution.
So it would seem the default Keil compiler is not working with the __attribute__at command for static allocation, with dynamic allocation the correct D0000000 addresss shows in the debugger.
The address location in the debugger is the same with or without the __attribute__at, I have checked the documentation and it should work fine with a non GNU compiler.
Is there a way to resolve this without dynamic allocation using the __attribute__at command, as I intend on having multiple 2D arrays within SDRAM?
Static allocation would be much simpler.
Many thanks
2018-06-04 09:08 AM
I don't like AT for many reasons. Why does this stuff need to be at absolute addresses? Can't you use the scatter file to direct the linker to place specific variables in SDRAM? can't you define a structure where you place all your SDRAM buffers, mange the placement/ordering in there, and set the pointer to the base of the SDRAM?
2018-06-04 09:17 AM
Try not defining the Array inside the scope of a function, ie do it globally, the code exploded because it made a large stack allocation.
2018-06-04 05:37 PM
Dear
Turvey.Clive.002
, please give examples of scatterfile for external memory2018-06-04 06:54 PM
Try some of these
https://community.st.com/0D50X00009XkgpJSAR
https://community.st.com/0D70X000006SIA5SAO
I'll fish some more, and try and fix the DEAD LINKs
2018-06-04 07:53 PM
Here stuffing memory into the Keil allocator
2018-06-07 11:57 AM
Clive, thank you so much, this is exactly what I needed to resolve.
Everything is working fine, I had no idea a large external array declaration would overflow the stack.
2018-06-07 12:19 PM
>> I had no idea a large external array declaration would overflow the stack.
From static analysis I didn't either, but the debugger kept exploding. Having an auto variable with an AT directive apparently is an issue, not a form I've every tried, but I'll remember it now.
&sharpTheElephantInTheRoom