feat(esp8266): add system version

Bootloader can get the version of application for specific section,
and then check if some features are supported.

Developers can use the macro "ESP_IDF_VERSION" to limite some function like following:

include "esp_idf_version.h"

if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(3, 4, 0) && ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(4, 0, 0) // 3.4 <= ver < 4.0
    do_xxx_process();
endif
This commit is contained in:
dongheng
2019-09-20 14:35:28 +08:00
parent 653d20dddc
commit d0f58daec1
6 changed files with 77 additions and 8 deletions

View File

@ -0,0 +1,58 @@
// Copyright 2019 Espressif Systems (Shanghai) PTE LTD
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#pragma once
#ifdef __cplusplus
extern "C" {
#endif
/** Major version number (X.x.x) */
#define ESP_IDF_VERSION_MAJOR 3
/** Minor version number (x.X.x) */
#define ESP_IDF_VERSION_MINOR 3
/** Patch version number (x.x.X) */
#define ESP_IDF_VERSION_PATCH 0
/**
* Macro to convert IDF version number into an integer
*
* To be used in comparisons, such as ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(4, 0, 0)
*/
#define ESP_IDF_VERSION_VAL(major, minor, patch) ((major << 16) | (minor << 8) | (patch))
/**
* Current IDF version, as an integer
*
* To be used in comparisons, such as ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(4, 0, 0)
*/
#define ESP_IDF_VERSION ESP_IDF_VERSION_VAL(ESP_IDF_VERSION_MAJOR, \
ESP_IDF_VERSION_MINOR, \
ESP_IDF_VERSION_PATCH)
/**
* Return full IDF version string, same as 'git describe' output.
*
* @note If you are printing the ESP-IDF version in a log file or other information,
* this function provides more information than using the numerical version macros.
* For example, numerical version macros don't differentiate between development,
* pre-release and release versions, but the output of this function does.
*
* @return constant string from IDF_VER
*/
const char* esp_get_idf_version(void);
#ifdef __cplusplus
}
#endif

View File

@ -21,6 +21,8 @@
#include "sdkconfig.h"
#include "esp_idf_version.h"
#ifdef __cplusplus
extern "C" {
#endif
@ -181,13 +183,6 @@ uint32_t esp_get_minimum_free_heap_size( void );
*/
uint32_t esp_random(void);
/**
* Get IDF version
*
* @return constant string from IDF_VER
*/
const char* esp_get_idf_version(void);
typedef enum {
FLASH_SIZE_4M_MAP_256_256 = 0, /**< Flash size : 4Mbits. Map : 256KBytes + 256KBytes */
FLASH_SIZE_2M, /**< Flash size : 2Mbits. Map : 256KBytes */

View File

@ -52,6 +52,16 @@ struct _rtc_sys_info {
if your bootloader is older than v3.2, please don't use this */
};
/**
* @brief System information
*/
typedef struct esp_sys_info {
uint32_t version; //!< system version
uint32_t reserved[3]; //!< reserved data
} esp_sys_info_t;
_Static_assert(sizeof(esp_sys_info_t) == 16, "esp_sys_info_t should be 16 bytes");
extern struct _rtc_sys_info rtc_sys_info;
/**