- 3.3.2.2.1. crosstool-ng中的配置参数:Architecture level, Emit assembly for CPU, Tune for CPU
- 3.3.2.2.2. crosstool-ng中的配置参数:MMU
- 3.3.2.2.3. crosstool-ng中的配置参数:大小端Endianness
- 3.3.2.2.4. crosstool-ng中的配置参数:浮点处理单元FPU
- 3.3.2.2.5. crosstool-ng中的配置参数:CFLAGS参数
- 3.3.2.2.6. crosstool-ng中的配置参数:Linux内核版本
- 3.3.2.2.7. crosstool-ng中的配置参数:binutils版本
- 3.3.2.2.8. crosstool-ng中的配置参数:gcc版本
- 3.3.2.2.9. crosstool-ng中的配置参数:C库的选择
- 3.3.2.2.10. crosstool-ng中的配置参数:线程模型的选择
crosstool-ng中的Architecture level, Emit assembly for CPU, Tune for CPU,分别对应的是gcc中的-march=xxx, -mcpu=xxx, -mtune=xxx
而这几个参数,是相对最最核心的,最最重要的配置了。
例 3.3. 举例说明Architecture level, Emit assembly for CPU, Tune for CPU如何去配置
比如,我之前的折腾:
中的:
以及后来的折腾:
【整理】crosstool-ng中的Architecture level,Emit assembly for CPU,Tune for CPU对于TQ2440的S3C2440的ARM920T填写何值
而搞清楚了自己的xscale的CPU所对应的配置是:
- Architecture level=CT_ARCH_ARCH=-march=armv5te
- Emit assembly for CPU=CT_ARCH_CPU=-mcpu=xscale
- Tune for CPU=CT_ARCH_TUNE=-mtune=strongarm110
以及,后来的折腾:
【记录】Cygwin下为arm920t配置crosstool-ng
中的:
【整理】crosstool-ng中的Architecture level,Emit assembly for CPU,Tune for CPU对于TQ2440的S3C2440的ARM920T填写何值
去搞懂了,S3C2440的对应的配置是:
- Architecture level=CT_ARCH_ARCH=-march=armv4t
- Emit assembly for CPU=CT_ARCH_CPU=-mcpu=arm9tdmi
- Tune for CPU=CT_ARCH_TUNE=-mtune=arm920t
crosstool-ng中,对于MMU的配置,此处如下:
Target options
[*] Use the MMU
Use the MMU的help的说明为:
┌──────────────────────────────── Use the MMU ─────────────────────────────────┐
│ CT_ARCH_USE_MMU: │
│ │
│ If your architecture has an MMU and you want to use it, │
│ say 'Y' here. │
│ │
│ OTOH, if you don't want to use the MMU, or your arch │
│ lacks an MMU, say 'N' here. │
│ │
│ Note that some architectures (eg. ARM) has variants that │
│ lacks an MMU (eg. ARM Cortex-M3), while other variants │
│ have one (eg. ARM Cortex-A8). │
│ │
│ Symbol: ARCH_USE_MMU [=y] │
│ Type : boolean │
│ Prompt: Use the MMU │
│ Defined at config/target.in:87 │
│ Depends on: ARCH_SUPPORTS_BOTH_MMU [=y] │
│ Location: │
│ -> Target options │
│ Selected by: ARCH_alpha [=n] && GEN_CHOICE_ARCH [=y] && \ │
│ ARCH_alpha_AVAILABLE [=y] || ARCH_s390 [=n] && GEN_CHOICE_ARCH [=y] && \ │
│ ARCH_s390_AVAILABLE [=y] || ARCH_powerpc [=n] && GEN_CHOICE_ARCH [=y] && \ │
│ ARCH_powerpc_AVAILABLE [=y] || ARCH_sparc [=n] && GEN_CHOICE_ARCH [=y] && \ │
│ ARCH_sparc_AVAILABLE [=y] || ARCH_mips [=n] && GEN_CHOICE_ARCH [=y] && \ │
│ ARCH_mips_AVAILABLE [=y] || ARCH_avr32 [=n] && GEN_CHOICE_ARCH [=y] && \ │
│ ARCH_avr32_AVAILABLE [=y] || ARCH_sh [=n] && GEN_CHOICE_ARCH [=y] && \ │
│ ARCH_sh_AVAILABLE [=y] || ARCH_x86 [=n] && GEN_CHOICE_ARCH [=y] && \ │
│ ARCH_x86_AVAILABLE [=y] │
此处,已经选上了MMU,是因为之前对于CPU部分,是在:
设置为xscale的,而xscale的CPU,全都是有MMU的。
所以,此处,crosstool-ng(根据内部已经实现好的依赖关系),已经自动帮你选上MMU了。
需要了解的是,现在多数的CPU,都是已经支持MMU的。
只有之前的很老的CPU,有的才不支持MMU。
crosstool-ng中,对于MMU的配置,此处如下:
Target options
Endianness: (Little endian) --->
Endianness的help的说明为:
┌──────────────────────────────── Endianness: ─────────────────────────────────┐
│ There is no help available for this option. │
│ Prompt: Endianness: │
│ Defined at config/target.in:112 │
│ Depends on: ARCH_SUPPORTS_BOTH_ENDIAN [=y] │
│ Location: │
│ -> Target options │
│ Selected by: ARCH_SUPPORTS_BOTH_ENDIAN [=y] && m │
此处,将Endianness设置为小端(Little endian)
一般,多数情况下,都是小端。
不论设置大端(Big Endian)还是小端(Little endian)
都要确保本身CPU是支持此种模式的。
比如,之前,也是经过确认,才知道,xscale,本身是,既支持大端,也支持小端的:
所以,此处设置小端,也才是确保,CPU本身是支持的。
关于大端和小端的区别的,不熟悉的可参考:
crosstool-ng中的配置中,同样会涉及到,当前的CPU,是否有FPU,浮点处理单元。
一般来说,多数CPU都是没有的。
比如,我之前的折腾:
【记录】Cygwin下为arm920t配置crosstool-ng
就发现,当然的S3C2440dearm920t的话,是不支持FPU的。
所以,此处,就设置为对应的,软件浮点了:
Target options
() Use specific FPU
Floating point: (softfp (FPU)) --->
Use specific FPU的help的说明为:
┌────────────────────────────── Use specific FPU ──────────────────────────────┐
│ CT_ARCH_FPU: │
│ │
│ On some targets (eg. ARM), you can specify the kind of FPU to emit │
│ code for. │
│ │
│ This is the configuration flag --with-fpu=XXX, and the runtime flag │
│ -mfpu=XXX. │
│ │
│ See below wether to actually emit FP opcodes, or to emulate them. │
│ │
│ Pick a value from the gcc manual for your choosen gcc version and your │
│ target CPU. │
│ │
│ Leave blank if you don't know, or if your target architecture does not │
│ offer this option. │
│ │
│ Symbol: ARCH_FPU [=] │
│ Type : string │
│ Prompt: Use specific FPU │
│ Defined at config/target.in:274 │
│ Depends on: ARCH_SUPPORTS_WITH_FPU [=y] │
│ Location: │
│ -> Target options │
Floating point的help的说明为:
┌────────────────────────────── Floating point: ───────────────────────────────┐
│ There is no help available for this option. │
│ Prompt: Floating point: │
│ Defined at config/target.in:294 │
│ Depends on: ARCH_SUPPORTS_WITH_FLOAT [=y] │
│ Location: │
│ -> Target options │
│ Selected by: ARCH_SUPPORTS_WITH_FLOAT [=y] && m │
可见,此处的FPU,就是对应着gcc中的参数:-mfpu=XXX
对应的,如果是你:
中所举例的Cortex-A9 with NEON的CPU的话,那么此处的设置就是:
Target options
(neon) Use specific FPU
Floating point: (hardware (FPU)) --->
了,而此时,你也可以看到,配置选择中,又多了个,关于后缀hf的选项,你也可以选择该项:
Target options
[*] append 'hf' to the tuple (EXPERIMENTAL)
append 'hf' to the tuple的help的说明为:
┌───────────────── append 'hf' to the tuple (EXPERIMENTAL) ─────────────────┐
│ CT_ARCH_ARM_TUPLE_USE_EABIHF: │
│ │
│ Is you say 'y' here, then the tuple for the toolchain will end │
│ up with *eabihf, instead of the usual *eabi. │
│ │
│ *eabihf is used to denote that the toolchain *is* using the │
│ hard-float ABI, while *eabi is just an indication of using the │
│ soft-float ABI. │
│ │
│ Ie. all one can say is: *eabihf hard-float ABI │
│ │
│ Saying 'n' here does *not* impact the ability of the toolchain to │
│ generate hard-float instructions with the hard-float ABI. It is a │
│ purely cosmetic thing, used by distros to differentiate their │
│ hard-float-ABI-using ports from their soft-float-ABI-using ports. │
│ (eg. Debian Wheezy and above). │
│ │
│ This is an option, as not all versions of gcc/binutils do support │
│ such tuple, and fail to build with *eabihf. Stock gcc version up │
│ to, and including 4.7.2 have an issue or another with *eabihf. │
│ │
│ This option is here for the future. │
│ │
│ Say 'n', unless you are trying to fix gcc to properly recognise │
│ the *eabihf tuples. │
│ │
│ Symbol: ARCH_ARM_TUPLE_USE_EABIHF [=y] │
│ Type : boolean │
│ Prompt: append 'hf' to the tuple (EXPERIMENTAL) │
│ Defined at config/arch/arm.in.2:64 │
│ Depends on: ARCH_arm [=y] && ARCH_FLOAT_HW [=y] && ARCH_ARM_EABI [=y]\ │
│ && EXPERIMENTAL [=y] │
│ Location: │
│ -> Target options │
│ -> Use EABI (ARCH_ARM_EABI [=y]) │
crosstool-ng中,支持设置对应的CFLAGS参数,以传递给底层的gcc的。
经过之前的调查:
【整理】crosstool中Target CFLAGS参数的含义和如何设置
结论是:
一般设置为-O,即可。
Target options
(-O) Target CFLAGS
Target CFLAGS的help的说明为:
┌────────────────────────────── Target CFLAGS ──────────────────────────────┐
│ CT_TARGET_CFLAGS: │
│ │
│ Used to add specific options when compiling libraries of the toolchain, │
│ that will run on the target (eg. libc.so). │
│ │
│ Note that the options above for ARCH, ABI, CPU, TUNE and FPU will be │
│ automatically used. You don't need to specify them here. │
│ │
│ Leave blank if you don't know better. │
│ │
│ Symbol: TARGET_CFLAGS [=-O] │
│ Type : string │
│ Prompt: Target CFLAGS │
│ Defined at config/target.in:341 │
│ Location: │
│ -> Target options │
目前我的理解是:
对于你进行嵌入式开发时,所选择的对应的Linux版本,应该和此处交叉编译器配置的Linux内核版本要一致。
比如,我之前折腾:
【记录】重试使用最新版本1.18.0的crosstool-ng去配置和编译xscale的交叉编译器
时,去选择了,自定义版本的Linux内核:linux-2.6.19.1.tar.bz2
所以,此处,就先去把对应的,自己的linux-2.6.19.1.tar.bz2,放到对应的路径下:
Cygwin下面的:
/home/CLi/develop/crosstool-ng/src/linux-2.6.19.1.tar.bz2
而当前自己的HOME路径是:
/home/CLi
所以就可以去设置为:
Operating System
Linux kernel version (custom tarball or directory) --->
custom tarball or directory
(${HOME}/develop/crosstool-ng/src/linux-2.6.19.1.tar.bz2) Path to custom source, tarball or directory
Path to custom source, tarball or directory的help的说明为:
┌─────────────────────────── Path to custom source, tarball or directory ───────────────────────────┐
│ CT_KERNEL_LINUX_CUSTOM_LOCATION: │
│ │
│ Enter here the path to the tarball of your full kernel tree or │
│ kernel directory │
│ │
│ Symbol: KERNEL_LINUX_CUSTOM_LOCATION [=${HOME}/develop/crosstool-ng/src/linux-2.6.19.1.tar.bz2] │
│ Type : string │
│ Prompt: Path to custom source, tarball or directory │
│ Defined at config/kernel/linux.in:148 │
│ Depends on: <choice> && KERNEL_LINUX_CUSTOM [=y] │
│ Location: │
│ -> Operating System │
│ -> Linux kernel version (<choice> [=y]) │
│ -> custom tarball or directory (KERNEL_LINUX_CUSTOM [=y]) │
如此,之后编译的时候,就可以找到你自己设置的Linux内核,并解压,去加载对应的头文件等内容了。
binutils,是编译交叉编译器时,一个比较重要的组件。
对应的版本的选择,一般还是按照之前使用示例配置时,选择的为准。
如果后期编译出错,实在解决不了的时候,再考虑换个其他的版本试试。
我目前的配置,供参考:
Binary utilities
binutils version (2.22) --->
binutils version的help的说明为:
┌─────────────────────── binutils version ────────────────────────┐
│ There is no help available for this option. │
│ Prompt: binutils version │
│ Defined at config/binutils/binutils.in:5 │
│ Depends on: BINUTILS_binutils [=y] │
│ Location: │
│ -> Binary utilities │
│ Selected by: BINUTILS_binutils [=y] && m │
crosstool-ng中的gcc的版本选择,也是属于极其重要的参数。
此处我的gcc版本的选择,还是按照之前的逻辑,选用示例配置中的gcc的版本的,此处是4.6.0版本的:
并且,对应着,此处,如果没有特殊需求,则只是选择C++的,即可。
即,剩余那些语言:Fortran,Java,ADA,Objective-C,Objective-C++等,都无需选择。
我此处的配置如下,供参考:
C compiler
C compiler (gcc) --->
gcc version (4.6.0) --->
[*] C++
[ ] Fortran
[ ] Java
[ ] ADA (EXPERIMENTAL)
[ ] Objective-C (EXPERIMENTAL)
[ ] Objective-C++ (EXPERIMENTAL)
() Other languages (EXPERIMENTAL)
crosstool-ng中,关于C库的选择,也是个重要的问题。
常见的有三种C库:glibc,eglibc,uclibc
不了解的,可参考:【整理】uclibc,eglibc,glibc之间的区别和联系
一般选择glibc或者是eglibc。
我此处,选择的是glibc,对应的版本选择,也是使用之前示例配置中的2.9
配置如下:
C-library
C library (glibc) --->
glibc version (2.9) --->
线程模型主要分两种:linuxThreads和nptl
相关区别,可参考这个帖子:Linux 线程模型的比较:LinuxThreads 和 NPTL
现在多数都选择,默认的nptl
配置如下:
C-library
Threading implementation to use: (nptl) --->




![[注意]](https://www.crifan.com/files/res/docbook/images/note.png)
![[提示]](https://www.crifan.com/files/res/docbook/images/tip.png)

