Tuesday, 23 July 2013
Monday, 14 January 2013
GitHub has a very interesting article for cross compiling for the Raspberry Pi using a another PC as the compiler over a network.
Monday, 15 October 2012
"One of the most common suggestions we’ve heard since launch is that we should produce a more expensive “Model C” version of Raspberry Pi with extra RAM. This would be useful for people who want to use the Pi as a general-purpose computer, with multiple large applications running concurrently, and would enable some interesting embedded use cases (particularly using Java) which are slightly too heavyweight to fit comfortably in 256MB.
The downside of this suggestion for us is that we’re very attached to $35 as our highest price point. With this in mind, we’re pleased to announce that from today all Model B Raspberry Pis will ship with 512MB of RAM as standard. If you have an outstanding order with either distributor, you will receive the upgraded device in place of the 256MB version you ordered. Units should start arriving in customers’ hands today, and we will be making a firmware upgrade available in the next couple of days to enable access to the additional memory.
I’d like to thank our partners, RS Components and element14/Premier Farnell, and the suppliers, particularly Samsung, Sony and Broadcom, for all their help in delivering a smooth transition to the 512MB. I’m looking forward to seeing what you all get up to with your shiny new Pis."
Wednesday, 19 September 2012
Tuesday, 18 September 2012
Guide: Compiling kernels and drivers for the Raspberry Pi - bootc I2C Kernel & Edimax EW-7811Un USB Wifi
In the past I have found compiling kernels for the Raspberry Pi to be a very frustrating experience, so I thought it would be a good idea to write this guide for my own future reference. If it helps anyone else have a better experience than me, then all the better!
If you have read any of my previous articles you may have seen that I have been playing with I2C IO Expansion chips via the GPIO port on the Raspberry Pi. As I have come to understand but not yet tested (if it ain't broke, don't fix), the latest 'Wheezy' kernel distribution now supports I2C drivers, however when I started this project with the 'Squeeze' 19-4-12 image the only way to use I2C was to use Chris Boot's own compiled images instead. Chris has been working on his own I2C drivers and building them into his own pre-built kernels for quite sometime now, simply loading his built image onto a SD card worked perfectly and I could program with I2C to my heart's content. Now, there was one small snag to this, my Edimax EW-7811Un USB Wifi Adapter.
The 7811Un drivers need to be compiled for the kernel it is to be used with. For the Raspbian images this was quite simple as the headers were available via a simple apt-get or I could get them pre-built using MrEngman's wonderful script but this isn't possible to do with the Bootc images as Chris explains. Therefore the only thing left to do is compile my own version of his kernel.
There are two ways of compiling a kernel:
- Compile on the target hardware.
- Cross compile for the target hardware.
The Raspberry Pi doesn't have a lot of memory or processing power available for an intensive task such as compiling a kernel, MrEngman has stated that it takes him about 7 hours to compile any latest official kernel releases and the wifi driver. I personally don't fancy waiting that long and he only does it so that he can simply hand out the driver to others, knowing it will work with the official release. As I'm making mine for my own personal use, the comparatively quick cross compile option is more sensible. A cross compiler is a compiler that runs on one type of computer architecture but creates a binary for another, in my case x64 to ARM.
I'll be using Ubuntu Server 12.04 LTS hosted on a VirtualBox virtual machine to do my compiling, using VirtualBox's shared folders to transfer data between the host and guest operating systems.
You'll now need the following files. Transfer them to your Ubuntu server or put them in the Vbox shared folder.
Realtek driver Unix (Linux) RTL8188CUS (Current: 3.4.4_4749)
Laest pre-compiled binary (.deb) from bootc.net (Current: 3.2.23)
Install cross compiler and Git source code management system
Run the following:
sudo apt-get install -y git-core gcc-4.6-arm-linux-gnueabi libncurses5-dev unzip
sudo ln -s /usr/bin/arm-linux-gnueabi-gcc-4.6 /usr/bin/arm-linux-gnueabi-gcc
Download the latest firmware and kernel source code
Take a note of the version of bootc you downloaded, I'll be using 3.2.23 as that is the latest at the time of writing this guide. Just substitute it with what ever version you are using.
git clone https://github.com/raspberrypi/firmware
git clone -b rpi-3.2.23 https://github.com/bootc/linux.git
Downloading the source code may time some time depending on your connection. It may look like it has hung on "Cloning into 'xxxxxxx'..." but it's most likely still working, just be patient.
When building a kernel there are many options to choose depending on what you want the kernel to do for you. Luckily Chris Boot has already compiled his kernel and provided it as a .deb package. Inside this package we can find the configuration that he used and then we can tweak it to suit our needs as well.
First we need to extract the contents of the .deb file downloaded earlier. Mine is kept in my shared folder ~/shared.
dpkg-deb -x ~/shared/linux-image-3.2.23-rpi1+_1_armel.deb /tmp/extract
cp /tmp/extract/boot/config-3.2.23-rpi1+ .config
sed -i 's/EXTRAVERSION =/EXTRAVERSION =-spi-i2c-rpi1/' Makefile
Next, we apply the config settings we got from Chris to the build we are about to do.
make ARCH=arm CROSS_COMPILE=/usr/bin/arm-linux-gnueabi- oldconfig
Now we need to make our own modifications to the compiler config.
make ARCH=arm CROSS_COMPILE=/usr/bin/arm-linux-gnueabi- menuconfig
You'll now be presented with a console menu system to help you configure your build. Use the arrow keys to navigate Up & Down through the menu, press Enter to go into a sub-menu and Space to make a selection.
Device Drivers. Press Enter to open.
Network device support. Press Enter to open.
Wireless LAN. Press Enter to open.
Realtek RTL8192CU/RTL8188CU USB Wireless Network Adapter. Press Space to unselect.
Press Tab then press Enter multiple times to go back up the sub-menus.
When asked 'Do you wish to save your new configuration?', select 'Yes' and press Enter.
Building the kernel
It's now time to compile the kernel! Note - the end of this command determines the number of processors on your system so that we can enable multithreaded compiling to improve compilation speed.
make ARCH=arm CROSS_COMPILE=/usr/bin/arm-linux-gnueabi- -k -j$(grep -c ^processor /proc/cpuinfo)
Now that the kernel has compiled successfully we can gather the kernel and module items to put onto our SD card. We'll place these in a folder called install in the rp1-3.2.23 directory.
mkdir -p ~/rpi-3.2.23/install/boot
make ARCH=arm INSTALL_MOD_PATH=~/rpi-3.2.23/install CROSS_COMPILE=/usr/bin/arm-linux-gnueabi- modules_install
make INSTALL_PATH=~/rpi-3.2.23/install/boot ARCH=arm CROSS_COMPILE=/usr/bin/arm-linux-gnueabi- INSTALLKERNEL=none install
Building the Edimax EW-7811Un Realtek 8192cu driver
We need to unpack the driver from the .zip file you obtained at the start. My zip file is stored in my shared folder.
tar -xvzf rtl8188C_8192C_usb_linux_v3.4.4_4749.20120730.tar.gz
Now it's unpacked we can compile it.
make KSRC=~/rpi-3.2.23/linux ARCH=arm CROSS_COMPILE=/usr/bin/arm-linux-gnueabi- -k -j$(grep -c ^processor /proc/cpuinfo)
We can now add the driver to the rest of the items destined for the SD card.
cp 8192cu.ko ~/rpi-3.2.23/install/lib/modules/3.2.23-spi-i2c-rpi1+/kernel/drivers/net/wireless
Installing the new kernel
Copy all files in ~/rpi-3.2.23/firmware/boot to the boot partition of the SD card.
Copy all files in ~/rpi-3.2.23/install/boot to the boot partition of the SD card.
Recursive copy all files and folders in ~/rpi-3.2.23/install/lib/modules/ to the system partition of the SD card and it's /lib/modules/ directory.
Overwrite the SD card's boot partition kernel.img with the one you built by copying the file 'vmlinux-3.2.23-spi-i2c-rpi1+' in the boot partition to 'kernel.img'.
Put the SD card in the Raspberry Pi and boot it up.
Log in as normal
You should now be able to configure your network settings and plug in your Edimax USB Wifi adapter.
Notes for the future
According to Chris Boot, the crosstool-ng cross compiler is easier to use and I believe I've read that it is provides more up-to-date support for ARM processors. I'll look into using this instead of the one used in this guide.
Try to merge the Wifi driver into the kernel rather than have it as a separate module.
Use make-kpkg instead of running the compilers separately which also gives the benefit of creating a .deb file for easier installation of the new kernel.
Wednesday, 12 September 2012
VirtualBox provides an excellent feature called Shared Folders. This feature allows you to share multiple folders between your host and virtual operating systems therefore making it much easier to transfer data between the two.
In Part 1 and Part 2 of this guide I showed you how to create your own virtual machine in VirtualBox and how to install Ubuntu Server 12.04.
In Part 3 I'll take you through the steps required to install the VirtualBox Guest Additions and how to create a shared folder between your main OS and Ubuntu Server.
Installing Guest Additions
If you've not done so already let's start your VM and log in. See Part 2 for more info if you are stuck.
Before we install the Guest Additions software, we need to install some prerequisite software that Guest Additions needs during installation.
- At the command prompt type the following text followed by the Enter key and enter your password when prompted:
sudo apt-get install -y dkms build-essential linux-headers-generic linux-headers-$(uname -r)
Next we need to load the Guest Additions software as a virtual CDROM and mount it in the OS.
- From the Devices menu of the VirtualBox window, select 'Install Guest Additions...'
- You'll notice that the CD icon at the bottom of this window will now become active and has a tooltip showing that VBoxGuestAdditions.iso is loaded.
- At the command prompt type the following and enter your password if prompted:
sudo mount /dev/cdrom /media/cdrom
- This has now mounted the contents of the CD into the folder /media/cdrom which you can view if you wish with the following command:
We can now install the Guest Additions software.
- At the command prompt type the following and enter your password if prompted:
- If you see a message saying "Installing the Window System drivers ...fail!(Could not find the X.Org or XFree86 Window System.)", don't worry about it. You're installing onto Ubuntu Server so you don't have any Windows systems, it's all console based.
Lastly we now need to add your current user to the user group 'vboxsf' so that you can view and edit shared folders.
- At the command prompt type the following where <your user name> is the user you are currently logged in as. Enter your password if prompted.
sudo usermod -a -G vboxsf <your user name>
Creating a shared folder
Firstly create or choose a folder on your host OS (Windows / OS X) that you wish to share with Ubuntu.
Next, from the Devices menu of the VirtualBox window, select 'Shared Folders...'
From the Folder Path drop down menu, choose 'Other...', then browse for and select the folder you wish to share on your host OS.
Tick Auto-mount and Make Permanent.
Now reboot your VM by typing the following:
Note that the folder is called the name you gave your share earlier and starts with a 'sf_'.
If you want to have easier access to the shared folder you can create a symbolic link to it in your home folder, a little like a shortcut to the real folder while.
ln -s /media/sf_Ubuntu_Share ~/Shared
Any files and folders you put into the share should now be visible to both Host and Guest operating systems.
Tuesday, 11 September 2012
In Part 1 I described how to set up a new blank virtual machine for Ubuntu Server 12.04 in VirtualBox. In Part 2 I shall walk you through how to install the operating system, boot it up, install updates and log in via SSH.
Installing the operating system
Select the VM you made in the list on the left and press the green Start button in the toolbar at the top.
Part 1 which is available from http://www.ubuntu.com/download/server
Press the yellow and green folder button to browse to the .iso file of the OS and press Continue.
Have the VirtualBox VM in focus, rather than say your web browser, then select your language with the arrow keys on the keyboard, in my case English, and press the Enter key.
If you are unsure, simply use the arrow keys to select 'Yes' and follow the on screen instructions that ask you to press various keys on your keyboard and if there are certain symbols present on any of the keys.
Press the Enter key to continue.
What ever you choose here... DON'T FORGET IT!
Select 'No' and press the Enter key to continue.
Press the Enter key to continue.
If all is well and you are connected to the internet, the installation will download extra data and continue automatically.
I'm a safety kinda guy so I choose to install them automatically.
Make your selection and press the Enter key to continue.
To install any of these software packages, use the arrow keys to highlight the item in red, press Space to make your selection(s) (denoted with a *) then press the Enter key to accept your choices.
The system will now reboot automatically.
Boot up and log in
Type in the user name you chose during installation and press the Enter key.
Then type in the password you chose for that user and press the Enter key. NB: You will not see any characters appear as you type your password.
You'll notice that when you log in you are presented with this welcoming message of the day and at the bottom of this message it tells you that there are updates available to install. We should do that.
Also, take a note of the IP address your VM has been assigned by your DHCP server, in my case it's '192.168.109.130'. We will need that later for logging in via SSH.
sudo apt-get update && sudo apt-get upgrade -y
This runs two commands which are chained together by '&&'.
The first command 'sudo apt-get update' will update the OS's list of where it gets it's updates from.
'sudo' means it will run the command with special system administrator priviliges of a user called root. See http://en.wikipedia.org/wiki/Sudo for more info.
The second command 'sudo apt-get upgrade -y' then performs a system upgrade using the latest updates. The '-y' tells the command to perform the upgrade without asking for confirmation. You may wish to leave the '-y' out so you can confirm each upgrade by pressing 'y' when prompted, but for a first time upgrade I'm usually pretty confident that all will be ok.
Let's reboot to activate the latest upgrades, type the following and press Enter, typing in your password if prompted:
You can now log in as before and continue working or alternatively log in via SSH.
Logging in using SSH
On Windows, Putty can be used for SSH logins, however on OS X SSH is already built into terminal.
On OS X, load terminal and type the following:
ssh <user name>@<ip address>
where <user name> is the user you log in with and <ip address> is the IP address you noted down earlier. If you forgot this step, log in again via the VirtualBox window and take a note of the IP address in the welcome message.
You will then type the word 'yes' followed by Enter to accept the RSA key NB: This is a one time only entry, so you shouldn't have to do it again unless the IP changes.
e.g for my VM I would access it with
On Windows it is very similar. Simply launch Putty and create a new connection to the address of <user name>@<ip address> and enter your password when prompted.