Author Topic: Concatenating SRAM area in ARM Cortex M  (Read 786 times)

0 Members and 1 Guest are viewing this topic.

Online ali_asadzadehTopic starter

  • Super Contributor
  • ***
  • Posts: 1905
  • Country: ca
Concatenating SRAM area in ARM Cortex M
« on: August 10, 2020, 12:43:13 pm »
Hi,
I want to know if there is a trick to Concatenate SRAMs in STM32H750 to be able to allocate multiple LCD frame buffers
Allocating memory something like this
Code: [Select]
uint8_t framebuffer[480*320*2]={0};  //16 bpp framebuffer
I 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 this
Quote
Graphic\Graphic.axf: Error: L6407E: Sections of aggregate size 0x4b000 bytes could not fit into .ANY selector(s)

The memory regions are attached in the PDF from the ST RM.

« Last Edit: August 10, 2020, 12:44:45 pm by ali_asadzadeh »
ASiDesigner, Stands for Application specific intelligent devices
I'm a Digital Expert from 8-bits to 64-bits
 

Offline voltsandjolts

  • Supporter
  • ****
  • Posts: 2299
  • Country: gb
Re: Concatenating SRAM area in ARM Cortex M
« Reply #1 on: August 10, 2020, 12:50:55 pm »
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.
 

Online ali_asadzadehTopic starter

  • Super Contributor
  • ***
  • Posts: 1905
  • Country: ca
Re: Concatenating SRAM area in ARM Cortex M
« Reply #2 on: August 10, 2020, 01:27:31 pm »
Quote
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.

Thanks,any sudo code or examples? can it be used with DMA?
ASiDesigner, Stands for Application specific intelligent devices
I'm a Digital Expert from 8-bits to 64-bits
 

Offline Silenos

  • Regular Contributor
  • *
  • Posts: 54
  • Country: pl
  • Fumbling in ignorance
Re: Concatenating SRAM area in ARM Cortex M
« Reply #3 on: August 10, 2020, 01:56:50 pm »
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: [Select]
uint16_t __attribute__((section("FRAME_TEST"))) frame[16] = {0};Linker script:
Code: [Select]
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.
« Last Edit: August 10, 2020, 01:59:37 pm by Silenos »
 

Online ali_asadzadehTopic starter

  • Super Contributor
  • ***
  • Posts: 1905
  • Country: ca
Re: Concatenating SRAM area in ARM Cortex M
« Reply #4 on: August 11, 2020, 06:28:03 am »
Thanks Silenos, do you have the complete linker script?
ASiDesigner, Stands for Application specific intelligent devices
I'm a Digital Expert from 8-bits to 64-bits
 

Offline Silenos

  • Regular Contributor
  • *
  • Posts: 54
  • Country: pl
  • Fumbling in ignorance
Re: Concatenating SRAM area in ARM Cortex M
« Reply #5 on: August 11, 2020, 04:23:03 pm »
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".
 
The following users thanked this post: ali_asadzadeh


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf