MEMORY
{
  UNPLACED_SECTIONS (wx) : ORIGIN = 0x100000000, LENGTH = 0
  STACK (wx) : ORIGIN = 0x20008000, LENGTH = 0x00038000
  RAM (wx) : ORIGIN = 0x20000000, LENGTH = 0x00008000
  FLASH (wx) : ORIGIN = 0x00000000, LENGTH = 0x00100000
}

SECTIONS
{
  __STACK_segment_start__ = 0x20008000;
  __STACK_segment_end__ = 0x20040000;
  __STACK_segment_size__ = 0x00038000;
  __RAM_segment_start__ = 0x20000000;
  __RAM_segment_end__ = 0x20008000;
  __RAM_segment_size__ = 0x00008000;
  __FLASH_segment_start__ = 0x00000000;
  __FLASH_segment_end__ = 0x00100000;
  __FLASH_segment_size__ = 0x00100000;

  __HEAPSIZE__ = 0;
  __STACKSIZE_PROCESS__ = 0;
  __STACKSIZE__ = 8192;

  __vectors_load_start__ = 0x0;
  .vectors 0x0 : AT(0x0)
  {
    __vectors_start__ = .;
    *(.vectors .vectors.*)
  }
  __vectors_end__ = __vectors_start__ + SIZEOF(.vectors);
  __vectors_size__ = SIZEOF(.vectors);
  __vectors_load_end__ = __vectors_end__;

  . = ASSERT(__vectors_start__ == __vectors_end__ || (__vectors_end__ - __FLASH_segment_start__) <= __FLASH_segment_size__ , "error: .vectors is too large to fit in FLASH memory segment");

  __mcb_vectors_load_start__ = 0x200;
  .mcb_vectors 0x200 : AT(0x200)
  {
    __mcb_vectors_start__ = .;
    *(.mcb_vectors .mcb_vectors.*)
    . = ALIGN(MAX(__mcb_vectors_start__ + 0x100 , .), 4);
  }
  __mcb_vectors_end__ = __mcb_vectors_start__ + SIZEOF(.mcb_vectors);
  __mcb_vectors_size__ = SIZEOF(.mcb_vectors);
  __mcb_vectors_load_end__ = __mcb_vectors_end__;

  . = ASSERT(__mcb_vectors_start__ == __mcb_vectors_end__ || (__mcb_vectors_end__ - __FLASH_segment_start__) <= __FLASH_segment_size__ , "error: .mcb_vectors is too large to fit in FLASH memory segment");
  . = ASSERT(__vectors_end__ <= __mcb_vectors_start__ , "error: section .vectors overlaps absolute placed section .mcb_vectors");

  __init_load_start__ = ALIGN(__mcb_vectors_end__ , 4);
  .init ALIGN(__mcb_vectors_end__ , 4) : AT(ALIGN(__mcb_vectors_end__ , 4))
  {
    __init_start__ = .;
    *(.init .init.*)
  }
  __init_end__ = __init_start__ + SIZEOF(.init);
  __init_size__ = SIZEOF(.init);
  __init_load_end__ = __init_end__;

  . = ASSERT(__init_start__ == __init_end__ || (__init_end__ - __FLASH_segment_start__) <= __FLASH_segment_size__ , "error: .init is too large to fit in FLASH memory segment");

  __text_load_start__ = ALIGN(__init_end__ , 4);
  .text ALIGN(__init_end__ , 4) : AT(ALIGN(__init_end__ , 4))
  {
    __text_start__ = .;
    *(.text .text.* .glue_7t .glue_7 .gnu.linkonce.t.* .gcc_except_table .ARM.extab* .gnu.linkonce.armextab.*)
  }
  __text_end__ = __text_start__ + SIZEOF(.text);
  __text_size__ = SIZEOF(.text);
  __text_load_end__ = __text_end__;

  . = ASSERT(__text_start__ == __text_end__ || (__text_end__ - __FLASH_segment_start__) <= __FLASH_segment_size__ , "error: .text is too large to fit in FLASH memory segment");

  __rodata_load_start__ = ALIGN(__text_end__ , 4);
  .rodata ALIGN(__text_end__ , 4) : AT(ALIGN(__text_end__ , 4))
  {
    __rodata_start__ = .;
    *(.rodata .rodata.* .gnu.linkonce.r.*)
  }
  __rodata_end__ = __rodata_start__ + SIZEOF(.rodata);
  __rodata_size__ = SIZEOF(.rodata);
  __rodata_load_end__ = __rodata_end__;

  . = ASSERT(__rodata_start__ == __rodata_end__ || (__rodata_end__ - __FLASH_segment_start__) <= __FLASH_segment_size__ , "error: .rodata is too large to fit in FLASH memory segment");

  __data_load_start__ = ALIGN(__rodata_end__ , 4);
  .data ALIGN(__RAM_segment_start__ , 4) : AT(ALIGN(__rodata_end__ , 4))
  {
    __data_start__ = .;
    *(.data .data.* .gnu.linkonce.d.*)
  }
  __data_end__ = __data_start__ + SIZEOF(.data);
  __data_size__ = SIZEOF(.data);
  __data_load_end__ = __data_load_start__ + SIZEOF(.data);

  . = ASSERT(__data_load_start__ == __data_load_end__ || (__data_load_end__ - __FLASH_segment_start__) <=  __FLASH_segment_size__ , "error: .data is too large to fit in FLASH memory segment");

  .data_run ALIGN(__RAM_segment_start__ , 4) (NOLOAD) :
  {
    __data_run_start__ = .;
    . = MAX(__data_run_start__ + SIZEOF(.data), .);
  }
  __data_run_end__ = __data_run_start__ + SIZEOF(.data_run);
  __data_run_size__ = SIZEOF(.data_run);
  __data_run_load_end__ = __data_run_end__;

  . = ASSERT(__data_run_start__ == __data_run_end__ || (__data_run_end__ - __RAM_segment_start__) <= __RAM_segment_size__ , "error: .data_run is too large to fit in RAM memory segment");

  __bss_load_start__ = ALIGN(__data_run_end__ , 4);
  .bss ALIGN(__data_run_end__ , 4) (NOLOAD) : AT(ALIGN(__data_run_end__ , 4))
  {
    __bss_start__ = .;
    *(.bss .bss.* .gnu.linkonce.b.*) *(COMMON)
  }
  __bss_end__ = __bss_start__ + SIZEOF(.bss);
  __bss_size__ = SIZEOF(.bss);
  __bss_load_end__ = __bss_end__;

  __RAM_segment_used_end__ = ALIGN(__data_run_end__ , 4) + SIZEOF(.bss);
  __RAM_segment_used_size__ = __RAM_segment_used_end__ - __RAM_segment_start__;

  . = ASSERT(__bss_start__ == __bss_end__ || (__bss_end__ - __RAM_segment_start__) <= __RAM_segment_size__ , "error: .bss is too large to fit in RAM memory segment");

  __mcb_datas_load_start__ = 0x1F000;
  .mcb_datas 0x1F000 : AT(0x1F000)
  {
    __mcb_datas_start__ = .;
    *(.mcb_datas .mcb_datas.*)
    . = ALIGN(MAX(__mcb_datas_start__ + 0x1000 , .), 4096);
  } =0xFF
  __mcb_datas_end__ = __mcb_datas_start__ + SIZEOF(.mcb_datas);
  __mcb_datas_size__ = SIZEOF(.mcb_datas);
  __mcb_datas_load_end__ = __mcb_datas_end__;

  . = ASSERT(__mcb_datas_start__ == __mcb_datas_end__ || (__mcb_datas_end__ - __FLASH_segment_start__) <= __FLASH_segment_size__ , "error: .mcb_datas is too large to fit in FLASH memory segment");
  . = ASSERT(__data_load_end__ <= __mcb_datas_start__ , "error: section .data overlaps absolute placed section .mcb_datas");

  __firmware1_load_start__ = 0x20000;
  .firmware1 0x20000 (NOLOAD) : AT(0x20000)
  {
    __firmware1_start__ = .;
    *(.firmware1 .firmware1.*)
    . = ALIGN(MAX(__firmware1_start__ + 0x60000 , .), 4096);
  }
  __firmware1_end__ = __firmware1_start__ + SIZEOF(.firmware1);
  __firmware1_size__ = SIZEOF(.firmware1);
  __firmware1_load_end__ = __firmware1_end__;

  . = ASSERT(__firmware1_start__ == __firmware1_end__ || (__firmware1_end__ - __FLASH_segment_start__) <= __FLASH_segment_size__ , "error: .firmware1 is too large to fit in FLASH memory segment");
  . = ASSERT(__mcb_datas_end__ <= __firmware1_start__ , "error: section .mcb_datas overlaps absolute placed section .firmware1");

  __firmware2_load_start__ = 0x80000;
  .firmware2 0x80000 (NOLOAD) : AT(0x80000)
  {
    __firmware2_start__ = .;
    *(.firmware2 .firmware2.*)
    . = ALIGN(MAX(__firmware2_start__ + 0x60000 , .), 4096);
  }
  __firmware2_end__ = __firmware2_start__ + SIZEOF(.firmware2);
  __firmware2_size__ = SIZEOF(.firmware2);
  __firmware2_load_end__ = __firmware2_end__;

  . = ASSERT(__firmware2_start__ == __firmware2_end__ || (__firmware2_end__ - __FLASH_segment_start__) <= __FLASH_segment_size__ , "error: .firmware2 is too large to fit in FLASH memory segment");
  . = ASSERT(__firmware1_end__ <= __firmware2_start__ , "error: section .firmware1 overlaps absolute placed section .firmware2");

  __flashpatchunit_load_start__ = 0xE0000;
  .flashpatchunit 0xE0000 (NOLOAD) : AT(0xE0000)
  {
    __flashpatchunit_start__ = .;
    *(.flashpatchunit .flashpatchunit.*)
    . = ALIGN(MAX(__flashpatchunit_start__ + 0x20000 , .), 4096);
  }
  __flashpatchunit_end__ = __flashpatchunit_start__ + SIZEOF(.flashpatchunit);
  __flashpatchunit_size__ = SIZEOF(.flashpatchunit);
  __flashpatchunit_load_end__ = __flashpatchunit_end__;

  __FLASH_segment_used_end__ = 0xE0000 + SIZEOF(.flashpatchunit);
  __FLASH_segment_used_size__ = __FLASH_segment_used_end__ - __FLASH_segment_start__;

  . = ASSERT(__flashpatchunit_start__ == __flashpatchunit_end__ || (__flashpatchunit_end__ - __FLASH_segment_start__) <= __FLASH_segment_size__ , "error: .flashpatchunit is too large to fit in FLASH memory segment");
  . = ASSERT(__firmware2_end__ <= __flashpatchunit_start__ , "error: section .firmware2 overlaps absolute placed section .flashpatchunit");

}

