Carputer Progress

From GrinningMonkey

Contents

Hardware

What I have so far

  • The PC (VIA Nehemiah 1GHz w/ 512MB RAM, car-friendly powersupply)
  • Wireless card (although I need to get a new one that's 802.11G and has a plug for an external antenna)
  • Alphagrip keyboard and mouse
  • Gyrations keyboard and mouse
  • Garmin eMap GPS
  • ElmScan 5 OBDII interface
  • Xenarc 700YV 7" TFT LCD screen (friendly powersupply, NO touchscreen)
  • 120VAC -> 12VDC power adapter w/ cigarette lighter interface


Hardware DONE

  • Wired the PC so that it has a switch which simulates the ignition
    (the PC has 12VDC which is always active, plus a switched 12VDC from the ignition. It turns on 5s after you turn the ignition -- enough time to crank/start the engine -- and when you turn the ignition off, the PC is given 2m to turn itself off gracefully)
  • Wired the PC to run off of a cigarette lighter, so that I can easily work on it in the car or elsewhere
    I have an old Coleman thermoelectric fridge. It stopped working (fan died) and I decided I'd rip it apart to use its wires. As a result, when I plug in the carputer, I always have to make sure that I set the plug to "COLD" d:) See the Thermo-Cup page for details on my plans to re-use the thermoelectric module from the fridge.


Hardware TODO

  • Re-wire the GPS so it can be turned on through software (parallel port?)
  • Wire up an extra COM port (the main board can have four, but I need to get some cables and plugs ... I can rip these out of any old computer)
  • Wire up a parallel port, too (again, the main board has connections for it, but it's not part of the basic form factor)


Infrastructure

I'm defining infrastructure as all the operating system and software stuff that's not part of the actual TruxII software.

Most of the software will be built using Perl and Qt, although there will be some low-level drivers written in C.

The production infrastructure will be optimized for boot speed:

Kernel 
The kernel will be compiled with only the modules required for this particular machine, and with the right components built-in so as to avoid having to use an initial ramdisk.
Booting 
The init process will be stripped-down and customized to minimize the time required to boot.
Graphics 
The production environment will (probably) use Xorg/X11, although QtEmbedded is not out of the question (I think it will be too painful)


Experimentation

For the time being, I'm experimenting. The goal of my experimentation is to get:


PHASE 1

Phase 1 is almost purely experimentation. Installing different OSes, compiling kernels over and over again, building X, etc.

Goals:

  • All the patches for the kernel that I need
  • Text mode matching resolution w/ graphics mode Too difficult as VESA doesn't support the resolution and SVGATextMode is giving weird results
  • Xorg/X11 up and running
    • With the drivers and customization necessary for 800x480 resolution
    • And with Direct Rendering working working properly
  • Set up a simple window manager and play with it a bit
  • A simple proof-of-concept sequence to test dependencies. This will probably be:
    • A small bit of Perl/Qt that displays the engine RPM on a Qwt gauge/graph
    • MP3s playing under X probably using ALSA
    • Wireless up and running

At the end of phase 1 I should have a documented process for getting everything above working -- a start-from-scratch sequence.


PHASE 2

Phase 2 is about stripping things down.

  • Strip the unneccessary stuff out of the kernel
    • Test the proof-of-concept sequence. Everything still works, right?
  • Rebuild X so that it starts quickly
    • Loads a window manager like fvwm or wm2 (no bloated Gnome or desktop or virtual desktop)

At the end of phase 2 I should have a documented process for the above, so that I can do it over and over again if necessary.


PHASE 3

Phase 3 is about setting up a stripped-down system. I've set up the box with a 50MB /boot partition, a 15GB / partition, and a 5GB un-mounted partition. It is the un-mounted partition that I'll use as the root filesystem for an alternative kernel.

At the end of phase three, I should have (a) a minimal kernel that (b) uses a minimal boot sequence to (c) get into a minimal X that is running the proof of concept sequence above.

And, of course, a documented process to get here.


Once I get to this point I will be confident in my fast-boot setup, and I will concentrate on developing the Perl/Qt software. I anticipate that I'll need to add new other bits of software over time (e.g. a set of applications and libraries to play video files) and I should be able to move the required libraries and binarys from the main partition to the stripped-down one as needed (with documentation updates).


Kernel

For now, I've got the hard disk partitioned with a 50MB /boot partition, a 15GB main partition, and a 5GB fastboot partition. One boot sequence loads a normal, stock-ish kernel, boots into the main partition, and acts like any other computer. The other will boot a highly trimmed down kernel and boot into the fastboot partition. Here the bootup sequence will be trimmed and specialized to get the computer up and running as quickly as possible.

Right now, I'm playing with building kernels, turning things off, compiling modules into the kernel, etc. I hope to learn about:

Initial ramdisks 
End goal is to compile a kernel with the necessary modules built into the kernel, so that no ramdisk is necessary (speed up boot)
EPIA patches 
I found a bunch of patches to support the video card and some other stuff this system has. These might already be in later stock kernels like 2.6.15, so I need to grab the latest kernel and see. UPDATE 20060318: EPIA patches maybe not necessary since DRM and DRI are now compiled from DRM/Mesa via Xorg Monolithic.


Kernel DONE

  • Tried Debian's kernel and packaging system. Not bad, but very slow because each re-build needs to rebuild the entire kernel (make clean; make).
  • Built linux 2.6.8.1 kernel from kernel.org using debian's .config. Works great.
  • Patched above with EPIA patches. Works fine.


Kernel TODO

  • Tried the latest 2.8.15.1 kernel, it didn't work right out of the box like 2.6.8.1 always seems to do, and since 2.6.8.1 does what I need, I don't see a need to waste time on that now.
  • Begin stripping things out of the kernel.


Kernel PROCESS

  • Grab linux-2.6.8.1 from ftp://ftp.kernel.org
  • Pull in the configuration file /boot/config-2.6.8(?) from the debian 2.6.8 kernel; doing a make oldconfig doesn't seem to be necessary
  • Apply the EPIA patch
  • make menuconfig and change:
    • Processor = Via C3 Nehemiah
    • Turn on the VIA DRM driver (Device drivers → Character devices) UPDATE 20060318: Don't do this! (see below)

(that's all I've got for now... )


Screen resolution

This screen has a weird resolution (800x480). It can handle other normal resolutions like 640x480 and 1024x768, but there's two problems:

  1. Sometimes it misjudges the incoming resolution, resulting in some stuff chopped off the screen
  2. It takes something like half a second to switch between resolutions

Ultimately, I want to be able to boot up so that both the text and X11 modes use the exact same resolution.


UPDATE 20060316-20h30: this is turning into a real PITA

It turns out that the default via driver doesn't like the 800x480 resolution

It ALSO turns out that there's apparently some setting in the BIOS for resolutions, which doesn't include this one

Some searching on the 'net found me this: http://www.mp3car.com/vbulletin/showthread.php?t=48529 which is instructions on how to build a different VIA driver which WILL support this funky resolution under X. This seems to have worked, I now have 800x480 in X.


Screen resolution DONE

  • I wanted to make it so that the kernel would boot in framebuffer mode using 800x480 (native resolution of the screen I have) but turns out that booting this way, you only get a few resolutions and 800x480 isn't one of them.
  • I have X running in 800x480
  • I can't get textmode to use the same resolution
    • Same specifications produce different results
    • Wide (100x30) is more than 80xWhatever and has wrapping issues
  • I did find that using 80x32, which uses 640x480 graphics instead of 640x400, seems to be more reliable as far as chopping is concerned, so I'll just go with that for the text resolution


Screen resolution TODO


Screen resolution PROCESS

Process for building a VIA driver that does 800x480:

  • Ensure apt-get cache up to date apt-get update; apt-get dist-upgrade
  • Get sources for xfree86: mkdir tempdir; cd tempdir; apt-get sources xfree86
  • Get stuff you need to build xfree86: apt-get build-dep xfree86
  • Start building: cd xfree86...blah; dpkg-buildpackage
  • This takes a long time, but when you can cd xfree86-blahblah/build-tree/xc/programs/Xserver/hw/xfree86/drivers/via and make works with no errors, you can abort the build
  • Get norm@guinness:DOWNLOADS/via_driver.tgz I already modified the ViaDotClock[] array to include two needed dotclocks
  • Do cd xfree86-blahblah/build-tree/xc/programs/Xserver/hw/xfree86/drivers; mv via/ via_old/; mv xfree86/ via/; make Makefiles
  • Make the driver: cd via; make
  • Install the driver: cp via_drv.o /usr/X11R6/lib/modules/drivers

Use one of these Modelines in your XF86Config-4 file:

(from Xenarc) -- avoid this one, weird unsupported clockrate
Modeline "800x480" 31.746 800 860 940 1000 480 508 511 525 -hsync -vsync #31.746MHz 32.26kHz 63Hz
  
or
 
(from mp3Car Forums -- eliminates waviness)
Modeline "800x480" 40.00 800 848 976 1056 480 637 641 672 -hsync -vsync  #40.00MHz 39.68kHz 78Hz


Xorg/X11

UPDATE 20060317: Getting DRI working is also a PITA

There are a few things needed for DRI:

  1. AGP support in the kernel (agpgart)
  2. AGP video card driver, kernel (via_agp)
  3. DRM in the kernel
    • In 2.6.8.1 this is an older DRM version (1.3)
    • So need a newer version (comes with Xorg Monolithic, see below d:)
  4. DRM video card driver, kernel (also comes with Xorg d:)
  5. DRI for video card (unichrome_dri.so ... comes with Mesa, which comes with Xorg d:)


X DONE

  • Rebuilt Xorg 6.9 from sources (no trouble at all!)
  • Got 800x480 resolution working (no trouble at all! Xorg's 6.9 driver is fine)
  • Got direct rendering working after a bit of recompiling


X TODO

  • Try to rebuild X, including DRI and Mesa and whatever, from sources
  • Get 800x480 resolution working
  • Get direct rendering working
  • Start minimizing X


X PROCESS

Xorg: Download the Xorg 6.9 Monolithic distribution

  • make World > world.org 2>&1
  • tail -f world.org from another window
  • make install; make install.man
  • Configure the /etc/X11/xorg.conf file

800x480: No problem! Just use the right modeline: Modeline "800x480" 41.164 800 848 976 1056 480 637 641 672 -hsync -vsync

Provide a backup of xorg.conf here

Direct Rendering (build Xorg 6.9 Monolithic, first!):

  1. Kernel stuff:
    • Turn OFF DRM in the kernel (shoulda done this earlier... see above)
    • Build the DRM stuff from Xorg
      cd xc/extras/drm/linux-core
      make DRM_MODULES="via"
      mkdir /lib/modules/<KERNEL>/kernel/drivers/char/drm 
      cp /usr/src/drm-unichrome/drm/linux-core/*.ko  /lib/modules/<KERNEL>/kernel/drivers/char/drm/
      depmod -a
    • May need to find a way to autoload these if they don't get loaded when X starts, haven't tried yet
  2. Mesa stuff:
    • Go into xc/extras/Mesa
    • Check configs/cf/linux-dri and ensure that unichrome is in the DRI_DIRS= list
    • Do make linux-dri (not sure, test and see if OK to just make/make install EVERYTHING... also note that my 'make' process here got stuck in a loop building the drivers... afterwards, just went to the unichrome driver and did make install


Software


Rebuilding process

As development and testing and trying and stuff happens, the system gets more and more tainted from trial and error stuff. Therefore, its' nice to keep track of the things that worked so when you go to build a clean system, you know what to do. Here's the process I have so far:


Installing initial Debian

  • PXEBoot from my laptop and install debian over the laptop
    • Remove unneeded packages
    • Turn useless stuff off from boot sequence


Compiling the kernels

  • Download the latest stock kernel
    • Make two copies, one trux-main, one trux-fastboot
    • Configure trux-main
      • What options? (processor, epia)
    • Strip useless stuff out of trux-fastboot kernel