May 31, 2009

Building kernels for Lemote Yeeloong

Well… it’ll be a while before I get around to porting Gentoo to the Yeeloong in earnest, however this is the first step.  The following are some notes for those who may wish to go ahead and set up Gentoo.

Toolchain

For both the Yeeloong, and the Loongson 2F-based Fulong, you’ll need the latest gcc (4.4.0) and binutils.  I normally don’t recommend H. J. Lu’s binutils distribution, but in this instance, you need something pretty bleeding edge, this gets you bleeding edge without needing live ebuilds.

I keep patched ebuilds of binutils and kgcc64 in my overlay.  To obtain these, install git, then run git clone git://git.longlandclan.yi.org/overlay.git and add it to your overlays.  The overlay is also browsable here.

Once added, simply merge sys-devel/binutils-2.19.51.0.5 and sys-devel/kgcc64-4.4.0_alpha20090407. These work for me anyway.

Patched Kernel

Zhang Le has done an excellent job in merging the Lemote patches into the Linux/MIPS tree… clone a copy by typing git clone git://www.gentoo-cn.org/var/git/linux-loongson.git. Use make yeeloong_defconfig to make a suitable config, then compile as per the Gentoo/MIPS handbook, using the vmlinux.32 target.

Power Management

There’s one final piece missing… and that’s the ec_module power management drivers. You get those from here. If you’re compiling against a kernel later than 2.6.29, double check that the version you fetch has the patch to correct for the new struct proc_dir_entry, sans owner field. You can get this patch from here if need be… or alternatively,

git clone git://dev.lemote.com/ec_module.git
git pull git://git.longlandclan.yi.org/ec_module.git

This will pull in the aforementioned patch if it isn’t already there.

To build the module, simply change to your kernel source directory, then run make modules modules_install CROSS_COMPILE=mips64el-unknown-linux-gnu- M=/path/to/ec_module.

Once I’m through exams, I’ll probably start looking into merging this into a patchset to place in mips-sources… but for now, there’s a starting point for those who are wondering where to begin.