FreeBSD Geode Resources

This is an ``unofficial'' page containing information supporting the use of the FreeBSD (and PicoBSD) operating system on the National Semiconductor Geode CPU. The intent of this page is to serve as an unofficial index of available web resources related to FreeBSD on the Geode.


Contents:

Introduction (about this page).

Installation kits (downloadable installation media).

FreeBSD 4.7 installation CD #1 and boot floppies (with Geode patches).

FreeBSD Kernel Patches for Geode platforms.

Patching FreeBSD 5.0-Current for the GX1.

TSC patch
Video nonlongword aligned bcopy patch
INT 15/E820 patch

Patching FreeBSD 4.x-Stable for the GX1.

TSC patch
Video nonlongword aligned bcopy patch


Drivers

FreeBSD PCM Native Audio Driver for NatSemi Geode GX1
Old XFree86 Geode driver (now replaced by ``nsc'' driver.
Old cyrix driver.


Platform configuration notes

Building FreeBSD 5.0-Current for the GX1.
Building FreeBSD 4.x-Stable for the GX1.

Building 5.0-Current PicoBSD for the GX1.
Building 4.x-Stable PicoBSD for the GX1.


Thin Client Notes
Diskless FreeBSD on the Aries

Using Compact Flash boot media with the Geode

Using the Compact Flash on the Dorado.
Initializing a Compact Flash for use as a FreeBSD disk.


Documentation

FreeBSD e-mail
XFree86 (nsc video driver) e-mail

Other links of interest

See also the FreeBSD Resources page at this site and the Home page.


Introduction (about this page)

This kit enables FreeBSD to be used on GX1-based systems. In particular, this kit has been used to run FreeBSD and PicoBSD on the National Semiconductor Centaurus II, Centaurus I, Aries, and Dorado platforms.

The Centaurus II is a general-purpose PC development platform for the GX1 and associated National chips. The Dorado is a Thin-Client development platform for System-on-a-Chip GX1-based chipsets.

The included patches enable both FreeBSD Stable (4.x) and FreeBSD Current (5.x), as well as the PicoBSD variations of both, to run on the Centaurus II and Dorado. (PicoBSD is a stripped-down diskless build of FreeBSD).

Without the patches described here, FreeBSD will not boot on the GX1 platforms. Specifically, standard FreeBSD release kits (downloaded or as distributed on CD-ROM) will not run.

This kit contains a FreeBSD-specific audio driver for the audio device integrated into the CS5530 GX1 I/O companion. This kit also includes instructions for using the "geode" driver for the GX1 native video hardware, which is now included in the XFree86 master CVS source tree. A second open source driver for the GX1 native video (a small driver based on the original "cyrix" XFree86 video driver) is also included.

This kit contains support documentation for use with the development kits. This kit does not serve as a FreeBSD tutorial or describe tasks such as basic FreeBSD system installation. However, links to a number of such resources are included in the documentation section.


Installation kits (downloadable installation media).

FreeBSD 4.7 Release for Geode. (This installation CD and boot floppies contains two kernel patches required to boot and run on National Semiconductor Reference platforms. Some motherboards using Geode will not likely require these patches, that is, on some motherboards the standard FreeBSD installation will boot and run).

Installation Boot Floppy #1

Installation Boot Floppy #2

Installation CD#1


Patches

To run FreeBSD 5.0-current, three patches to the FreeBSD source are required. To run FreeBSD 4.x-stable, two of these patches are required.

Patching FreeBSD 5.0-Current for the GX1.

There are three manual patches that need to be applied to the FreeBSD 5.0-Curent sources to enable FreeBSD/PicoBSD to run on the Centaurus/Geode motherboard. These patches are:

[1] Use the 8254 chip instead of the CPU's TSC (TimeStamp Counter) register as the clock. If the TSC register is used, the clock will be much slower than is useful, off by at least a factor of ten. This causes anything that does a tsleep() to ``stall'', resulting in the system being almost unusable.

TSC patch instructions (clock.c).

[2] Modify generic_bcopy() to use byte-moves, not long-moves. The FreeBSD generic_bcopy() routine uses a rep movsl instruction. The initial address passed to generic_bcopy() is sometimes non-long-aligned. This should work, but on the GX1 platfroms it hangs. On older Centaurus boards, this problem could be generated by typing backspace. On the current development platforms running 5.0, the system will simply hang doing console I/O.

Byte-aligned bcopy patch (support.s).

[3] Remove use of an INT 15/AX=E820h BIOS trap from VM86 mode. This trap determines physical memory size and layout. FreeBSD 5.0-Current uses this INT 15 to size physical memory, but will fall back to an earlier memory-sizing scheme if this trap fails. This INT 15 trap on the GX1 development platforms generates a fatal page fault.

VM86 INT 15/E820h patch (machdep.c).

The INT 15 patch is not required on FreeBSD 4.x-Stable systems.


FreeBSD 5.0-current TSC patch (clock.c)


Using the 8254 timer instead of the TSC.

In file:

 /usr/src/sys/i386/isa/clock.c


If the following code occurs at the end of routine startrtclock(), replace this code:

        init_TSC();
}

