Go Down

Topic: Arduino 1.0.2 & ATtiny 85 (Read 6536 times) previous topic - next topic

camz

Nov 11, 2012, 06:20 am Last Edit: Nov 12, 2012, 07:06 am by camz Reason: 1
I get the following error when compiling if the board is set to ATtiny85.  To keep things simple, I was trying to compile the sample "blink.ino" sketch.

In file included from D:\Arduino\arduino-1.0.2\hardware\arduino\cores\arduino/Arduino.h:193,
                from Blink.ino:10:
D:\Arduino\arduino-1.0.2\hardware\arduino\cores\arduino/HardwareSerial.h:125:2: error: #error TXC0 not definable in HardwareSerial.h


The relevant section of the header file is (the indenting is mine to make it easier to understand):

Code: [Select]
#if !defined(TXC0)
 #if defined(TXC)
   #define TXC0 TXC
 #elif defined(TXC1)
   // Some devices have uart1 but no uart0
   #define TXC0 TXC1
 #else
   #error TXC0 not definable in HardwareSerial.h
 #endif
#endif


The #ifdef's don't account for the case where neither TXC0 nor TXC1 exist

In HardwareSerial.cpp, the following #ifdef's are used to exclude *all* of the code, which also supresses the include for HardwareSerial.h, however, in Arduino.h, it goes ahead and include HardwareSerial.h anyways.

Code: [Select]
// this next line disables the entire HardwareSerial.cpp,
// this is so I can support Attiny series and any other chip without a uart
#if defined(UBRRH) || defined(UBRR0H) || defined(UBRR1H) || defined(UBRR2H) || defined(UBRR3H)


If I modify Arduino.h to wrap the #include for HardwareSerial.h with the same #ifdef, then the error changes to:

D:\Arduino\arduino-1.0.2\hardware\arduino\cores\arduino\IPAddress.cpp: In member function 'virtual size_t IPAddress::printTo(Print&) const':
D:\Arduino\arduino-1.0.2\hardware\arduino\cores\arduino\IPAddress.cpp:49: error: invalid use of incomplete type 'struct Print'
D:\Arduino\arduino-1.0.2\hardware\arduino\cores\arduino/Printable.h:25: error: forward declaration of 'struct Print'
D:\Arduino\arduino-1.0.2\hardware\arduino\cores\arduino\IPAddress.cpp:49: error: 'DEC' was not declared in this scope
D:\Arduino\arduino-1.0.2\hardware\arduino\cores\arduino\IPAddress.cpp:50: error: invalid use of incomplete type 'struct Print'
D:\Arduino\arduino-1.0.2\hardware\arduino\cores\arduino/Printable.h:25: error: forward declaration of 'struct Print'
D:\Arduino\arduino-1.0.2\hardware\arduino\cores\arduino\IPAddress.cpp:52: error: invalid use of incomplete type 'struct Print'
D:\Arduino\arduino-1.0.2\hardware\arduino\cores\arduino/Printable.h:25: error: forward declaration of 'struct Print'
D:\Arduino\arduino-1.0.2\hardware\arduino\cores\arduino\IPAddress.cpp:52: error: 'DEC' was not declared in this scope


I would have expected Arduino.h to have been the "top" header file, but that doesn't seem to be the case.  It looks like the IPAddress code is dependent on a serial port being present and to somehow define or include the proper Print functions.

The includes and #ifdef's are rather broken for the AT tiny parts that don't have serial.  It also looks like things are being included that shouldn't (blink really shouldn't have any need to include the IPAddress code at all, but it does).

I'm more than happy to help sort this out, but I'll need some ideas on where to start looking, more precisely, I'll need to know where to look for what the command line is that is used to start compiling so I know which headers to look at (and in more or less which order).

Camz.

Tom Carpenter

#1
Nov 12, 2012, 10:17 pm Last Edit: Nov 13, 2012, 12:26 am by Tom Carpenter Reason: 1
Thats because it is compiling the wrong core.

you should be seeing it compile filed at:
D:\Arduino\arduino-1.0.2\hardware\arduino\cores\tiny\

Have you downloaded the Tiny core? The Arduino core is not suitable for attiny's.


As for blink including the IPAddress files, when the IDE uses gcc to compile the program, it tells it to compile all files in the core. If you don't include the associated header files (or cpp files themselves) anywhere in your code, the files and code associated will be scrubbed by the linker.
~Tom~

bperrybap


... , when gcc compiles the program, it compiles all visible cpp files - which means all cpp files in the core. If you don't include the associated header files (or cpp files themselves) anywhere in your code, the files and code associated will be scrubbed by the linker.


gcc only compiles what it is told to compile. The IDE is the one that tells gcc what to compile.

Tom Carpenter


gcc only compiles what it is told to compile. The IDE is the one that tells gcc what to compile.
Post edited :)
~Tom~

fkeel

#4
Nov 21, 2012, 11:45 pm Last Edit: Nov 22, 2012, 12:16 am by fkeel Reason: 1
Was this ever resolved? I have exactly the same error, and I have followed the instructions from here: http://hlt.media.mit.edu/?p=1695

The only thing I do different from those instructions is that I use the Arduino Duemilenove

Any ideas what I might be doing wrong?

EDIT:
Switching to Arduino 1.0.1 solves this problem.
http://embodimentlabs.tumblr.com/
http://paulstrohmeier.info/

Coding Badly


@Tom Carpenter provided the solution in Reply #1.  Use the Tiny Core...
http://code.google.com/p/arduino-tiny/

ChrisXenon

Tom's core at http://code.google.com/p/arduino-tiny/ seems to be incompatible with the with the wire library in Arduino 1.0.2. I get a compilation error:

In file included from mySketch.ino:12:
C:\Program Files\arduino\arduino-1.0.2\libraries\Wire/Wire.h:61: error: conflicting return type specified for 'virtual size_t TwoWire::write(const uint8_t*, size_t)'
C:\Program Files\arduino\arduino-1.0.2\hardware\tiny\cores\tiny/Print.h:75: error:   overriding 'virtual void Print::write(const uint8_t*, size_t)'

The sketch compiles fine for Arduino, just not for the Attiny core. I'm not experienced enough to be able to fix this. Any help would be appreciated. Is there a more up-to-date Attiny85 core?

Thanks,
Chris

Coding Badly

Any help would be appreciated. Is there a more up-to-date Attiny85 core?


Won't help.  The Wire library is written specifically for the ATmega line of processors.  The ATtiny processors do not have the necessary hardware.  Try the TinyWire library.

mellis

Sorry, there was a change in 1.0.2 that is incompatible with processors that don't have hardware serial support (like the ATtiny). This will be fixed in 1.0.3.  See: https://github.com/damellis/attiny/issues/8. For now, you can use 1.0.1 or change:

#error TXC0 not definable in HardwareSerial.h

to:

#warning TXC0 not definable in HardwareSerial.h

in HardwareSerial.h.

Go Up