Forum Discussion
Altera_Forum
Honored Contributor
20 years ago --- Quote Start --- originally posted by ken@Nov 26 2004, 09:37 AM that's an extremely complicated makefile... have you tried using the makefile i provided in this thread? it does allow for building outside of the kernel tree. as a bonus, it also pulls in all the necessary rules for building the module properly from the original kernel source instead of requiring you to specify the rules manually.
give it a try, and post any errors that you get when you try running "make". it worked like a charm when i did it.
in fact, here's the makefile tailored to your situation:
config_test_mod=m
ifneq ($(kernelrelease),)
# this is the section of the makefile that builds the module inside the kernel
obj-$(config_test_mod) := testmodule_mod.o
else
# this section is for building the module outside of the source# $(eclipse_workspace) is assumed to be defined externally by the environment
# please reference the articles on http://www.lwn.net regarding# kernel module development for more information about this makefile
kdir := $(kernel_plugin)/linux-2.6.x
$(error you need to specify the kernel project that this module is being built for before this will work!)# delete the above line after you have modified the variable below to its proper setting
kernel_project := your_kernel_project
builddir := $(eclipse_workspace)/$(kernel_project)/build
pwd := $(shell pwd)
default:
$(make) -c $(kdir) o=$(builddir) subdirs=$(pwd) modules
endif --- Quote End --- Hello, I used the Makefile you provided to compile my own simple Hello World kernel module. I want to build up a more sophisticated driver by adding calls to the Nios II HAL, but I can't get the module to compile whenever I include a HAL header file. For instance, adding #include "alt_types.h" to #include <stdio.h>
int main()
{
printf("Hello World\n");
return 0;
} does not compile. Adding the proper directories to the include path using the Nios IDE does not fix the problem. Since we compile the kernel module using the Nios SDK Shell, adding the path in the IDE doesn't help, I suspect. I'd like to add -I<HAL directories> to the Makefile you provided, but I'm not sure how to do it in a clean way (ie. without modifying %eclipse_plugins%/com.microtronix.nios2linux.kernel_0.1.5/linux-2.6.x/Makefile). Summarizing, I would like to create a kernel module that calls HAL functions. Please explain how this can be done http://forum.niosforum.com/work2/style_emoticons/<#EMO_DIR#>/smile.gif Thank you, jwistead.