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

ESP32 compile error with arduino-esp32 v2.0.3-rc1 (error: 'esp32_gpioMux' was not declared in this scope) #112

Closed
bghavami opened this issue Apr 11, 2022 · 36 comments

Comments

@bghavami
Copy link

Board
Esp32S2 Dev Module and Esp32S3 Dev Module

Device Description
NodeMcu-32S or Esp32-S3-DevKitC-1 v1.6
Testing with Dallas OneWire Temperature sensor

Hardware Configuration
GPIO 2 connected to Dallas Temperature sensor

Version
latest master

IDE Name
Arduino IDE 1.8.20

Operating System
Windows 10

Flash frequency
80 Mhz

PSRAM enabled
no

Upload speed
921600

Description:
I am getting an error while compiling sample/example code for Dallas Temperature sensor.
Steps to generate the error:
1- Load the code: File -> Examples -> Dallas Temperature -> Simple
2- verify / Compile

Compiler generates the following error:
OneWire_direct_gpio.h:191:38: error: 'esp32_gpioMux' was not declared in this scope ESP_REG(DR_REG_IO_MUX_BASE + esp32_gpioMux[pin].reg) = pinFunction;

It appears that "esp32_gpioMux" is no longer defined!!!

Sketch:
// Include the libraries we need
#include <OneWire.h>
#include <DallasTemperature.h>

// Data wire is plugged into port 2 on the Arduino
#define ONE_WIRE_BUS 2

// Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs)
OneWire oneWire(ONE_WIRE_BUS);

// Pass our oneWire reference to Dallas Temperature.
DallasTemperature sensors(&oneWire);

/*

  • The setup function. We only start the sensors here
    */
    void setup(void)
    {
    // start serial port
    Serial.begin(9600);
    Serial.println("Dallas Temperature IC Control Library Demo");

// Start up the library
sensors.begin();
}

/*

  • Main function, get and show the temperature
    */
    void loop(void)
    {
    // call sensors.requestTemperatures() to issue a global temperature
    // request to all devices on the bus
    Serial.print("Requesting temperatures...");
    sensors.requestTemperatures(); // Send the command to get temperatures
    Serial.println("DONE");
    // After we got the temperatures, we can print them here.
    // We use the function ByIndex, and as an example get the temperature from the first sensor only.
    float tempC = sensors.getTempCByIndex(0);

// Check if reading was successful
if(tempC != DEVICE_DISCONNECTED_C)
{
Serial.print("Temperature for the device 1 (index 0) is: ");
Serial.println(tempC);
}
else
{
Serial.println("Error: Could not read temperature data");
}
}

Errors or Incorrect Output

Debug Message
In file included from C:\Users\eghav\AppData\Local\arduino15\packages\esp32\hardware\esp32\2.0.3-RC1\cores\esp32/Arduino.h:36,
from C:\Users\eghav\Documents\Arduino\libraries\OneWire\OneWire.cpp:142:
C:\Users\eghav\Documents\Arduino\libraries\OneWire\util/OneWire_direct_gpio.h: In function 'void directModeInput(uint32_t)':
C:\Users\eghav\Documents\Arduino\libraries\OneWire\util/OneWire_direct_gpio.h:191:38: error: 'esp32_gpioMux' was not declared in this scope
ESP_REG(DR_REG_IO_MUX_BASE + esp32_gpioMux[pin].reg) = pinFunction;
^~~~~~~~~~~~~
C:\Users\eghav\AppData\Local\arduino15\packages\esp32\hardware\esp32\2.0.3-RC1\cores\esp32/esp32-hal.h:73:47: note: in definition of macro 'ESP_REG'
#define ESP_REG(addr) *((volatile uint32_t *)(addr))
^~~~
C:\Users\eghav\Documents\Arduino\libraries\OneWire\util/OneWire_direct_gpio.h: In function 'void directModeOutput(uint32_t)':
C:\Users\eghav\Documents\Arduino\libraries\OneWire\util/OneWire_direct_gpio.h:232:38: error: 'esp32_gpioMux' was not declared in this scope
ESP_REG(DR_REG_IO_MUX_BASE + esp32_gpioMux[pin].reg) = pinFunction;
^~~~~~~~~~~~~
C:\Users\eghav\AppData\Local\arduino15\packages\esp32\hardware\esp32\2.0.3-RC1\cores\esp32/esp32-hal.h:73:47: note: in definition of macro 'ESP_REG'
#define ESP_REG(addr) *((volatile uint32_t *)(addr))
^~~~
exit status 1
Error compiling for board ESP32S3 Dev Module.

