-
Notifications
You must be signed in to change notification settings - Fork 13.3k
provide full version descriptor, displayed in debug mode #4467
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
Conversation
cores/esp8266/Esp.cpp
Outdated
|
||
String EspClass::getFullVersion() | ||
{ | ||
return String(F("Boot:")) + system_get_boot_version() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
system_get_boot_version
will not return any meaningful value, because we are using eboot instead of the SDK bootloader.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, will be removed
cores/esp8266/HardwareSerial.cpp
Outdated
@@ -39,6 +39,9 @@ void HardwareSerial::begin(unsigned long baud, SerialConfig config, SerialMode m | |||
{ | |||
end(); | |||
_uart = uart_init(_uart_nr, baud, (int) config, (int) mode, tx_pin, _rx_size); | |||
#if defined(DEBUG_ESP_PORT) && !defined(NDEBUG) | |||
println(ESP.getFullVersion()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Usually after reset you get some garbage, so a newline might be necessary before the version string.
cores/esp8266/core_esp8266_main.cpp
Outdated
@@ -41,6 +41,7 @@ extern "C" { | |||
|
|||
struct rst_info resetInfo; | |||
|
|||
#if 0 | |||
extern "C" { | |||
extern const uint32_t __attribute__((section(".ver_number"))) core_version = ARDUINO_ESP8266_GIT_VER; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you remove this, then eboot will no longer be able to print the core version:
Arduino/bootloaders/eboot/eboot.c
Lines 21 to 33 in 7999f5c
int print_version(const uint32_t flash_addr) | |
{ | |
uint32_t ver; | |
if (SPIRead(flash_addr + APP_START_OFFSET + sizeof(image_header_t) + sizeof(section_header_t), &ver, sizeof(ver))) { | |
return 1; | |
} | |
const char* __attribute__ ((aligned (4))) fmtt = "v%08x\n\0\0"; | |
uint32_t fmt[2]; | |
fmt[0] = ((uint32_t*) fmtt)[0]; | |
fmt[1] = ((uint32_t*) fmtt)[1]; | |
ets_printf((const char*) fmt, ver); | |
return 0; | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(which i personally use to check that I'm running correct version; but if you think it should be removed i can find some other way)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I personally don't mind, I could not find where it was used in the core.
cores/esp8266/HardwareSerial.cpp
Outdated
@@ -94,6 +97,9 @@ void HardwareSerial::setDebugOutput(bool en) | |||
if(en) { | |||
if(uart_tx_enabled(_uart)) { | |||
uart_set_debug(_uart_nr); | |||
#if !defined(DEBUG_ESP_PORT) && !defined(NDEBUG) | |||
os_printf("%s\r\n", ESP.getFullVersion().c_str()); | |||
#endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm fine with printing the version in Serial::begin if debug output is enabled... however if i'm calling setDebugOutput i probably know what i'm doing and can handle calling ESP.getFullVersion if needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removing this one will also allow the linker to get rid of the code if sources are moved to a separate file.
cores/esp8266/core_esp8266_main.cpp
Outdated
@@ -150,7 +152,7 @@ void init_done() { | |||
system_set_os_print(1); | |||
gdb_init(); | |||
do_global_ctors(); | |||
printf("\n%08x\n", core_version); | |||
//printf("\n%08x\n", core_version); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This printf seems to be some debugging leftover — it is not used and can be removed.
platform.txt
Outdated
@@ -6,7 +6,7 @@ | |||
# https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5---3rd-party-Hardware-specification | |||
|
|||
name=ESP8266 Modules | |||
version=2.5.0 | |||
version=2.4.0-post |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to semver, 2.4.0-post is something before 2.4.0.
It might be 2.4.1-pre if we intend to merge this before 2.4.1?
platform.txt
Outdated
recipe.hooks.core.prebuild.1.pattern=bash -c "mkdir -p {build.path}/core && echo \#define ARDUINO_ESP8266_GIT_VER 0x`git --git-dir {runtime.platform.path}/.git rev-parse --short=8 HEAD 2>/dev/null || echo ffffffff` >{build.path}/core/core_version.h" | ||
## windows-compatible version may be added later | ||
recipe.hooks.core.prebuild.1.pattern.windows= | ||
recipe.hooks.core.prebuild.1.pattern=bash -c "mkdir -p {build.path}/core && echo \#define ARDUINO_ESP8266_GIT_VER `cd {runtime.platform.path}; git describe --tags 2>/dev/null || echo nix-{version}` >{build.path}/core/core_version.h" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we keep ARDUINO_ESP8266_GIT_VER
to be a short hash (expressed as an integer), and add a new define for the git describe
output instead? E.g. ARDUINO_ESP8266_GIT_DESC
. I have some release scripts which rely on ARDUINO_ESP8266_GIT_VER being what it is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, not necessarily nix-
version. Also works on macOS, as far as i can tell.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will rename to GIT_DESC, and leave GIT_VER as before. About nix, it's a typo, unix was intended (for linux + macos).
I think the idea with core_version.h was that the generated file would be placed into the build directory, so that the compiler picks it up before the one in the core. If this is broken for some reason, maybe it means that the IDE has started calling arduino-builder in some different way... |
I hope we have a better view of what's happening in issues after next release. |
Some questions on this:
|
@igrr if system_get_boot_version() doesn't return something meaningful, shouldn't we re-implement EspClass::getBootVersion() in terms of the current eboot version? |
If this function is not used, then it takes no flash (~400bytes just to print a ~40bytes string) even if another EspClass:: one is used. It's because we don't have
To be honest, I'm quite bothered when it comes to string manipulations and all those calls to malloc making tiny holes in ram tickle me. That's the reason why I enclosed them in a big function. It's rather useless, but it's all put in a single place. Still you're right, let's keep the modular way and let's expect gcc5 (or is it gcc49?) to come soon!
I put this NDEBUG conditional when the function was in Esp.cc because people using this option want to save more flash. It makes indeed no sense to keep it in the separate file. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM except for these two minor things!
@@ -0,0 +1,46 @@ | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
License header missing here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added
cores/esp8266/HardwareSerial.cpp
Outdated
@@ -39,6 +39,10 @@ void HardwareSerial::begin(unsigned long baud, SerialConfig config, SerialMode m | |||
{ | |||
end(); | |||
_uart = uart_init(_uart_nr, baud, (int) config, (int) mode, tx_pin, _rx_size); | |||
#if defined(DEBUG_ESP_PORT) && !defined(NDEBUG) | |||
println(); | |||
println(ESP.getFullVersion()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unrelated to printing the version, but since you're adding this code block here. Let's call setDebugOutput(true);
or the equivalent uart_
function. At the moment debug output only gets enabled before loop
runs, so you don't get debug output while setup
is running. Then these three lines can be removed:
Arduino/cores/esp8266/core_esp8266_main.cpp
Lines 118 to 120 in 7999f5c
#ifdef DEBUG_ESP_PORT | |
DEBUG_ESP_PORT.setDebugOutput(true); | |
#endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To understand well, setDebugOutput(true) (= sdk debug messages) is then not automatically enabled anymore when Serial debug is enabled, we would not have espressif debug messages anymore, but only this "full version" displayed and selected arduino-core debug messages ?
For anywone willing to get sdk debug messages, then setDebugOutput(true) has to be called.
That sounds nice to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm suggesting that we move the call to setDebugOutput(true);
a bit earlier, if DEBUG_ESP_PORT is set.
Currently it happens only before loop
, so some debug messages during setup may be lost.
If we do this in HardwareSerial::begin, then we will see all debug messages. So the feature merely becomes more consistent.
(We also need if (&DEBUG_ESP_PORT == this) {
check before enabling debug output, in case DEBUG_ESP_PORT is the HardwareSerial which we are initializing).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok to summarize, we should automatically enable sdk messages along with core messages, but before setup not after.
OK about Serial/Serial1 distinction.
@@ -88,6 +88,7 @@ $SED 's/recipe.hooks.core.prebuild.1.pattern.*//g' \ | |||
ver_define=`echo $plain_ver | tr "[:lower:].\055" "[:upper:]_"` | |||
echo Ver define: $ver_define | |||
echo \#define ARDUINO_ESP8266_GIT_VER 0x`git rev-parse --short=8 HEAD 2>/dev/null` >$outdir/cores/esp8266/core_version.h | |||
echo \#define ARDUINO_ESP8266_GIT_DESC `git describe --tags 2>/dev/null` >>$outdir/cores/esp8266/core_version.h |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few lines above (can't comment on the line directly...) there is
$SED 's/recipe.hooks.core.prebuild.1.pattern.*//g' \
Since you have added 2.pattern, please add one more SED line to remove 2.pattern, then run the script and check that the prebuild hooks are removed from platform.txt in the built archive.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. I had to rebase to push the fix.
also: improve version string remove useless message
restore ARDUINO_ESP8266_GIT_VER restore global variable "core_version" don't print full version on setDebugOutput(true) set platform.txt version to 2.4.1-pre hide irrelevant boot version fix typo
…bler in hardware serial
(wip)ESP.getFullVersion()
, or if.Serial.setDebugOutput(true)
is calledgit describe --tags
on linux, orwin-2.4.0-post
win-2.4.1-pre
on windows (set inside platform.txt)caveats:
Travis may not like core_version.h disappearancesome macro format are modifiedglobal variablecore_version
removedBoot:31/SDK:2.2.1(cfd48f3)/Core:2.4.0-94-g7999f5c/lwIP:1.4.0rc2
Boot:31/SDK:2.2.1(cfd48f3)/Core:2.4.0-95-gd1f9c14/lwIP:2.0.3(STABLE-2_0_3_RELEASE/glue:arduino-2.4.0-5-gafb60c2)