Skip to content

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

Merged
merged 16 commits into from
Mar 8, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions cores/esp8266/Esp-version.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/*
Esp.cpp - ESP8266-specific APIs
Copyright (c) 2015 Ivan Grokhotkov. All rights reserved.
This file is part of the esp8266 core for Arduino environment.

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

License header missing here

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added

#include <Arduino.h>
#include <user_interface.h>
#include <core_version.h>
#include <lwip/init.h> // LWIP_VERSION_*
#include <lwipopts.h> // LWIP_HASH_STR (lwip2)

#define STRHELPER(x) #x
#define STR(x) STRHELPER(x) // stringifier

static const char arduino_esp8266_git_ver [] PROGMEM = STR(ARDUINO_ESP8266_GIT_DESC);
#if LWIP_VERSION_MAJOR != 1
static const char lwip2_version [] PROGMEM = "/lwIP:" STR(LWIP_VERSION_MAJOR) "." STR(LWIP_VERSION_MINOR) "." STR(LWIP_VERSION_REVISION);
#endif

String EspClass::getFullVersion()
{
return String(F("SDK:")) + system_get_sdk_version()
+ F("/Core:") + FPSTR(arduino_esp8266_git_ver)
#if LWIP_VERSION_MAJOR == 1
+ F("/lwIP:") + String(LWIP_VERSION_MAJOR) + "." + String(LWIP_VERSION_MINOR) + "." + String(LWIP_VERSION_REVISION)
#else
+ FPSTR(lwip2_version)
#endif
#if LWIP_VERSION_IS_DEVELOPMENT
+ F("-dev")
#endif
#if LWIP_VERSION_IS_RC
+ F("rc") + String(LWIP_VERSION_RC)
#endif
#ifdef LWIP_HASH_STR
+ "(" + F(LWIP_HASH_STR) + ")"
#endif
;
}
1 change: 1 addition & 0 deletions cores/esp8266/Esp.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ class EspClass {

const char * getSdkVersion();
String getCoreVersion();
String getFullVersion();

uint8_t getBootVersion();
uint8_t getBootMode();
Expand Down
10 changes: 9 additions & 1 deletion cores/esp8266/HardwareSerial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
#include <inttypes.h>
#include "Arduino.h"
#include "HardwareSerial.h"

#include "Esp.h"

HardwareSerial::HardwareSerial(int uart_nr)
: _uart_nr(uart_nr), _rx_size(256)
Expand All @@ -39,6 +39,14 @@ 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)
if (this == &DEBUG_ESP_PORT)
{
setDebugOutput(true);
println();
println(ESP.getFullVersion());
}
#endif
}

void HardwareSerial::end()
Expand Down
4 changes: 0 additions & 4 deletions cores/esp8266/core_esp8266_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,6 @@ static void loop_wrapper() {
preloop_update_frequency();
if(!setup_done) {
setup();
#ifdef DEBUG_ESP_PORT
DEBUG_ESP_PORT.setDebugOutput(true);
#endif
setup_done = true;
}
loop();
Expand Down Expand Up @@ -150,7 +147,6 @@ void init_done() {
system_set_os_print(1);
gdb_init();
do_global_ctors();
printf("\n%08x\n", core_version);
esp_schedule();
}

Expand Down
1 change: 1 addition & 0 deletions cores/esp8266/core_version.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#define ARDUINO_ESP8266_GIT_VER 0x00000000
#define ARDUINO_ESP8266_GIT_DESC unspecified

// ARDUINO_ESP8266_RELEASE is defined for released versions as a string containing the version name, i.e. "2_3_0_RC1"
// ARDUINO_ESP8266_RELEASE is used in the core internally. Please use ESP.getCoreVersion() function instead.
Expand Down
4 changes: 3 additions & 1 deletion package/build_boards_manager_package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,15 @@ $SED 's/runtime.tools.xtensa-lx106-elf-gcc.path={runtime.platform.path}\/tools\/
$SED 's/runtime.tools.esptool.path={runtime.platform.path}\/tools\/esptool//g' | \
$SED 's/tools.esptool.path={runtime.platform.path}\/tools\/esptool/tools.esptool.path=\{runtime.tools.esptool.path\}/g' | \
$SED 's/tools.mkspiffs.path={runtime.platform.path}\/tools\/mkspiffs/tools.mkspiffs.path=\{runtime.tools.mkspiffs.path\}/g' |\
$SED 's/recipe.hooks.core.prebuild.1.pattern.*//g' \
$SED 's/recipe.hooks.core.prebuild.1.pattern.*//g' |\
$SED 's/recipe.hooks.core.prebuild.2.pattern.*//g' \
> $outdir/platform.txt

