cancel
Showing results for 
Search instead for 
Did you mean: 

Place Pictures data in external ram

Hello Dear Engineers and Developers,

This one is an advance question for me, perhaps as easy as ABC for you.

I want to put image data on the external ram. Either of Keil or Stm32cubeIDE compilers are acceptable. I know that I should change the linker script, read data from one external memory, and load it into (the external) ram region. I had saved the binary data into SDCARD and have been able to read SDCARD data.

First question: How should I change the linker script in either of the compilers so that the data are put and read from external ram? I have been able to write into external ram from SDCARD.

Second question: For Touchgfx, which Address should I write into so that I can be able to see them as if data was in the internal flash section?

Any help would be appreciated.

8 REPLIES 8

You will need to describe to the linker where memories you want it to use are situated.

ie QSPI is at 0x90000000, SDRAM probably at 0xC0000000 or 0xD0000000, this should be in the Reference Manual or Data Sheet

With external memories you MUST configure the peripheral, pins and memories themselves properly BEFORE touching them.

In more normative models you'd do this in SystemInit() prior to the code in startup.s that initializes the statics, copies data, zeros other data, and calls the constructors, etc.

If you're using Keil, and initialize the memory properly, their code in __main / scatterload will unpack the load regions described in the scatter file (Keil's linker script equivalent)

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

>>This one is an advance question for me, perhaps as easy as ABC for you.

College level Compilers, Assemblers, Linkers and Loaders should provide sufficient context. I took EE not CS

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

Dear @Community member​ 

Thank you for your reply.

I was looking for a handy guide. To tell on how to configure the code and compiler. Any videos or documents. I said I know I should do all of them. I asked HOW should I do them. Any template or anything that can help.

; *************************************************************
; *** Scatter-Loading Description File generated by uVision ***
; *************************************************************
 
LR_IROM1 0x08000000 0x40000  {    ; load region size_region
	ER_IROM1 0x08000000 0x40000  {  ; load address = execution address
		*.o (RESET, +First)
	}
	RW_IRAM1 0x20000000 0x00020000  {  ; RW data
		.ANY (+RW +ZI)
	}
}
 
LR_IROM2 0x08041000     {    ; load region size_region
	ER_IROM2 0x08041000     {
		*(.IntThirdPartyHeaderSection, +First)
		*(InRoot$$Sections)
		.ANY (+RO)
	}
	RW__RAM  0x24000000 0x80000{
		*(.sdio_heap)
		*(.audio_buffers)
		*(.jpeg_decoder_buffers)
		*(heap_mem)
		*(.avi_video_buffers)
		.ANY (+RW +ZI)
	}
	ER_SDRAM 0xD0000000 UNINIT 0x2000000{
		*(.framebuffer)
		*(.viz_back_buffer)
		*(.viz_bitmap_buffer)
		*(.viz_deform_x_buffer)
		*(.viz_deform_y_buffer)
		*(.viz_front_buffer)
		*(.rgb_video_buffers)
		*(.gfx_buffers)
		*(.STemWinMemPool)
	}
}
LR_QSPI_STEW 0x90800000  {
	thp_ext_header  0x90800000  0x40 {
		*(.ExtThirdPartyHeaderSection)
	}
	ER_QSPI_STEW  0x90800040 0x1DFFFC0 {
		*(demo_icon_section)
		*(demo_logo_section)
		*(.ExtQSPIFlashSection)
		ST_Fonts.o(+RO)
		FComic24B_ASCII.o (+RO)
		F13B_1.o (+RO)
		F13B_ASCII.o (+RO)
		F13_1.o (+RO)
		F13_ASCII.o (+RO)
		F16B_1.o (+RO)
		F16B_ASCII.o (+RO)
		F16_ASCII.o (+RO)
		F20B_1.o(+RO)
		F20B_ASCII.o (+RO)
		F20_1.o (+RO)
		F20_ASCII.o(+RO)
		Arial32.o (+RO)
	}
} 
; *************************************************************
; *** Scatter-Loading Description File generated by uVision ***
; *************************************************************
 
LR_IROM1 0x08140000 0x1000  {    ; load region size_region
  ER_IROM1 0x08140000 0x1000 {
        *.o (RESET, +First)
  }
}
 
LR_TGFX 0x08141000   {    ; load region size_region
  ER_TGFX 0x08141000  {
   *(.IntThirdPartyHeaderSection, +First)
   *(FontFlashSection)
   *(TextFlashSection)
   *(InRoot$$Sections)
      .ANY (+RO)
	  }
 
  RW_IRAM1 0x24000000 0x80000  {  ; RW data
   .ANY (+RW +ZI)
   *(audio_buffers)
  }
}
 
LR_QSPI_TGFX 0x94400000 0x1E00000  {    ; load region size_region
  ER_thp_ext_header 0x94400000 0x40  {	
  *(.ExtThirdPartyHeaderSection, +First)
     }
  ER_QSPI_TGFX 0x94400040   {
    *(demo_icon_section)
	*(demo_logo_section)
	*(ExtFlashSection)
	}
	}

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

Dear @MM..1​ 

Thank you for your follow up. I have read these documentations in advance, but yet there is no example on one compiler, either IAR, Keil, or stm32cubeide. ANY working videos.

@Community member​  How can I do that in Keil? Should I go to Keil project options, change something in the target tab, and then it is generated automatically? or should I change it in the linker tab page by hand?

mattias norlander
ST Employee

Hi Vahid,

Have you looked into the User Guide? Find it in Help > Information Center > Technical documentation > User Guide. See specifically chapter 2.5.7.2 - Place code in RAM (might be different number in other version of the UG). Admittedly the example I refer to is how to place CODE in RAM. The example also does not take into account that you rely on EXTERNAL memory. But still the example shows you some linker magic like LMA vs VMA. In terms of code you have to initialize the external memories before copying the data, hence your data copy loops might be part of main() rather than Reset_Handler().