Showing posts with label systems. Show all posts
Showing posts with label systems. Show all posts

Friday, August 16, 2013

My all-in-one Pi


I have a Raspberry Pi, but I wasn't sure how to encase it or whatever.  I picked up a bunch of these 13" LCD monitors from the scrap heap at work.  They run on 12v, and have VGA, S-Video, Component and Composite inputs.  I figured that I wanted to use one as a display for the Pi, so I started with trying to suck 5v of power off of the mainboard inside of it.  After a little probing with a multimeter, I found a 5v and Ground that seemed like a good place to tap.


I sacrificed a micro usb cable to tap directly onto the motherboard.  On the left you can see where I zip-tied it to the frame to prevent strain on the soldered connection.


The cord comes out from an unused port opening.  I added the two screw/standoffs you see on the bottom right.  I should note that I also removed the fan whose grille you can see in the top of the frame.  The fan wasn't needed, and was super noisy.  Next thing to do is to mount the pi on the back of the case.


Huzzah.  Everything fits nicely.  A short composite cable to hook it up and it's ready for use... Only problem was a way to prop it up.  I was going to build some sort of stand for it, but after looking around the parts area of Interlock, I found a broken Dell monitor I had brought in months ago.  I decided to repurpose its stand.


I removed the plastic backing from the upper portion, then removed the mounting plate from the stand.  I added four more holes to line up with the four screws coming out of the monitor (which have a ball joint as seen above) and use those to mount it to the stand.


After assembling it all together, it seems to work nicely.  I've since zip-tied the power brick to the back as well, although I'm not sure I like the way that works out.  The USB and ethernet ports are underneath the stand.  I'm considering moving the pi to be on the back, along the right side rather than on the back along the bottom.

You can also see in the above picture that I have added in a handle on the side of the monitor as well.  It's just the same kind of wire/metal drawer pull as I've used in the past.  It adds a nice carry handle to the project.


All of the ports of the Pi are still easily accessible.

Saturday, January 5, 2013

Howto: Setup a Sylvania SYNET07 Netbook with Linux


I recently picked up the Sylvania SYNET07 ARM-based 7" netbook from DailySteals for $40.  This is the same netbook that CVS as well as other convenience stores sell for $70-$100.  It came with Windows CE, although it is available with Android as well.  I figured that for $40, I could throw Linux on it, and use it as a portable, pocket sized hack laptop. Some people seemed to have some success getting Linux on it.  I can't afford a MacBook Air right now, so this will have to do for uberportable hackbox.  I ordered the red one, because why not.

I first decided to try out the latest Windows CE and Android on it before sticking with Linux. Windows CE booted super fast, but it was mostly unusable.  IE was sluggish, YouTube app didn't work at all. Android took longer to boot, and seemed to work ok, but the marketplace was empty for it, so no additional apps could be added, which made it kinda useless.

Next, it was Linux time!  Most of this follows this procedure, but with some additional changes.

Card Setup

The first thing to be done was to prep the SD card.  I had spun up a Linux box recently, so I'll be using that to prep the SD card.  I plugged it in and noticed from dmesg that it showed up as /dev/sdb.  I used "fdisk" to create two partitions on the card.  First is a 250 meg FAT-16 partition, then a 7.5 gig (? whatever filled the rest of the card) Linux/EXT3 partition.  I then formatted the partitions:

    sudo mkfs.msdos -F 16 -n FAT250 /dev/sdb1
    sudo mkfs -t ext3 /dev/sdb2

Then mounted them in /mnt:

    cd /mnt
    sudo mkdir fat
    sudo mkdir linux
    sudo mount /dev/sdb1 fat
    sudo mount /dev/sdb2/ linux

I had downloaded the two files provided at the above link, which I've mirrored here:  [fatpart.tgz] [extpart.tgz]  I then extracted these to the newly formatted SD card:

    cd /mnt/fat
    sudo tar -zxvf ~/fatpart.tgz
    cd /mnt/linux
    sudo tar -zxvf ~/extpart.tgz

The card is now bootable in the Sylvania netbook.  I like to make a few tweaks from here though; namely changing the hostname, and prepping the pacakge system to actually work as expected.

   cd /mnt/linux/etc/apt
   sudo vi sources.list  -- change "ftp.au.debian.org" to "ftp.debian.org"

   sudo echo "newHostName" > /mnt/linux/etc/hostname


   sudo mkdir /mnt/linux/var/log/apt/


Now, we'll disconnect the SD card:

    cd /mnt
    sudo umount fat
    sudo umount linux

First Boot, Package Installation

Next, put the SD card into the netbook, and press the power button to turn it on.  It will boot to a linux prompt.  Log in as root, no password.  Plug the netbook into a network connection, then type "dhclient" to get an ip address.

I like to change the password, just to keep casual people out.  I use something simple like "hunter2" ;)

The first thing we need to do is to update the old package database on the thing.

    apt-get update
    apt-get upgrade

