搜索
bottom↓
回复: 0

arm-gcc链接脚本如何修改将程序链接到外部flash

[复制链接]

出0入0汤圆

发表于 2013-6-15 10:36:37 | 显示全部楼层 |阅读模式
我使用LPC1788处理器,因为程序比较大,所以打算将一部分程序烧写到外部的nor flash中,MDK下添加了nor flash的烧写算法,而且测试也已经通过并可以烧写程序,程序可正常运行。keil的链接脚本比较简单,而且生成方便。
因为用到了一些标准库以及.a的静态库,所以使用gnu的工具链,但是链接脚本不会编写,求指教,外部nor flash起始地址为0x90000000,MEMORY段已经标识,比如放一个lib.a和一个hello.o到外部的nor flash中 脚本应该如何编写
原链接脚本如下:
  1. /*
  2. * linker script for LPC1788 (512kB Flash, 48kB + 48kB SRAM ) with GNU ld
  3. * yiyue.fang 2012-04-14
  4. */

  5. /* Program Entry, set to mark it as "used" and avoid gc */
  6. MEMORY
  7. {
  8.     CODE (rx) : ORIGIN = 0x00000000, LENGTH = 0x00080000
  9.     DATA (rw) : ORIGIN = 0x10000000, LENGTH = 0x00010000
  10.     EXCODE (rx) : ORIGIN = 0x90000000, LENGTH = 0x00400000
  11. }
  12. ENTRY(Reset_Handler)
  13. _system_stack_size = 0x200;

  14. SECTIONS
  15. {
  16.     .text :
  17.     {
  18.         . = ALIGN(4);
  19.         KEEP(*(.isr_vector))      /* Startup code */
  20.         . = ALIGN(4);
  21.         *(.text)                        /* remaining code */
  22.         *(.text.*)                      /* remaining code */
  23.         *(.rodata)                      /* read-only data (constants) */
  24.         *(.rodata*)
  25.         *(.glue_7)
  26.         *(.glue_7t)
  27.         *(.gnu.linkonce.t*)

  28.         /* section information for finsh shell */
  29.         . = ALIGN(4);
  30.         __fsymtab_start = .;
  31.         KEEP(*(FSymTab))
  32.         __fsymtab_end = .;
  33.         . = ALIGN(4);
  34.         __vsymtab_start = .;
  35.         KEEP(*(VSymTab))
  36.         __vsymtab_end = .;
  37.         . = ALIGN(4);

  38.         . = ALIGN(4);
  39.         _etext = .;
  40.     } > CODE = 0
  41.    
  42.     /* .ARM.exidx is sorted, so has to go in its own output section.  */
  43.     __exidx_start = .;
  44.     .ARM.exidx :
  45.     {
  46.         *(.ARM.exidx* .gnu.linkonce.armexidx.*)

  47.         /* This is used by the startup in order to initialize the .data secion */
  48.         _sidata = .;
  49.     } > CODE
  50.     __exidx_end = .;

  51.     /* .data section which is used for initialized data */

  52.     .data : AT (_sidata)
  53.     {
  54.         . = ALIGN(4);
  55.         /* This is used by the startup in order to initialize the .data secion */
  56.         _sdata = . ;

  57.         *(.data)
  58.         *(.data.*)
  59.         *(.gnu.linkonce.d*)

  60.         . = ALIGN(4);
  61.         /* This is used by the startup in order to initialize the .data secion */
  62.         _edata = . ;
  63.     } >DATA

  64.     .stack :
  65.     {
  66.         . = . + _system_stack_size;
  67.         . = ALIGN(4);
  68.         _estack = .;
  69.     } >DATA

  70.     __bss_start = .;
  71.     .bss :
  72.     {
  73.         . = ALIGN(4);
  74.         /* This is used by the startup in order to initialize the .bss secion */
  75.         _sbss = .;

  76.         *(.bss)
  77.         *(.bss.*)
  78.         *(COMMON)

  79.         . = ALIGN(4);
  80.         /* This is used by the startup in order to initialize the .bss secion */
  81.         _ebss = . ;        
  82.         *(.bss.init)
  83.     } > DATA
  84.     __bss_end = .;

  85.     _end = .;

  86.     /* Stabs debugging sections.  */
  87.     .stab          0 : { *(.stab) }
  88.     .stabstr       0 : { *(.stabstr) }
  89.     .stab.excl     0 : { *(.stab.excl) }
  90.     .stab.exclstr  0 : { *(.stab.exclstr) }
  91.     .stab.index    0 : { *(.stab.index) }
  92.     .stab.indexstr 0 : { *(.stab.indexstr) }
  93.     .comment       0 : { *(.comment) }
  94.     /* DWARF debug sections.
  95.      * Symbols in the DWARF debugging sections are relative to the beginning
  96.      * of the section so we begin them at 0.  */
  97.     /* DWARF 1 */
  98.     .debug          0 : { *(.debug) }
  99.     .line           0 : { *(.line) }
  100.     /* GNU DWARF 1 extensions */
  101.     .debug_srcinfo  0 : { *(.debug_srcinfo) }
  102.     .debug_sfnames  0 : { *(.debug_sfnames) }
  103.     /* DWARF 1.1 and DWARF 2 */
  104.     .debug_aranges  0 : { *(.debug_aranges) }
  105.     .debug_pubnames 0 : { *(.debug_pubnames) }
  106.     /* DWARF 2 */
  107.     .debug_info     0 : { *(.debug_info .gnu.linkonce.wi.*) }
  108.     .debug_abbrev   0 : { *(.debug_abbrev) }
  109.     .debug_line     0 : { *(.debug_line) }
  110.     .debug_frame    0 : { *(.debug_frame) }
  111.     .debug_str      0 : { *(.debug_str) }
  112.     .debug_loc      0 : { *(.debug_loc) }
  113.     .debug_macinfo  0 : { *(.debug_macinfo) }
  114.     /* SGI/MIPS DWARF 2 extensions */
  115.     .debug_weaknames 0 : { *(.debug_weaknames) }
  116.     .debug_funcnames 0 : { *(.debug_funcnames) }
  117.     .debug_typenames 0 : { *(.debug_typenames) }
  118.     .debug_varnames  0 : { *(.debug_varnames) }
  119. }
复制代码

阿莫论坛20周年了!感谢大家的支持与爱护!!

曾经有一段真挚的爱情摆在我的面前,我没有珍惜,现在想起来,还好我没有珍惜……
回帖提示: 反政府言论将被立即封锁ID 在按“提交”前,请自问一下:我这样表达会给举报吗,会给自己惹麻烦吗? 另外:尽量不要使用Mark、顶等没有意义的回复。不得大量使用大字体和彩色字。【本论坛不允许直接上传手机拍摄图片,浪费大家下载带宽和论坛服务器空间,请压缩后(图片小于1兆)才上传。压缩方法可以在微信里面发给自己(不要勾选“原图),然后下载,就能得到压缩后的图片。注意:要连续压缩2次才能满足要求!!】。另外,手机版只能上传图片,要上传附件需要切换到电脑版(不需要使用电脑,手机上切换到电脑版就行,页面底部)。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

手机版|Archiver|amobbs.com 阿莫电子技术论坛 ( 粤ICP备2022115958号, 版权所有:东莞阿莫电子贸易商行 创办于2004年 (公安交互式论坛备案:44190002001997 ) )

GMT+8, 2024-8-25 23:01

© Since 2004 www.amobbs.com, 原www.ourdev.cn, 原www.ouravr.com

快速回复 返回顶部 返回列表