How to complie Flash driver to RAM? while other source program still in flash?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to complie Flash driver to RAM? while other source program still in flash?

Jump to solution
1,153 Views
459021854
Contributor III

Hi, experts:

please do me a favor, when I develop a bootloader.  I need  separate Flash driver  with the other parts of bootloader code to different places.

Flash driver, such as FLASH_DRV_Program, should be compiled as a separate .src file and be  placed at RAM.

other parts of bootloader code should be placed in the flash. 

I have tryed   __attribute__((section (".customSection"))) 

status_t __attribute__((section (".customSection"))) FLASH_DRV_Program(const flash_ssd_config_t * pSSDConfig,
uint32_t dest,
uint32_t size,
const uint8_t * pData)

but in .map  the result turn out to be 360截图20200924162616978.jpg

 

 

this means  function FLASH_DRV_Program is loaded from address 0x00007acc to address 0x20000000, NOT I want.

I just want FLASH_DRV_Program is directly placed in RAM by compiler, NOT loaded from flash.

If the flash driver which placed in RAM be compiler as a separate .src,  that's better.

How can I solve those problem?  please help me, much appreciated. my MCU is S32K144.

 

@all experts 

 

 

0 Kudos
1 Solution
1,148 Views
kef2
Senior Contributor IV

Hi,

 

I'm not expert of GCC linker scripts, but as I understand it ": AT(xx)" in linker file instructs section to be loaded from xx.

 

  .code : AT(__CODE_ROM)
  {
    . = ALIGN(4);
    __CODE_RAM = .;
    __code_start__ = .;      /* Create a global symbol at code start. */
    *(.code_ram)             /* Custom section for storing code in RAM */
    . = ALIGN(4);
    __code_end__ = .;        /* Define a global symbol at code end. */
  } > m_data

 

__CODE_ROM is a location in flash while m_data is RAM. So try removing : AT(xx) and see.

 

Regards,

Edward

 

View solution in original post

3 Replies
1,124 Views
Alexis_A
NXP TechSupport
NXP TechSupport

Hello @459021854 ,

Please check the following post, explains how to modify the linker file to add the code allocation regions.

Best Regards,

Alexis Andalon

0 Kudos
1,144 Views
459021854
Contributor III

Hi, Edward

I have tryed your method that's not working.360截图20200924173725845.jpg

I think because in c  file     "   startup.c    "  there is code to  copy code from FLASH to RAM,

360截图20200924174335388.jpg

that's not I wanted. I do not want any COPY happened, because i do not want a copy of flash driver be placed in flash.   just want only one flash driver directly be  placed in RAM.

PLEASE,  still need help.

 

 

0 Kudos
1,149 Views
kef2
Senior Contributor IV

Hi,

 

I'm not expert of GCC linker scripts, but as I understand it ": AT(xx)" in linker file instructs section to be loaded from xx.

 

  .code : AT(__CODE_ROM)
  {
    . = ALIGN(4);
    __CODE_RAM = .;
    __code_start__ = .;      /* Create a global symbol at code start. */
    *(.code_ram)             /* Custom section for storing code in RAM */
    . = ALIGN(4);
    __code_end__ = .;        /* Define a global symbol at code end. */
  } > m_data

 

__CODE_ROM is a location in flash while m_data is RAM. So try removing : AT(xx) and see.

 

Regards,

Edward