Jul 232013
 

Update

We have released dfreerdp (FreeRDP for the DirectFB backend) as a package for the Raspberry Pi. Please go to our new blog post to get it!

Intro

RDP is a convenient way to connect to Windows and also other operating systems with RDP host software, e.g. Linux. RDP transmits display information more efficiently than VLC, as it sees the structure of the screen and it’s elements. It also allows to transmit audio information both ways – playback and recording, share printers, drives, and more. As it is an extensible protocol, efficient video / multimedia playback can be implemented – and has been implemented, albeit apparently only in Windows Media Player.

The Raspberry Pi is a low-power device, with Full-HD (and audio) capable HDMI output.

FreeRDP is a mighty utility to connect to RDP servers, and utilize many of their possibilities. It even supports the video extensions for RDP (in RDP lingo: video redirection virtual channel extension) with ffmpeg. Don’t get your hope up too high right now, though: while theoretically feasible in software, it still would have to be written for both the Raspberry AND the host (it is not a “plug & forget” solution, but the software run on the server has to support it specifically).

The current state: A marriage made in heaven?

Not quite. FreeRDP is easily installed, and used from an X session. But it is … agonizingly slow. Audio playback is in a bad state.

The problem: X adds a very high overhead to any application, but even more so a graphics intensive, such as FreeRDP. Even super-charging the Raspberry Pi with overclocking, Class 10 SD cards, a beefy power supply, etc. will NOT solve this problem! An RDP client compiled specifically for Wayland might, but this is still some way off.

Solution

FreeRDP can be compiled to draw to the Direct Frame Buffer. This eliminates all of the overhead, which X would add. This is perfect for people really trying to use the Raspberry as Windows / RDP thin client. It will work in FullHD resolution (over the local network), with sufficient performance (and 16 bit color depth).

Kudos are in order to the Tao of Mac blog, which had the idea, and the instructions to get me up and running. You rock!

We will release a hardware & software package RDP client, based on the Raspberry, really soon now. If you’re interested, hit me up in the comments.

Step-by step instructions

With all that out of the way, let’s jump into the instructions!

Preparation

We suggest to use a Class 10 SD card, with ample space for the installation & build of the packages (8 GB Class 10 seems sensible). Install the newest Raspbian image, set up your locale and keyboard layout, aptitude update and aptitude upgrade.

Install the necessary packages:

aptitude install build-essential git-core cmake libssl-dev libx11-dev libxext-dev libxinerama-dev libxcursor-dev libxdamage-dev libxv-dev libxkbfile-dev libasound2-dev libcups2-dev libxml2 libxml2-dev libxrandr-dev libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev libavutil-dev libavcodec-dev libcunit1-dev libdirectfb-dev xmlto doxygen libxtst-dev

This should take quite a while.

Download the FreeRDP package (use a sensible location, we will be compiling there later. If in doubt, a sub-folder in your home folder is OK):

wget https://github.com/FreeRDP/FreeRDP/archive/1.0.2.tar.gz

You might also consider checking out the 1.0.3 pre-release version. It might turn stable in a couple of months.

Set up the build environment – this is analoguous to ./configure seen in many other compilations:

cmake -DCMAKE_BUILD_TYPE=Release  -DWITH_FFMPEG=OFF -DWITH_XINERAMA=OFF -DWITH_XCURSOR=OFF -DWITH_DIRECTFB=ON -DCMAKE_INSTALL_PREFIX=~/freerdp

A couple of hints for this:

  • You might want to adjust the –DCMAKE_INSTALL_PREFIX to something more suitable – if you compile as root, it will install the application and the libraries into the folder /root/freerdp otherwise.
    A good choice could be /usr – this way the binaries and libraries will be in the normal search path.
  • turning off FFMPEG means turning off virtual video extension. As discussed before, this is of limited use anyway, right now. But some experimenting might be interesting. FreeRDP also is built modularized on top of FFMPEG, so exchanging that for an omxplayer-like code thingy SHOULD be feasible.
  • Xinerama – is an X extension which allows X applications to span two or more displays a one large virtual display.

Check for the output of this command. It will tell you about skipped options and missed packages. It should find DirectFB amongst others (Found DirectFB: /usr/lib/arm-linux-gnueabihf/libdirectfb.so).

  • pulseaudio: this is a sound server, and another layer on ALSA. It is network capable. Users report varying mileage with pulseaudio and good playback quality. We have tested without the pulseaudio package, future tests will show whether there is an advantage in using it.
  • pcsc – this is for smart card support, most likely you will not need it
  • CUnit – a lightweight system for writing, administering and running unit tests in C – most likely you will not need this, either.

