arm-linux-gcc 交叉工具链可以直接在linux上编译生成STM32(Cotex-M3内核)的程序吗?跪求高手现身。
比如编译2440的工具链,也可以同样拿来编译6410,stm32,等ARM架构的芯片,而不需要做任何设置?如果需要该怎么配置呢?...
比如编译2440的工具链,也可以同样拿来编译6410,stm32,等ARM架构的芯片,而不需要做任何设置?如果需要该怎么配置呢?
展开
展开全部
看你的编译器,但是 M3 这个内核比较新,在旧版本的 gcc 上会没有针对这个 CPU 的支持。
M3 好像有部分指令不支持,如果你的编译器不支持,编译出来的程序会不能正常运行。
这东西不是随便找个几百年前的东西,就能支持新硬件的。
你看看你的 gcc 到底支持什么 CPU 吧……
gcc-4.8.1 反正支持如下 arm CPU 和核心。
-mcpu=name
This specifies the name of the target ARM processor. GCC uses this name to determine what kind of instructions it can emit when generating assembly code. Permissible names are: ‘arm2’, ‘arm250’, ‘arm3’, ‘arm6’, ‘arm60’, ‘arm600’, ‘arm610’, ‘arm620’, ‘arm7’, ‘arm7m’, ‘arm7d’, ‘arm7dm’, ‘arm7di’, ‘arm7dmi’, ‘arm70’, ‘arm700’, ‘arm700i’, ‘arm710’, ‘arm710c’, ‘arm7100’, ‘arm720’, ‘arm7500’, ‘arm7500fe’, ‘arm7tdmi’, ‘arm7tdmi-s’, ‘arm710t’, ‘arm720t’, ‘arm740t’, ‘strongarm’, ‘strongarm110’, ‘strongarm1100’, ‘strongarm1110’, ‘arm8’, ‘arm810’, ‘arm9’, ‘arm9e’, ‘arm920’, ‘arm920t’, ‘arm922t’, ‘arm946e-s’, ‘arm966e-s’, ‘arm968e-s’, ‘arm926ej-s’, ‘arm940t’, ‘arm9tdmi’, ‘arm10tdmi’, ‘arm1020t’, ‘arm1026ej-s’, ‘arm10e’, ‘arm1020e’, ‘arm1022e’, ‘arm1136j-s’, ‘arm1136jf-s’, ‘mpcore’, ‘mpcorenovfp’, ‘arm1156t2-s’, ‘arm1156t2f-s’, ‘arm1176jz-s’, ‘arm1176jzf-s’, ‘cortex-a5’, ‘cortex-a7’, ‘cortex-a8’, ‘cortex-a9’, ‘cortex-a15’, ‘cortex-r4’, ‘cortex-r4f’, ‘cortex-r5’, ‘cortex-m4’, ‘cortex-m3’, ‘cortex-m1’, ‘cortex-m0’, ‘cortex-m0plus’, ‘marvell-pj4’, ‘xscale’, ‘iwmmxt’, ‘iwmmxt2’, ‘ep9312’, ‘fa526’, ‘fa626’, ‘fa606te’, ‘fa626te’, ‘fmp626’, ‘fa726te’.
-mcpu=generic-arch is also permissible, and is equivalent to -march=arch -mtune=generic-arch. See -mtune for more information.
-mcpu=native causes the compiler to auto-detect the CPU of the build computer. At present, this feature is only supported on Linux, and not all architectures are recognized. If the auto-detect is unsuccessful the option has no effect.
M3 好像有部分指令不支持,如果你的编译器不支持,编译出来的程序会不能正常运行。
这东西不是随便找个几百年前的东西,就能支持新硬件的。
你看看你的 gcc 到底支持什么 CPU 吧……
gcc-4.8.1 反正支持如下 arm CPU 和核心。
-mcpu=name
This specifies the name of the target ARM processor. GCC uses this name to determine what kind of instructions it can emit when generating assembly code. Permissible names are: ‘arm2’, ‘arm250’, ‘arm3’, ‘arm6’, ‘arm60’, ‘arm600’, ‘arm610’, ‘arm620’, ‘arm7’, ‘arm7m’, ‘arm7d’, ‘arm7dm’, ‘arm7di’, ‘arm7dmi’, ‘arm70’, ‘arm700’, ‘arm700i’, ‘arm710’, ‘arm710c’, ‘arm7100’, ‘arm720’, ‘arm7500’, ‘arm7500fe’, ‘arm7tdmi’, ‘arm7tdmi-s’, ‘arm710t’, ‘arm720t’, ‘arm740t’, ‘strongarm’, ‘strongarm110’, ‘strongarm1100’, ‘strongarm1110’, ‘arm8’, ‘arm810’, ‘arm9’, ‘arm9e’, ‘arm920’, ‘arm920t’, ‘arm922t’, ‘arm946e-s’, ‘arm966e-s’, ‘arm968e-s’, ‘arm926ej-s’, ‘arm940t’, ‘arm9tdmi’, ‘arm10tdmi’, ‘arm1020t’, ‘arm1026ej-s’, ‘arm10e’, ‘arm1020e’, ‘arm1022e’, ‘arm1136j-s’, ‘arm1136jf-s’, ‘mpcore’, ‘mpcorenovfp’, ‘arm1156t2-s’, ‘arm1156t2f-s’, ‘arm1176jz-s’, ‘arm1176jzf-s’, ‘cortex-a5’, ‘cortex-a7’, ‘cortex-a8’, ‘cortex-a9’, ‘cortex-a15’, ‘cortex-r4’, ‘cortex-r4f’, ‘cortex-r5’, ‘cortex-m4’, ‘cortex-m3’, ‘cortex-m1’, ‘cortex-m0’, ‘cortex-m0plus’, ‘marvell-pj4’, ‘xscale’, ‘iwmmxt’, ‘iwmmxt2’, ‘ep9312’, ‘fa526’, ‘fa626’, ‘fa606te’, ‘fa626te’, ‘fmp626’, ‘fa726te’.
-mcpu=generic-arch is also permissible, and is equivalent to -march=arch -mtune=generic-arch. See -mtune for more information.
-mcpu=native causes the compiler to auto-detect the CPU of the build computer. At present, this feature is only supported on Linux, and not all architectures are recognized. If the auto-detect is unsuccessful the option has no effect.
追问
哈哈,太感谢您了,大神。但我还有几个小问题:
第一、可否告诉我这些信息‘arm2’, ‘arm250’, ‘arm3’您是怎样查看到的?
第二、也就是说可以使用同一个编译器去编译2440,和STM32了?编译STM32的话是不是还得加上-mcpu=cortex-m3 ?
第三、如果编译when generating assembly code好像是只有汇编代码才要加,C语言就不用了?
追答
1、http://gcc.gnu.org/onlinedocs/ 具体怎么让 GCC 直接显示自己支持的 CPU 不清楚。
2、理论上一个 arm GCC 可以支持全部的 arm CPU 核心的程序编译,但问题在于,GCC 自己还会提供几个函数库,这些函数库也必须都是针对性的。不然你的程序在目标设备上还是不能运行。
3、汇编是最终的目标。C 语言是高级语言,而计算机运行的是机器码,机器码和汇编是对应的。所以,一般的编译优化,都是优化到汇编上去,汇编会被对应到机器码上。
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询