Re: [uClinux-dev] Linux Device Drivers

From: Kirsch Martin (Martin.Kirsch@mhm6.siemens.de)
Date: Mon May 07 2001 - 02:28:40 EDT


Here's some little Docu that I wrote for the uCsimm:


This is a small documentation for writing a char device-driver:

A good book for understanding, how device drivers work, is the following.
But be aware that uClinux differs a little bit:
http://www.oreilly.com "Linux Device Drivers" by Alessandro Rubini, ISBN:
1-56592-292-1.

I will start to work out, how you can implement the driver to the kernel.
First of all, you have to change the file
(uClinuxdir)/linux/arch/m68knommu/config.in as followed:

after:
mainmenu_option next_comment        
comment 'Character devices'         

you have to insert:
#Definition for FPGA by Martin Kirsch                                   
if [ "$CONFIG_UCSIMM" = "y" ]; then                                     
        bool 'FPGA-Driver' CONFIG_UCFPGA 
fi                                                                      
#Definition for FPGA END                                                

This will show the device in make menuconfig.

The driver has to be put in the  (uClinuxdir)/linux/drivers/char/FPGA.c
(listed at the end)
And to have the driver to be included correctly change the Makefile in the
same directory as followed:
After:
ifdef CONSOLE_BAUD_RATE                                  
CFLAGS += -DCONSOLE_BAUD_RATE=$(CONSOLE_BAUD_RATE)       
endif                                                    
                                                         
you have to insert:
# Definition by Martin Kirsch for Communication with FPGA
ifeq ($(CONFIG_UCFPGA),y)                                
        L_OBJS += FPGA.o                                 
endif                                                    
# Definition by Martin Kirsch END                        

To have the driver to be included to the kernel, you must register it to the
starting routine in mem.c
in the following routine you have to insert after:
int chr_dev_init(void)

{

        if (register_chrdev(MEM_MAJOR,"mem",&memory_fops))

                printk("unable to get major %d for memory devs\n",
MEM_MAJOR);
        rand_initialize();

        tty_init();


the following:
#ifdef CONFIG_UCFPGA

        fpga_init();

#endif


the following include file is needed in
(uClinuxdir)/linux/include/linux/fpga.h with the code listed below:
/*FPGAUni*/                 
extern int fpga_init(void); 

After these steps the driver will be compiled and linked to the kernel and
be started at the boot-startup.
To user the device you must register it to the system and therefor you'll
need the mknod command:
cp (uClinuxdir)/testenv/src/bin/mknod
(uClinuxdir)/testenv/romdisk/sbin/mknod

Then you can start making the kernel and the bins and flash them to the rom.
After a reboot  you can create the device by the following command or type
it in the /etc/rc -batch:
/sbin/mknod /var/fpga c 50 0

The driver will be visible in /proc/modules /proc/devices and the interrupt
handler in /proc/interrupts.

I hope I helped you.

Martin Kirsch
mailto:Martin.Kirsch@mhm6.siemens.de



Virus checked  by Siemens AG I&S IS GFA Mannheim


This message resent by the uclinux-dev@uclinux.org list server http://www.uClinux.org/

This archive was generated by hypermail 2.1.4 : Thu Sep 19 2002 - 13:19:42 EDT