@vangalvin
Copy link

I seem to be having the same issue. I tried to move to OneWireNG but DSTherm is pretty limited in what it can do and i could not get the DallasTemperature lib to work with it.

@uzi18
Copy link

uzi18 commented Apr 15, 2022

OneWireNG and DallasTemperature works perfectly, what was your problem? If you got problem open issue in OneWireNG project
@pstolarz

@vangalvin
Copy link

OneWireNG and DallasTemperature works perfectly, what was your problem? If you got problem open issue in OneWireNG project @pstolarz

Its working, perfectly now. The issue was being caused by another version of onewire that was lurking in my libraries. As soon as I huned it out and deleted it the error went away.

@uzi18
Copy link

uzi18 commented Apr 15, 2022

We tested it on esp32 and it works with perfect timings on logic analyzer.
For esp32 it is perfect from 0.11.0
Glad you found solution.

@goetmat
Copy link

goetmat commented Apr 19, 2022

same issue on my side: .pio/libdeps/xxx/OneWire/util/OneWire_direct_gpio.h:191:38: error: 'esp32_gpioMux' was not declared in this scope

@bghavami
Copy link
Author

bghavami commented May 6, 2022

We tested it on esp32 and it works with perfect timings on logic analyzer. For esp32 it is perfect from 0.11.0 Glad you found solution.

If possible, Please, verify that it works with Esp32s3 Dev Module using Version 2.0.3-RC1. I am unable to get it to function.
Thanks.

@uzi18
Copy link

uzi18 commented May 6, 2022

If you got problem report it on OneWireNg project.
Thanks

@Jason2866
Copy link
Contributor

@uzi18 OneWire is not working. No one here is interested if OneWireNG is working.
As it is now OneWire does NOT work with actual Espressif32 Arduino Core 2.0.3.
We changed it to work with actual version. It can be seen here. Will do no PR since it will not get merged (as any fix for espressif devices).

@juergen-weber
Copy link

juergen-weber commented May 16, 2022

I got a similar error on Platformio indicating that OneWire 2.3.6 is broken when being used with esp32-203:
[env:m5stack-core2]
platform_packages = framework-arduinoespressif32 @ https://github.com/espressif/arduino-esp32/releases/download/2.0.3/esp32-2.0.3.zip
platform = espressif32
board = m5stack-core2

In function 'void directModeInput(uint32_t)':
.pio/libdeps/m5stack-core2/OneWire/util/OneWire_direct_gpio.h:191:38: error: 'esp32_gpioMux' was not declared in this scope

@Jason2866
Copy link
Contributor

Jason2866 commented May 16, 2022

To be clear it is not a Arduino Core 2.0.3 issue. The problem is the external OneWire library. The library is not from espressif. So espressif is not responsible for.
A example for a working modified version is mentioned in #112 (comment)

@drquark
Copy link

drquark commented May 18, 2022

I am having the same problem today. I have one copy of OneWire, version 2.3.6 and it conflicts when I have the ESP32 TTGO LoRa32-OLED Board selected. The #include <OneWire.h> code verifies OK if there is an ESP8266 selected.

If I delete the #include statement, the code verifies OK with the ESP32.

@drquark
Copy link

drquark commented May 18, 2022

For the previous comment: This was suggested on the Arduino Forum--
My only 2 suggestions would be to go to the github site of the onewire and report your issue there as you've done here. See if an older version of onewire will work.

ESPRESSIF has recently released a new version of the ESP32 core for the ESP-IDF. That core is not compatible, yet, with the ESP32 Arduino Core. From the errors OneWire is using the ESP32 API directly. OneWire may need to be updated.

@uzi18
Copy link

uzi18 commented May 18, 2022

But OneWireNG is compatible and works perfectly.

@MrYsLab
Copy link

MrYsLab commented May 18, 2022

+1 I, too, am having the compile issue. Downgrading to version 2.0.2 of the ESP32 Arduino core works as a temporary fix.

@drquark
Copy link

drquark commented May 18, 2022