with this new code:

        /* init_TSC(); */
}


If the following code occurs at the end of routine startrtclock(), replace this code:

        if (tsc_present && tsc_freq != 0 && !tsc_is_broken) {
                tsc_timecounter.tc_frequency = tsc_freq;
                tc_init(&tsc_timecounter);
        }

with this new code:

/*---- BRM -- Dont use TSC. ----*/
#if 0
        if (tsc_present && tsc_freq != 0 && !tsc_is_broken) {
                tsc_timecounter.tc_frequency = tsc_freq;
                tc_init(&tsc_timecounter);
        }
#endif

Source code prior to February 2003 will require this version of the patch.


What this does is keep the virtual real-time clock that corresponds to the TSC from running.

FreeBSD can use multiple real-time clock devices. Each device corresponds to a virtualized ``timecounter''. The last ``timercounter'' initialized is used by the system to perform delta-time delays such as those required by the all-important ``tsleep()'' function.

Simply commenting out the TSC ``tc_init()'' call has the effect of causing the previously initialized 8254 timer chip to be used for system delta-time operations. Further investigation into why this problem occurs and is not detected (``tsc_is_broken'') is warranted.


Byte-alinged generic_bcopy patch (support.s)

Writing to Video Memory

In file:

/usr/src/sys/i386/i386/support.s

Replace this code:

ENTRY(generic_bcopy)
        pushl   %esi
        pushl   %edi
        movl    12(%esp),%esi
        movl    16(%esp),%edi
        movl    20(%esp),%ecx

        movl    %edi,%eax
        subl    %esi,%eax
        cmpl    %ecx,%eax        /* overlapping && src < dst? */
        jb      1f

        shrl    $2,%ecx          /* copy by 32-bit words */
        cld                      /* nope, copy forwards */
        rep
        movsl

        movl    20(%esp),%ecx
        andl    $3,%ecx          /* any bytes left? */

        rep
        movsb

        popl    %edi
        popl    %esi
        ret

With this new code:

ENTRY(generic_bcopy)
        pushl   %esi
        pushl   %edi
        movl    12(%esp),%esi
        movl    16(%esp),%edi
        movl    20(%esp),%ecx

        movl    %edi,%eax
        subl    %esi,%eax
        cmpl    %ecx,%eax        /* overlapping && src < dst? */
        jb      1f


#if 0
        shrl    $2,%ecx          /* copy by 32-bit words */
        cld                      /* nope, copy forwards */
        rep
        movsl

        movl    20(%esp),%ecx
        andl    $3,%ecx          /* any bytes left? */
#else
        cld                /* BRM */
#endif
        rep
        movsb

        popl    %edi
        popl    %esi
        ret

