Encoder icon indicating copy to clipboard operation
Encoder copied to clipboard

ESP32 Not working.

Open ageir opened this issue 7 years ago • 16 comments

I can't get the library working on an ESP32 lolin. I see that ESP32 is in the .h files. But for some reason it's not working. Here's an excerpt of the errors.

ESP32 is defined, because if i try to define it it says I'm redefining it. No idea how to solve it.

Compiling .pioenvs/lolin32/FrameworkArduino/HardwareSerial.o In file included from /home/myuser/.platformio/lib/Encoder_ID129/Encoder.h:46:0, from src/main.cpp:7: /home/myuser/.platformio/lib/Encoder_ID129/utility/interrupt_pins.h:202:2: error: #error "Interrupts are unknown for th is board, please add to this code" #error "Interrupts are unknown for this board, please add to this code" ^ /home/myuser/.platformio/lib/Encoder_ID129/utility/interrupt_pins.h:205:2: error: #error "Encoder requires interrupt pi ns, but this board does not have any :(" #error "Encoder requires interrupt pins, but this board does not have any :(" ^ ^ /home/myuser/.platformio/lib/Encoder_ID129/utility/interrupt_pins.h:206:2: error: #error "You could try defining ENCODE R_DO_NOT_USE_INTERRUPTS as a kludge." #error "You could try defining ENCODER_DO_NOT_USE_INTERRUPTS as a kludge." ^ In file included from src/main.cpp:7:0: /home/myuser/.platformio/lib/Encoder_ID129/Encoder.h:61:11: error: 'IO_REG_TYPE' does not name a type volatile IO_REG_TYPE * pin1_register; ^ /home/myuser/.platformio/lib/Encoder_ID129/Encoder.h:62:11: error: 'IO_REG_TYPE' does not name a type volatile IO_REG_TYPE * pin2_register; ^

ageir avatar Dec 14 '17 18:12 ageir

I do not use ESP. I'm depending on the ESP community to resolve problems and submit pull requests.

PaulStoffregen avatar Dec 14 '17 19:12 PaulStoffregen

Ah. Okej. Hopefully someone who knows the esp32 code sees this and can give me a hint on how to solve it. :)

ageir avatar Dec 15 '17 18:12 ageir

I had also trouble to compile the lib with my "nodemcu-32s" board. After looking at the source code, the ESP32 seems to be supported already. The switch for the interrupts is done with by checking for a define of "ESP32". This define seems to be missing. After adding "#define ESP32" to my main.cpp the project compiles fine.

Flos avatar Jan 13 '18 22:01 Flos

I'm depending on the ESP community to submit pull requests. If someone knows the proper way to conditionally compile for ESP32, please submit a pull request.

Again, I do not use or test with ESP32. This is free open source software. I'm depending on you, the ESP community, to send good quality pull requests.

PaulStoffregen avatar Jan 14 '18 04:01 PaulStoffregen

I don't want to be a pain, but the esp32 is far from properly working. This will take time, as it took time for the esp8266, to become reliable.

fredericplante avatar Jan 14 '18 05:01 fredericplante

I can confirm that this library works on an ESP32 (Lolin32 Lite) under Arduino IDE (with the Espressif core of course).

@ageir I see you are using PlatformIO. I've never used that IDE but suspect Espressif do not support it. I believe that is your trouble.

@fredericplante that has been true, especially six months ago but I'm finding that isn't really the case now (some edge cases of course), it's mostly generic libraries (or specific to AVR) and/or having not updated the Espressif core. Still, that isn't really on topic but thought I'd mention it in case other ESP32 users assume it's Paul's library or something.

Jim-McDonald avatar Feb 03 '18 22:02 Jim-McDonald

Hi, also on my side I can confirm that this libray is working properly on WEMOS LOLIN32 ( based on ESP32) , with 2 encoders. My dev. environment is VS2015 + VisualMicro, based on Arduino IDE toolchain.

The only issue I've found , but not caused by this great library , is that if I choose some pins (e.g. 0 and 2 for EncA and 7,6 for EncB, the program becomes instable (infinite reset with message "Guru Meditation Error: Core 0 panic'ed (IllegalInstruction))". This does not happen if i choose pin 36,25 and 26,11.

Luke1962 avatar May 24 '18 17:05 Luke1962

Going to add a little follow-up here because I couldn't understand how it worked for some ESP32 users and not me. Well, the ESP32 updates are not in v1.4.1, and that is the most recent version available through library managers in Arduino IDE and PlatformIO.

I manually updated direct_pin_read.h and interrupt_pins.h from the head of this repo (utility folder) and now it compiles happily.

Brilliant work @PaulStoffregen, thank you to @lumostor and @aster94 for the ESP32 fixes!

euphy avatar Jun 08 '18 08:06 euphy

Tried and works on ESP32, but just on "No_interrupt" mode

Zefram88 avatar Jul 27 '19 14:07 Zefram88

does esp32 works with pi 3 as a sender?

majd47 avatar Oct 18 '19 00:10 majd47

