util/delay.h no such file

heimi

Active member
Since today I get the error
util/delay.h no such file
at line
Code:
#include <util/delay.h>
when compiling a sletch that worked for a good time now

Changing to <avr/delay.h> gives the same result.
MacOs 11.2.3 BigSur
Arduino 1.8.13
Teensyduino 1.53

The same error occurs with
Code:
#include <i2c_t3.h>

that also worked for e good time.

How can I find these libraries?
 
I tried just now on MacOS 11.4 Big Sur. Seems to work fine.

screenshot.jpg

Check which board you have selected in the Tools > Boards menu. The wrong board selected is the only reason I can imagine why this wouldn't work.
 
Hi,

I get this:

Code:
/Users/sork/Documents/Arduino/libraries/ssd1306/src/intf/i2c/ssd1306_i2c_embedded.c:33:10: fatal error: util/delay_basic.h: No such file or directory
   33 | #include <util/delay_basic.h>
      |          ^~~~~~~~~~~~~~~~~~~~
compilation terminated.

exit status 1

Compilation error: exit status 1

I have selected the correct board (Teensy 3.0) and serial port.

To reproduce:
Load SSD1306 lib from Alexey Dynda ( https://www.arduino.cc/reference/en/libraries/ssd1306/ )
Load his examples (I did this with ssd1306>demos>ssd1306_demo )
Try to compile and load.
 
Teensy is not listed in the supported platforms for that library, so I googled the missing file "util\delay_basic.h", and it's part of avrlibc. The library you're trying to use is usable with AVR and ESP32, but not with Teensy. Not every Arduino-compatible library is necessarily usable with Teensy. The developer (or user) has to make it compatible. There are other SSD1306 libraries that are compatible with Teensy, such as the one from Adafruit.
 
Teensy is not listed in the supported platforms for that library, so I googled the missing file "util\delay_basic.h", and it's part of avrlibc. The library you're trying to use is usable with AVR and ESP32, but not with Teensy. Not every Arduino-compatible library is necessarily usable with Teensy. The developer (or user) has to make it compatible. There are other SSD1306 libraries that are compatible with Teensy, such as the one from Adafruit.

First thanks for your time.
I am not sure about what you have stated.
Paul did make util\delay_basic.h available in a previous post.
So it is a matter of not finding the file (if I am not wrong).
 
I looked at this library today.

The main problem appears to be lack of checking for AVR platform before enabling a lot of very AVR specific code, in the default case where a platform doesn't many any of the specific ones tested. Lack of util/delay_basic.h is just the tip of that iceberg. Fortunately the library was designed to not compile that stuff on non-AVR platforms, it just doesn't automatically configure itself properly. Easy to fix.

A second minor problem is it assumes Wire1.h exists if WIRE_INTERFACES_COUNT >= 1. I don't understand why, as Arduino's Wire libraries for AVR and SAMD don't have Wire1.h. But it's easy to solve.

I've made a copy with these 2 issues fixed.

https://github.com/PaulStoffregen/ssd1306

It compiles, but gives several warnings about I2C instance, so might not work with I2C.

Please let me know if this works for you? And if so, which Teensy and display did you try, and how where they connected (eg, I2C, SPI, etc).
 
Thanks Paul.
I am using a SSD1306_128x64_i2c display on a Teensy 3.0 board.
This is the display.

Should I still try your modified version?
 
Last edited:
There are other SSD1306 libraries that are compatible with Teensy, such as the one from Adafruit.

You are right on this, I tested it.
But with Adafruit SSD1306 I get strange behaviour at the top row of the display after a time by simply uploading the sketch at examples>Adafruit SSD1306>ssd1306_128x64_i2c
That is why I am looking for an alternative.
 
Last edited:
Code:
/Users/sork/Documents/Arduino/libraries/ssd1306/src/ssd1306_hal/arduino/platform.cpp: In function 'void ssd1306_platform_i2cInit(int8_t, uint8_t, ssd1306_platform_i2cConfig_t*)':
/Users/sork/Documents/Arduino/libraries/ssd1306/src/ssd1306_hal/arduino/platform.cpp:132:22: error: 'Wire1' was not declared in this scope; did you mean 'Wire'?
  132 |             s_i2c = &Wire1;
      |                      ^~~~~
      |                      Wire

exit status 1

Compilation error: exit status 1
This happens when trying to compile the example sketch ssd1306_demo provided by the author.
 
Perhaps it's about time you posted your code.

The code was said in msg #3 to simply be this library's ssd1306>demos>ssd1306_demo example.

Yeah, the "Forum Rule" says to post complete code. But in a case like this where the code is just using a library example without modification, clearly saying which example is perfectly fine. Anyone can just install the library and click File > Examples menu to get the complete code (which is exactly what I did this morning to investigate this problem and patch the library).
 
Code:
/Users/sork/Documents/Arduino/libraries/ssd1306/src/ssd1306_hal/arduino/platform.cpp:132:22: error: 'Wire1' was not declared in this scope; did you mean 'Wire'?
  132 |             s_i2c = &Wire1;
      |                      ^~~~~
      |                      Wire[/QUOTE]

I'm sorry, this error is my fault.  I didn't add a specific WIRE_INTERFACES_COUNT count define for Teensy 3.0.  (You're really using Teensy 3.0?  It was discontinued 9 years ago)

I've committed a fix on github.

https://github.com/PaulStoffregen/cores/commit/83d11eefcf6aec1cf4ed00fe8b7e8adf0ea27bd2

I'll also attach a copy of pins_arduino.h to this message.  To manually install, find the pins_arduino.h on your computer.  You should have 3 copies.  Replace the one which is inside a "teensy3" folder.  The other 2 copies are for Teensy 2.x and Teensy 4.x.

Looks like you're using MacOS.  With Arduino 1.8.x on MacOS, the folder is inside the application bundle.  Control-click Teensyduino and choose "Show Package Contents" to access it.  With Arduino 2.1.x, search inside {Library}/Arduino15/packages/teensy.
 

Attachments

  • pins_arduino.h
    11.2 KB · Views: 109
fwiw, I'm still looking into those compiler warnings... might take a while as this library has a lot of abstraction layer stuff to sift through before really finding things!
 
Thanks Paul for the effort.
YES... Teensy 3.0 still works. I am an early adopter and I just refuse to throw them away! (this may not be a lot of business for you for sure) ;)
I will try your changes with the example.

On the other hand, here is the same happening with the example code with Adafruit ssd1306 lib.
After a while behaving completely normally, from one moment to the other the first top row starts behaving as the bottom row.

 
I'm sorry, this error is my fault. I didn't add a specific WIRE_INTERFACES_COUNT count define for Teensy 3.0. (You're really using Teensy 3.0? It was discontinued 9 years ago)

I've committed a fix on github.

https://github.com/PaulStoffregen/cores/commit/83d11eefcf6aec1cf4ed00fe8b7e8adf0ea27bd2

I'll also attach a copy of pins_arduino.h to this message. To manually install, find the pins_arduino.h on your computer. You should have 3 copies. Replace the one which is inside a "teensy3" folder. The other 2 copies are for Teensy 2.x and Teensy 4.x.

Looks like you're using MacOS. With Arduino 1.8.x on MacOS, the folder is inside the application bundle. Control-click Teensyduino and choose "Show Package Contents" to access it. With Arduino 2.1.x, search inside {Library}/Arduino15/packages/teensy.

No Compiling errors !!
And it is working !!
(0nly not sure if CANVAS GFX in the video below is what it is supposed to be)


Thanks Paul !!
 
Paul, FYI, not all the examples compile if you want to check.
There is a BENCHMARK sketch that does not for example.
 
Back
Top