I have been trying to compile a kernel module (usbhid), to make mybook monitor a UPS over USB (so it can shutodown in case a power failure). I have found quite a lot of difficulties, which I finally solved, so I give some ideas here:
When following those posts, consider also these points:
- You can do it in anylinux modern version, regardless the gcc compiler inside. No need to change the linux distro compiler (e.g., I did it with Ubuntu 8.04, gcc-4.3). The reason is that the buildroot will compile the specific gcc version with cross-compilation support.
- When configuring buildroot, set always soft emulated FP processor. Configure not to include any application, so it takes less time. The interesting thing is to compile basic tools and the applicable gcc compiler for arm cross compilation.
- If you compile applications, the easiest is to use all which comes in the WD source package. Just put all the buildroot archives inside buildroot/dl directory (so there is no download), and configure buildroot as in the original system, e.g. with FW 1.0.18 with gcc-3, and kernel 18.104.22.168. Important point is not to get the latest uClibc snapshot, but the version a specified version (leave empty and it takes default one, already indl, I think). If setting all correct, it compiles ok, except last steps of building the root, which is not necessary.
- Once you have the compiler, you can try to compile applications from source code, using the buildroot generated copiler and libraries. I have not done it, but maybe you need to touch makefiles to use correct elements. You can see how buildroot compiles applications to do the same.
- If you want to compile a kernel module, it is a bit more difficult, because you need to use arm gcc-4.1 compiler generated by build root. The main problem is that buildroot and uClibc evolve, and they do not support anymore old compilers gcc-4.1 and kernel. The following worked for me:
- Download the latest buildroot package and extract it. Maybe in the future it does not work, so instead of latest, take from buildroot site the one available as latest around nov-2009, which I used. The same for uClibc
- In the configuration, it is the same as for applications, except that you have to enable obsolete packages, and then select the gcc-4.1 version (in my case it was gcc-4.1.2). Take the latest snapshot of uClibc. Use the latest In the kernel headers, specify manually the version 22.214.171.124 (because kernel 17 does not have headers install kernel, so buildroot fails. It seems that using this version is ok.
- When you make, it takes quite a long time, because it downloads some packages and compiles big thing like gmp (I do not know why). At the end, it should compile until the erroor when creating root image, and hopefully the gcc-4.1.2 should be available.
- You can then go to the vendor/kernel sources provided by WD, set the path to the generated gcc-4.1.2 compiler and try. I could obtain my module doing this.
I hopt that with the original instructions and these tips someone with good knowledge of linux and compilation can get things to work…