ram.icf 7.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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 ILM = [from 0x00000000 size 256k]; /* ILM */
  8. define region DLM = [from 0x00080000 size 256k]; /* DLM */
  9. define region AXI_SRAM = [from 0x01080000 size 512k]; /* AXI SRAM0 */
  10. define region NONCACHEABLE_RAM = [from 0x01100000 size 256k]; /* AXI SRAM1 */
  11. define region SHARE_RAM = [from 0x0117C000 size 16k];
  12. define region AHB_SRAM = [from 0xF0300000 size 32k];
  13. define region APB_SRAM = [from 0xF40F0000 size 8k];
  14. assert (__STACKSIZE__ + __HEAPSIZE__) <= 256k with error "stack and heap total size larger than 256k";
  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 cherryusb_usbh_class_info { section .usbh_class_info };
  25. define block framebuffer { section .framebuffer };
  26. define block heap with size = __HEAPSIZE__, alignment = 8, /* fill =0x00, */ readwrite access { };
  27. define block stack with size = __STACKSIZE__, alignment = 8, /* fill =0xCD, */ readwrite access { };
  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 = end of block stack + 1;
  34. define exported symbol _stack_safe = 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. do not initialize { section .backup_sram};
  43. initialize by copy with packing=auto { section .noncacheable.init };
  44. initialize by copy with packing=none { section .data, section .data.*, section .*.data, section .*.data.* }; // Static data sections
  45. initialize by copy with packing=auto { section .sdata, section .sdata.* };
  46. initialize by copy with packing=auto { section .fast, section .fast.*, section .*.fast, section .*.fast.* }; // "RAM Code" sections
  47. initialize by symbol __SEGGER_init_heap { block heap }; // Init the heap if there is one
  48. 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.
  49. /* Placement */
  50. place at start of ILM { symbol _start };
  51. place in ILM { block vectors }; // Vector table section
  52. place in ILM { section .fast, section .fast.* }; // "ramfunc" section
  53. place in ILM 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 AXI_SRAM { block cherryusb_usbh_class_info };
  70. place in AXI_SRAM { block framebuffer };
  71. place in AXI_SRAM {
  72. block tls, // Thread-local-storage block
  73. readwrite, // Catch-all for initialized/uninitialized data sections (e.g. .data, .noinit)
  74. zeroinit // Catch-all for zero-initialized data sections (e.g. .bss)
  75. };
  76. place in NONCACHEABLE_RAM { section .noncacheable, section .noncacheable.init, section .noncacheable.bss }; // Noncacheable
  77. place in SHARE_RAM { section .sh_mem}; // Share memory
  78. place in AHB_SRAM { section .ahb_sram}; // AHB SRAM memory
  79. place in APB_SRAM { section .backup_sram}; // Backup SRAM memory
  80. place in DLM { section .fast_ram}; // Fast access memory
  81. place in DLM { block heap }; // Heap reserved block
  82. place at end of DLM { block stack }; // Stack reserved block
  83. /* Keep */
  84. keep { section .usbh_class_info};