Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

digispark/digistump ATTINY85 board keyboard compile errors #113

Open
tcurdt opened this issue Nov 5, 2018 · 9 comments
Open

digispark/digistump ATTINY85 board keyboard compile errors #113

tcurdt opened this issue Nov 5, 2018 · 9 comments

Comments

@tcurdt
Copy link

tcurdt commented Nov 5, 2018

[env:digispark-tiny]
platform = atmelavr
board = digispark-tiny
framework = arduino

src/keyboard.cpp:

#include "DigiKeyboard.h"

void setup() {
  DigiKeyboard.update();
}

void loop() {
  delay(1000);

  DigiKeyboard.update();
  delay(100);

  DigiKeyboard.print("hello");
  DigiKeyboard.println("world");

  delay(5000);
}
$ platformio run --target upload
Processing digispark-tiny (platform: atmelavr; board: digispark-tiny; framework: arduino)
--------------------------------------------------------------------------------------------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/atmelavr/digispark-tiny.html
PLATFORM: Atmel AVR > Digispark USB
SYSTEM: ATTINY85 16MHz 512B RAM (5.87KB Flash)
Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF MODES: FINDER(chain) COMPATIBILITY(soft)
Collected 48 compatible libraries
Scanning dependencies...
Dependency Graph
|-- <DigisparkKeyboard>
Compiling .pioenvs/digispark-tiny/src/keyboard.cpp.o
Compiling .pioenvs/digispark-tiny/lib379/DigisparkKeyboard/oddebug.c.o
Compiling .pioenvs/digispark-tiny/lib379/DigisparkKeyboard/osccal.c.o
In file included from ~/.platformio/packages/framework-arduinoavr/cores/digispark_tiny/Stream.h:24:0,
from ~/.platformio/packages/framework-arduinoavr/cores/digispark_tiny/TinyDebugSerial.h:31,
from ~/.platformio/packages/framework-arduinoavr/cores/digispark_tiny/WProgram.h:18,
from ~/.platformio/packages/framework-arduinoavr/cores/digispark_tiny/Arduino.h:4,
from ~/.platformio/packages/framework-arduinoavr/libraries/__cores__/digispark/DigisparkKeyboard/DigiKeyboard.h:10,
from src/keyboard.cpp:1:
~/.platformio/packages/framework-arduinoavr/cores/digispark_tiny/Print.h:37:0: warning: "BIN" redefined
#define BIN 2
^
In file included from ~/.platformio/packages/toolchain-atmelavr/avr/include/avr/iotn85.h:38:0,
from ~/.platformio/packages/toolchain-atmelavr/avr/include/avr/io.h:428,
from ~/.platformio/packages/toolchain-atmelavr/avr/include/avr/interrupt.h:38,
from ~/.platformio/packages/framework-arduinoavr/cores/digispark_tiny/WProgram.h:8,
from ~/.platformio/packages/framework-arduinoavr/cores/digispark_tiny/Arduino.h:4,
from ~/.platformio/packages/framework-arduinoavr/libraries/__cores__/digispark/DigisparkKeyboard/DigiKeyboard.h:10,
from src/keyboard.cpp:1:
~/.platformio/packages/toolchain-atmelavr/avr/include/avr/iotnx5.h:55:0: note: this is the location of the previous definition
#define BIN     7
^
In file included from ~/.platformio/packages/framework-arduinoavr/libraries/__cores__/digispark/DigisparkKeyboard/DigiKeyboard.h:13:0,
from src/keyboard.cpp:1:
~/.platformio/packages/toolchain-atmelavr/avr/include/avr/delay.h:36:2: warning: #warning "This file has been moved to <util/delay.h>." [-Wcpp]
#warning "This file has been moved to <util/delay.h>."
^
Compiling .pioenvs/digispark-tiny/lib379/DigisparkKeyboard/usbdrv.c.o
In file included from src/keyboard.cpp:1:0:
~/.platformio/packages/framework-arduinoavr/libraries/__cores__/digispark/DigisparkKeyboard/DigiKeyboard.h:59:1: error: narrowing conversion of '161' from 'int' to 'char' inside { } [-Wnarrowing]
};
^
~/.platformio/packages/framework-arduinoavr/libraries/__cores__/digispark/DigisparkKeyboard/DigiKeyboard.h:59:1: error: narrowing conversion of '224' from 'int' to 'char' inside { } [-Wnarrowing]
~/.platformio/packages/framework-arduinoavr/libraries/__cores__/digispark/DigisparkKeyboard/DigiKeyboard.h:59:1: error: narrowing conversion of '231' from 'int' to 'char' inside { } [-Wnarrowing]
~/.platformio/packages/framework-arduinoavr/libraries/__cores__/digispark/DigisparkKeyboard/DigiKeyboard.h:59:1: error: narrowing conversion of '149' from 'int' to 'char' inside { } [-Wnarrowing]
~/.platformio/packages/framework-arduinoavr/libraries/__cores__/digispark/DigisparkKeyboard/DigiKeyboard.h:59:1: error: narrowing conversion of '129' from 'int' to 'char' inside { } [-Wnarrowing]
~/.platformio/packages/framework-arduinoavr/libraries/__cores__/digispark/DigisparkKeyboard/DigiKeyboard.h:59:1: error: narrowing conversion of '149' from 'int' to 'char' inside { } [-Wnarrowing]
~/.platformio/packages/framework-arduinoavr/libraries/__cores__/digispark/DigisparkKeyboard/DigiKeyboard.h:59:1: error: narrowing conversion of '129' from 'int' to 'char' inside { } [-Wnarrowing]
~/.platformio/packages/framework-arduinoavr/libraries/__cores__/digispark/DigisparkKeyboard/DigiKeyboard.h:59:1: error: narrowing conversion of '192' from 'int' to 'char' inside { } [-Wnarrowing]
*** [.pioenvs/digispark-tiny/src/keyboard.cpp.o] Error 1
~/.platformio/packages/framework-arduinoavr/libraries/__cores__/digispark/DigisparkKeyboard/osccal.c: In function 'calibrateOscillator':
~/.platformio/packages/framework-arduinoavr/libraries/__cores__/digispark/DigisparkKeyboard/osccal.c:34:13: warning: implicit declaration of function 'usbMeasureFrameLength' [-Wimplicit-function-declaration]
x = usbMeasureFrameLength();    /* proportional to current real frequency */
^
==================================================================== [ERROR] Took 1.12 seconds ====================================================================

Which looks like 3 issues:

  1. redefinition of BIN with different values
  2. deprecated inclusion of delay.h which should be util/delay.h
  3. conversion of from 'int' to 'char' inside { }
@tcurdt
Copy link
Author

tcurdt commented Nov 5, 2018

changing the file

~/.platformio/packages/framework-arduinoavr/libraries/__cores__/digispark/DigisparkKeyboard/DigiKeyboard.h

explicitly casting to char is a hack/workaround for at least error 3)

@ekrempel
Copy link

Many thanks for your tip. I was able to compile and deploy the coded after I modified the code as follows.

const PROGMEM char usbHidReportDescriptor[USB_CFG_HID_REPORT_DESCRIPTOR_LENGTH] = { /* USB report descriptor */

  (char) 0x05, (char) 0x01,                    // USAGE_PAGE (Generic Desktop)
  (char) 0x09, (char) 0x06,                    // USAGE (Keyboard)
  (char) 0xa1, (char) 0x01,                    // COLLECTION (Application)
  (char) 0x05, (char) 0x07,                    //   USAGE_PAGE (Keyboard)
  (char) 0x19, (char) 0xe0,                    //   USAGE_MINIMUM (Keyboard LeftControl)
  (char) 0x29, (char) 0xe7,                    //   USAGE_MAXIMUM (Keyboard Right GUI)
  (char) 0x15, (char) 0x00,                    //   LOGICAL_MINIMUM (0)
  (char) 0x25, (char) 0x01,                    //   LOGICAL_MAXIMUM (1)
  (char) 0x75, (char) 0x01,                    //   REPORT_SIZE (1)
  (char) 0x95, (char) 0x08,                    //   REPORT_COUNT (8)
  (char) 0x81, (char) 0x02,                    //   INPUT (Data,Var,Abs)
  (char) 0x95, (char) 0x01,           //   REPORT_COUNT (simultaneous keystrokes)
  (char) 0x75, (char) 0x08,                    //   REPORT_SIZE (8)
  (char) 0x25, (char) 0x65,                    //   LOGICAL_MAXIMUM (101)
  (char) 0x19, (char) 0x00,                    //   USAGE_MINIMUM (Reserved (no event indicated))
  (char) 0x29, (char) 0x65,                    //   USAGE_MAXIMUM (Keyboard Application)
  (char) 0x81, (char) 0x00,                    //   INPUT (Data,Ary,Abs)
  (char) 0xc0                           // END_COLLECTION
};

@maelremrem
Copy link

I have an error : "too many initializers for 'const char [22]'" on the same part of the lib, can you help me ?

LuckyTurtleDev added a commit to LuckyTurtleDev/DigistumpArduino that referenced this issue May 28, 2019
@LuckyTurtleDev
Copy link

LuckyTurtleDev commented May 28, 2019

I have create a pull request:
digistump/DigistumpArduino#93

@steelywing
Copy link

steelywing commented Jul 4, 2019

I change to unsigned char also work, I am not good at C? will (char) 0x80 overflow?

// .platformio\packages\framework-arduinoavr\libraries\__cores__\digispark\DigisparkKeyboard\DigiKeyboard.h

const PROGMEM unsigned char usbHidReportDescriptor[USB_CFG_HID_REPORT_DESCRIPTOR_LENGTH]
// .platformio\packages\framework-arduinoavr\libraries\__cores__\digispark\DigisparkKeyboard\usbdrv.h

unsigned char usbDescriptorHidReport[];

@bryanjhv
Copy link

I guess it's NOT a Digistump thing, because that code compiles fine on Arduino IDE.
That made me look at root cause, it's because atmelavr sets other flags for compilation.

Specifically, builder/frameworks/arduino.py should read:

    CXXFLAGS=[
        "-Wno-error=narrowing",

@kdlslyv
Copy link

kdlslyv commented Jan 6, 2020

just fyi, as of 2020-01-06, still had to apply the proposed fix by @bryanjhv manually to work with DigiSpark USB.

@zaypen
Copy link

zaypen commented Aug 13, 2020

As of 2020-08-14, having the same issue 😂
alternative fix besides @bryanjhv 's, add this line to platformio.ini

build_flags = -Wno-error=narrowing

@dromer
Copy link

dromer commented Feb 18, 2021

Thnx @zaypen that did the trick for me!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants