views:

47

answers:

2

Hi Guys,

I wish to access some registers of my ARM Cortex-A8 board which are by default in a non-accessible state. Ubuntu 9.10 runs on this board. So, to access them I have to in-turn change 1 other register settings (Allow-access-register) first. To change this Allow-access-register, I found out that I must do it only in Kernel mode and not in the user mode.

So, I referred how to program in Kernel mode and I got to this wonderful tutorial. I wrote this small hello world program and a make file. Note that I'm still running this program on my x86 Desktop (Ubutnu 10.04) and not YET on my ARM processor. Not until I get a hang over Kernel level programming.

I get these errors. Whats going wrong here?

Help!


Errors I get on my i.MX515 board

ubuntu@ubuntu-desktop:~/Documents/Kernel_Programming$ make
make -C /lib/modules/2.6.31-203-gee1fdae/build M=/home/ubuntu/Documents/Kernel_Programming modules
make[1]: Entering directory `/usr/src/linux'
make[1]: *** No rule to make target `modules'.  Stop.
make[1]: Leaving directory `/usr/src/linux'
make: *** [all] Error 2

Errors I get

ubuntu@ubuntu-desktop:~/Documents$ make
make -C /lib/modules/2.6.32-23-generic/build M=/home/ubuntu/Documents modules
make[1]: Entering directory `/usr/src/linux-headers-2.6.32-23-generic'
make[2]: *** No rule to make target `/home/ubuntu/Documents/hello-1.c', 
needed by `/home/ubuntu/Documents/hello-1.o'.  Stop.
make[1]: *** [_module_/home/ubuntu/Documents] Error 2
make[1]: Leaving directory `/usr/src/linux-headers-2.6.32-23-generic'
make: *** [all] Error 2

Program

#include <linux/module.h>
#include <linux/kernel.h>

int init_module(void)
{
    printk(KERN_INFO "\nHello World! I'm programming in Kernel Mode\n");

    return 0;
}

void cleanup_module(void)
{
    printk(KERN_INFO "\nBye Bye blue bird\n");
}

makefile

obj-m +=hello-1.o

all:
    make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules

clean:
    make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean
A: 

There is a typo in your make command like:

It should be:

make -C /lib/modules/2.6.32-23-generic/build M=/home/ubuntu/Documents modules   

not

make -C /lb/modules/2.6.32-23-generic/build M=/home/ubuntu/Documents modules   
Nils Pipenbrinck
Hey Nils, Oh my head has become so fuzzy with the problem I'm facing I can't see anything straight :) :) I fixed it, but I get these new make errors. (Refer my question, I have edited it)
vikramtheone
A: 

I don't know if it's just the formatting of your post or not, but the kernel build scripts are looking for "Makefile" and you have "makefile" (difference in case). Could that really be the problem? Plus, is your username "ubuntu"?

Karmastan
Okay I renamed my makefile from makefile to Makefile and I get new errors (Refer my question, I have edited it)
vikramtheone
Is your source file actually named "hello-1.c"? That's what the scripts are looking for.
Karmastan
Sorry, I fixed it. After renaming the file, I had two makefiles and I was executing the wrong makefile. now it is compiling and generating object file. Thank you.
vikramtheone
Hi Karmastan, new problems! I took both my makefile and .c file to my board and tried executing my makefile and I get make errors. This was not happening on my linux desktop. (Refer my question, I have edited it. Errors I get on my i.MX515 board section)
vikramtheone
The problem I see is that at /usr/src/ I don't see 2.6.31-203-gee1fdae directory, so it fails.
vikramtheone
Do you actually have the linux headers installed on your Cortex? I'm guessing not.
Karmastan
@vikramtheone: Rather than continually editing your question, you should mark an answer as accepted for the original problem, and post a fresh question for the new problem.
caf