Igor's Blog
Programming, DIY, Games, Hacks, and Tech

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!).


Please leave your comments or feedback below!
comments powered by Disqus
Other posts you may like...

Recent Blog Posts

How to enable the full stack trace in Maven's Surefire plugin for JUnit testing

Twelve elements of the Burst Mining Pool interface explained

TPG FTTB settings for the Billion BiPAC 8700AXL 1600 modem router

Protecting old Atari Lynx game boxes with snug fit plastic sleeves

How to fix SoapUI javax.net.ssl.SSLHandshakeException calling WebLogic 12.2 web services on Java 8

Woolworths (WOW) shares disappeared from Computer Share Investor Centre

Connecting the Dell UltraSharp U3415W monitor to a MacBookPro via USB-C

How to add/change PHP versions appearing in MAMP preferences

Fix the ORA-00904: ORA_ROWSCN: invalid identifier error in SQLDeveloper with a few easy steps

G Suite Gmail is broken on Safari due to new Google Content Security Policy settings

Recent Galleries

Protecting old Atari Lynx game boxes with snug fit plastic sleeves

Monument Valley 2 is released and does not disappoint

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

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

Blogs and Friends

Matt Moores Blog
Georgi's FlatPress Guide
Perplexing Permutations
The Security Sleuth
Ilia Rogatchevski
Travelling Fairy

Blog Activity

Blog Activity
Don't forget to
my Facebook page for more great articles!
Don't show this again