Forums » Software Development »
Driver Development Procedure
Added by david kasper about 14 years ago
I need to create a loadable Linux module that runs on the ARM9 of the MityDSP-L138 and accesses the FPGA. Preferrably the build would be performed "out-of-tree" such that an environment variable references the angstrom kernel tree. I have successfully performed this method for another distribution (see example makefile below) however I get errors with the Angstrom distribution (see below). Does anybody have an example that I can modify or a tutorial on how this can be accomplished?
Thank you,
David Kasper
>>>>>>>>>BUILD ERRORS [student@localhost modules]$ make -f make_gpio ========= building dir ==> gpio CC [M] //home/student/build/sup_sw/linux/angstrom/arm9/modules/gpio/gpio.o //home/student/build/sup_sw/linux/angstrom/arm9/modules/gpio/gpio.c:1: error: code model âkernelâ not supported in the 32 bit mode //home/student/build/sup_sw/linux/angstrom/arm9/modules/gpio/gpio.c:1: sorry, unimplemented: 64-bit mode not compiled in make[2]: *** [//home/student/build/sup_sw/linux/angstrom/arm9/modules/gpio/gpio.o] Error 1 make[1]: *** [_module_//home/student/build/sup_sw/linux/angstrom/arm9/modules/gpio] Error 2 make[1]: *** No rule to make target `zip'. Stop. make: *** [build] Error 2 [student@localhost modules]$ # # Sample out of tree build Makefile # for the TARGET system # PWD = $(shell pwd) ROOTDIR ?= $(KERNEL_ROOT)/.. KSRC = $(ROOTDIR)/$(LINUXDIR) ARCH ?= arm CROSS_COMPILE ?=arm-angstrom-linux-gnueabi- MAKEARCH_KERNEL ?= $(MAKE) ARCH=$(ARCH) CROSS_COMPILE=$(CROSS_COMPILE) #ifdef M obj-m += gpio.o #else all: CFLAGS="" CPPFLAGS="" LDFLAGS="" \ $(MAKEARCH_KERNEL) -C $(ROOTDIR)/$(LINUXDIR) M=$(PWD) modules $(MAKEARCH_KERNEL) -C $(ROOTDIR)/$(LINUXDIR) M=$(PWD) \ INSTALL_MOD_PATH=$(ROOTDIR)/romfs DEPMOD=true modules_install romfs: clean: $(MAKEARCH_KERNEL) -C $(ROOTDIR)/$(LINUXDIR) M=$(PWD) clean #endif
Replies (3)
RE: Driver Development Procedure - Added by Michael Williamson about 14 years ago
Hi David,
There's no magic with the kernel sources we're using. Your makefile looks OK to me.
This is just a guess, but the error messages suggest that perhaps your trying to use the wrong toolchain (64 bit on a 32 bit host). Are you using the VM provided, or a native linux install (what distro/version, e.g., what's "uname -a" give you)? Are you using a 32 bit or 64 bit version of linux on your host machine? What version of the toolchain do you have installed?
-Mike
RE: Driver Development Procedure - Added by david kasper about 14 years ago
Mike,
Thanks for your fast reply. I have installed the 32-bit GCC running on Fedora 9. Also I have successfully compiled and tested hello world, an application and shared libraries. Uname generates the following response:
[student@localhost modules]$ uname -a
Linux localhost.localdomain 2.6.25-14.fc9.i686 #1 SMP Thu May 1 06:28:41 EDT 2008 i686 i686 i386 GNU/Linux
FYI I invoked the previous makefile from a top-level makefile listed below. Note the kernel tree was referenced at the ~linux-davinci level as follows:
[student@localhost modules]$ $KERNEL_ROOT
-bash: /home/student/work/arm9/linux-davinci: is a directory
Let me know if you have any suggestions or a simple example to try.
Thanks,
David Kasper
############################################################################# # uClinux Module Makefile # # INVOCATION: make -f make_gpio [build] [clean] [host] # # INPUTS: build - rebuild .ko's and compress result # clean - remove module .o and .ko files # host - copy module to TFTP_DIR # KERNEL_ROOT - path to compiler kernel folder # ############################################################################# ############################################################################ # Environment Variables Section ############################################################################ # Check if required variables are set ifeq "$(KERNEL_ROOT)" "" $(error ERROR: KERNEL_ROOT environment variable not set.) endif ############################################################################ # Module Names Section ############################################################################ MODULENAMES=gpio \ ############################################################################ # Make Options Section # # ignore-errors - ignore errors in all rules # no-print-directory - suppress directory messages during recursive make ############################################################################ BUILD_MOPTS=--no-print-directory -C $(KERNEL_ROOT) SUBDIRS=/$(PWD)/$$i modules MOPTS=--ignore-errors --no-print-directory ############################################################################ # Default Target # # all - build libraries ############################################################################ all: build ############################################################################ # Build Modules ############################################################################ build:: @for i in $(MODULENAMES); do \ (echo "========= building dir ==> "$$i; cd $$i; $(MAKE) $(BUILD_MOPTS); \ $(MAKE) $(MOPTS) zip) || exit $?; \ done ############################################################################ # Clean Modules ############################################################################ clean:: @for i in $(MODULENAMES); do \ (echo "======== cleaning dir ==> "$$i; cd $$i; $(MAKE) $(MOPTS) clean) \ || exit $?; \ done ############################################################################ # Host Modules ############################################################################ host:: @for i in $(MODULENAMES); do \ (echo "======== Hosting module ==> "$$i; cd $$i; $(MAKE) $(MOPTS) host) \ || exit $?; \ done
RE: Driver Development Procedure - Added by david kasper about 14 years ago
Mike,
For some reason the source gets messed-up when pasting into the reply box. Therefore, I have attached the make files. Note prior to compiling I export the location of the Linux tree as follows:
export KERNEL_ROOT=/home/student/work/arm9/linux-davinci
It will be more efficient to build out of tree during testing.
- Dave