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