Hello World Driver Module _ load the driver to the mini210s Development Board

Source: Internet
Author: User

Continue to drive learning based on the progress of the previous article .......

Main references: http://blog.csdn.net/dg1683wen/article/details/6861044

First, build the kernel source code tree. I am using the friendly arm comes with Linux source code: linux-2.6.35.7-20120912.tgz

First copy the kernel source code linux-2.6.35.7-20120912.tgz to the Ubuntu system directory/home/liuhui8989/linuxshare

Unzip: Tar zxvf linux-2.6.35.7-20120912.tgz to get the linux-2.6.35.7 folder.

Start to build the source tree, according to the friendly arm Manual know, first in the linux-2.6.35.7 directory to execute

CP mini210_linux_defconfig. config

Then, execute make or make zimage to build the kernel source code tree.


Start writing the hello World Driver. Here, the driver is loaded to the Development Board. the difference with the Ubuntu system is that the cross compiler is specified, and the driver must be specified as arm-Linux-GCC.

Create the hello_mini210s folder under/home/liuhui8989/upload_minicom/example, and create two new files: Hello. C and makefile.

// Hello. c

# Include <Linux/init. h>
# Include <Linux/module. h>
Module_license ("liuhui8989 BSD/GPL ");
Int init_moduless (void)
{
Printk ("<0>" Hello. World-this is the kernel speaking \ n ");
Return 0;
}
Void cleanup_moduless (void)
{
Printk (kern_alert "Short is the life of a kernel \ n ");
}

Module_init (init_moduless );
Module_exit (cleanup_moduless );


# Makefile

OBJ-M: = Hello. o
Cc = arm-Linux-gcc
Kerneldir: =/home/liuhui8989/linuxshare/linux-2.6.35.7
PWD: = $ (shell PWD)
Modules:
[Here is the tab key] $ (make)-C $ (kerneldir) M = $ (PWD) Modules
Modules_install:
[Here is the tab key] $ (make)-C $ (kerneldir) M = $ (PWD) modules_install

After the two files are built, make directly to get the desired driver.


Write the zimage file generated by the source code tree built above to the Development Board, enter the system, connect the Development Board, and enter the minicom interface.

Download the hello. Ko file generated by make in the/home/liuhui8989/upload_minicom/example/hello_mini210s directory to the Development Board.

Load the driver:

[Root @ friendlyarm/] # insmod hello. Ko
[2, 1290.351906] Hello. World-this is the kernel speaking

Printed information indicates that the driver has been loaded successfully.

You can also view

[Root @ friendlyarm/] # lsmod
Hello 693 0-live 0xbf0a7000 (P)
Rtl8192cu 489899 0-live 0xbf01e000
Tvp5150_tiny210 14147 0-live 0xbf015000
Snd_soc_mini210_wm8960 2936 0-live 0xbf00f000
Snd_soc_wm8960 15882 1 snd_soc_mini210_wm8960, live 0xbf006000

Also found hello

Uninstall DRIVER:

[Root @ friendlyarm/] # rmmod hello
[2, 2679.617061] short is the life of a kernel
Rmmod: module 'hello' not found


So far, simple-driven development is complete .....


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.