Development environment:
ubuntu12.04 (64-bit)
Eclipse (c + +) Luna
Note: This article is primarily about configuring eclipse with the compiler. For the section on remote debugging, see another post for the Eclipse Debug environment configuration.
My ARM-LINUX-GCC path is:/OPT/EMBEDSKY/4.3.3/BIN/ARM-LINUX-GCC ( what?) How to see the path of ARM-LINUX-GCC?? You can use which ARM-LINUX-GCC to view)
My Linux kernel path is:/opt/embedsky/linux-2.6.30.4
Step1:
Install Eclipse and the configuration of the JDK, the configuration of the cross-compiler, see Eclipse (C + +) Luna installation in this section.
Step2:
0, this step assumes that you have been able to open the Eclipse ARM-LINUX-GCC has been configured well.
1. To open eclipse, it is best to set the workspace to NFS so that your board can mount it. (See this NFS Mount method forNFS configuration Methods ).
After opening:
I have built a project. It's certainly not the first time you open it.
2. Create a new project: File->new->c project.
3, enter the project name.
Select Empty Project Cross GCC. Finish can, the specific configuration we will come back to configure.
Step3:
Let's configure it below.
0, mainly include: Cancel makefile automatic generation, configuration compiler ARM-LINUX-GCC, configuration path and symbols.
1. Remove Eclipse Auto-generated makefile: Remove the makefile automatically. Ok
3. Configure the compilation environment:
In the left-hand project bar, right-click the project name, select Properties, and in c/c++build-->setting, change the command in toolsetting to ARM-LINUX-GCC, ARM-LINUX-GCC and Arm-linux-as altogether changed these three.
4. Configure the path and symbols:
Select Gun C and click on the right side add add ARM-LINUX-GCC some header files:
Mine is:
/opt/embedsky/4.3.3/lib/gcc/arm-none-linux-gnueabi/4.3.3/include
/opt/embedsky/4.3.3/lib/gcc/arm-none-linux-gnueabi/4.3.3/include-fixed
/opt/embedsky/4.3.3/arm-none-linux-gnueabi/include
/opt/embedsky/4.3.3/arm-none-linux-gnueabi/libc/usr/include
When adding, don't forget to choose (tick): Add to all configurations.
We save the following configuration: Click on the export setting below. Format is an XML file, name casually, location casually, it is a very casual file haha.
Configuration is not over, this configuration is obviously not enough, we simply configured in the XML file.
5. Open the XML file you saved and we'll edit him. Use Gedit to open the line.
In the first
<language name= "C Source File" >
</language>
The path (include path) between the header files that are added to the kernel tree. Mine is:
<includepath>/opt/EmbedSky/linux-2.6.30.4/include</includepath>
<includepath>/opt/EmbedSky/linux-2.6.30.4/arch/arm/include</includepath>
<includepath>/opt/EmbedSky/linux-2.6.30.4/arch/arm/plat-s3c24xx/include</includepath>
Note the format. For more information, please learn XML. So the kernel tree path problem is solved, here I would like to remind you that your kernel compiled? Not compiled is not possible, when compiling the driver will prompt a file to kill can not find, hurriedly make it again!
6, find autoconf.h We need the macro definition inside, put these macros in symbols inside. Specific practices:
My autoconf.h file is under the/opt/embedsky/linux-2.6.30.4/include/linux directory. If our version is different, please grep yourself.
Go to this directory, and then execute the command:
cat autoconf.h |grep define |awk ' {print ' <macro><name> ' $ $ ' </name><value> ' $ 3 "</value></macro>"} ' > Symbol.xml
The purpose of this command is to store the macros in the autoconf.h file in the Symbol.xml file. not successful?? It's impossible, try Sudo.
Open this Symbol.xml file and copy all the text from the file into the configuration file we just made from eclipse (also the XML file). Paste to the location is:
A second
<language name= "C Source File" >
</language>
In the middle.
and manually add a <language name= "C Source File" > below:
<macro><name>__KERNEL__</name><value>1</value></macro>
Preview it:
STEP5:
OK, the configuration file is finally finished, save it. We open the Eclipse's gun C configuration interface, click the Import Setting button, the XML file in. It would be nice to import this configuration file directly when we build the project again.
The Linux driver Development IDE is built to do this. Writing a tutorial is not easy, reproduced please mark the source. Http://blog.csdn.net/tianzhihen_wq
A simple experiment, please. Import a. c file and a makefile
Give you an example:
#include <linux/init.h> #include <linux/module.h> module_license ("Dual BSD/GPL"); static int hello_init (void) { printk (kern_alert "Hello, world\n"); return 0; } static void Hello_exit (void) { printk (kern_alert "Goodbye, cruel world\n");} Module_init (hello_init); Module_exit (Hello_exit);
Arch=arm cross_compile=arm-linux- obj-m: = hello.o kdir: =/opt/embedsky/linux-2.6.30.4 PWD: =$ (Shell pwd) All: $ (make)-C $ (kdir) m=$ (PWD) modules Clean : $ (make)-C $ (kdir) m=$ (pwd) clean
Makefile needs to be selected based on your Linux kernel location. Also, since we are using our own makefile, the eclipse is compiled by default from the debug directory under the project directory, which is available from Eclipse's
PWD path Selection,
A lot of configuration, I believe after 5 days to let me start from the beginning to configure the time must have forgotten ... So turn a copy of my blog, reprint please mark the source. Http://blog.csdn.net/tianzhihen_wq
This is all configured, build it, and see if there is a. ko file in the debug directory. I wish you success!.
Configuring the Eclipse Linux Embedded Integrated Development Environment (compilation section) details