The GCC issue of Linux driver development

Source: Internet
Author: User

Recently learning to drive development, progress to the character device-driven development phase.

First of all, the first reading of a learning-driven step of the post is recorded as follows:

1. Learn to write simple makefile

2. Compile an application that can run with makefile

3. Learn to write driven makefile

4. Write a simple char drive, makefile compile through, can Insmod, Lsmod, Rmmod. Print Hello World in the init function of the driver, Insmod should be able to see the output through DMESG.

5. Write a complete driver, plus read, write, IOCTL, polling and other functions of the drive implementation. The implementation of transferring the structure from user space to kernel space is done in the IOCTL.

6. Write a block drive, plus a variety of functions such as read,write,ioctl,poll implementation.

7. Simple learning under memory management, this is the most difficult, understand the various memory alloc function implementation details. This is the basic skill of Linux development.

8. Learn the application of lock mechanism, this is not the most difficult but the most error-prone, involving a lot of synchronization and concurrency problems.

9. Look at the driver code that is actually applied in the kernel. You will find the most basic you already know, the big frame is the same, nothing but the implementation of read, write, IOCTL and other functions, but it contains a lot of small implementation details are not known before. It's time to consider a lot of other issues rather than just the implementation of basic functions.

Recommended you see 2.6.20 in integrated of a driver KVM, remember is under the driver/lguest, very fun, is Linux under the virtual machine driver, code is not long, but powerful. Capable of writing an operating system on its own. Disk mirroring is loaded into the virtual machine as required, and the client can have its own 4G virtual address space.

10. Read the driver welcome you into the Linux kernel learning.

From yesterday began to write the device driver, after the completion of the compilation, there are various problems, the original thought is the code of the grammar problem, has been unable to find a solution, today re-write a piece of code, the structure of the compile error and yesterday, so I suspect the compiler is the reason for GCC, Maybe the GCC version is too low (the version I'm using is GCC4.4.7). After generating the. ko file, the. ko file is loaded with an error:-1 unknow symbol in module, because some content is undefined in the original earlier version of GCC.

The GCC solution for another park friend is now recorded as follows: http://www.cnblogs.com/zhuyp1015/p/3533613.html

--------------------------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------

GCC 4.8.1 is the first fully supported C++11 compiler, Windows can be installed MinGW version of the SourceForge on the download, installation is more convenient. Installing on Linux requires installing some dependent libraries first. In Ubuntu12.04 LTS is installed by default gcc4.6.3, in fact, this version also supports some c++11 features, you can add "-std=c++0x" compilation option to use these features, but the support for multi-line libraries is poor, GCC 4.8.1 is installed through the PPA , so you need to install PPA repository. Here's a look at the installation steps:

Install dependencies First:

sudo apt-get install Libgmp-dev
sudo apt-get install LIBMPFR4 Libmpfr-dev
sudo apt-get install Libmpc-dev LIBMPC2
sudo apt-get install Libtool
sudo apt-get install M4
sudo apt-get install Bison
sudo apt-get install Flex
sudo apt-get install autoconf

Next go to the main steps to install the gcc4.8.1:

sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update

sudo apt-get install gcc-4.8
sudo apt-get install g++-4.8
sudo apt-get install Gcc-4.8-multilib
sudo apt-get install G++-4.8-multilib
sudo apt-get install Gcc-4.8-doc
sudo update-alternatives--install/usr/bin/gcc gcc/usr/bin/gcc-4.8 20
sudo update-alternatives--install/usr/bin/g++ g++/usr/bin/g++-4.8 20
sudo update-alternatives--config gcc
sudo update-alternatives--config g++

sudo apt-get update
sudo apt-get upgrade-y
sudo apt-get dist-upgrade

After that, you can view the current GCC version by using the GCC-V command:

Network conditions are not good, the installation process is slow, you can use NetEase or Sohu source to improve the installation speed.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.