Compile the DirectFB RDP client:

cd client/DirectFB/
make

#optionally 
sudo make install

#for sound support
cd ../../channels/drdynvc
make
sudo make install
cd ../rdpsnd
make
sudo make install

This is all – but this will take quite a while (some hours).

Set up some configuration files

Edit your /etc/udev/rules.d/99-input.rules to be:

SUBSYSTEM=="input", GROUP="input", MODE="0660"
KERNEL=="tty[0-9]*", GROUP="root", MODE="0666"
KERNEL=="mice", MODE="0666"
KERNEL=="fb0", OWNER="root", MODE="0660"

The first line should aready be in the file, add the other three lines.

Optional, but recommended: Edit your /boot/config.txt to contain the following settings:

framebuffer_width=1920
framebuffer_height=1080
framebuffer_depth=16
# for other stuff
gpu_mem=128

arm_freq=800
disable_overscan=1
hdmi_drive=2
hdmi_ignore_edid=0xa5000080

This will

  • set your resolution as fixed [framebuffer_width, framebuffer_height] – be sure to adjust to your needs!
  • set bit depth to 16 – as we will connect to the RDP server using this depth for better performance.
  • ignore anything the monitor will tell the Raspberry – it might lead to blurry edges, otherwise [hdmi_ignore_edid=0xa5000080]
  • overclock the raspberry just a little [arm_freq=800]
  • disable the overscan – remove the black area around the display output on modern LCD monitors [disable_overscan=1]
  • set up the HDMI output to be a real HDMI output and carry audio – this will fix “no sound output” problems [hdmi_drive=2] don’t use this if you connect your Raspberry via DVI or VGA to the monitor

Edit /etc/fb.modes and add a new mode:

# Added as per taoofmac instructions
mode "1920x1080-24p"
   geometry 1920 1080 1920 1080 32
   timings 13468 148 638 36 4 44 5
endmode

You will have to adjust this if you use a different resolution than FullHD. The original article at Tao of Mac has some more resolution examples for you.

Create a new file /etc/directfbrc with the following contents:

system=fbdev
autoflip-window
desktop-buffer-mode=auto
vt-switching
graphics-vt
no-deinit-check
no-motion-compression
no-translucent-windows
memcpy=arm
mode=1920x1080
depth=16
dma
hardware
# for the moment, we need DirectFB's own cursor sprite
cursor

Reboot.

 

Usage

If you specified –DCMAKE_INSTALL_PREFIX to be /usr, you should be able to use FreeRDP DirectFB client without any path prefix, else just prepend your path:

dfreerdp -u "user name" -p secret_password_here -f -g 1920x1080 -x l -z --disable-full-window-drag  --gdi hw --plugin rdpsnd --data alsa --  host:port

Be sure to adjust this command:

  • “user name” should be your user name. If it contains a space, you should keep the quotation marks, else you can loose them.
  • secret_password_here should be your password, obviosly.
  • -g specifies the geometry. Adjust, as necessary.
  • -x = experience (l for LAN), will enable different bells and whistles. You might want to modify that, or use a more finegrained control of which features to enable, and which to disable
  • -z enable compression (useful)
  • –gdi hw – I’m not sure whether this is really necessary
  • –plugin rdpsnd –data alsa —  – this will enable remote sound output on the Raspberry. Drdynvc is said to have better quality, but I could not get it to work unfortunately. And, yes, the trailing double dashes are part of this option.
  • server:port – can be specified as domain or IP adress. The :port can be omitted, if you are connecting to the default RDP port (3389)

If you want sound output on the remote machine, use the –o switch.

 

FAQ

What about keyboard layout?

It will work exactly as you see your keyboard input on the Raspberry console itself. Even the Windows key should work. If your layout does not work on the Raspberry console, consider setting it up using raspi-config

Will this work over WLAN?

Sure it will. Just adjust your WiFi dongle for optimum throughput and latency (yes, literally change its position, tilt, etc. until you find the best performance spot!)

We recommend you the following packes for graphical / console adjustment of Wireless settings:

aptitude install wicd wicd-gtk wicd-curses

Will Skype work?

