After using dd
to write Raspbian to a memory card I went on to configure the a VNC server to simplify remote configuration.
Before doing any configuration you should make sure your pi is up to date. Run:
sudo apt-get update && sudo apt-get dist-upgrade
Installing VNC Server
When the pi is up to date we can move on to installing the VNC server.
I’m using x11vnc as it works well with Raspberry Pi and lets you share the X session started by the pi itself. To install it:
pi@raspberrypi ~ $ sudo apt-get install x11vnc
First time configuration
After installation we want to run x11vnc once to store the password we will use to connect later.
If you are running over SSH we need to export the X display before continuing. Also make sure an X server is running before you attempt this.
pi@raspberrypi ~ $ export DISPLAY=:0 pi@raspberrypi ~ $ x11vnc -storepasswd Enter VNC password: Verify password: Write password to /home/pi/.vnc/passwd? [y]/n y Password written to: /home/pi/.vnc/passwd pi@raspberrypi ~ $
Type in the password you want to use and make sure you remember it for when you connect later. You can rerun this command if you need to reset the password.
Configuring VNC server as a service
To make the VNC server start at boot we can use this simple init script I made.
pi@raspberrypi ~ $ sudo nano /etc/init.d/x11vnc
Paste in the following code, then save (Ctrl + x, then y).
These defaults should be fine for normal use though you can optionally change resolution and more. Modify the OPTIONS
variable highlighted below to change VNC options. Check the manual for x11vnc for more options.
#!/bin/sh ### BEGIN INIT INFO # Provides: x11vnc # Required-Start: $remote_fs $syslog # Required-Stop: $remote_fs $syslog # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: Start VNC Server at boot time # Description: Start VNC Server at boot time. ### END INIT INFO USER=pi OPTIONS="-usepw -noxdamage -ncache 10 -ncache_cr -listen 0.0.0.0 -forever" export DISPLAY=:0 eval cd ~$USER case "$1" in start) echo "Starting VNC Server" #Insert your favoured settings for a VNC session su $USER -c "/usr/bin/x11vnc $OPTIONS" > /var/log/x11vnc.log 2>&1 & ;; stop) echo "Stopping VNC Server" PID=`ps -u $USER | grep x11vnc | awk {'print $1'}` su $USER -c "kill -9 $PID" ;; restart) $0 stop && sleep 2 && $0 start ;; *) echo "Usage: /etc/init.d/x11vnc {start|stop|restart}" exit 1 ;; esac exit 0
Make the new file we created executable
pi@raspberrypi ~ $sudo chmod +x /etc/init.d/x11vnc
Then we add it to start at boot
pi@raspberrypi ~ $ sudo update-rc.d x11vnc defaults
Before we restart we want to start the server once and configure the password.
pi@raspberrypi ~ $ sudo service x11vnc start
You can try to connect to the desktop but I recommend restarting the pi to ensure that the VNC server starts at boot.
pi@raspberrypi ~ $ sudo reboot
Preparations for TP-Link (TP-Link TL-WN725N)
Make sure the pi is updated before proceeding and to be extra sure restart it.
When we install the driver we will load it into the kernel as a kernel module, which is how Linux works with drivers.
We want to know what kernel version we are on currently:
pi@raspberrypi ~ $ uname -a Linux raspberrypi 3.12.35+ #Note this number
So 3.12.35 is the kernel we’re using right now. To successfully install the wifi driver we need the kernel headers to be installed for when we compile the driver.
Now we need to find the appropriate headers, hopefully they are in the repository. Let’s use apt to search for them.
pi@raspberrypi ~ $ apt-cache search linux-headers linux-headers-3.10-3-all - All header files for Linux 3.10 (meta-package) linux-headers-3.10-3-all-armhf - All header files for Linux 3.10 (meta-package) linux-headers-3.10-3-common - Common header files for Linux 3.10-3 linux-headers-3.10-3-rpi - Header files for Linux 3.10-3-rpi linux-headers-3.12-1-all - All header files for Linux 3.12 (meta-package) linux-headers-3.12-1-all-armhf - All header files for Linux 3.12 (meta-package) linux-headers-3.12-1-common - Common header files for Linux 3.12-1 linux-headers-3.12-1-rpi - Header files for Linux 3.12-1-rpi linux-headers-3.2.0-4-all - All header files for Linux 3.2 (meta-package) linux-headers-3.2.0-4-all-armhf - All header files for Linux 3.2 (meta-package) linux-headers-3.2.0-4-common - Common header files for Linux 3.2.0-4 linux-headers-3.2.0-4-rpi - Header files for Linux 3.2.0-4-rpi linux-headers-3.6-trunk-all - All header files for Linux 3.6 (meta-package) linux-headers-3.6-trunk-all-armhf - All header files for Linux 3.6 (meta-package) linux-headers-3.6-trunk-common - Common header files for Linux 3.6-trunk linux-headers-3.6-trunk-rpi - Header files for Linux 3.6-trunk-rpi linux-headers-rpi - Header files for Linux rpi configuration (meta-package) linux-headers-rpi-rpfv - This metapackage will pull in the headers for the raspbian kernel based on
Okay. We found some headers but not for 3.12.35 which we are using, which means two things:
1. Either upgrade or downgrade the kernel to a version where we can install the headers from the repository
2. Compile a kernel from scratch and include the headers.
I went with the first option and this time actually downgraded for some reason to 3.2.0.4-rpi. The newer kernels will work just fine as well and I recommend using the newest one available that has headers available in the repository.
To change kernel I simply installed the kernel, image and associated headers
sudo apt-get install linux-3.2.0.4-rpi sudo apt-get install linux-image-3.2.0-4-rpi sudo apt-get install linux-headers-3.2.0-4-all
After it is installed you should see the kernel image in the /boot/ directory:
pi@raspberrypi ~ $ ls /boot | grep initrd initrd.img-3.2.0-4-rpi initrd.img-3.6-trunk-rpi
Then to tell the bootloader to load this kernel we have to change /boot/config.txt and include two lines.
pi@raspberrypi ~ $ sudo nano /boot/config.txt
Change the version number depending on the image name in /boot/.
kernel=vmlinuz-3.2.0-4-rpi
initramfs initrd.img-3.2.0-4-rpi followkernel
So now we’re using initramfs to load our wanted kernel version instead of the default kernel.img. You could also replace the kernel.img but this way we have a fallback kernel to load should or wanted version fail for some reason.
Reboot and then run:
pi@raspberrypi ~ $ uname -a Linux raspberrypi 3.2.0-4-rpi #1 Debian 3.2.51-1+rpi1 armv6l GNU/Linux
Success! Time to move on to compiling the driver!
Installing Wifi driver for TP-Link
Thanks to the raspberry pi forums installing the required driver is fairly straight forward.
We have to compile the appropriate driver for our kernel version. This is a bit complicated but we’ll break it down into multiple steps.
First we prepare our environment.
pi@raspberrypi ~ $ mkdir src pi@raspberrypi ~ $ cd src
Then clone the git repository with the driver
pi@raspberrypi ~/src $ git clone https://github.com/lwfinger/rtl8188eu
When it’s done we have to compile the driver from the source files we just cloned.
Change into the new directory we’ve cloned
pi@raspberrypi ~/src $ cd rtl8188eu
This step will take a while, probably 10-15 minutes.
pi@raspberrypi ~/src/rtl8188eu $ make all
When it is done we have to install it
pi@raspberrypi ~/src/rtl8188eu $ sudo make install
And the last step is to copy the bin file we’ve just compiled to the appropriate directory.
You might have to create the directory yourself if it doesn’t exist:
pi@raspberrypi ~/src/rtl8188eu $ sudo mkdir -p /lib/firmware/rtlwifi
Then copy the driver
pi@raspberrypi ~/src/rtl8188eu $ sudo cp rtl8188eufw.bin /lib/firmware/rtlwifi
Now all we have to do is reboot and the wireless driver should be loaded!
Comments