You are on page 1of 10

Building a Linux-Driven Digital Picture Frame, Part 2

Date: Mar 25, 2005 By Seth Fogie.

In part 2 of his series on converting an old laptop into a digital picture frame, Seth Fogie loads Linux and assembles the finished product.

It's time to continue our project for turning an old laptop into a digital picture frame. In part 1 we determined system requirements and cost, decided to use Linux as the OS, and purchased the parts. This time we'll load Linux and put everything together. Installing muLinux Installing muLinux was not as easy as I would have hoped. On a scale of 1-10 for Linux installations, muLinux rates around a 5. However, most of the annoyances are by design. While it does support a permanent installation via a process called cloning, muLinux was initially created to be a temporary floppy/RAM-based OS. The following sections outline the steps required to install muLinux onto the hard drive. NOTE If you have the ability, create two partitions on the target computer prior to installation. One needs to be ext2 and the other should be Linux Swap (82). Generally, the swap space should be at least the size of your system's RAM. The cloning process includes the ability to create partitions, but it's easier to use a program such as Symantec's PartitionMagic.

Preparation
The complete muLinux OS is downloadable as 13 separate packages, plus a DOSTOOLS file for Windows-based installations. All of these files should be placed into the c:\mulinux folder on a Windows-based computer with a floppy drive. Once all the files are downloaded, you can create the installation disks. You'll need the following:
q q q q

Working Windows computer 13 blank 1.44MB floppies Target laptop BIOS for all involved computers configured to boot from floppy

Here's how you create the installation disks: 1. 2. 3. 4. Place all files into the c:\muLinux folder on the Windows computer. Unzip DOSTOOLS.zip into the c:\mulinux folder. Reboot into MS-DOS and change to the c:\mulinux folder. Execute unpack.bat to extract the core OS files from mulinux-13r2.tgz.

5. 6. 7. 8.

Execute makefi to create an installation disk. Leave the newly created Install disk in the floppy drive and reboot the computer. Once the installation program loads, select option [1] to create a boot disk. Continue through the package-installation routine until all add-on disks have been created.

Installation
Installing muLinux is accomplished via a process called cloning that transfers the OS files stored in memory to the hard drive for permanent storage. To do this, muLinux must first be loaded into RAM with a few necessary components. Following are the steps needed to complete the cloning. First, the initial muLinux boot (loading muLinux into RAM): 1. Insert the boot floppy into the target computer and boot it up to the first configuration screen. 2. Hit [y] for swap space configuration. a. Select 1 to "choice a swap partition" [sic]. b. Confirm the swap-partition selection. c. Enter the swap size and confirm the configuration. 3. Hit [y] for /usr partition configuration. 4. Select [y] for the SRV add-on and insert the SVR package disk. 5. Select [n] for the remainder of the package options: X11, NS1, NS2, GCC, TCL, VNC, TEX, PERL, EMU, and JVM. 6. Select the "lazy" model. (Use the spacebar to select and Enter to confirm.) 7. Reinsert the startup floppy. 8. Enter the profile name. 9. Select the No option for the tour. 10. Login using the root account. Creating the clone (you can try to repartition at this time): 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. Type clone at the prompt. Select [2] for filesystem type. Hit [n] for repartition. Select install partition (Linux Native). Select [2] LILO for the boot loader. Select /dev/fd0 (floppy drive) for the boot partition. Confirm the installation configuration settings and start the copy routine. Configure the kernel options according to your laptop's specifications (default). Insert the boot disk for LILO (Linux Loader, used to keep Linux off the MBR). Hit Enter "and give yourself a congratulatory pat on the back!!!" Type setup -s to save your settings. (Do this anytime you run setup or menu.) At the /root prompt, type shutdown -r now to reboot.

Configuring muLinux
When the system reboots, it will prompt you for various configuration options. For the most part, these options were set to the default. The only exception in my case was the mouse. As I learned, using X requires a mouse that's properly configured. The easiest method was to keep a mouse connected during the initial setup of muLinux. Once the setup was complete, the mouse can be removed. At the login, type root and press Enter. This will put you at the command line. You then need to type setup to load the muLinux setup program (see Figure 1). From this screen, you can install all the necessary add-ons to turn your laptop into a

picture viewer.

