Author Topic: Link Error  (Read 6911 times)

Offline neil

  • Sr. Member
  • ****
  • Posts: 438
    • View Profile
Link Error
« on: November 25, 2013, 11:05:54 AM »
Hi Mark,
  I am using the 52259, and set everything up for 512k memory, but getting a segment overflow flash2 , see my linker file below. Looking at the linker file, below, I have changed the following and want to make sure there will be no issues:

changed:
    flash1  (RX)   : ORIGIN = 0x00000000, LENGTH = 0x001000

and
    flash2  (RX)   : ORIGIN = 0x00001020, LENGTH = 0x007EFDC

Many Thanks
Neil


MEMORY
{
    flash1  (RX)   : ORIGIN = 0x00000000, LENGTH = 0x000400
    flashconfig   (RX)   : ORIGIN = 0x00000400, LENGTH = 0x00000018 
    flash2  (RX)   : ORIGIN = 0x00000420, LENGTH = 0x003FBE0
    vectorram(RWX) : ORIGIN = 0x20000000, LENGTH = 0x00000400
  /*  usbrram(RWX) : ORIGIN = 0x20000400, LENGTH = 0x00000080
    sram    (RWX)  : ORIGIN = 0x20000480, LENGTH = 0x00007b80   */
    sram    (RWX)  : ORIGIN = 0x20000400, LENGTH = 0x0000FC00   
    extram    (RWX): ORIGIN = 0x2040000, LENGTH = 0x00080000    /* {2} */
    ipsbar  (RWX)  : ORIGIN = 0x40000000, LENGTH = 0x0
}
 

SECTIONS
{
   .ipsbar    : {} > ipsbar
   
   .flash1 :
   {
      Startup.s (.text)
      .             = ALIGN(0x10);

    } > flash1
   
   .flashconfig :
   {
      flash_config.s (.text)            
    } > flashconfig     
   
   .flash2 :
   {
      .             = ALIGN(0x10);
      *(.text)
      .             = ALIGN(0x10);

      *(.rodata)
      ___DATA_ROM      = .;      
    } > flash2       
   
    .data : AT(___DATA_ROM)
   {
      ___DATA_RAM    = . ;
        *(.data)
      .              = ALIGN (0x10);
      ___DATA_END    = .;

      __START_SDATA  = .;
        *(.sdata)
      .              = ALIGN (0x10);
      __END_SDATA    = .;
__SDA_BASE     = .;

          .              = ALIGN(0x10);
      
   } > extram                                                           // {2}

   .bss :
   {
      . = ALIGN(0x10);
      __START_SBSS = .;
      *(.sbss)
      *(SCOMMON)
      __END_SBSS   = .;

      . = ALIGN(0x10);
      __START_BSS  = .;
      *(.bss)
      *(COMMON)
      __END_BSS    = .;   
        ___BSS_START = __START_SBSS;
        ___BSS_END   = __END_BSS;
        . = ALIGN(0x10);

   } >> extram                                                          // {2}

   ___FLASH      = ADDR(.flash1);
   ___FLASH_SIZE   = 0x00040000;
   ___SRAM         = 0x20000000;
   ___VECT_SIZE   = 0x00000400;
   ___SRAM_SIZE   = 0x00010000;

   ___VECTOR_RAM   = ___SRAM;
   ___IPSBAR      = ADDR(.ipsbar);
/*   ___USB_BDT_RAM = ___SRAM + 0x400;   */
   ___INTERNAL_RAM = ___SRAM + ___VECT_SIZE;

    __S_romp        = 0;

       HEAP_SIZE    = 0;                                                  /* {1} This can be left as zero if only uMalloc is used */
   ___HEAP_START   = .;
   ___HEAP_END   = ___HEAP_START + HEAP_SIZE;
   ___SP_INIT   = ___SRAM + ___SRAM_SIZE;
   ___PC_INIT      = ___FLASH + 0x8;   
   
     ___heap_addr    = ___HEAP_START;
   ___heap_size    = ___HEAP_END - ___HEAP_START ;
   __SP_INIT       = ___SP_INIT;
}

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3236
    • View Profile
    • uTasker
Re: Link Error
« Reply #1 on: November 25, 2013, 03:03:22 PM »
Hi Neil

If you have 512 Flash it is OK to increase the size of the second flash area (from the default value for 256k devices)

flash2  (RX)   : ORIGIN = 0x00000420, LENGTH = 0x007FBE0

The size of the first flash area should however be left unchanged otherwise it will move the flash configuration area, which could lead to problems.

Regards

Mark

Offline neil

  • Sr. Member
  • ****
  • Posts: 438
    • View Profile
Re: Link Error
« Reply #2 on: November 25, 2013, 05:01:45 PM »
Hi Mark,
  Just noticed , the above is when I am NOT using the boot-loader.  The below is when I use the boot loader:

MEMORY
{
    flash   (RX)   : ORIGIN = 0x00001000, LENGTH = 0x0007F800
    vectorram(RWX) : ORIGIN = 0x20000000, LENGTH = 0x00000400
    sram    (RWX)  : ORIGIN = 0x20000400, LENGTH = 0x0000FC00   
    extram    (RWX): ORIGIN = 0x2040000, LENGTH = 0x00080000    /* {2} */
    ipsbar  (RWX)  : ORIGIN = 0x40000000, LENGTH = 0x0
}


When I am using boot-loader application, doesn't this use up to location 0x1000? When I program my app after the boot-loader, I start at memory address 0x1000. I thought the boot-loader is 0x1000 bytes long?

Regards
Neil
« Last Edit: November 25, 2013, 05:04:54 PM by neil »

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3236
    • View Profile
    • uTasker
Re: Link Error
« Reply #3 on: November 25, 2013, 11:36:38 PM »
Neil

In the case of the application configuration to work together with the boot loader there is no flash configuration content.
Therefore the single area of importance is "flash"
Its start location depends on the boot loader size so, assuming 0x1000 is the start address (boot loader < 0x1000 of course),
flash   (RX)   : ORIGIN = 0x00001000, LENGTH = 0x0007F000
would be suitable (length is size of flash minus the application start address).

The exact length is not normally critical since it is only used by the linker to warn when the content gets too large to locate it - using 0x0007efff instead of 0x0007f000 or  would, for example, not cause errors in the image to result.

Regards

Mark