Not tested yet – enlighten us Smile This will need microphone redirection, too.

Will forwarding of devices work?

Not tested yet – inform us about usb printers, thumb drives, etc.

How can I test sound output on the Raspberry?

aplay /usr/share/scratch/Media/Sounds/Vocals/Singer2.wav -v -V mono

Will performance over WAN networks be OK?

Yes, pretty much – sound output will suffer (a lot), but the GUI will still be quite usable. You might want to adjust the flags to disable some eye candy.

Why do the browsers “stutter” during scrolling?

In my understanding: Unfortunately browsers need a very high degree of control over their screen outputs, and thus they render it themselves, instead of letting Windows do it – RDP sees browser output as image, which is retransmitted when scrolling. Playing with image compression options might alleviate this problem a bit.

Will accessing Linux hosts over RDP work?

Not out of the box – you will need to install an X to RDP conversion software.

In a very quick and rough test, a connection set up by the Scarygliders X11 RDP O Matic as a server backend did not work reliably enough (it was installed on a Pentium IV Linux server). It might do so with some tuning.

Or another backend / solution might do the trick. Looking forward to your input Smile

 

Known problems

  • Flash (isn’t it always on some list?) – will deliver horrible audio performance, native players (Foobar2000) will be OK, though.
  • Video playback – don’t even dream of playing YouTube videos over an RDP connection … the time is not ready yet, the software not written. Care to join a noble cause?
  • WLAN performance will depend on WLAN throughput and latency. The orientation of your dongle – especially nano dongles – will be very important. It can be tuned to a decent performance state, though.
  • I can’t get the new / style switches to work with FreeRDP, fallback to the legacy – switches for now.
  • Sound output: only rdpsnd works, –plugin drdynvc –data tsmf:audio:alsa:plughw:0,0 — will not work – maybe this is a configuration issue, though and some other parameters need to be passed. Drdynvc is said to have better quality. The issue might be with servers with no sound card drivers installed. I did not find an easy solution to this, and I am looking forward to your suggestions.
  • Connection to Linux RDP server compiled with X11 RDP O Matic is not stable for me.

References & further reading

Apr 272013
 

If you have a powerful primary machine (for instance a Dell notebook with an Intel Core i7 processor), it can easily run several Operating Systems and user sessions in / on them side by side – virtualisation is the magic of today’s computing.

The Raspberry Pi, whilst not having enough general purpose power to do really pleasant desktop computing, can very well serve as a “window” to Windows, Linux, MacOS and other more exotic systems running elsewhere. You could run several users off a powerful server machine – all you need is some networking gear, monitors, mice, keyboards, and of course Raspberry Pis.

Your users will enjoy an absolutely silent and energy-efficient client, while the noisy server is hidden away in the basement somewhere (or is in the admin’s room).

Access Windows from the Raspberry Pi

Today we will show you how to access a virtualised Windows desktop from the Raspberry Pi.

VirtualBox

On the host computer which will run the Operating Systems and user sessions for the Raspberry Pi terminals, you should install Oracle’s VirtualBox. (If you are not a fan of Oracle, remember that this was not developed by them but by SUN, and rebranded later on).

The host computer ideally should have hardware virtualisation extensions in the processor, which will allow the guest systems to run much more fluently.

We assume that you run Windows 7+ on the host. VirtualBox also works on Linux, though.

Run VirtualBox, and set up a Windows virtual machine (how to do this is outside the scope of this document).

Networking setup

Here’s the important part to know: initially the virtual network adapters for your virtual machine are set up as “NAT” devices. To be able to access RDP and all other parts freely on your network, the network adapter should be set up as “Bridged Adapter”.

image

This will connect it directly to your network – the machine will be seen outside of the host computer. If you have a DHCP server running, Windows by default will fetch it’s IP address from the DHCP server (e.g. your router).

To be able to access the virtual machine without looking up it’s address first, we recommend to assign a static IP for it ( outside of the area your DHCP server uses to assign IPs).

This is done by right-clicking on the network adapter in Windows, bringing up it’s properties, and editing the IPv4 properties. Whilst being mostly outside of the scope of this short how-to, I’ll share a screenshot with you, which should help you:

image

adjust your settings accordingly.

Note:

The current IP address of your windows computer can be determined by hitting the Windows key, writing “cmd”, pressing Enter (to bring up the command line), and the following command:

ipconfig

image

 

RDP Setup

This part can also be applied to physical machines running Windows.