Figure 1 Setup v14r0 screen. The top menu of Setup v14r0 lists the main packages you can add. Below that is a list of the programs and services that can be enabled, configured, or disabled. You must have the corresponding add-on installed before you can use it. Unfortunately, it's not always easy to tell which add-on includes the program you need. The key to controlling resources on the DPF is to limit the number of programs running. For example, there's no need to load ssh or Samba. These programs just take up valuable RAM and can result in slower image-load times. To create a digital picture frame, you need to load the add-ons in the following table. Add-on SRV WKS X11 Description Provides key files used to manage the system Provides key files used to manage the system Required for X Window System support

NS1 and NS2 Required for SVGA driver support VNC Loads the image-viewer program called xli (discussed later)

Once you have all these add-ons installed, make sure that you save the setup (Press the [s] key in the Setup program or type setup -s at the command line.) You must save the configuration each time you change something, or you'll lose your changes when the computer is turned off. Once the save is complete, reboot the system, which will prompt you again with several configuration options. Bypass these and log back into root. Again, save the settings using setup -s.

Setting Up X
Setting up X to work on your laptop might be the most challenging aspect of this whole process. Before doing anything, you have to know the key specifications needed by the X program. Fortunately, I was able to learn that my laptop video chip was a Cirrus CL-GD7543. Armed with this information, I learned that my display had the settings shown in the following table.

Setting

Value

Horizontal sync 31.5 kHz Vertical sync Dot-clock Bit-plane 5070 kHz 25.175 8 or 16

With this information noted, I had two choices. First, I could run a program called xprobe to set up my X configuration file located in /etc/X11 and called XF86Config. My second option was to use the "menu" program wizard included with muLinux to assist with the general configuration tasks. Both options perform the same actions, except that the wizard provides more choices that can help get your X session up and running. To set up X, follow these steps: 1. 2. 3. 4. 5. Type menu at the command line and press Enter. Arrow down to Configuration Wizards and press Enter (see Figure 2). Arrow down to XWindow and Video Setup and press the spacebar followed by Enter (see Figure 3). At X server menu, arrow down to Super-VGA cards; press the spacebar and then Enter (see Figure 4). From the Setup Method menu, select user defined or modeline probing and use your known settings to fill in the blanks. Once this info is complete, you'll have a chance to confirm the settings (see Figure 5). 6. Exit the menu and type startx to execute XWindows & Fvwm95.

Figure 2 The Menu menu.

Figure 3 The Configuration Wizards menu.

Figure 4 Selecting SVGA support.

Figure 5 Confirming the detected/entered settings. Now it's time to fix X. Please note that X may or may not load, depending on the success of the wizard. If it fails, you can troubleshoot using the information in /var/log/startx.log. To see this information, use the following command: cat /var/log/startx.log | more or open the log file in vi. To get X working correctly on my laptop, I had to alter the VertRefresh entry in the Monitor section from VertRefresh 70 to VertRefresh 50-70. This small change made all the difference to Xas well as to my sanity, as I spent a good hour troubleshooting this problem. Note on vi: Linux/UNIX users must be familiar with the editing program called vi. This little tool is one of the icons of the older UNIX days, where everything was done via a text screen. vi does take some getting used to; however, 95% of what you'll need to do requires knowing only these few keystrokes:
q q q q q q

Move the cursor around the file using the arrow keys. Press x to delete a character and d to delete a line. Press i to start insert mode, where you can add and change existing characters. Pressing Esc exits insert mode. Press q to quit. Typing q! will quit without saving, and wq will write out (save) and then quit. Shift-z-z to save and exit.

Once X loads with fvwm95 serving up the graphics, you should be rewarded with a basic GUI with several programs running on the desktop. Take a look around and see how they work, because they won't be there for long! At this point you can take a break. The hard part is over, and the basic system is working. All that's left is some custom scripting, tweaking xli, creating the frame, uploading the pictures, and of course lots of testing...on second thought, it might be too early to celebrate! The Picture Frame Code The following code is not secure, nor is it bulletproof. In addition, there are many other ways to show or loop through pictures. For example, you might want to add a random-timing feature, or perhaps a "hidden" image that shows up every 20 days. The options are up to your imagination!

xli
Prior to doing anything, you must test the xli program installed with the VNC add-on. xli is an image viewer based on

xloadimage that does much more than just show a picture. Included in this package is support for clipping, zooming, focusing, background-color adjustments, and more. However, before using it, you must make sure that all the libraries are loaded. To do this, type xli at the command prompt. If you get an error about a missing libpng.so.2 file, you need to create a link using the following command: ln /usr/vnc/lib/libpng.so.2 /usr/lib/libpng.so.2 This step creates a shortcut to the missing library file that essentially tricks the OS into believing the missing file is now installed in /usr/lib. If you need to locate any other missing files, use this command: find / -print | grep <filename>

