Nios® V/II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® V/II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++
12748 Discussions

How to compile driver in Nios2uclinux

Altera_Forum
Honored Contributor II
1,430 Views

Hello everyone, 

 

In Microtronix nios2uclinux,How can I compile my device driver? through the nios2 IDE or other ways?And can I use the module or must add the program into kernel? 

 

Who can tell me the method in detail?Thanks! 

 

 

 

Tony Zhu 

ChongQing ,China
0 Kudos
7 Replies
Altera_Forum
Honored Contributor II
713 Views

In the kernel tree ( should be something like "C:\altera\kits\nios2\bin\eclipse\plugins\com.microtronix.nios2linux.kernel_0.1.5\linux-2.6.x\drivers" but it depends on where you installed the NIOS IDE) add your driver code files to the appropriate directory (char for instance if you are writing a char driver).  

In the makefile for that directory add the object file for your driver to the line "obj-y += ..." (eg if your code is in mydrv.c you should put mydrv.o at the end of that line). 

 

Compile your kernel as usual. 

 

This will get you going, but this will put your driver directly in the kernel (it will not be a module). To add modules or make your driver appear in the kernel configuration menu you will have to ask again. 

 

Tuck
0 Kudos
Altera_Forum
Honored Contributor II
713 Views

Thanks Tuck!Yes,it can compile my drivers in kernel,but when I debug the drivers,this like so slow.So,just the same I want to know how to compile the drivers as a module? 

 

 

--- Tony Zhu
0 Kudos
Altera_Forum
Honored Contributor II
713 Views

It's also possible to compile your driver as a kernel module outside of the source tree. Take a look at: 

 

lwn: driver porting (http://lwn.net/articles/21823/

 

The only thing that you would have to do differently to get it working is to specify an output directory on the make commandline from within the example makefile. 

 

... KDIR = $(KERNEL_PlUGIN)/linux-2.6.x BUILDDIR = $(ECLIPSE_WORKSPACE)/kernel_project/build ... $(MAKE) -C $(KDIR) O=$(BUILDDIR) SUBDIR=$(PWD) modules ... 

 

After compiling the module, you can upload it to your filesystem or copy it into a filesystem project and re-upload the filesystem project.
0 Kudos
Altera_Forum
Honored Contributor II
713 Views

Ken,thank you very much.And I have a little question about how to cancel the login and password when I startup the uclinux system.I had tried to modify the /etc/password before,but the examination was faulted. 

Do you have a new way to solve it? 

 

 

Tony Zhu 

ChongQing,China
0 Kudos
Altera_Forum
Honored Contributor II
713 Views

All usernames and passwords are hard-coded within the applications (take a look inside login and ftpd... I believe that's where you'll find the passwords). 

 

The best way to bypass the passwords is to do one of the following: 

 

(1) modify inittab to start a shell instead of agetty on the serial console 

(2) remove init entirely from the filesystem so that it'll start sh by default 

 

Lemme know if you run into trouble...
0 Kudos
Altera_Forum
Honored Contributor II
713 Views

 

--- Quote Start ---  

originally posted by ken@Nov 2 2004, 08:20 AM 

all usernames and passwords are hard-coded within the applications (take a look inside login and ftpd... i believe that's where you'll find the passwords). 

 

the best way to bypass the passwords is to do one of the following: 

 

(1) modify inittab to start a shell instead of agetty on the serial console 

(2) remove init entirely from the filesystem so that it'll start sh by default 

 

lemme know if you run into trouble... 

--- Quote End ---  

 

Ken, 

I tried like your way.But when startup the script like /etc/rc didn't autorun.I add the "./etc/rc" in inittab,didn't autorun also. 

Then,I add the init.exe in the system file's /bin/,the script rc can autorun,but in the console I didn't go into the linux prompt.PLS help and so sorry to tell you late! 

 

Tony
0 Kudos
Altera_Forum
Honored Contributor II
713 Views

What error messages did you receive? I suspect that it might have been a linefeed error since Eclipse likes to put everything in CRLF mode (I think). 

 

Try restoring the inittab to its original state or something similar and changing the linefeed style on the file through the "Edit" pull down menu. 

 

Or alternatively, you can modify the linefeeds by using dos2unix in the Nios II SDK shell. 

 

But first things first, what error messages are you getting?
0 Kudos
Reply