uzi18, I have read the docs on OneWireNG at github and I can't see how to do the following very simple read/write on a designated pin:
--------- for function "dallas()" --------------------------
int dallas(int x) {
OneWire ds(x) ;
int data0 ;
int data1 ;
int result ;

ds.reset() ;
ds.write(0xCC) ;  // skip command
ds.write(0xBE) ;  // Read 1st 2 bytes of Scratchpad
data0 = ds.read() ;
data1 = ds.read() ;
result = (data1 << 8) | data0 ;
result = (((result * 90)+0x04) >> 3 ) + 3200 ;  // F x 100
ds.reset() ;
ds.write(0xCC) ;   // skip command
ds.write(0x44,1) ; // start conversion
return result ;

}

@drquark
Copy link

drquark commented May 18, 2022

For the previous comment, that's one DS18B20 per pin and direct power. Real simple.

What I don't see in the OneWireNG examples is how it is compatible with OneWire. If it is directly compatible, then the code in the previous comment should work without change. Is that true?

The reason I wrote my own code to read the DS18B20 is that I have 20 remote units, but the Dallas library can take a second or so to do a read. I don't have the time to sit in the Dallas function 20 times reading the remotes, so my code (the first time through in each remote) gets garbage, but it starts the conversion. The second and subsequent passes, it reads good data and restarts the conversion process. This works really well with a Nano or Pro Mini.

@drquark
Copy link

drquark commented May 18, 2022

OK, I used the library manager to add OneWireNg. The #include statement seems to work, but using the statement "OneWire" doesn't create the expected read/write functions, so I don't know what "compatible" means.

@Jason2866
Copy link
Contributor

@drquark Use this OneWire version. It is a modified version of OneWire and does work with actual Arduino Esp32 core 2.0.3

@drquark
Copy link

drquark commented May 18, 2022

OK, Jason2866, I'll give it a try. Thanks.

I just downgraded to ESP32 core version 2.0.2 and that eliminated the #include <OneWire.h> error.

@uzi18
Copy link

uzi18 commented May 18, 2022

uzi18, I have read the docs on OneWireNG at github and I can't see how to do the following very simple read/write on a designated pin: --------- for function "dallas()" -------------------------- int dallas(int x) { OneWire ds(x) ; int data0 ; int data1 ; int result ;

ds.reset() ;
ds.write(0xCC) ;  // skip command
ds.write(0xBE) ;  // Read 1st 2 bytes of Scratchpad
data0 = ds.read() ;
data1 = ds.read() ;
result = (data1 << 8) | data0 ;
result = (((result * 90)+0x04) >> 3 ) + 3200 ;  // F x 100
ds.reset() ;
ds.write(0xCC) ;   // skip command
ds.write(0x44,1) ; // start conversion
return result ;

}

include is the same, but try to uninstall OneWire lib - they can collide in Arduino IDE

check also DSTemp example for code like above

@PaulStoffregen
Copy link
Owner

Please understand I am depending on the open source community to submit pull requests to maintain ESP32 defines.
I do not personally use or test ESP boards. The old defines, which worked with prior versions of the ESP software, were contributed by the open source community. My hope is someone in the ESP open source community will take the time to verify a new set of defines and send a pull request.

@drquark
Copy link

drquark commented May 18, 2022

Using the ESP32 core version 2.0.2 and the current 2.3.6 version of OneWire, I'm uploading fine and reading the DS18B20s no sweat.

@uzi18
Copy link

uzi18 commented May 18, 2022

But now you are fixed with old core

@Jason2866
Copy link
Contributor

Have done a version which is PR ready and should work. Since i have no possibility to test (for the next 4 weeks) give it a try and if ok please give me a feedback here and i will do the PR.

@MrYsLab
Copy link

MrYsLab commented May 18, 2022

@Jason2866 Thanks for this fix. I just tried with a DS18B20 and am seeing some strange behavior.
If I test with ESP32 core version 2.0.2, your version works. However, if I upgrade to 2.0.3, my sketch compiles, but I cannot upload it to my board. There is a serial communication problem. I am using a DoIt DevKit1.
Here is the failure output from the Arduino IDE with Show verbose output during compilation turned on:

Sketch uses 705725 bytes (53%) of program storage space. Maximum is 1310720 bytes.
Global variables use 42228 bytes (12%) of dynamic memory, leaving 285452 bytes for local variables. Maximum is 327680 bytes.
esptool.py v3.3-dev
Serial port /dev/ttyUSB0
Connecting......................................

