2

I am learning to program my ATtiny85 without a bootloader using a MiniPro, and I want to generate a hex file. First I try to compile my file using the avr-gcc command, but I get an error that states:

Fatal error: unknown MCU: gcc-isr

This is the command I use to compile my file

avr-gcc -Wall -mmcu=avr25 -Os -DF_CPU=8000000 -c main.c -o main.o

And this is the code I'm trying to compile

#define __AVR_ATtiny85__
#include <avr/io.h>
#include <util/delay.h>

int main(void)
{
    DDRB = 0b00001000;
    while (1)
    {
        PORTB = 0b00001000;
        _delay_ms(20);
        PORTB = 0b00000000;
        _delay_ms(20);

        PORTB = 0b00001000;
        _delay_ms(200);
        PORTB = 0b00000000;
        _delay_ms(200);
    }

    return 1;
}

I am not entirely sure what the error means and why it appears in the first place, since my mcu is explicitly specified as avr25 category, which the attiny85 falls into. The same error is produced if I set the mmcu variable to attiny85 explicitly

Output of avr-gcc --version

% avr-gcc --version
avr-gcc (GCC) 11.2.0
Copyright (C) 2021 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.

I also installed the latest binutils-avr and avr-libc packages from AUR (2.20 and 2.1.0 respectively)

frogstair
  • 444
  • 5
  • 20
  • 1
    What is the version of your avr-gcc? It works for me with 11.2, but avr25 was introduced with 4.2. – the busybee Apr 13 '22 at 20:25
  • I tried to reproduce this issue using GCC 5.4.0 on Windows, from the [AVR 8-bit Toolchain version 3.6.2](https://www.microchip.com/en-us/tools-resources/develop/microchip-studio/gcc-compilers), but GCC compiled the object file with no errors. What exact toolchain are you using and how did you install it? It's definitely better to use `-mccu=attiny85`, by the way. – David Grayson Apr 15 '22 at 18:14
  • @DavidGrayson how do I check the version of my AVR toolchain? The version of avr-gcc is 11.2.0 – frogstair Apr 20 '22 at 15:32
  • You should edit your question to include the full output of `avr-gcc --version`, the full name of your operating system, and the steps you followed to install the AVR toolchain (i.e. what did you download or what package installation command did you run). – David Grayson Apr 20 '22 at 15:34
  • @DavidGrayson I have added the additional information – frogstair Apr 20 '22 at 16:17
  • I cannot reproduce this on `avr-gcc (Fedora 11.2.0-1.fc36) 11.2.0`. Neither when compiling your original `main.c` with `-mmcu=avr25` nor with the proper `-mmcu=attiny85` and the `#define __AVR_ATtiny85__` removed from `main.c`. Are you sure your avr-libc is built and installed properly? – ndim Apr 29 '22 at 10:58

1 Answers1

2

Fatal error: unknown MCU: gcc-isr

This indicates that you are using an outdated Binutils (as) and that the compiler was configured against a Binutils version that is newer than the Binutils you are actually using.

Since v8, avr-gcc supports option -mgas-isr-prologues, and it will activate the respective part of the assembler by calling it with option -mgcc-isr. The feature was introduced with Binutils v2.29.

You can

  • Re-configure and build avr-gcc against the Binutils version you are preferring to use. The configure script does check whether Binutils support -mgcc-isr; and if that is not the case, the respective GCC feature will be disabled.

  • Use avr-gcc with disabled optimization feature PR20296 / PR21683, i.e. compile with -mno-gas-isr-prologues.


Apart from that:

avr-gcc -mmcu=avr25 ...

Always call avr-gcc with the AVR device you are going to use, in your case -mmcu=attiny85. Also remove that

#define __AVR_ATtiny85__

which will be defined in specs-attiny85 which is part of the installation and the central hub that sets command line options for the sub-processes (compiler proper, assembler, linker). If you have a broken toolchain or are using wrong command line options, this define will not fix it.

emacs drives me nuts
  • 2,785
  • 13
  • 23