I am also running into this problem. I can only get it to work by entering this dependancy in my platformio.ini: lib_deps = https://github.com/PaulStoffregen/Encoder.git This will install version #34ea332 of the library and this works without any problems. If I enter lib_deps = Encoder, the latest version #4c4ec3a of the library gets installed and this will produce the errors again. Can someone explain this?

willemx avatar Dec 13 '19 09:12 willemx

I was having the same problem in a laptop but not in a desktop computer. Both with same Arduino IDE and Encoder library version. In laptop I installed the library with Arduino tool and in desktop I did it manually from this github repository, and that was the trick. After installed manually in laptop it compiled ok.

fercapa avatar Feb 15 '20 20:02 fercapa

The version of encoder library from the arduino IDE and platformio is 1.4.1 (commit c23bd40) which is prior ESP32 addition. You should install from github.

lumostor avatar Feb 16 '20 03:02 lumostor

I am also using platformIO with no luck compiling for esp32dev.

In file included from .pio/libdeps/esp32dev/Encoder/Encoder.h:46:0, from src/main.cpp:14: .pio/libdeps/esp32dev/Encoder/utility/interrupt_pins.h:202:2: error: #error "Interrupts are unknown for this board, please add to this code" #error "Interrupts are unknown for this board, please add to this code" ^ .pio/libdeps/esp32dev/Encoder/utility/interrupt_pins.h:205:2: error: #error "Encoder requires interrupt pins, but this board does not have any :(" #error "Encoder requires interrupt pins, but this board does not have any :(" ^ .pio/libdeps/esp32dev/Encoder/utility/interrupt_pins.h:206:2: error: #error "You could try defining ENCODER_DO_NOT_USE_INTERRUPTS as a kludge." #error "You could try defining ENCODER_DO_NOT_USE_INTERRUPTS as a kludge."

works flawlessly if I compile for esp32 using arduino IDE. I dont know how to define the board in pins.h, im a newbie.

leckietech avatar Sep 13 '21 23:09 leckietech

I am also using platformIO and it doesn't work for esp32dev with newest github version of this lib.

.pio/build/esp32dev/src/myEncoder.cpp.o: In function Encoder::isr39()': /home/.../src/myEncoder.cpp:161:(.iram1.41[Encoder::isr39()]+0x3): dangerous relocation: l32r: literal placed after use: .literal._ZN7Encoder5isr16Ev /home/.../src/myEncoder.cpp:161:(.iram1.41[Encoder::isr39()]+0x9): dangerous relocation: l32r: literal placed after use: (.literal._ZN7Encoder5isr16Ev+0x4) .pio/build/esp32dev/src/myEncoder.cpp.o: In function Encoder::isr36()': /home/.../src/myEncoder.cpp:161:(.iram1.40[Encoder::isr15()]+0x3): dangerous relocation: l32r: literal placed after use: .literal._ZN7Encoder5isr15Ev /home/.../src/myEncoder.cpp:161:(.iram1.40[Encoder::isr15()]+0x9): dangerous relocation: l32r: literal placed after use: (.literal._ZN7Encoder5isr15Ev+0x4) .pio/build/esp32dev/src/myEncoder.cpp.o: In function `Encoder::isr35()':

here Messages of isr35() to isr32(), isr27() to isr25(), isr23() to isr12(), isr5() to isr0()(below)

.pio/build/esp32dev/src/myEncoder.cpp.o: In function Encoder::isr1()': /home/.../src/myEncoder.cpp:161:(.iram1.17[Encoder::isr1()]+0x3): dangerous relocation: l32r: literal placed after use: .literal._ZN7Encoder4isr1Ev /home/.../src/myEncoder.cpp:161:(.iram1.17[Encoder::isr1()]+0x8): dangerous relocation: l32r: literal placed after use: (.literal._ZN7Encoder4isr1Ev+0x4) .pio/build/esp32dev/src/myEncoder.cpp.o: In function Encoder::isr0()': /home/.../src/myEncoder.cpp:161:(.iram1.16[Encoder::isr0()]+0x3): dangerous relocation: l32r: literal placed after use: .literal._ZN7Encoder4isr0Ev /home/.../src/myEncoder.cpp:161:(.iram1.16[Encoder::isr0()]+0x8): dangerous relocation: l32r: literal placed after use: (.literal._ZN7Encoder4isr0Ev+0x4) collect2: error: ld returned 1 exit status *** [.pio/build/esp32dev/firmware.elf] Error 1

Can someone help?

goldeng0d avatar Oct 24 '21 18:10 goldeng0d

There are solution for "dangerous relocation: l32r: literal placed after use:" error which help me with Arduino IDE. I changed -ffunction-sections to -mtext-section-literals in C:\Users*****\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.6\platform.txt file, in compiler.c.cmd=xtensa-esp32-elf-gcc and compiler.cpp.cmd=xtensa-esp32-elf-g++ paragraphs. After changes two knobs encoder example compiles normal.

RGeorge10 avatar Apr 27 '22 22:04 RGeorge10