Howto: Update gcc-avr and binutils-avr

Tuesday, 18. September 2007 18:13 - daniel - Linux - 1 Comment


Ubuntu 7.04 Feisty comes with gcc-avr version 4.1.0 and binutils-avr version 2.16.1. I wanted to update the compiler to support the dwarf2 debug format. Since avr-gcc < 4.1.2 has a bug that makes it impossible to compile with dwarf2, I couldn't just recompile the ubuntu package with dwarf2 enabled. This howto is loosely based on this howto by coldtobi and this article (German) by Sven Rudolph and Heiko Schlittermann. The coldtobi's howto doesn't work at the moment, because the links for his patches are broken.

This Howto isn't for beginners, so if you miss something, ask. The lines that start with a $ sign are for a normal terminal and lines with a # in front are for a root terminal (or write sudo in front of the command).

Let's get started:

1. Create a directory where we can store all the files.

mkdir ~/avr
cd ~/avr


2. Download the source packages and the utilitis required for compiling
apt-get source gcc-avr binutils-avr
apt-get build-dep gcc-avr binutils-avr
apt-get install linux-headers-$(uname -r) build-essential


3. binutils

3.1 Rename the folder and download the latest binutils from gnu
mv binutils-avr-2.16.1 binutils-avr-2.18
cd binutils-avr-2.18rm binutils-2.16.1.tar.bz2
wget ftp://ftp.gnu.org/gnu/binutils/binutils-2.18.tar.gz


3.2 Update the Debian control files
The dollar.patch is no longer needed/supported.
rm debian/pathces/dollars.patch

We need to update the changelog. The changelog contains the the version number, changes, the date of the changes and the name of the person updated the package. You need to update in to let dpkg know, that the version number changed.
Open the file debian/changelog in your favourite editor and add this to the top:
binutils-avr (2.18-1) unstable; urgency=low

* New upstream release

-- Daniel Triendl <daniel@tac-ops.net> Tue, 18 Sep 2007 18:13:21 +0200

(There are two spaces between the email address and the date.)
Replace the name, the date and the email address with your data. You can get the current time in the correct format by typing date -R.

3.3 Compile the package
fakeroot dpkg-buildpackage -b -uc -us

(Or use fakeroot dpkg-buildpackage -b if you have gpg installed and want to create a signed package.)

3.4 Installing
cd ..

(You should be in avr/ again.)
dpkg -i binutils-avr_2.18-1_i386.deb


4. gcc
The next steps are pretty much the same as for the binutils, except that we need to update the rules too.

4.1 Rename the folder and get the latest version of gcc from gnu
mv gcc-avr-4.1.2/ gcc-avr-4.2.1
cd gcc-avr-4.2.1/
rm gcc-core-4.1.0.tar.bz2 gcc-g++-4.1.0.tar.bz2
wget ftp://ftp.fu-berlin.de/unix/languages/gcc/releases/gcc-4.2.1/gcc-core-4.2.1.tar.bz2
wget ftp://ftp.fu-berlin.de/unix/languages/gcc/releases/gcc-4.2.1/gcc-g++-4.2.1.tar.bz2


4.2 Updating the Debian control files
Fix the changelog in debian/changelog
gcc-avr (1:4.2.1-1) unstable; urgency=low

* New Upstream release
* Added support for dwarf-2 debug format

-- Daniel Triendl <daniel@tac-ops.net> Tue, 18 Sep 2007 18:30:31 +0200


Enable dwarf2, open debian/rules and edit the CONFARGS block to look like this (The last line and the \ in the previous line):
CONFARGS = -v \
--enable-languages=c,c++ \
--prefix=/usr \
--infodir=/usr/share/info \
--mandir=/usr/share/man \
--enable-shared \
--with-system-zlib \
--enable-long-long \
--enable-nls \
--without-included-gettext \
--disable-checking \
--disable-libssp \
--build=$(DEB_BUILD_GNU_TYPE) \
--host=$(DEB_HOST_GNU_TYPE) \
--target=$(TARGET) \
--with-dwarf2


4.3 Compile the package
fakeroot dpkg-buildpackage -b -uc -us

Again, skip -uc -us if you want to create a signed package.

4.4 Installing
cd ..dpkg -i gcc-avr_4.2.1-1_i386.deb


5. Check if you got the right version
avr-gcc --version should print something like this:
avr-gcc (GCC) 4.2.1
Copyright (C) 2007 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.


You can also download my packages if you don't want to build them yourself.
binutils-avr_2.18-1_i386.deb
gcc-avr_4.2.1-1_i386.deb

These packages are signed, you can get my gpg key from a keyserver or from here. The id is E25F8322.



Comments

coldtobi - Friday, 2. November 2007 19:24

I repaired the links on my article!