world leader in high performance signal processing
Trace: » basic-build

Basic Driver Configure and Build

The driver code is complete. The driver now needs to be added into the kernel source and the kernel build system modified to include the new driver.

The procedure used is as follows:

  • Create a new driver directory
  • Add the source to the new directory
  • Create a Makefile in the new directory
  • Extend the root Makefile to include the new subdir
  • Test a basic build
  • Add a configuration option in the old Kconfig file
  • Create a new Kconfig file
  • Test again
  • Test download to the target

Create a New Driver Directory

The new driver will be created in a test directory.

   mkdir -p linux-2.6.x/drivers/char/test

Copy the source to the New Directory

The new driver source is copied to the test directory.


Create a Makefile in the New Directory

The new driver Makefile will be created in the drivers/char/test directory.

   # basic Makefile                             
   # place this in linux-2.6.x/drivers/char/test
   # bypass the config system for now
   CONFIG_SCMD_DRIVER = y                       
   # add the driver 
   obj-$(CONFIG_SCMD_DRIVER) += simple_driver.o 

Extend the Makefile in the Root Drivers/Char Directory

The Makefile in the drivers/char directory is modified to add a reference to the new test directory.

 #  modify linux-2.6.x/drivers/char/Makefile       
 #  add the test sub directory note the trailing / 
 obj-$(CONFIG_BLACKFIN_RTC) += blackfin_rtc.o      
 obj-$(CONFIG_BLACKFIN_DPMC) += blackfin_dpmc.o    
 obj-$(CONFIG_HANGCHECK_TIMER) += hangcheck-timer.o
 # dummy config statement to be removed later      
 CONFIG_DRIVER_TEST = y                            
 # trigger the inclusion of the test directory     
 obj-$(CONFIG_DRIVER_TEST) += test/                

Test the process so far

Build the kernel and the build information of the new driver should show up in the Makefile output.

 cd linux-2.6.x/
 make > make.out
 grep simple_driver make.out

Add the basic Config options

Edit the drivers/char/Kconfig file to enable the new directory to be selected by make menuconfig.

Remove the statements that bypassed the config system

  Comment out                              
    CONFIG_DRIVER_TEST = y                   
    in linux-2.6.x/drivers/char/Makefile     
  Comment out                              
    CONFIG_SCMD_DRIVER = y                   
    in linux-2.6.x/drivers/char/test/Makefile

Add the new Config options

  Add to
config DRIVER_TEST                           
     tristate "Driver Test"                      
          Some Test Drivers     
source "drivers/char/test/Kconfig"           

Do this just before the last endmenu statement in the file

 Create a new config file in the test directory                       

Put the following in the new file

# Test Driver configuration                  
config SCMD_DRIVER                           
       tristate "Basic Test Driver"          
       depends on DRIVER_TEST                
         A basic demo driver                 

Now run make menuconfig and attempt to find and select the new driver.

Run make to include the driver in the kernel build.

cd linux-2.6.x/