A fatal error occurred: Failed to connect to ESP32: Wrong boot mode detected (0x13)! The chip needs to be in download mode.
For troubleshooting steps visit: https://docs.espressif.com/projects/esptool/en/latest/troubleshooting.html
the selected serial port For troubleshooting steps visit: https://docs.espressif.com/projects/esptool/en/latest/troubleshooting.html
 does not exist or your board is not connected

I will research about the boot mode, and if I make any progress will report back.

@juergen-weber
Copy link

juergen-weber commented May 19, 2022

Sorted. By simply replacing .pio\libdeps\m5stack-core2\OneWire\utilOneWire_direct_gpio.h with your new file from https://github.com/Jason2866/OneWire/tree/esp32_arduino_core2/util/utilOneWire_direct_gpio.h solved the problem. Thanks Jason

PLATFORM: Espressif 32 (4.2.0) > M5Stack Core2
HARDWARE: ESP32 240MHz, 4.31MB RAM, 16MB Flash
PACKAGES:

  • framework-arduinoespressif32 @ 2.0.3
  • tool-esptoolpy @ 1.30300.0 (3.3.0)
  • toolchain-xtensa-esp32 @ 8.4.0+2021r2-patch3

DallasTemperature @ 3.9.1
OneWire @ 2.3.6

@ogiewon
Copy link

ogiewon commented May 22, 2022

@Jason2866 - Thank you very much! I still need to perform some final testing, but so far my code now compiles and loads on to my ESP32-WROOM DevKit.

@Jason2866
Copy link
Contributor

@Jason2866 Thanks for this fix. I just tried with a DS18B20 and am seeing some strange behavior. If I test with ESP32 core version 2.0.2, your version works. However, if I upgrade to 2.0.3, my sketch compiles, but I cannot upload it to my board. There is a serial communication problem. I am using a DoIt DevKit1. Here is the failure output from the Arduino IDE with Show verbose output during compilation turned on:

Sketch uses 705725 bytes (53%) of program storage space. Maximum is 1310720 bytes.
Global variables use 42228 bytes (12%) of dynamic memory, leaving 285452 bytes for local variables. Maximum is 327680 bytes.
esptool.py v3.3-dev
Serial port /dev/ttyUSB0
Connecting......................................

A fatal error occurred: Failed to connect to ESP32: Wrong boot mode detected (0x13)! The chip needs to be in download mode.
For troubleshooting steps visit: https://docs.espressif.com/projects/esptool/en/latest/troubleshooting.html
the selected serial port For troubleshooting steps visit: https://docs.espressif.com/projects/esptool/en/latest/troubleshooting.html
 does not exist or your board is not connected

I will research about the boot mode, and if I make any progress will report back.

This is issue is not related to the OneWire problem. You have a other problem here.

@Jason2866
Copy link
Contributor

PR #114

@PaulStoffregen
Copy link
Owner

I've merged #114. For everyone following this issue and still using ESP32, please download the latest OneWire and reply here to confirm (or deny) this fully solves the problem.

I am waiting for your feedback before publishing a new OneWire version which will make this fix available to everyone using the Arduino Library Manager. Please take a moment to test this latest code and let me know if it should be published as a release to the wider Arduino community?

@MrYsLab
Copy link

MrYsLab commented May 23, 2022

It works for me connecting to a DS18B20. Thanks.

@ogiewon
Copy link

ogiewon commented May 26, 2022

I just tested the latest version on an ESP8266 with 4 DS18B20 sensors attached to a single pin and it still works fine. (I know this change is for the ESP32, but always good to make sure other platforms are not impacted as well.)

@roboticboyer
Copy link

I've merged #114. For everyone following this issue and still using ESP32, please download the latest OneWire and reply here to confirm (or deny) this fully solves the problem.

I am waiting for your feedback before publishing a new OneWire version which will make this fix available to everyone using the Arduino Library Manager. Please take a moment to test this latest code and let me know if it should be published as a release to the wider Arduino community?

It's working on ESP32!

@MrYsLab
Copy link

MrYsLab commented Jun 2, 2022

Is there an ETA on when a new release containing this PR might be? I want to publish my repository that depends on the fix or if I need to add some documentation to describe a workaround. Tnx.

@PaulStoffregen
Copy link
Owner

2.3.7 released

@MrYsLab
Copy link

MrYsLab commented Jun 4, 2022

@PaulStoffregen @Jason2866 Thank you.

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