# Put core version and short hash of git version into core_version.h
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
Copy link
Member

@igrr igrr Mar 7, 2018

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.

Copy link
Collaborator Author

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.

echo \#define ARDUINO_ESP8266_RELEASE_$ver_define >>$outdir/cores/esp8266/core_version.h
echo \#define ARDUINO_ESP8266_RELEASE \"$ver_define\" >>$outdir/cores/esp8266/core_version.h

Expand Down
8 changes: 5 additions & 3 deletions platform.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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.1-pre

runtime.tools.xtensa-lx106-elf-gcc.path={runtime.platform.path}/tools/xtensa-lx106-elf
runtime.tools.esptool.path={runtime.platform.path}/tools/esptool
Expand Down Expand Up @@ -71,8 +71,10 @@ compiler.elf2hex.extra_flags=
## generate file with git version number
## needs bash, git, and echo
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.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"
## windows-compatible version without git
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
recipe.hooks.core.prebuild.2.pattern.windows=

## Compile c files
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}"
Expand Down
Binary file modified tools/sdk/lib/liblwip2.a
Binary file not shown.
Binary file modified tools/sdk/lib/liblwip2_1460.a
Binary file not shown.
14 changes: 9 additions & 5 deletions tools/sdk/lwip2/include/gluedebug.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#define ULWIPDEBUG 0 // 0 or 1 (trigger lwip debug)
#define ULWIPASSERT 0 // 0 or 1 (trigger lwip self-check, 0 saves flash)

#define STRING_IN_FLASH 0 // *print("fmt is stored in flash")
#define STRING_IN_FLASH 1 // *print("fmt is stored in flash")

#define ROTBUFLEN_BIT 11 // (UDEBUGSTORE=1) doprint()'s buffer: 11=2048B

Expand Down Expand Up @@ -82,10 +82,7 @@ int doprint_minus (const char* format, ...) __attribute__ ((format (printf, 1, 2
#define uprint(x...) do { (void)0; } while (0)
#endif

#if UNDEBUG
#define uassert(assertion...) do { (void)0; } while (0)
#else // !defined(UNDEBUG)
#define uassert(assertion...) \
#define udoassert(assertion...) \
do { if ((assertion) == 0) { \
static const char assrt[] ICACHE_RODATA_ATTR STORE_ATTR = #assertion " wrong@"; \
os_printf_plus(assrt); \
Expand All @@ -95,8 +92,15 @@ do { if ((assertion) == 0) { \
os_printf_plus(assrt_line, __LINE__); \
uhalt(); \
} } while (0)

#if UNDEBUG
#define uassert(assertion...) do { (void)0; } while (0)
#else // !defined(UNDEBUG)
#define uassert(assertion...) udoassert(assertion)
#endif // !defined(UNDEBUG)

#define ualwaysassert(assertion...) udoassert(assertion)

#define uerror(x...) do { doprint(x); } while (0)
#define uhalt() do { *((int*)0) = 0; /* this triggers gdb */ } while (0)
#define nl() do { uprint("\n"); } while (0)
Expand Down
3 changes: 1 addition & 2 deletions tools/sdk/lwip2/include/lwip-git-hash.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// generated by makefiles/make-lwip2-hash
#ifndef LWIP_HASH_H
#define LWIP_HASH_H
#define LWIP_HASH 0x92f23d6
#define LWIP_HASH_STR "92f23d6(tag:STABLE-2_0_3_RELEASE)"
#define LWIP_HASH_STR "STABLE-2_0_3_RELEASE/glue:arduino-2.4.1"
#endif // LWIP_HASH_H