TinyDebugKnockBang compile Errors

I am trying to get TinyDebugKnockBang to work with an ATtiny85 running at 8MHz on the internal clock.

I get the following compile error of a conflict :

TinyDebugKnockBang.h:52:20: error: conflicting declaration 'typedef struct fstr_t __FlashStringHelper'
typedef fstr_t __FlashStringHelper;

WString.h:39:7: error: 'class __FlashStringHelper' has a previous declaration as 'class __FlashStringHelper'
class __FlashStringHelper;

Any help to fix this would be appreciated.

Core?

This one.

Hum...

The FlashStringHelper in my core looks to be identical to the one used in the default Arduino core...

It looks like the TinyDebugKnockBang is assuming there isn't a FlashStringHelper already defined, and trying to supply it's own?

What is TC_VERSION here?

#if TC_VERSION < 200
typedef fstr_t __FlashStringHelper;
#endif

As a stop-gap solution, removing those lines from TinyDebugKnockBang should make it work.

It looks like the TinyDebugKnockBang is assuming there isn't a FlashStringHelper already defined, and trying to supply it's own?

TinyDebugKnockBang predates the F-macro / __FlashStringHelper existence in the Arduino core. At one point in time it was necessary to supply a definition.

What is TC_VERSION here?

Tiny Core Version. I believe it will always be 100 or undefined. (200 is unpublished)

It looks like @SpenceKonde stripped it out so it will be undefined. This may work...

  #if defined( TC_VERSION ) && (TC_VERSION < 200)
    typedef fstr_t __FlashStringHelper;
  #endif

