Notes on converting AVR IAR style code to AVR-GCC style code

The previous entry Notes on AVR interrupt grew to larger than expected, so now this entry covers other problem areas and their possible solutions. This included compiling a complete new toolchain. (device ATtiny13)

After sorting out the problems described in the previous notes for an ATtiny13, it was found that an error occurred in the final link stage, “Error:illegal opcode mul for mcu attiny13”. A web search revealed a similar bug in the attiny2313 support.

As can be seen this is due to some opcodes not being available to some devices within a device class. The solution back then was to patch up the existing toolchain. Comments were seen in the thread that gcc 4.0 might have these patches incorporated. The host machine was running Debian unstable, and the latest gcc version available through the package system was 3.4.

Therefore, a new toolchain was compiled. This was rather straightforward when approached in the right way, and when compiled on a fast box.

First get the latest binutils from gnu, binutils-2.16 in this case, a recent stable gcc-4.0 release, gcc-4.0.2 in this case, and a new libc, avr-libc-1.4.2.

These were compiled as follows:


./configure —target=avr && make && sudo make install

At this point remove the old avr-gcc and avr-binutils packages from your system (apt-get remove gcc-avr binutils-avr, in the case of Debian).

Create a new build directory from within gcc-4.0.*, and work from there.

mkdir build && cd build && ../configure —target=avr && make && sudo make install

./configure && make && make install

This will by default install under /usr/local.

From this point the ATtiny13 code that failed before compiled, and ran successfully.

Sun, 22 Jan 2006 00:58 Posted in