Coding-Badly / TinyDebugKnockBang

Write-only serial like interface for TinyISP. Useful for debugging AVR programs.
7 stars 0 forks source link

Problem compiling TinyDebugKnockBang: issue with inline assembly macros #2

Open ldldr opened 6 years ago

ldldr commented 6 years ago

Consider the following code:

#include <TinyDebugKnockBang.h>

void setup() {
  Debug.begin( 19200 );
}

void loop() {
  Debug.println("knock knock");
  delay(1000);
}

It fails compiling with:

Arduino: 1.8.1 (Mac OS X), Board: "ATtiny25/45/85, ATtiny85, Internal 1 MHz"

[...]

Compiling sketch...
"/Users/ldldr/Library/Arduino15/packages/arduino/tools/avr-gcc/4.9.2-atmel3.5.4-arduino2/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -flto -mmcu=attiny85 -DF_CPU=1000000L -DARDUINO=10801 -DARDUINO_attiny -DARDUINO_ARCH_AVR   "-I/Users/ldldr/Library/Arduino15/packages/arduino/hardware/avr/1.6.20/cores/arduino" "-I/Users/ldldr/Library/Arduino15/packages/attiny/hardware/avr/1.0.2/variants/tiny8" "-I/Users/ldldr/Documents/Arduino/libraries/TinyDebugKnockBang" "/var/folders/d_/bgdp6sl51rnghxwy2tskfnf80000gx/T/arduino_build_670517/sketch/knock_knock.ino.cpp" -o "/var/folders/d_/bgdp6sl51rnghxwy2tskfnf80000gx/T/arduino_build_670517/sketch/knock_knock.ino.cpp.o"
Compiling libraries...
Compiling library "TinyDebugKnockBang"
"/Users/ldldr/Library/Arduino15/packages/arduino/tools/avr-gcc/4.9.2-atmel3.5.4-arduino2/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -flto -mmcu=attiny85 -DF_CPU=1000000L -DARDUINO=10801 -DARDUINO_attiny -DARDUINO_ARCH_AVR   "-I/Users/ldldr/Library/Arduino15/packages/arduino/hardware/avr/1.6.20/cores/arduino" "-I/Users/ldldr/Library/Arduino15/packages/attiny/hardware/avr/1.0.2/variants/tiny8" "-I/Users/ldldr/Documents/Arduino/libraries/TinyDebugKnockBang" "/Users/ldldr/Documents/Arduino/libraries/TinyDebugKnockBang/TinyDebugKnockBang.cpp" -o "/var/folders/d_/bgdp6sl51rnghxwy2tskfnf80000gx/T/arduino_build_670517/libraries/TinyDebugKnockBang/TinyDebugKnockBang.cpp.o"

[...]

Linking everything together...
"/Users/ldldr/Library/Arduino15/packages/arduino/tools/avr-gcc/4.9.2-atmel3.5.4-arduino2/bin/avr-gcc" -w -Os -g -flto -fuse-linker-plugin -Wl,--gc-sections -mmcu=attiny85  -o "/var/folders/d_/bgdp6sl51rnghxwy2tskfnf80000gx/T/arduino_build_670517/knock_knock.ino.elf" "/var/folders/d_/bgdp6sl51rnghxwy2tskfnf80000gx/T/arduino_build_670517/sketch/knock_knock.ino.cpp.o" "/var/folders/d_/bgdp6sl51rnghxwy2tskfnf80000gx/T/arduino_build_670517/libraries/TinyDebugKnockBang/TinyDebugKnockBang.cpp.o" "/var/folders/d_/bgdp6sl51rnghxwy2tskfnf80000gx/T/arduino_build_670517/core/core.a" "-L/var/folders/d_/bgdp6sl51rnghxwy2tskfnf80000gx/T/arduino_build_670517" -lm
/var/folders/d_/bgdp6sl51rnghxwy2tskfnf80000gx/T//ccIBQAEW.s: Assembler messages:
/var/folders/d_/bgdp6sl51rnghxwy2tskfnf80000gx/T//ccIBQAEW.s:111: Error: unknown opcode `delay_fine'
/var/folders/d_/bgdp6sl51rnghxwy2tskfnf80000gx/T//ccIBQAEW.s:113: Error: unknown opcode `delay_fine'
/var/folders/d_/bgdp6sl51rnghxwy2tskfnf80000gx/T//ccIBQAEW.s:215: Error: unknown opcode `delay_roug'
/var/folders/d_/bgdp6sl51rnghxwy2tskfnf80000gx/T//ccIBQAEW.s:218: Error: unknown opcode `delay_roug'
/var/folders/d_/bgdp6sl51rnghxwy2tskfnf80000gx/T//ccIBQAEW.s:255: Error: unknown opcode `delay_roug'
/var/folders/d_/bgdp6sl51rnghxwy2tskfnf80000gx/T//ccIBQAEW.s:258: Error: unknown opcode `delay_fine'
/var/folders/d_/bgdp6sl51rnghxwy2tskfnf80000gx/T//ccIBQAEW.s:260: Error: unknown opcode `delay_roug'
lto-wrapper: /Users/ldldr/Library/Arduino15/packages/arduino/tools/avr-gcc/4.9.2-atmel3.5.4-arduino2/bin/avr-gcc returned 1 exit status
/Users/ldldr/Library/Arduino15/packages/arduino/tools/avr-gcc/4.9.2-atmel3.5.4-arduino2/bin/../lib/gcc/avr/4.9.2/../../../../avr/bin/ld: error: lto-wrapper failed
collect2: error: ld returned 1 exit status
Using library TinyDebugKnockBang in folder: /Users/ldldr/Documents/Arduino/libraries/TinyDebugKnockBang (legacy)
exit status 1
Error compiling for board ATtiny25/45/85.

