如何运行RAM code ARM架构 [英] How to run code from RAM on ARM architecture

查看:292
本文介绍了如何运行RAM code ARM架构的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我编程了ARM Cortex-R4和我有我想从TCRAM执行它们,只是为了看看在性能上的提高是不够好几个二进制文件。

I am programming an ARM Cortex-R4 and I have a few binary files that I'd like to execute them from TCRAM, just to see if the increase in performance is good enough.

我知道我不得不写一个函数的二进制文件复制到RAM(可与链接器脚本来完成,并知道二进制文件的大小)。但是,如何将它们运行?

I know I'd have to write a function to copy the binaries to the RAM (which can be accomplished with the linker script, and knowing the size of the binaries). But how would they run?

想象一下:第一个二进制文件func1的(),FUNC2(),FUNC3()和FUNC4()。我想复制整个模块TCRAM,我怎么会调用一个函数呢?我不得不使用一个函数指针,特异功能?如果什么FUNC4(),调用了func2()和FUNC3()?如果我没有记错的话,他们会指向一块位于闪光code的。这是否意味着我必须重新编写这些funcs中?完全使用函数指针?有人告诉我,只是链接脚本,就足以做到这一切,我不用担心什么,但我还是不明白它是如何工作。

Imagine this: The first binary has func1(), func2(), func3() and func4(). I'd copy the entire module to TCRAM and how would I call a function there? I'd have to use a function pointer to that specific function? And what if func4(), calls func2() and func3()? If I'm not mistaken they'd point to the piece of code located in the flash. Does that mean I'd have to re write those funcs? Use entirely function pointers? I've been told that just the linker script is enough to do all of this and I needn't worry about anything, but I still don't understand how it works.

推荐答案

您有两种选择。


  1. 复制他们为你建议,编译 PC相对

  2. 使用一个连接文件具有不同的负载/运行地址。

如果例程不使用任何的绝对地址:一种简单的复制才会工作。如果它可能罚款他们使用绝对地址我猜你会在标准RAM离开副本。然而,这可能不会得到充分受益的医药

A simple copy will only work if the routines do not use any absolute addresses. It maybe fine if they do use the absolute address as I guess you are going to leave a copy in standard RAM. However, this may not get the full benefit of the TCM.

通过链接脚本,您可以指定不同的 LOAD 运行位置。

With a linker script, you can specify a different LOAD and RUN locations.

sections {
 .text { *(.text); } >FLASH
 .tcm {
       *(.tcm);
  } >TCM_MEM AT>FLASH
  .data { *(.data); } > RAM
  .bss : NOLOAD { *(.bss); } > RAM
}

请注意特别是 AT> FLASH

参见:<一href=\"http://stackoverflow.com/questions/14453996/gnu-linker-map-file-giving-unexpected-load-addresses\">gnu链接器映射文件... 和许多更多的计算器的。该牛羚LD手动信息LMA 部分( LOAD 地址)。你的 LMA 闪存的,但 VMA 生成地址)将医药。上面还手工链接显示如何复制。在 RAM FLASH TCM_MEM 与LD定义 MEMORY 的信息,根据不同的地址是您的主板。所有这一切都将在地图文件记录在案。一定要生成一个地图文件,并检查地址,仔细检查你的 LD 脚本。

See also: gnu linker map file... and many more on stackoverflow. The Gnu Ld manual has information on LMA sections (LOAD address). Your LMA would be flash, but the VMA (RUN address) would be TCM. The manual link above also shows how to copy. The RAM, FLASH, and TCM_MEM are defined with ld MEMORY information, depending on the addresses are for your board. All of this will be documented in a MAP file. Be sure to generate a MAP file and examine the addresses to double check your ld script.

第二的情况下也需要一个副本(在启动时或至少在第一个医药函数使用前)。然而,编译器可以使用绝对地址,他们将在医药内存。也是主要的内存中的任何功能,可以直接调用医药功能。对于第一种情况,你必须使用函数指针调用医药 code。如果你希望全球变量被放置在该存储器中,可以使用属性,把它们放在不同的部分,并使用的 GNU LD 的适当地放置它们。我觉得这是 ITCM DTCM ?因此,也许这并不适用于你,或者你需要两部分。

The 2nd case also requires a copy (at start-up or at least before the first TCM function use). However, the compiler can use absolute addresses and they will be in the TCM memory. Also any function within the main DRAM can call the TCM function directly. With the first case, you must use function pointers to call the TCM code. If you wish global variables to be placed in this memory, you can use attributes to put them in different sections and use gnu ld to place them appropriately. I think there is ITCM and DTCM? So maybe this doesn't apply for you, or you need two sections.

链接器脚本更通用的,将工作最好的,如果你把在医药复杂的功能。只是用 -fpic 等,并复制可能得到的东西很快的工作,特别是如果你只有一个纯粹功能。

The linker script is more generic and will work best if you put complicated functionality in the TCM. Just using -fpic, etc and copying may get things working quickly, especially if you only have a single pure function.

这篇关于如何运行RAM code ARM架构的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