To allow remote connections to your Windows machine, you have to enable RDP connections first. This is done by hitting the Windows menu, right-clicking on “Computer”, selecting the entry “Properties”.

In Windows 7, you have to click on “Remote settings” in the sidebar of the window which you will see. The dialogue which comes up, will allow you to configure RDP settings.

image

Select “allow connections from computers running any version of Remote Desktop (less secure)”. Click “OK”.

Creating new user

If you do not have a password protected user in your virtual Windows installation yet, you should set one up. You can either create an admin user or a regular Windows user. Using these credentials you will be able to connect to the machine later on. Of course you can also create a new password for the user you already have, if you have decided not to use a password initially.

Raspberry Pi

Start an X session:

startx

Launch the root shell (start menu > Other > X-Terminal as root (GKsu).

Update apt package cache (if you don’t have aptitude, use apt-get):

aptitude update

Install rdesktop package

aptitude install rdesktop

After rdesktop is installed, it is literally just one short command to connect to your virtual Windows desktop:

rdesktop 192.168.1.3

Just replace the IP address with the IP address of your Windows virtual box.

Rdesktop will start a window and allow you to log in to your Windows virtual box. You can click on “Other user” and insert your login credentials here. If another user is logged in at the main machine / via another terminal, Windows might request you to wait for 30 seconds so the other user might allow or disallow your connection.

If you want to launch a full-screen session, you can use the –f switch

rdesktop -f  192.168.1.3

Forwarding sound of the Windows machine to the Raspberry is also possible. Unfortunately it will sound horrible (choppy / barely understandable) – I am not sure what the reason is, as the Raspberry Pi processor is not maxed out (e.g. when streaming Web radio). The sound will sound the same over HDMI and analog output (tested today).

rdesktop -r sound=local 192.168.1.3

Some further options will improve your experience:

rdesktop -z -x lan -P 192.168.1.3

These switches have the following meaning:

-z: enable compression

-x lan: set experience to “LAN” (will show desktop wallpaper, windows while moving them etc.)

-P: enable caching to disk (i.e. the Raspberry Pi’s disk)

Some screenshots

rdesktop-on-raspberry-pi

 

libreoffice-rdesktop-raspberry

Experience

YouTube

YouTube will run, but very choppy – it will max out the Raspberry Pi’s processor. (This is a software problem – rdesktop is probably not using the efficient GPU of the Pi for processing). Sound quality is horrible, actually you can’t really understand it – it’s all chopped up. Sound quality will improve if you minimize YouTube (thereby limiting screen updates which are required, and lowering the load on the Raspberry processor). Sound will still sound choppy, though. All in all not good enough right now.

Sound

As mentioned above, sound quality (if forwarding sound) will be nearly unbearable. Maybe there are some better solutions (i.e. combining a sound streaming server which captures the sound and plays it back on the Pi).

The sound unfortunately will not improve if setting the Group Policy, and forcing sound quality to “high” on Windows. (use gpedit.msc)

Update

The sound problems seem to occur from buffer underruns on the Raspberry Pi side. (see below, xfreerdp).

Desktop experience

Especially with the optimised parameters (-z –x lan –P) the experience is really smooth. For word processing, spreadsheets and web browsing, you will be pleasantly surprised by the reaction speed.

Drawing & photo manipulation will be doable, but in a test with Paint, there was some slugginess.

Actually I see a huge potential in classical desktop / web application workspaces – where you don’t need multimedia, i.e. in a call center where people use web forms and interfaces to access your account with the company.

xfreerdp

xfreerdp is an alternative RDP client. You can install it using

aptitude install freerdp

And use it

xfreerdp -u Wanda -x l -z --plugin rdpsnd --data alsa -- 192.168.1.3

Please note the “x” in front of freerdp here.

This will connect with the user “Wanda”, enable LAN experience, enable compression (-z), and activate sound forwarding through the rdpsnd plugin. The two double dashes after “alsa” and before the IP of the host virtual machine ARE necessary.

Sound will still sound horrible – it will spew out a lot of “underrun occurred” messages on the console. We have tested different options to decrease load, increase latency, use the tsmf option, etc – nothing changed the horrible quality. Right now, the verdict stays the same: great for desktop computing, but not at all for multimedia applications.

There may be some improvement with the current GIT version of freerdp. We have not tested it yet.

Optimization WordPress Plugins & Solutions by W3 EDGE