Mirroring a Windows PC screen on a TV through a BeagleBone Black

This method is not suitable for showing movies or anything else that requires a fast framerate. I get about 1 FPS over a fast LAN connection, but it's enough for my purposes (looking at graphs with colleagues).

Preparations on the BeagleBone

Download the official Debian image (the one that runs on both BBB and BB White, and does not flash the MMC!). This image includes LXDE as a graphical environment. (I had no luck installing LXDE on a minimal Ubuntu image, so we'll have to use this official image.) Unfortunately, it has all kinds of stuff running on the BeagleBone (Cloud9 development environment...) which makes it a security nightmare. Oh well, I am running it in a somewhat trusted environment...

Copy the image on a uSD card. When I used Windows for the copying, I ended up with an unbootable uSD card (three or four solid lights instead of blinkenlights...). So instead I used Linux (Ubuntu) to install Debian on the uSD, using these commands:

mount   # -> find out the location of the uSD card. For me: /dev/sdb
sudo umount /dev/sdb1
sudo umount /dev/sdb2
xz -d bone-debian-7.5-2014-05-14-2gb.img.xz
sudo dd if=bone-debian-7.5-2014-05-14-2gb.img of=/dev/sdb bs=1M

The last step took almost an hour to finish.

Boot up the BeagleBone and do the standard steps to add another user and to delete the default user (Debian and Ubuntu are so closely related that this process is identical). I made sure to run

bash /opt/scripts/tools/grow_partition.sh

to make use of the full space on my uSD card (not just 2GB).

Edit the autologin-line in the lightdm.conf file, so that the new standard user will be logged in automatically.

nano /etc/lightdm/lightdm.conf
 # Look for the autologin line, change debian -> bob or so

Install the necessary vnc packages:

sudo apt-get install x11vnc
sudo apt-get install xtightvncviewer

Add the following line to /etc/xdg/lxsession/LXDE/autostart:

@xtightvncviewer -fullscreen -listen 0
@xset s noblank
@xset s off
@xset -dpms

The first line makes sure a VNC-viewer is started in "listening" mode on bootup, the last three lines disable screen blanking and power-saving and such nonsense.

Finally, connect the BeagleBone to a TV.

VNC'ing into the main Display from outside

Now, if I want to VNC into the "main screen" of the BeagleBone, I first ssh into the BeagleBone and run the command

x11vnc -display :0

Note: This is extremely unsafe, because now there is no password set. For first tests that's okay.

On Windows, I use "TightVNC Viewer" to open a connection to the BeagleBone on port 5900 ("192.168.0.50::5590", note the double "::"!). This is useful for troubleshooting.

"Mirroring" a PC screen to the BeagleBone

I had some trouble to start the following command via ssh, so I put into the autostart file of the Window manager:

xtightvncviewer -fullscreen -listen 0

Here, "0" is the display on which the VNC viewer should be running in full-screen mode. Now, using TightVNC Server on Windows, I can attach a listening viewer (using the address "192.168.0.50::5500" - again, note the double "::"!).

Automating the Windows TightVNC Server startup with a batch file

The following batch file start the VNC Server, attaches the listening client, and then waits for another keystroke to end the program again. Modify tvncpath and bbb-address to your liking. Note: I don't have TightVNC registered as a service, because I do not want it running unless it absolutely has to. The script probably fails if you have TightVNC registered as a service.

@echo off

set tvncpath="c:\Program Files\TightVNC\tvnserver.exe"
set bbb-address="192.168.0.50"

rem Check if tvnserver is running
tasklist /FI "IMAGENAME eq tvnserver.exe" | findstr "tvnserver.exe" >nul
if %ERRORLEVEL% == 1 goto starttvnc
goto afterstarttvnc

:starttvnc
start "" %tvncpath%
rem Wait 0.5s for the server to start up
ping 192.0.2.2 -n 1 -w 500 > nul

:afterstarttvnc

start "" %tvncpath% -controlapp -sharerect 1920x1080+0+0
start "" %tvncpath% -controlapp -connect %bbb-address%

echo press any key to stop sharing
pause >nul

rem Check if tvnserver is (still) running
tasklist /FI "IMAGENAME eq tvnserver.exe" | findstr "tvnserver.exe" >nul
if %ERRORLEVEL% == 1 goto afterstoptvnc
start "" %tvncpath% -controlapp -disconnectall
start "" %tvncpath% -controlapp -shutdown

:afterstoptvnc