ESP32 not the SDK-Version the "package"-Version (Arduino-Release-number)

I have done some googling about if there is a possaility to retrieve the "package-Version" of the Arduino-Core.

With package-Version I mean
the compiler-log has an entry like this

Using core 'esp32' from platform in folder: C:\Arduino-Pure-Portable\arduino-1.8.19\portable\packages\esp32\hardware\esp32\2.0.16

packages\esp32\hardware\esp32\ 2.0.16

So far I have only found a function that retrieves the SDK-Version

ESP.getSdkVersion()

which is a completely different number than this "Arduino-core-Version" / "package"-number

So does anybody know if there exists a function to retrieve the ESP32 Arduino-Release number from inside the code ?

In the meantime I let notepad++ search through all corefiles and I found a header-file named
core_version.h

The content is

#define ARDUINO_ESP32_GIT_VER 0x18f0f05f
#define ARDUINO_ESP32_GIT_DESC 2.0.16
#define ARDUINO_ESP32_RELEASE_2_0_16
#define ARDUINO_ESP32_RELEASE "2_0_16"

this file causes a compile-error if you try to include it
packages\esp32\hardware\esp32\2.0.16\cores\esp32/core_version.h:2:32: error: too many decimal points in number

same file same error in the core_version.h for ESP8266

#define ARDUINO_ESP8266_GIT_VER   0x210897ef
#define ARDUINO_ESP8266_GIT_DESC  3.1.2
#define ARDUINO_ESP8266_VERSION   3.1.2

#define ARDUINO_ESP8266_MAJOR     3
#define ARDUINO_ESP8266_MINOR     1
#define ARDUINO_ESP8266_REVISION  2

#define ARDUINO_ESP8266_RELEASE   "3.1.2"
#define ARDUINO_ESP8266_RELEASE_3_1_2

So I modified the defines with the decimal dots to have double-hyphens
added a line of code

#include <core_version.h>

and now this can be used for serial printing etc.
me personal I have a function that prints all the details about file,name, compiletime etc.

#include <SafeString.h> // see docs at https://www.forward.com.au/pfod/ArduinoProgramming/SafeString/docs/html/index.html

cSF(FileInfo_SS,256); // create a variable of type SafeString 

void PrintFileNameDateTime() {

  FileInfo_SS = "Code running comes from file ";
  FileInfo_SS += __FILE__ ;
  FileInfo_SS += "  compiled " ;
  FileInfo_SS += __DATE__ ;
  FileInfo_SS += " ";
  FileInfo_SS += __TIME__;

  FileInfo_SS += " ARDUINO_ESP8266_GIT_VER:";
  FileInfo_SS += ARDUINO_ESP8266_GIT_VER;

  FileInfo_SS += " ARDUINO_ESP8266_RELEASE:";
  FileInfo_SS += ARDUINO_ESP8266_RELEASE;

  FileInfo_SS += "  ESP.getSdkVersion():";
  FileInfo_SS += ESP.getSdkVersion();

  Serial.println(FileInfo_SS);
}

Don't you think that might cause problems with something in the Arduino build tool set that's depending on the "decimal dots" being there?

How should it cause problems if the file is not even compilable as an include-file?
The only reason I can think of that this could happen would be that the build tool uses a header-file for some completely different purpose than source-code!

Something like the toolchain is reading in this file not for compiling but for using the number with decimal points for a different purpose. And then why for heavens sake Why does it have to have the file extension .h ?

I see this as a misuse of the file-extension *.h

The code compiled with the modification adding double-hyphens.

#define ARDUINO_ESP8266_VERSION   "3.1.2"

If this is causing any failure at runtime it is even worse

Of course it can be compiled, it contains valid #define macros. I should have asked ... is that macro used in any other files as part of a conditional compilation sequence??? You'll find that frequently with the "__cplusplus" macro that defines the version of C++ being compiled. Lot's files contain constructs such as:

#if defined (__cplusplus) && __cplusplus >= 201103L
.
.
.
#endif

So, the code in between will only be compiled you're using C++ 2011 or later.

I don't know if that's the case with your ARDUINO_ESP32_RELEASE macro. But, my point was that if you don't know, you shouldn't mess with it by redefining is.

OK I re-read the compiler-log

C:\Arduino-Pure-Portable\arduino-1.8.19\portable\packages\esp32\hardware\esp32\2.0.16\cores\esp32/
core_version.h:2:32: error: too many decimal points in number

 #define ARDUINO_ESP32_GIT_DESC 2.0.16

                                ^~~~~~

C:\Arduino-Pure-Portable\arduino-1.8.19\portable\sketchbook\ESP32-S3-ESPUI-WebSPro-elOTA-UDP-Msg-Para-006\
ESP32-S3-ESPUI-WebSPro-elOTA-UDP-Msg-Para-006.ino:206:18: note: in expansion of macro 'ARDUINO_ESP32_GIT_DESC'

   FileInfo_SS += ARDUINO_ESP32_GIT_DESC;

So it seems that the SafeString-library or the compiler interprets the character-sequence 2.0.16 as a float and then complains about too many decimal-points.

hm so how can a macro defined as

#define ARDUINO_ESP32_GIT_DESC 2.0.16

be used in this case?

See the file "esp_arduino_version.h" for a better way:

void setup() {
  Serial.begin(115200);
  delay(2000);

  const uint32_t coreVersion = ESP_ARDUINO_VERSION;
  Serial.printf("ESP32 Core Version: %d.%d.%d\n", coreVersion >> 16, (coreVersion > 8) & 0xFF, coreVersion & 0xFF);
}

void loop() {
}

strange they differ..

void setup() {
  Serial.begin(115200);
  Serial.print("ESP32 Arduino Version: ");
  Serial.print(ESP_ARDUINO_VERSION_MAJOR);Serial.print(".");
  Serial.print(ESP_ARDUINO_VERSION_MINOR);Serial.print(".");
  Serial.println(ESP_ARDUINO_VERSION_PATCH);

    const uint32_t coreVersion = ESP_ARDUINO_VERSION;
  Serial.printf("ESP32 Core Version: %d.%d.%d\n", coreVersion >> 16, (coreVersion > 8) & 0xFF, coreVersion & 0xFF);

}

starting with v3 they've added getCoreVersion() and some new defines..

good luck.. ~q

My mistake, missing '>' in my Post #7:

  Serial.printf("ESP32 Core Version: %d.%d.%d\n", coreVersion >> 16, (coreVersion >> 8) & 0xFF, coreVersion & 0xFF);
                                                                                  ^^
1 Like

In order to make all relevant information available to any who are interested in this subject, I'll share a link to the related discussion here:

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.