你的浏览器版本过低,可能导致网站不能正常访问!
为了你能正常使用网站功能,请使用这些浏览器。

eclipse+jlink在RAM中调试代码

[复制链接]
huahuahnu 提问时间:2023-12-4 16:27 / 未解决
使用eclipse+jlink下载到flash中调试stm32g0已经可以,现在想把代码放到RAM中调试,改了3个地方,但失败了,请问有研究过的小伙伴吗?网上资料都查不到
1、定义VECT_TAB_SRAM宏定义
2、修改脚本文件,代码都映射到RAM中
3、修改Debug配置选项

如果只把某个函数定义到RAM中运行该怎么改?

  1. /* Entry Point */
  2. ENTRY(Reset_Handler)

  3. /* Highest address of the user mode stack */
  4. _estack = 0x20009000;    /* end of RAM */
  5. /* Generate a link error if heap and stack don't fit into RAM */
  6. _Min_Heap_Size = 0x200;      /* required amount of heap  */
  7. _Min_Stack_Size = 0x400; /* required amount of stack */

  8. /* Specify the memory areas */
  9. MEMORY
  10. {
  11. RAM (xrw)      : ORIGIN = 0x20004000, LENGTH = 20K
  12. FLASH (rx)      : ORIGIN = 0x20000000, LENGTH = 16K
  13. }

  14. /* Define output sections */
  15. SECTIONS
  16. {
  17.   /* The startup code goes first into FLASH */
  18.   .isr_vector :
  19.   {
  20.     . = ALIGN(4);
  21.     KEEP(*(.isr_vector)) /* Startup code */
  22.     . = ALIGN(4);
  23.   } >FLASH

  24.   /* The program code and other data goes into FLASH */
  25.   .text :
  26.   {
  27.     . = ALIGN(4);
  28.     *(.text)           /* .text sections (code) */
  29.     *(.text*)          /* .text* sections (code) */
  30.     *(.glue_7)         /* glue arm to thumb code */
  31.     *(.glue_7t)        /* glue thumb to arm code */
  32.     *(.eh_frame)

  33.     KEEP (*(.init))
  34.     KEEP (*(.fini))

  35.     . = ALIGN(4);
  36.     _etext = .;        /* define a global symbols at end of code */
  37.   } >FLASH

  38.   /* Constant data goes into FLASH */
  39.   .rodata :
  40.   {
  41.     . = ALIGN(4);
  42.     *(.rodata)         /* .rodata sections (constants, strings, etc.) */
  43.     *(.rodata*)        /* .rodata* sections (constants, strings, etc.) */
  44.     . = ALIGN(4);
  45.   } >FLASH

  46.   .ARM.extab   : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >FLASH
  47.   .ARM : {
  48.     __exidx_start = .;
  49.     *(.ARM.exidx*)
  50.     __exidx_end = .;
  51.   } >FLASH

  52.   .preinit_array     :
  53.   {
  54.     PROVIDE_HIDDEN (__preinit_array_start = .);
  55.     KEEP (*(.preinit_array*))
  56.     PROVIDE_HIDDEN (__preinit_array_end = .);
  57.   } >FLASH
  58.   .init_array :
  59.   {
  60.     PROVIDE_HIDDEN (__init_array_start = .);
  61.     KEEP (*(SORT(.init_array.*)))
  62.     KEEP (*(.init_array*))
  63.     PROVIDE_HIDDEN (__init_array_end = .);
  64.   } >FLASH
  65.   .fini_array :
  66.   {
  67.     PROVIDE_HIDDEN (__fini_array_start = .);
  68.     KEEP (*(SORT(.fini_array.*)))
  69.     KEEP (*(.fini_array*))
  70.     PROVIDE_HIDDEN (__fini_array_end = .);
  71.   } >FLASH

  72.   /* used by the startup to initialize data */
  73.   _sidata = LOADADDR(.data);

  74.   /* Initialized data sections goes into RAM, load LMA copy after code */
  75.   .data :
  76.   {
  77.     . = ALIGN(4);
  78.     _sdata = .;        /* create a global symbol at data start */
  79.     *(.data)           /* .data sections */
  80.     *(.data*)          /* .data* sections */

  81.     . = ALIGN(4);
  82.     _edata = .;        /* define a global symbol at data end */
  83.   } >RAM AT> FLASH

  84.    
  85.   /* Uninitialized data section */
  86.   . = ALIGN(4);
  87.   .bss :
  88.   {
  89.     /* This is used by the startup in order to initialize the .bss secion */
  90.     _sbss = .;         /* define a global symbol at bss start */
  91.     __bss_start__ = _sbss;
  92.     *(.bss)
  93.     *(.bss*)
  94.     *(COMMON)

  95.     . = ALIGN(4);
  96.     _ebss = .;         /* define a global symbol at bss end */
  97.     __bss_end__ = _ebss;
  98.   } >RAM

  99.   /* User_heap_stack section, used to check that there is enough RAM left */
  100.   ._user_heap_stack :
  101.   {
  102.     . = ALIGN(4);
  103.     PROVIDE ( end = . );
  104.     PROVIDE ( _end = . );
  105.     . = . + _Min_Heap_Size;
  106.     . = . + _Min_Stack_Size;
  107.     . = ALIGN(4);
  108.   } >RAM

  109.    

  110.   /* Remove information from the standard libraries */
  111.   /DISCARD/ :
  112.   {
  113.     libc.a ( * )
  114.     libm.a ( * )
  115.     libgcc.a ( * )
  116.   }

  117.   .ARM.attributes 0 : { *(.ARM.attributes) }
  118. }
复制代码





无标题.png
收藏 评论2 发布时间:2023-12-4 16:27

举报

2个回答
STMCU-管管 回答时间:2023-12-5 14:13:27
使用函数属性(attribute):在函数定义时,可以使用__attribute__((section("RAM_SECTION")))将该函数放置在RAM的特定段中。例如:
  1. void __attribute__((section("RAM_SECTION"))) my_function(void) {
  2.   // 函数体
  3. }
复制代码
在这个例子中,my_function函数将被放置在名为"RAM_SECTION"的RAM段中。
huahuahnu 回答时间:2023-12-13 16:16:35

STMCU-管管 发表于 2023-12-5 14:13
使用函数属性(attribute):在函数定义时,可以使用<strong>attribute</strong>((section("RAM_SECTION")))将该函数放置 ...

谢谢管管,这是实现某个函数放到sram里,我已经解决了。

关于意法半导体
我们是谁
投资者关系
意法半导体可持续发展举措
创新和工艺
招聘信息
联系我们
联系ST分支机构
寻找销售人员和分销渠道
社区
媒体中心
活动与培训
隐私策略
隐私策略
Cookies管理
行使您的权利
关注我们
st-img 微信公众号
st-img 手机版