What this does is eliminate an attempt to use a repeated move-word instruction loop as an optimization. Instead the entire string of bytes to be copied is simply copied using the repeated move-byte instruction that normally just handles the bytes in the last word.

This fix is required because of a call in file:

 /usr/src/sys/dev/syscons/scvtb.c

Routine sc_vtb_copy() calls bcopy_toio() on an odd-address when the bytes that comprise the video memory are blitted after a backspace. This mis-aligned move-word should exact a performace penalty, but should not hang the system (early Centaurus boards generate a bad SMI).


FreeBSD 5.0-current patch to not use INT 15/E820 (machdep.c)

In file:

/usr/src/sys/i386/i386/machdep.c

In routine getmemsize(), replace this code:

      i = vm86_datacall(0x15, &vmf, &vmc );

With this new code:

#if 0
      i = vm86_datacall(0x15, &vmf, &vmc );
#else
      i = 1;
#endif

There is only a single vm86_datacall() in getmemsize().

This eliminate the attempt to use the INT 15/E820.

Patching FreeBSD 4.x-Stable for the GX1.

There are two manual patches that need to be applied to the FreeBSD 4.x-Stable sources to enable FreeBSD/PicoBSD to run on GX1 systems. These patches are:

[1] Use the 8254 chip instead of the CPU's TSC (TimeStamp Counter) register as the clock. If the TSC register is used, the clock will be much slower than is useful, off by at least a factor of ten. This causes anything that does a tsleep() to ``stall'', resulting in the system being almost unusable.

TSC patch instructions (clock.c).

[2] Modify generic_bcopy() to use byte-moves, not long-moves. The FreeBSD generic_bcopy() routine uses a rep movsl instruction. The initial address passed to generic_bcopy() is sometimes non-long-aligned. This should work, but on the GX1 platfroms it hangs. On older Centaurus boards, this problem could be generated by typing backspace. On the current development platforms running 5.0, the system will simply hang doing console I/O.

Byte-aligned bcopy patch (support.s).


FreeBSD 4.x-Stable TSC patch (clock.c)


Using the 8254 timer instead of the TSC.

In file:

 /usr/src/sys/i386/isa/clock.c

At the end of routine startrtclock(), replace this code:

        if (tsc_present && tsc_freq != 0 && !tsc_is_broken) {
                tsc_timecounter.tc_frequency = tsc_freq;
                init_timecounter(&tsc_timecounter);
        }

with this new code:

/*---- BRM -- Dont use TSC. ----*/
#if 0
        if (tsc_present && tsc_freq != 0 && !tsc_is_broken) {
                tsc_timecounter.tc_frequency = tsc_freq;
                init_timecounter(&tsc_timecounter);
        }
#endif

What this does is keep the virtual real-time clock that corresponds to the TSC from running.

FreeBSD can use multiple real-time clock devices. Each device corresponds to a virtualized ``timecounter''. The last ``timercounter'' initialized is used by the system to perform delta-time delays such as those required by the all-important ``tsleep()'' function.

Simply commenting out the TSC ``init_timecounter()'' call has the effect of causing the previously initialized 8254 timer chip to be used for system delta-time operations. Further investigation into why this problem occurs and is not detected (``tsc_is_broken'') is warranted.


Drivers

FreeBSD Geode GX1 Native Audio Driver Kit

The following video drivers are available. You should always obtains these from the Xfree86 cvs repository instead of here.

The XFree86 "Geode" GX1 Native Video Driver. (files)

The "cyrix" GX1 Native Video Driver. (files)


FreeBSD configuration on some Geode reference platforms

The following build instructions exist:

Building FreeBSD 5.0-Current for the GX1.
Building FreeBSD 4.x-Stable for the GX1.

Building 5.0-Current PicoBSD for the GX1.
Building 4.x-Stable PicoBSD for the GX1.

Diskless FreeBSD on the Aries


