linker_psram_4m.ld 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607
  1. /*
  2. * Copyright (c) 2013-2014 Wind River Systems, Inc.
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. */
  6. /**
  7. * @file
  8. * @brief Linker command/script file
  9. *
  10. * Linker script for the Cortex-M platforms.
  11. */
  12. #include <autoconf.h>
  13. #include <linker/sections.h>
  14. #include <devicetree.h>
  15. #include <linker/linker-defs.h>
  16. #include <linker/linker-tool.h>
  17. #ifdef CONFIG_SECTION_OVERLAY
  18. #include <section_overlay.h>
  19. #endif
  20. /* physical address of RAM */
  21. #define ROMABLE_REGION FLASH
  22. #define RAMABLE_REGION PSRAM
  23. #define ROM_ADDR (CONFIG_FLASH_BASE_ADDRESS + CONFIG_FLASH_LOAD_OFFSET)
  24. #define ROM_SIZE (CONFIG_FLASH_SIZE*1K - CONFIG_FLASH_LOAD_OFFSET)
  25. #define RAM_SIZE (CONFIG_SRAM_SIZE * 1K)
  26. #define RAM_ADDR CONFIG_SRAM_BASE_ADDRESS
  27. /* Set alignment to CONFIG_ARM_MPU_REGION_MIN_ALIGN_AND_SIZE
  28. * to make linker section alignment comply with MPU granularity.
  29. */
  30. #if defined(CONFIG_ARM_MPU_REGION_MIN_ALIGN_AND_SIZE)
  31. _region_min_align = CONFIG_ARM_MPU_REGION_MIN_ALIGN_AND_SIZE;
  32. #else
  33. /* If building without MPU support, use default 4-byte alignment. */
  34. _region_min_align = 4;
  35. #endif
  36. #define MPU_ALIGN(region_size) . = ALIGN(_region_min_align)
  37. MEMORY
  38. {
  39. FLASH (rx) : ORIGIN = ROM_ADDR, LENGTH = ROM_SIZE
  40. SRAM (wx) : ORIGIN = CONFIG_SRAM_BASE_ADDRESS, LENGTH = RAM_SIZE
  41. PSRAM (wx) : ORIGIN = CONFIG_PSRAM_BASE_ADDRESS, LENGTH = CONFIG_PSRAM_SIZE * 1K
  42. SHARE_RAM (wx) : ORIGIN = 0x2FF1AE00, LENGTH = 0x51FF
  43. DSP_SRAM (wx) : ORIGIN = 0x30044000, LENGTH = 0x14000
  44. /* Used by and documented in include/linker/intlist.ld */
  45. IDT_LIST (wx) : ORIGIN = (RAM_ADDR + RAM_SIZE), LENGTH = 2K
  46. }
  47. ENTRY(CONFIG_KERNEL_ENTRY)
  48. SECTIONS
  49. {
  50. #include <linker/rel-sections.ld>
  51. /*
  52. * .plt and .iplt are here according to 'arm-zephyr-elf-ld --verbose',
  53. * before text section.
  54. */
  55. /DISCARD/ :
  56. {
  57. *(.plt)
  58. }
  59. /DISCARD/ :
  60. {
  61. *(.iplt)
  62. }
  63. GROUP_START(ROMABLE_REGION)
  64. __rom_region_start = ROM_ADDR;
  65. SECTION_PROLOGUE(rom_start,,)
  66. {
  67. /* Located in generated directory. This file is populated by calling
  68. * zephyr_linker_sources(ROM_START ...). This typically contains the vector
  69. * table and debug information.
  70. */
  71. #include <snippets-rom-start.ld>
  72. } GROUP_LINK_IN(ROMABLE_REGION)
  73. SECTION_PROLOGUE(img_head,(ROM_ADDR+0x200),) AT (ROM_ADDR+0x200)
  74. {
  75. KEEP(*(.img_head*))
  76. } GROUP_LINK_IN(ROMABLE_REGION)
  77. SECTION_PROLOGUE(_ACTIONS_RODATA_SECTION_NAME,,)
  78. {
  79. . = ALIGN(4);
  80. __app_entry_table = .;
  81. KEEP(*(.app_entry))
  82. __app_entry_end = .;
  83. . = ALIGN(4);
  84. __service_entry_table = .;
  85. KEEP(*(.service_entry))
  86. __service_entry_end = .;
  87. . = ALIGN(4);
  88. __view_entry_table = .;
  89. KEEP(*(.view_entry))
  90. __view_entry_end = .;
  91. } GROUP_LINK_IN(ROMABLE_REGION)
  92. #ifdef CONFIG_SENSOR_ALGO
  93. #include <sensor_algo.ld>
  94. #endif
  95. SECTION_PROLOGUE(_TEXT_SECTION_NAME,,)
  96. {
  97. __text_region_start = .;
  98. #include <linker/kobject-text.ld>
  99. *(.text)
  100. *(".text.*")
  101. *(.gnu.linkonce.t.*)
  102. /*
  103. * These are here according to 'arm-zephyr-elf-ld --verbose',
  104. * after .gnu.linkonce.t.*
  105. */
  106. *(.glue_7t) *(.glue_7) *(.vfp11_veneer) *(.v4_bx)
  107. } GROUP_LINK_IN(ROMABLE_REGION)
  108. __text_region_end = .;
  109. /*#if defined (CONFIG_CPLUSPLUS)*/
  110. SECTION_PROLOGUE(.ARM.extab,,)
  111. {
  112. /*
  113. * .ARM.extab section containing exception unwinding information.
  114. */
  115. *(.ARM.extab* .gnu.linkonce.armextab.*)
  116. } GROUP_LINK_IN(ROMABLE_REGION)
  117. /*#endif*/
  118. SECTION_PROLOGUE(.ARM.exidx,,)
  119. {
  120. /*
  121. * This section, related to stack and exception unwinding, is placed
  122. * explicitly to prevent it from being shared between multiple regions.
  123. * It must be defined for gcc to support 64-bit math and avoid
  124. * section overlap.
  125. */
  126. __start_unwind_idx = .;
  127. __exidx_start = .;
  128. #if defined (__GCC_LINKER_CMD__)
  129. *(.ARM.exidx* gnu.linkonce.armexidx.*)
  130. #endif
  131. __exidx_end = .;
  132. __stop_unwind_idx = .;
  133. } GROUP_LINK_IN(ROMABLE_REGION)
  134. __rodata_region_start = .;
  135. #include <linker/common-rom.ld>
  136. #include <linker/thread-local-storage.ld>
  137. SECTION_PROLOGUE(_RODATA_SECTION_NAME,,)
  138. {
  139. *(.rodata)
  140. *(".rodata.*")
  141. *(.gnu.linkonce.r.*)
  142. /* Located in generated directory. This file is populated by the
  143. * zephyr_linker_sources() Cmake function.
  144. */
  145. #include <snippets-rodata.ld>
  146. #ifdef CONFIG_SECTION_OVERLAY
  147. . = ALIGN(4);
  148. __overlay_table = .;
  149. LONG(OVERLAY_TABLE_MAGIC)
  150. /* overlay items count */
  151. LONG(7)
  152. /* for a1_wav_p.a */
  153. LONG(OVERLAY_ID_LIBAPWAV)
  154. LONG(0);
  155. LONG(0);
  156. LONG(0);
  157. LONG(ABSOLUTE(ADDR(.overlay.data.apwav)));
  158. LONG(SIZEOF(.overlay.data.apwav));
  159. LONG(LOADADDR(.overlay.data.apwav));
  160. LONG(ABSOLUTE(ADDR(.overlay.bss.apwav)));
  161. LONG(SIZEOF(.overlay.bss.apwav));
  162. /* for a1_mp3_p.a */
  163. LONG(OVERLAY_ID_LIBAPMP3)
  164. LONG(0);
  165. LONG(0);
  166. LONG(0);
  167. LONG(ABSOLUTE(ADDR(.overlay.data.apmp3)));
  168. LONG(SIZEOF(.overlay.data.apmp3));
  169. LONG(LOADADDR(.overlay.data.apmp3));
  170. LONG(ABSOLUTE(ADDR(.overlay.bss.apmp3)));
  171. LONG(SIZEOF(.overlay.bss.apmp3));
  172. /* for a1_ape_p.a */
  173. LONG(OVERLAY_ID_LIBAPAPE)
  174. LONG(0);
  175. LONG(0);
  176. LONG(0);
  177. LONG(ABSOLUTE(ADDR(.overlay.data.apape)));
  178. LONG(SIZEOF(.overlay.data.apape));
  179. LONG(LOADADDR(.overlay.data.apape));
  180. LONG(ABSOLUTE(ADDR(.overlay.bss.apape)));
  181. LONG(SIZEOF(.overlay.bss.apape));
  182. /* for a1_w13_p.a */
  183. LONG(OVERLAY_ID_LIBAPWMA)
  184. LONG(0);
  185. LONG(0);
  186. LONG(0);
  187. LONG(ABSOLUTE(ADDR(.overlay.data.apwma)));
  188. LONG(SIZEOF(.overlay.data.apwma));
  189. LONG(LOADADDR(.overlay.data.apwma));
  190. LONG(ABSOLUTE(ADDR(.overlay.bss.apwma)));
  191. LONG(SIZEOF(.overlay.bss.apwma));
  192. /* for a1_fla_p.a */
  193. LONG(OVERLAY_ID_LIBADFLA)
  194. LONG(0);
  195. LONG(0);
  196. LONG(0);
  197. LONG(ABSOLUTE(ADDR(.overlay.data.apfla)));
  198. LONG(SIZEOF(.overlay.data.apfla));
  199. LONG(LOADADDR(.overlay.data.apfla));
  200. LONG(ABSOLUTE(ADDR(.overlay.bss.apfla)));
  201. LONG(SIZEOF(.overlay.bss.apfla));
  202. /* for a1_a23_p.a */
  203. LONG(OVERLAY_ID_LIBAPAAC)
  204. LONG(0);
  205. LONG(0);
  206. LONG(0);
  207. LONG(ABSOLUTE(ADDR(.overlay.data.apaac)));
  208. LONG(SIZEOF(.overlay.data.apaac));
  209. LONG(LOADADDR(.overlay.data.apaac));
  210. LONG(ABSOLUTE(ADDR(.overlay.bss.apaac)));
  211. LONG(SIZEOF(.overlay.bss.apaac));
  212. . = ALIGN(4);
  213. #endif
  214. #include <linker/kobject-rom.ld>
  215. /*
  216. * For XIP images, in order to avoid the situation when __data_rom_start
  217. * is 32-bit aligned, but the actual data is placed right after rodata
  218. * section, which may not end exactly at 32-bit border, pad rodata
  219. * section, so __data_rom_start points at data and it is 32-bit aligned.
  220. *
  221. * On non-XIP images this may enlarge image size up to 3 bytes. This
  222. * generally is not an issue, since modern ROM and FLASH memory is
  223. * usually 4k aligned.
  224. */
  225. . = ALIGN(4);
  226. } GROUP_LINK_IN(ROMABLE_REGION)
  227. #include <linker/cplusplus-rom.ld>
  228. __rodata_region_end = .;
  229. MPU_ALIGN(__rodata_region_end -__rom_region_start);
  230. __rom_region_end = .;
  231. __rom_region_size = __rom_region_end - __rom_region_start;
  232. GROUP_END(ROMABLE_REGION)
  233. /*
  234. * These are here according to 'arm-zephyr-elf-ld --verbose',
  235. * before data section.
  236. */
  237. /DISCARD/ : {
  238. *(.got.plt)
  239. *(.igot.plt)
  240. *(.got)
  241. *(.igot)
  242. }
  243. . = RAM_ADDR;
  244. __ramdump_sram_start = .;
  245. /* Align the start of image SRAM with the
  246. * minimum granularity required by MPU.
  247. */
  248. . = ALIGN(_region_min_align);
  249. _image_ram_start = .;
  250. /* ================================= sram data =================================*/
  251. SECTION_DATA_PROLOGUE(_SRAM_CODE_SECTION_NAME,,)
  252. {
  253. . = ALIGN(4);
  254. _sram_data_start = .;
  255. _sram_func_start = .;
  256. *(.sleepfunc)
  257. *(".sleepfunc.*")
  258. *(.defunc)
  259. *(.lvglfunc)
  260. _sram_func_end = .;
  261. }GROUP_DATA_LINK_IN(SRAM, ROMABLE_REGION)
  262. _sram_func_ram_size = _sram_func_end - _sram_func_start;
  263. _sram_func_rom_start = LOADADDR(_SRAM_CODE_SECTION_NAME);
  264. SECTION_DATA_PROLOGUE(_SRAM_DATA_SECTION_NAME,,)
  265. {
  266. . = ALIGN(4);
  267. *(.sleep.data*)
  268. }GROUP_DATA_LINK_IN(SRAM, ROMABLE_REGION)
  269. _sram_data_end = .;
  270. _sram_data_ram_size = _sram_data_end - _sram_data_start;
  271. _sram_data_rom_start = LOADADDR(_SRAM_CODE_SECTION_NAME);
  272. /* ================================= psram data =================================*/
  273. OVERLAY : NOCROSSREFS
  274. {
  275. .overlay.data.apfla {
  276. *a1_fla_p.a:*(.data .data.*)
  277. }
  278. .overlay.data.apwma {
  279. *a1_w13_p.a:*(.data .data.*)
  280. }
  281. .overlay.data.apape {
  282. *a1_ape_p.a:*(.data .data.*)
  283. }
  284. .overlay.data.apmp3 {
  285. *a1_mp3_p.a:*(.data .data.*)
  286. }
  287. .overlay.data.apwav {
  288. *a1_wav_p.a:*(.data .data.*)
  289. }
  290. .overlay.data.apaac {
  291. *a1_a13_p.a:*(.data .data.*)
  292. }
  293. } GROUP_DATA_LINK_IN(PSRAM, ROMABLE_REGION)
  294. __ramdump_psram_start = ALIGN(4);
  295. /* Located in generated directory. This file is populated by the
  296. * zephyr_linker_sources() Cmake function.
  297. */
  298. #include <snippets-ram-sections.ld>
  299. SECTION_DATA_PROLOGUE(_DATA_SECTION_NAME,,)
  300. {
  301. __data_region_start = .;
  302. __data_start = .;
  303. *(.data)
  304. *(".data.*")
  305. *(".kernel.*")
  306. /* Located in generated directory. This file is populated by the
  307. * zephyr_linker_sources() Cmake function.
  308. */
  309. #include <snippets-rwdata.ld>
  310. __data_end = .;
  311. } GROUP_DATA_LINK_IN(PSRAM, ROMABLE_REGION)
  312. __data_size = __data_end - __data_start;
  313. __data_load_start = LOADADDR(_DATA_SECTION_NAME);
  314. __data_region_load_start = LOADADDR(_DATA_SECTION_NAME);
  315. #include <linker/common-ram.ld>
  316. #include <linker/kobject-data.ld>
  317. #include <linker/cplusplus-ram.ld>
  318. __data_region_end = .;
  319. /* ================================= sram bss =================================*/
  320. SECTION_PROLOGUE(_SRAM_BSS_SECTION_NAME,(NOLOAD),)
  321. {
  322. __sram_bss_start = .;
  323. *(.bss.sys_pool_buffer*)
  324. *(.bss.share_stack_area*)
  325. *(.bss.btsrv_stack_area*)
  326. *(.bss.meidasrv_stack_area*)
  327. *(.bss.sensorsrv_stack_area*)
  328. *(.bss.logsrv_stack*)
  329. *(.bss.bat_work_stack*)
  330. *(.bss.cache_buf*)
  331. *(.bss.nor_cache_data*)
  332. *(.bss.logsrv_svc_buf*)
  333. *(.bss.heap_base*)
  334. *(.bss.diskio_cache*)
  335. *(.bss.state_map_table*)
  336. *(.bss.Decoder*)
  337. *(.bss.bt_mem_buffer*)
  338. *(".kernel_bss.*")
  339. *(.bthost_bss*)
  340. *(.btsrv_bss*)
  341. __sram_bss_end = .;
  342. } GROUP_LINK_IN(SRAM)
  343. /* ================================= psram bss ================================= */
  344. OVERLAY : NOCROSSREFS
  345. {
  346. .overlay.bss.apfla {
  347. *a1_fla_p.a:*(.bss .bss.* .scommon COMMON)
  348. }
  349. .overlay.bss.apwma {
  350. *a1_w13_p.a:*(.bss .bss.* .scommon COMMON)
  351. }
  352. .overlay.bss.apape {
  353. *a1_ape_p.a:*(.bss .bss.* .scommon COMMON)
  354. }
  355. .overlay.bss.apmp3 {
  356. *a1_mp3_p.a:*(.bss .bss.* .scommon COMMON)
  357. }
  358. .overlay.bss.apwav {
  359. *a1_wav_p.a:*(.bss .bss.* .scommon COMMON)
  360. }
  361. .overlay.bss.apaac {
  362. *a1_a13_p.a:*(.bss .bss.* .scommon COMMON)
  363. }
  364. } GROUP_LINK_IN(PSRAM)
  365. __psram_bss_start = .;
  366. __bss_start = .;
  367. SECTION_PROLOGUE(_BSS_SECTION_NAME,(NOLOAD),)
  368. {
  369. /*
  370. * For performance, BSS section is assumed to be 4 byte aligned and
  371. * a multiple of 4 bytes
  372. */
  373. . = ALIGN(4);
  374. *(.bss)
  375. *(.bss.*)
  376. *(.scommon)
  377. *(COMMON)
  378. /*
  379. * As memory is cleared in words only, it is simpler to ensure the BSS
  380. * section ends on a 4 byte boundary. This wastes a maximum of 3 bytes.
  381. */
  382. } GROUP_LINK_IN(PSRAM)
  383. SECTION_PROLOGUE(_PSRAM_BSS_SECTION_NAME,(NOLOAD),)
  384. {
  385. /*
  386. * For performance, BSS section is assumed to be 4 byte aligned and
  387. * a multiple of 4 bytes
  388. */
  389. . = ALIGN(4);
  390. } GROUP_LINK_IN(PSRAM)
  391. __bss_end = ALIGN(4);
  392. __psram_bss_end = ALIGN(4);
  393. /* ================================= sram noinit ================================= */
  394. SECTION_PROLOGUE(_SRAM_NOINIT_SECTION_NAME,(NOLOAD),)
  395. {
  396. . = ALIGN(512);
  397. __kernel_ram_start = .;
  398. *(.srm_irq_vector*)
  399. *(.interrupt.noinit.stack*)
  400. *(.main.noinit.stack*)
  401. *(.uisrv.noinit.stack*)
  402. *(.lvgl.noinit.gpu*)
  403. *(.spinand.bss.BLK_ARRAY*)
  404. *(.spinand.bss.PAGE_CACHE_BUF*)
  405. *(.system.bss.sdfs_cache*)
  406. *(.diskio.cache.pool*)
  407. *(.jpeg.bss.temp_buffer*)
  408. *(.ram.noinit*)
  409. *(.decompress.bss.cache*)
  410. *(.lvgl.noinit.vdb*)
  411. *(.ram.noinit.stack*)
  412. *(.audio.bss.ouput_pcm*)
  413. *(.audio.bss.input_pcm*)
  414. *(.act_s2_not_save_mem*)
  415. *(.lvgl.noinit.malloc*)
  416. *(.vglite.noinit.mem_pool*)
  417. *(.vglite.noinit.malloc*)
  418. __kernel_ram_save_end = .;
  419. }GROUP_LINK_IN(SRAM)
  420. __ramdump_sram_end = ALIGN(4);
  421. SECTION_PROLOGUE(_SRAM_SLEEP_SHUTDOWN_SECTION_NAME,(NOLOAD),)
  422. {
  423. . = ALIGN(512);
  424. _sleep_shutdown_ram_start = .;
  425. *(.sram.noinit.sufacebuffer*)
  426. _sleep_shutdown_ram_end = .;
  427. }GROUP_LINK_IN(SRAM)
  428. #ifdef CONFIG_SIM_FLASH_ACTS
  429. SECTION_PROLOGUE(SIM_ACTLOG,(NOLOAD),)
  430. {
  431. . = ALIGN(4);
  432. __sim_flash_ram_start = .;
  433. *(.sram.noinit.actlog*)
  434. __sim_flash_ram_end = .;
  435. }GROUP_LINK_IN(SRAM)
  436. #endif
  437. /* ================================= psram noinit ================================= */
  438. SECTION_PROLOGUE(_NOINIT_SECTION_NAME,(NOLOAD),)
  439. {
  440. /*
  441. * This section is used for non-initialized objects that
  442. * will not be cleared during the boot process.
  443. */
  444. *(.noinit)
  445. *(".noinit.*")
  446. *(".kernel_noinit.*")
  447. /* Located in generated directory. This file is populated by the
  448. * zephyr_linker_sources() Cmake function.
  449. */
  450. #include <snippets-noinit.ld>
  451. #ifdef CONFIG_SOC_NOINIT_LD
  452. #include <soc-noinit.ld>
  453. #endif
  454. } GROUP_LINK_IN(SRAM)
  455. SECTION_PROLOGUE(_PRAM_NOINIT_SECTION_NAME, (NOLOAD),SUBALIGN(64))
  456. {
  457. __ramdump_psram_end = ALIGN(4);
  458. *(.UI_PSRAM_REGION*)
  459. *(.RES_PSRAM_REGION*)
  460. *(.BMPFONT_PSRAM_REGION*)
  461. *(.font.bss.cache*)
  462. *(.tile.bss.cache*)
  463. } GROUP_LINK_IN(PSRAM)
  464. /* Define linker symbols */
  465. _image_ram_end = .;
  466. __kernel_ram_end = RAM_ADDR + RAM_SIZE;
  467. __kernel_ram_size = __kernel_ram_end - __kernel_ram_start;
  468. SECTION_PROLOGUE(_ATT_RUNTIME_DATA_SECTION_NAME,(NOLOAD),)
  469. {
  470. /*
  471. * For att runtime data
  472. */
  473. . = ALIGN(4);
  474. KEEP(*(.attruntimedata*))
  475. }GROUP_LINK_IN(DSP_SRAM)
  476. /* ================================= share ram noinit ================================= */
  477. SECTION_DATA_PROLOGUE(_SHARE_RAM_BSS_SECTION_NAME, (NOLOAD),SUBALIGN(4))
  478. {
  479. __share_ram_start = .;
  480. *(.DSP_SHARE_RAM*)
  481. } GROUP_LINK_IN(SHARE_RAM)
  482. __share_ram_end = .;
  483. _end = .; /* end of image */
  484. /* Located in generated directory. This file is populated by the
  485. * zephyr_linker_sources() Cmake function.
  486. */
  487. #include <snippets-sections.ld>
  488. #include <linker/debug-sections.ld>
  489. /DISCARD/ : { *(.note.GNU-stack) }
  490. SECTION_PROLOGUE(.ARM.attributes, 0,)
  491. {
  492. KEEP(*(.ARM.attributes))
  493. KEEP(*(.gnu.attributes))
  494. }
  495. /* Must be last in romable region */
  496. SECTION_PROLOGUE(.last_section,(NOLOAD),)
  497. {
  498. } GROUP_LINK_IN(ROMABLE_REGION)
  499. /* To provide the image size as a const expression,
  500. * calculate this value here. */
  501. _flash_used = LOADADDR(.last_section) - __rom_region_start;
  502. }