This digest is "Developing and debugging Skills" in the book "Embedded Linux driver template explaining and project practice".
The power of Linux is that there are many open source projects that can be used, and often many requirements can be quickly solved by looking for relevant open source modules. One of the key points to apply these open source modules to embedded is to cross-compile the open source project using the cross-compilation tool.
Depending on the situation, the download of open source projects in the organization there are many situations, where the various situations are categorized.
1. The downloaded open source package could not find makefile
For this open source package is usually organized in a configure way, the first step is to use the Configure in the package to generate the makefile file. For example, porting module-init-tools-3.2:
CC=ARM-LINUX-GCC./configure--prefix=/my_depmod--without-gun-ld--host=arm-linux
Specify the cross-compilation tool before./configure, specify the installation path to/my_depmod, and the following options are CPU-dependent. Each option can be viewed through the./configure–help.
The second step, after generating makefile, opens makefile to see:
prefix =/home/xlong.lin/workspace/sample/module-init-tools-3.2/my_depmode
CC = ARM-LINUX-GCC
The corresponding cross-compilation makefile has been generated automatically.
Step three, make to compile.
Fourth step, make install installation. The target file or library that is ultimately required under the specified installation path.
Fifth step, in order to verify that the resulting file is used to see if the obtained files are embedded in the CPU can be performed.
2. Some source package download after decompression has makefile, at the same time there are CC options, this situation is relatively simple, just modify the CC and other options.
For example, to transplant goahead onto a single board, unzip the makefile after the modification:
CC = ARM-LINUX-GCC
AR = Arm-linux-ar
Then make compiles.
If you have cross_compile in makefile, you can also modify the cross-compilation tool.
3. There is makefile but can not find CC or cross_compile case.
This situation is compiled with make cross= arm-linux-.
The above only summarizes the common situation of cross-compilation, regardless of what is compiled will need to use the file tool to confirm whether cross-compilation is successful, can be executed on the corresponding CPU. Being good at using open source software for cross-compiling porting can quickly implement many functions.