HomeDaemon Embedded


Ok, so you've seen the HomeDaemon package, but are not really interested in having to buy and run a "PC" with Unix on it.

What if I told you that you could buy a roughly $500 piece of hardware that was completely disk and fanless, yet would run HomeDaemon - and was only the size of a largish book?

Yes, you read that right - a machine that requires less than 40 watts of power, has a solid state disk, still runs Unix, and will run HomeDaemon!

That's the computer. Its smaller than it looks!

I ordered it with two serial ports, which is an option in the obvious place. It comes with an Ethernet connector, a VGA connector, one front panel and one rear panel USB connector.

I equipped it with a "horizontal Disk-On-Module", which amounts to a 4GB disk drive that is comprised of flash memory. That was surprisingly inexpensive - under $100.

This gives you a totally fanless, diskless, zero-moving parts system.

The first thing to do is download FreeBSD 7.x from http://www.freebsd.org and make an installation disk. This is simply a CDROM. You will need a USB CDROM Drive in order to install the software, as of course this machine has no CD drive. If you don't have one, borrow it - you'll only need it once.

The system installation is entirely typical; nothing special need be done. Select a "Typical User" configuration. I recommend strongly that you partition the system into two filesystems, / (root) and /var; the latter contains most of the "writeable" files. Also, make sure you set soft updates, as this greatly reduces the risk of a reboot failing due to needing a manual disk cleaning operation. Start the "ssh" function so you can log into the machine from a Windows (or other Unix) box when you're done. Do not define a swap partition! It is critical that the system not write any more frequently to the NVRAM than necessary, and a swap partition encourages this. This will generate a warning; ignore it.

My recommendation with a 4GB disk is to partition it with 2GB for root (/) and 2GB for /var.

Once the system is installed and running you need to make a few changes in order to be "friendly" to the disk on module (Flash), as flash memory does have a maximum write-cycle life. We also want to load a few packages in order to enhance functionality.

Use "sysinstall"'s package feature to load the Festival Speech Synthesis system and apache web server. You need the following:

You can load other voices if you'd like; "kal" and "ked" are the two that I usually use.

The next order of business is to create the "xten" user ID and a "HomeDaemon" user ID; you can use the "adduser" function to do this. Make sure "homedaemon" is added to the "wheel" group so that it can use the "su" fucntion to gain root privileges!

You must also create "hamx10" as a port definition in /etc/services; this looks like this:

hamx10		50000/tcp

