user_linker.icf 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. /*
  2. * Copyright (c) 2024 HPMicro
  3. * SPDX-License-Identifier: BSD-3-Clause
  4. */
  5. define exported symbol _link_file_version_2 = 1;
  6. define memory with size = 4G;
  7. /* Sizes */
  8. if (isdefinedsymbol(CSTACK_SIZE)) {
  9. define symbol __size_cstack__ = CSTACK_SIZE;
  10. } else {
  11. define symbol __size_cstack__ = 0x4000;
  12. }
  13. if (isdefinedsymbol(HEAP_SIZE)) {
  14. define symbol __size_heap__ = HEAP_SIZE;
  15. } else {
  16. define symbol __size_heap__ = 0x4000;
  17. }
  18. if (isdefinedsymbol(_flash_size)) {
  19. define symbol __size_flash__ = _flash_size;
  20. } else {
  21. define symbol __size_flash__ = 8M;
  22. }
  23. if (isdefinedsymbol(_extram_size)) {
  24. define symbol __size_exram__ = _extram_size;
  25. } else {
  26. define symbol __size_exram__ = 16M;
  27. }
  28. define symbol __size_safestack__ = 256;
  29. /* Regions */
  30. define region NOR_CFG_OPTION = mem:[ from 0x80000400 size 0x0C00 ];
  31. define region BOOT_HEADER = mem:[ from 0x80001000 size 0x2000 ];
  32. define region XPI0 = mem:[from 0x80003000 size (__size_flash__ - 0x3000) ]; /* XPI0 */
  33. define region ILM = mem:[from 0x00000000 size 256k]; /* ILM */
  34. define region DLM = mem:[from 0x00080000 size 256k]; /* DLM */
  35. define region AXI_SRAM = mem:[from 0x01080000 size 768k]; /* AXI SRAM */
  36. define region SHARE_RAM = mem:[from 0x0117C000 size 16k];
  37. define region SDRAM = mem:[from 0x40000000 size __size_exram__ - 4M];
  38. define region NONCACHEABLE_RAM = mem:[from 0x40000000 + __size_exram__ - 4M size 4M];
  39. define region AHB_SRAM = mem:[from 0xF0300000 size 32k];
  40. define region APB_SRAM = mem:[from 0xF40F0000 size 8k];
  41. /* Blocks */
  42. define block vectors with fixed order { section .vector_table, section .isr_vector };
  43. define block HEAP with size = __size_heap__, alignment = 8 { };
  44. define block CSTACK with size = __size_cstack__, alignment = 16 { };
  45. define block SAFESTACK with size = __size_safestack__, alignment = 8 { };
  46. define block RW_DATA with static base GPREL { rw data };
  47. define block boot_header with fixed order { section .boot_header, section .fw_info_table, section .dc_info };
  48. define block cherryusb_usbh_class_info { section .usbh_class_info };
  49. define block framebuffer { section .framebuffer, section .framebuffer.* };
  50. define block rtthread_FSymTab { section FSymTab };
  51. define block rtthread_VSymTab { section VSymTab };
  52. define block rtthread_rti_fn with alphabetical order { section .rti_fn* };
  53. define block rtthread_RTMSymTab { section RTMSymTab };
  54. /* Symbols */
  55. define exported symbol __nor_cfg_option_load_addr__ = start(NOR_CFG_OPTION);
  56. define exported symbol __boot_header_load_addr__ = start(BOOT_HEADER);
  57. define exported symbol __app_load_addr__ = start(XPI0);
  58. define exported symbol __app_offset__ = __app_load_addr__ - __boot_header_load_addr__;
  59. define exported symbol __boot_header_length__ = size(BOOT_HEADER);
  60. define exported symbol __fw_size__ = 0x1000;
  61. define exported symbol __noncacheable_start__ = start(NONCACHEABLE_RAM);
  62. define exported symbol __noncacheable_end__ = end(NONCACHEABLE_RAM) + 1;
  63. define exported symbol __share_mem_start__ = start(SHARE_RAM);
  64. define exported symbol __share_mem_end__ = end(SHARE_RAM) + 1;
  65. /* Initialization */
  66. do not initialize { section .noncacheable, section .fast_ram }; // Legacy sections, kept for backwards compatibility
  67. do not initialize { section .non_init, section .non_init.*, section .*.non_init, section .*.non_init.* };
  68. do not initialize { section .no_init, section .no_init.*, section .*.no_init, section .*.no_init.* }; // Legacy sections, kept for backwards compatibility
  69. do not initialize { section .noinit, section .noinit.*, section .*.noinit, section .*.noinit.* }; // Legacy sections, used by some SDKs/HALs
  70. do not initialize { section .backup_sram, section .backup_sram.*};
  71. initialize by copy with packing=auto { section .noncacheable.init, section .noncacheable.init.*, section .fast_ram.init, section .fast_ram.init.* };
  72. initialize by copy with packing=auto { section .fast, section .fast.*, section .*.fast, section .*.fast.* }; // "RAM Code" sections
  73. initialize by copy with packing=none { section .vector_table };
  74. initialize by copy with packing=none { section .isr_vector };
  75. initialize by copy { readwrite };
  76. /* Placement */
  77. place in NOR_CFG_OPTION { section .nor_cfg_option };
  78. place in BOOT_HEADER { block boot_header };
  79. place at start of XPI0 { symbol _start };
  80. place in XPI0 { block rtthread_FSymTab,
  81. block rtthread_VSymTab,
  82. block rtthread_rti_fn,
  83. block rtthread_RTMSymTab,
  84. block cherryusb_usbh_class_info,
  85. readonly
  86. };
  87. place at start of ILM { block vectors };
  88. place in ILM {
  89. section .fast, section .fast.*, // "ramfunc" section
  90. };
  91. place in SDRAM { block framebuffer };
  92. place in AXI_SRAM | SDRAM {
  93. block RW_DATA
  94. };
  95. place in NONCACHEABLE_RAM { section .noncacheable.non_init, section .noncacheable.non_init.*, section .noncacheable.init, section .noncacheable.init.*, section .noncacheable.bss, section .noncacheable.bss.*, section .noncacheable }; // Noncacheable
  96. place in SHARE_RAM { section .sh_mem, section .sh_mem.*}; // Share memory
  97. place in AHB_SRAM { section .ahb_sram, section .ahb_sram.*}; // AHB SRAM memory
  98. place in APB_SRAM { section .backup_sram, section .backup_sram.*}; // Backup SRAM memory
  99. place in DLM { section .fast_ram.init, section .fast_ram.init.*, section .fast_ram.non_init, section .fast_ram.non_init.*, section .fast_ram.bss, section .fast_ram.bss.*, section .fast_ram }; // Fast access memory
  100. place in SDRAM { block HEAP }; // Heap reserved block
  101. place at end of DLM { block CSTACK, block SAFESTACK }; // Stack reserved block, Safe Stack reserved block
  102. /* Keep */
  103. keep { section .nor_cfg_option, section .boot_header, section .fw_info_table, section .dc_info };
  104. keep { section .usbh_class_info,
  105. section FSymTab,
  106. section VSymTab,
  107. section .rti_fn*,
  108. section RTMSymTab
  109. };
  110. keep symbol __iar_cstart_init_gp;