Building FreeBSD 5.0-CURRENT for GX1-based Systems

Contents:

- GEODE sample kernel configuration file.
- Patched FreeBSD 5.0-Current source files.


Building FreeBSD 4.6-Stable for GX1-based Systems

Contents:

- GEODE sample kernel configuration file.
- Patched FreeBSD 4.6-stable source files.


Building PicoBSD 5.0-CURRENT for GX1-based Systems

Contents:

Patches:

- Patch to the picobsd script - newfs. ( freebsd mailing list)
- Patch to the picobsd script - remove perl. ( freebsd mailing list)

- Patch to PICOBSD bridge reference system for bootable floppy. ( freebsd mailing list)

Files:
- PICOBSD sample kernel configuration file.
- PICOBSD sample crunch file.

- PicoBSD 5.0-Current files.


Building PicoBSD 4-7 Stable for GX1-based Systems

Contents:

- Building PicoBSD for the Centaurus II.

- Patching the standard ``bridge'' configruation.

- PICOBSD sample kernel configuration file.
- PICOBSD sample crunch file.

- PicoBSD 4.6-Stable files.


Building picobsd for the Centaurus II.

To build a ``starter'' PicoBSD system for the Centaurus II, start with the standard ``bridge'' configuration. To use the standard 4.6-Stable ``bridge'' Picobsd configuration:

 #cp -R /usr/src/release/picobsd/bridge .
 #cd bridge

 (Edit ``crunch.conf'' and PICOBSD if
  desired - you will likely need the ``crunch.conf''
  patches below.)

 #cd ..
 #picobsd bridge

Patches:

The released 4.6-standard bridge ``crunch.conf'' assumes the ssh port has been installed.

The Patch to the released 4.6-stable bridge crunch file:

--- /usr/src/release/picobsd/bridge/crunch.conf Fri Apr 19 05:42:51 2002
+++ crunch.conf Tue Nov 12 17:01:03 2002
@@ -87,7 +87,7 @@
 #progs less # 36KB
 #ln less more
 #progs more # 24KB
-special more srcdir /usr/ports/misc/44bsd-more/work
+#special more srcdir /usr/ports/misc/44bsd-more/work

 progs sysctl
 progs swapon # 0KB.
@@ -122,7 +122,7 @@
 # libs -lcurses # for vi

 #progs tcpdump # 100KB.
-special tcpdump srcdir /usr/src/usr.sbin/tcpdump/tcpdump
+#special tcpdump srcdir /usr/src/usr.sbin/tcpdump/tcpdump

 progs arp # 0KB.

@@ -158,13 +158,13 @@

 # Check the ssh license! If you want to use this,
 # go to /usr/ports/security/ssh-picobsd, do a make extract configure
-progs sshd     # includes ssh and scp
-special sshd objvar SSHD_OBJS
-special sshd srcdir /usr/ports/picobsd/ssh-picobsd/work/ssh-1.2.27
-special sshd objdir /usr/ports/picobsd/ssh-picobsd/work/ssh-1.2.27
-ln sshd ssh
-ln sshd ssh1
-ln sshd scp
+#progs sshd    # includes ssh and scp
+#special sshd objvar SSHD_OBJS
+#special sshd srcdir /usr/ports/picobsd/ssh-picobsd/work/ssh-1.2.27
+#special sshd objdir /usr/ports/picobsd/ssh-picobsd/work/ssh-1.2.27
+#ln sshd ssh
+#ln sshd ssh1
+#ln sshd scp

 ### ee uses ncurses instead of curses
 libs -ledit -lutil -lmd -lcrypt -lmp -lgmp -lm -lkvm

Using Compact Flash boot media with the Geode

Using the Compact Flash FreeBSD on the Dorado.

Initializing a Compact Flash for use as a FreeBSD disk.


Using the Compact Flash FreeBSD on the Dorado.

Identify Jumpers J14 and J68 on the Dorado motherboard.

