[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [microblaze-uclinux] Getting Started with microblaze-uclinux-gcc
Hi,
> 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
This book is about building toolchains, root filesystems, bootloaders
etc. It is nice to have, if you want to build embedded linux adapted to
a special hardware or if you are completely new to embedded linux and
want _one_ book which covers almost all topics and to get an overview.
Here is a description and also the table of contents:
http://www.oreilly.com/catalog/belinuxsys/
> http://www.amazon.com/Linux-Device-Drivers-Jonathan-Corbet/dp/0596005903/ref=pd_bxgy_b_img_b/104-2097690-1463950
>
Before buying this book, read it online:
Linux Device Drivers, 2nd edition (Kernel 2.4):
http://www.xml.com/ldd/chapter/book/
Linux Device Drivers, 3rd edition (Kernel 2.6):
http://lwn.net/Kernel/LDD3/
The web is full of sites describing how to build drivers, for example:
http://www.freesoftwaremagazine.com/articles/drivers_linux
Building a good driver (kernel module) isn´t trivial!
Here is an article describing the differences of µCLinux compared to
"normal" linux:
http://www.ee.ryerson.ca/~courses/coe518/LinuxJournal/elj2004-123-uCLinux.pdf
> A major problem that I am running into is where to locate the header
> files available to me.
The header files are in a uCLinux-dist subdirectory called "include".
> >From what it seems, the compiler uses this directory:
> PetaLinux\tools\linux-i386\microblaze-uclinux-tools\microblaze-uclinux\include
I do not have PetaLinux installed, but this seems to be correct.
> >From my understanding, I cannot utilize these functions in user mode
> and must use a module to access kernel mode.
Yes.
> 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'
You are trying to build an executable (-Wl,-elf2flt). But you want a
kernel module. Omit these flags.
> KernelMod.elf2flt: In function `init_module':
> /home/bleep/PetaLinux/software/user-apps/KernelMod/KernelMod.c(.text+0xe8):
> undefined reference to `printk'
Try finding printk in "module.h". You won´t ;-)
You must include "kernel.h" and you must define MODULE and __KERNEL__.
(kernel.h starts with: #ifdef __KERNEL__ ...)
Example:
---hello.c---
#include <linux/module.h>
#include <linux/kernel.h>
int init_module(void){ printk("Hello...\n"); return 0; }
void cleanup_module(void){ printk("World...\n"); }
---
Compile it like this:
mb-gcc -DMODULE -D__KERNEL__ -Wall
-I/home/kdre/development/uClinux-dist/linux-2.4.x/include/ -c hello.c
(change include path!)
Or put everything into a makefile:
---Makefile---
CC = mb-gcc
INCLUDE = -I/home/kdre/development/uClinux-dist/linux-2.4.x/include
CFLAGS = -Os -g -fomit-frame-pointer -fno-common -fno-builtin -Wall
-mno-xl-soft-mul -mxl-soft-div -DMODULE -D__KERNEL__
all: hello.o
hello.o: hello.c
${CC} ${CFLAGS} ${INCLUDE} -c hello.c
clean:
rm -rf hello.o
---
Another way would be to create a new directory under linux-2.4.x/drivers
and add this subdir to "subdir-y" in "linux-2.4.x/drivers/Makefile".
Then you do not have to care about the neccessary CFLAGS.
A question similar to your question can be found in the uCLinux
mailinglist:
http://mailman.uclinux.org/pipermail/uclinux-dev/2002-December/013429.html
Good luck!
Klaus
PS: I did not load the compiled module into a running µCLinux, but it
should work.
___________________________
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/