Project

General

Profile

Compiling for ATtiny84 - ‘Serial’ was not declared in this scope

Added by dzach about 4 years ago

Hi all

I’ve built an SPI programmer and connector following the suggestions in http://jeelabs.org/2011/05/29/summary-of-isp-options. The “working” board is an Arduino Nano v3 with which I’ve successfully used the isp_repair2.pde code to re-flash a JeeNode v6 target.

With that same programmer I’m trying to (eventually) upload a simple sketch to a JeeNode Micro v1. For the time being I cannot get any sketch, no matter how simple, to compile using the Arduino IDE 1.0.3. This is an example empty sketch:

#include 

void setup () {
}

void loop () {
}

and this is the error I get:

In file included from /home/dz/sketchbook/libraries/JeeLib/JeeLib.h:7,
                 from gas_meter_tiny84_test.ino:8:
/home/dz/sketchbook/libraries/JeeLib/Ports.h:682: error: ‘Serial’ was not declared in this scope
/home/dz/sketchbook/libraries/JeeLib/Ports.h:683: error: ‘Serial’ was not declared in this scope

I’ve selected the “ATtiny84 (internal 8MHz clock)” board.

Reading through the posts I see jcw’s suggestion to to disable the InputParser in post http://forum.jeelabs.net/node/1407 .
After disabling the InputParser there are more errors coming from using Serial.print in a number of places in the included libraries.

I have a feeling I’m doing something stupid here. Is the above still necessary or it has been corrected in the JeeLib?

Any suggestions?


Replies (14)

RE: [SOLVED] Compiling for ATtiny84 - ‘Serial’ was not declared in this scope - Added by dzach about 4 years ago

Fixed it: was using the wrong core for the ATtiny.

RE: Compiling for ATtiny84 - ‘Serial’ was not declared in this scope - Added by dzach about 4 years ago

A few more words for anyone with the same problem landing on this post:

I first used the instructions of this page: http://hlt.media.mit.edu/?p=1695 and downloaded the library from the ATtiny.zip link described there. Its contents are the same with the GitHub repository given on the same page. The zip contains a directory structure and 3 files: boards.txt, tiny14/pins_arduino.h and tiny8/pins_arduino.h . I didn’t pay attention to the directory names, tiny14 and tiny8, but these were not the ATtiny that I wanted to use.

The library that solved my compilation problem was downloaded from here: http://code.google.com/p/arduino-tiny/downloads/detail?name=arduino-tiny-0100-0015.zip . It contains a set of core files and a range of bootloaders for the ATtiny family of micro-controllers.

RE: Compiling for ATtiny84 - ‘Serial’ was not declared in this scope - Added by martynj about 4 years ago

An alternative way to set up the toolchain is described in the JeeMicro V2 wiki. (Cut & paste from a contribution from JohnO)

RE: Compiling for ATtiny84 - ‘Serial’ was not declared in this scope - Added by dzach about 4 years ago

@martynj thank you for the link.

I am actually on Linux, but the note in the linked page:

the bus loading from the unpowered RFM12B module can disrupt the programming process

might give an explanation for the other problems I have with the uploading of sketches to the JNμ, though my JNμ is v1, not v2.

RE: Compiling for ATtiny84 - ‘Serial’ was not declared in this scope - Added by martynj about 4 years ago

@dzach - unfortunately not, the bus loading issue is new to v2. The earlier versions did not have power control of the RFM12B module, which is the root cause.

RE: Compiling for ATtiny84 - ‘Serial’ was not declared in this scope - Added by dzach 12 months ago

Well, it's been 3 years, and from time to time I get the same error, as in the title of this thread, probably every time a new IDE version comes along.

I have spent quite some time recently trying to correct my setup, and then trying to find any setup that will compile ATtiny84 code without a problem. The Jeelib installation I was using until now started having problems, even with the 1.5.5 version of the IDE. E.g. I could not compile the OneWire lib, or it would give me the "Serial was not declared in this scope" error for jeelib. Googling for a solution, I came across my problems described here 3 years ago, but now the problem seemed to be a different one.

It looks like I have finally found one setup that works, and it runs with the recent Arduino IDE 1.6.8 (Hourly Build 2016/02/02) and all, without any tweaking.
Installed with the IDE board manager, the URL for the setup is: http://drazzy.com/package_drazzy.com_index.json. It installs a number of boards with titles ATtiny Classic and ATtiny Modern, and the one for ATtiny84 gives me no error in all sketches that I've tried so far.

I hope this solution may help others that get similar frustrating errors with the ATtiny μPs.

RE: Compiling for ATtiny84 - ‘Serial’ was not declared in this scope - Added by JohnO 12 months ago

Hi dzach,

that is interesting, I wonder if it is pulling in SoftwareSerial. Have you tried any sketches that use serial?

RE: Compiling for ATtiny84 - ‘Serial’ was not declared in this scope - Added by JohnO 12 months ago

Actually I hope it is pulling in TinyDebugSerial, the small TX only code.

RE: Compiling for ATtiny84 - ‘Serial’ was not declared in this scope - Added by dzach 12 months ago

Hi John

I haven't used SoftwareSerial yet on the ATtiny, but I did a check with the example code of SoftwareSerial and it compiles ok. Hopefully it runs ok too.

RE: Compiling for ATtiny84 - ‘Serial’ was not declared in this scope - Added by JohnO 12 months ago

Thanks for that dzach, the issue in the past was the size of Softwareserial where it was not possible to build rf12demo.cpp for the T84. The TinyDebugSerial only supports serial output but was able to squeeze into a T84 with rf12demo. Having briefly looked at the git site you noted it appears that a new approach to serial has been taken, using the same hooks of course.

RE: Compiling for ATtiny84 - ‘Serial’ was not declared in this scope - Added by dzach 12 months ago

TinyDebugSerial also compiles without problems. I haven't actually tested if it runs ok though.

EDIT:
It says:

Sketch uses 1,372 bytes (16%) of program storage space. Maximum is 8,192 bytes.
Global variables use 87 bytes (16%) of dynamic memory, leaving 425 bytes for local variables. Maximum is 512 bytes.

RE: Compiling for ATtiny84 - ‘Serial’ was not declared in this scope - Added by dzach 12 months ago

One source of great confusion with the above ATtiny core is the pin names. I was very puzzled with this issue, and tried to make use of pinout descriptions like this:

but failed, and then tried to make a table with trial and error, until I realized that the above core uses the following nomenclature for the pins:

// ATMEL ATTINY84 / ARDUINO
//
//                           +-\/-+
//                     VCC  1|    |14  GND
//             (D  0)  PB0  2|    |13  AREF (D 10)
//             (D  1)  PB1  3|    |12  PA1  (D  9) 
//                     PB3  4|    |11  PA2  (D  8) 
//  PWM  INT0  (D  2)  PB2  5|    |10  PA3  (D  7) 
//  PWM        (D  3)  PA7  6|    |9   PA4  (D  6) 
//  PWM        (D  4)  PA6  7|    |8   PA5  (D  5)        PWM
//                           +----+

... which comes from the jeelabs/avr/cores/tiny/pins_arduino.c file. Which, of course, proves that jcw has already been there before :)
Which may also be an answer to this problem, now that some issues seem to have been ironed out. Until next change.

ATtiny44-84.png (36.9 KB)

RE: Compiling for ATtiny84 - ‘Serial’ was not declared in this scope - Added by dzach 12 months ago

It does indeed.
Now, if I could only find where on earth all this info goes hiding, when I need it...

Thanks Martynj

    (1-14/14)