mirror of
https://github.com/esp8266/Arduino.git
synced 2025-04-19 23:22:16 +03:00
Store git version of the core in the compiled binary (#2099)
* Store git version of the core in the compiled binary * Don't update version number when using boards manager package
This commit is contained in:
parent
dbef28d394
commit
32bd42b028
@ -9,6 +9,7 @@
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <string.h>
|
||||
#include "flash.h"
|
||||
#include "eboot_command.h"
|
||||
|
||||
@ -17,6 +18,20 @@
|
||||
extern void ets_wdt_enable(void);
|
||||
extern void ets_wdt_disable(void);
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
int load_app_from_flash_raw(const uint32_t flash_addr)
|
||||
{
|
||||
image_header_t image_header;
|
||||
@ -114,6 +129,8 @@ void main()
|
||||
{
|
||||
int res = 9;
|
||||
struct eboot_command cmd;
|
||||
|
||||
print_version(0);
|
||||
|
||||
if (eboot_command_read(&cmd) == 0) {
|
||||
// valid command was passed via RTC_MEM
|
||||
|
Binary file not shown.
@ -158,6 +158,19 @@ uint32_t EspClass::getChipId(void)
|
||||
return system_get_chip_id();
|
||||
}
|
||||
|
||||
extern "C" uint32_t core_version;
|
||||
extern "C" const char* core_release;
|
||||
|
||||
String EspClass::getCoreVersion()
|
||||
{
|
||||
if (core_release != NULL) {
|
||||
return String(core_release);
|
||||
}
|
||||
char buf[12];
|
||||
snprintf(buf, sizeof(buf), "%08x", core_version);
|
||||
return String(buf);
|
||||
}
|
||||
|
||||
const char * EspClass::getSdkVersion(void)
|
||||
{
|
||||
return system_get_sdk_version();
|
||||
|
@ -106,6 +106,7 @@ class EspClass {
|
||||
uint32_t getChipId();
|
||||
|
||||
const char * getSdkVersion();
|
||||
String getCoreVersion();
|
||||
|
||||
uint8_t getBootVersion();
|
||||
uint8_t getBootMode();
|
||||
|
@ -31,6 +31,8 @@ extern "C" {
|
||||
#include "user_interface.h"
|
||||
#include "cont.h"
|
||||
}
|
||||
#include <core_version.h>
|
||||
|
||||
#define LOOP_TASK_PRIORITY 1
|
||||
#define LOOP_QUEUE_SIZE 1
|
||||
|
||||
@ -38,6 +40,16 @@ extern "C" {
|
||||
|
||||
struct rst_info resetInfo;
|
||||
|
||||
extern "C" {
|
||||
extern const uint32_t __attribute__((section(".ver_number"))) core_version = ARDUINO_ESP8266_GIT_VER;
|
||||
const char* core_release =
|
||||
#ifdef ARDUINO_ESP8266_RELEASE
|
||||
ARDUINO_ESP8266_RELEASE;
|
||||
#else
|
||||
NULL;
|
||||
#endif
|
||||
} // extern "C"
|
||||
|
||||
int atexit(void (*func)()) {
|
||||
return 0;
|
||||
}
|
||||
@ -134,6 +146,7 @@ void init_done() {
|
||||
system_set_os_print(1);
|
||||
gdb_init();
|
||||
do_global_ctors();
|
||||
printf("\n%08x\n", core_version);
|
||||
esp_schedule();
|
||||
}
|
||||
|
||||
|
6
cores/esp8266/core_version.h
Normal file
6
cores/esp8266/core_version.h
Normal file
@ -0,0 +1,6 @@
|
||||
#define ARDUINO_ESP8266_GIT_VER 0x00000000
|
||||
|
||||
// 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.
|
||||
|
||||
// ARDUINO_ESP8266_RELEASE_<version number> are defined for releases, for use in #ifdef... constructs
|
@ -46,8 +46,8 @@ rm exclude.txt
|
||||
|
||||
# Get additional libraries (TODO: add them as git submodule or subtree?)
|
||||
|
||||
# SoftwareSerial version 2.2
|
||||
wget -q -O SoftwareSerial.zip https://github.com/plerup/espsoftwareserial/archive/097712eb07f5b3a70ef419b6e7a7ed2ada5aab85.zip
|
||||
# SoftwareSerial library
|
||||
wget -q -O SoftwareSerial.zip https://github.com/plerup/espsoftwareserial/archive/3.1.0.zip
|
||||
unzip -q SoftwareSerial.zip
|
||||
rm -rf SoftwareSerial.zip
|
||||
mv espsoftwareserial-* SoftwareSerial
|
||||
@ -66,9 +66,17 @@ cat $srcdir/platform.txt | \
|
||||
$SED 's/runtime.tools.xtensa-lx106-elf-gcc.path={runtime.platform.path}\/tools\/xtensa-lx106-elf//g' | \
|
||||
$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/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' \
|
||||
> $outdir/platform.txt
|
||||
|
||||
# Put core version and short hash of git version into core_version.h
|
||||
ver_define=`echo $ver | tr "[:lower:].-" "[: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_RELEASE_$ver_define >>$outdir/cores/esp8266/core_version.h
|
||||
echo \#define ARDUINO_ESP8266_RELEASE \"$ver_define\" >>$outdir/cores/esp8266/core_version.h
|
||||
|
||||
# Zip the package
|
||||
pushd package/versions/$ver
|
||||
echo "Making $package_name.zip"
|
||||
|
@ -22,7 +22,7 @@ build.lwip_flags=-DLWIP_OPEN_SRC
|
||||
|
||||
compiler.path={runtime.tools.xtensa-lx106-elf-gcc.path}/bin/
|
||||
compiler.sdk.path={runtime.platform.path}/tools/sdk
|
||||
compiler.cpreprocessor.flags=-D__ets__ -DICACHE_FLASH -U__STRICT_ANSI__ "-I{compiler.sdk.path}/include" "-I{compiler.sdk.path}/lwip/include"
|
||||
compiler.cpreprocessor.flags=-D__ets__ -DICACHE_FLASH -U__STRICT_ANSI__ "-I{compiler.sdk.path}/include" "-I{compiler.sdk.path}/lwip/include" "-I{build.path}/core"
|
||||
|
||||
compiler.c.cmd=xtensa-lx106-elf-gcc
|
||||
compiler.c.flags=-c {compiler.warning_flags} -Os -g -Wpointer-arith -Wno-implicit-function-declaration -Wl,-EL -fno-inline-functions -nostdlib -mlongcalls -mtext-section-literals -falign-functions=4 -MMD -std=gnu99 -ffunction-sections -fdata-sections
|
||||
@ -63,6 +63,12 @@ compiler.ar.extra_flags=
|
||||
compiler.objcopy.eep.extra_flags=
|
||||
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=
|
||||
|
||||
## 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}" {compiler.c.extra_flags} {build.extra_flags} {includes} "{source_file}" -o "{object_file}"
|
||||
|
||||
|
@ -152,6 +152,7 @@ SECTIONS
|
||||
.irom0.text : ALIGN(4)
|
||||
{
|
||||
_irom0_text_start = ABSOLUTE(.);
|
||||
*(.ver_number)
|
||||
*.c.o( EXCLUDE_FILE (umm_malloc.c.o) .literal*, \
|
||||
EXCLUDE_FILE (umm_malloc.c.o) .text*)
|
||||
*.cpp.o(.literal*, .text*)
|
||||
|
Loading…
x
Reference in New Issue
Block a user