Now, it's time to install some packages.  Here's the commands to install the developer packages I like:

    apt-get install gcc g++ gobjc make bison flex
    apt-get install ncurses-dev screen ssh
    apt-get install git-arch subversion-tools

Next, it's time for some X11 goodness

    apt-get install xinit xorg xorg-dev twm wm2 x11-utils

Audio, apps. console config stuff.  These may prompt for console configuration.  I use "UTF-8" and then "Latin 1"

    apt-get install mpg123 libmpg123-dev mp3blaster
    apt-get install console-setup console-tools nethack-console
    apt-get install irssi markdown arduino arduino-core

Past this, I like to install the window manager "wmx", building it from source

    mkdir ~/src
    cd ~/src
    wget http://www.all-day-breakfast.com/wmx/wmx-7.tar.gz
    tar -zxvf wmx-7.tar.gz
    cd wmx-7
    ./configure
    make
    make install

You should be able to start up X11 - "startx" and it should bring you into twm.  You can edit ~/.xsession to something like:

    twm &
    xsetroot -solid midnightblue
    xterm -fg red -bg orange -name "EXIT TO LEAVE X" -iconic

Shown running X11 with the "amiwm" window manager.

Crash prevention (Date and Time config)

There's something about the way it accesses the hwclock (hardware clock) on shutdown that crashes the machine.  We'll flat-out disable it here so that we get clean shutdowns.  This isn't elegant, but it works.

    vi /etc/init.d/hwclock*

and replace their contents with:

    #!/bin/sh
    echo "hwclock: disabled."

Now, let's do the same to the command at /sbin/hwclock

    mv /sbin/hwclock /sbin/hwclock.original
    cp /etc/init.d/hwclock.sh /sbin/hwclock
    chmod 755 /sbin/hwclock

This may mean however that we will need to enter the date each time we login, like so:

    date MMDDhhmmYYYY

eg, for January 4th, 2013 at 1:36 pm:

    date 010413362013

Now, we should get the timezone stuff setup properly. Add this stuff to your .profile or .bashrc:

    TZ='America/New_York' ; export TZ

Some commands may expect these, which you can probably ignore:

    export LC_CTYPE=en_US.UTF-8
    export LC_ALL=en_US.UTF-8

And now install locales and ntpdate

    apt-get install ntpdate

Do not install 'ntp' or locales ('locales-all'), as they may scrog the hwclock and dhcp client/ethernet hardware again.  (...Well, not particularly the dhcp stuff, but it makes the system forget that eth0 is broadcast capable somehow.  There's a fix for that by specifying eth0 on the 'dhclient' call, as seen in the following.)

I added the following to my .profile to make network starting easier:
    neton() {
        echo "dhclient..."
        dhclient eth0
        ifconfig
        echo "ntpdate..."
        ntpdate time.apple.com
        date
    }

If time gets out of sync, as well as after you login, you can just use:

    ntp() {
        ntpdate time.apple.com
        date
    }

To get your machine in sync with real time, if you have net access.  If you don't have net access, use the date command above.

Additional Stuff - Backlight Control

Add this in to your .profile to get a handy routine to change the system's screen backlight.  The values range from 0 through 255.  It seems that anything less than 90 is essentially off.  above 192, the intensity increase is minimal.  The default is 128.  I run it at 98 in very dark rooms.

    backlight() {
        echo $* > /sys/devices/platform/lcd-backlight.0/leds/lcd-backlight/brightness
    }

    backlight-lo() {

        backlight 95
    }
    backlight-hi() {
        backlight 192
    }

So now, you can just type "backlight-lo" or "backlight-hi" in any shell, and it'll adjust your screen's backlight.

Additional Stuff - Backups!

While you could do rsync from the laptop to another host, I've found that the easiest way to back up the system is to shut it down cleanly, pop the SD card, shove it into another machine and just tar the entire EXT3 partition to a file to be kept for safe keeping.  I only use about a gig of space on the card, so this takes up very little space on a desktop machine.  I also keep a directory of stuff that doesn't get backed up, "/NOBACKUP".

Plug the card into a host, I use an ubuntu machine.  CD to the root of the mounted SD card, and tar it to a file in your home directory (or wherever, adapt the line for your own use)

    cd /media/99bf3e8c
    sudo tar -cvf /home/myHome/laptopBackup_2013-01-04.tar .

Backups go fairly quick, restores take more time.

    cd /media/99bf3e8c
    sudo tar -xvf /home/myHome/laptopBackup_2013-01-04.tar

To restore, simply follow the first step above, where you just untar your new backup, rather than "extpart.tgz".  My backups are around 990 meg with all of the above installed.  gzip of that cuts it about in half to 450 meg, which is great for archival.

Additional Stuff - Package notes

I've found that some packages seem to totally scrog the NIC for no reason.  For example, as mentioned above, "ntp" causes bad things to happen, as well as "xscreensaver".  I'm not entirely sure why this is, they don't seem to touch anything that should touch the network, but apparently they do.  Backup often.  Get used to restoring. ;)