It wasn't me that removed it :stuck_out_tongue: But that wouldn't have made a difference, as it still wouldn't have been 200.
I blame the dude whose core I forked (always a good scapegoat, right?) - He did some very aggressive cleanup and reorganization (to keep pins_arduino sane using variants, rather than stuffing everything into one giant file littered with #ifdefs, since it supports so many different parts), and that's probably when that got removed.

Is there a way to test if a macro is defined? If so, then testing whether there's an F macro should work, and would cover almost any case, since it's unlikely someone would add FlashStringHelper without F()

It wasn't me that removed it

Sorry about that. I knew someone...

He did some very aggressive cleanup and reorganization...

...just not who.

Is there a way to test if a macro is defined?

#ifdef
  • or -
#if defined(MACRO)

If you make changes to TinyDebugKnockBang please let me know so I can merge them. Or, create a pull request...

:stuck_out_tongue:

Sure. I'll check that it builds with my core and pull req it.

I know all of this is above my pay grade but....
By putting a fix in the core, isn't that a bit like the tail wagging the dog?

The core is what is essential and used with every ATtiny (yes I know there are many versions) so to my mind that should be a static base.
TinyDebugKnockBang is an optional piece of code - so it should really be adjusted to work with the core and not the other way round - irrespective of the core not previously having contained the FlashStringHelper declaration.

According to DrAzzy, the FlashStringHelper in the ATtiny cores matches the FlashStringHelper in the Arduino cores. This alone should be reason enough to preserve the core's iteration thereof.

My 2 cents contribution for a solution would be along the lines of: TinyDebugKnockBang should contain an "if not defined" condition for FlashStringHelper (since some ATtiny cores may not have it) before enabling its own iteration. Where FlashStringHelper is defined in the core TinyDebugKnockBang should be made compatible with the class defined in the core, based on the class in the official Arduino cores.

@Coding Badly / DrAzzy: Just wondering if this issue has been resolved already...?

We agreed the change doesn't go in the core, the knockbang thingie needs to be fixed.

fine fine, I'll fix it, check that it compiles and put in a pull req.

Done.

Thank you for the fix. Merged.

Thanks for fixing it.

I assume I need to download TinyDebugKnockBang again, but I have no idea how to do this:

DrAzzy:
... and put in a pull req.

Could u please provide a bit of guidance.

Yes.

The repository is here...

There is button on the right towards the bottom labeled "Download ZIP". You can download the source code packaged in a ZIP file by clicking that button. (Or use this link... https://github.com/Coding-Badly/TinyDebugKnockBang/archive/master.zip) Unfortunately, GitHub appends "-master" to the directory name. You will have to remove that. Other than that it is installed just like any other library.

Oh ok, so it is just a normal library install.
Thought DrAzzy had added some twist with his "pull req".

A pull request is a git / GitHub thing...
https://www.google.com/search?q=site%3Agithub.com+pull+request

It allows me to easily merge @DrAzzy's changes.

@DrAzzy & CodingBadly - thank you for you work :slight_smile:

@DrAzzy - compiling below code with your attiny2313 core (IDE 1.6.5 Win 8.1):

#include <TinyDebugKnockBang.h>

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

void loop() 
{
  Debug.println("test");
}

I receive:

In file included from test.ino:1:0:
D:\gc\attiny\libraries\TinyDebugKnockBang/TinyDebugKnockBang.h:78:20: error: conflicting declaration 'typedef struct fstr_t __FlashStringHelper'
     typedef fstr_t __FlashStringHelper;
                    ^
In file included from D:\gc\attiny\hardware\ATTinyCore\avr\cores\tiny/Arduino.h:221:0,
                 from D:\gc\attiny\libraries\TinyDebugKnockBang/TinyDebugKnockBang.h:28,
                 from test.ino:1:
D:\gc\attiny\hardware\ATTinyCore\avr\cores\tiny/WString.h:39:7: error: 'class __FlashStringHelper' has a previous declaration as 'class __FlashStringHelper'
 class __FlashStringHelper;
       ^

Any chance for fixing?

I am asking because I need to read on attiny x313 from software serial and debug (TinyDebugKnockBang).
DrAzzy's core seems not to work with TinyDebugKnockBang so I moved to CodingBadly's core - TinyDebugKnockBang is ok but ... SoftwareSerial gives:

D:\gc\attiny\hardware\tiny\avr\libraries\SoftwareSerial\SoftwareSerial.cpp: In member function 'void SoftwareSerial::begin(long int)':
D:\gc\attiny\hardware\tiny\avr\libraries\SoftwareSerial\SoftwareSerial.cpp:317:36: error: 'digitalPinToPCICR' was not declared in this scope
   if (digitalPinToPCICR(_receivePin)) {
                                    ^
In file included from c:\utils\arduino-1.6.5-r2\hardware\tools\avr\avr\include\avr\io.h:99:0,
                 from c:\utils\arduino-1.6.5-r2\hardware\tools\avr\avr\include\avr\interrupt.h:38,
                 from D:\gc\attiny\hardware\tiny\avr\libraries\SoftwareSerial\SoftwareSerial.cpp:41:
D:\gc\attiny\hardware\tiny\avr\libraries\SoftwareSerial\SoftwareSerial.cpp:358:76: error: 'digitalPinToPCICRbit' was not declared in this scope
     *digitalPinToPCICR(_receivePin) |= _BV(digitalPinToPCICRbit(_receivePin));
                                                                            ^
D:\gc\attiny\hardware\tiny\avr\libraries\SoftwareSerial\SoftwareSerial.cpp:361:51: error: 'digitalPinToPCMSK' was not declared in this scope
     _pcint_maskreg = digitalPinToPCMSK(_receivePin);
                                                   ^
In file included from c:\utils\arduino-1.6.5-r2\hardware\tools\avr\avr\include\avr\io.h:99:0,
                 from c:\utils\arduino-1.6.5-r2\hardware\tools\avr\avr\include\avr\interrupt.h:38,
                 from D:\gc\attiny\hardware\tiny\avr\libraries\SoftwareSerial\SoftwareSerial.cpp:41:
D:\gc\attiny\hardware\tiny\avr\libraries\SoftwareSerial\SoftwareSerial.cpp:362:60: error: 'digitalPinToPCMSKbit' was not declared in this scope
     _pcint_maskvalue = _BV(digitalPinToPCMSKbit(_receivePin));
                                                            ^

I tried also dammelis's core, but that one seems not to work with TinyDebugKnockBang.

Could you advise me any working configuration for x313 with SoftwareSerial (read) and TinyDebugKnockBang?

Thanks in advance... GC

redownload and reinstall tinydebugknockbang library.

You're using the old version from 11 or more days ago that doesn't have the fix to work with every core. It was fixed with this commit:

I just tested that with latest version of the library and my ATTiny core, the code you posted compiles.

I was aware about the new version, but... So I:

  1. unzipped fresh IDE
  2. created new sketch directory (maybe too much mess in the former one...) and configured IDE to use it
  3. downloaded new core: GitHub - SpenceKonde/ATTinyCore: Arduino core for ATtiny 1634, 828, x313, x4, x41, x5, x61, x7 and x8 and placed into newly created hardware in the new sketch folder
  4. downloaded GitHub - Coding-Badly/TinyDebugKnockBang: Write-only serial like interface for TinyISP. Useful for debugging AVR programs. and uzipped into newly created libraries in the new sketch folder (.h file created 12 days ago)
  5. Opened attached sketch (Attiny2313, 8MHz internal) and ... it compiles :slight_smile:

Sorry for bothering you DrAzzy... but:

  1. Connecting arduino, attiny2313 (Arduino as ISP), burning bootloader ... and:
Arduino: 1.6.5 (Windows 8.1), Board: "ATtiny x313 series, ATtiny2313, 8 mhz (internal), B.O.D. Disabled"

avrdude: AVR Part "attiny2313" not found.

Valid parts are:

  t1634    = ATtiny1634

  t167     = ATtiny167

  t24      = ATtiny24

Error while burning bootloader.

  t25      = ATtiny25

  t261     = ATtiny261

  t44      = ATtiny44

  t441     = ATtiny441

  t45      = ATtiny45

  t461     = ATtiny461

  t828     = ATtiny828

  t84      = ATtiny84

  t841     = ATtiny841

  t85      = ATtiny85

  t861     = ATtiny861

  t87      = ATtiny87

  t88      = ATtiny88

  This report would have more information with
  "Show verbose output during compilation"
  enabled in File > Preferences.

Above wouldn't be much important since I can use CodingBadly's bootloader. However I dont think that CodingBadly's core has the option for 20MHz external which I hoped your core will have...

@CodingBadly
I decided to test also the SoftwareSerial on the new installation. So:

//#include <TinyDebugKnockBang.h>
#include <SoftwareSerial.h>

SoftwareSerial gps(9,10);

void setup() 
{
  //Debug.begin(9600);
  gps.begin(9600);
}

void loop() 
{
  //Debug.println("test");
  int znak=gps.read();
}

... and no errors. So... sorry for bothering you as well...

Unfortunately both (TinyDebugKnockBang+SoftwareSerial) do not fit into 2313 and I cannot confirm that they compile together - but it looks promising. I have no idea which version I used previously then - they fitted... Nevertheless I have to try with 4313. Ordered alredy.

Hope that SoftwareSerial will work good enough with 4313, otherwise I'll be looking for external crystal cores... Guys, any chance for it?

And once again thank you very much for your work,
GC

Of course I can check compilation before arrival of 4313. Checked and it's OK.