Hello Bruce,
I have successfully build a module/driver for petalinux. I fiddled around with the make file (not too long) and the way I call make. It might be not the most elegant solution :-)
I suggest to compare yours to mine.
Here is the makefile:
# Add your debugging flag (or not) to CFLAGS
ifeq ($(DEBUG),y)
DEBFLAGS = -O -g -DINT_TEST_DEBUG # "-O" is needed to expand inlines
else
DEBFLAGS = -O2
endif
CFLAGS += $(DEBFLAGS)
CFLAGS += -I..
ifneq ($(KERNELRELEASE),)
# call from kernel build system
dac_audio-objs := main.o database.o libsrc/xio.o libsrc/xtmrctr_l.o debug.o
obj-m := dac_audio.o
else
KERNELDIR ?= /lib/modules/$(shell uname -r)/build
PWD := $(shell pwd)
default:
$(MAKE) -C $(KERNELDIR) M=$(PWD) modules
endif
clean:
rm -rf *.o *~ core .depend .*.cmd *.ko *.mod.c .tmp_versions
depend .depend dep:
$(CC) $(CFLAGS) -M *.c > .depend
ifeq (.depend,$(wildcard .depend))
include .depend
endif
I call make this way:
make -C /programs/petalinux-v0.30-rc1.s3a_starter/software/linux-2.6.x-petalogix M=`pwd` ARCH=microblaze CROSS_COMPILE=microblaze-uclinux- modules
Let me know if it works and also if you find a better way.
regards,
Marco
-----Original Message-----
From: owner-microblaze-uclinux@xxxxxxxxxxxxxx on behalf of Blue
Sent: Sat 9/20/2008 10:40 AM
To: microblaze-uclinux@xxxxxxxxxxxxxx
Subject: [microblaze-uclinux] Problem with make petalinux kernel 2.6 driver codes
hello folks:
I am new to write a driver for petalinux kernel 2.6,and i had ported the
petalinux kernel 2.6 to Xilinx ML403 broad.It can booted
successfully.
Now,i try to write a driver for a simple IP named "ipgcd"
when i "make" my driver codes ,i got some error message below:
make -C
/home/bluedkdk/petalinux-v0.30-rc1/software/petalinux-dist/linux-2.6.x/
ARCH=microblaze
M=/home/bluedkdk/petalinux-v0.30-rc1/software/user-apps/ipgcd modules
make[1]: Entering directory
`/home/bluedkdk/petalinux-v0.30-rc1/software/linux-2.6.x-petalogix'
Building modules, stage 2.
MODPOST 1 modules
LD [M]
/home/bluedkdk/petalinux-v0.30-rc1/software/user-apps/ipgcd/ipgcd.ko
/home/bluedkdk/petalinux-v0.30-rc1/tools/linux-i386/microblaze-uclinux-tools/bin/microblaze-uclinux-ld.real:
unrecognised emulation mode: cpu=v5.00.c
Supported emulations: elf32microblaze
make[2]: ***
[/home/bluedkdk/petalinux-v0.30-rc1/software/user-apps/ipgcd/ipgcd.ko] Error
1
make[1]: *** [modules] Error 2
make[1]: Leaving directory
`/home/bluedkdk/petalinux-v0.30-rc1/software/linux-2.6.x-petalogix'
make: *** [modules] Error 2
i don't know how to fix it, could anyone help me to fix the problem?
My Makefile is below :
######################################################################################
# Comment/uncomment the following line to disable/enable debugging
#DEBUG = y
# Add your debugging flag (or not) to CFLAGS
#ifeq ($(DEBUG),y)
# DEBFLAGS = -O -g -DSCULL_DEBUG # "-O" is needed to expand inlines
#else
DEBFLAGS = -O2
#endif
CFLAGS += $(DEBFLAGS)
CFLAGS += -I$(LDDINC)
ifndef ROOTDIR
ROOTDIR=$(PETALINUX)/software/petalinux-dist
endif
UCLINUX_BUILD_USER = 1
-include $(ROOTDIR)/.config
-include $(ROOTDIR)/$(CONFIG_LINUXDIR)/.config
#LIBCDIR = $(CONFIG_LIBCDIR)
-include $(ROOTDIR)/config.arch
#ROMFSDIR=$(ROOTDIR)/romfs
#ROMFSINST=$(ROOTDIR)/tools/romfs-inst.sh
#ifneq ($(KERNELRELEASE),)
# call from kernel build system
#ipgcd-objs := ipgcd.o
obj-m := ipgcd.o
#else
#KERNELDIR ?= /lib/modules/$(shell uname -r)/build
KERNELDIR :=
/home/bluedkdk/petalinux-v0.30-rc1/software/petalinux-dist/linux-2.6.x/
PWD := $(shell pwd)
modules:
$(MAKE) -C $(KERNELDIR) ARCH=microblaze M=$(PWD) modules
#$(MAKE) -C $(KERNELDIR) ARCH=microblaze M=$(PWD)
LDDINC=$(CONFIG_LIBCDIR) modules
#endif
clean:
rm -rf *.o *~ core .depend .*.cmd *.ko *.mod.c .tmp_versions
depend .depend dep:
$(CC) $(CFLAGS) -M *.c > .depend
#ifeq (.depend,$(wildcard .depend))
#include .depend
#endif
######################################################################################
--
Best regards
Bruce Lan