Skip to content

Commit 8053f28

Browse files
d-a-vigrr
authored andcommitted
provide full version descriptor, displayed in debug mode (#4467)
* provide full version descriptor, displayed in debug mode * unix: shows core version like under windows when git is unavailable * store strings in progmem * version string honours NDEBUG * add ARDUINO_ESP8266_GIT_DESC 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 * lwip2: fix disconnection/reconnection issue also: improve version string remove useless message * lwip2: bump tag before 2.4.1 * lwip2: improve netif flags management on git side * full-version string: remove useless NDEBUG in separate source file * do not automatically enable sdk messages along with core messages * automatically reenable sdk messages along with core messages *before* setup not after * check serial port when showing version-string + move sdk messages enabler in hardware serial * + license header * updated and tested windows commands in platform.txt (without git) * updated and tested windows commands in platform.txt (without git) * update package builder accordingly
1 parent 5b87c7b commit 8053f28

7 files changed

+73
-9
lines changed

cores/esp8266/Esp-version.cpp

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/*
2+
Esp.cpp - ESP8266-specific APIs
3+
Copyright (c) 2015 Ivan Grokhotkov. All rights reserved.
4+
This file is part of the esp8266 core for Arduino environment.
5+
6+
This library is free software; you can redistribute it and/or
7+
modify it under the terms of the GNU Lesser General Public
8+
License as published by the Free Software Foundation; either
9+
version 2.1 of the License, or (at your option) any later version.
10+
11+
This library is distributed in the hope that it will be useful,
12+
but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14+
Lesser General Public License for more details.
15+
16+
You should have received a copy of the GNU Lesser General Public
17+
License along with this library; if not, write to the Free Software
18+
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19+
*/
20+
21+
#include <Arduino.h>
22+
#include <user_interface.h>
23+
#include <core_version.h>
24+
#include <lwip/init.h> // LWIP_VERSION_*
25+
#include <lwipopts.h> // LWIP_HASH_STR (lwip2)
26+
27+
#define STRHELPER(x) #x
28+
#define STR(x) STRHELPER(x) // stringifier
29+
30+
static const char arduino_esp8266_git_ver [] PROGMEM = STR(ARDUINO_ESP8266_GIT_DESC);
31+
#if LWIP_VERSION_MAJOR != 1
32+
static const char lwip2_version [] PROGMEM = "/lwIP:" STR(LWIP_VERSION_MAJOR) "." STR(LWIP_VERSION_MINOR) "." STR(LWIP_VERSION_REVISION);
33+
#endif
34+
35+
String EspClass::getFullVersion()
36+
{
37+
return String(F("SDK:")) + system_get_sdk_version()
38+
+ F("/Core:") + FPSTR(arduino_esp8266_git_ver)
39+
#if LWIP_VERSION_MAJOR == 1
40+
+ F("/lwIP:") + String(LWIP_VERSION_MAJOR) + "." + String(LWIP_VERSION_MINOR) + "." + String(LWIP_VERSION_REVISION)
41+
#else
42+
+ FPSTR(lwip2_version)
43+
#endif
44+
#if LWIP_VERSION_IS_DEVELOPMENT
45+
+ F("-dev")
46+
#endif
47+
#if LWIP_VERSION_IS_RC
48+
+ F("rc") + String(LWIP_VERSION_RC)
49+
#endif
50+
#ifdef LWIP_HASH_STR
51+
+ "(" + F(LWIP_HASH_STR) + ")"
52+
#endif
53+
;
54+
}

cores/esp8266/Esp.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ class EspClass {
108108

109109
const char * getSdkVersion();
110110
String getCoreVersion();
111+
String getFullVersion();
111112

112113
uint8_t getBootVersion();
113114
uint8_t getBootMode();

cores/esp8266/HardwareSerial.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
#include <inttypes.h>
3030
#include "Arduino.h"
3131
#include "HardwareSerial.h"
32-
32+
#include "Esp.h"
3333

3434
HardwareSerial::HardwareSerial(int uart_nr)
3535
: _uart_nr(uart_nr), _rx_size(256)
@@ -39,6 +39,14 @@ void HardwareSerial::begin(unsigned long baud, SerialConfig config, SerialMode m
3939
{
4040
end();
4141
_uart = uart_init(_uart_nr, baud, (int) config, (int) mode, tx_pin, _rx_size);
42+
#if defined(DEBUG_ESP_PORT) && !defined(NDEBUG)
43+
if (this == &DEBUG_ESP_PORT)
44+
{
45+
setDebugOutput(true);
46+
println();
47+
println(ESP.getFullVersion());
48+
}
49+
#endif
4250
}
4351

4452
void HardwareSerial::end()

cores/esp8266/core_esp8266_main.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,6 @@ static void loop_wrapper() {
115115
preloop_update_frequency();
116116
if(!setup_done) {
117117
setup();
118-
#ifdef DEBUG_ESP_PORT
119-
DEBUG_ESP_PORT.setDebugOutput(true);
120-
#endif
121118
setup_done = true;
122119
}
123120
loop();
@@ -150,7 +147,6 @@ void init_done() {
150147
system_set_os_print(1);
151148
gdb_init();
152149
do_global_ctors();
153-
printf("\n%08x\n", core_version);
154150
esp_schedule();
155151
}
156152

cores/esp8266/core_version.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#define ARDUINO_ESP8266_GIT_VER 0x00000000
2+
#define ARDUINO_ESP8266_GIT_DESC unspecified
23

34
// ARDUINO_ESP8266_RELEASE is defined for released versions as a string containing the version name, i.e. "2_3_0_RC1"
45
// ARDUINO_ESP8266_RELEASE is used in the core internally. Please use ESP.getCoreVersion() function instead.

package/build_boards_manager_package.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,13 +81,15 @@ $SED 's/runtime.tools.xtensa-lx106-elf-gcc.path={runtime.platform.path}\/tools\/
8181
$SED 's/runtime.tools.esptool.path={runtime.platform.path}\/tools\/esptool//g' | \
8282
$SED 's/tools.esptool.path={runtime.platform.path}\/tools\/esptool/tools.esptool.path=\{runtime.tools.esptool.path\}/g' | \
8383
$SED 's/tools.mkspiffs.path={runtime.platform.path}\/tools\/mkspiffs/tools.mkspiffs.path=\{runtime.tools.mkspiffs.path\}/g' |\
84-
$SED 's/recipe.hooks.core.prebuild.1.pattern.*//g' \
84+
$SED 's/recipe.hooks.core.prebuild.1.pattern.*//g' |\
85+
$SED 's/recipe.hooks.core.prebuild.2.pattern.*//g' \
8586
> $outdir/platform.txt
8687

8788
# Put core version and short hash of git version into core_version.h
8889
ver_define=`echo $plain_ver | tr "[:lower:].\055" "[:upper:]_"`
8990
echo Ver define: $ver_define
9091
echo \#define ARDUINO_ESP8266_GIT_VER 0x`git rev-parse --short=8 HEAD 2>/dev/null` >$outdir/cores/esp8266/core_version.h
92+
echo \#define ARDUINO_ESP8266_GIT_DESC `git describe --tags 2>/dev/null` >>$outdir/cores/esp8266/core_version.h
9193
echo \#define ARDUINO_ESP8266_RELEASE_$ver_define >>$outdir/cores/esp8266/core_version.h
9294
echo \#define ARDUINO_ESP8266_RELEASE \"$ver_define\" >>$outdir/cores/esp8266/core_version.h
9395

platform.txt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
# https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5---3rd-party-Hardware-specification
77

88
name=ESP8266 Modules
9-
version=2.5.0
9+
version=2.4.1-pre
1010

1111
runtime.tools.xtensa-lx106-elf-gcc.path={runtime.platform.path}/tools/xtensa-lx106-elf
1212
runtime.tools.esptool.path={runtime.platform.path}/tools/esptool
@@ -71,8 +71,10 @@ compiler.elf2hex.extra_flags=
7171
## generate file with git version number
7272
## needs bash, git, and echo
7373
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"
74-
## windows-compatible version may be added later
75-
recipe.hooks.core.prebuild.1.pattern.windows=
74+
recipe.hooks.core.prebuild.2.pattern=bash -c "mkdir -p {build.path}/core && echo \#define ARDUINO_ESP8266_GIT_DESC `cd {runtime.platform.path}; git describe --tags 2>/dev/null || echo unix-{version}` >>{build.path}/core/core_version.h"
75+
## windows-compatible version without git
76+
recipe.hooks.core.prebuild.1.pattern.windows=cmd.exe /c mkdir {build.path}\core & (echo #define ARDUINO_ESP8266_GIT_VER 0x00000000 & echo #define ARDUINO_ESP8266_GIT_DESC win-{version} ) > {build.path}\core\core_version.h
77+
recipe.hooks.core.prebuild.2.pattern.windows=
7678

7779
## Compile c files
7880
recipe.c.o.pattern="{compiler.path}{compiler.c.cmd}" {compiler.cpreprocessor.flags} {compiler.c.flags} -DF_CPU={build.f_cpu} {build.lwip_flags} {build.debug_port} {build.debug_level} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} -DARDUINO_BOARD="{build.board}" {build.led} {compiler.c.extra_flags} {build.extra_flags} {includes} "{source_file}" -o "{object_file}"

0 commit comments

Comments
 (0)