The compiler only picks up the macro definitions when you call TinyDebugKnockBangClass_AssemblyMacros() from inside TinyDebugKnockBangClass::sendByte() and TinyDebugKnockBangClass::knockHello() just before the asm volatile statements, e.g.:

452   TinyDebugKnockBangClass_AssemblyMacros();
590   TinyDebugKnockBangClass_AssemblyMacros();
Coding-Badly commented 6 years ago

Core?

ldldr commented 6 years ago

Sorry, what do you mean by "core"?

Coding-Badly commented 6 years ago

In order to build for the ATtinyX5 family using the Arduino IDE you had to install a "core". Which one did you install?

ldldr commented 6 years ago

Right: https://github.com/damellis/attiny (version 1.0.2)

ldldr commented 6 years ago

Good hint. Seems to work with SpenceKonde/ATTinyCore. Why?

sebasira commented 2 years ago

I'm having the same issue, and I already have SpenceKonde/ATTinyCore installed

Coding-Badly commented 2 years ago

Is the SpenceKonde/ATTinyCore selected when you build?

avelor-76 commented 1 year ago

I also have the same issue, with SpenceKonde/ATTinyCore installed and selected

Coding-Badly commented 1 year ago

"have the same issue" cannot be true. According to ldldr, the original poster, using the SpenceKonde/ATTinyCore works.

avelor-76 commented 1 year ago

Hi, The original post from ldldr dates back to 2018. However another user [sebasira] reported having an issue in 2022, and I have a very similar error log. Could it be that issue reappears with more recent versions of SpenceKonde/ATTinyCore? I am using version 1.5.2 (see also log below).


