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)
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. Theconfigure
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.