How to use the Mentor Graphics Sourcery ARM toolchain on 64-bit Debian Wheezy

The Mentor Graphics CodeBench Lite ARM toolchain (formerly known as the CodeSourcery ARM toolchain) is the toolchain of choice for many open-source ARM projects. Unfortunately, Mentor Graphics provides only 32-bit binaries for the toolchain and the provided source code package is quite difficult to compile. If you try to run these 32-bit binaries on a 64-bit Debian or Ubuntu installation without the proper 32-bit libraries installed, your shell will greet you with the following less than helpful error message:

$ arm-none-eabi-gcc
-bash: /opt/arm-2013.05/bin/arm-none-eabi-gcc: No such file or directory

The ‘No such file or directory’ error occurs not because bash can’t find the file, but because your 64-bit system lacks the proper libraries to run the 32-bit executable.

On Debian Squeeze (6.0) and most other Debian-based distributions, the solution is to install the ia32-libs package:

$ sudo apt-get install ia32-libs

However, starting with Debian Wheezy (7.0) the i386 packages are not available by default on a 64-bit installation due to¬†Debian’s new Multiarch system. Attempting to install ia32-libs on a fresh Debian Wheezy install gives the following error:

$ sudo apt-get install ia32-libs
Reading package lists... Done
Building dependency tree 
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:
The following packages have unmet dependencies:
 ia32-libs : Depends: ia32-libs-i386 but it is not installable
E: Unable to correct problems, you have held broken packages.

The solution is to add the i386 architecture to your multiarch setup before attempting to install any 32-bit libraries such as ia32-libs:

$ sudo dpkg --add-architecture i386
$ sudo apt-get update
$ sudo apt-get install ia32-libs

After adding the i386 architecture and installing ia32-libs, you should be able to run the 32-bit Sourcery ARM toolchain binaries:

$ arm-none-eabi-gcc --version
arm-none-eabi-gcc (Sourcery CodeBench Lite 2013.05-23) 4.7.3
Copyright (C) 2012 Free Software Foundation, Inc.

Note that the ia32-libs package installs a lot of i386 libraries that aren’t necessary for the Sourcery ARM toolchain. If you’re trying to minimize disk space usage and you’re feeling adventurous, you can get away with only installing libc6-i386, which is substantially smaller:

$ sudo apt-get install libc6-i386

This worked for my purposes with the Sourcery ARM toolchain. However, you may run into issues with some of the other 32-bit binaries in the toolchain, as I didn’t use them all in my build process.