Altering the Default fvwm95 Display


In this project, we're using fvwm95 as our window manager. This isn't essential, and you could avoid a window manager altogether. However, by using fvwm95, your DPF will include a GUI that can be used for games and other applications. First, we need to remove a few extra parts from fvwm95 to hide it from the user. When startx is executed, it performs some checks and then attempts to load fvwm95. fvwm95 loads according to a configuration file and then passes control back to the startx script for further processing. muLinux is configured by default to open several programs in the GUI, such as xterm, xload, and a file manager. We don't want these to load, which means that the startx file must be edited. To do this, type vi /usr/X11R6/bin/startx and open the startx script in vi (our editor). Arrow down until you find the lines responsible for loading the extra programs. With the cursor set at the beginning of the line, press i (insert) followed by #. This action tells the shell to ignore the line. Save your changes and close vi by pressing Esc, followed by Shift-z-z. If you execute startx now, you should only see a cyan screen with a taskbar. Click the screen with your mouse and exit fvwm95. Then type the following to load the fvwm95s configuration file into vi: vi /usr/X11R6/lib/X11/fvwm95-2/fvwm95-2.mu Again, arrow down through the lines until you come to this line: AddToFunc "InitFunction" "I" Exec xsetroot -solid cyan4 &

First, change this line as follows to ensure that fvwm95 uses a black background: AddToFunc "InitFunction" "I" Exec xsetroot -solid black &

Next, add a # by using the insert command in front of the line to stop fvwm95 from loading the taskbar: #+ "I" Module FvwmTaskBar

With all these steps complete, save the file and execute startx again. You should be rewarded with a blank black screen, with the exception of a small X in the center for the mouse cursor. Click the screen for the fvwm95 menu and then exit the window manager.

The Picture Script


The goal of this project was to make a user-friendly DPF. At this point, I could manually tell my laptop to view a picture, but my in-laws wouldn't find this very amusing. To complete the conversion from laptop to picture viewer, I needed some customized code that would automatically load and display pictures without interaction from a user. After a little thought, I came to the conclusion that my script would have to prompt the owner for a floppy disk, copy images from the floppy to the local drive, and cycle through the images, loading each for a predefined period of time. Thankfully, xli had the power and options to help me; for a complete listing, type xli -help at the command prompt. NOTE To use the list or path flag, you need to create an executable .xlirc file in the /root and / directories. This file needs one line to tell xli where to find your image store: path=/pics NOTE To create this file, type the following: echo path=/pics > /.xlirc echo path=/pics > /root/.xlirc I'll include my picture script to give you a place to start. Feel free to plagiarize this for your own purposes. This entire file was saved as runpics in the /root directory. Included are comments explaining the purpose of each line. ################################################################## #Send message to screen prior to picture load. This is also done with splashpage image. #Added a pause to allow X to start, the splash image to load, and the user to insert #the image floppy echo MAKE SURE YOU SWAP THE FLOPPY!!!! echo Sleeping for a minute sleep 60 echo Mounting floppy and copying over new pictures umount /a ;if the floppy is mounted, unmount it mount -t vfat /dev/fd0 /a ;mount the floppy using vfat (Windows) format cd /a ;change directory to the floppy cp *.jpg /pics ;copy the jpgs to the /pics folder sleep 10 ;I like to sleep a lot #umount /dev/fd0 ;I keep it mounted in case I want to remove a file echo Copy complete. Starting image cycle. #Start image load process xlist=$(xli -list) ;Get file listing from xli (also returns folder name) badname="/pics//pics:" ;Assign badname with '/pics//pics:' (folder not a picture) while [ 0 -eq 0 ]; do ;Continuous loop (0 will always equal 0) for i in $xlist ;Assign $i with image name do xname=/pics/$i ;Assign xname with image path & name

if [ $xname != $badname ] ;Test to see if xname = '/pics//pics:' then #Load the image according to my specification using xli xli -onroot -display localhost:0 -border black -center $xname fi sleep 20 done ;sleep for 20 seconds and then repeat!

done ################################################################# Once your script file is created, change the permissions on it to allow it to execute, by using the following command: chmod 755 <filename>

