mirror of
https://github.com/espressif/ESP8266_RTOS_SDK.git
synced 2025-06-15 02:43:00 +08:00
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:
components/esp8266
@ -34,6 +34,7 @@ COMPONENT_ADD_LDFLAGS += -L$(COMPONENT_PATH)/lib \
|
|||||||
-T $(COMPONENT_BUILD_DIR)/esp8266.project.ld \
|
-T $(COMPONENT_BUILD_DIR)/esp8266.project.ld \
|
||||||
-Wl,--no-check-sections \
|
-Wl,--no-check-sections \
|
||||||
-u call_user_start \
|
-u call_user_start \
|
||||||
|
-u g_esp_sys_info \
|
||||||
$(addprefix -T ,$(LINKER_SCRIPTS))
|
$(addprefix -T ,$(LINKER_SCRIPTS))
|
||||||
|
|
||||||
ALL_LIB_FILES := $(patsubst %,$(COMPONENT_PATH)/lib/lib%.a,$(LIBS))
|
ALL_LIB_FILES := $(patsubst %,$(COMPONENT_PATH)/lib/lib%.a,$(LIBS))
|
||||||
|
58
components/esp8266/include/esp_idf_version.h
Normal file
58
components/esp8266/include/esp_idf_version.h
Normal 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
|
@ -21,6 +21,8 @@
|
|||||||
|
|
||||||
#include "sdkconfig.h"
|
#include "sdkconfig.h"
|
||||||
|
|
||||||
|
#include "esp_idf_version.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
@ -181,13 +183,6 @@ uint32_t esp_get_minimum_free_heap_size( void );
|
|||||||
*/
|
*/
|
||||||
uint32_t esp_random(void);
|
uint32_t esp_random(void);
|
||||||
|
|
||||||
/**
|
|
||||||
* Get IDF version
|
|
||||||
*
|
|
||||||
* @return constant string from IDF_VER
|
|
||||||
*/
|
|
||||||
const char* esp_get_idf_version(void);
|
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
FLASH_SIZE_4M_MAP_256_256 = 0, /**< Flash size : 4Mbits. Map : 256KBytes + 256KBytes */
|
FLASH_SIZE_4M_MAP_256_256 = 0, /**< Flash size : 4Mbits. Map : 256KBytes + 256KBytes */
|
||||||
FLASH_SIZE_2M, /**< Flash size : 2Mbits. Map : 256KBytes */
|
FLASH_SIZE_2M, /**< Flash size : 2Mbits. Map : 256KBytes */
|
||||||
|
@ -52,6 +52,16 @@ struct _rtc_sys_info {
|
|||||||
if your bootloader is older than v3.2, please don't use this */
|
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;
|
extern struct _rtc_sys_info rtc_sys_info;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -48,7 +48,7 @@ SECTIONS
|
|||||||
_iram_start = ABSOLUTE(.);
|
_iram_start = ABSOLUTE(.);
|
||||||
/* Vectors go to IRAM */
|
/* Vectors go to IRAM */
|
||||||
_init_start = ABSOLUTE(.);
|
_init_start = ABSOLUTE(.);
|
||||||
LONG(_iram_start)
|
KEEP(*(.SystemInfoVector.text));
|
||||||
. = 0x10;
|
. = 0x10;
|
||||||
KEEP(*(.DebugExceptionVector.text));
|
KEEP(*(.DebugExceptionVector.text));
|
||||||
. = 0x20;
|
. = 0x20;
|
||||||
|
@ -33,6 +33,11 @@ static const char* TAG = "system_api";
|
|||||||
|
|
||||||
static uint8_t base_mac_addr[6] = { 0 };
|
static uint8_t base_mac_addr[6] = { 0 };
|
||||||
|
|
||||||
|
// Bootloader can get this information
|
||||||
|
const __attribute__((section(".SystemInfoVector.text"))) esp_sys_info_t g_esp_sys_info = {
|
||||||
|
.version = ESP_IDF_VERSION
|
||||||
|
};
|
||||||
|
|
||||||
esp_err_t esp_base_mac_addr_set(uint8_t *mac)
|
esp_err_t esp_base_mac_addr_set(uint8_t *mac)
|
||||||
{
|
{
|
||||||
if (mac == NULL) {
|
if (mac == NULL) {
|
||||||
|
Reference in New Issue
Block a user