Concatenating SRAM area in ARM Cortex M - Page 1
Forum section: electronics / general

author: ali_asadzadeh
author_rank: Super Contributor
timestamp: August 10, 2020, 12:43:13 pm
content: Hi,I want to know if there is a trick to Concatenate SRAMs in STM32H750 to be able to allocate multiple LCD frame buffersAllocating memory something like thisCode:uint8_t framebuffer[480*320*2]={0}; //16 bpp framebufferI have a 480X320 16bit LCD and the memory areas are such that I can only make 1 Buffer, if I try to declare two buffers Keil would spit errors like thisQuoteThe memory regions are attached in the PDF from the ST RM.

author: voltsandjolts
author_rank: Unknown
timestamp: August 10, 2020, 12:50:55 pm
content: Well, you could write your own wrapper functions to access non-contiguous memory as if it were contiguous.But the compiler isn't gonna do that for you.

author: ali_asadzadeh
author_rank: Super Contributor
timestamp: August 10, 2020, 01:27:31 pm
content: QuoteThanks,any sudo code or examples? can it be used with DMA?

author: Silenos
author_rank: Regular Contributor
timestamp: August 10, 2020, 01:56:50 pm
content: I assume you are using that LTDC module to drive the display - note that srams 1-3 are out of reach of its dma.The srams 1-3 addresses seems contigous, fill them* with known values, and dma1 them as one big transfer into axi sram to find out. Never did it, but I guess it may technically work. But such copy-overwrite would propably be visible on display.Oh, your buffer seems too big even for 32 bit transfer for those general dma's 16-bit item counter, so it would be double transfer..Any chances you can slap external memory to qspi or fmc for the buffer?*you need scatter file (script) for linker to assign variables in c with _attribute_ to desired named regions of memory.Ok I happen to dig out my keil + that STM project, maybe it may help. Idk if are familiar with linker trickery. Maybe your error comes out of a fact you try to fit your buffer into default dtcm region. Tbh I don't know how are these ram region you filled into gui are used by a toolchain.I put a global table from main.c into axi sram:Code:uint16_t __attribute__((section("FRAME_TEST"))) frame = {0};Linker script:Code:FLASH 0x08000000 0x08020000{FLASH_PROGRAM 0x08000000 0x08020000{startup_stm32h743xx.o (RESET, +FIRST) ;fit your own startup*(+RO) ;remaining code}RAM_DTCM 0x20000000 0x2001FFFF{*(+RW,+ZI) ;unasigned variables}RAM_AXI 0x24000000 0x2407FFFF{main.o (FRAME_TEST)}}In keil you add that linker script/scatter file in Linker tab in options window. And add misc argument--entry=Reset_Handler(check name of your handler) for whatever reason it refused me to pull the ENTRY point from script in earlier version.Inspect .map file afterwards, it is crucial to validate your desires.

author: ali_asadzadeh
author_rank: Super Contributor
timestamp: August 11, 2020, 06:28:03 am
content: Thanks Silenos, do you have the complete linker script?

author: Silenos
author_rank: Regular Contributor
timestamp: August 11, 2020, 04:23:03 pm
content: It is complete - it is enough to build a project. Just fit the names of startup file and maybe reset handler to bo coherent with your project. You need rest of srams - type them in them just like the axi sram is done, with addresses from rm page you have attached.Oh, and btw you have to enable the "far" srams in RCC registers, just like every other peripheral, before filling routines kick in. It saves you an "unexplainable crash" at boot.If you happen to have jump to "SystemInit" before "__main" in your startup file, put the enable code inside "SystemInit".