Igor's Blog

Over the Easter Weekend I've done quite a large update on my JPhotoFrame project. There are a number of bug fixes and the weather functionality has been switched to OpenWeatherMap. I took this opportunity to completely rebuild my digital photo frame from scratch and write up all the steps required to put it together.

I've written disparate articles on related topics here, here and here but have never tried to put it all into one coherent guide, until now.

This guide assumes that you're going to do the initial part of the setup on a Mac running OS X. It also assumes you have a Raspberry Pi Model A and a USB monitor to drive your photo frame. I won't be covering any of the physical construction aspects of the photo frame, this is purely how to set up all the software, file sharing, etc.

The end result is something like this...

What you will need:
  • Raspberry Pi
  • USB Monitor
  • SD Card (1Gb)
  • 8Gb+ USB key
  • USB Keyboard

Create a bootable SD Card

First download the following:

Using ApplePi-Baker run the 'Restore Backup' for the Minibian-wifi image e.g. 2015-12-30-wheezy-minibian-wifi.img.

Eject the SD card, which now has the Minibian-wifi image, insert it into your Raspberry Pi, power on and let it boot up.

Everything that follows must be done on the RPi as the 'root' user...

Note1: Wherever you see file contents listed without further instructions, simply copy/paste what's shown into the file specified.

Note2: Wherever you see a 'Commands' listing, type those commands into the RPi as shown.

Network Setup

Update the /etc/wpa_supplicant/wpa_supplicant.conf file with your WiFi information, update network details to assign a static IP address similar to the following. A static IP is not necessary but useful for the future so you don't have to guess the IP address when connecting to the RPi.
auto lo
iface lo inet loopback
allow-hotplug wlan0
iface wlan0 inet manual
wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
iface default inet static

Disk Partitioning and Resizing

Because SD cards are slow we will transfer the OS to a USB key.

Partition the USB key. Delete any old partitions first, then create a new primary partition.
fdisk /dev/sda
(accept default)

Copy the file system from the SD card to a USB key.
dd bs=1M if=/dev/mmcblk0p2 of=/dev/sda1

Resize the file system to make use of all the extra space on the USB key.
e2fsck -f /dev/sda1
resize2fs /dev/sda1

Update fstab so that it reflects the new location of the OS.
/dev/mmcblk0p1 /boot vfat defaults 0 2
/dev/sda1 / ext4 errors=remount-ro,noatime,defaults,sync 0 1

Edit the /boot/cmdline.txt file and make sure the root option is set as this: root=/dev/sda1.

Restart the RPi.

Update the OS and Install Additional Software

We're going to need some additional software to compile the Kernel and also to get JPhotoFrame source code and build it.
apt-get -y update
apt-get -y dist-upgrade
apt-get -y install raspi-config gcc make bc screen ncurses-dev git ant dosfstools lxde oracle-java7-jdk netatalk samba samba-common-bin unclutter dphys-swapfile

Run Raspi-Config and do the following: Overclock to Turbo. Change time zone to your relevant setting. Restart the RPi.

Compile the Kernel

Because we're using a USB monitor and the default kernel build doesn't have this included we need to build this into the kernel. There are some good guides on how to do this here and here and I'm providing the condensed version of the commands to run below.

Check out the Kernel source.
mkdir ~/kernel && cd ~/kernel
git clone --depth=1 https://github.com/raspberrypi/linux
cd linux

Configure the Kernel.
make mrproper
modprobe configs
zcat /proc/config.gz > .config
make bcmrpi_defconfig
make menuconfig

Navigate to the following option: Device Drivers -> Graphics Support -> Frame buffer devices -> Displaylink USB Framebuffer support. Press 'Y' and save and exit.

