LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware > Linux - Embedded & Single-board computer
User Name
Password
Linux - Embedded & Single-board computer This forum is for the discussion of Linux on both embedded devices and single-board computers (such as the Raspberry Pi, BeagleBoard and PandaBoard). Discussions involving Arduino, plug computers and other micro-controller like devices are also welcome.

Notices

Reply
 
Search this Thread
Old 12-31-2010, 12:54 AM   #1
mailtosouvik
LQ Newbie
 
Registered: Jan 2006
Posts: 6

Rep: Reputation: 0
Compile kernel module for MIPS32


Hello All,

I need to compile a kernel module for my target platform running 2.6.21 kernel. If I run file command on some other module that runs successfully on the target system, it shows "ELF 32-bit LSB relocatable, MIPS, MIPS32 version 1 (SYSV), not stripped"

I downloaded 2.6.21 kernel, updates $ARCH and $CROSS_COMPILE and compiled the kernel. Now when I specify this kernel source path in my module makefile it builds a module which is for MIPSIII, and MSB (as observed when running file command on the .ko). The linux-2.6.21/.config does not have CONFIG_MIPS32 set and CONFIG_LITTLE_ENDIAN set. So I thought I need to configure the kernel (at least modify these two options) before building my module against this kernel. Am I thinking in the right way? If not what should be my approach? Please let me know which option/options should I select from make menuconfig if I need to recompile the kerenl.

Also, please let me know if these two option (mips32 and 'little endian') can be specified in my module Makefile. What would be the make line then?

Thanks in advance,
Souvik
 
Old 12-31-2010, 04:46 AM   #2
Oliv'
Senior Member
 
Registered: Jan 2004
Location: Montpellier (France)
Distribution: Gentoo
Posts: 1,014

Rep: Reputation: 36
Hello,

What toolchain do you use ? Typically if you use MIPS CodeSourcery toolchain, it will create by default a MIPS Big Endian binary. A quick workaround for that is to create some wrappers for gcc, ld...
Let me know if you are in such a case and that you need more info about that.

Kind regards

Oliv'
 
Old 12-31-2010, 05:14 AM   #3
mailtosouvik
LQ Newbie
 
Registered: Jan 2006
Posts: 6

Original Poster
Rep: Reputation: 0
Thanks Oliv for the reply. I am using a mipsel toolchain created using buildroot. I am not been able to get the work around you are referring to. Can you please explain it in bit more detail.

If I build any application code using this toolchain with '-mips32' options specified it builds LSB executable for mips32. File command to this application binary shows "ELF 32-bit LSB executable, MIPS, MIPS32 version 1 (SYSV), statically linked, not stripped". But if I specify -mips32 option in my module Makefile it shows the following error:

Assembler messages:
Error: -mips32 conflicts with the other architecture options, which imply -mips3

So I thinks that somehow my kernel configuration is not correct. My kernel .config file does not have MIPS32 flag enabled. Please suggest what should I do now. The module Makefile is also pastes here,

================== Makefile to compile module =========================
obj-m = my_mod.o
KPATH =/home/souvik/test/linux-2.6.21.1
CROSS_COMPILE ?=/home/souvik/Toolchain/buildroot-gcc342/bin/mipsel-linux-
AS = $(CROSS_COMPILE)as
LD = $(CROSS_COMPILE)ld
CC = $(CROSS_COMPILE)gcc -Os -pipe -mips32 -mtune=mips32 -funit-at-a-time
CPP = $(CC) -E
AR = $(CROSS_COMPILE)ar
NM = $(CROSS_COMPILE)nm
STRIP = $(CROSS_COMPILE)strip
OBJCOPY = $(CROSS_COMPILE)objcopy
OBJDUMP = $(CROSS_COMPILE)objdump

ARCH = mips

all:
$(MAKE) -C $(KPATH) M=$(PWD) modules CROSS_COMPILE=$(CROSS_COMPILE) ARCH=$(ARCH)
clean:
$(MAKE) -C $(KPATH) M=$(PWD) clean\
================================================

If I remove "-Os -pipe -mips32 -mtune=mips32 -funit-at-a-time" from the CC definition it builds MIPS III MSB binary. ("ELF 32-bit MSB relocatable, MIPS, MIPS-III version 1 (SYSV), not stripped").

Last edited by mailtosouvik; 12-31-2010 at 05:17 AM.
 
Old 12-31-2010, 05:30 AM   #4
Oliv'
Senior Member
 
Registered: Jan 2004
Location: Montpellier (France)
Distribution: Gentoo
Posts: 1,014

Rep: Reputation: 36
Ok, so that's your kernel which are probably not perfectly set (as you said in your first post).
I think that you have to ensure that the following options are enabled:
CONFIG_CPU_LITTLE_ENDIAN=y
CONFIG_CPU_MIPS32_R1=y (in CPU selection)

Regards,

Oliv'
 
Old 12-31-2010, 05:38 AM   #5
mailtosouvik
LQ Newbie
 
Registered: Jan 2006
Posts: 6

Original Poster
Rep: Reputation: 0
Thanks Oliv, It looks my machine selection section is wrongly configured. That's why I didn't get the MIPS32R1 and LITTLE Endian option last time. I will correct this one and will try building the module. I will keep you posted.
 
Old 01-01-2011, 09:12 PM   #6
mailtosouvik
LQ Newbie
 
Registered: Jan 2006
Posts: 6

Original Poster
Rep: Reputation: 0
Hey Oliv,

It works - Muy machine selection was wrong. Thanks a ton for all the support.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Compile and load kernel module automatically after boot? (Intel NIC module) touser Linux - Newbie 3 08-29-2009 08:45 PM
what to compile into kernel and what as module tramni1980 Slackware 5 07-13-2009 01:57 AM
Adaptec Kernel Module - Kernel Compile Errors dumbsheep Linux - General 3 11-07-2007 03:47 PM
Why can't I compile this kernel module? (kernel: 2.6.8-powerpc Debian sarge) Lannix Linux - Hardware 5 05-01-2007 12:29 PM
can i compile just one kernel module whithout recompiling the whole kernel? edman007 Linux - Software 3 02-17-2004 03:05 PM


All times are GMT -5. The time now is 10:16 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration