Closed m-wb closed 1 year ago
To me it looks like an issue with the avr-minicore. Did you try the suggestion from the above refere issue? Try to comment / remove this line in your local u8g2 installation: https://github.com/olikraus/u8g2/blob/74e379c08f4e3db2c9ac18db72cdee0d47276a58/cppsrc/U8x8lib.h#L138
Maybe this will fix the error...
Thanks for the answer. Unfortunately, commenting did not help, the error is the same. I'll post the full error response below, in case this might help
HARDWARE: ATMEGA328P 8MHz, 2KB RAM, 32KB Flash
DEBUG: Current (avr-stub) External (avr-stub, simavr)
PACKAGES:
- framework-arduino-avr-minicore @ 2.2.2
- tool-avrdude @ 1.70100.0 (7.1.0)
- toolchain-atmelavr @ 1.70300.191015 (7.3.0)
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 24 compatible libraries
Scanning dependencies...
Dependency Graph
|-- U8g2 @ 2.34.22
Building in release mode
Compiling .pio\build\Upload_ISP\src\main.cpp.o
Compiling .pio\build\Upload_ISP\libc9a\Wire1\Wire1.cpp.o
Compiling .pio\build\Upload_ISP\libc9a\Wire1\utility\twi1.c.o
C:\Users\marku\.platformio\packages\framework-arduino-avr-minicore\libraries\Wire1\src\utility\twi1.c: In function 'twi_init1':
C:\Users\marku\.platformio\packages\framework-arduino-avr-minicore\libraries\Wire1\src\utility\twi1.c:88:16: error: 'SDA1' undeclared (first use in this function); did you mean 'SDA'?
digitalWrite(SDA1, 1);
^~~~
SDA
C:\Users\marku\.platformio\packages\framework-arduino-avr-minicore\libraries\Wire1\src\utility\twi1.c:88:16: note: each undeclared identifier is reported only once for each function it appears in
C:\Users\marku\.platformio\packages\framework-arduino-avr-minicore\libraries\Wire1\src\utility\twi1.c:89:16: error: 'SCL1' undeclared (first use in this function); did you mean 'SCL'?
digitalWrite(SCL1, 1);
^~~~
SCL
In file included from c:\users\marku\.platformio\packages\toolchain-atmelavr\avr\include\avr\io.h:99:0,
from C:\Users\marku\.platformio\packages\framework-arduino-avr-minicore\libraries\Wire1\src\utility\twi1.c:25:
C:\Users\marku\.platformio\packages\framework-arduino-avr-minicore\libraries\Wire1\src\utility\twi1.c:92:7: error: 'TWSR1' undeclared (first use in this function); did you mean 'TWSR'?
cbi(TWSR1, TWPS0);
^
C:\Users\marku\.platformio\packages\framework-arduino-avr-minicore\libraries\Wire1\src\utility\twi1.c:92:3: note: in expansion of macro 'cbi'
cbi(TWSR1, TWPS0);
^~~
C:\Users\marku\.platformio\packages\framework-arduino-avr-minicore\libraries\Wire1\src\utility\twi1.c:94:9: error: lvalue required as left operand of assignment
TWBR1 = ((F_CPU / TWI_FREQ) - 16) / 2;
^
C:\Users\marku\.platformio\packages\framework-arduino-avr-minicore\libraries\Wire1\src\utility\twi1.c:102:3: error: 'TWCR1' undeclared (first use in this function); did you mean 'TWSR1'?
TWCR1 = _BV(TWEN) | _BV(TWIE) | _BV(TWEA);
^~~~~
TWSR1
C:\Users\marku\.platformio\packages\framework-arduino-avr-minicore\libraries\Wire1\src\utility\twi1.c: In function 'twi_disable1':
C:\Users\marku\.platformio\packages\framework-arduino-avr-minicore\libraries\Wire1\src\utility\twi1.c:114:3: error: 'TWCR1' undeclared (first use in this function); did you mean 'TWCR'?
TWCR1 &= ~(_BV(TWEN) | _BV(TWIE) | _BV(TWEA));
^~~~~
TWCR
C:\Users\marku\.platformio\packages\framework-arduino-avr-minicore\libraries\Wire1\src\utility\twi1.c:117:16: error: 'SDA1' undeclared (first use in this function); did you mean 'SDA'?
digitalWrite(SDA1, 0);
^~~~
SDA
C:\Users\marku\.platformio\packages\framework-arduino-avr-minicore\libraries\Wire1\src\utility\twi1.c:118:16: error: 'SCL1' undeclared (first use in this function); did you mean 'SCL'?
digitalWrite(SCL1, 0);
^~~~
SCL
C:\Users\marku\.platformio\packages\framework-arduino-avr-minicore\libraries\Wire1\src\utility\twi1.c: In function 'twi_setAddress1':
C:\Users\marku\.platformio\packages\framework-arduino-avr-minicore\libraries\Wire1\src\utility\twi1.c:130:3: error: 'TWAR1' undeclared (first use in this function); did you mean 'TWA1'?
TWAR1 = address << 1;
^~~~~
TWA1
C:\Users\marku\.platformio\packages\framework-arduino-avr-minicore\libraries\Wire1\src\utility\twi1.c: In function 'twi_setFrequency1':
C:\Users\marku\.platformio\packages\framework-arduino-avr-minicore\libraries\Wire1\src\utility\twi1.c:141:9: error: lvalue required as left operand of assignment
TWBR1 = ((F_CPU / frequency) - 16) / 2;
^
C:\Users\marku\.platformio\packages\framework-arduino-avr-minicore\libraries\Wire1\src\utility\twi1.c: In function 'twi_readFrom1':
C:\Users\marku\.platformio\packages\framework-arduino-avr-minicore\libraries\Wire1\src\utility\twi1.c:218:9: error: 'TWDR1' undeclared (first use in this function); did you mean 'TWD1'?
TWDR1 = twi_slarw;
^~~~~
TWD1
C:\Users\marku\.platformio\packages\framework-arduino-avr-minicore\libraries\Wire1\src\utility\twi1.c:219:15: error: 'TWCR1' undeclared (first use in this function); did you mean 'TWDR1'?
} while(TWCR1 & _BV(TWWC));
^~~~~
TWDR1
C:\Users\marku\.platformio\packages\framework-arduino-avr-minicore\libraries\Wire1\src\utility\twi1.c: In function 'twi_writeTo1':
C:\Users\marku\.platformio\packages\framework-arduino-avr-minicore\libraries\Wire1\src\utility\twi1.c:321:9: error: 'TWDR1' undeclared (first use in this function); did you mean 'TWD1'?
TWDR1 = twi_slarw;
^~~~~
TWD1
C:\Users\marku\.platformio\packages\framework-arduino-avr-minicore\libraries\Wire1\src\utility\twi1.c:322:15: error: 'TWCR1' undeclared (first use in this function); did you mean 'TWDR1'?
} while(TWCR1 & _BV(TWWC));
^~~~~
TWDR1
C:\Users\marku\.platformio\packages\framework-arduino-avr-minicore\libraries\Wire1\src\utility\twi1.c: In function 'twi_reply1':
C:\Users\marku\.platformio\packages\framework-arduino-avr-minicore\libraries\Wire1\src\utility\twi1.c:420:5: error: 'TWCR1' undeclared (first use in this function); did you mean 'TWCR'?
TWCR1 = _BV(TWEN) | _BV(TWIE) | _BV(TWINT) | _BV(TWEA);
^~~~~
TWCR
C:\Users\marku\.platformio\packages\framework-arduino-avr-minicore\libraries\Wire1\src\utility\twi1.c: In function 'twi_stop1':
C:\Users\marku\.platformio\packages\framework-arduino-avr-minicore\libraries\Wire1\src\utility\twi1.c:435:3: error: 'TWCR1' undeclared (first use in this function); did you mean 'TWCR'?
TWCR1 = _BV(TWEN) | _BV(TWIE) | _BV(TWEA) | _BV(TWINT) | _BV(TWSTO);
^~~~~
TWCR
C:\Users\marku\.platformio\packages\framework-arduino-avr-minicore\libraries\Wire1\src\utility\twi1.c: In function 'twi_releaseBus1':
C:\Users\marku\.platformio\packages\framework-arduino-avr-minicore\libraries\Wire1\src\utility\twi1.c:473:3: error: 'TWCR1' undeclared (first use in this function); did you mean 'TWCR'?
TWCR1 = _BV(TWEN) | _BV(TWIE) | _BV(TWEA) | _BV(TWINT);
^~~~~
TWCR
C:\Users\marku\.platformio\packages\framework-arduino-avr-minicore\libraries\Wire1\src\utility\twi1.c: In function 'twi_handleTimeout1':
C:\Users\marku\.platformio\packages\framework-arduino-avr-minicore\libraries\Wire1\src\utility\twi1.c:505:29: error: 'TWAR1' undeclared (first use in this function); did you mean 'TWA1'?
uint8_t previous_TWAR = TWAR1;
^~~~~
TWA1
C:\Users\marku\.platformio\packages\framework-arduino-avr-minicore\libraries\Wire1\src\utility\twi1.c:513:11: error: lvalue required as left operand of assignment
TWBR1 = previous_TWBR;
^
In file included from C:\Users\marku\.platformio\packages\framework-arduino-avr-minicore\libraries\Wire1\src\utility\twi1.c:26:0:
C:\Users\marku\.platformio\packages\framework-arduino-avr-minicore\libraries\Wire1\src\utility\twi1.c: In function 'TWI1_vect':
C:\Users\marku\.platformio\packages\framework-arduino-avr-minicore\libraries\Wire1\src\utility\twi1.c:532:5: warning: 'TWI1_vect' appears to be a misspelled 'signal' handler, missing '__vector' prefix [-Wmisspelled-isr]
ISR(TWI1_vect)
^
C:\Users\marku\.platformio\packages\framework-arduino-avr-minicore\libraries\Wire1\src\utility\twi1.c:535:10: error: 'TWSR1' undeclared (first use in this function); did you mean 'TWSR'?
switch(TWSR1 & TW_STATUS_MASK){
^~~~~
TWSR
C:\Users\marku\.platformio\packages\framework-arduino-avr-minicore\libraries\Wire1\src\utility\twi1.c:540:7: error: 'TWDR1' undeclared (first use in this function); did you mean 'TWSR1'?
TWDR1 = twi_slarw;
^~~~~
TWSR1
C:\Users\marku\.platformio\packages\framework-arduino-avr-minicore\libraries\Wire1\src\utility\twi1.c:560:5: error: 'TWCR1' undeclared (first use in this function); did you mean 'TWDR1'?
TWCR1 = _BV(TWINT) | _BV(TWSTA)| _BV(TWEN) ;
^~~~~
TWDR1
C:\Users\marku\.platformio\packages\framework-arduino-avr-minicore\libraries\Wire1\src\Wire1.cpp: In lambda function:
C:\Users\marku\.platformio\packages\framework-arduino-avr-minicore\libraries\Wire1\src\Wire1.cpp:24:56: error: 'static void TwoWire::onReceiveService(uint8_t*, int)' is private within this context
[](uint8_t* v, int len){ Wire1.onReceiveService(v, len); },
^~~~~~~~~~~~~~~~
In file included from C:\Users\marku\.platformio\packages\framework-arduino-avr-minicore\libraries\Wire1\src\Wire1.h:4:0,
from C:\Users\marku\.platformio\packages\framework-arduino-avr-minicore\libraries\Wire1\src\Wire1.cpp:5:
C:\Users\marku\.platformio\packages\framework-arduino-avr-minicore\libraries\Wire\src/Wire.h:53:17: note: declared private here
static void onReceiveService(uint8_t*, int);
^~~~~~~~~~~~~~~~
C:\Users\marku\.platformio\packages\framework-arduino-avr-minicore\libraries\Wire1\src\Wire1.cpp:24:79: error: 'static void TwoWire::onReceiveService(uint8_t*, int)' is private within this context
[](uint8_t* v, int len){ Wire1.onReceiveService(v, len); },
^
In file included from C:\Users\marku\.platformio\packages\framework-arduino-avr-minicore\libraries\Wire1\src\Wire1.h:4:0,
from C:\Users\marku\.platformio\packages\framework-arduino-avr-minicore\libraries\Wire1\src\Wire1.cpp:5:
C:\Users\marku\.platformio\packages\framework-arduino-avr-minicore\libraries\Wire\src/Wire.h:53:17: note: declared private here
static void onReceiveService(uint8_t*, int);
^~~~~~~~~~~~~~~~
C:\Users\marku\.platformio\packages\framework-arduino-avr-minicore\libraries\Wire1\src\Wire1.cpp: In lambda function:
C:\Users\marku\.platformio\packages\framework-arduino-avr-minicore\libraries\Wire1\src\Wire1.cpp:26:37: error: 'static void TwoWire::onRequestService()' is private within this context
[](){ Wire1.onRequestService(); });
^~~~~~~~~~~~~~~~
In file included from C:\Users\marku\.platformio\packages\framework-arduino-avr-minicore\libraries\Wire1\src\Wire1.h:4:0,
from C:\Users\marku\.platformio\packages\framework-arduino-avr-minicore\libraries\Wire1\src\Wire1.cpp:5:
C:\Users\marku\.platformio\packages\framework-arduino-avr-minicore\libraries\Wire\src/Wire.h:52:17: note: declared private here
static void onRequestService(void);
^~~~~~~~~~~~~~~~
C:\Users\marku\.platformio\packages\framework-arduino-avr-minicore\libraries\Wire1\src\Wire1.cpp:26:54: error: 'static void TwoWire::onRequestService()' is private within this context
[](){ Wire1.onRequestService(); });
^
In file included from C:\Users\marku\.platformio\packages\framework-arduino-avr-minicore\libraries\Wire1\src\Wire1.h:4:0,
from C:\Users\marku\.platformio\packages\framework-arduino-avr-minicore\libraries\Wire1\src\Wire1.cpp:5:
C:\Users\marku\.platformio\packages\framework-arduino-avr-minicore\libraries\Wire\src/Wire.h:52:17: note: declared private here
static void onRequestService(void);
^~~~~~~~~~~~~~~~
C:\Users\marku\.platformio\packages\framework-arduino-avr-minicore\libraries\Wire1\src\Wire1.cpp: At global scope:
C:\Users\marku\.platformio\packages\framework-arduino-avr-minicore\libraries\Wire1\src\Wire1.cpp:26:58: error: no matching function for call to 'TwoWire::TwoWire(int, void (&)(), void (&)(), void (&)(uint8_t), void (&)(uint32_t), uint8_t (&)(uint8_t, uint8_t*, uint8_t, uint8_t), uint8_t (&)(uint8_t, uint8_t*, uint8_t, uint8_t, uint8_t), uint8_t (&)(const uint8_t*, uint8_t), void (&)(uint8_t), void (&)(), void (&)(), void (&)(void (*)(uint8_t*, int)), <lambda(uint8_t*, int)>, void (&)(void (*)()), <lambda()>)'
[](){ Wire1.onRequestService(); });
^
In file included from C:\Users\marku\.platformio\packages\framework-arduino-avr-minicore\libraries\Wire1\src\Wire1.h:4:0,
from C:\Users\marku\.platformio\packages\framework-arduino-avr-minicore\libraries\Wire1\src\Wire1.cpp:5:
C:\Users\marku\.platformio\packages\framework-arduino-avr-minicore\libraries\Wire\src/Wire.h:55:5: note: candidate: TwoWire::TwoWire()
TwoWire();
^~~~~~~
C:\Users\marku\.platformio\packages\framework-arduino-avr-minicore\libraries\Wire\src/Wire.h:55:5: note: candidate expects 0 arguments, 15 provided
C:\Users\marku\.platformio\packages\framework-arduino-avr-minicore\libraries\Wire\src/Wire.h:37:7: note: candidate: constexpr TwoWire::TwoWire(const TwoWire&)
class TwoWire : public Stream
^~~~~~~
C:\Users\marku\.platformio\packages\framework-arduino-avr-minicore\libraries\Wire\src/Wire.h:37:7: note: candidate expects 1 argument, 15 provided
C:\Users\marku\.platformio\packages\framework-arduino-avr-minicore\libraries\Wire\src/Wire.h:37:7: note: candidate: constexpr TwoWire::TwoWire(TwoWire&&)
C:\Users\marku\.platformio\packages\framework-arduino-avr-minicore\libraries\Wire\src/Wire.h:37:7: note: candidate expects 1 argument, 15 provided
Compiling .pio\build\Upload_ISP\lib253\U8g2\clib\u8x8_d_ssd1306_64x32.c.o
Compiling .pio\build\Upload_ISP\lib253\U8g2\clib\u8x8_d_ssd1306_64x48.c.o
Compiling .pio\build\Upload_ISP\lib253\U8g2\clib\u8x8_d_ssd1306_72x40.c.o
Compiling .pio\build\Upload_ISP\lib253\U8g2\clib\u8x8_d_ssd1306_96x16.c.o
Compiling .pio\build\Upload_ISP\lib253\U8g2\clib\u8x8_d_ssd1306_96x40.c.o
Compiling .pio\build\Upload_ISP\lib253\U8g2\clib\u8x8_d_ssd1309.c.o
Compiling .pio\build\Upload_ISP\lib253\U8g2\clib\u8x8_d_ssd1316.c.o
Compiling .pio\build\Upload_ISP\lib253\U8g2\clib\u8x8_d_ssd1317.c.o
Compiling .pio\build\Upload_ISP\lib253\U8g2\clib\u8x8_d_ssd1318.c.o
Compiling .pio\build\Upload_ISP\lib253\U8g2\clib\u8x8_d_ssd1320.c.o
Compiling .pio\build\Upload_ISP\lib253\U8g2\clib\u8x8_d_ssd1322.c.o
Compiling .pio\build\Upload_ISP\lib253\U8g2\clib\u8x8_d_ssd1325.c.o
*** [.pio\build\Upload_ISP\libc9a\Wire1\utility\twi1.c.o] Error 1
Compiling .pio\build\Upload_ISP\lib253\U8g2\clib\u8x8_d_ssd1326.c.o
*** [.pio\build\Upload_ISP\libc9a\Wire1\Wire1.cpp.o] Error 1
========================== [FAILED] Took 3.10 seconds ==========================
[Finished in 3.7s]```
From my perspective the error is in the board library. So u8g2 is the wrong place to ask. The only thing what you could do here is to fully disable I2C support:
Remove the following line to disable I2C: https://github.com/olikraus/u8g2/blob/74e379c08f4e3db2c9ac18db72cdee0d47276a58/cppsrc/U8x8lib.h#L84
Thanks for your response. Unfortunately I'll need I2C to drive an OLED. But I'll find another way around this.
Thanks again.
FYI: I did compile successfully without any problems on a M0+, so yes, probably an issue with the minicore board lib.
Thanks for the support anyhow :)
@m-wb did you ever get this working with the 328p? I'm running into the same issue https://community.platformio.org/t/cannot-compile-basic-u8g2-sketch/36168
Edit: solved this by just removing the #include <Wire1.h>
in U8x8lib.cpp. Not sure why the logic was pulling that in since I have a 328p board (not 328pb).
Anyways, I changed the directive to:
#ifdef U8X8_HAVE_HW_I2C
# ifdef U8X8_HAVE_HW_I2C_TEENSY3
# include <i2c_t3.h>
# else
# include <Wire.h>
# endif
#endif /* U8X8_HAVE_HW_I2C */
and I can compile now
Hi, No, I did not on the 328p. i had to switch to a more capable MCU anyways due to other requirements, so it was no issue for me anymore.
But good to know for future projects, thanks for letting me know, although this would not solve the issue for the 328pb.
Hi, I am trying to compile for the Atmega328P using PlatformIO and miniCore.
as soon as I include the U8g2 lib, I get compilation errors regarding Wire (even with empty / minimal examples)
I get these errors:
and many more that look the same, ending with
Google searches led to nothing and I have no idea on how to proceed. I was reminded of the issue I had last year with the 328PB which was solved here: https://github.com/olikraus/u8g2/issues/1890
Interestingly it worked until I installed the library fresh (I had U8g2 2.33.9 installed globally via pio, removed it, then added it again via platformio.ini in lib_deps = olikraus/U8g2@^2.34.22). I'm not 100% positive whether I changed anything in the old installation, but if, then it certainly only was the fix of issue 1890 before it was integrated into the code vie PR.
Any ideas?