[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [microblaze-uclinux] Getting Started with microblaze-uclinux-gcc



Hi Klaus and Mike,
Thanks for your thorough explanations and eagerness to help!
Unfortunately, my development tools are being shipped back to school
as my winter break is almost over.  As for now, I have a bit of
reading to do. ; )
I will keep you updated on my progress.
Thanks again,
Jose

On 1/5/07, Mike Thompson <mpthompson@xxxxxxxxx> wrote:
Jose,

I'm also new to working with Linux/uClinux kernel modules and been
stumbling my way through to getting something working the last week.  My
approach is to build my module parallel to the xgpio driver in the
uClinux build tree using it as a template for a functioning Xilinx
specific kernel module.  The steps I followed are below.

The xgpio module header lives at:

   uClinux-2.4.x/include/linux/xgpio.h

My xilinx module header lives at:

   uClinux-2.4.x/include/linux/xmotor.h

The xgpio module source lives in the directory:

   uClinux-2.4.x/drivers/char/xilinx_gpio

My xilinx module source lives in the directory:

   uClinux-2.4.x/drivers/char/xilinx_motor

I copied the Makefile and adapter.c file the xgpio module source into my
source directory and stripped the gpio hardware specific code from
adapter.c and renamed it xmotor.c.  Other changes included making my own
test IOCTL handlers ans such.  My header file xmotor.h was also edited
as needed and the module assigned a non-conflicting minor device number.
  I then made the minor changes in the Makefile in my source directory
to account for the name changes of the files it should compile.

Next, I edited the following Makefile in the directory above my source
directory:

   uClinux-2.4.x/drivers/char/Makefile

To add the following just before the GPIO section:

   # Support for Xilinx MOTOR driver
   mod-subdirs += xilinx_motor
   subdir-$(CONFIG_XILINX_MOTOR) += xilinx_motor
   obj-$(CONFIG_XILINX_MOTOR) += xilinx_motor/xilinx_motor.o

Next, I manually edited the uClinux build .config file:

   uClinux-2.4.x/.config

And appended my own entry:

   CONFIG_XILINX_MOTOR=y

Finally, I edited the following file:

   uClinux-dist/vendors/Xilinx/uclinux-auto/Makefile

to include the following just before the 'ifdef CONFIG_XILINX_GPIO'
section to create a device file for my module:

   ifdef CONFIG_XILINX_MOTOR
   DEVICES +=      \
           motor,c,10,186
   endif

The from the uClinux-dist directory I did a 'make clean; make dep; make'
compile and had the beginnings of a functioning module compiled into
resulting uClinux binary image.  Once I got the skeleton working at the
'Hello World' level I then started adding in my own hardware specific
code and such.  The hardest part so far for me was getting the interrupt
handler working -- but I looked at the following file for a working example:

   uClinux-2.4.x/arch/microblaze/kernel/xmbserial.c

Of course, I also created a test application that opens up my device and
calls the various test IOCTL calls.

There are probably better ways of doing this, but so far this approach
is working for me in getting uClinux to talk with my specialized FPGA IP.

I hope this information is useful.

Mike Thompson


Jose Torres wrote:
> Hello,
> I have been scouring the internet for information on
> microblaze-uclinux-gcc and kernel modules. I haven't come up with much
> and any guidance would greatly be appreciated.
>
> I have found two books and I was wondering if anyone with experience
> with them recommend I buy them.
> http://www.amazon.com/Building-Embedded-Linux-Systems-Yaghmour/dp/059600222X
>
> http://www.amazon.com/Linux-Device-Drivers-Jonathan-Corbet/dp/0596005903/ref=pd_bxgy_b_img_b/104-2097690-1463950
>
>
> A major problem that I am running into is where to locate the header
> files available to me.
>> From what it seems, the compiler uses this directory:
> PetaLinux\tools\linux-i386\microblaze-uclinux-tools\microblaze-uclinux\include
>
>
> I would like to incorporate the header files that the EDK provides to
> me to allow access to hardware such as xgpio.h and xtmrctr.h.
>> From my understanding, I cannot utilize these functions in user mode
> and must use a module to access kernel mode.
>
> I have tried compiling a simple kernel module as follows:
>
> #include <linux/module.h>
>
> int init_module()
> {
>        printk("Hello...\n");
>        return 0;
> }
>
> void cleanup_module()
> {
>        printk("World...\n");
> }
>
> But it simply will not make:
> [bleep@localhost KernelMod]# make
> microblaze-uclinux-gcc   -msoft-float -mxl-pattern-compare
> -mno-xl-soft-mul -mxl-barrel-shift -mno-xl-soft-div -Wl,-elf2flt -o
> KernelMod KernelMod.o
> KernelMod.elf2flt: In function `_start':
> KernelMod.elf2flt(.text+0x44): undefined reference to `main'
> KernelMod.elf2flt: In function `init_module':
> /home/bleep/PetaLinux/software/user-apps/KernelMod/KernelMod.c(.text+0xe8):
> undefined reference to `printk'
> KernelMod.elf2flt: In function `cleanup_module':
> /home/bleep/PetaLinux/software/user-appsKernelMod/KernelMod.c(.text+0x114):
> undefined reference to `printk'
> /home/bleep/PetaLinux/software/user-apps/KernelMod/KernelMod.c:11:
> undefined reference to `main'
> collect2: ld returned 1 exit status
> make: *** [KernelMod] Error 1
>
> I hope this isn't a big problem and that I'm just oblivious to something.
> Thanks,
> Jose
> ___________________________
> microblaze-uclinux mailing list
> microblaze-uclinux@xxxxxxxxxxxxxx
> Project Home Page : http://www.itee.uq.edu.au/~jwilliams/mblaze-uclinux
> Mailing List Archive :
> http://www.itee.uq.edu.au/~listarch/microblaze-uclinux/
>
>

___________________________
microblaze-uclinux mailing list
microblaze-uclinux@xxxxxxxxxxxxxx
Project Home Page : http://www.itee.uq.edu.au/~jwilliams/mblaze-uclinux
Mailing List Archive : http://www.itee.uq.edu.au/~listarch/microblaze-uclinux/


___________________________
microblaze-uclinux mailing list
microblaze-uclinux@xxxxxxxxxxxxxx
Project Home Page : http://www.itee.uq.edu.au/~jwilliams/mblaze-uclinux
Mailing List Archive : http://www.itee.uq.edu.au/~listarch/microblaze-uclinux/