SplashPage Script
To make sure that the user doesn't forget to insert the image floppy, I decided to set up a splash page to provide a reminder. In addition, the splash page would be nicer to look at than a blank window or text as the runpics script took its naps. However, I wanted this part of the startup routine to be separate from the runpics script, so I created a splash script with the following line: xli -onroot -display localhost:0 -center -border black /root/splashPage.jpg

Go Script
I next wanted to create a starting point from which everything could be executed. As a result, I created a third script called go, which I placed in the /usr/bin directory. This would allow me to execute go from any location on the computer. The contents of this file are as follows (the & tells the command to execute in the background and allow the script to continue to the next line): rm /tmp/.X0-lock startx & /root/runpics & /root/splash & NOTE When the X Window System is executed, it creates a file called .X0-lock in the /tmp directory. This is meant to stop an additional X session from starting, but can cause problems if the system is not shut down properly. As I discovered, a poweroff will leave this file in the /tmp directory, thus halting the startx script from loading. By removing this file, I clear the way for a proper execution of X. With all this work complete, it's a good time to test the entire process to make sure that it works. After a clean reboot, login to root and type go. Assuming that you have a splashpage.jpg image in the /root directory, you should be rewarded with a black screen that soon displays your splash image. After about 1.5 minutes, the screen should change to your first image in the /pics folder.

Getting It All Started

The final step was to find a way to execute go during startup. I could have my in-laws log in and type go, but again, that wasn't user-friendly. I first tried adding a reference to go in the rc.local file, but this file failed to execute anything. Instead of troubleshooting, I just decided to edit the /etc/rc/5 file and include an entry to execute go & (this worked beautifully). The technical side of the picture frame was complete. Creating the Case Creating the case proved to be fairly easy, although it took a couple of tries. My initial attempt was a little gaudy and equally as ugly. However, my second attempt resulted in a rather spiffy-looking DPF, if I might say so myself! Following are the steps I took: 1. Remove and discard the battery (they're usually dead in old laptops). 2. Purchase nylon screws, nuts, and washers; brackets; Velcro; a paper shelf thing that fits the laptop; and paint. All of the nylon screws were unused in my final prototype. 3. Locate screwdrivers, pliers, drill, sledgehammer, blowtorch, etc. 4. Remove the LCD display from the laptop. This usually involves removing bottom screws from the laptop and side screws for the attached monitor. Look under rubber protection pads for hidden screws. (Note: This will void your warranty. <g>) 5. Remove the hard drive for safekeeping. 6. Once the keyboard is off, locate and unplug the LCD display attachment. 7. Disconnect and remove the LCD display. 8. Remove the top of the LCD display. 9. Paint the top of the LCD display and let it dry overnight. 10. Unravel the LCD-to-computer strip and extend it. The extra length is needed to flip the display around onto the back of the computer (Figure 6 shows the disassembled laptop). 11. Remove extra parts that are normally used to mount the LCD onto the laptop chassis. You may need to break off extra parts to allow easy mounting of the frame over the LCD. 12. Reconnect the LCD display to the laptop chassis. 13. Apply Velcro to the bottom of the laptop and the back of the LCD and stick the Velcro pieces together. TIP Try to place the LCD about one inch higher than the laptop chassis. This helps when placing on the picture display. 14. Using Velcro, apply the frame to the LCD.

Figure 6 Disassembled laptop. Various Problems I faced many obstacles getting this DPF to work. And there were two issues that I couldn't properly handle. The first was a display-timeout problem that turned off the screen after 10 minutes. I changed the BIOS and looked for a software solution, but nothing worked. In the end, I used a hair clip to just hold down a key and trick the laptop into believing that a user was

present. The second problem was trying to get rid of the little X cursor on the screen. My solution was to move it off into a corner using Shift+Ctrl+up arrow. This worked, although it's annoying for the end user. However, as it states on the initial boot screen, "...you're welcome to apply for a full refund of the money you paid me for it :-)." Summary This project took a lot of time. I spent hours trying to troubleshoot various problems, but it was all worth it. After getting some very positive feedback, and a few offers to buy one, the homemade digital picture frame is a success. Since a picture is supposedly worth 1,000 words, I'll let Figures 7 and 8 provide a closing for this article!

Figure 7 Two finished digital picture frames.

Figure 8 Displaying images.

2005 Pearson Education, Inc. InformIT. All rights reserved. 800 East 96th Street Indianapolis, Indiana 46240

You might also like