This is necessary if you intend to use the X10 protocol (Dan Lancini's X10d code)

Next, you need to make some changes to the system in order to make it "friendly" to the disk. Specifically, we're going to:

First things first - we edit the system startup files to create the memory disk and mount it, along with a few other things. Edit /etc/rc.local to read:

HomeDaemon# cat /etc/rc.local
#
# Local stuff
#
/sbin/mdconfig -a -t malloc -s 100m -u 10
newfs -U /dev/md10
mount /dev/md10 /var/log
/usr/sbin/mixer vol 100

These lines configure a 100mb RAMDISK, make it a filesystem, and then mount it. Move /var/log out of the way (mv /var/log /var/log.saved), create a new empty /var/log with "mkdir /var/log" and reboot. Once you've rebooted you can remove the "/var/log.saved" with "rm -r /var/log.save". The last line sets the "mixer" final volume for the audio output to 100%.

Now edit the /etc/rc.d/local file; at the top there is a block of text. Change the "BEFORE:" line to add "syslogd" as shown. This makes sure that the rc.local file gets run before the system logger (which writes in /var/log) starts.

#!/bin/sh
#
# $FreeBSD: src/etc/rc.d/local,v 1.6.14.1 2008/01/28 07:58:31 dougb Exp $
#
# PROVIDE: local
# REQUIRE: DAEMON
# BEFORE: LOGIN syslogd
# KEYWORD: shutdown
 

Next, we are going to turn off "atime" on our mounted filesystems. This is because by default Unix will actually update the inode (disk directory entry) of a file on every read to keep track of the "access time." Again, we don't want to write to the NVRAM more than we have to. Edit your /etc/fstab to read:

HomeDaemon# cat /etc/fstab
# Device Mountpoint FStype Options Dump Pass#
/dev/ad2s1a / ufs rw,noatime 1 1
/dev/ad2s1d /var ufs rw,noatime 2 2
/dev/cd0 /cdrom cd9660 ro,noauto 0 0

Next, we are going to set the time server to point somewhere convenient. This is in "/etc/ntp.conf"; I use my machine but you will need to find a convenient place; my systems will not accept "chime" requests from arbitrary outside sources. This can be omitted if you wish, but note that timed events do rely on the system clock! The syntax in /etc/ntp.conf is:

HomeDaemon# cat /etc/ntp.conf
server genesis.denninger.net 

This file will not exist, you will have to create it.

Now we are going to edit the "rc.conf" file. Some of hte lines will be there in the file already, but we're going to add a couple more. Here they are, with the changed/added ones in bold print:

HomeDaemon# cat /etc/rc.conf
# -- sysinstall generated deltas -- # Fri Feb 15 01:40:28 2008
# Created: Fri Feb 15 01:40:28 2008
# Enable network daemons for user convenience.
# Please make all changes to this file, not to /etc/defaults/rc.conf.
# This file now contains just the overrides from /etc/defaults/rc.conf.
hostname="HomeDaemon.denninger.net"
ifconfig_rl0="DHCP"
inetd_enable="YES"
saver="daemon"
sshd_enable="YES"
ntpd_enable="YES"
syslogd_flags="-s -C"
fsck_y_enable="YES" # Set to YES to do fsck -y if the initial preen fails.
#
HomeDaemon_enable="YES"

The first enables the time client to synchronize your clock. The second changes the "syslog" startup so it creates empty files in the /var/log directory - necessary, because on each boot this directory will be empty, having been created from a memory disk. The third tells the system that in the event of a catastrophic crash that causes the disk checks to fail, it is ok to use more drastic measures. This may damage the system, but there really is no alternative anyway, and without it the machine will halt during the boot process if the "preen" fails; it is therefore a judgement call to include this. The odds of this coming into play are small but I judge it to be worth it.

Finally, the last line enables "HomeDaemon" - once you have installed the package.

Next, su to the "homedaemon" user ID, fetch the HomeDaemon.tar.gz package, unzip and make + make install the package, then read the "README" files and set it up.

Note that the "rc" file must be copied into the correct location (/usr/local/etc/rc.d) and you will have to make most of the "/usr/local/" directory tree, as it won't be there. Installation will fail until and unless you do.

The last thing to do is to insert two lines in /boot/loader.conf so that the system will find both the driver for any FTDI based serial concentrator(s) you plug into USB ports, and so it also finds the audio chip drivers so festival can speak. The changes to /boot/loader.conf are:

HomeDaemon# cat /boot/loader.conf
uftdi_load="YES"
snd_hda_load="YES" 

We also change the file /etc/crontab as follows - again, to reduce the writing to disk:


HomeDaemon# cat /etc/crontab
# /etc/crontab - root's crontab for FreeBSD
#
# $FreeBSD: src/etc/crontab,v 1.32 2002/11/22 16:13:39 tom Exp $
#
SHELL=/bin/sh
PATH=/etc:/bin:/sbin:/usr/bin:/usr/sbin
HOME=/var/log
#
#minute hour mday month wday who command
#
*/5 * * * * root /usr/libexec/atrun
#
# Save some entropy so that /dev/random can re-seed on boot.
#*/11 * * * * operator /usr/libexec/save-entropy
#
# Rotate log files every hour, if necessary.
0 * * * * root newsyslog
#
# Perform daily/weekly/monthly maintenance.
#1 3 * * * root periodic daily
#15 4 * * 6 root periodic weekly
#30 5 1 * * root periodic monthly
#
# Adjust the time zone if the CMOS clock keeps local time, as opposed to
# UTC time. See adjkerntz(8) for details.
#1,31 0-5 * * * root adjkerntz -a

Essentially what we've done here is comment out almost everything that would otherwise write to the disk. The periodic files will generate email which is both a write to disk and a maintenance bother, so we remove both. There is no point to the "adjkerntz" line if you're using ntpd.

Also, the following changes are made to /etc/newsyslog.conf to decrease the amount of data held in the log area. This is not strictly essential, as running out of memory disk will simply piss the system off (but not do any harm), but we may as well try to prevent it. The file as I'm running it is:

HomeDaemon# cat /etc/newsyslog.conf
# configuration file for newsyslog
# $FreeBSD: src/etc/newsyslog.conf,v 1.50 2005/03/02 00:40:55 brooks Exp $
#
# Entries which do not specify the '/pid_file' field will cause the
# syslogd process to be signalled when that log file is rotated. This
# action is only appropriate for log files which are written to by the
# syslogd process (ie, files listed in /etc/syslog.conf). If there
# is no process which needs to be signalled when a given log file is
# rotated, then the entry for that file should include the 'N' flag.
#
# The 'flags' field is one or more of the letters: BCGJNUWZ or a '-'.
#
# Note: some sites will want to select more restrictive protections than the
# defaults. In particular, it may be desirable to switch many of the 644
# entries to 640 or 600. For example, some sites will consider the
# contents of maillog, messages, and lpd-errs to be confidential. In the
# future, these defaults may change to more conservative ones.
#
# logfilename [owner:group] mode count size when flags [/pid_file] [sig_num]
/var/log/all.log 600 2 * @T00 J
/var/log/amd.log 644 2 50 * J
/var/log/auth.log 600 2 50 * JC
/var/log/console.log 600 5 50 * J
/var/log/cron 600 3 50 * JC
/var/log/daily.log 640 2 * @T00 JN
/var/log/debug.log 600 2 50 * JC
/var/log/kerberos.log 600 2 50 * J
/var/log/lpd-errs 644 5 50 * JC
/var/log/maillog 640 5 * @T00 JC
/var/log/messages 644 5 50 * JC
/var/log/monthly.log 640 1 * $M1D0 JN
/var/log/pflog 600 3 50 * JB /var/run/pflogd.pid
/var/log/ppp.log root:network 640 3 50 * JC
/var/log/security 600 3 50 * JC
/var/log/sendmail.st 640 3 * 168 B
/var/log/slip.log root:network 640 3 50 * JC
/var/log/weekly.log 640 3 1 $W6D0 JN
/var/log/wtmp 644 3 * @01T05 B
/var/log/xferlog 600 2 50 * JC /var/log/httpd-access.log 644 2 50 * Z /var/run/httpd.pid
/var/log/httpd-error.log 644 2 50 * Z /var/run/httpd.pid

That's it!

For serial ports you can either use the two "PC" serial ports that the machine came with, or, if you need more (e.g. you're using the Leopard and/or ADICON interfaces, in which case you need four ports total - ADICON, Leopard, X10 and ZWave) you can purchase any FTDI-based serial USB concentrator and plug it in. I have an 8-port unit that works quite well, and there are inexpensive ($25) single-port units if you only need one more port (e.g. either ADICON or a Leopard, but not both.) The Serial "Rat" is a known-working FTDI based unit that is both inexpensive and does the job. For an 8-port unit you can use this; I own one of these and it works well. If you only require four ports this unit claims to be FTDI based (I have not tried it, however.)

Note that there are other USB serial chipsets out there, and that they are problematic AT BEST. Choose something with an FTDI chipset in it or suffer the consequences, which can include hung serial boxes and processes!

The box, once set up, can run entirely stand-alone with no keyboard, no monitor, no nothing. If you have an Ehternet network available (e.g. home LAN) you can plug it into there (e.g. a wireless router) and access it should you find a need or desire, and if its accessible from the outside, you can even control your house from a web browser - anywhere!

There is presently in development a "pay for" service available soon that will allow you to edit your HomeDaemon device files on a central server at Cuda Systems LLC and, for a monthly fee, keep your box "up to date". This will allow you to edit off a web form without any Unix knowledge whatsoever. If there is demand we will also be selling these boxes preconfigured and ready to run, with one exception - you will have to load Dan Lancini's x10d daemon yourself due to licensing issues (if you intend to run a pure ZWave box this is, of course, not necessary.) If you have an interest in either please contact us at the below email link!

 

Email sent from this link should pertain ONLY to the "HomeDaemon" software. I do not guarantee a response, but I will read all comments sent. Please do NOT send HTML-ized email - I cannot read it and won't respond to it. Patches for other operating systems as well as comments and suggestions are appreciated.

Prev 5 | Prev | List | Next | Next 5