flash.icf 7.2 KB

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