mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-04 13:14:32 +02:00
esp_system: split esp_system.h header
This commit is contained in:
72
components/esp_hw_support/include/esp_chip_info.h
Normal file
72
components/esp_hw_support/include/esp_chip_info.h
Normal file
@@ -0,0 +1,72 @@
|
|||||||
|
// Copyright 2021 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
|
||||||
|
|
||||||
|
#include <stdbool.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include "sdkconfig.h"
|
||||||
|
#include "esp_bit_defs.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Chip models
|
||||||
|
*/
|
||||||
|
typedef enum {
|
||||||
|
CHIP_ESP32 = 1, //!< ESP32
|
||||||
|
CHIP_ESP32S2 = 2, //!< ESP32-S2
|
||||||
|
CHIP_ESP32S3 = 4, //!< ESP32-S3
|
||||||
|
CHIP_ESP32C3 = 5, //!< ESP32-C3
|
||||||
|
} esp_chip_model_t;
|
||||||
|
|
||||||
|
/* Chip feature flags, used in esp_chip_info_t */
|
||||||
|
#define CHIP_FEATURE_EMB_FLASH BIT(0) //!< Chip has embedded flash memory
|
||||||
|
#define CHIP_FEATURE_WIFI_BGN BIT(1) //!< Chip has 2.4GHz WiFi
|
||||||
|
#define CHIP_FEATURE_BLE BIT(4) //!< Chip has Bluetooth LE
|
||||||
|
#define CHIP_FEATURE_BT BIT(5) //!< Chip has Bluetooth Classic
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief The structure represents information about the chip
|
||||||
|
*/
|
||||||
|
typedef struct {
|
||||||
|
esp_chip_model_t model; //!< chip model, one of esp_chip_model_t
|
||||||
|
uint32_t features; //!< bit mask of CHIP_FEATURE_x feature flags
|
||||||
|
uint8_t cores; //!< number of CPU cores
|
||||||
|
uint8_t revision; //!< chip revision number
|
||||||
|
} esp_chip_info_t;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Fill an esp_chip_info_t structure with information about the chip
|
||||||
|
* @param[out] out_info structure to be filled
|
||||||
|
*/
|
||||||
|
void esp_chip_info(esp_chip_info_t* out_info);
|
||||||
|
|
||||||
|
#if CONFIG_ESP32_ECO3_CACHE_LOCK_FIX
|
||||||
|
/**
|
||||||
|
* @brief Cache lock bug exists or not
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* - ture : bug exists
|
||||||
|
* - false : bug not exists
|
||||||
|
*/
|
||||||
|
bool soc_has_cache_lock_bug(void);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
134
components/esp_hw_support/include/esp_mac.h
Normal file
134
components/esp_hw_support/include/esp_mac.h
Normal file
@@ -0,0 +1,134 @@
|
|||||||
|
// Copyright 2021 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
|
||||||
|
|
||||||
|
#include "esp_err.h"
|
||||||
|
#include "sdkconfig.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
ESP_MAC_WIFI_STA,
|
||||||
|
ESP_MAC_WIFI_SOFTAP,
|
||||||
|
ESP_MAC_BT,
|
||||||
|
ESP_MAC_ETH,
|
||||||
|
} esp_mac_type_t;
|
||||||
|
|
||||||
|
/** @cond */
|
||||||
|
#define TWO_UNIVERSAL_MAC_ADDR 2
|
||||||
|
#define FOUR_UNIVERSAL_MAC_ADDR 4
|
||||||
|
#if CONFIG_IDF_TARGET_ESP32
|
||||||
|
#define UNIVERSAL_MAC_ADDR_NUM CONFIG_ESP32_UNIVERSAL_MAC_ADDRESSES
|
||||||
|
#elif CONFIG_IDF_TARGET_ESP32S2
|
||||||
|
#define UNIVERSAL_MAC_ADDR_NUM CONFIG_ESP32S2_UNIVERSAL_MAC_ADDRESSES
|
||||||
|
#elif CONFIG_IDF_TARGET_ESP32S3
|
||||||
|
#define UNIVERSAL_MAC_ADDR_NUM CONFIG_ESP32S3_UNIVERSAL_MAC_ADDRESSES
|
||||||
|
#elif CONFIG_IDF_TARGET_ESP32C3
|
||||||
|
#define UNIVERSAL_MAC_ADDR_NUM CONFIG_ESP32C3_UNIVERSAL_MAC_ADDRESSES
|
||||||
|
#endif
|
||||||
|
/** @endcond */
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Set base MAC address with the MAC address which is stored in BLK3 of EFUSE or
|
||||||
|
* external storage e.g. flash and EEPROM.
|
||||||
|
*
|
||||||
|
* Base MAC address is used to generate the MAC addresses used by the networking interfaces.
|
||||||
|
* If using base MAC address stored in BLK3 of EFUSE or external storage, call this API to set base MAC
|
||||||
|
* address with the MAC address which is stored in BLK3 of EFUSE or external storage before initializing
|
||||||
|
* WiFi/BT/Ethernet.
|
||||||
|
*
|
||||||
|
* @note Base MAC must be a unicast MAC (least significant bit of first byte must be zero).
|
||||||
|
*
|
||||||
|
* @note If not using a valid OUI, set the "locally administered" bit
|
||||||
|
* (bit value 0x02 in the first byte) to avoid collisions.
|
||||||
|
*
|
||||||
|
* @param mac base MAC address, length: 6 bytes.
|
||||||
|
*
|
||||||
|
* @return ESP_OK on success
|
||||||
|
* ESP_ERR_INVALID_ARG If mac is NULL or is not a unicast MAC
|
||||||
|
*/
|
||||||
|
esp_err_t esp_base_mac_addr_set(const uint8_t *mac);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Return base MAC address which is set using esp_base_mac_addr_set.
|
||||||
|
*
|
||||||
|
* @param mac base MAC address, length: 6 bytes.
|
||||||
|
*
|
||||||
|
* @return ESP_OK on success
|
||||||
|
* ESP_ERR_INVALID_MAC base MAC address has not been set
|
||||||
|
*/
|
||||||
|
esp_err_t esp_base_mac_addr_get(uint8_t *mac);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Return base MAC address which was previously written to BLK3 of EFUSE.
|
||||||
|
*
|
||||||
|
* Base MAC address is used to generate the MAC addresses used by the networking interfaces.
|
||||||
|
* This API returns the custom base MAC address which was previously written to BLK3 of EFUSE.
|
||||||
|
* Writing this EFUSE allows setting of a different (non-Espressif) base MAC address. It is also
|
||||||
|
* possible to store a custom base MAC address elsewhere, see esp_base_mac_addr_set() for details.
|
||||||
|
*
|
||||||
|
* @param mac base MAC address, length: 6 bytes.
|
||||||
|
*
|
||||||
|
* @return ESP_OK on success
|
||||||
|
* ESP_ERR_INVALID_VERSION An invalid MAC version field was read from BLK3 of EFUSE
|
||||||
|
* ESP_ERR_INVALID_CRC An invalid MAC CRC was read from BLK3 of EFUSE
|
||||||
|
*/
|
||||||
|
esp_err_t esp_efuse_mac_get_custom(uint8_t *mac);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Return base MAC address which is factory-programmed by Espressif in BLK0 of EFUSE.
|
||||||
|
*
|
||||||
|
* @param mac base MAC address, length: 6 bytes.
|
||||||
|
*
|
||||||
|
* @return ESP_OK on success
|
||||||
|
*/
|
||||||
|
esp_err_t esp_efuse_mac_get_default(uint8_t *mac);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Read base MAC address and set MAC address of the interface.
|
||||||
|
*
|
||||||
|
* This function first get base MAC address using esp_base_mac_addr_get or reads base MAC address
|
||||||
|
* from BLK0 of EFUSE. Then set the MAC address of the interface including wifi station, wifi softap,
|
||||||
|
* bluetooth and ethernet.
|
||||||
|
*
|
||||||
|
* @param mac MAC address of the interface, length: 6 bytes.
|
||||||
|
* @param type type of MAC address, 0:wifi station, 1:wifi softap, 2:bluetooth, 3:ethernet.
|
||||||
|
*
|
||||||
|
* @return ESP_OK on success
|
||||||
|
*/
|
||||||
|
esp_err_t esp_read_mac(uint8_t* mac, esp_mac_type_t type);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Derive local MAC address from universal MAC address.
|
||||||
|
*
|
||||||
|
* This function derives a local MAC address from an universal MAC address.
|
||||||
|
* A `definition of local vs universal MAC address can be found on Wikipedia
|
||||||
|
* <https://en.wikipedia.org/wiki/MAC_address#Universal_vs._local>`.
|
||||||
|
* In ESP32, universal MAC address is generated from base MAC address in EFUSE or other external storage.
|
||||||
|
* Local MAC address is derived from the universal MAC address.
|
||||||
|
*
|
||||||
|
* @param local_mac Derived local MAC address, length: 6 bytes.
|
||||||
|
* @param universal_mac Source universal MAC address, length: 6 bytes.
|
||||||
|
*
|
||||||
|
* @return ESP_OK on success
|
||||||
|
*/
|
||||||
|
esp_err_t esp_derive_local_mac(uint8_t* local_mac, const uint8_t* universal_mac);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
54
components/esp_hw_support/include/esp_random.h
Normal file
54
components/esp_hw_support/include/esp_random.h
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
// Copyright 2021 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
|
||||||
|
|
||||||
|
#include <stddef.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get one random 32-bit word from hardware RNG
|
||||||
|
*
|
||||||
|
* The hardware RNG is fully functional whenever an RF subsystem is running (ie Bluetooth or WiFi is enabled). For
|
||||||
|
* random values, call this function after WiFi or Bluetooth are started.
|
||||||
|
*
|
||||||
|
* If the RF subsystem is not used by the program, the function bootloader_random_enable() can be called to enable an
|
||||||
|
* entropy source. bootloader_random_disable() must be called before RF subsystem or I2S peripheral are used. See these functions'
|
||||||
|
* documentation for more details.
|
||||||
|
*
|
||||||
|
* Any time the app is running without an RF subsystem (or bootloader_random) enabled, RNG hardware should be
|
||||||
|
* considered a PRNG. A very small amount of entropy is available due to pre-seeding while the IDF
|
||||||
|
* bootloader is running, but this should not be relied upon for any use.
|
||||||
|
*
|
||||||
|
* @return Random value between 0 and UINT32_MAX
|
||||||
|
*/
|
||||||
|
uint32_t esp_random(void);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Fill a buffer with random bytes from hardware RNG
|
||||||
|
*
|
||||||
|
* @note This function has the same restrictions regarding available entropy as esp_random()
|
||||||
|
*
|
||||||
|
* @param buf Pointer to buffer to fill with random numbers.
|
||||||
|
* @param len Length of buffer in bytes
|
||||||
|
*/
|
||||||
|
void esp_fill_random(void *buf, size_t len);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
@@ -8,7 +8,8 @@ set(srcs
|
|||||||
"rtc_pm.c"
|
"rtc_pm.c"
|
||||||
"rtc_sleep.c"
|
"rtc_sleep.c"
|
||||||
"rtc_time.c"
|
"rtc_time.c"
|
||||||
"rtc_wdt.c")
|
"rtc_wdt.c"
|
||||||
|
"chip_info.c")
|
||||||
|
|
||||||
add_prefix(srcs "${CMAKE_CURRENT_LIST_DIR}/" "${srcs}")
|
add_prefix(srcs "${CMAKE_CURRENT_LIST_DIR}/" "${srcs}")
|
||||||
target_sources(${COMPONENT_LIB} PRIVATE "${srcs}")
|
target_sources(${COMPONENT_LIB} PRIVATE "${srcs}")
|
||||||
|
52
components/esp_hw_support/port/esp32/chip_info.c
Normal file
52
components/esp_hw_support/port/esp32/chip_info.c
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
// Copyright 2013-2016 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.
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
#include "esp_chip_info.h"
|
||||||
|
#include "soc/soc.h"
|
||||||
|
#include "soc/efuse_reg.h"
|
||||||
|
#include "esp_efuse.h"
|
||||||
|
|
||||||
|
void esp_chip_info(esp_chip_info_t* out_info)
|
||||||
|
{
|
||||||
|
uint32_t efuse_rd3 = REG_READ(EFUSE_BLK0_RDATA3_REG);
|
||||||
|
memset(out_info, 0, sizeof(*out_info));
|
||||||
|
|
||||||
|
out_info->model = CHIP_ESP32;
|
||||||
|
out_info->revision = esp_efuse_get_chip_ver();
|
||||||
|
|
||||||
|
if ((efuse_rd3 & EFUSE_RD_CHIP_VER_DIS_APP_CPU_M) == 0) {
|
||||||
|
out_info->cores = 2;
|
||||||
|
} else {
|
||||||
|
out_info->cores = 1;
|
||||||
|
}
|
||||||
|
out_info->features = CHIP_FEATURE_WIFI_BGN;
|
||||||
|
if ((efuse_rd3 & EFUSE_RD_CHIP_VER_DIS_BT_M) == 0) {
|
||||||
|
out_info->features |= CHIP_FEATURE_BT | CHIP_FEATURE_BLE;
|
||||||
|
}
|
||||||
|
uint32_t package = esp_efuse_get_pkg_ver();
|
||||||
|
if (package == EFUSE_RD_CHIP_VER_PKG_ESP32D2WDQ5 ||
|
||||||
|
package == EFUSE_RD_CHIP_VER_PKG_ESP32PICOD2 ||
|
||||||
|
package == EFUSE_RD_CHIP_VER_PKG_ESP32PICOD4 ||
|
||||||
|
package == EFUSE_RD_CHIP_VER_PKG_ESP32PICOV302) {
|
||||||
|
out_info->features |= CHIP_FEATURE_EMB_FLASH;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#if CONFIG_ESP32_ECO3_CACHE_LOCK_FIX
|
||||||
|
inline bool soc_has_cache_lock_bug(void)
|
||||||
|
{
|
||||||
|
return (esp_efuse_get_chip_ver() == 3);
|
||||||
|
}
|
||||||
|
#endif
|
@@ -4,7 +4,9 @@ set(srcs "cpu_util_esp32c3.c"
|
|||||||
"rtc_init.c"
|
"rtc_init.c"
|
||||||
"rtc_pm.c"
|
"rtc_pm.c"
|
||||||
"rtc_sleep.c"
|
"rtc_sleep.c"
|
||||||
"rtc_time.c")
|
"rtc_time.c"
|
||||||
|
"chip_info.c"
|
||||||
|
)
|
||||||
|
|
||||||
add_prefix(srcs "${CMAKE_CURRENT_LIST_DIR}/" "${srcs}")
|
add_prefix(srcs "${CMAKE_CURRENT_LIST_DIR}/" "${srcs}")
|
||||||
|
|
||||||
|
26
components/esp_hw_support/port/esp32c3/chip_info.c
Normal file
26
components/esp_hw_support/port/esp32c3/chip_info.c
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
// Copyright 2013-2020 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.
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
#include "esp_chip_info.h"
|
||||||
|
#include "esp_efuse.h"
|
||||||
|
|
||||||
|
void esp_chip_info(esp_chip_info_t *out_info)
|
||||||
|
{
|
||||||
|
memset(out_info, 0, sizeof(*out_info));
|
||||||
|
out_info->model = CHIP_ESP32C3;
|
||||||
|
out_info->revision = esp_efuse_get_chip_ver();
|
||||||
|
out_info->cores = 1;
|
||||||
|
out_info->features = CHIP_FEATURE_WIFI_BGN | CHIP_FEATURE_BLE;
|
||||||
|
}
|
@@ -9,7 +9,9 @@ set(srcs
|
|||||||
"rtc_sleep.c"
|
"rtc_sleep.c"
|
||||||
"rtc_time.c"
|
"rtc_time.c"
|
||||||
"rtc_wdt.c"
|
"rtc_wdt.c"
|
||||||
"regi2c_ctrl.c")
|
"regi2c_ctrl.c"
|
||||||
|
"chip_info.c"
|
||||||
|
)
|
||||||
|
|
||||||
add_prefix(srcs "${CMAKE_CURRENT_LIST_DIR}/" "${srcs}")
|
add_prefix(srcs "${CMAKE_CURRENT_LIST_DIR}/" "${srcs}")
|
||||||
target_sources(${COMPONENT_LIB} PRIVATE "${srcs}")
|
target_sources(${COMPONENT_LIB} PRIVATE "${srcs}")
|
||||||
|
40
components/esp_hw_support/port/esp32s2/chip_info.c
Normal file
40
components/esp_hw_support/port/esp32s2/chip_info.c
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
// Copyright 2013-2016 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.
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
#include "esp_chip_info.h"
|
||||||
|
#include "esp_efuse.h"
|
||||||
|
|
||||||
|
void esp_chip_info(esp_chip_info_t *out_info)
|
||||||
|
{
|
||||||
|
uint32_t pkg_ver = esp_efuse_get_pkg_ver();
|
||||||
|
|
||||||
|
memset(out_info, 0, sizeof(*out_info));
|
||||||
|
|
||||||
|
out_info->model = CHIP_ESP32S2;
|
||||||
|
out_info->cores = 1;
|
||||||
|
out_info->features = CHIP_FEATURE_WIFI_BGN;
|
||||||
|
|
||||||
|
switch (pkg_ver) {
|
||||||
|
case 0: // ESP32-S2
|
||||||
|
break;
|
||||||
|
case 1: // ESP32-S2FH16
|
||||||
|
// fallthrough
|
||||||
|
case 2: // ESP32-S2FH32
|
||||||
|
out_info->features |= CHIP_FEATURE_EMB_FLASH;
|
||||||
|
break;
|
||||||
|
default: // New package, features unknown
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
@@ -9,6 +9,7 @@ set(srcs
|
|||||||
"rtc_sleep.c"
|
"rtc_sleep.c"
|
||||||
"rtc_time.c"
|
"rtc_time.c"
|
||||||
"rtc_wdt.c"
|
"rtc_wdt.c"
|
||||||
|
"chip_info.c"
|
||||||
)
|
)
|
||||||
|
|
||||||
add_prefix(srcs "${CMAKE_CURRENT_LIST_DIR}/" "${srcs}")
|
add_prefix(srcs "${CMAKE_CURRENT_LIST_DIR}/" "${srcs}")
|
||||||
|
24
components/esp_hw_support/port/esp32s3/chip_info.c
Normal file
24
components/esp_hw_support/port/esp32s3/chip_info.c
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
// Copyright 2013-2020 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.
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
#include "esp_chip_info.h"
|
||||||
|
|
||||||
|
void esp_chip_info(esp_chip_info_t *out_info)
|
||||||
|
{
|
||||||
|
memset(out_info, 0, sizeof(*out_info));
|
||||||
|
out_info->model = CHIP_ESP32S3;
|
||||||
|
out_info->cores = 2;
|
||||||
|
out_info->features = CHIP_FEATURE_WIFI_BGN;
|
||||||
|
}
|
@@ -24,31 +24,17 @@
|
|||||||
|
|
||||||
#include "sdkconfig.h"
|
#include "sdkconfig.h"
|
||||||
|
|
||||||
|
// For backward compatibility. These headers
|
||||||
|
// contains hardware operation functions and definitions
|
||||||
|
// that were originally declared in this header.
|
||||||
|
#include "esp_mac.h"
|
||||||
|
#include "esp_chip_info.h"
|
||||||
|
#include "esp_random.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef enum {
|
|
||||||
ESP_MAC_WIFI_STA,
|
|
||||||
ESP_MAC_WIFI_SOFTAP,
|
|
||||||
ESP_MAC_BT,
|
|
||||||
ESP_MAC_ETH,
|
|
||||||
} esp_mac_type_t;
|
|
||||||
|
|
||||||
/** @cond */
|
|
||||||
#define TWO_UNIVERSAL_MAC_ADDR 2
|
|
||||||
#define FOUR_UNIVERSAL_MAC_ADDR 4
|
|
||||||
#if CONFIG_IDF_TARGET_ESP32
|
|
||||||
#define UNIVERSAL_MAC_ADDR_NUM CONFIG_ESP32_UNIVERSAL_MAC_ADDRESSES
|
|
||||||
#elif CONFIG_IDF_TARGET_ESP32S2
|
|
||||||
#define UNIVERSAL_MAC_ADDR_NUM CONFIG_ESP32S2_UNIVERSAL_MAC_ADDRESSES
|
|
||||||
#elif CONFIG_IDF_TARGET_ESP32S3
|
|
||||||
#define UNIVERSAL_MAC_ADDR_NUM CONFIG_ESP32S3_UNIVERSAL_MAC_ADDRESSES
|
|
||||||
#elif CONFIG_IDF_TARGET_ESP32C3
|
|
||||||
#define UNIVERSAL_MAC_ADDR_NUM CONFIG_ESP32C3_UNIVERSAL_MAC_ADDRESSES
|
|
||||||
#endif
|
|
||||||
/** @endcond */
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Reset reasons
|
* @brief Reset reasons
|
||||||
*/
|
*/
|
||||||
@@ -138,120 +124,6 @@ uint32_t esp_get_free_internal_heap_size(void);
|
|||||||
*/
|
*/
|
||||||
uint32_t esp_get_minimum_free_heap_size( void );
|
uint32_t esp_get_minimum_free_heap_size( void );
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Get one random 32-bit word from hardware RNG
|
|
||||||
*
|
|
||||||
* The hardware RNG is fully functional whenever an RF subsystem is running (ie Bluetooth or WiFi is enabled). For
|
|
||||||
* random values, call this function after WiFi or Bluetooth are started.
|
|
||||||
*
|
|
||||||
* If the RF subsystem is not used by the program, the function bootloader_random_enable() can be called to enable an
|
|
||||||
* entropy source. bootloader_random_disable() must be called before RF subsystem or I2S peripheral are used. See these functions'
|
|
||||||
* documentation for more details.
|
|
||||||
*
|
|
||||||
* Any time the app is running without an RF subsystem (or bootloader_random) enabled, RNG hardware should be
|
|
||||||
* considered a PRNG. A very small amount of entropy is available due to pre-seeding while the IDF
|
|
||||||
* bootloader is running, but this should not be relied upon for any use.
|
|
||||||
*
|
|
||||||
* @return Random value between 0 and UINT32_MAX
|
|
||||||
*/
|
|
||||||
uint32_t esp_random(void);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Fill a buffer with random bytes from hardware RNG
|
|
||||||
*
|
|
||||||
* @note This function has the same restrictions regarding available entropy as esp_random()
|
|
||||||
*
|
|
||||||
* @param buf Pointer to buffer to fill with random numbers.
|
|
||||||
* @param len Length of buffer in bytes
|
|
||||||
*/
|
|
||||||
void esp_fill_random(void *buf, size_t len);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Set base MAC address with the MAC address which is stored in BLK3 of EFUSE or
|
|
||||||
* external storage e.g. flash and EEPROM.
|
|
||||||
*
|
|
||||||
* Base MAC address is used to generate the MAC addresses used by the networking interfaces.
|
|
||||||
* If using base MAC address stored in BLK3 of EFUSE or external storage, call this API to set base MAC
|
|
||||||
* address with the MAC address which is stored in BLK3 of EFUSE or external storage before initializing
|
|
||||||
* WiFi/BT/Ethernet.
|
|
||||||
*
|
|
||||||
* @note Base MAC must be a unicast MAC (least significant bit of first byte must be zero).
|
|
||||||
*
|
|
||||||
* @note If not using a valid OUI, set the "locally administered" bit
|
|
||||||
* (bit value 0x02 in the first byte) to avoid collisions.
|
|
||||||
*
|
|
||||||
* @param mac base MAC address, length: 6 bytes.
|
|
||||||
*
|
|
||||||
* @return ESP_OK on success
|
|
||||||
* ESP_ERR_INVALID_ARG If mac is NULL or is not a unicast MAC
|
|
||||||
*/
|
|
||||||
esp_err_t esp_base_mac_addr_set(const uint8_t *mac);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Return base MAC address which is set using esp_base_mac_addr_set.
|
|
||||||
*
|
|
||||||
* @param mac base MAC address, length: 6 bytes.
|
|
||||||
*
|
|
||||||
* @return ESP_OK on success
|
|
||||||
* ESP_ERR_INVALID_MAC base MAC address has not been set
|
|
||||||
*/
|
|
||||||
esp_err_t esp_base_mac_addr_get(uint8_t *mac);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Return base MAC address which was previously written to BLK3 of EFUSE.
|
|
||||||
*
|
|
||||||
* Base MAC address is used to generate the MAC addresses used by the networking interfaces.
|
|
||||||
* This API returns the custom base MAC address which was previously written to BLK3 of EFUSE.
|
|
||||||
* Writing this EFUSE allows setting of a different (non-Espressif) base MAC address. It is also
|
|
||||||
* possible to store a custom base MAC address elsewhere, see esp_base_mac_addr_set() for details.
|
|
||||||
*
|
|
||||||
* @param mac base MAC address, length: 6 bytes.
|
|
||||||
*
|
|
||||||
* @return ESP_OK on success
|
|
||||||
* ESP_ERR_INVALID_VERSION An invalid MAC version field was read from BLK3 of EFUSE
|
|
||||||
* ESP_ERR_INVALID_CRC An invalid MAC CRC was read from BLK3 of EFUSE
|
|
||||||
*/
|
|
||||||
esp_err_t esp_efuse_mac_get_custom(uint8_t *mac);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Return base MAC address which is factory-programmed by Espressif in BLK0 of EFUSE.
|
|
||||||
*
|
|
||||||
* @param mac base MAC address, length: 6 bytes.
|
|
||||||
*
|
|
||||||
* @return ESP_OK on success
|
|
||||||
*/
|
|
||||||
esp_err_t esp_efuse_mac_get_default(uint8_t *mac);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Read base MAC address and set MAC address of the interface.
|
|
||||||
*
|
|
||||||
* This function first get base MAC address using esp_base_mac_addr_get or reads base MAC address
|
|
||||||
* from BLK0 of EFUSE. Then set the MAC address of the interface including wifi station, wifi softap,
|
|
||||||
* bluetooth and ethernet.
|
|
||||||
*
|
|
||||||
* @param mac MAC address of the interface, length: 6 bytes.
|
|
||||||
* @param type type of MAC address, 0:wifi station, 1:wifi softap, 2:bluetooth, 3:ethernet.
|
|
||||||
*
|
|
||||||
* @return ESP_OK on success
|
|
||||||
*/
|
|
||||||
esp_err_t esp_read_mac(uint8_t* mac, esp_mac_type_t type);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Derive local MAC address from universal MAC address.
|
|
||||||
*
|
|
||||||
* This function derives a local MAC address from an universal MAC address.
|
|
||||||
* A `definition of local vs universal MAC address can be found on Wikipedia
|
|
||||||
* <https://en.wikipedia.org/wiki/MAC_address#Universal_vs._local>`.
|
|
||||||
* In ESP32, universal MAC address is generated from base MAC address in EFUSE or other external storage.
|
|
||||||
* Local MAC address is derived from the universal MAC address.
|
|
||||||
*
|
|
||||||
* @param local_mac Derived local MAC address, length: 6 bytes.
|
|
||||||
* @param universal_mac Source universal MAC address, length: 6 bytes.
|
|
||||||
*
|
|
||||||
* @return ESP_OK on success
|
|
||||||
*/
|
|
||||||
esp_err_t esp_derive_local_mac(uint8_t* local_mac, const uint8_t* universal_mac);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Trigger a software abort
|
* @brief Trigger a software abort
|
||||||
*
|
*
|
||||||
@@ -259,50 +131,6 @@ esp_err_t esp_derive_local_mac(uint8_t* local_mac, const uint8_t* universal_mac)
|
|||||||
*/
|
*/
|
||||||
void __attribute__((noreturn)) esp_system_abort(const char* details);
|
void __attribute__((noreturn)) esp_system_abort(const char* details);
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Chip models
|
|
||||||
*/
|
|
||||||
typedef enum {
|
|
||||||
CHIP_ESP32 = 1, //!< ESP32
|
|
||||||
CHIP_ESP32S2 = 2, //!< ESP32-S2
|
|
||||||
CHIP_ESP32S3 = 4, //!< ESP32-S3
|
|
||||||
CHIP_ESP32C3 = 5, //!< ESP32-C3
|
|
||||||
} esp_chip_model_t;
|
|
||||||
|
|
||||||
/* Chip feature flags, used in esp_chip_info_t */
|
|
||||||
#define CHIP_FEATURE_EMB_FLASH BIT(0) //!< Chip has embedded flash memory
|
|
||||||
#define CHIP_FEATURE_WIFI_BGN BIT(1) //!< Chip has 2.4GHz WiFi
|
|
||||||
#define CHIP_FEATURE_BLE BIT(4) //!< Chip has Bluetooth LE
|
|
||||||
#define CHIP_FEATURE_BT BIT(5) //!< Chip has Bluetooth Classic
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief The structure represents information about the chip
|
|
||||||
*/
|
|
||||||
typedef struct {
|
|
||||||
esp_chip_model_t model; //!< chip model, one of esp_chip_model_t
|
|
||||||
uint32_t features; //!< bit mask of CHIP_FEATURE_x feature flags
|
|
||||||
uint8_t cores; //!< number of CPU cores
|
|
||||||
uint8_t revision; //!< chip revision number
|
|
||||||
} esp_chip_info_t;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Fill an esp_chip_info_t structure with information about the chip
|
|
||||||
* @param[out] out_info structure to be filled
|
|
||||||
*/
|
|
||||||
void esp_chip_info(esp_chip_info_t* out_info);
|
|
||||||
|
|
||||||
|
|
||||||
#if CONFIG_ESP32_ECO3_CACHE_LOCK_FIX
|
|
||||||
/**
|
|
||||||
* @brief Cache lock bug exists or not
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
* - ture : bug exists
|
|
||||||
* - false : bug not exists
|
|
||||||
*/
|
|
||||||
bool soc_has_cache_lock_bug(void);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@@ -24,6 +24,7 @@ INCLUDE_DIRS := \
|
|||||||
) \
|
) \
|
||||||
$(addprefix ../../../components/, \
|
$(addprefix ../../../components/, \
|
||||||
esp_rom/include \
|
esp_rom/include \
|
||||||
|
esp_hw_support/include \
|
||||||
esp_system/include \
|
esp_system/include \
|
||||||
xtensa/include \
|
xtensa/include \
|
||||||
xtensa/esp32/include \
|
xtensa/esp32/include \
|
||||||
|
@@ -26,6 +26,7 @@ INCLUDE_DIRS := \
|
|||||||
$(addprefix ../../../components/, \
|
$(addprefix ../../../components/, \
|
||||||
esp_rom/include \
|
esp_rom/include \
|
||||||
esp_common/include \
|
esp_common/include \
|
||||||
|
esp_hw_support/include \
|
||||||
esp_system/include \
|
esp_system/include \
|
||||||
xtensa/include \
|
xtensa/include \
|
||||||
xtensa/esp32/include \
|
xtensa/esp32/include \
|
||||||
|
@@ -20,6 +20,7 @@ INCLUDE_DIRS := \
|
|||||||
vfs/include \
|
vfs/include \
|
||||||
$(addprefix ../../../../components/, \
|
$(addprefix ../../../../components/, \
|
||||||
esp_common/include \
|
esp_common/include \
|
||||||
|
esp_hw_support/include \
|
||||||
esp_system/include \
|
esp_system/include \
|
||||||
soc/esp32/include \
|
soc/esp32/include \
|
||||||
soc/include \
|
soc/include \
|
||||||
|
@@ -25,6 +25,7 @@ INCLUDE_DIRS := \
|
|||||||
$(addprefix ../../../components/, \
|
$(addprefix ../../../components/, \
|
||||||
esp_rom/include \
|
esp_rom/include \
|
||||||
esp_common/include \
|
esp_common/include \
|
||||||
|
esp_hw_support/include \
|
||||||
esp_system/include \
|
esp_system/include \
|
||||||
xtensa/include \
|
xtensa/include \
|
||||||
xtensa/esp32/include \
|
xtensa/esp32/include \
|
||||||
|
@@ -25,6 +25,7 @@ INCLUDE_DIRS := \
|
|||||||
esp_rom/include \
|
esp_rom/include \
|
||||||
esp_system/include \
|
esp_system/include \
|
||||||
esp_common/include \
|
esp_common/include \
|
||||||
|
esp_hw_support/include \
|
||||||
xtensa/include \
|
xtensa/include \
|
||||||
xtensa/esp32/include \
|
xtensa/esp32/include \
|
||||||
soc/esp32/include \
|
soc/esp32/include \
|
||||||
|
Reference in New Issue
Block a user