Compile the Kernel.
make zImage modules dtbs
make modules_install
cp arch/arm/boot/dts/*.dtb /boot/
cp arch/arm/boot/dts/overlays/*.dtb* /boot/overlays/
cp arch/arm/boot/dts/overlays/README /boot/overlays/
scripts/mkknlimg arch/arm/boot/zImage /boot/$KERNEL.img

Edit /boot/config.txt and add this line to the top of the file:

Configure the swap file

JPhotoFrame may need more memory than the RPi actually has (depending on the size of your photo library) so it's a good idea to configure some swap space.

Enable swap space.
dphys-swapfile setup
dphys-swapfile swapon

Configure File Sharing

Create Photos directory (copy some photos to it later).
mkdir -p /photos/cache
chmod 777 /photos
chmod 777 /photos/cache

Configure AFP file sharing.
<?xml version="1.0" standalone='no'?><!--*-nxml-*-->
<!DOCTYPE service-group SYSTEM "avahi-service.dtd">
<name replace-wildcards="yes">%h</name>

Put the following line at the bottom of /etc/netatalk/afpd.conf file, replacing any existing default.
- -tcp -noddp -uamlist uams_dhx.so,uams_dhx2.so,uams_guest.so -nosavepassword

/photos Photos allow:nobody options:usedots,upriv

Configure Samba file sharing.
map to guest = bad user
wins support = yes
server string = %h
only guest=Yes

Configure the host name.

Disable Power Management

Because this is a photo frame and it should be on most of the time, some of the built-in power management needs to be disabled.

Disable screen blanking. In /etc/kbd/config look for the following settings and set them to 0.

Set X server power management. In /etc/lightdm/lightdm.conf make sure that the xserver-command is set as follows:
xserver-command=X -s 0 dpms

Configure the 'pi' user and Automatic Login

Create the pi user.
useradd -m pi
passwd pi

Enable automatic login by running raspi-config.

Select Enable Boot to Desktop/Scratch > Desktop Log in as user 'pi' at the graphical desktop. Exit and optionally restart.

Everything that follows must be done as the 'pi' user...

Set up the Desktop Environment

Because this is a photo frame, we don't want the desktop to really be visible so most features need to be disabled and desktop icons removed. These are my configuration files for LXDE.
Global {

desktop_font=Sans 12

Make sure that mode is set to off.
mode: off

Get and Compile JPhotoFrame

Now that the system is set up it's time to build the photo frame software itself.

Clone JPhotoFrame from GitHub
cd ~
git clone --depth=1 https://github.com/ikromin/jphotoframe.git
cd jphotoframe

Edit jphotoframe.properties and set the jdk.home.1.7 property.

Build JPhotoFrame.
cp out/artifacts/jphotoframe/jphotoframe.jar .

Set up a crontab

JPhotoFrame includes a script to turn the USB monitor on/off during certain hours of the day, this is done by scheduling an hour job as follows:
 crontab -e
0 * * * * bash /home/pi/jphotoframe/onoff.sh

Auto-start JPhotoFrame

Now all that is left is to make sure that JPhotoFrame automatically starts when the RPi boots up. Create the following files to do so.
cd /home/pi/jphotoframe
sh run.sh

[Desktop Entry]

Make sure the script above is executable.
chmod 755 /home/pi/jphotoframe.sh

Copy Photos

Copy some photos over to the /photos directory or use file sharing to copy files to the RPi.


That's it, the photo frame should be functional at this point so sit back and enjoy (it's probably taken you 2 or 3 days to get to this point!).


, , ,
About — I'm an enthusiastic software engineer and consultant interested in many fields including J2EE, programming, electronics, 3D printing, video games, wood working and gardening.
See my Resume for more information.
The views expressed in this blog are my own and not those of my employer.
comments powered by Disqus
My other posts you may like...
Programming, DIY, Games, Hacks, Tech and more.
Follow me on...
Current and Past Projects
See my Resume


RSS Feed

My Other Web Sites

Igor and Elise's Travels
Riverside Expressway Cam
300 George St Blogumentary

My Online Tools

UUID to OID Converter
Guru JSON-RPC Tester
Extrudifier Object Designer
Travel ┬ÁBlog

Recent Blog Posts

Base64 Encode or Decode on the command line without installing extra tools on Linux, Windows or macOS

How to install Panel Glide Blinds from Blinds Online

Showing whitespace characters in vi

Using Jackson to automatically convert Java POJOs to JSON as output of a Jersey service

Enable quick access to the keyboard and emoji viewer in macOS

How to tell if your site is served via CloudFlare

Googe Cloud Platform doesn't support CloudFlare's free edge certificates

Fixing the invalid private key error in the Google Cloud Platform App Engine app Settings page

Cleaning the sticky PlayStation controller analogue thumb sticks

Invoking interactive shell scripts non-interactively

Recent Galleries

Space Food - Chocolate Ice Cream with Chocolate Chips

Legeod Star Wars AT-DP kit

DIY spare parts computer build with a RAIDMAX Anura case

Fake 'Lepin' brand Lego packaging

Hardwood garden bench with clear resin void filler

Fixing a 3D printer extruder that stopped heating up

Easily increase disk space in a Lenovo Ideapad 100S 14" laptop with an M.2 SSD

Making a multi-piece 3D printed solder spool holder stand

DIY indoor apartment grow light wiring

Good Friday Electronics fun Easter Bunny LED PCB Kit IBEABU-01.0

Top Categories

Blogs I follow

Matt Moores Blog
Georgi's FlatPress Guide
Perplexing Permutations
The Security Sleuth


RAWS Parts Online
Alpha Dimensions Hosting
Kristensen Photography
Ilia Rogatchevski
Travelling Fairy

Blog Activity

Blog Activity
Follow me on... 
...or subscribe for updates!

Don't show this again