Fun with Gentoo on the VIA C3

The VIA C3 is a neat low-power processor, available in Socket 370 versions as well as on embedded motherboards (including the tiny Mini-ITX series). It was also, from what I’ve seen elsewhere on the web, used in some of the “Microtel” Lindows PCs sold by Wal-Mart.

Update, to disambiguate things: The Nehemiah core and later fully support the CMOV instruction mentioned below! As far as I know, you can use i686 as the CHOST for those. (Please let me know if this isn’t the case.)

Unfortunately, it’s got one serious oddity that will trip you up under some conditions when attempting to install Linux on the C3 system. The C3 identifies itself as being an i686-class processor with MMX, SSE, and 3DNOW feature sets. Pre-’Nehemiah’ core C3s are missing an instruction that is present on proper i686 chips! The instruction in question is CMOV, which may be present in code compiled for an i686 platform.

I first discovered this when using the Gentoo Linux LiveCD to install on a C3 system. The core in mine is the older Via Samuel 2, on a Syntax brand board. (A sticker on top of the cooler calls it a “1.3GigaPro” or such oddness.) On this CMOV-less core, the kernel booted ok, the proper init dance was danced, but attempting to chroot led to an illegal instruction error!

A quick search revealed that some other users had run into this same problem. It was mentioned on the Gentoo forums how to fix it on an already running system, but not on one that hadn’t been installed yet!

From searching around on the web, I saw that newer versions of Redhat were built to avoid CMOV on these chips, and just on a hunch, guessed that such a fix might have trickled down to the newer Fedora Core releases. I’d already had the 5-cd set downloading via Bittorrent so I could burn it off for a fellow follower of the great penguin, and the rescue disc of the set (about 100 megs) had already finished. I burned that to disc, and it allowed me to get up in a bootable LiveCD environment like Gentoo’s CD does.

At the point where it asked whether or not I wanted to mount the existing partitions (I had sucessfully partitioned it *before* running into the CMOV bug), I selected Skip. Voila… I had a shell with networking functional. From there, the usual steps of creating /mnt/gentoo and mounting the partitions worked, and I was able to chroot into the new environment set up from the Stage 1 x86 tarball. (NOT the i686 tarball, of course.)

Excellent! Things were looking up so far. I found some various suggestions for the choice of CFLAGS for this system, and there seemed to be some disagreement over whether it’s better to use -Os to minimize cache misses (64kb cache? Ow!) or some other optimization level. I chose -Os… I can always play with this later.

Here’s what I wound up with:
CHOST=”i586-pc-linux-gnu”
(This is very important - you MUST use i586 or the system will attempt to use CMOV, which is, of course, broken!)
CFLAGS=”-march=c3 -mmmx -m3dnow -fomit-frame-pointer -Os -pipe”
(Yes, it really does appear to support 3dnow. Newer ones do SSE as well. And, if you’ve got GCC 3.3 or newer, you can use -march=c3 - otherwise, use -march=pentium-mmx. Gentoo uses 3.3 by default on new systems, so there’s no problem there.)
CXXFLAGS=”${CFLAGS}”
(since there’s really no reason to have different flags for C and C++…)

Things appear to be working well so far - it’s in the bootstrap stage, and nothing’s exploded. Now, if only I didn’t have the guts of two computers spread across my bed, I wouldn’t have to go to sleep on the couch this morning…

Ahh, just when I thought I had it easy…
Ran into a stupid portage bug that stopped glibc from emerging during the bootstrap stage. The solution appears to be here (along with exactly the same error I recieved). Once I got past that, it’s been smooth sailing from there on out.

I’ve almost forgotten how nice it is to have a system that doesn’t require utterly exotic CPU cooling. My, this thing runs quiet!

5 Responses to “Fun with Gentoo on the VIA C3”

  1. Reupbert Says:

    This article was very useful to me in identifying why Gentoo 2005.1 was kernel panicking on my VIA C3 system. Thanks.

  2. Kim Sönksen Says:

    Thanks for the blog! It helped me to fix my gentoo 2005.1 installation trouble. But a addiotional hint: You do not need to use another live-cd, the gentoo cd’s are compiled for x86 IMHO. Booting from the standard live-cd and using a x86-stage archive worked fine for me.

  3. Pellaeon Says:

    Just another thank you for providing the hint that gor my Via system running Gentoo! Booting the standard x86 live-cd worked for me too; I had to install through a stage 1 tarball though, as that was the only non-i686 tarball present. For those in a similar need, this url may be of use:
    http://gentoo-wiki.com/HOWTO_Install_Gentoo_-_The_Gentoo_Developers_Method_with_NPTL_and_2.6_from_Stage1

  4. Shaun Osborne Says:

    I found a great howto that covers all this including the new kernels and all. I am on day 3 of the compiling, though, and am going to never do one of these little systems again with distcc and compiling on multiple machines. What an ordeal!!!
    http://linuxreviews.org/gentoo/Installing_Gentoo_Knoppix/

  5. Doomtrain Says:

    This article has saved me befor using genkernel…
    Thank you very much, it works as well with gentoo 2008.0 (I used the Minimal CD for installing, there you have no chroot problems)

Leave a Reply



Akismet has protected Bravo November from 126,697 spam comments.