Intro: The Frankenputer! (Raspberry Pi Laptop)
I've been into the Raspberry Pi for quite a while now and I've always hankered after making a decent portable computer out of an RPi, but having tried to build one using either a Motorola Atrix lapdock, or the RPi touchscreen display, neither of which was very successful, I had almost given up ... until ... I had a sudden flash of an idea and with a "Presto Changeo!" flourish, I turned my HP Windows portable into a Raspberry Pi portable in just an afternoon!
I call this my "Frankenputer" because it is stitched together out of two separate computers.
The basic idea is ridiculously simple: attach a Raspberry Pi to the lid of the portable and connect it with a short USB cable for power and a short Ethernet cable for networking.
The windows PC shares its wifi connection over its ethernet port, and for keyboard and display I run tightvncserver on the RPi and tightvnc viewer on the Windows. So by clicking on the vnc icon I can turn the computer instantly from a Windows portable into a Raspberry Pi portable.
Linux on a Windows PC is something that you could approximate with just emulation (eg VirtualBox), so to take full advantage of the Raspberry Pi I've also attached a breadboard next to the RPi that lets me build circuits using it as well. I'll demo that at the end of this instructable with the 'blink' program that shows when your RPi has booted up and is ready for use.
Step 1: What You'll Need...
- Portable computer with ethernet socket and wifi ($359)
- 6in Ethernet cable ($5.25, or crimp your own)
- right-angle USB A to Micro-USB cable ($2.24)
- Small Stand-offs ($7.99)
- Optional: (Kit? - $17.85)
- Breadboard (with self-adhesive backing)
- 470Ohm resistor (or thereabouts)
- RED LED
- Male-Female jumper wires
Fortunately the only things in the list that I had to buy were the short USB cable and the standoffs :-) The Breadboard etc I had around from previous projects and kits acquired from Radio Shack during closing down sales. (Though I hear they're back from bankruptcy and have a more hobbyist focus nowadays - I wish them well in this return to their roots)
Step 2: Assemble and Attach - WITH CAVEATS
THIS WILL MESS UP THE LID OF YOUR COMPUTER PERMANENTLY so obviously you only do this if you're OK with leaving sticky residue behind if/when your ever remove this setup. In fact if the glue in your self-adhesive components is too strong you may well never be able to remove the RPi or the breadboard from your computer again ever. I'm the sort of person who doesn't mind permanently attaching a bunch of stuff with wires to their portable but you may not be - especially if you ever expect to take it through an airport, where they can be somewhat sensitive to electronics with dangling wires and flashing LEDs...
I've removed the RPi once and was able to rub all the residue off with my fingers but you may not be so lucky. I've never tried removing the breadboard which uses a fierce adhesive! Also be careful both when putting this in place, and if you ever try to remove it, not to push hard on the back of your lid in any way that might damage your screen.
Attaching the breadboard is optional, so if you're worried about it being stuck down too well, you might decide to skip that part and just install the Raspberry Pi.
The image here shows what we're trying to do. The only tricky parts are:
- Attaching the stand-offs to the Raspberry Pi
- Positioning the RPi so that the cables don't get stretched when you open the portable lid
I found that I had to pinch the head of the standoffs with a pair of pliers to get them small enough to fit through the PCB holes in the RPi. (Note that the earliest RPi didn't have 4 mounting holes so check yours before you start this project)
Attach as per the image (you may have to shuffle things around to accommodate the USB and ether outlets on your own portable) and once you're happy with the arrangement, stick them down with the self-adhesive pads. I have to say I'm pretty pleased with the way it turned out - the RPi doesn't get in the way for normal Windows PC use and it makes a great conversation starter when you're working in your local coffee shop, as well as being functional.
Step 3: Windows-side Software
Configure network sharing. Your portable should already be configured to use Wifi. Select the wired ethernet interface and add network sharing to it, using the Wifi connection as the shared network to add.
Then install the Windows TightVNC client and also Putty. When you have tightvncserver running successfully on the RPi side, make a connection and then save the
.vnc connector info as an icon so that you can reconnect immediately. I always save the RPi password in the connector file even though it's not secure, since there's nothing of value on my RPi, and you would have to compromise my Windows PC first before you could compromise the RPi, in which case I would have bigger problems than someone knowing the RPi password. You'll want to set fullscreen mode in the connector as well but that's tricky because VNC exits fullscreen to give you access to the save menu, and it never saves that parameter. The trick there is to edit the
.vnc connector with a text editor and modify the parameters by hand. Here's mine:
[connection] host=192.168.137.8 port=5901 password=(some poorly encoded string) [options] use_encoding_1=1 copyrect=1 viewonly=0 fullscreen=1 8bit=0 shared=1 belldeiconify=0 disableclipboard=0 swapmouse=0 fitwindow=0 cursorshape=0 noremotecursor=1 preferred_encoding=7 compresslevel=-1 quality=6 localcursor=0 scale_den=1 scale_num=1 local_cursor_shape=0
Now double-clicking that
.vnc connector brings up the RPi as fullscreen with a normal-looking cursor.
Step 4: Raspberry Pi Software
During setup, you may need to attach a USB keyboard and mouse and hook up the RPi to an HDMI monitor, in order to configure the initial networking and get the RPi ready for use as a slave computer. (Although by default you ought to get a DHCP address automatically and be able to connect using ssh (Putty) - the only tricky part will be determining the IP address to connect to, which you could do by probing the shared subnet from the Windows side.)
The RPi will use the shared subnet and ought to be able to access the internet (though incoming network connections will stop at the Windows PC and won't be forwarded to the RPi unless you explicitly configure the PC to do so) and you should have DNS available though for some reason I did not, so I manually added 184.108.40.206 as a nameserver in /etc/resolv.conf)
Once networking is working, install tightvncserver and set a connection password. This is stored insecurely by tightvnc so don't use your real password; however it is only accessible from your portable so it is not a major risk unless your portable is compromised, in which case you have bigger problems.
If you want to get fancy, you can mount the "My Documents" and "Downloads" directories from your Windows PC onto your Raspberry Pi. I added these lines to my /etc/fstab:
pi@frankenputer:~ $ cat /etc/fstab proc /proc proc defaults 0 0 /dev/mmcblk0p6 /boot vfat defaults 0 2 /dev/mmcblk0p7 / ext4 defaults,noatime 0 1 # a swapfile is not a swap partition, no line here # use dphys-swapfile swap[on|off] for that //192.168.137.1/Users/gtoal/Documents /home/pi/Desktop/Documents cifs username=pi,password=INSECURE1,uid=pi,gid=pi 0 0 //192.168.137.1/Users/gtoal/Downloads /home/pi/Desktop/Downloads cifs username=pi,password=INSECURE1,uid=pi,gid=pi 0 0
Note that I had to add a 'pi' user to the Windows PC and give it admin privileges so it could access those folders on the Windows PC. I also had to make a specific exception for the IP address of the RPi in the Windows firewall. Neither of these are particularly secure; they're a risk I'm willing to take but you may not be. You might prefer to not share those directories at all, or perhaps set something up using sshfs and keyfiles instead.
Step 5: Set Up the Breadboard (optional)
If you attached a breadboard, you'll need to hook up power and ground. I've put +3.3V and Ground on the left bus bars and +5V on the right. Use the pin numbering diagram to chose where to get those signals from. I used Pin 1 for 3.3V, Pin 4 for 5V and pin 6 for Ground. There are other pins available, it's your call.
In this test circuit with the LED, we only use the GPIO pin that drives the LED and Ground, neither +3.3V nor +5V are needed, but you do want them connected to the breadboard for future projects.
I decided to drive the LED from GPIO 18 which is connector pin 12. I picked that one simply because it was easy to count down 3 pins from where I had the Ground connector.
You should make yourself familiar with any basic RPi LED intro before hooking up the LED and the resistor, just to make sure you have a good resistor value for whichever LED you are using, and to ensure you insert the LED the right way round. The short leg attaches directly to Ground and the longer leg attaches to one end of the resistor. The other end of the resistor is connected to GPIO 18 (the blue wire coming from Pin 12 in the photo)
Step 6: Install the LED Code on the RPi
Here are the modifications I made to /etc/rc.local on the RPi:
# Print the IP address _IP=$(hostname -I) || true if [ "$_IP" ]; then printf "My IP address is %s\n" "$_IP" su -l pi -c "vncserver :1 -geometry 1360x760 -depth 24" 2>&1 > /dev/null & ( /home/pi/bin/led-setup; /home/pi/bin/led-blink ) > /dev/null 2>&1 & fi
This also includes the setup for the vncserver so that it starts automatically when the RPi is booted. (I tweaked the screen resolution so that I could go full screen on my portable which is actually 1366x768, however if I used those numbers exactly, VNC added unwanted scrollbars.)
The led-setup script initialises the GPIO pin for output. This is only called once at power up.
#!/bin/sh echo 18 > /sys/class/gpio/export echo out > /sys/class/gpio/gpio18/direction echo 1 > /sys/class/gpio/gpio18/value
and the led-blink script is just a loop that toggles the signal on that pin:
#!/bin/sh echo out > /sys/class/gpio/gpio18/direction while [ /bin/true ] ; do echo 1 > /sys/class/gpio/gpio18/value sleep 0.3 echo 0 > /sys/class/gpio/gpio18/value sleep 0.3 done
Step 7: Power Mad!
You're pretty much set up now. When you power up your Windows PC, the RPi will power up as well and when the external LED starts blinking, you know the RPi is ready for you to log in. Double-clicking the saved VNC icon should replace your windows desktop with an RPi desktop and the experience is just like using a custom built RPi portable computer. You'll have networking, graphics, your Documents from Windows, and any external hardware you want to build on the breadboard. You won't have sound, but that's a challenge I'll leave for you to solve.
When you close the lid of your portable, one of two things may happen. Either the USB connector which is powering the RPi will drop power, in which case your RPi will unceremoniously power down (ie not a clean shutdown, so in the long term you risk SD card corruption) or power will stay online, in which case you'll be burning a miniscule amount of battery power - possibly indefinitely.
It is possible on some PCs to control the behaviour - the USB which normally drops power can be made to leave it on - this is a feature intended for charging cellphones. The details will be vendor-dependent.
What I'm working on (so far unreliably) is detecting that the Windows system is going away and doing a clean shutdown quickly before the power drops. Because windows kills the ethernet connection before it sleeps the PC, it's possible to get a few milliseconds warning by monitoring the ether status in
/sys/class/net/eth0/carrier, but I haven't been able to shutdown from that indication consistently yet. Note that although an RPi shutdown does not kill power completely, it does reduce the power usage to negligible amounts (as confirmed by my USB power meter)
I know I've glossed over some of the details to keep this within a readable size, but I've pointed out the main issues and you can find the details with a Google search. Please do post your successes or problems in the comments section and especially if you find ways to improve this setup do let us all know.