Using board 'attinyx5' from platform in folder: C:\Users\Guido\AppData\Local\Arduino15\packages\ATTinyCore\hardware\avr\1.5.2 Using core 'tiny' from platform in folder: C:\Users\Guido\AppData\Local\Arduino15\packages\ATTinyCore\hardware\avr\1.5.2 Detecting libraries used... "C:\Users\Guido\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino7/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -flto -w -x c++ -E -CC -mmcu=attiny85 -DF_CPU=8000000L -DCLOCK_SOURCE=0 -DARDUINO=10607 -DARDUINO_AVR_ATTINYX5 -DARDUINO_ARCH_AVR -DNEOPIXELPORT=PORTB "-IC:\Users\Guido\AppData\Local\Arduino15\packages\ATTinyCore\hardware\avr\1.5.2\cores\tiny" "-IC:\Users\Guido\AppData\Local\Arduino15\packages\ATTinyCore\hardware\avr\1.5.2\variants\tinyX5" "C:\Users\Guido\AppData\Local\Temp\arduino-sketch-E4A5EB9899A7ECCFF91B7D42D14191EC\sketch\sketch_feb2a.ino.cpp" -o nul Alternatives for TinyDebugKnockBang.h: [TinyDebugKnockBang] ResolveLibrary(TinyDebugKnockBang.h) -> candidates: [TinyDebugKnockBang] "C:\Users\Guido\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino7/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -flto -w -x c++ -E -CC -mmcu=attiny85 -DF_CPU=8000000L -DCLOCK_SOURCE=0 -DARDUINO=10607 -DARDUINO_AVR_ATTINYX5 -DARDUINO_ARCH_AVR -DNEOPIXELPORT=PORTB "-IC:\Users\Guido\AppData\Local\Arduino15\packages\ATTinyCore\hardware\avr\1.5.2\cores\tiny" "-IC:\Users\Guido\AppData\Local\Arduino15\packages\ATTinyCore\hardware\avr\1.5.2\variants\tinyX5" "-Ic:\Users\Guido\Documents\Arduino\libraries\TinyDebugKnockBang" "C:\Users\Guido\AppData\Local\Temp\arduino-sketch-E4A5EB9899A7ECCFF91B7D42D14191EC\sketch\sketch_feb2a.ino.cpp" -o nul "C:\Users\Guido\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino7/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -flto -w -x c++ -E -CC -mmcu=attiny85 -DF_CPU=8000000L -DCLOCK_SOURCE=0 -DARDUINO=10607 -DARDUINO_AVR_ATTINYX5 -DARDUINO_ARCH_AVR -DNEOPIXELPORT=PORTB "-IC:\Users\Guido\AppData\Local\Arduino15\packages\ATTinyCore\hardware\avr\1.5.2\cores\tiny" "-IC:\Users\Guido\AppData\Local\Arduino15\packages\ATTinyCore\hardware\avr\1.5.2\variants\tinyX5" "-Ic:\Users\Guido\Documents\Arduino\libraries\TinyDebugKnockBang" "c:\Users\Guido\Documents\Arduino\libraries\TinyDebugKnockBang\TinyDebugKnockBang.cpp" -o nul Generating function prototypes... "C:\Users\Guido\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino7/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -flto -w -x c++ -E -CC -mmcu=attiny85 -DF_CPU=8000000L -DCLOCK_SOURCE=0 -DARDUINO=10607 -DARDUINO_AVR_ATTINYX5 -DARDUINO_ARCH_AVR -DNEOPIXELPORT=PORTB "-IC:\Users\Guido\AppData\Local\Arduino15\packages\ATTinyCore\hardware\avr\1.5.2\cores\tiny" "-IC:\Users\Guido\AppData\Local\Arduino15\packages\ATTinyCore\hardware\avr\1.5.2\variants\tinyX5" "-Ic:\Users\Guido\Documents\Arduino\libraries\TinyDebugKnockBang" "C:\Users\Guido\AppData\Local\Temp\arduino-sketch-E4A5EB9899A7ECCFF91B7D42D14191EC\sketch\sketch_feb2a.ino.cpp" -o "C:\Users\Guido\AppData\Local\Temp\arduino-sketch-E4A5EB9899A7ECCFF91B7D42D14191EC\preproc\ctags_target_for_gcc_minus_e.cpp" "C:\Users\Guido\AppData\Local\Arduino15\packages\builtin\tools\ctags\5.8-arduino11/ctags" -u --language-force=c++ -f - --c++-kinds=svpf --fields=KSTtzns --line-directives "C:\Users\Guido\AppData\Local\Temp\arduino-sketch-E4A5EB9899A7ECCFF91B7D42D14191EC\preproc\ctags_target_for_gcc_minus_e.cpp" Compiling sketch... "C:\Users\Guido\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino7/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -flto -mmcu=attiny85 -DF_CPU=8000000L -DCLOCK_SOURCE=0 -DARDUINO=10607 -DARDUINO_AVR_ATTINYX5 -DARDUINO_ARCH_AVR -DNEOPIXELPORT=PORTB "-IC:\Users\Guido\AppData\Local\Arduino15\packages\ATTinyCore\hardware\avr\1.5.2\cores\tiny" "-IC:\Users\Guido\AppData\Local\Arduino15\packages\ATTinyCore\hardware\avr\1.5.2\variants\tinyX5" "-Ic:\Users\Guido\Documents\Arduino\libraries\TinyDebugKnockBang" "C:\Users\Guido\AppData\Local\Temp\arduino-sketch-E4A5EB9899A7ECCFF91B7D42D14191EC\sketch\sketch_feb2a.ino.cpp" -o "C:\Users\Guido\AppData\Local\Temp\arduino-sketch-E4A5EB9899A7ECCFF91B7D42D14191EC\sketch\sketch_feb2a.ino.cpp.o" Compiling libraries... Compiling library "TinyDebugKnockBang" "C:\Users\Guido\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino7/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -flto -mmcu=attiny85 -DF_CPU=8000000L -DCLOCK_SOURCE=0 -DARDUINO=10607 -DARDUINO_AVR_ATTINYX5 -DARDUINO_ARCH_AVR -DNEOPIXELPORT=PORTB "-IC:\Users\Guido\AppData\Local\Arduino15\packages\ATTinyCore\hardware\avr\1.5.2\cores\tiny" "-IC:\Users\Guido\AppData\Local\Arduino15\packages\ATTinyCore\hardware\avr\1.5.2\variants\tinyX5" "-Ic:\Users\Guido\Documents\Arduino\libraries\TinyDebugKnockBang" "c:\Users\Guido\Documents\Arduino\libraries\TinyDebugKnockBang\TinyDebugKnockBang.cpp" -o "C:\Users\Guido\AppData\Local\Temp\arduino-sketch-E4A5EB9899A7ECCFF91B7D42D14191EC\libraries\TinyDebugKnockBang\TinyDebugKnockBang.cpp.o" Compiling core... Using precompiled core: C:\Users\Guido\AppData\Local\Temp\arduino-core-cache\core_239b623b643e47bd02ee21189f3c12ba.a Linking everything together... "C:\Users\Guido\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino7/bin/avr-gcc" -w -Os -g -flto -fuse-linker-plugin -Wl,--gc-sections -mmcu=attiny85 -o "C:\Users\Guido\AppData\Local\Temp\arduino-sketch-E4A5EB9899A7ECCFF91B7D42D14191EC/sketch_feb2a.ino.elf" "C:\Users\Guido\AppData\Local\Temp\arduino-sketch-E4A5EB9899A7ECCFF91B7D42D14191EC\sketch\sketch_feb2a.ino.cpp.o" "C:\Users\Guido\AppData\Local\Temp\arduino-sketch-E4A5EB9899A7ECCFF91B7D42D14191EC\libraries\TinyDebugKnockBang\TinyDebugKnockBang.cpp.o" "C:\Users\Guido\AppData\Local\Temp\arduino-sketch-E4A5EB9899A7ECCFF91B7D42D14191EC/..\arduino-core-cache\core_239b623b643e47bd02ee21189f3c12ba.a" "-LC:\Users\Guido\AppData\Local\Temp\arduino-sketch-E4A5EB9899A7ECCFF91B7D42D14191EC" -lm C:\Users\Guido\AppData\Local\Temp\cc4f4rjB.s: Assembler messages: C:\Users\Guido\AppData\Local\Temp\cc4f4rjB.s:111: Error: unknown opcode `delay_fine' C:\Users\Guido\AppData\Local\Temp\cc4f4rjB.s:113: Error: unknown opcode `delay_fine' C:\Users\Guido\AppData\Local\Temp\cc4f4rjB.s:216: Error: unknown opcode `delay_roug' C:\Users\Guido\AppData\Local\Temp\cc4f4rjB.s:219: Error: unknown opcode `delay_roug' C:\Users\Guido\AppData\Local\Temp\cc4f4rjB.s:256: Error: unknown opcode `delay_roug' C:\Users\Guido\AppData\Local\Temp\cc4f4rjB.s:259: Error: unknown opcode `delay_fine' C:\Users\Guido\AppData\Local\Temp\cc4f4rjB.s:261: Error: unknown opcode `delay_roug' lto-wrapper.exe: fatal error: C:\Users\Guido\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino7/bin/avr-gcc returned 1 exit status compilation terminated. c:/users/guido/appdata/local/arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino7/bin/../lib/gcc/avr/7.3.0/../../../../avr/bin/ld.exe: error: lto-wrapper failed collect2.exe: error: ld returned 1 exit status

Using library TinyDebugKnockBang in folder: C:\Users\Guido\Documents\Arduino\libraries\TinyDebugKnockBang (legacy) exit status 1

Compilation error: exit status 1