J14 is a 3-pin jumper that is the closest jumper to the Compact Flash connector.

J68 is directly adjacent to the Disk-On-Chip.

Strap J14 so that the CF is master and any HDD the slave, that is, strap pins 1-2:

 1-2   Connected  (CF is Master)
 2-3   Open

Pin 1 on J14 is the pin closest to the CF.

J68 should have pins 7-8 and pings 9-10 unstrapped. Typically, only pins 1-2 on J68 need be strapped. Pin 7-8 is the DOC-chip select-enable. Remove it to boot from CF. Pins 9-10 need to be unstrapped to disable the DOC and boot from the CF.


Initializing Compact Flash Media for use with the Dorado.

This section describes how to work with a Compact Flash (CF) device on the Dorado as the only FreeBSD ``disk'' device. Compact Flash media are widely available, and can often be found wherever digital camera equipment is sold. The examples below assume a common CF media sold by SanDisk.

Beware, that most CF devices cannot be ``hot-swapped'', that is, cannot be removed or inserted while the power is on.

You can use a device such as the ``Microtech CardMaster ISA-to-PCMCIA PC Card reader/writer'' in the Centaurus II, or other PC, to write a Compact Flash that can be used in the Dorado. To initialize a Compact Flash using an ISA->CF Microtech adapter in the Centaurus II, do the following:

In ``/etc/defaults/pccard.conf'' assure the following entry exists:

# SunDisk Flash ATA
# (SanDisk)
card "SunDisk" "SDP"
        config  0x1 "ata" ?
        insert echo SanDisk Insert
        remove echo SanDisk Remove

(However, see below for additional information regarding the CIS information for SanDisk. SanDisk has recently changed the erroneous ``SunDisk'' entry to ``SanDisk''.)

In ``/etc/rc.conf'':

#
pccard_enable="YES"
pccard_mem="DEFAULT"

Check dmesg for:

pccard0:  on pcic2
pccard1:  on pcic2

...

ad6: 30MB  [490/4/32] at ata3-master BIOSPIO

Reboot and issue the command:

>pccardc dumpcis

The dumpcis command should diplay voluminious output, including:

Tuple #5, code = 0x15 (Version 1 info), length = 23
    000:  04 01 53 75 6e 44 69 73 6b 00 53 44 50 00 35 2f
    010:  33 20 30 2e 36 00 ff
        Version = 4.1, Manuf = [SunDisk], card vers = [SDP]
        Addit. info = [5/3 0.6]

At this point, output from the command:

>cat /var/log/messages

should include near the tail:

Aug 12 15:13:46 centaurus /kernel: pccard: card inserted, slot 0
Aug 12 15:13:49 centaurus pccardd[49]: Card "SunDisk"("SDP") [5/3 0.6] [(null)]
matched "SunDisk" ("SDP") [(null)] [(null)]
Aug 12 15:13:55 centaurus /kernel: ata3 at port 0x240-0x247,0x24e irq 5 slot 0 on pccard0
Aug 12 15:13:55 centaurus /kernel: ad6: 30MB  [490/4/32] at at a3-master BIOSPIO
Aug 12 15:13:55 centaurus pccardd[49]: ata3: SunDisk (SDP) inserted.
Aug 12 15:13:55 centaurus pccardd[49]: pccardd started

The specific device may vary, depending on your configuration. For instance, you may see ad8 instead of ad6.


The following line should appear in /var/log/messages:

Aug 12 15:13:55 centaurus /kernel: ad6: 30MB  [490/4/32] at at a3-master BIOSPIO

If this line does not appear in ``/var/log/messages'', check the information in config file ``/etc/defaults/pccard.conf''. The CIS information in the device likely does not match the information in the config file.

Display the contents of the device CIS using the ``pccardc dumpcis'' command as described above. Match the information with the ``/etc/defaults/pccardc.conf'' information, use the ``Manuf'' and vendors card version information. For a SanDisk, this might appear as follows:

