ATTiny10 linker error

I’m trying to set up development for an ATTiny10, which isn’t included in platform-atmelavr.

I created ~/.platformio/boards and the file ~/.platformio/boards/attiny10.json:

{
  "build": {
    "f_cpu": "1000000L",
    "mcu": "attiny10"
  },
  "name": "ATtiny10",
  "upload": {
    "maximum_ram_size": 32,
    "maximum_size": 1024,
    "protocol": "atmel-ice"
  },
  "url": "http://www.atmel.com/devices/ATTINY10.aspx",
  "vendor": "Atmel"
}

Creating an ATTiny project loaded the necessary files:

Tool Manager: Installing platformio/toolchain-atmelavr @ ~1.70300.0
Unpacking  [####################################]  100%          
Tool Manager: toolchain-atmelavr@1.70300.191015 has been installed!
Tool Manager: Installing platformio/tool-scons @ ~4.40300.0
Unpacking  [####################################]  100%
Tool Manager: tool-scons@4.40300.1 has been installed!
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/atmelavr/attiny10.html
PLATFORM: Atmel AVR (3.4.0) > ATtiny10
HARDWARE: ATTINY10 1MHz, 32B RAM, 1KB Flash
PACKAGES: 
 - toolchain-atmelavr @ 1.70300.191015 (7.3.0)
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 0 compatible libraries
Scanning dependencies...
No dependencies

and generated a platformio.io file:

[env:attiny10]
platform = atmelavr
board = attiny10
upload_flags = -e

Entering pio run on the command line throws a linker error though:

~/.platformio/packages/toolchain-atmelavr/bin/../lib/gcc/avr/7.3.0/../../../../avr/bin/ld: cannot find crtattiny10.o: No such file or directory

which translates to: "ld can’t find the file crtattiny10.o."

That file does exist:

~/.platformio/packages/toolchain-atmelavr/avr/lib/avrtiny/crtattiny10.o

But I don’t know how to tell the build system to look in the right directory.

My OS is MacOS 12.4 Monterey, and I’m using the command line/vim version of platformio.

If I take the sample program at Writing Code for the ATtiny10 « irq5.io

#include <util/delay.h>
#include <avr/io.h>
 
int main() {
    DDRB |= _BV(DDB2); // set as output
 
    while (1) {
        PORTB &= ~_BV(PORTB2); // turn off
        _delay_ms(1000);
 
        PORTB |= _BV(PORTB2); // turn on
        _delay_ms(1000);
    }
 
    return 0;
}

and try it with the standard AVR-GCC 7.3.0 compiler

>C:\Users\Max\.platformio\packages\toolchain-atmelavr\bin\avr-gcc  -mmcu=attiny10 -DF_CPU=1000000 -g -Os main.c -o main.elf
c:/users/max/.platformio/packages/toolchain-atmelavr/bin/../lib/gcc/avr/7.3.0/../../../../avr/bin/ld.exe: cannot find crtattiny10.o: No such file or directory
c:/users/max/.platformio/packages/toolchain-atmelavr/bin/../lib/gcc/avr/7.3.0/../../../../avr/bin/ld.exe: skipping incompatible c:/users/max/.platformio/packages/toolchain-atmelavr/bin/../lib/gcc/avr/7.3.0\libgcc.a when searching for -lgcc
c:/users/max/.platformio/packages/toolchain-atmelavr/bin/../lib/gcc/avr/7.3.0/../../../../avr/bin/ld.exe: cannot find -lgcc
c:/users/max/.platformio/packages/toolchain-atmelavr/bin/../lib/gcc/avr/7.3.0/../../../../avr/bin/ld.exe: skipping incompatible c:/users/max/.platformio/packages/toolchain-atmelavr/bin/../lib/gcc/avr/7.3.0/../../../../avr/lib\libm.a when searching for -lm
c:/users/max/.platformio/packages/toolchain-atmelavr/bin/../lib/gcc/avr/7.3.0/../../../../avr/bin/ld.exe: cannot find -lm
c:/users/max/.platformio/packages/toolchain-atmelavr/bin/../lib/gcc/avr/7.3.0/../../../../avr/bin/ld.exe: skipping incompatible c:/users/max/.platformio/packages/toolchain-atmelavr/bin/../lib/gcc/avr/7.3.0/../../../../avr/lib\libc.a when searching for -lc
c:/users/max/.platformio/packages/toolchain-atmelavr/bin/../lib/gcc/avr/7.3.0/../../../../avr/bin/ld.exe: cannot find -lc
c:/users/max/.platformio/packages/toolchain-atmelavr/bin/../lib/gcc/avr/7.3.0/../../../../avr/bin/ld.exe: cannot find -lattiny10

but with the older 5.4.0 compiler

>C:\Users\Max\.platformio\packages\toolchain-atmelavr@1.50400.190710\bin\avr-gcc  -mmcu=attiny10 -DF_CPU=1000000 -g -Os main.c -o main.elf

C:\Users\Max\temp\attiny>

does so nicely.

So “somehow” the 7.3.0 version has lost its ability to compile for this chip. Try placing

platform_packages =
   toolchain-atmelavr@~1.50400.0

in the platformio.ini of the project to make PlatformIO use the older compiler.

1 Like

That worked, thank you!

I’ll keep poking around and see if I can find a workaround with the newer toolchain. If I find anything I’ll post back.