flash.icf 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. /*
  2. * Copyright (c) 2022-2023 HPMicro
  3. * SPDX-License-Identifier: BSD-3-Clause
  4. */
  5. define memory with size = 4G;
  6. /* Regions */
  7. define region XPI0 = [from 0x80000000 + 0x3000, size _flash_size - 0x3000]; /* XPI0 */
  8. define region ILM = [from 0x00000000 size 128k]; /* ILM */
  9. define region DLM = [from 0x00080000 size 128k]; /* DLM */
  10. define region NONCACHEABLE_RAM = [from 0x01080000 size 128k];
  11. define region AXI_SRAM = [from 0x010A0000 size 112k];
  12. define region SHARE_RAM = [from 0x010BC000 size 16k];
  13. define region AHB_SRAM = [from 0xF0300000 size 32k];
  14. assert (__STACKSIZE__ + __HEAPSIZE__) <= 128k with error "stack and heap total size larger than 128k";
  15. /* Blocks */
  16. define block vectors { section .isr_vector, section .vector_table };
  17. define block ctors { section .ctors, section .ctors.*, block with alphabetical order { init_array } };
  18. define block dtors { section .dtors, section .dtors.*, block with reverse alphabetical order { fini_array } };
  19. define block eh_frame { section .eh_frame, section .eh_frame.* };
  20. define block tbss { section .tbss, section .tbss.* };
  21. define block tdata { section .tdata, section .tdata.* };
  22. define block tls { block tbss, block tdata };
  23. define block tdata_load { copy of block tdata };
  24. define block heap with size = __HEAPSIZE__, alignment = 8, /* fill =0x00, */ readwrite access { };
  25. define block stack with size = __STACKSIZE__, alignment = 8, /* fill =0xCD, */ readwrite access { };
  26. define block cherryusb_usbh_class_info with alignment = 8 { section .usbh_class_info };
  27. define block framebuffer with alignment = 8 { section .framebuffer };
  28. /* Symbols */
  29. define exported symbol __noncacheable_start__ = start of region NONCACHEABLE_RAM;
  30. define exported symbol __noncacheable_end__ = end of region NONCACHEABLE_RAM + 1;
  31. define exported symbol __share_mem_start__ = start of region SHARE_RAM;
  32. define exported symbol __share_mem_end__ = end of region SHARE_RAM + 1;
  33. define exported symbol _stack_safe = end of block stack + 1;
  34. define exported symbol _stack = end of block stack + 1;
  35. define exported symbol __usbh_class_info_start__ = start of block cherryusb_usbh_class_info;
  36. define exported symbol __usbh_class_info_end__ = end of block cherryusb_usbh_class_info + 1;
  37. /* Initialization */
  38. do not initialize { section .noncacheable };
  39. do not initialize { section .non_init, section .non_init.*, section .*.non_init, section .*.non_init.* };
  40. do not initialize { section .no_init, section .no_init.*, section .*.no_init, section .*.no_init.* }; // Legacy sections, kept for backwards compatibility
  41. do not initialize { section .noinit, section .noinit.*, section .*.noinit, section .*.noinit.* }; // Legacy sections, used by some SDKs/HALs
  42. initialize by copy with packing=auto { section .noncacheable.init };
  43. initialize by copy with packing=none { section .data, section .data.*, section .*.data, section .*.data.* }; // Static data sections
  44. initialize by copy with packing=auto { section .sdata, section .sdata.* };
  45. initialize by copy with packing=auto { section .fast, section .fast.*, section .*.fast, section .*.fast.* }; // "RAM Code" sections
  46. initialize by symbol __SEGGER_init_heap { block heap }; // Init the heap if there is one
  47. initialize by symbol __SEGGER_init_ctors { block ctors }; // Call constructors for global objects which need to be constructed before reaching main (if any). Make sure this is done after setting up heap.
  48. initialize by copy { block vectors, block vectors_s };
  49. initialize by copy { block cherryusb_usbh_class_info };
  50. /* Placement */
  51. place at start of XPI0 with fixed order { symbol _start };
  52. place at start of ILM with fixed order { block vectors, block vectors_s };
  53. place in XPI0 with minimum size order {
  54. block tdata_load, // Thread-local-storage load image
  55. block ctors, // Constructors block
  56. block dtors, // Destructors block
  57. block eh_frame, // Exception frames placed directly into flash overriding default placement (sections writable)
  58. readonly, // Catch-all for readonly data (e.g. .rodata, .srodata)
  59. readexec // Catch-all for (readonly) executable code (e.g. .text)
  60. };
  61. //
  62. // The GNU compiler creates these exception-related sections as writeable.
  63. // Override the section header flag and make them readonly so they can be
  64. // placed into flash.
  65. //
  66. define access readonly { section .gcc_except_table, section .gcc_except_table.* };
  67. define access readonly { section .eh_frame, section .eh_frame.* };
  68. define access readonly { section .sdata.DW.* };
  69. place in ILM {
  70. section .fast, section .fast.* // "ramfunc" section
  71. };
  72. place in AXI_SRAM { block cherryusb_usbh_class_info };
  73. place in AXI_SRAM { block framebuffer };
  74. place in AXI_SRAM {
  75. block tls, // Thread-local-storage block
  76. readwrite, // Catch-all for initialized/uninitialized data sections (e.g. .data, .noinit)
  77. zeroinit // Catch-all for zero-initialized data sections (e.g. .bss)
  78. };
  79. place in NONCACHEABLE_RAM { section .noncacheable, section .noncacheable.init, section .noncacheable.bss };
  80. place in SHARE_RAM { section .sh_mem}; // Share memory
  81. place in AHB_SRAM { section .ahb_sram}; // AHB SRAM memory
  82. place in DLM { section .fast_ram}; // Fast access memory
  83. place in DLM { block heap }; // Heap reserved block
  84. place at end of DLM { block stack }; // Stack reserved block
  85. /* Keep */
  86. keep { section .usbh_class_info};