General Question

linuxgnuru's avatar

How to compile a linux module for a different arch?

Asked by linuxgnuru (207points) June 8th, 2011

I’m playing with an ARM device; got a copy of Debian working just fine; the problem is I’d like to use this USB ethernet (asix.ko) but not sure how to compile for this device from my desktop. and sadly google has failed me so, how does one compile not the whole kernel; just a single module for an architecture other than i386 but from a i386 machine?

Observing members: 0 Composing members: 0

13 Answers

koanhead's avatar

Generally speaking, gcc has an ‘arch’ flag which should take care of this.
This may mean that you need to edit Makefiles if you such are provided by the manufacturer – hopefully you don’t need to ‘roll your own’ driver for this.
The Debian kernel is not so good as the equivalent Ubuntu kernel at auto-detecting hardware (which is one reason why Debian installs usually boot faster- but there is no direct equivalence between versions of the two distros, really).
If you don’t have a human-readable Makefile to work with (or even if you do), you’ll probably need to search within gnu.org for better informaton.
If you can provide more details of the architecture involved, I can be of more help- but honestly, gcc either supports it or it does not, and GNU is the place to find out about that.

linuxgnuru's avatar

The only modules I need are usbnet, asix, and usbserial (for now)
The “device” is a wm8505 300mhz that I was given to play with for free.

Here’s some more info:

uname:
Linux william 2.6.29–00236-g4f8dbbb-dirty armv5tejl GNU/Linux

/proc/cpuinfo:

Processor : ARM926EJ-S rev 5 (v5l)
BogoMIPS : 174.48
Features : swp half thumb fastmult edsp java
CPU implementer : 0×41
CPU architecture: 5TEJ
CPU variant : 0×0
CPU part : 0×926
CPU revision : 5

Hardware : WMT
Revision : 0000
Serial : 0000000000000000

I was really hoping this would a cinch to get working

koanhead's avatar

Do you have the sources for the modules you need?

If you’re running Debian on the target system then you can probably pull the sources from one of the mirrors in this list. The Debian sources will most likely have a working Makefile so you won’t have to mess about with gcc options. I don’t know where apt puts them by default, but dpkg -L should tell you this.

It’s even possible that you could just download working binaries directly to the ARM device if it has any net access; or you could download the binaries to your desktop and then copy them to the target system’s /lib/modules/[uname -r], just as you would do after compiling them.

Note that there are two different ARM distributions of Debian, called ‘arm’ and ‘armel’. I think armel is the one your device would use but I’m not 100% sure.

I’ve downloaded http://ftp.us.debian.org/debian/dists/lenny/Contents-arm.gz and verified that all three modules you mention are part of the armel distribution. Hopefully you won’t need to compile anything.

If you aren’t using Debian ARM, than what are you using?

linuxgnuru's avatar

I am using a package comes from http://www.projectgus.com/files/abrasive_mirror/wm8505_linux/1.0/extpart.tgz and uses Debian 5.0.4; but as for which CPU it is (arm or armel) I haven’t the faintest idea.

koanhead's avatar

Ok, looking through the ftp directories there it looks like this is a more-or-less Debian port for a specific device. Since you’ve posted uname output, obviously the kernel is up and running, so I guess it’s working ok.
What happened when you did ‘modprobe rt3070sta’? (I’m presuming that you read the README file.) does the rt3070sta module show up in lsmod? If it does then you have wireless networking available, and if you bring that interface up you can use apt-get to get the other modules you want.
It looks like you’ll have to craft your own /etc/apt/sources.list but there are plenty of samples out there on the Web. It doesn’t look like you need to specify your architecture in that file, I guess apt knows to choose the right one automagically. Just make sure you pick a mirror from the list above that supports arm / armel. As far as I can tell, there aren’t any that support one and not the other.

koanhead's avatar

Btw, I’m not entirely sure which of Gus’ projects relate to that file tree. Is it covered on the main page? Is it the Android tablet thing?

linuxgnuru's avatar

The only issue is I have 23 MB to work with and I doubt I could install all the packages needed for gcc to work. It’s a fairly cheap Chinese “internet device” some times you can find them under the name EasyPC

koanhead's avatar

I keep trying to tell you- you don’t need gcc. Even if you do need it you only need it on your desktop computer. You almost certainly do not need to compile anything, and you definitely don’t need to compile anything on the ARM device.

I don’t understand why you seem to be trying to complicate your life unnecessarily. Did you read the README file? Did you read the things I wrote above?

koanhead's avatar

Is this the relevant blog?
http://projectgus.com/2010/07/debian-on-the-eken-m001/

Also, am I misunderstanding what you are trying to accomplish? I’m not sure if you are focused on compiling these modules just for the hacker cred, or if you are just trying to get the device working. Either way I’ll try to help as best I can.

linuxgnuru's avatar

Let me try to start over. I honestly don’t know much about project gus; I’ve been using: http://www.cheap-hack.com/home/en/computer-science/wm8505/debian-installation as the primary stepping stone and through that I was sent to a mirror of abrasive residing at project gus. The modules that I have that are working were pre-compiled. All that I am wanting is if there is some new module I need, (like usbserial to use my gprs / 3g modem) can I just download the module or do I have to compile it myself?

koanhead's avatar

As far as I can tell, you should be able to just download it. Like I said, you can use apt-get to fetch it from a local mirror if the device has any connectivity at all; or you can use wget on your desktop to download the .deb file, transfer it to your card and then dpkg -i to install it.
I’ve already verified that the packages exist for arm and armel at ftp.us.debian.org.

That blog you cited should have told you to read the README file. It’s here: http://www.projectgus.com/files/abrasive_mirror/wm8505_linux/1.0/README

You don’t need to compile anything.

linuxgnuru's avatar

thanks for all your input; even if I wasn’t quite understanding things. I come from redhat/fedora and didn’t know you could use apt-get to get kernel modules.

koanhead's avatar

Crap. I thought you could fetch individual modules that way, but looking at that Contents.gz file and playing with apt-cache search, it looks like you can’t- apparently they are packaged inside the kernel image packages. Sorry about that.

It looks like there are two options. First we need to figure out which kernel-image package is the right one for that device. If you’ll post the output of ‘cat /proc/cpuinfo’ that might help us determine which one we need. If that fails for any reason you could try ‘dmesg |grep -i cpu’.
Once we have that information, you might be able to just apt-get install the whole kernel image. I’m not sure how large it is, but once we know which one is needed we can determine that using apt-cache show. How much free space do you have on the device’s storage?
Once the new kernel is installed you should have a choice at boot time between it and the existing kernel- if you have GRUB. If you don’t then there’s a chance installing the new package could nuke the bootloader – so you’d need to not do that.

If you can’t install the whole image to the device, then you’ll need to download it to the desktop using ‘apt-get—download-only [packagename]’. Then you can extract the archive using ‘dpkg—extract [downloaded-file] [target-directory]’. Then you can pull the file you want out of there and transfer it.

If all that fails, then you might need to compile the package- but we’ll burn that bridge when we get to it, yes?

Answer this question

Login

or

Join

to answer.

This question is in the General Section. Responses must be helpful and on-topic.

Your answer will be saved while you login or join.

Have a question? Ask Fluther!

What do you know more about?
or
Knowledge Networking @ Fluther