Manuf = [SunDisk], card vers = [SDP]
SanDisk, for instance, has devices that contain both ``SunDisk'' as the manufacturer, as well as ``SanDisk''. You may have to create ``pccard.conf entries for both. card "SanDisk" "SDP" config 0x1 "ata" ? card "SunDisk" "SDP" config 0x1 "ata" ? You may have to create device nodes for the CF device. In this case, use a command of the form: cd /dev sh MAKEDEV ad8 In some cases (this should no longer be necessary) it may be useful to pccardc enabler 0 ad6 To displa the, The command fdisk -s ad8

Again, your CF device name may vary. In the following examples, device node ad6 is used.

The CF my already have a valid MBR, in which case you may not want to destroy it. Now zero the first 100 512-byte sectors of the Compact Flash:

>su
#dd if=/dev/zero of=/dev/ad6 count=100
100+0 records in
100+0 records out
51200 bytes transferred in 0.285553 secs (179301 bytes/sec)
fdisk: invalid fdisk partition table found

Write the bootsector, use only 1 slice (ignore error about existing "invalid fdisk partition"; none yet exists).

# fdisk -BI ad6
******* Working on device /dev/ad6 *******

Write a Unix volume label (with *ix partition info):

#disklabel -w -B ad6s1 auto
Aug 12 15:41:10 centaurus /kernel: ad6: cannot find label (no disk label)
Aug 12 15:41:10 centaurus /kernel: ad6s1: cannot find label (no disk label)
Aug 12 15:41:10 centaurus /kernel: ad6: cannot find label (no disk label)
Aug 12 15:41:10 centaurus /kernel: ad6s1: cannot find label (no disk label)

Display the label:

#disklabel -e ad6s1
# /dev/ad6s1c:
type: unknown
disk: amnesiac
label:
flags:
bytes/sector: 512
sectors/track: 32
tracks/cylinder: 4
sectors/cylinder: 128
cylinders: 489
sectors/unit: 62688
rpm: 3600
interleave: 1
trackskew: 0
cylinderskew: 0
headswitch: 0           # milliseconds
track-to-track seek: 0  # milliseconds
drivedata: 0
8 partitions:
#        size   offset    fstype   [fsize bsize bps/cpg]
  c:    62688        0    unused        0     0         # (Cyl.    0 - 489*)
~


8 partitions:
#        size   offset    fstype   [fsize bsize bps/cpg]
  a:    62688        0    4.2BSD        0     0         # (Cyl.    0 - 489*)
  c:    62688        0    unused        0     0         # (Cyl.    0 - 489*)
----------------------------------

Now create a filesystem on the Compact Flash:

#newfs -b 8192 -f 1024 /dev/ad6s1a
Warning: Block size restricts cylinders per group to 23.
Warning: 2848 sector(s) in last cylinder unallocated
/dev/ad6s1a:    62688 sectors in 16 cylinders of 1 tracks, 4096 sectors
        30.6MB in 1 cyl groups (23 c/g, 46.00MB/g, 7680 i/g)
super-block backups (for fsck -b #) at:
 32

At this point you should be able to mount the Compact Flash as if it were a normal disk device:

#mount /dev/ad6s1a /mnt

Documentation


Index of Geode/FreeBSD Relevant e-mail

XFree86 Geode (``nsc'') video driver e-mails

http://www.mail-archive.com/devel%40xfree86.org/msg00967.html
National Semiconductors GX1 & Xv -- bug?

http://www.mail-archive.com/devel%40xfree86.org/msg00455.html
Patch-for mode bug in NSC driver.

http://www.mail-archive.com/devel%40xfree86.org/msg00454.html
Patching nsc_drv to allow low-res video modes

FreeBSD Geode e-mails

Re: NS Geode GX1- 300MHz compatible?


Links of Interest

General FreeBSD pages.










brucem@mail.cruzio.com
Copyright (c) 2003, Bruce R. Montague