mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
Merge branch 'master' into feature/esp32s2beta_merge
This commit is contained in:
commit
adfc06a530
@ -9,11 +9,16 @@ unset(compile_definitions)
|
||||
# Add the following build specifications here, since these seem to be dependent
|
||||
# on config values on the root Kconfig.
|
||||
|
||||
if(CONFIG_COMPILER_OPTIMIZATION_LEVEL_RELEASE)
|
||||
if(CONFIG_COMPILER_OPTIMIZATION_SIZE)
|
||||
list(APPEND compile_options "-Os")
|
||||
list(APPEND compile_options "-freorder-blocks")
|
||||
else()
|
||||
elseif(CONFIG_COMPILER_OPTIMIZATION_DEFAULT)
|
||||
list(APPEND compile_options "-Og")
|
||||
elseif(CONFIG_COMPILER_OPTIMIZATION_NONE)
|
||||
list(APPEND compile_options "-O0")
|
||||
elseif(CONFIG_COMPILER_OPTIMIZATION_PERF)
|
||||
list(APPEND compile_options "-O2")
|
||||
|
||||
endif()
|
||||
|
||||
if(CONFIG_COMPILER_CXX_EXCEPTIONS)
|
||||
|
40
Kconfig
40
Kconfig
@ -40,6 +40,13 @@ mainmenu "Espressif IoT Development Framework Configuration"
|
||||
default "n"
|
||||
select FREERTOS_UNICORE
|
||||
|
||||
config IDF_FIRMWARE_CHIP_ID
|
||||
hex
|
||||
default 0x0000 if IDF_TARGET_ESP32
|
||||
# note: S2 beta uses Chip ID 0 still, S2 will use 0x0002
|
||||
default 0x0000 if IDF_TARGET_ESP32S2BETA
|
||||
default 0xFFFF
|
||||
|
||||
menu "SDK tool configuration"
|
||||
config SDK_TOOLPREFIX
|
||||
string "Compiler toolchain path/prefix"
|
||||
@ -81,24 +88,35 @@ mainmenu "Espressif IoT Development Framework Configuration"
|
||||
|
||||
choice COMPILER_OPTIMIZATION
|
||||
prompt "Optimization Level"
|
||||
default COMPILER_OPTIMIZATION_LEVEL_DEBUG
|
||||
default COMPILER_OPTIMIZATION_DEFAULT
|
||||
help
|
||||
This option sets compiler optimization level (gcc -O argument).
|
||||
|
||||
- for "Release" setting, -Os flag is added to CFLAGS.
|
||||
- for "Debug" setting, -Og flag is added to CFLAGS.
|
||||
- The "Default" setting will add the -0g flag to CFLAGS.
|
||||
- The "Size" setting will add the -0s flag to CFLAGS.
|
||||
- The "Performance" setting will add the -O2 flag to CFLAGS.
|
||||
- The "None" setting will add the -O0 flag to CFLAGS.
|
||||
|
||||
"Release" with -Os produces smaller & faster compiled code but it
|
||||
may be harder to correlated code addresses to source files when debugging.
|
||||
The "Size" setting cause the compiled code to be smaller and faster, but
|
||||
may lead to difficulties of correlating code addresses to source file
|
||||
lines when debugging.
|
||||
|
||||
To add custom optimization settings, set CFLAGS and/or CPPFLAGS
|
||||
in project makefile, before including $(IDF_PATH)/make/project.mk. Note that
|
||||
custom optimization levels may be unsupported.
|
||||
The "Performance" setting causes the compiled code to be larger and faster,
|
||||
but will be easier to correlated code addresses to source file lines.
|
||||
|
||||
config COMPILER_OPTIMIZATION_LEVEL_DEBUG
|
||||
"None" with -O0 produces compiled code without optimization.
|
||||
|
||||
Note that custom optimization levels may be unsupported.
|
||||
|
||||
config COMPILER_OPTIMIZATION_DEFAULT
|
||||
bool "Debug (-Og)"
|
||||
config COMPILER_OPTIMIZATION_LEVEL_RELEASE
|
||||
bool "Release (-Os)"
|
||||
config COMPILER_OPTIMIZATION_SIZE
|
||||
bool "Optimize for size (-Os)"
|
||||
config COMPILER_OPTIMIZATION_PERF
|
||||
bool "Optimize for performance (-O2)"
|
||||
config COMPILER_OPTIMIZATION_NONE
|
||||
bool "Debug without optimization (-O0)"
|
||||
|
||||
endchoice
|
||||
|
||||
choice COMPILER_OPTIMIZATION_ASSERTION_LEVEL
|
||||
|
@ -40,9 +40,6 @@ read_otadata: $(PARTITION_TABLE_CSV_PATH) partition_table_get_info | check_pytho
|
||||
--partition-table-offset $(partition_table_offset) \
|
||||
read_otadata
|
||||
|
||||
erase_ota: erase_otadata
|
||||
@echo "WARNING: erase_ota is deprecated. Use erase_otadata instead."
|
||||
|
||||
all: blank_ota_data
|
||||
flash: blank_ota_data
|
||||
ifdef CONFIG_SECURE_FLASH_ENCRYPTION_MODE_DEVELOPMENT
|
||||
|
@ -202,7 +202,7 @@ esp_err_t esp_ota_write(esp_ota_handle_t handle, const void *data, size_t size)
|
||||
// must erase the partition before writing to it
|
||||
assert(it->erased_size > 0 && "must erase the partition before writing to it");
|
||||
if (it->wrote_size == 0 && it->partial_bytes == 0 && size > 0 && data_bytes[0] != ESP_IMAGE_HEADER_MAGIC) {
|
||||
ESP_LOGE(TAG, "OTA image has invalid magic byte (expected 0xE9, saw 0x%02x", data_bytes[0]);
|
||||
ESP_LOGE(TAG, "OTA image has invalid magic byte (expected 0xE9, saw 0x%02x)", data_bytes[0]);
|
||||
return ESP_ERR_OTA_VALIDATE_FAILED;
|
||||
}
|
||||
|
||||
|
@ -15,6 +15,7 @@
|
||||
#pragma once
|
||||
#include "esp_flash_partitions.h"
|
||||
#include "esp_image_format.h"
|
||||
#include "esp_app_format.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@ -148,6 +149,16 @@ int bootloader_common_select_otadata(const esp_ota_select_entry_t *two_otadata,
|
||||
*/
|
||||
esp_err_t bootloader_common_get_partition_description(const esp_partition_pos_t *partition, esp_app_desc_t *app_desc);
|
||||
|
||||
/**
|
||||
* @brief Check if the image (bootloader and application) has valid chip ID and revision
|
||||
*
|
||||
* @param img_hdr: image header
|
||||
* @return
|
||||
* - ESP_OK: image and chip are matched well
|
||||
* - ESP_FAIL: image doesn't match to the chip
|
||||
*/
|
||||
esp_err_t bootloader_common_check_chip_validity(const esp_image_header_t* img_hdr);
|
||||
|
||||
/**
|
||||
* @brief Configure VDDSDIO, call this API to rise VDDSDIO to 1.9V when VDDSDIO regulator is enabled as 1.8V mode.
|
||||
*/
|
||||
|
@ -13,6 +13,19 @@
|
||||
// limitations under the License.
|
||||
#pragma once
|
||||
|
||||
/**
|
||||
* @brief ESP chip ID
|
||||
*
|
||||
*/
|
||||
typedef enum {
|
||||
ESP_CHIP_ID_ESP32 = 0x0000, /*!< chip ID: ESP32 */
|
||||
ESP_CHIP_ID_INVALID = 0xFFFF /*!< Invalid chip ID (we defined it to make sure the esp_chip_id_t is 2 bytes size) */
|
||||
} __attribute__((packed)) esp_chip_id_t;
|
||||
|
||||
/** @cond */
|
||||
_Static_assert(sizeof(esp_chip_id_t) == 2, "esp_chip_id_t should be 16 bit");
|
||||
/** @endcond */
|
||||
|
||||
/**
|
||||
* @brief SPI flash mode, used in esp_image_header_t
|
||||
*/
|
||||
@ -63,7 +76,9 @@ typedef struct {
|
||||
* the IDF bootloader uses software to configure the WP
|
||||
* pin and sets this field to 0xEE=disabled) */
|
||||
uint8_t spi_pin_drv[3]; /*!< Drive settings for the SPI flash pins (read by ROM bootloader) */
|
||||
uint8_t reserved[11]; /*!< Reserved bytes in ESP32 additional header space, currently unused */
|
||||
esp_chip_id_t chip_id; /*!< Chip identification number */
|
||||
uint8_t min_chip_rev; /*!< Minimum chip revision supported by image */
|
||||
uint8_t reserved[8]; /*!< Reserved bytes in additional header space, currently unused */
|
||||
uint8_t hash_appended; /*!< If 1, a SHA256 digest "simple hash" (of the entire image) is appended after the checksum.
|
||||
* Included in image length. This digest
|
||||
* is separate to secure boot and only used for detecting corruption.
|
||||
|
@ -98,12 +98,6 @@ typedef struct {
|
||||
esp_err_t esp_partition_table_verify(const esp_partition_info_t *partition_table, bool log_errors, int *num_partitions);
|
||||
|
||||
|
||||
/* This function is included for compatibility with the ESP-IDF v3.x API */
|
||||
inline static __attribute__((deprecated)) esp_err_t esp_partition_table_basic_verify(const esp_partition_info_t *partition_table, bool log_errors, int *num_partitions)
|
||||
{
|
||||
return esp_partition_table_verify(partition_table, log_errors, num_partitions);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether the region on the main flash is safe to write.
|
||||
*
|
||||
|
@ -79,36 +79,6 @@ _Static_assert(CONFIG_BOOTLOADER_RESERVE_RTC_SIZE % 4 == 0, "CONFIG_BOOTLOADER_R
|
||||
_Static_assert(sizeof(rtc_retain_mem_t) <= ESP_BOOTLOADER_RESERVE_RTC, "Reserved RTC area must exceed size of rtc_retain_mem_t");
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Verify and (optionally, in bootloader mode) load an app image.
|
||||
*
|
||||
* This name is deprecated and is included for compatibility with the ESP-IDF v3.x API.
|
||||
* It will be removed in V4.0 version.
|
||||
* Function has been renamed to esp_image_verify().
|
||||
* Use function esp_image_verify() to verify a image. And use function bootloader_load_image() to load image from a bootloader space.
|
||||
*
|
||||
* If encryption is enabled, data will be transparently decrypted.
|
||||
*
|
||||
* @param mode Mode of operation (verify, silent verify, or load).
|
||||
* @param part Partition to load the app from.
|
||||
* @param[inout] data Pointer to the image metadata structure which is be filled in by this function. 'start_addr' member should be set (to the start address of the image.) Other fields will all be initialised by this function.
|
||||
*
|
||||
* Image validation checks:
|
||||
* - Magic byte.
|
||||
* - Partition smaller than 16MB.
|
||||
* - All segments & image fit in partition.
|
||||
* - 8 bit image checksum is valid.
|
||||
* - SHA-256 of image is valid (if image has this appended).
|
||||
* - (Signature) if signature verification is enabled.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK if verify or load was successful
|
||||
* - ESP_ERR_IMAGE_FLASH_FAIL if a SPI flash error occurs
|
||||
* - ESP_ERR_IMAGE_INVALID if the image appears invalid.
|
||||
* - ESP_ERR_INVALID_ARG if the partition or data pointers are invalid.
|
||||
*/
|
||||
esp_err_t esp_image_load(esp_image_load_mode_t mode, const esp_partition_pos_t *part, esp_image_metadata_t *data) __attribute__((deprecated));
|
||||
|
||||
/**
|
||||
* @brief Verify an app image.
|
||||
*
|
||||
|
@ -35,6 +35,7 @@
|
||||
#include "esp_image_format.h"
|
||||
#include "bootloader_sha.h"
|
||||
#include "sys/param.h"
|
||||
#include "esp_efuse.h"
|
||||
|
||||
#define ESP_PARTITION_HASH_LEN 32 /* SHA-256 digest length */
|
||||
|
||||
@ -278,6 +279,25 @@ void bootloader_common_vddsdio_configure(void)
|
||||
#endif // CONFIG_BOOTLOADER_VDDSDIO_BOOST
|
||||
}
|
||||
|
||||
esp_err_t bootloader_common_check_chip_validity(const esp_image_header_t* img_hdr)
|
||||
{
|
||||
esp_err_t err = ESP_OK;
|
||||
esp_chip_id_t chip_id = CONFIG_IDF_FIRMWARE_CHIP_ID;
|
||||
if (chip_id != img_hdr->chip_id) {
|
||||
ESP_LOGE(TAG, "image has invalid chip ID, expected at least %d, found %d", chip_id, img_hdr->chip_id);
|
||||
err = ESP_FAIL;
|
||||
}
|
||||
uint8_t revision = esp_efuse_get_chip_ver();
|
||||
if (revision < img_hdr->min_chip_rev) {
|
||||
ESP_LOGE(TAG, "image has invalid chip revision, expected at least %d, found %d", revision, img_hdr->min_chip_rev);
|
||||
err = ESP_FAIL;
|
||||
} else if (revision != img_hdr->min_chip_rev) {
|
||||
ESP_LOGI(TAG, "This chip is revision %d but project was configured for minimum revision %d. "\
|
||||
"Suggest setting project minimum revision to %d if safe to do so.",
|
||||
revision, img_hdr->min_chip_rev, revision);
|
||||
}
|
||||
return err;
|
||||
}
|
||||
|
||||
#if defined( CONFIG_BOOTLOADER_SKIP_VALIDATE_IN_DEEP_SLEEP ) || defined( CONFIG_BOOTLOADER_CUSTOM_RESERVE_RTC )
|
||||
|
||||
|
@ -60,6 +60,7 @@
|
||||
#endif
|
||||
|
||||
#include "sdkconfig.h"
|
||||
#include "esp_efuse.h"
|
||||
#include "esp_image_format.h"
|
||||
#include "esp_secure_boot.h"
|
||||
#include "esp_flash_encrypt.h"
|
||||
@ -168,6 +169,14 @@ static esp_err_t bootloader_main(void)
|
||||
ESP_LOGE(TAG, "failed to load bootloader header!");
|
||||
return ESP_FAIL;
|
||||
}
|
||||
|
||||
/* Check chip ID and minimum chip revision that supported by this image */
|
||||
uint8_t revision = esp_efuse_get_chip_ver();
|
||||
ESP_LOGI(TAG, "Chip Revision: %d", revision);
|
||||
if (bootloader_common_check_chip_validity(&fhdr) != ESP_OK) {
|
||||
return ESP_FAIL;
|
||||
}
|
||||
|
||||
bootloader_init_flash_configure(&fhdr);
|
||||
|
||||
#ifdef CONFIG_IDF_TARGET_ESP32
|
||||
|
@ -22,7 +22,7 @@
|
||||
#include <bootloader_random.h>
|
||||
#include <bootloader_sha.h>
|
||||
#include "bootloader_util.h"
|
||||
#include "bootloader_utility.h"
|
||||
#include "bootloader_common.h"
|
||||
#if CONFIG_IDF_TARGET_ESP32
|
||||
#include <esp32/rom/rtc.h>
|
||||
#include <esp32/rom/secure_boot.h>
|
||||
@ -300,8 +300,6 @@ esp_err_t esp_image_verify(esp_image_load_mode_t mode, const esp_partition_pos_t
|
||||
return image_load(mode, part, data);
|
||||
}
|
||||
|
||||
esp_err_t esp_image_load(esp_image_load_mode_t mode, const esp_partition_pos_t *part, esp_image_metadata_t *data) __attribute__((alias("esp_image_verify")));
|
||||
|
||||
static esp_err_t verify_image_header(uint32_t src_addr, const esp_image_header_t *image, bool silent)
|
||||
{
|
||||
esp_err_t err = ESP_OK;
|
||||
@ -312,6 +310,9 @@ static esp_err_t verify_image_header(uint32_t src_addr, const esp_image_header_t
|
||||
}
|
||||
err = ESP_ERR_IMAGE_INVALID;
|
||||
}
|
||||
if (bootloader_common_check_chip_validity(image) != ESP_OK) {
|
||||
err = ESP_ERR_IMAGE_INVALID;
|
||||
}
|
||||
if (!silent) {
|
||||
if (image->spi_mode > ESP_IMAGE_SPI_MODE_SLOW_READ) {
|
||||
ESP_LOGW(TAG, "image at 0x%x has invalid SPI mode %d", src_addr, image->spi_mode);
|
||||
|
@ -315,6 +315,8 @@ static void btc_ble_mesh_client_model_op_cb(struct bt_mesh_model *model,
|
||||
return;
|
||||
}
|
||||
|
||||
bt_mesh_client_model_lock();
|
||||
|
||||
node = bt_mesh_is_client_recv_publish_msg(model, ctx, buf, false);
|
||||
if (node == NULL) {
|
||||
msg.act = ESP_BLE_MESH_CLIENT_MODEL_RECV_PUBLISH_MSG_EVT;
|
||||
@ -334,12 +336,21 @@ static void btc_ble_mesh_client_model_op_cb(struct bt_mesh_model *model,
|
||||
|
||||
msg.sig = BTC_SIG_API_CB;
|
||||
msg.pid = BTC_PID_MODEL;
|
||||
if (msg.act != ESP_BLE_MESH_CLIENT_MODEL_RECV_PUBLISH_MSG_EVT) {
|
||||
// Don't forget to release the node at the end.
|
||||
bt_mesh_client_free_node(&data->queue, node);
|
||||
}
|
||||
if (msg.act == ESP_BLE_MESH_CLIENT_MODEL_RECV_PUBLISH_MSG_EVT) {
|
||||
ret = btc_transfer_context(&msg, &mesh_param,
|
||||
sizeof(esp_ble_mesh_model_cb_param_t), btc_ble_mesh_model_copy_req_data);
|
||||
} else {
|
||||
if (!k_delayed_work_free(&node->timer)) {
|
||||
ret = btc_transfer_context(&msg, &mesh_param,
|
||||
sizeof(esp_ble_mesh_model_cb_param_t), btc_ble_mesh_model_copy_req_data);
|
||||
// Don't forget to release the node at the end.
|
||||
bt_mesh_client_free_node(&data->queue, node);
|
||||
} else {
|
||||
ret = BT_STATUS_SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
bt_mesh_client_model_unlock();
|
||||
|
||||
if (ret != BT_STATUS_SUCCESS) {
|
||||
LOG_ERROR("%s, btc_transfer_context failed", __func__);
|
||||
@ -611,6 +622,9 @@ static void btc_ble_mesh_client_model_timeout_cb(struct k_work *work)
|
||||
return;
|
||||
}
|
||||
|
||||
bt_mesh_client_model_lock();
|
||||
|
||||
if (!k_delayed_work_free(&node->timer)) {
|
||||
mesh_param.client_send_timeout.opcode = node->opcode;
|
||||
mesh_param.client_send_timeout.model = (esp_ble_mesh_model_t *)node->ctx.model;
|
||||
mesh_param.client_send_timeout.ctx = (esp_ble_mesh_msg_ctx_t *)&node->ctx;
|
||||
@ -618,14 +632,19 @@ static void btc_ble_mesh_client_model_timeout_cb(struct k_work *work)
|
||||
msg.sig = BTC_SIG_API_CB;
|
||||
msg.pid = BTC_PID_MODEL;
|
||||
msg.act = ESP_BLE_MESH_CLIENT_MODEL_SEND_TIMEOUT_EVT;
|
||||
|
||||
ret = btc_transfer_context(&msg, &mesh_param,
|
||||
sizeof(esp_ble_mesh_model_cb_param_t), btc_ble_mesh_model_copy_req_data);
|
||||
|
||||
if (ret != BT_STATUS_SUCCESS) {
|
||||
LOG_ERROR("%s btc_transfer_context failed", __func__);
|
||||
}
|
||||
|
||||
// Don't forget to release the node at the end.
|
||||
bt_mesh_client_free_node(&data->queue, node);
|
||||
}
|
||||
|
||||
bt_mesh_client_model_unlock();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -505,17 +505,21 @@ static struct bt_mesh_model *bt_mesh_elem_find_group(struct bt_mesh_elem *elem,
|
||||
|
||||
struct bt_mesh_elem *bt_mesh_elem_find(u16_t addr)
|
||||
{
|
||||
int i;
|
||||
u16_t index;
|
||||
|
||||
for (i = 0; i < dev_comp->elem_count; i++) {
|
||||
struct bt_mesh_elem *elem = &dev_comp->elem[i];
|
||||
|
||||
if (BLE_MESH_ADDR_IS_GROUP(addr) ||
|
||||
BLE_MESH_ADDR_IS_VIRTUAL(addr)) {
|
||||
if (bt_mesh_elem_find_group(elem, addr)) {
|
||||
return elem;
|
||||
if (BLE_MESH_ADDR_IS_UNICAST(addr)) {
|
||||
index = (addr - dev_comp->elem[0].addr);
|
||||
if (index < dev_comp->elem_count) {
|
||||
return &dev_comp->elem[index];
|
||||
} else {
|
||||
return NULL;
|
||||
}
|
||||
} else if (elem->addr == addr) {
|
||||
}
|
||||
|
||||
for (index = 0; index < dev_comp->elem_count; index++) {
|
||||
struct bt_mesh_elem *elem = &dev_comp->elem[index];
|
||||
|
||||
if (bt_mesh_elem_find_group(elem, addr)) {
|
||||
return elem;
|
||||
}
|
||||
}
|
||||
|
@ -12,6 +12,7 @@
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "osi/allocator.h"
|
||||
#include "osi/mutex.h"
|
||||
#include "sdkconfig.h"
|
||||
#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BLE_MESH_DEBUG_MODEL)
|
||||
|
||||
@ -82,6 +83,28 @@ static const bt_mesh_client_op_pair_t cfg_op_pair[] = {
|
||||
{ OP_NET_TRANSMIT_SET, OP_NET_TRANSMIT_STATUS },
|
||||
};
|
||||
|
||||
static osi_mutex_t cfg_client_mutex;
|
||||
|
||||
static void bt_mesh_cfg_client_mutex_new(void)
|
||||
{
|
||||
static bool init;
|
||||
|
||||
if (!init) {
|
||||
osi_mutex_new(&cfg_client_mutex);
|
||||
init = true;
|
||||
}
|
||||
}
|
||||
|
||||
static void bt_mesh_cfg_client_lock(void)
|
||||
{
|
||||
osi_mutex_lock(&cfg_client_mutex, OSI_MUTEX_MAX_TIMEOUT);
|
||||
}
|
||||
|
||||
static void bt_mesh_cfg_client_unlock(void)
|
||||
{
|
||||
osi_mutex_unlock(&cfg_client_mutex);
|
||||
}
|
||||
|
||||
static void timeout_handler(struct k_work *work)
|
||||
{
|
||||
config_internal_data_t *internal = NULL;
|
||||
@ -108,10 +131,16 @@ static void timeout_handler(struct k_work *work)
|
||||
return;
|
||||
}
|
||||
|
||||
bt_mesh_cfg_client_lock();
|
||||
|
||||
if (!k_delayed_work_free(&node->timer)) {
|
||||
bt_mesh_config_client_cb_evt_to_btc(node->opcode,
|
||||
BTC_BLE_MESH_EVT_CONFIG_CLIENT_TIMEOUT, node->ctx.model, &node->ctx, NULL, 0);
|
||||
|
||||
// Don't forget to release the node at the end.
|
||||
bt_mesh_client_free_node(&internal->queue, node);
|
||||
}
|
||||
|
||||
bt_mesh_cfg_client_unlock();
|
||||
|
||||
return;
|
||||
}
|
||||
@ -139,6 +168,9 @@ static void cfg_client_cancel(struct bt_mesh_model *model,
|
||||
/* If it is a publish message, sent to the user directly. */
|
||||
buf.data = (u8_t *)status;
|
||||
buf.len = (u16_t)len;
|
||||
|
||||
bt_mesh_cfg_client_lock();
|
||||
|
||||
node = bt_mesh_is_client_recv_publish_msg(model, ctx, &buf, true);
|
||||
if (!node) {
|
||||
BT_DBG("Unexpected config status message 0x%x", ctx->recv_op);
|
||||
@ -199,11 +231,15 @@ static void cfg_client_cancel(struct bt_mesh_model *model,
|
||||
break;
|
||||
}
|
||||
|
||||
if (!k_delayed_work_free(&node->timer)) {
|
||||
bt_mesh_config_client_cb_evt_to_btc(
|
||||
node->opcode, evt_type, model, ctx, (const u8_t *)status, len);
|
||||
// Don't forget to release the node at the end.
|
||||
bt_mesh_client_free_node(&data->queue, node);
|
||||
}
|
||||
}
|
||||
|
||||
bt_mesh_cfg_client_unlock();
|
||||
|
||||
switch (ctx->recv_op) {
|
||||
case OP_DEV_COMP_DATA_STATUS: {
|
||||
@ -1653,5 +1689,7 @@ int bt_mesh_cfg_cli_init(struct bt_mesh_model *model, bool primary)
|
||||
/* Configuration Model security is device-key based */
|
||||
model->keys[0] = BLE_MESH_KEY_DEV;
|
||||
|
||||
bt_mesh_cfg_client_mutex_new();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -12,6 +12,7 @@
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "osi/allocator.h"
|
||||
#include "osi/mutex.h"
|
||||
#include "sdkconfig.h"
|
||||
#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BLE_MESH_DEBUG_MODEL)
|
||||
|
||||
@ -38,6 +39,28 @@ static const bt_mesh_client_op_pair_t health_op_pair[] = {
|
||||
{ OP_ATTENTION_SET, OP_ATTENTION_STATUS },
|
||||
};
|
||||
|
||||
static osi_mutex_t health_client_mutex;
|
||||
|
||||
static void bt_mesh_health_client_mutex_new(void)
|
||||
{
|
||||
static bool init;
|
||||
|
||||
if (!init) {
|
||||
osi_mutex_new(&health_client_mutex);
|
||||
init = true;
|
||||
}
|
||||
}
|
||||
|
||||
static void bt_mesh_health_client_lock(void)
|
||||
{
|
||||
osi_mutex_lock(&health_client_mutex, OSI_MUTEX_MAX_TIMEOUT);
|
||||
}
|
||||
|
||||
static void bt_mesh_health_client_unlock(void)
|
||||
{
|
||||
osi_mutex_unlock(&health_client_mutex);
|
||||
}
|
||||
|
||||
static void timeout_handler(struct k_work *work)
|
||||
{
|
||||
health_internal_data_t *internal = NULL;
|
||||
@ -64,10 +87,16 @@ static void timeout_handler(struct k_work *work)
|
||||
return;
|
||||
}
|
||||
|
||||
bt_mesh_health_client_lock();
|
||||
|
||||
if (!k_delayed_work_free(&node->timer)) {
|
||||
bt_mesh_health_client_cb_evt_to_btc(node->opcode,
|
||||
BTC_BLE_MESH_EVT_HEALTH_CLIENT_TIMEOUT, node->ctx.model, &node->ctx, NULL, 0);
|
||||
|
||||
// Don't forget to release the node at the end.
|
||||
bt_mesh_client_free_node(&internal->queue, node);
|
||||
}
|
||||
|
||||
bt_mesh_health_client_unlock();
|
||||
|
||||
return;
|
||||
}
|
||||
@ -95,6 +124,9 @@ static void health_client_cancel(struct bt_mesh_model *model,
|
||||
/* If it is a publish message, sent to the user directly. */
|
||||
buf.data = (u8_t *)status;
|
||||
buf.len = (u16_t)len;
|
||||
|
||||
bt_mesh_health_client_lock();
|
||||
|
||||
node = bt_mesh_is_client_recv_publish_msg(model, ctx, &buf, true);
|
||||
if (!node) {
|
||||
BT_DBG("Unexpected health status message 0x%x", ctx->recv_op);
|
||||
@ -115,11 +147,15 @@ static void health_client_cancel(struct bt_mesh_model *model,
|
||||
break;
|
||||
}
|
||||
|
||||
if (!k_delayed_work_free(&node->timer)) {
|
||||
bt_mesh_health_client_cb_evt_to_btc(
|
||||
node->opcode, evt_type, model, ctx, (const u8_t *)status, len);
|
||||
// Don't forget to release the node at the end.
|
||||
bt_mesh_client_free_node(&data->queue, node);
|
||||
}
|
||||
}
|
||||
|
||||
bt_mesh_health_client_unlock();
|
||||
|
||||
switch (ctx->recv_op) {
|
||||
case OP_HEALTH_FAULT_STATUS: {
|
||||
@ -453,6 +489,8 @@ int bt_mesh_health_cli_init(struct bt_mesh_model *model, bool primary)
|
||||
client->op_pair = health_op_pair;
|
||||
client->internal_data = internal;
|
||||
|
||||
bt_mesh_health_client_mutex_new();
|
||||
|
||||
/* Set the default health client pointer */
|
||||
if (!health_cli) {
|
||||
health_cli = client;
|
||||
|
@ -38,14 +38,6 @@ typedef struct alarm_t {
|
||||
int64_t deadline_us;
|
||||
} osi_alarm_t;
|
||||
|
||||
static void bt_mesh_alarm_cb(void *data)
|
||||
{
|
||||
assert(data != NULL);
|
||||
struct k_delayed_work *work = (struct k_delayed_work *)data;
|
||||
work->work.handler(&work->work);
|
||||
return;
|
||||
}
|
||||
|
||||
unsigned int bt_mesh_irq_lock(void)
|
||||
{
|
||||
#if defined(CONFIG_BLE_MESH_IRQ_LOCK) && CONFIG_BLE_MESH_IRQ_LOCK
|
||||
@ -111,7 +103,7 @@ void k_delayed_work_init(struct k_delayed_work *work, k_work_handler_t handler)
|
||||
|
||||
osi_mutex_lock(&bm_alarm_lock, OSI_MUTEX_MAX_TIMEOUT);
|
||||
if (!hash_map_has_key(bm_alarm_hash_map, (void *)work)) {
|
||||
alarm = osi_alarm_new("bt_mesh", bt_mesh_alarm_cb, (void *)work, 0);
|
||||
alarm = osi_alarm_new("bt_mesh", (osi_alarm_callback_t)handler, (void *)work, 0);
|
||||
if (alarm == NULL) {
|
||||
BT_ERR("%s, Unable to create alarm", __func__);
|
||||
return;
|
||||
@ -189,17 +181,5 @@ s32_t k_delayed_work_remaining_get(struct k_delayed_work *work)
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!alarm->deadline_us) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
s32_t remain_time = 0;
|
||||
int64_t now = esp_timer_get_time();
|
||||
if ((alarm->deadline_us - now) < 0x1FFFFFFFFFF) {
|
||||
remain_time = (alarm->deadline_us - now) / 1000;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return remain_time;
|
||||
return osi_alarm_get_remaining_ms(alarm);
|
||||
}
|
||||
|
@ -16,6 +16,7 @@
|
||||
#include <errno.h>
|
||||
|
||||
#include "osi/allocator.h"
|
||||
#include "osi/mutex.h"
|
||||
|
||||
#include "mesh_access.h"
|
||||
#include "mesh_buf.h"
|
||||
@ -222,6 +223,28 @@ int bt_mesh_client_send_msg(struct bt_mesh_model *model,
|
||||
return err;
|
||||
}
|
||||
|
||||
static osi_mutex_t client_model_mutex;
|
||||
|
||||
static void bt_mesh_client_model_mutex_new(void)
|
||||
{
|
||||
static bool init;
|
||||
|
||||
if (!init) {
|
||||
osi_mutex_new(&client_model_mutex);
|
||||
init = true;
|
||||
}
|
||||
}
|
||||
|
||||
void bt_mesh_client_model_lock(void)
|
||||
{
|
||||
osi_mutex_lock(&client_model_mutex, OSI_MUTEX_MAX_TIMEOUT);
|
||||
}
|
||||
|
||||
void bt_mesh_client_model_unlock(void)
|
||||
{
|
||||
osi_mutex_unlock(&client_model_mutex);
|
||||
}
|
||||
|
||||
int bt_mesh_client_init(struct bt_mesh_model *model)
|
||||
{
|
||||
bt_mesh_client_internal_data_t *data = NULL;
|
||||
@ -256,17 +279,18 @@ int bt_mesh_client_init(struct bt_mesh_model *model)
|
||||
cli->model = model;
|
||||
cli->internal_data = data;
|
||||
|
||||
bt_mesh_client_model_mutex_new();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int bt_mesh_client_free_node(sys_slist_t *queue, bt_mesh_client_node_t *node)
|
||||
{
|
||||
if (!queue || !node) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
// Free the node timer
|
||||
k_delayed_work_free(&node->timer);
|
||||
// Release the client node from the queue
|
||||
sys_slist_find_and_remove(queue, &node->client_node);
|
||||
// Free the node
|
||||
|
@ -17,6 +17,7 @@
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "osi/allocator.h"
|
||||
#include "osi/mutex.h"
|
||||
#include "sdkconfig.h"
|
||||
|
||||
#include "mesh_types.h"
|
||||
@ -119,6 +120,28 @@ static const bt_mesh_client_op_pair_t gen_op_pair[] = {
|
||||
{ BLE_MESH_MODEL_OP_GEN_CLIENT_PROPERTIES_GET, BLE_MESH_MODEL_OP_GEN_CLIENT_PROPERTIES_STATUS },
|
||||
};
|
||||
|
||||
static osi_mutex_t generic_client_mutex;
|
||||
|
||||
static void bt_mesh_generic_client_mutex_new(void)
|
||||
{
|
||||
static bool init;
|
||||
|
||||
if (!init) {
|
||||
osi_mutex_new(&generic_client_mutex);
|
||||
init = true;
|
||||
}
|
||||
}
|
||||
|
||||
static void bt_mesh_generic_client_lock(void)
|
||||
{
|
||||
osi_mutex_lock(&generic_client_mutex, OSI_MUTEX_MAX_TIMEOUT);
|
||||
}
|
||||
|
||||
static void bt_mesh_generic_client_unlock(void)
|
||||
{
|
||||
osi_mutex_unlock(&generic_client_mutex);
|
||||
}
|
||||
|
||||
static void timeout_handler(struct k_work *work)
|
||||
{
|
||||
generic_internal_data_t *internal = NULL;
|
||||
@ -145,10 +168,16 @@ static void timeout_handler(struct k_work *work)
|
||||
return;
|
||||
}
|
||||
|
||||
bt_mesh_generic_client_lock();
|
||||
|
||||
if (!k_delayed_work_free(&node->timer)) {
|
||||
bt_mesh_generic_client_cb_evt_to_btc(node->opcode,
|
||||
BTC_BLE_MESH_EVT_GENERIC_CLIENT_TIMEOUT, node->ctx.model, &node->ctx, NULL, 0);
|
||||
|
||||
// Don't forget to release the node at the end.
|
||||
bt_mesh_client_free_node(&internal->queue, node);
|
||||
}
|
||||
|
||||
bt_mesh_generic_client_unlock();
|
||||
|
||||
return;
|
||||
}
|
||||
@ -535,6 +564,9 @@ static void generic_status(struct bt_mesh_model *model,
|
||||
|
||||
buf->data = val;
|
||||
buf->len = len;
|
||||
|
||||
bt_mesh_generic_client_lock();
|
||||
|
||||
node = bt_mesh_is_client_recv_publish_msg(model, ctx, buf, true);
|
||||
if (!node) {
|
||||
BT_DBG("Unexpected generic status message 0x%x", rsp);
|
||||
@ -580,10 +612,14 @@ static void generic_status(struct bt_mesh_model *model,
|
||||
break;
|
||||
}
|
||||
|
||||
if (!k_delayed_work_free(&node->timer)) {
|
||||
bt_mesh_generic_client_cb_evt_to_btc(node->opcode, evt, model, ctx, val, len);
|
||||
// Don't forget to release the node at the end.
|
||||
bt_mesh_client_free_node(&internal->queue, node);
|
||||
}
|
||||
}
|
||||
|
||||
bt_mesh_generic_client_unlock();
|
||||
|
||||
switch (rsp) {
|
||||
case BLE_MESH_MODEL_OP_GEN_USER_PROPERTIES_STATUS: {
|
||||
@ -1181,6 +1217,8 @@ static int generic_client_init(struct bt_mesh_model *model, bool primary)
|
||||
client->op_pair = gen_op_pair;
|
||||
client->internal_data = internal;
|
||||
|
||||
bt_mesh_generic_client_mutex_new();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -78,6 +78,10 @@ typedef struct {
|
||||
void *cb_data; /* User defined callback value */
|
||||
} bt_mesh_client_common_param_t;
|
||||
|
||||
void bt_mesh_client_model_lock(void);
|
||||
|
||||
void bt_mesh_client_model_unlock(void);
|
||||
|
||||
int bt_mesh_client_init(struct bt_mesh_model *model);
|
||||
|
||||
/**
|
||||
|
@ -17,6 +17,7 @@
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "osi/allocator.h"
|
||||
#include "osi/mutex.h"
|
||||
#include "sdkconfig.h"
|
||||
|
||||
#include "mesh_types.h"
|
||||
@ -128,6 +129,28 @@ static const bt_mesh_client_op_pair_t light_op_pair[] = {
|
||||
{ BLE_MESH_MODEL_OP_LIGHT_LC_PROPERTY_SET, BLE_MESH_MODEL_OP_LIGHT_LC_PROPERTY_STATUS },
|
||||
};
|
||||
|
||||
static osi_mutex_t light_client_mutex;
|
||||
|
||||
static void bt_mesh_light_client_mutex_new(void)
|
||||
{
|
||||
static bool init;
|
||||
|
||||
if (!init) {
|
||||
osi_mutex_new(&light_client_mutex);
|
||||
init = true;
|
||||
}
|
||||
}
|
||||
|
||||
static void bt_mesh_light_client_lock(void)
|
||||
{
|
||||
osi_mutex_lock(&light_client_mutex, OSI_MUTEX_MAX_TIMEOUT);
|
||||
}
|
||||
|
||||
static void bt_mesh_light_client_unlock(void)
|
||||
{
|
||||
osi_mutex_unlock(&light_client_mutex);
|
||||
}
|
||||
|
||||
static void timeout_handler(struct k_work *work)
|
||||
{
|
||||
light_internal_data_t *internal = NULL;
|
||||
@ -154,10 +177,16 @@ static void timeout_handler(struct k_work *work)
|
||||
return;
|
||||
}
|
||||
|
||||
bt_mesh_light_client_lock();
|
||||
|
||||
if (!k_delayed_work_free(&node->timer)) {
|
||||
bt_mesh_lighting_client_cb_evt_to_btc(node->opcode,
|
||||
BTC_BLE_MESH_EVT_LIGHTING_CLIENT_TIMEOUT, node->ctx.model, &node->ctx, NULL, 0);
|
||||
|
||||
// Don't forget to release the node at the end.
|
||||
bt_mesh_client_free_node(&internal->queue, node);
|
||||
}
|
||||
|
||||
bt_mesh_light_client_unlock();
|
||||
|
||||
return;
|
||||
}
|
||||
@ -650,6 +679,9 @@ static void light_status(struct bt_mesh_model *model,
|
||||
|
||||
buf->data = val;
|
||||
buf->len = len;
|
||||
|
||||
bt_mesh_light_client_lock();
|
||||
|
||||
node = bt_mesh_is_client_recv_publish_msg(model, ctx, buf, true);
|
||||
if (!node) {
|
||||
BT_DBG("Unexpected light status message 0x%x", rsp);
|
||||
@ -706,10 +738,14 @@ static void light_status(struct bt_mesh_model *model,
|
||||
break;
|
||||
}
|
||||
|
||||
if (!k_delayed_work_free(&node->timer)) {
|
||||
bt_mesh_lighting_client_cb_evt_to_btc(node->opcode, evt, model, ctx, val, len);
|
||||
// Don't forget to release the node at the end.
|
||||
bt_mesh_client_free_node(&internal->queue, node);
|
||||
}
|
||||
}
|
||||
|
||||
bt_mesh_light_client_unlock();
|
||||
|
||||
switch (rsp) {
|
||||
case BLE_MESH_MODEL_OP_LIGHT_LC_PROPERTY_STATUS: {
|
||||
@ -1371,6 +1407,8 @@ static int light_client_init(struct bt_mesh_model *model, bool primary)
|
||||
client->op_pair = light_op_pair;
|
||||
client->internal_data = internal;
|
||||
|
||||
bt_mesh_light_client_mutex_new();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -17,6 +17,7 @@
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "osi/allocator.h"
|
||||
#include "osi/mutex.h"
|
||||
#include "sdkconfig.h"
|
||||
|
||||
#include "mesh_types.h"
|
||||
@ -57,6 +58,28 @@ static const bt_mesh_client_op_pair_t sensor_op_pair[] = {
|
||||
{ BLE_MESH_MODEL_OP_SENSOR_SERIES_GET, BLE_MESH_MODEL_OP_SENSOR_SERIES_STATUS },
|
||||
};
|
||||
|
||||
static osi_mutex_t sensor_client_mutex;
|
||||
|
||||
static void bt_mesh_sensor_client_mutex_new(void)
|
||||
{
|
||||
static bool init;
|
||||
|
||||
if (!init) {
|
||||
osi_mutex_new(&sensor_client_mutex);
|
||||
init = true;
|
||||
}
|
||||
}
|
||||
|
||||
static void bt_mesh_sensor_client_lock(void)
|
||||
{
|
||||
osi_mutex_lock(&sensor_client_mutex, OSI_MUTEX_MAX_TIMEOUT);
|
||||
}
|
||||
|
||||
static void bt_mesh_sensor_client_unlock(void)
|
||||
{
|
||||
osi_mutex_unlock(&sensor_client_mutex);
|
||||
}
|
||||
|
||||
static void timeout_handler(struct k_work *work)
|
||||
{
|
||||
sensor_internal_data_t *internal = NULL;
|
||||
@ -83,10 +106,16 @@ static void timeout_handler(struct k_work *work)
|
||||
return;
|
||||
}
|
||||
|
||||
bt_mesh_sensor_client_lock();
|
||||
|
||||
if (!k_delayed_work_free(&node->timer)) {
|
||||
bt_mesh_sensor_client_cb_evt_to_btc(node->opcode,
|
||||
BTC_BLE_MESH_EVT_SENSOR_CLIENT_TIMEOUT, node->ctx.model, &node->ctx, NULL, 0);
|
||||
|
||||
// Don't forget to release the node at the end.
|
||||
bt_mesh_client_free_node(&internal->queue, node);
|
||||
}
|
||||
|
||||
bt_mesh_sensor_client_unlock();
|
||||
|
||||
return;
|
||||
}
|
||||
@ -262,6 +291,9 @@ static void sensor_status(struct bt_mesh_model *model,
|
||||
|
||||
buf->data = val;
|
||||
buf->len = len;
|
||||
|
||||
bt_mesh_sensor_client_lock();
|
||||
|
||||
node = bt_mesh_is_client_recv_publish_msg(model, ctx, buf, true);
|
||||
if (!node) {
|
||||
BT_DBG("Unexpected sensor status message 0x%x", rsp);
|
||||
@ -284,10 +316,14 @@ static void sensor_status(struct bt_mesh_model *model,
|
||||
break;
|
||||
}
|
||||
|
||||
if (!k_delayed_work_free(&node->timer)) {
|
||||
bt_mesh_sensor_client_cb_evt_to_btc(node->opcode, evt, model, ctx, val, len);
|
||||
// Don't forget to release the node at the end.
|
||||
bt_mesh_client_free_node(&internal->queue, node);
|
||||
}
|
||||
}
|
||||
|
||||
bt_mesh_sensor_client_unlock();
|
||||
|
||||
switch (rsp) {
|
||||
case BLE_MESH_MODEL_OP_SENSOR_DESCRIPTOR_STATUS: {
|
||||
@ -612,5 +648,7 @@ int bt_mesh_sensor_cli_init(struct bt_mesh_model *model, bool primary)
|
||||
client->op_pair = sensor_op_pair;
|
||||
client->internal_data = internal;
|
||||
|
||||
bt_mesh_sensor_client_mutex_new();
|
||||
|
||||
return 0;
|
||||
}
|
@ -17,6 +17,7 @@
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "osi/allocator.h"
|
||||
#include "osi/mutex.h"
|
||||
#include "sdkconfig.h"
|
||||
|
||||
#include "mesh_types.h"
|
||||
@ -73,6 +74,28 @@ static const bt_mesh_client_op_pair_t time_scene_op_pair[] = {
|
||||
{ BLE_MESH_MODEL_OP_SCHEDULER_ACT_SET, BLE_MESH_MODEL_OP_SCHEDULER_ACT_STATUS },
|
||||
};
|
||||
|
||||
static osi_mutex_t time_scene_client_mutex;
|
||||
|
||||
static void bt_mesh_time_scene_client_mutex_new(void)
|
||||
{
|
||||
static bool init;
|
||||
|
||||
if (!init) {
|
||||
osi_mutex_new(&time_scene_client_mutex);
|
||||
init = true;
|
||||
}
|
||||
}
|
||||
|
||||
static void bt_mesh_time_scene_client_lock(void)
|
||||
{
|
||||
osi_mutex_lock(&time_scene_client_mutex, OSI_MUTEX_MAX_TIMEOUT);
|
||||
}
|
||||
|
||||
static void bt_mesh_time_scene_client_unlock(void)
|
||||
{
|
||||
osi_mutex_unlock(&time_scene_client_mutex);
|
||||
}
|
||||
|
||||
static void timeout_handler(struct k_work *work)
|
||||
{
|
||||
time_scene_internal_data_t *internal = NULL;
|
||||
@ -99,10 +122,16 @@ static void timeout_handler(struct k_work *work)
|
||||
return;
|
||||
}
|
||||
|
||||
bt_mesh_time_scene_client_lock();
|
||||
|
||||
if (!k_delayed_work_free(&node->timer)) {
|
||||
bt_mesh_time_scene_client_cb_evt_to_btc(node->opcode,
|
||||
BTC_BLE_MESH_EVT_TIME_SCENE_CLIENT_TIMEOUT, node->ctx.model, &node->ctx, NULL, 0);
|
||||
|
||||
// Don't forget to release the node at the end.
|
||||
bt_mesh_client_free_node(&internal->queue, node);
|
||||
}
|
||||
|
||||
bt_mesh_time_scene_client_unlock();
|
||||
|
||||
return;
|
||||
}
|
||||
@ -299,6 +328,9 @@ static void time_scene_status(struct bt_mesh_model *model,
|
||||
|
||||
buf->data = val;
|
||||
buf->len = len;
|
||||
|
||||
bt_mesh_time_scene_client_lock();
|
||||
|
||||
node = bt_mesh_is_client_recv_publish_msg(model, ctx, buf, true);
|
||||
if (!node) {
|
||||
BT_DBG("Unexpected time scene status message 0x%x", rsp);
|
||||
@ -328,10 +360,14 @@ static void time_scene_status(struct bt_mesh_model *model,
|
||||
break;
|
||||
}
|
||||
|
||||
if (!k_delayed_work_free(&node->timer)) {
|
||||
bt_mesh_time_scene_client_cb_evt_to_btc(node->opcode, evt, model, ctx, val, len);
|
||||
// Don't forget to release the node at the end.
|
||||
bt_mesh_client_free_node(&internal->queue, node);
|
||||
}
|
||||
}
|
||||
|
||||
bt_mesh_time_scene_client_unlock();
|
||||
|
||||
switch (rsp) {
|
||||
case BLE_MESH_MODEL_OP_SCENE_REGISTER_STATUS: {
|
||||
@ -675,6 +711,8 @@ static int time_scene_client_init(struct bt_mesh_model *model, bool primary)
|
||||
client->op_pair = time_scene_op_pair;
|
||||
client->internal_data = internal;
|
||||
|
||||
bt_mesh_time_scene_client_mutex_new();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1,3 +0,0 @@
|
||||
#pragma once
|
||||
#warning "This header is deprecated, please use functions defined in esp_bt.h instead."
|
||||
#include "esp_bt.h"
|
@ -1180,18 +1180,6 @@ esp_err_t i2s_driver_uninstall(i2s_port_t i2s_num)
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
int i2s_write_bytes(i2s_port_t i2s_num, const void *src, size_t size, TickType_t ticks_to_wait)
|
||||
{
|
||||
size_t bytes_written = 0;
|
||||
int res = 0;
|
||||
res = i2s_write(i2s_num, src, size, &bytes_written, ticks_to_wait);
|
||||
if (res != ESP_OK) {
|
||||
return ESP_FAIL;
|
||||
} else {
|
||||
return bytes_written;
|
||||
}
|
||||
}
|
||||
|
||||
esp_err_t i2s_write(i2s_port_t i2s_num, const void *src, size_t size, size_t *bytes_written, TickType_t ticks_to_wait)
|
||||
{
|
||||
char *data_ptr, *src_byte;
|
||||
@ -1317,18 +1305,6 @@ esp_err_t i2s_write_expand(i2s_port_t i2s_num, const void *src, size_t size, siz
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
int i2s_read_bytes(i2s_port_t i2s_num, void *dest, size_t size, TickType_t ticks_to_wait)
|
||||
{
|
||||
size_t bytes_read = 0;
|
||||
int res = 0;
|
||||
res = i2s_read(i2s_num, dest, size, &bytes_read, ticks_to_wait);
|
||||
if (res != ESP_OK) {
|
||||
return ESP_FAIL;
|
||||
} else {
|
||||
return bytes_read;
|
||||
}
|
||||
}
|
||||
|
||||
esp_err_t i2s_read(i2s_port_t i2s_num, void *dest, size_t size, size_t *bytes_read, TickType_t ticks_to_wait)
|
||||
{
|
||||
char *data_ptr, *dest_byte;
|
||||
@ -1367,29 +1343,3 @@ esp_err_t i2s_read(i2s_port_t i2s_num, void *dest, size_t size, size_t *bytes_re
|
||||
xSemaphoreGive(p_i2s_obj[i2s_num]->rx->mux);
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
int i2s_push_sample(i2s_port_t i2s_num, const void *sample, TickType_t ticks_to_wait)
|
||||
{
|
||||
size_t bytes_push = 0;
|
||||
int res = 0;
|
||||
I2S_CHECK((i2s_num < I2S_NUM_MAX), "i2s_num error", ESP_FAIL);
|
||||
res = i2s_write(i2s_num, sample, p_i2s_obj[i2s_num]->bytes_per_sample, &bytes_push, ticks_to_wait);
|
||||
if (res != ESP_OK) {
|
||||
return ESP_FAIL;
|
||||
} else {
|
||||
return bytes_push;
|
||||
}
|
||||
}
|
||||
|
||||
int i2s_pop_sample(i2s_port_t i2s_num, void *sample, TickType_t ticks_to_wait)
|
||||
{
|
||||
size_t bytes_pop = 0;
|
||||
int res = 0;
|
||||
I2S_CHECK((i2s_num < I2S_NUM_MAX), "i2s_num error", ESP_FAIL);
|
||||
res = i2s_read(i2s_num, sample, p_i2s_obj[i2s_num]->bytes_per_sample, &bytes_pop, ticks_to_wait);
|
||||
if (res != ESP_OK) {
|
||||
return ESP_FAIL;
|
||||
} else {
|
||||
return bytes_pop;
|
||||
}
|
||||
}
|
||||
|
@ -218,20 +218,6 @@ esp_err_t adc1_config_channel_atten(adc1_channel_t channel, adc_atten_t atten);
|
||||
*/
|
||||
int adc1_get_raw(adc1_channel_t channel);
|
||||
|
||||
/** @cond */ //Doxygen command to hide deprecated function from API Reference
|
||||
/*
|
||||
* @note When the power switch of SARADC1, SARADC2, HALL sensor and AMP sensor is turned on,
|
||||
* the input of GPIO36 and GPIO39 will be pulled down for about 80ns.
|
||||
* When enabling power for any of these peripherals, ignore input from GPIO36 and GPIO39.
|
||||
* Please refer to section 3.11 of 'ECO_and_Workarounds_for_Bugs_in_ESP32' for the description of this issue.
|
||||
*
|
||||
* @deprecated This function returns an ADC1 reading but is deprecated due to
|
||||
* a misleading name and has been changed to directly call the new function.
|
||||
* Use the new function adc1_get_raw() instead
|
||||
*/
|
||||
int adc1_get_voltage(adc1_channel_t channel) __attribute__((deprecated));
|
||||
/** @endcond */
|
||||
|
||||
/**
|
||||
* @brief Enable ADC power
|
||||
*/
|
||||
|
@ -42,25 +42,6 @@ typedef enum {
|
||||
*/
|
||||
esp_err_t dac_pad_get_io_num(dac_channel_t channel, gpio_num_t *gpio_num);
|
||||
|
||||
/** @cond */
|
||||
/**
|
||||
* @brief Set DAC output voltage.
|
||||
*
|
||||
* @note Function has been deprecated, please use dac_output_voltage instead.
|
||||
* This name will be removed in a future release.
|
||||
* The difference is that before calling dac_output_voltage, we need to initialize the dac pad by dac_output_enable
|
||||
*
|
||||
*
|
||||
* @param channel DAC channel
|
||||
* @param dac_value DAC output value
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK success
|
||||
* - ESP_ERR_INVALID_ARG Parameter error
|
||||
*/
|
||||
esp_err_t dac_out_voltage(dac_channel_t channel, uint8_t dac_value) __attribute__ ((deprecated));
|
||||
/** @endcond */
|
||||
|
||||
/**
|
||||
* @brief Set DAC output voltage.
|
||||
*
|
||||
|
@ -294,18 +294,6 @@ esp_err_t i2s_driver_install(i2s_port_t i2s_num, const i2s_config_t *i2s_config,
|
||||
*/
|
||||
esp_err_t i2s_driver_uninstall(i2s_port_t i2s_num);
|
||||
|
||||
/**
|
||||
* @brief Write data to I2S DMA transmit buffer.
|
||||
*
|
||||
* This function is deprecated. Use 'i2s_write' instead.
|
||||
* This definition will be removed in a future release.
|
||||
*
|
||||
* @return
|
||||
* - The amount of bytes written, if timeout, the result will be less than the size passed in.
|
||||
* - ESP_FAIL Parameter error
|
||||
*/
|
||||
int i2s_write_bytes(i2s_port_t i2s_num, const void *src, size_t size, TickType_t ticks_to_wait) __attribute__ ((deprecated));
|
||||
|
||||
/**
|
||||
* @brief Write data to I2S DMA transmit buffer.
|
||||
*
|
||||
@ -361,18 +349,6 @@ esp_err_t i2s_write(i2s_port_t i2s_num, const void *src, size_t size, size_t *by
|
||||
*/
|
||||
esp_err_t i2s_write_expand(i2s_port_t i2s_num, const void *src, size_t size, size_t src_bits, size_t aim_bits, size_t *bytes_written, TickType_t ticks_to_wait);
|
||||
|
||||
/**
|
||||
* @brief Read data from I2S DMA receive buffer
|
||||
*
|
||||
* This function is deprecated. Use 'i2s_read' instead.
|
||||
* This definition will be removed in a future release.
|
||||
*
|
||||
* @return
|
||||
* - The amount of bytes read, if timeout, bytes read will be less than the size passed in
|
||||
* - ESP_FAIL Parameter error
|
||||
*/
|
||||
int i2s_read_bytes(i2s_port_t i2s_num, void *dest, size_t size, TickType_t ticks_to_wait) __attribute__ ((deprecated));
|
||||
|
||||
/**
|
||||
* @brief Read data from I2S DMA receive buffer
|
||||
*
|
||||
@ -395,42 +371,6 @@ int i2s_read_bytes(i2s_port_t i2s_num, void *dest, size_t size, TickType_t ticks
|
||||
*/
|
||||
esp_err_t i2s_read(i2s_port_t i2s_num, void *dest, size_t size, size_t *bytes_read, TickType_t ticks_to_wait);
|
||||
|
||||
/**
|
||||
* @brief Write a single sample to the I2S DMA TX buffer.
|
||||
*
|
||||
* This function is deprecated. Use 'i2s_write' instead.
|
||||
* This definition will be removed in a future release.
|
||||
*
|
||||
* @param i2s_num I2S_NUM_0, I2S_NUM_1
|
||||
*
|
||||
* @param sample Buffer to read data. Size of buffer (in bytes) = bits_per_sample / 8.
|
||||
*
|
||||
* @param ticks_to_wait Timeout in RTOS ticks. If a sample is not available in the DMA buffer within this period, no data is read and function returns zero.
|
||||
*
|
||||
* @return
|
||||
* - Number of bytes successfully pushed to DMA buffer, will be either zero or the size of configured sample buffer (in bytes).
|
||||
* - ESP_FAIL Parameter error
|
||||
*/
|
||||
int i2s_push_sample(i2s_port_t i2s_num, const void *sample, TickType_t ticks_to_wait) __attribute__ ((deprecated));
|
||||
|
||||
/**
|
||||
* @brief Read a single sample from the I2S DMA RX buffer.
|
||||
*
|
||||
* This function is deprecated. Use 'i2s_read' instead.
|
||||
* This definition will be removed in a future release.
|
||||
*
|
||||
* @param i2s_num I2S_NUM_0, I2S_NUM_1
|
||||
*
|
||||
* @param sample Buffer to write data. Size of buffer (in bytes) = bits_per_sample / 8.
|
||||
*
|
||||
* @param ticks_to_wait Timeout in RTOS ticks. If a sample is not available in the DMA buffer within this period, no data is read and function returns zero.
|
||||
*
|
||||
* @return
|
||||
* - Number of bytes successfully read from DMA buffer, will be either zero or the size of configured sample buffer (in bytes).
|
||||
* - ESP_FAIL Parameter error
|
||||
*/
|
||||
int i2s_pop_sample(i2s_port_t i2s_num, void *sample, TickType_t ticks_to_wait) __attribute__ ((deprecated));
|
||||
|
||||
/**
|
||||
* @brief Set sample rate used for I2S RX and TX.
|
||||
*
|
||||
|
@ -130,10 +130,7 @@ typedef struct {
|
||||
*/
|
||||
typedef struct {
|
||||
ledc_mode_t speed_mode; /*!< LEDC speed speed_mode, high-speed mode or low-speed mode */
|
||||
union {
|
||||
ledc_timer_bit_t duty_resolution; /*!< LEDC channel duty resolution */
|
||||
ledc_timer_bit_t bit_num __attribute__((deprecated)); /*!< Deprecated in ESP-IDF 3.0. This is an alias to 'duty_resolution' for backward compatibility with ESP-IDF 2.1 */
|
||||
};
|
||||
ledc_timer_t timer_num; /*!< The timer source of channel (0 - 3) */
|
||||
uint32_t freq_hz; /*!< LEDC timer frequency (Hz) */
|
||||
ledc_clk_cfg_t clk_cfg; /*!< Configure LEDC source clock.
|
||||
|
@ -430,21 +430,6 @@ typedef void (* filter_cb_t)(uint16_t *raw_value, uint16_t *filtered_value);
|
||||
*/
|
||||
esp_err_t touch_pad_set_filter_read_cb(filter_cb_t read_cb);
|
||||
|
||||
/**
|
||||
* @brief Register touch-pad ISR,
|
||||
* @note Deprecated function, users should replace this with touch_pad_isr_register,
|
||||
* because RTC modules share a same interrupt index.
|
||||
* @param fn Pointer to ISR handler
|
||||
* @param arg Parameter for ISR
|
||||
* @param unused Reserved, not used
|
||||
* @param handle_unused Reserved, not used
|
||||
* @return
|
||||
* - ESP_OK Success ;
|
||||
* - ESP_ERR_INVALID_ARG GPIO error
|
||||
* - ESP_ERR_NO_MEM No memory
|
||||
*/
|
||||
esp_err_t touch_pad_isr_handler_register(void(*fn)(void *), void *arg, int unused, intr_handle_t *handle_unused) __attribute__ ((deprecated));
|
||||
|
||||
/**
|
||||
* @brief Register touch-pad ISR.
|
||||
* The handler will be attached to the same CPU core that this function is running on.
|
||||
|
@ -1901,11 +1901,6 @@ int adc1_get_raw(adc1_channel_t channel)
|
||||
return adc_value;
|
||||
}
|
||||
|
||||
int adc1_get_voltage(adc1_channel_t channel) //Deprecated. Use adc1_get_raw(void) instead
|
||||
{
|
||||
return adc1_get_raw(channel);
|
||||
}
|
||||
|
||||
void adc1_ulp_enable(void)
|
||||
{
|
||||
adc_power_on();
|
||||
@ -2223,35 +2218,6 @@ esp_err_t dac_output_voltage(dac_channel_t channel, uint8_t dac_value)
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
esp_err_t dac_out_voltage(dac_channel_t channel, uint8_t dac_value)
|
||||
{
|
||||
RTC_MODULE_CHECK((channel >= DAC_CHANNEL_1) && (channel < DAC_CHANNEL_MAX), DAC_ERR_STR_CHANNEL_ERROR, ESP_ERR_INVALID_ARG);
|
||||
portENTER_CRITICAL(&rtc_spinlock);
|
||||
//Disable Tone
|
||||
CLEAR_PERI_REG_MASK(SENS_SAR_DAC_CTRL1_REG, SENS_SW_TONE_EN);
|
||||
|
||||
//Disable Channel Tone
|
||||
if (channel == DAC_CHANNEL_1) {
|
||||
CLEAR_PERI_REG_MASK(SENS_SAR_DAC_CTRL2_REG, SENS_DAC_CW_EN1_M);
|
||||
} else if (channel == DAC_CHANNEL_2) {
|
||||
CLEAR_PERI_REG_MASK(SENS_SAR_DAC_CTRL2_REG, SENS_DAC_CW_EN2_M);
|
||||
}
|
||||
|
||||
//Set the Dac value
|
||||
if (channel == DAC_CHANNEL_1) {
|
||||
SET_PERI_REG_BITS(RTC_IO_PAD_DAC1_REG, RTC_IO_PDAC1_DAC, dac_value, RTC_IO_PDAC1_DAC_S); //dac_output
|
||||
} else if (channel == DAC_CHANNEL_2) {
|
||||
SET_PERI_REG_BITS(RTC_IO_PAD_DAC2_REG, RTC_IO_PDAC2_DAC, dac_value, RTC_IO_PDAC2_DAC_S); //dac_output
|
||||
}
|
||||
|
||||
portEXIT_CRITICAL(&rtc_spinlock);
|
||||
//dac pad init
|
||||
dac_rtc_pad_init(channel);
|
||||
dac_output_enable(channel);
|
||||
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
esp_err_t dac_i2s_enable(void)
|
||||
{
|
||||
portENTER_CRITICAL(&rtc_spinlock);
|
||||
|
@ -82,7 +82,7 @@ static void timer_frequency_test(ledc_channel_t channel, ledc_timer_bit_t timer_
|
||||
};
|
||||
ledc_timer_config_t ledc_time_config = {
|
||||
.speed_mode = speed_mode,
|
||||
.bit_num = timer_bit,
|
||||
.duty_resolution = timer_bit,
|
||||
.timer_num = timer,
|
||||
.freq_hz = 5000,
|
||||
.clk_cfg = LEDC_AUTO_CLK,
|
||||
@ -123,7 +123,7 @@ static void timer_duty_test(ledc_channel_t channel, ledc_timer_bit_t timer_bit,
|
||||
};
|
||||
ledc_timer_config_t ledc_time_config = {
|
||||
.speed_mode = speed_mode,
|
||||
.bit_num = timer_bit,
|
||||
.duty_resolution = timer_bit,
|
||||
.timer_num = timer,
|
||||
.freq_hz = 5000,
|
||||
.clk_cfg = LEDC_AUTO_CLK,
|
||||
@ -227,7 +227,7 @@ TEST_CASE("LEDC normal channel and timer config", "[ledc][test_env=UT_T1_LEDC]")
|
||||
|
||||
ledc_timer_config_t ledc_time_config = {
|
||||
.speed_mode = LEDC_HIGH_SPEED_MODE,
|
||||
.bit_num = LEDC_TIMER_13_BIT,
|
||||
.duty_resolution = LEDC_TIMER_13_BIT,
|
||||
.timer_num = LEDC_TIMER_0,
|
||||
.freq_hz = 5000,
|
||||
.clk_cfg = LEDC_AUTO_CLK,
|
||||
@ -297,7 +297,7 @@ TEST_CASE("LEDC timer set", "[ledc][test_env=UT_T1_LEDC]")
|
||||
|
||||
ledc_timer_config_t ledc_time_config = {
|
||||
.speed_mode = LEDC_HIGH_SPEED_MODE,
|
||||
.bit_num = 13,
|
||||
.duty_resolution = 13,
|
||||
.timer_num = LEDC_TIMER_0,
|
||||
.freq_hz = 5000,
|
||||
.clk_cfg = LEDC_AUTO_CLK,
|
||||
|
@ -385,7 +385,7 @@ menu "ESP32-specific"
|
||||
|
||||
config ESP32_DEBUG_STUBS_ENABLE
|
||||
bool "OpenOCD debug stubs"
|
||||
default COMPILER_OPTIMIZATION_LEVEL_DEBUG
|
||||
default COMPILER_OPTIMIZATION_DEFAULT
|
||||
depends on !ESP32_TRAX
|
||||
help
|
||||
Debug stubs are used by OpenOCD to execute pre-compiled onboard code which does some useful debugging,
|
||||
|
@ -43,7 +43,7 @@
|
||||
#include "sdkconfig.h"
|
||||
#include "esp_system.h"
|
||||
#include "esp_spi_flash.h"
|
||||
#include "esp_flash.h"
|
||||
#include "esp_flash_internal.h"
|
||||
#include "nvs_flash.h"
|
||||
#include "esp_event.h"
|
||||
#include "esp_spi_flash.h"
|
||||
@ -395,20 +395,9 @@ void start_cpu0_default(void)
|
||||
/* init default OS-aware flash access critical section */
|
||||
spi_flash_guard_set(&g_flash_guard_default_ops);
|
||||
|
||||
#ifndef CONFIG_SPI_FLASH_USE_LEGACY_IMPL
|
||||
esp_flash_app_init();
|
||||
esp_err_t flash_ret = esp_flash_init_default_chip();
|
||||
assert(flash_ret == ESP_OK);
|
||||
#endif
|
||||
|
||||
uint8_t revision = esp_efuse_get_chip_ver();
|
||||
ESP_LOGI(TAG, "Chip Revision: %d", revision);
|
||||
if (revision > CONFIG_ESP32_REV_MIN) {
|
||||
ESP_LOGW(TAG, "Chip revision is higher than the one configured in menuconfig. Suggest to upgrade it.");
|
||||
} else if(revision != CONFIG_ESP32_REV_MIN) {
|
||||
ESP_LOGE(TAG, "ESP-IDF can't support this chip revision. Modify minimum supported revision in menuconfig");
|
||||
abort();
|
||||
}
|
||||
|
||||
#ifdef CONFIG_PM_ENABLE
|
||||
esp_pm_impl_init();
|
||||
|
@ -31,9 +31,7 @@ extern "C" {
|
||||
* Pass a pointer to this structure as an argument to esp_pm_configure function.
|
||||
*/
|
||||
typedef struct {
|
||||
rtc_cpu_freq_t max_cpu_freq __attribute__((deprecated)); /*!< Maximum CPU frequency to use. Deprecated, use max_freq_mhz instead. */
|
||||
int max_freq_mhz; /*!< Maximum CPU frequency, in MHz */
|
||||
rtc_cpu_freq_t min_cpu_freq __attribute__((deprecated)); /*!< Minimum CPU frequency to use when no frequency locks are taken. Deprecated, use min_freq_mhz instead. */
|
||||
int min_freq_mhz; /*!< Minimum CPU frequency to use when no locks are taken, in MHz */
|
||||
bool light_sleep_enable; /*!< Enter light sleep when no locks are taken */
|
||||
} esp_pm_config_esp32_t;
|
||||
|
@ -295,16 +295,6 @@ esp_err_t esp_light_sleep_start(void);
|
||||
*/
|
||||
void esp_deep_sleep(uint64_t time_in_us) __attribute__((noreturn));
|
||||
|
||||
/**
|
||||
* @brief Enter deep-sleep mode
|
||||
*
|
||||
* Function has been renamed to esp_deep_sleep.
|
||||
* This name is deprecated and will be removed in a future version.
|
||||
*
|
||||
* @param time_in_us deep-sleep time, unit: microsecond
|
||||
*/
|
||||
void system_deep_sleep(uint64_t time_in_us) __attribute__((noreturn, deprecated));
|
||||
|
||||
|
||||
/**
|
||||
* @brief Get the wakeup source which caused wakeup from sleep
|
||||
|
@ -182,15 +182,6 @@ esp_err_t esp_pm_configure(const void* vconfig)
|
||||
int min_freq_mhz = config->min_freq_mhz;
|
||||
int max_freq_mhz = config->max_freq_mhz;
|
||||
|
||||
if (min_freq_mhz == 0 && max_freq_mhz == 0) {
|
||||
/* For compatibility, handle deprecated fields, min_cpu_freq and max_cpu_freq. */
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
|
||||
min_freq_mhz = rtc_clk_cpu_freq_value(config->min_cpu_freq) / MHZ;
|
||||
max_freq_mhz = rtc_clk_cpu_freq_value(config->max_cpu_freq) / MHZ;
|
||||
#pragma GCC diagnostic pop
|
||||
}
|
||||
|
||||
if (min_freq_mhz > max_freq_mhz) {
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
@ -360,8 +360,6 @@ esp_err_t esp_light_sleep_start(void)
|
||||
return err;
|
||||
}
|
||||
|
||||
void system_deep_sleep(uint64_t) __attribute__((alias("esp_deep_sleep")));
|
||||
|
||||
esp_err_t esp_sleep_disable_wakeup_source(esp_sleep_source_t source)
|
||||
{
|
||||
// For most of sources it is enough to set trigger mask in local
|
||||
|
@ -47,10 +47,6 @@ static uint8_t base_mac_addr[6] = { 0 };
|
||||
#define SHUTDOWN_HANDLERS_NO 2
|
||||
static shutdown_handler_t shutdown_handlers[SHUTDOWN_HANDLERS_NO];
|
||||
|
||||
void system_init(void)
|
||||
{
|
||||
}
|
||||
|
||||
esp_err_t esp_base_mac_addr_set(uint8_t *mac)
|
||||
{
|
||||
if (mac == NULL) {
|
||||
@ -122,9 +118,6 @@ esp_err_t esp_efuse_mac_get_default(uint8_t* mac)
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
esp_err_t system_efuse_read_mac(uint8_t *mac) __attribute__((alias("esp_efuse_mac_get_default")));
|
||||
esp_err_t esp_efuse_read_mac(uint8_t *mac) __attribute__((alias("esp_efuse_mac_get_default")));
|
||||
|
||||
esp_err_t esp_derive_local_mac(uint8_t* local_mac, const uint8_t* universal_mac)
|
||||
{
|
||||
uint8_t idx;
|
||||
@ -344,8 +337,6 @@ void IRAM_ATTR esp_restart_noos(void)
|
||||
}
|
||||
}
|
||||
|
||||
void system_restart(void) __attribute__((alias("esp_restart")));
|
||||
|
||||
uint32_t esp_get_free_heap_size( void )
|
||||
{
|
||||
return heap_caps_get_free_size( MALLOC_CAP_DEFAULT );
|
||||
@ -356,13 +347,6 @@ uint32_t esp_get_minimum_free_heap_size( void )
|
||||
return heap_caps_get_minimum_free_size( MALLOC_CAP_DEFAULT );
|
||||
}
|
||||
|
||||
uint32_t system_get_free_heap_size(void) __attribute__((alias("esp_get_free_heap_size")));
|
||||
|
||||
const char* system_get_sdk_version(void)
|
||||
{
|
||||
return "master";
|
||||
}
|
||||
|
||||
const char* esp_get_idf_version(void)
|
||||
{
|
||||
return IDF_VER;
|
||||
|
@ -387,46 +387,3 @@ esp_err_t esp_task_wdt_status(TaskHandle_t handle)
|
||||
portEXIT_CRITICAL(&twdt_spinlock);
|
||||
return ESP_ERR_NOT_FOUND;
|
||||
}
|
||||
|
||||
void esp_task_wdt_feed(void)
|
||||
{
|
||||
portENTER_CRITICAL(&twdt_spinlock);
|
||||
//Return immediately if TWDT has not been initialized
|
||||
ASSERT_EXIT_CRIT_RETURN((twdt_config != NULL), VOID_RETURN);
|
||||
|
||||
//Check if task is on list
|
||||
TaskHandle_t handle = xTaskGetCurrentTaskHandle();
|
||||
bool all_reset;
|
||||
twdt_task_t *target_task = find_task_in_twdt_list(handle, &all_reset);
|
||||
|
||||
//reset the task if it's on the list, then return
|
||||
if(target_task != NULL){
|
||||
target_task->has_reset = true;
|
||||
if(all_reset){
|
||||
reset_hw_timer(); //Reset hardware timer if all other tasks have reset
|
||||
}
|
||||
portEXIT_CRITICAL(&twdt_spinlock);
|
||||
return;
|
||||
}
|
||||
|
||||
//Add task if it's has not on list
|
||||
target_task = calloc(1, sizeof(twdt_task_t));
|
||||
ASSERT_EXIT_CRIT_RETURN((target_task != NULL), VOID_RETURN); //If calloc failed
|
||||
target_task->task_handle = handle;
|
||||
target_task->has_reset = true;
|
||||
target_task->next = NULL;
|
||||
|
||||
if (twdt_config->list == NULL) { //Adding to empty list
|
||||
twdt_config->list = target_task;
|
||||
} else { //Adding to tail of list
|
||||
twdt_task_t *task;
|
||||
for (task = twdt_config->list; task->next != NULL; task = task->next){
|
||||
; //point task to current tail of wdt task list
|
||||
}
|
||||
task->next = target_task;
|
||||
}
|
||||
|
||||
portEXIT_CRITICAL(&twdt_spinlock);
|
||||
}
|
||||
|
||||
|
||||
|
@ -15,6 +15,8 @@
|
||||
#include "esp32/ulp.h"
|
||||
#include "soc/rtc_periph.h"
|
||||
|
||||
#define MHZ 1000000
|
||||
|
||||
TEST_CASE("Can dump power management lock stats", "[pm]")
|
||||
{
|
||||
esp_pm_dump_locks(stdout);
|
||||
@ -31,15 +33,15 @@ static void switch_freq(int mhz)
|
||||
};
|
||||
ESP_ERROR_CHECK( esp_pm_configure(&pm_config) );
|
||||
printf("Waiting for frequency to be set to %d MHz...\n", mhz);
|
||||
while (esp_clk_cpu_freq() / 1000000 != mhz) {
|
||||
while (esp_clk_cpu_freq() / MHZ != mhz) {
|
||||
vTaskDelay(pdMS_TO_TICKS(200));
|
||||
printf("Frequency is %d MHz\n", esp_clk_cpu_freq() / 1000000);
|
||||
printf("Frequency is %d MHz\n", esp_clk_cpu_freq() / MHZ);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("Can switch frequency using esp_pm_configure", "[pm]")
|
||||
{
|
||||
int orig_freq_mhz = esp_clk_cpu_freq() / 1000000;
|
||||
int orig_freq_mhz = esp_clk_cpu_freq() / MHZ;
|
||||
switch_freq(240);
|
||||
switch_freq(40);
|
||||
switch_freq(160);
|
||||
@ -60,9 +62,12 @@ TEST_CASE("Can switch frequency using esp_pm_configure", "[pm]")
|
||||
|
||||
static void light_sleep_enable(void)
|
||||
{
|
||||
int cur_freq_mhz = esp_clk_cpu_freq() / MHZ;
|
||||
int xtal_freq = (int) rtc_clk_xtal_freq_get();
|
||||
|
||||
const esp_pm_config_esp32_t pm_config = {
|
||||
.max_cpu_freq = rtc_clk_cpu_freq_get(),
|
||||
.min_cpu_freq = RTC_CPU_FREQ_XTAL,
|
||||
.max_freq_mhz = cur_freq_mhz,
|
||||
.min_freq_mhz = xtal_freq,
|
||||
.light_sleep_enable = true
|
||||
};
|
||||
ESP_ERROR_CHECK( esp_pm_configure(&pm_config) );
|
||||
@ -70,9 +75,11 @@ static void light_sleep_enable(void)
|
||||
|
||||
static void light_sleep_disable(void)
|
||||
{
|
||||
int cur_freq_mhz = esp_clk_cpu_freq() / MHZ;
|
||||
|
||||
const esp_pm_config_esp32_t pm_config = {
|
||||
.max_cpu_freq = rtc_clk_cpu_freq_get(),
|
||||
.min_cpu_freq = rtc_clk_cpu_freq_get(),
|
||||
.max_freq_mhz = cur_freq_mhz,
|
||||
.min_freq_mhz = cur_freq_mhz,
|
||||
};
|
||||
ESP_ERROR_CHECK( esp_pm_configure(&pm_config) );
|
||||
}
|
||||
|
@ -390,23 +390,3 @@ esp_err_t esp_adc_cal_get_voltage(adc_channel_t channel,
|
||||
*voltage = esp_adc_cal_raw_to_voltage((uint32_t)adc_reading, chars);
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
/* ------------------------ Deprecated API --------------------------------- */
|
||||
void esp_adc_cal_get_characteristics(uint32_t vref,
|
||||
adc_atten_t atten,
|
||||
adc_bits_width_t bit_width,
|
||||
esp_adc_cal_characteristics_t *chars)
|
||||
{
|
||||
assert(chars != NULL);
|
||||
esp_adc_cal_characterize(ADC_UNIT_1, atten, bit_width, vref, chars);
|
||||
}
|
||||
|
||||
uint32_t adc1_to_voltage(adc1_channel_t channel, const esp_adc_cal_characteristics_t *chars)
|
||||
{
|
||||
assert(chars != NULL);
|
||||
uint32_t voltage = 0;
|
||||
esp_adc_cal_get_voltage((adc_channel_t)channel, chars, &voltage);
|
||||
return voltage;
|
||||
}
|
||||
|
||||
|
||||
|
@ -127,24 +127,6 @@ uint32_t esp_adc_cal_raw_to_voltage(uint32_t adc_reading, const esp_adc_cal_char
|
||||
*/
|
||||
esp_err_t esp_adc_cal_get_voltage(adc_channel_t channel, const esp_adc_cal_characteristics_t *chars, uint32_t *voltage);
|
||||
|
||||
/* -------------------------- Deprecated API ------------------------------- */
|
||||
|
||||
/** @cond */ //Doxygen command to hide deprecated function from API Reference
|
||||
/**
|
||||
* @deprecated ADC1 characterization function. Deprecated in order to accommodate
|
||||
* ADC2 and eFuse functionality. Use esp_adc_cal_characterize() instead
|
||||
*/
|
||||
void esp_adc_cal_get_characteristics(uint32_t vref, adc_atten_t atten, adc_bits_width_t bit_width, esp_adc_cal_characteristics_t *chars) __attribute__((deprecated));
|
||||
|
||||
/*
|
||||
* @deprecated This function reads ADC1 and returns the corrected voltage. This
|
||||
* has been deprecated in order to accommodate ADC2 support. Use the
|
||||
* new function esp_adc_cal_get_voltage() instead.
|
||||
*/
|
||||
uint32_t adc1_to_voltage(adc1_channel_t channel, const esp_adc_cal_characteristics_t *chars) __attribute__((deprecated));
|
||||
|
||||
/** @endcond */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -62,22 +62,6 @@ typedef enum {
|
||||
ESP_RST_SDIO, //!< Reset over SDIO
|
||||
} esp_reset_reason_t;
|
||||
|
||||
/** @cond */
|
||||
/**
|
||||
* @attention Applications don't need to call this function anymore. It does nothing and will
|
||||
* be removed in future version.
|
||||
*/
|
||||
void system_init(void) __attribute__ ((deprecated));
|
||||
|
||||
/**
|
||||
* @brief Reset to default settings.
|
||||
*
|
||||
* Function has been deprecated, please use esp_wifi_restore instead.
|
||||
* This name will be removed in a future release.
|
||||
*/
|
||||
void system_restore(void) __attribute__ ((deprecated));
|
||||
/** @endcond */
|
||||
|
||||
/**
|
||||
* Shutdown handler type
|
||||
*/
|
||||
@ -117,32 +101,12 @@ esp_err_t esp_unregister_shutdown_handler(shutdown_handler_t handle);
|
||||
*/
|
||||
void esp_restart(void) __attribute__ ((noreturn));
|
||||
|
||||
/** @cond */
|
||||
/**
|
||||
* @brief Restart system.
|
||||
*
|
||||
* Function has been renamed to esp_restart.
|
||||
* This name will be removed in a future release.
|
||||
*/
|
||||
void system_restart(void) __attribute__ ((deprecated, noreturn));
|
||||
/** @endcond */
|
||||
|
||||
/**
|
||||
* @brief Get reason of last reset
|
||||
* @return See description of esp_reset_reason_t for explanation of each value.
|
||||
*/
|
||||
esp_reset_reason_t esp_reset_reason(void);
|
||||
|
||||
/** @cond */
|
||||
/**
|
||||
* @brief Get system time, unit: microsecond.
|
||||
*
|
||||
* This function is deprecated. Use 'gettimeofday' function for 64-bit precision.
|
||||
* This definition will be removed in a future release.
|
||||
*/
|
||||
uint32_t system_get_time(void) __attribute__ ((deprecated));
|
||||
/** @endcond */
|
||||
|
||||
/**
|
||||
* @brief Get the size of available heap.
|
||||
*
|
||||
@ -153,18 +117,6 @@ uint32_t system_get_time(void) __attribute__ ((deprecated));
|
||||
*/
|
||||
uint32_t esp_get_free_heap_size(void);
|
||||
|
||||
/** @cond */
|
||||
/**
|
||||
* @brief Get the size of available heap.
|
||||
*
|
||||
* Function has been renamed to esp_get_free_heap_size.
|
||||
* This name will be removed in a future release.
|
||||
*
|
||||
* @return Available heap size, in bytes.
|
||||
*/
|
||||
uint32_t system_get_free_heap_size(void) __attribute__ ((deprecated));
|
||||
/** @endcond */
|
||||
|
||||
/**
|
||||
* @brief Get the minimum heap that has ever been available
|
||||
*
|
||||
@ -250,31 +202,6 @@ esp_err_t esp_efuse_mac_get_custom(uint8_t *mac);
|
||||
*/
|
||||
esp_err_t esp_efuse_mac_get_default(uint8_t *mac);
|
||||
|
||||
/** @cond */
|
||||
/**
|
||||
* @brief Read hardware MAC address from efuse.
|
||||
*
|
||||
* Function has been renamed to esp_efuse_mac_get_default.
|
||||
* This name will be removed in a future release.
|
||||
*
|
||||
* @param mac hardware MAC address, length: 6 bytes.
|
||||
*
|
||||
* @return ESP_OK on success
|
||||
*/
|
||||
esp_err_t esp_efuse_read_mac(uint8_t *mac) __attribute__ ((deprecated));
|
||||
|
||||
/**
|
||||
* @brief Read hardware MAC address.
|
||||
*
|
||||
* Function has been renamed to esp_efuse_mac_get_default.
|
||||
* This name will be removed in a future release.
|
||||
*
|
||||
* @param mac hardware MAC address, length: 6 bytes.
|
||||
* @return ESP_OK on success
|
||||
*/
|
||||
esp_err_t system_efuse_read_mac(uint8_t *mac) __attribute__ ((deprecated));
|
||||
/** @endcond */
|
||||
|
||||
/**
|
||||
* @brief Read base MAC address and set MAC address of the interface.
|
||||
*
|
||||
@ -305,17 +232,6 @@ esp_err_t esp_read_mac(uint8_t* mac, esp_mac_type_t type);
|
||||
*/
|
||||
esp_err_t esp_derive_local_mac(uint8_t* local_mac, const uint8_t* universal_mac);
|
||||
|
||||
/** @cond */
|
||||
/**
|
||||
* Get SDK version
|
||||
*
|
||||
* This function is deprecated and will be removed in a future release.
|
||||
*
|
||||
* @return constant string "master"
|
||||
*/
|
||||
const char* system_get_sdk_version(void) __attribute__ ((deprecated));
|
||||
/** @endcond */
|
||||
|
||||
/**
|
||||
* @brief Chip models
|
||||
*/
|
||||
|
@ -141,22 +141,6 @@ esp_err_t esp_task_wdt_delete(TaskHandle_t handle);
|
||||
*/
|
||||
esp_err_t esp_task_wdt_status(TaskHandle_t handle);
|
||||
|
||||
/**
|
||||
* @brief Reset the TWDT on behalf of the current running task, or
|
||||
* subscribe the TWDT to if it has not done so already
|
||||
*
|
||||
* @warning This function is deprecated, use esp_task_wdt_add() and
|
||||
* esp_task_wdt_reset() instead
|
||||
*
|
||||
* This function is similar to esp_task_wdt_reset() and will reset the TWDT on
|
||||
* behalf of the current running task. However if this task has not subscribed
|
||||
* to the TWDT, this function will automatically subscribe the task. Therefore,
|
||||
* an unsubscribed task will subscribe to the TWDT on its first call to this
|
||||
* function, then proceed to reset the TWDT on subsequent calls of this
|
||||
* function.
|
||||
*/
|
||||
void esp_task_wdt_feed(void) __attribute__ ((deprecated));
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -390,10 +390,10 @@ static esp_err_t dm9051_verify_id(emac_dm9051_t *emac)
|
||||
uint8_t id[2];
|
||||
MAC_CHECK(dm9051_register_read(emac, DM9051_VIDL, &id[0]) == ESP_OK, "read VIDL failed", err, ESP_FAIL);
|
||||
MAC_CHECK(dm9051_register_read(emac, DM9051_VIDH, &id[1]) == ESP_OK, "read VIDH failed", err, ESP_FAIL);
|
||||
MAC_CHECK(0x0A46 == *(uint16_t *)id, "wrong Vendor ID", err, ESP_ERR_INVALID_VERSION);
|
||||
MAC_CHECK(0x0A == id[1] && 0x46 == id[0], "wrong Vendor ID", err, ESP_ERR_INVALID_VERSION);
|
||||
MAC_CHECK(dm9051_register_read(emac, DM9051_PIDL, &id[0]) == ESP_OK, "read PIDL failed", err, ESP_FAIL);
|
||||
MAC_CHECK(dm9051_register_read(emac, DM9051_PIDH, &id[1]) == ESP_OK, "read PIDH failed", err, ESP_FAIL);
|
||||
MAC_CHECK(0x9051 == *(uint16_t *)id, "wrong Product ID", err, ESP_ERR_INVALID_VERSION);
|
||||
MAC_CHECK(0x90 == id[1] && 0x51 == id[0], "wrong Product ID", err, ESP_ERR_INVALID_VERSION);
|
||||
return ESP_OK;
|
||||
err:
|
||||
return ret;
|
||||
|
@ -514,10 +514,6 @@ void vRingbufferGetInfo(RingbufHandle_t xRingbuffer,
|
||||
*/
|
||||
void xRingbufferPrintInfo(RingbufHandle_t xRingbuffer);
|
||||
|
||||
/* ------------------------------- Deprecated ------------------------------- */
|
||||
|
||||
typedef RingbufferType_t ringbuf_type_t __attribute__((deprecated));
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -12,7 +12,6 @@ idf_component_register(SRCS "src/coexist.c"
|
||||
"src/lib_printf.c"
|
||||
"src/mesh_event.c"
|
||||
"src/phy_init.c"
|
||||
"src/restore.c"
|
||||
"src/smartconfig.c"
|
||||
"src/smartconfig_ack.c"
|
||||
"src/wifi_init.c"
|
||||
|
@ -813,32 +813,6 @@ esp_err_t esp_wifi_ap_get_sta_list(wifi_sta_list_t *sta);
|
||||
*/
|
||||
esp_err_t esp_wifi_set_storage(wifi_storage_t storage);
|
||||
|
||||
/**
|
||||
* @brief Set auto connect
|
||||
* The default value is true
|
||||
*
|
||||
* @param en : true - enable auto connect / false - disable auto connect
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: succeed
|
||||
* - ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init
|
||||
* - ESP_ERR_WIFI_MODE: WiFi internal error, the station/soft-AP control block is invalid
|
||||
* - others: refer to error code in esp_err.h
|
||||
*/
|
||||
esp_err_t esp_wifi_set_auto_connect(bool en) __attribute__ ((deprecated));
|
||||
|
||||
/**
|
||||
* @brief Get the auto connect flag
|
||||
*
|
||||
* @param[out] en store current auto connect configuration
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: succeed
|
||||
* - ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init
|
||||
* - ESP_ERR_INVALID_ARG: invalid argument
|
||||
*/
|
||||
esp_err_t esp_wifi_get_auto_connect(bool *en) __attribute__ ((deprecated));
|
||||
|
||||
/**
|
||||
* @brief Function signature for received Vendor-Specific Information Element callback.
|
||||
* @param ctx Context argument, as passed to esp_wifi_set_vendor_ie_cb() when registering callback.
|
||||
|
@ -181,9 +181,7 @@ typedef enum {
|
||||
typedef struct {
|
||||
int8_t rssi; /**< The minimum rssi to accept in the fast scan mode */
|
||||
wifi_auth_mode_t authmode; /**< The weakest authmode to accept in the fast scan mode */
|
||||
}wifi_fast_scan_threshold_t;
|
||||
|
||||
typedef wifi_fast_scan_threshold_t wifi_scan_threshold_t; /**< wifi_fast_scan_threshold_t only used in fast scan mode once, now it enabled in all channel scan, the wifi_fast_scan_threshold_t will be remove in version 4.0 */
|
||||
}wifi_scan_threshold_t;
|
||||
|
||||
typedef enum {
|
||||
WIFI_PS_NONE, /**< No power save */
|
||||
@ -191,8 +189,6 @@ typedef enum {
|
||||
WIFI_PS_MAX_MODEM, /**< Maximum modem power saving. In this mode, interval to receive beacons is determined by the listen_interval parameter in wifi_sta_config_t */
|
||||
} wifi_ps_type_t;
|
||||
|
||||
#define WIFI_PS_MODEM WIFI_PS_MIN_MODEM /**< @deprecated Use WIFI_PS_MIN_MODEM or WIFI_PS_MAX_MODEM instead */
|
||||
|
||||
#define WIFI_PROTOCOL_11B 1
|
||||
#define WIFI_PROTOCOL_11G 2
|
||||
#define WIFI_PROTOCOL_11N 4
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit 7d93cbf05bb521520700b2cbcc8e104d9cb9efec
|
||||
Subproject commit 3ea3a8f30c6cd5b29ccfb8b9b74d3e6741bdc1c2
|
@ -1,24 +0,0 @@
|
||||
// Copyright 2013-2017 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 "esp_system.h"
|
||||
#include "esp_wifi.h"
|
||||
|
||||
/* This function is in a separate file from the reset of system APIs because
|
||||
* it causes link time dependency on WiFi stack.
|
||||
*/
|
||||
void system_restore(void)
|
||||
{
|
||||
esp_wifi_restore();
|
||||
}
|
@ -13,7 +13,6 @@ menu "Core dump"
|
||||
config ESP32_ENABLE_COREDUMP_TO_FLASH
|
||||
bool "Flash"
|
||||
select ESP32_ENABLE_COREDUMP
|
||||
select SPI_FLASH_USE_LEGACY_IMPL
|
||||
config ESP32_ENABLE_COREDUMP_TO_UART
|
||||
bool "UART"
|
||||
select ESP32_ENABLE_COREDUMP
|
||||
|
@ -8,3 +8,12 @@ entries:
|
||||
core_dump_port (noflash_text)
|
||||
else:
|
||||
* (default)
|
||||
|
||||
[mapping:spi_flash_override]
|
||||
archive: libspi_flash.a
|
||||
entries:
|
||||
if ESP_PANIC_HANDLER_IRAM = y && ESP32_ENABLE_COREDUMP_TO_FLASH = y:
|
||||
esp_flash_api (noflash_text)
|
||||
esp_flash_spi_init (noflash_text)
|
||||
else:
|
||||
* (default)
|
||||
|
@ -15,6 +15,9 @@
|
||||
#include "esp32/rom/crc.h"
|
||||
#include "esp_partition.h"
|
||||
#include "esp_core_dump_priv.h"
|
||||
#include "esp_flash_internal.h"
|
||||
|
||||
#include "sdkconfig.h"
|
||||
|
||||
const static DRAM_ATTR char TAG[] __attribute__((unused)) = "esp_core_dump_flash";
|
||||
|
||||
@ -82,7 +85,11 @@ static uint32_t esp_core_dump_write_flash_padded(size_t off, uint8_t *data, uint
|
||||
assert((off + data_len + (data_size % sizeof(uint32_t) ? sizeof(uint32_t) : 0)) <=
|
||||
s_core_flash_config.partition.start + s_core_flash_config.partition.size);
|
||||
|
||||
#ifdef CONFIG_SPI_FLASH_USE_LEGACY_IMPL
|
||||
err = spi_flash_write(off, data, data_len);
|
||||
#else
|
||||
err = esp_flash_write(esp_flash_default_chip, data, off, data_len);
|
||||
#endif
|
||||
if (err != ESP_OK) {
|
||||
ESP_COREDUMP_LOGE("Failed to write data to flash (%d)!", err);
|
||||
return 0;
|
||||
@ -95,7 +102,11 @@ static uint32_t esp_core_dump_write_flash_padded(size_t off, uint8_t *data, uint
|
||||
for (k = 0; k < len; k++) {
|
||||
rom_data.data8[k] = *(data + data_len + k);
|
||||
}
|
||||
#ifdef CONFIG_SPI_FLASH_USE_LEGACY_IMPL
|
||||
err = spi_flash_write(off + data_len, &rom_data, sizeof(uint32_t));
|
||||
#else
|
||||
err = esp_flash_write(esp_flash_default_chip, &rom_data, off + data_len, sizeof(uint32_t));
|
||||
#endif
|
||||
if (err != ESP_OK) {
|
||||
ESP_COREDUMP_LOGE("Failed to finish write data to flash (%d)!", err);
|
||||
return 0;
|
||||
@ -127,7 +138,11 @@ static esp_err_t esp_core_dump_flash_write_prepare(void *priv, uint32_t *data_le
|
||||
sec_num++;
|
||||
}
|
||||
assert(sec_num * SPI_FLASH_SEC_SIZE <= s_core_flash_config.partition.size);
|
||||
#ifdef CONFIG_SPI_FLASH_USE_LEGACY_IMPL
|
||||
err = spi_flash_erase_range(s_core_flash_config.partition.start + 0, sec_num * SPI_FLASH_SEC_SIZE);
|
||||
#else
|
||||
err = esp_flash_erase_region(esp_flash_default_chip, s_core_flash_config.partition.start + 0, sec_num * SPI_FLASH_SEC_SIZE);
|
||||
#endif
|
||||
if (err != ESP_OK) {
|
||||
ESP_COREDUMP_LOGE("Failed to erase flash (%d)!", err);
|
||||
return err;
|
||||
@ -141,7 +156,11 @@ static esp_err_t esp_core_dump_flash_write_word(core_dump_write_flash_data_t *wr
|
||||
uint32_t data32 = word;
|
||||
|
||||
assert(wr_data->off + sizeof(uint32_t) <= s_core_flash_config.partition.size);
|
||||
#ifdef CONFIG_SPI_FLASH_USE_LEGACY_IMPL
|
||||
err = spi_flash_write(s_core_flash_config.partition.start + wr_data->off, &data32, sizeof(uint32_t));
|
||||
#else
|
||||
err = esp_flash_write(esp_flash_default_chip, &data32, s_core_flash_config.partition.start + wr_data->off, sizeof(uint32_t));
|
||||
#endif
|
||||
if (err != ESP_OK) {
|
||||
ESP_COREDUMP_LOGE("Failed to write to flash (%d)!", err);
|
||||
return err;
|
||||
@ -166,7 +185,11 @@ static esp_err_t esp_core_dump_flash_write_end(void *priv)
|
||||
uint32_t data32[4];
|
||||
} rom_data;
|
||||
|
||||
#ifdef CONFIG_SPI_FLASH_USE_LEGACY_IMPL
|
||||
esp_err_t err = spi_flash_read(s_core_flash_config.partition.start + 0, &rom_data, sizeof(rom_data));
|
||||
#else
|
||||
esp_err_t err = esp_flash_read(esp_flash_default_chip, &rom_data, s_core_flash_config.partition.start + 0, sizeof(rom_data));
|
||||
#endif
|
||||
if (err != ESP_OK) {
|
||||
ESP_COREDUMP_LOGE("Failed to read flash (%d)!", err);
|
||||
return err;
|
||||
@ -214,10 +237,9 @@ void esp_core_dump_to_flash(XtExcFrame *frame)
|
||||
return;
|
||||
}
|
||||
|
||||
#if CONFIG_SPI_FLASH_USE_LEGACY_IMPL
|
||||
// init non-OS flash access critical section
|
||||
spi_flash_guard_set(&g_flash_guard_no_os_ops);
|
||||
#endif
|
||||
esp_flash_app_disable_protect(true);
|
||||
|
||||
memset(&wr_cfg, 0, sizeof(wr_cfg));
|
||||
wr_cfg.prepare = esp_core_dump_flash_write_prepare;
|
||||
|
@ -31,6 +31,10 @@ endif
|
||||
|
||||
ESPTOOL_ELF2IMAGE_OPTIONS :=
|
||||
|
||||
ifdef CONFIG_ESP32_REV_MIN
|
||||
ESPTOOL_ELF2IMAGE_OPTIONS += --min-rev $(CONFIG_ESP32_REV_MIN)
|
||||
endif
|
||||
|
||||
ifdef CONFIG_SECURE_BOOT_ENABLED
|
||||
ifndef CONFIG_SECURE_BOOT_ALLOW_SHORT_APP_PARTITION
|
||||
ifndef IS_BOOTLOADER_BUILD
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit 9c41a57955b3c4b3873d653ac0d87c0900b135ff
|
||||
Subproject commit ecc72c54037eeae9b95e442246b8a92696518a3b
|
@ -52,6 +52,10 @@ if(CONFIG_SECURE_BOOT_ENABLED AND
|
||||
set(ESPTOOLPY_ELF2IMAGE_OPTIONS ${ESPTOOLPY_ELF2IMAGE_OPTIONS} --secure-pad)
|
||||
endif()
|
||||
|
||||
if(CONFIG_ESP32_REV_MIN)
|
||||
set(ESPTOOLPY_ELF2IMAGE_OPTIONS ${ESPTOOLPY_ELF2IMAGE_OPTIONS} --min-rev ${CONFIG_ESP32_REV_MIN})
|
||||
endif()
|
||||
|
||||
if(CONFIG_ESPTOOLPY_FLASHSIZE_DETECT)
|
||||
# Set ESPFLASHSIZE to 'detect' *after* elf2image options are generated,
|
||||
# as elf2image can't have 'detect' as an option...
|
||||
|
@ -50,20 +50,6 @@ extern "C" {
|
||||
esp_err_t esp_vfs_fat_register(const char* base_path, const char* fat_drive,
|
||||
size_t max_files, FATFS** out_fs);
|
||||
|
||||
/**
|
||||
* @brief Un-register FATFS from VFS
|
||||
*
|
||||
* @note FATFS structure returned by esp_vfs_fat_register is destroyed after
|
||||
* this call. Make sure to call f_mount function to unmount it before
|
||||
* calling esp_vfs_fat_unregister.
|
||||
* This function is left for compatibility and will be changed in
|
||||
* future versions to accept base_path and replace the method below
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - ESP_ERR_INVALID_STATE if FATFS is not registered in VFS
|
||||
*/
|
||||
esp_err_t esp_vfs_fat_unregister(void) __attribute__((deprecated));
|
||||
|
||||
/**
|
||||
* @brief Un-register FATFS from VFS
|
||||
*
|
||||
|
@ -205,19 +205,6 @@ esp_err_t esp_vfs_fat_unregister_path(const char* base_path)
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
esp_err_t esp_vfs_fat_unregister(void)
|
||||
{
|
||||
if (s_fat_ctx == NULL) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
esp_err_t err = esp_vfs_fat_unregister_path(s_fat_ctx->base_path);
|
||||
if (err != ESP_OK) {
|
||||
return err;
|
||||
}
|
||||
s_fat_ctx = NULL;
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
static int get_next_fd(vfs_fat_ctx_t* fat_ctx)
|
||||
{
|
||||
for (size_t i = 0; i < fat_ctx->max_files; ++i) {
|
||||
|
@ -411,7 +411,7 @@ menu "FreeRTOS"
|
||||
|
||||
config FREERTOS_TASK_FUNCTION_WRAPPER
|
||||
bool "Enclose all task functions in a wrapper function"
|
||||
depends on COMPILER_OPTIMIZATION_LEVEL_DEBUG
|
||||
depends on COMPILER_OPTIMIZATION_DEFAULT
|
||||
default y
|
||||
help
|
||||
If enabled, all FreeRTOS task functions will be enclosed in a wrapper function.
|
||||
|
@ -1,35 +0,0 @@
|
||||
// Copyright 2015-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.
|
||||
#pragma once
|
||||
#warning "This header is deprecated, please use functions defined in esp_heap_caps.h instead."
|
||||
#include "esp_heap_caps.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Deprecated FreeRTOS-style esp_heap_alloc_caps.h functions follow */
|
||||
|
||||
/* Please use heap_caps_malloc() instead of this function */
|
||||
void *pvPortMallocCaps(size_t xWantedSize, uint32_t caps) asm("heap_caps_malloc") __attribute__((deprecated));
|
||||
|
||||
/* Please use heap_caps_get_minimum_free_size() instead of this function */
|
||||
size_t xPortGetMinimumEverFreeHeapSizeCaps( uint32_t caps ) asm("heap_caps_get_minimum_free_size") __attribute__((deprecated));
|
||||
|
||||
/* Please use heap_caps_get_free_size() instead of this function */
|
||||
size_t xPortGetFreeHeapSizeCaps( uint32_t caps ) asm("heap_caps_get_free_size") __attribute__((deprecated));
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
@ -464,7 +464,6 @@ test cases:
|
||||
SDK: |-
|
||||
8266_NonOS
|
||||
8266_RTOS
|
||||
ESP32_IDF
|
||||
Test App: SSC
|
||||
allow fail: ''
|
||||
auto test: 'Yes'
|
||||
@ -1069,35 +1068,6 @@ test cases:
|
||||
test point 1: basic function
|
||||
test point 2: use WiFi API after WiFi stop
|
||||
version: v1 (2016-12-31)
|
||||
- CI ready: 'Yes'
|
||||
ID: WIFI_CONN_1202
|
||||
SDK: ESP32_IDF
|
||||
Test App: SSC
|
||||
allow fail: ''
|
||||
auto test: 'Yes'
|
||||
category: Function
|
||||
cmd set:
|
||||
- ''
|
||||
- - SSC SSC1 sta -R -a 1
|
||||
- - R SSC1 C +AUTORECONN:OK
|
||||
- - SSC SSC1 sta -Q
|
||||
- - R SSC1 C +JAP:DISCONNECTED
|
||||
execution time: 0
|
||||
expected result: |
|
||||
1. OK
|
||||
2. DISCONNECTED
|
||||
initial condition: WIFISTO
|
||||
level: Integration
|
||||
module: WIFI MAC
|
||||
steps: |
|
||||
1. sta reconnect start
|
||||
2. query sta state
|
||||
sub module: WIFI Connect
|
||||
summary: sta reconnect start and connect fail after WiFi stop
|
||||
test environment: SSC_T1_5
|
||||
test point 1: basic function
|
||||
test point 2: use WiFi API after WiFi stop
|
||||
version: v1 (2016-12-31)
|
||||
- CI ready: 'Yes'
|
||||
ID: WIFI_CONN_1203
|
||||
SDK: ESP32_IDF
|
||||
|
@ -208,13 +208,6 @@ int esp_internal_aes_encrypt( esp_aes_context *ctx,
|
||||
return r;
|
||||
}
|
||||
|
||||
void esp_aes_encrypt( esp_aes_context *ctx,
|
||||
const unsigned char input[16],
|
||||
unsigned char output[16] )
|
||||
{
|
||||
esp_internal_aes_encrypt(ctx, input, output);
|
||||
}
|
||||
|
||||
/*
|
||||
* AES-ECB block decryption
|
||||
*/
|
||||
@ -237,13 +230,6 @@ int esp_internal_aes_decrypt( esp_aes_context *ctx,
|
||||
return r;
|
||||
}
|
||||
|
||||
void esp_aes_decrypt( esp_aes_context *ctx,
|
||||
const unsigned char input[16],
|
||||
unsigned char output[16] )
|
||||
{
|
||||
esp_internal_aes_decrypt(ctx, input, output);
|
||||
}
|
||||
|
||||
/*
|
||||
* AES-ECB block encryption/decryption
|
||||
*/
|
||||
|
@ -332,9 +332,6 @@ int esp_aes_xts_setkey_dec( esp_aes_xts_context *ctx,
|
||||
*/
|
||||
int esp_internal_aes_encrypt( esp_aes_context *ctx, const unsigned char input[16], unsigned char output[16] );
|
||||
|
||||
/** Deprecated, see esp_aes_internal_encrypt */
|
||||
void esp_aes_encrypt( esp_aes_context *ctx, const unsigned char input[16], unsigned char output[16] ) __attribute__((deprecated));
|
||||
|
||||
/**
|
||||
* \brief Internal AES block decryption function
|
||||
* (Only exposed to allow overriding it,
|
||||
@ -346,9 +343,6 @@ void esp_aes_encrypt( esp_aes_context *ctx, const unsigned char input[16], unsig
|
||||
*/
|
||||
int esp_internal_aes_decrypt( esp_aes_context *ctx, const unsigned char input[16], unsigned char output[16] );
|
||||
|
||||
/** Deprecated, see esp_aes_internal_decrypt */
|
||||
void esp_aes_decrypt( esp_aes_context *ctx, const unsigned char input[16], unsigned char output[16] ) __attribute__((deprecated));
|
||||
|
||||
/** AES-XTS buffer encryption/decryption */
|
||||
int esp_aes_crypt_xts( esp_aes_xts_context *ctx, int mode, size_t length, const unsigned char data_unit[16], const unsigned char *input, unsigned char *output );
|
||||
|
||||
|
@ -45,7 +45,7 @@ void Storage::populateBlobIndices(TBlobIndexList& blobIdxList)
|
||||
while (p.findItem(Page::NS_ANY, ItemType::BLOB_IDX, nullptr, itemIndex, item) == ESP_OK) {
|
||||
BlobIndexNode* entry = new BlobIndexNode;
|
||||
|
||||
item.getKey(entry->key, sizeof(entry->key) - 1);
|
||||
item.getKey(entry->key, sizeof(entry->key));
|
||||
entry->nsIndex = item.nsIndex;
|
||||
entry->chunkStart = item.blobIndex.chunkStart;
|
||||
entry->chunkCount = item.blobIndex.chunkCount;
|
||||
@ -101,7 +101,7 @@ esp_err_t Storage::init(uint32_t baseSector, uint32_t sectorCount)
|
||||
Item item;
|
||||
while (p.findItem(Page::NS_INDEX, ItemType::U8, nullptr, itemIndex, item) == ESP_OK) {
|
||||
NamespaceEntry* entry = new NamespaceEntry;
|
||||
item.getKey(entry->mName, sizeof(entry->mName) - 1);
|
||||
item.getKey(entry->mName, sizeof(entry->mName));
|
||||
item.getValue(entry->mIndex);
|
||||
mNamespaces.push_back(entry);
|
||||
mNamespaceUsage.set(entry->mIndex, true);
|
||||
|
@ -21,7 +21,9 @@
|
||||
#include <algorithm>
|
||||
#include "nvs.h"
|
||||
#include "compressed_enum_table.hpp"
|
||||
#include "string.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
namespace nvs
|
||||
{
|
||||
@ -125,7 +127,8 @@ public:
|
||||
|
||||
void getKey(char* dst, size_t dstSize)
|
||||
{
|
||||
strncpy(dst, key, (dstSize<MAX_KEY_LENGTH)?dstSize:MAX_KEY_LENGTH);
|
||||
strncpy(dst, key, min(dstSize, sizeof(key)));
|
||||
dst[dstSize-1] = 0;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
@ -138,6 +141,4 @@ public:
|
||||
|
||||
} // namespace nvs
|
||||
|
||||
|
||||
|
||||
#endif /* nvs_types_h */
|
||||
|
@ -77,40 +77,6 @@
|
||||
#define PIN_INPUT_DISABLE(PIN_NAME) CLEAR_PERI_REG_MASK(PIN_NAME,FUN_IE)
|
||||
#define PIN_SET_DRV(PIN_NAME, drv) REG_SET_FIELD(PIN_NAME, FUN_DRV, (drv));
|
||||
|
||||
/*
|
||||
* @attention
|
||||
* The PIN_PULL[UP|DWN]_[EN|DIS]() functions used to exist as macros in previous SDK versions.
|
||||
* Unfortunately, however, they do not work for some GPIOs on the ESP32 chip, which needs pullups
|
||||
* and -downs turned on and off through RTC registers. The functions still exist for compatibility
|
||||
* with older code, but are marked as deprecated in order to generate a warning.
|
||||
* Please replace them in this fashion: (make sure to include driver/gpio.h as well)
|
||||
* PIN_PULLUP_EN(GPIO_PIN_MUX_REG[x]) -> gpio_pullup_en(x)
|
||||
* PIN_PULLUP_DIS(GPIO_PIN_MUX_REG[x]) -> gpio_pullup_dis(x)
|
||||
* PIN_PULLDWN_EN(GPIO_PIN_MUX_REG[x]) -> gpio_pulldown_en(x)
|
||||
* PIN_PULLDWN_DIS(GPIO_PIN_MUX_REG[x]) -> gpio_pulldown_dis(x)
|
||||
*
|
||||
*/
|
||||
static inline void __attribute__ ((deprecated)) PIN_PULLUP_DIS(uint32_t PIN_NAME)
|
||||
{
|
||||
REG_CLR_BIT(PIN_NAME, FUN_PU);
|
||||
}
|
||||
|
||||
static inline void __attribute__ ((deprecated)) PIN_PULLUP_EN(uint32_t PIN_NAME)
|
||||
{
|
||||
REG_SET_BIT(PIN_NAME, FUN_PU);
|
||||
}
|
||||
|
||||
static inline void __attribute__ ((deprecated)) PIN_PULLDWN_DIS(uint32_t PIN_NAME)
|
||||
{
|
||||
REG_CLR_BIT(PIN_NAME, FUN_PD);
|
||||
}
|
||||
|
||||
static inline void __attribute__ ((deprecated)) PIN_PULLDWN_EN(uint32_t PIN_NAME)
|
||||
{
|
||||
REG_SET_BIT(PIN_NAME, FUN_PD);
|
||||
}
|
||||
|
||||
|
||||
#define PIN_FUNC_SELECT(PIN_NAME, FUNC) REG_SET_FIELD(PIN_NAME, MCU_SEL, FUNC)
|
||||
|
||||
#define PIN_FUNC_GPIO 2
|
||||
|
@ -79,11 +79,6 @@ typedef volatile struct ledc_dev_s {
|
||||
uint32_t low_speed_update: 1; /*This bit is only useful for low speed timer channels, reserved for high speed timers*/
|
||||
uint32_t reserved26: 5;
|
||||
};
|
||||
struct {
|
||||
uint32_t bit_num: 5 __attribute__((deprecated)); /*Deprecated in ESP-IDF 3.0. This is an alias to 'duty_resolution' for backward compatibility with ESP-IDF 2.1.*/
|
||||
uint32_t div_num: 18 __attribute__((deprecated)); /*Deprecated in ESP-IDF 3.0. This is an alias to 'clock_divider' for backward compatibility with ESP-IDF 2.1.*/
|
||||
uint32_t place_holder: 9 __attribute__((deprecated)); /*A place holder to accommodate deprecated members*/
|
||||
};
|
||||
uint32_t val;
|
||||
} conf;
|
||||
union {
|
||||
|
@ -304,82 +304,6 @@ void rtc_clk_fast_freq_set(rtc_fast_freq_t fast_freq);
|
||||
*/
|
||||
rtc_fast_freq_t rtc_clk_fast_freq_get(void);
|
||||
|
||||
/**
|
||||
* @brief Switch CPU frequency
|
||||
*
|
||||
* @note This function is deprecated and will be removed.
|
||||
* See rtc_clk_cpu_freq_config_set instead.
|
||||
*
|
||||
* If a PLL-derived frequency is requested (80, 160, 240 MHz), this function
|
||||
* will enable the PLL. Otherwise, PLL will be disabled.
|
||||
* Note: this function is not optimized for switching speed. It may take several
|
||||
* hundred microseconds to perform frequency switch.
|
||||
*
|
||||
* @param cpu_freq new CPU frequency
|
||||
*/
|
||||
void rtc_clk_cpu_freq_set(rtc_cpu_freq_t cpu_freq) __attribute__((deprecated));
|
||||
|
||||
/**
|
||||
* @brief Switch CPU frequency
|
||||
*
|
||||
* @note This function is deprecated and will be removed.
|
||||
* See rtc_clk_cpu_freq_set_config_fast instead.
|
||||
*
|
||||
* This is a faster version of rtc_clk_cpu_freq_set, which can handle some of
|
||||
* the frequency switch paths (XTAL -> PLL, PLL -> XTAL).
|
||||
* When switching from PLL to XTAL, PLL is not disabled (unlike rtc_clk_cpu_freq_set).
|
||||
* When switching back from XTAL to PLL, only the same PLL can be used.
|
||||
* Therefore it is not possible to switch 240 -> XTAL -> (80 or 160) using this
|
||||
* function.
|
||||
*
|
||||
* For unsupported cases, this function falls back to rtc_clk_cpu_freq_set.
|
||||
*
|
||||
* Unlike rtc_clk_cpu_freq_set, this function relies on static data, so it is
|
||||
* less safe to use it e.g. from a panic handler (when memory might be corrupted).
|
||||
*
|
||||
* @param cpu_freq new CPU frequency
|
||||
*/
|
||||
void rtc_clk_cpu_freq_set_fast(rtc_cpu_freq_t cpu_freq) __attribute__((deprecated));
|
||||
|
||||
/**
|
||||
* @brief Get the currently selected CPU frequency
|
||||
*
|
||||
* @note This function is deprecated and will be removed.
|
||||
* See rtc_clk_cpu_freq_get_config instead.
|
||||
*
|
||||
* Although CPU can be clocked by APLL and RTC 8M sources, such support is not
|
||||
* exposed through this library. As such, this function will not return
|
||||
* meaningful values when these clock sources are configured (e.g. using direct
|
||||
* access to clock selection registers). In debug builds, it will assert; in
|
||||
* release builds, it will return RTC_CPU_FREQ_XTAL.
|
||||
*
|
||||
* @return CPU frequency (one of rtc_cpu_freq_t values)
|
||||
*/
|
||||
rtc_cpu_freq_t rtc_clk_cpu_freq_get(void) __attribute__((deprecated));
|
||||
|
||||
/**
|
||||
* @brief Get corresponding frequency value for rtc_cpu_freq_t enum value
|
||||
*
|
||||
* @note This function is deprecated and will be removed.
|
||||
* See rtc_clk_cpu_freq_get/set_config instead.
|
||||
*
|
||||
* @param cpu_freq CPU frequency, on of rtc_cpu_freq_t values
|
||||
* @return CPU frequency, in HZ
|
||||
*/
|
||||
uint32_t rtc_clk_cpu_freq_value(rtc_cpu_freq_t cpu_freq) __attribute__((deprecated));
|
||||
|
||||
/**
|
||||
* @brief Get rtc_cpu_freq_t enum value for given CPU frequency
|
||||
*
|
||||
* @note This function is deprecated and will be removed.
|
||||
* See rtc_clk_cpu_freq_mhz_to_config instead.
|
||||
*
|
||||
* @param cpu_freq_mhz CPU frequency, one of 80, 160, 240, 2, and XTAL frequency
|
||||
* @param[out] out_val output, rtc_cpu_freq_t value corresponding to the frequency
|
||||
* @return true if the given frequency value matches one of enum values
|
||||
*/
|
||||
bool rtc_clk_cpu_freq_from_mhz(int cpu_freq_mhz, rtc_cpu_freq_t* out_val) __attribute__((deprecated));
|
||||
|
||||
/**
|
||||
* @brief Get CPU frequency config corresponding to a rtc_cpu_freq_t value
|
||||
* @param cpu_freq CPU frequency enumeration value
|
||||
|
@ -104,7 +104,6 @@ static void rtc_clk_cpu_freq_to_8m(void);
|
||||
static void rtc_clk_bbpll_disable(void);
|
||||
static void rtc_clk_bbpll_enable(void);
|
||||
static void rtc_clk_cpu_freq_to_pll_mhz(int cpu_freq_mhz);
|
||||
static bool rtc_clk_cpu_freq_from_mhz_internal(int mhz, rtc_cpu_freq_t* out_val);
|
||||
|
||||
// Current PLL frequency, in MHZ (320 or 480). Zero if PLL is not enabled.
|
||||
static int s_cur_pll_freq;
|
||||
@ -501,21 +500,6 @@ static void rtc_clk_cpu_freq_to_pll_mhz(int cpu_freq_mhz)
|
||||
rtc_clk_wait_for_slow_cycle();
|
||||
}
|
||||
|
||||
|
||||
void rtc_clk_cpu_freq_set(rtc_cpu_freq_t cpu_freq)
|
||||
{
|
||||
rtc_cpu_freq_config_t config;
|
||||
rtc_clk_cpu_freq_to_config(cpu_freq, &config);
|
||||
rtc_clk_cpu_freq_set_config(&config);
|
||||
}
|
||||
|
||||
void rtc_clk_cpu_freq_set_fast(rtc_cpu_freq_t cpu_freq)
|
||||
{
|
||||
rtc_cpu_freq_config_t config;
|
||||
rtc_clk_cpu_freq_to_config(cpu_freq, &config);
|
||||
rtc_clk_cpu_freq_set_config_fast(&config);
|
||||
}
|
||||
|
||||
void rtc_clk_cpu_freq_set_xtal(void)
|
||||
{
|
||||
int freq_mhz = (int) rtc_clk_xtal_freq_get();
|
||||
@ -525,57 +509,6 @@ void rtc_clk_cpu_freq_set_xtal(void)
|
||||
rtc_clk_bbpll_disable();
|
||||
}
|
||||
|
||||
rtc_cpu_freq_t rtc_clk_cpu_freq_get(void)
|
||||
{
|
||||
rtc_cpu_freq_config_t config;
|
||||
rtc_clk_cpu_freq_get_config(&config);
|
||||
rtc_cpu_freq_t freq = RTC_CPU_FREQ_XTAL;
|
||||
rtc_clk_cpu_freq_from_mhz_internal(config.freq_mhz, &freq);
|
||||
return freq;
|
||||
}
|
||||
|
||||
uint32_t rtc_clk_cpu_freq_value(rtc_cpu_freq_t cpu_freq)
|
||||
{
|
||||
switch (cpu_freq) {
|
||||
case RTC_CPU_FREQ_XTAL:
|
||||
return ((uint32_t) rtc_clk_xtal_freq_get()) * MHZ;
|
||||
case RTC_CPU_FREQ_2M:
|
||||
return 2 * MHZ;
|
||||
case RTC_CPU_FREQ_80M:
|
||||
return 80 * MHZ;
|
||||
case RTC_CPU_FREQ_160M:
|
||||
return 160 * MHZ;
|
||||
case RTC_CPU_FREQ_240M:
|
||||
return 240 * MHZ;
|
||||
default:
|
||||
SOC_LOGE(TAG, "invalid rtc_cpu_freq_t value");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
static bool rtc_clk_cpu_freq_from_mhz_internal(int mhz, rtc_cpu_freq_t* out_val)
|
||||
{
|
||||
if (mhz == 240) {
|
||||
*out_val = RTC_CPU_FREQ_240M;
|
||||
} else if (mhz == 160) {
|
||||
*out_val = RTC_CPU_FREQ_160M;
|
||||
} else if (mhz == 80) {
|
||||
*out_val = RTC_CPU_FREQ_80M;
|
||||
} else if (mhz == (int) rtc_clk_xtal_freq_get()) {
|
||||
*out_val = RTC_CPU_FREQ_XTAL;
|
||||
} else if (mhz == 2) {
|
||||
*out_val = RTC_CPU_FREQ_2M;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool rtc_clk_cpu_freq_from_mhz(int mhz, rtc_cpu_freq_t* out_val)
|
||||
{
|
||||
return rtc_clk_cpu_freq_from_mhz_internal(mhz, out_val);
|
||||
}
|
||||
|
||||
void rtc_clk_cpu_freq_to_config(rtc_cpu_freq_t cpu_freq, rtc_cpu_freq_config_t* out_config)
|
||||
{
|
||||
uint32_t source_freq_mhz;
|
||||
|
@ -142,11 +142,6 @@ struct spi_flash_host_driver_t {
|
||||
* modified, the cache needs to be flushed. Left NULL if not supported.
|
||||
*/
|
||||
esp_err_t (*flush_cache)(spi_flash_host_driver_t* driver, uint32_t addr, uint32_t size);
|
||||
/**
|
||||
* Check if the given region is protected (e.g. is the bootloader). Left
|
||||
* NULL if current host doesn't need protection.
|
||||
*/
|
||||
bool (*region_protected)(spi_flash_host_driver_t* driver, uint32_t addr, uint32_t size);
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@ -12,18 +12,19 @@ else()
|
||||
"spi_flash_chip_drivers.c"
|
||||
"spi_flash_chip_generic.c"
|
||||
"spi_flash_chip_issi.c"
|
||||
"spi_flash_rom_patch.c"
|
||||
)
|
||||
if (NOT CONFIG_IDF_TARGET_ESP32S2BETA)
|
||||
# TODO: workaround until ESP32-S2 supports new API, can be always included
|
||||
list(APPEND srcs "esp_flash_spi_init.c"
|
||||
"memspi_host_driver.c"
|
||||
"spi_flash_os_func_app.c"
|
||||
"spi_flash_os_func_noos.c")
|
||||
"spi_flash_os_func_noos.c"
|
||||
"memspi_host_driver.c"
|
||||
"esp_flash_api.c"
|
||||
)
|
||||
endif()
|
||||
|
||||
if(NOT CONFIG_SPI_FLASH_USE_LEGACY_IMPL)
|
||||
list(APPEND srcs "esp_flash_api.c")
|
||||
endif()
|
||||
set(priv_requires bootloader_support app_update soc)
|
||||
endif()
|
||||
|
||||
|
@ -22,6 +22,7 @@
|
||||
#include "esp_log.h"
|
||||
#include "sdkconfig.h"
|
||||
#include "esp_heap_caps.h"
|
||||
#include "esp_flash_internal.h"
|
||||
|
||||
static const char TAG[] = "spi_flash";
|
||||
|
||||
@ -42,7 +43,7 @@ static const char TAG[] = "spi_flash";
|
||||
#define CHECK_WRITE_ADDRESS(CHIP, ADDR, SIZE)
|
||||
#else /* FAILS or ABORTS */
|
||||
#define CHECK_WRITE_ADDRESS(CHIP, ADDR, SIZE) do { \
|
||||
if (CHIP && CHIP->host->region_protected && CHIP->host->region_protected(CHIP->host, ADDR, SIZE)) { \
|
||||
if (CHIP && CHIP->os_func->region_protected && CHIP->os_func->region_protected(CHIP->os_func_data, ADDR, SIZE)) { \
|
||||
UNSAFE_WRITE_ADDRESS; \
|
||||
} \
|
||||
} while(0)
|
||||
@ -294,14 +295,15 @@ esp_err_t IRAM_ATTR esp_flash_erase_region(esp_flash_t *chip, uint32_t start, ui
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
esp_err_t err = spiflash_start(chip);
|
||||
if (err != ESP_OK) {
|
||||
return err;
|
||||
}
|
||||
|
||||
esp_err_t err = ESP_OK;
|
||||
// Check for write protected regions overlapping the erase region
|
||||
if (chip->chip_drv->get_protected_regions != NULL &&
|
||||
chip->chip_drv->num_protectable_regions > 0) {
|
||||
|
||||
err = spiflash_start(chip);
|
||||
if (err != ESP_OK) {
|
||||
return err;
|
||||
}
|
||||
uint64_t protected = 0;
|
||||
err = chip->chip_drv->get_protected_regions(chip, &protected);
|
||||
if (err == ESP_OK && protected != 0) {
|
||||
@ -313,10 +315,10 @@ esp_err_t IRAM_ATTR esp_flash_erase_region(esp_flash_t *chip, uint32_t start, ui
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Don't lock the SPI flash for the entire erase, as this may be very long
|
||||
err = spiflash_end(chip, err);
|
||||
}
|
||||
|
||||
|
||||
while (err == ESP_OK && len >= sector_size) {
|
||||
err = spiflash_start(chip);
|
||||
@ -615,6 +617,17 @@ esp_err_t IRAM_ATTR esp_flash_read_encrypted(esp_flash_t *chip, uint32_t address
|
||||
return spi_flash_read_encrypted(address, out_buffer, length);
|
||||
}
|
||||
|
||||
#ifndef CONFIG_SPI_FLASH_USE_LEGACY_IMPL
|
||||
esp_err_t esp_flash_app_disable_protect(bool disable)
|
||||
{
|
||||
if (disable) {
|
||||
return esp_flash_app_disable_os_functions(esp_flash_default_chip);
|
||||
} else {
|
||||
return esp_flash_app_init_os_functions(esp_flash_default_chip);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
Adapter layer to original api before IDF v4.0
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -22,8 +22,9 @@
|
||||
#include "esp_heap_caps.h"
|
||||
#include "hal/spi_types.h"
|
||||
#include "driver/spi_common.h"
|
||||
#include "esp_flash_internal.h"
|
||||
|
||||
static const char TAG[] = "spi_flash";
|
||||
__attribute__((unused)) static const char TAG[] = "spi_flash";
|
||||
|
||||
#ifdef CONFIG_ESPTOOLPY_FLASHFREQ_80M
|
||||
#define DEFAULT_FLASH_SPEED ESP_FLASH_80MHZ
|
||||
@ -49,6 +50,18 @@ static const char TAG[] = "spi_flash";
|
||||
#define DEFAULT_FLASH_MODE SPI_FLASH_FASTRD
|
||||
#endif
|
||||
|
||||
#define ESP_FLASH_HOST_CONFIG_DEFAULT() (memspi_host_config_t){ \
|
||||
.host_id = SPI_HOST,\
|
||||
.speed = DEFAULT_FLASH_SPEED, \
|
||||
.cs_num = 0, \
|
||||
.iomux = false, \
|
||||
.input_delay_ns = 0,\
|
||||
}
|
||||
|
||||
|
||||
esp_flash_t *esp_flash_default_chip = NULL;
|
||||
|
||||
|
||||
static IRAM_ATTR void cs_initialize(esp_flash_t *chip, const esp_flash_spi_device_config_t *config, bool use_iomux)
|
||||
{
|
||||
//Not using spicommon_cs_initialize since we don't want to put the whole
|
||||
@ -151,29 +164,22 @@ esp_err_t spi_bus_remove_flash_device(esp_flash_t *chip)
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
#define ESP_FLASH_HOST_CONFIG_DEFAULT() (memspi_host_config_t){ \
|
||||
.host_id = SPI_HOST,\
|
||||
.speed = DEFAULT_FLASH_SPEED, \
|
||||
.cs_num = 0, \
|
||||
.iomux = false, \
|
||||
.input_delay_ns = 0,\
|
||||
}
|
||||
|
||||
static DRAM_ATTR spi_flash_host_driver_t esp_flash_default_host_drv = ESP_FLASH_DEFAULT_HOST_DRIVER();
|
||||
|
||||
static DRAM_ATTR memspi_host_data_t default_driver_data;
|
||||
|
||||
/* The default (ie initial boot) no-OS ROM esp_flash_os_functions_t */
|
||||
extern const esp_flash_os_functions_t esp_flash_noos_functions;
|
||||
|
||||
#ifndef CONFIG_SPI_FLASH_USE_LEGACY_IMPL
|
||||
|
||||
static DRAM_ATTR memspi_host_data_t default_driver_data;
|
||||
static DRAM_ATTR spi_flash_host_driver_t esp_flash_default_host_drv = ESP_FLASH_DEFAULT_HOST_DRIVER();
|
||||
|
||||
|
||||
static DRAM_ATTR esp_flash_t default_chip = {
|
||||
.read_mode = DEFAULT_FLASH_MODE,
|
||||
.host = &esp_flash_default_host_drv,
|
||||
.os_func = &esp_flash_noos_functions,
|
||||
};
|
||||
|
||||
esp_flash_t *esp_flash_default_chip = NULL;
|
||||
|
||||
esp_err_t esp_flash_init_default_chip(void)
|
||||
{
|
||||
memspi_host_config_t cfg = ESP_FLASH_HOST_CONFIG_DEFAULT();
|
||||
@ -202,5 +208,7 @@ esp_err_t esp_flash_init_default_chip(void)
|
||||
|
||||
esp_err_t esp_flash_app_init(void)
|
||||
{
|
||||
return esp_flash_init_os_functions(&default_chip, 0);
|
||||
return esp_flash_app_init_os_functions(&default_chip);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -45,6 +45,9 @@ typedef struct {
|
||||
/** Called after completing any flash operation. */
|
||||
esp_err_t (*end)(void *arg);
|
||||
|
||||
/** Called before any erase/write operations to check whether the region is limited by the OS */
|
||||
esp_err_t (*region_protected)(void* arg, size_t start_addr, size_t size);
|
||||
|
||||
/** Delay for at least 'ms' milliseconds. Called in between 'start' and 'end'. */
|
||||
esp_err_t (*delay_ms)(void *arg, unsigned ms);
|
||||
} esp_flash_os_functions_t;
|
||||
@ -282,33 +285,6 @@ esp_err_t esp_flash_read_encrypted(esp_flash_t *chip, uint32_t address, void *ou
|
||||
*/
|
||||
extern esp_flash_t *esp_flash_default_chip;
|
||||
|
||||
/** @brief Initialise the default SPI flash chip
|
||||
*
|
||||
* Called by OS startup code. You do not need to call this in your own applications.
|
||||
*/
|
||||
esp_err_t esp_flash_init_default_chip(void);
|
||||
|
||||
/**
|
||||
* Enable OS-level SPI flash protections in IDF
|
||||
*
|
||||
* Called by OS startup code. You do not need to call this in your own applications.
|
||||
*
|
||||
* @return ESP_OK if success, otherwise failed. See return value of ``esp_flash_init_os_functions``.
|
||||
*/
|
||||
esp_err_t esp_flash_app_init(void);
|
||||
|
||||
/**
|
||||
* Enable OS-level SPI flash for a specific chip.
|
||||
*
|
||||
* @param chip The chip to init os functions.
|
||||
* @param host_id Which SPI host to use, 1 for SPI1, 2 for SPI2 (HSPI), 3 for SPI3 (VSPI)
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK if success
|
||||
* - ESP_ERR_INVALID_ARG if host_id is invalid
|
||||
*/
|
||||
esp_err_t esp_flash_init_os_functions(esp_flash_t *chip, int host_id);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
100
components/spi_flash/include/esp_flash_internal.h
Normal file
100
components/spi_flash/include/esp_flash_internal.h
Normal file
@ -0,0 +1,100 @@
|
||||
// Copyright 2015-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
|
||||
#include "esp_err.h"
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "sdkconfig.h"
|
||||
|
||||
#include "esp_flash.h"
|
||||
|
||||
/** Internal API, don't use in the applications */
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/** @brief Initialise the default SPI flash chip
|
||||
*
|
||||
* Called by OS startup code. You do not need to call this in your own applications.
|
||||
*/
|
||||
#ifdef CONFIG_SPI_FLASH_USE_LEGACY_IMPL
|
||||
#define esp_flash_init_default_chip(...) ({ESP_OK;})
|
||||
#else
|
||||
esp_err_t esp_flash_init_default_chip(void);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Enable OS-level SPI flash protections in IDF
|
||||
*
|
||||
* Called by OS startup code. You do not need to call this in your own applications.
|
||||
*
|
||||
* @return ESP_OK if success, otherwise failed. See return value of ``esp_flash_init_os_functions``.
|
||||
*/
|
||||
#ifdef CONFIG_SPI_FLASH_USE_LEGACY_IMPL
|
||||
#define esp_flash_app_init(...) ({ESP_OK;})
|
||||
#else
|
||||
esp_err_t esp_flash_app_init(void);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Disable OS-level SPI flash protections in IDF
|
||||
*
|
||||
* Called by the IDF internal code (e.g. coredump). You do not need to call this in your own applications.
|
||||
*
|
||||
* @return always ESP_OK.
|
||||
*/
|
||||
#ifdef CONFIG_SPI_FLASH_USE_LEGACY_IMPL
|
||||
#define esp_flash_app_disable_protect(...) ({ESP_OK;})
|
||||
#else
|
||||
esp_err_t esp_flash_app_disable_protect(bool disable);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Initialize OS-level functions for a specific chip.
|
||||
*
|
||||
* @param chip The chip to init os functions.
|
||||
* @param host_id Which SPI host to use, 1 for SPI1, 2 for SPI2 (HSPI), 3 for SPI3 (VSPI)
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK if success
|
||||
* - ESP_ERR_INVALID_ARG if host_id is invalid
|
||||
*/
|
||||
esp_err_t esp_flash_init_os_functions(esp_flash_t *chip, int host_id);
|
||||
|
||||
/**
|
||||
* Initialize OS-level functions for the main flash chip.
|
||||
*
|
||||
* @param chip The chip to init os functions. Only pointer to the default chip is supported now.
|
||||
*
|
||||
* @return always ESP_OK
|
||||
*/
|
||||
esp_err_t esp_flash_app_init_os_functions(esp_flash_t* chip);
|
||||
|
||||
/**
|
||||
* Disable OS-level functions for the main flash chip during special phases (e.g. coredump)
|
||||
*
|
||||
* @param chip The chip to init os functions. Only "esp_flash_default_chip" is supported now.
|
||||
*
|
||||
* @return always ESP_OK
|
||||
*/
|
||||
esp_err_t esp_flash_app_disable_os_functions(esp_flash_t* chip);
|
||||
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
@ -35,7 +35,6 @@
|
||||
.configure_host_read_mode = spi_flash_hal_configure_host_read_mode, \
|
||||
.poll_cmd_done = spi_flash_hal_poll_cmd_done, \
|
||||
.flush_cache = memspi_host_flush_cache, \
|
||||
.region_protected = memspi_region_protected, \
|
||||
}
|
||||
|
||||
/// configuration for the memspi host
|
||||
@ -100,14 +99,3 @@ esp_err_t memspi_host_read_status_hs(spi_flash_host_driver_t *driver, uint8_t *o
|
||||
* @return always ESP_OK.
|
||||
*/
|
||||
esp_err_t memspi_host_flush_cache(spi_flash_host_driver_t* driver, uint32_t addr, uint32_t size);
|
||||
|
||||
/**
|
||||
* Check if the given region is protected.
|
||||
*
|
||||
* @param driver The driver context.
|
||||
* @param addr Start address of the region.
|
||||
* @param size Size of the region to check.
|
||||
*
|
||||
* @return true if protected, otherwise false.
|
||||
*/
|
||||
bool memspi_region_protected(spi_flash_host_driver_t* driver, uint32_t addr, uint32_t size);
|
@ -34,7 +34,6 @@ esp_err_t memspi_host_init_pointers(spi_flash_host_driver_t *host, memspi_host_d
|
||||
//some functions are not required if not SPI1
|
||||
if (data->spi != &SPI1) {
|
||||
host->flush_cache = NULL;
|
||||
host->region_protected = NULL;
|
||||
}
|
||||
return ESP_OK;
|
||||
}
|
||||
@ -88,14 +87,3 @@ esp_err_t memspi_host_flush_cache(spi_flash_host_driver_t* driver, uint32_t addr
|
||||
}
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
bool memspi_region_protected(spi_flash_host_driver_t* driver, uint32_t addr, uint32_t size)
|
||||
{
|
||||
if (((memspi_host_data_t*)(driver->driver_data))->spi != &SPI1) {
|
||||
return false;
|
||||
}
|
||||
if (!esp_partition_main_flash_region_safe(addr, size)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
@ -172,9 +172,7 @@ static esp_err_t load_partitions(void)
|
||||
err = ESP_ERR_NO_MEM;
|
||||
break;
|
||||
}
|
||||
#ifndef CONFIG_SPI_FLASH_USE_LEGACY_IMPL
|
||||
item->info.flash_chip = esp_flash_default_chip;
|
||||
#endif
|
||||
item->info.address = it->pos.offset;
|
||||
item->info.size = it->pos.size;
|
||||
item->info.type = it->type;
|
||||
@ -336,11 +334,10 @@ esp_err_t esp_partition_read(const esp_partition_t* partition,
|
||||
#endif // CONFIG_SPI_FLASH_USE_LEGACY_IMPL
|
||||
} else {
|
||||
#if CONFIG_SECURE_FLASH_ENC_ENABLED
|
||||
#ifndef CONFIG_SPI_FLASH_USE_LEGACY_IMPL
|
||||
if (partition->flash_chip != esp_flash_default_chip) {
|
||||
return ESP_ERR_NOT_SUPPORTED;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Encrypted partitions need to be read via a cache mapping */
|
||||
const void *buf;
|
||||
spi_flash_mmap_handle_t handle;
|
||||
@ -379,11 +376,9 @@ esp_err_t esp_partition_write(const esp_partition_t* partition,
|
||||
#endif // CONFIG_SPI_FLASH_USE_LEGACY_IMPL
|
||||
} else {
|
||||
#if CONFIG_SECURE_FLASH_ENC_ENABLED
|
||||
#ifndef CONFIG_SPI_FLASH_USE_LEGACY_IMPL
|
||||
if (partition->flash_chip != esp_flash_default_chip) {
|
||||
return ESP_ERR_NOT_SUPPORTED;
|
||||
}
|
||||
#endif
|
||||
return spi_flash_write_encrypted(dst_offset, src, size);
|
||||
#else
|
||||
return ESP_ERR_NOT_SUPPORTED;
|
||||
@ -433,11 +428,9 @@ esp_err_t esp_partition_mmap(const esp_partition_t* partition, size_t offset, si
|
||||
if (offset + size > partition->size) {
|
||||
return ESP_ERR_INVALID_SIZE;
|
||||
}
|
||||
#ifndef CONFIG_SPI_FLASH_USE_LEGACY_IMPL
|
||||
if (partition->flash_chip != esp_flash_default_chip) {
|
||||
return ESP_ERR_NOT_SUPPORTED;
|
||||
}
|
||||
#endif
|
||||
size_t phys_addr = partition->address + offset;
|
||||
// offset within 64kB block
|
||||
size_t region_offset = phys_addr & 0xffff;
|
||||
|
@ -16,6 +16,8 @@
|
||||
#include "esp_attr.h"
|
||||
#include "esp_spi_flash.h" //for ``g_flash_guard_default_ops``
|
||||
#include "esp_flash.h"
|
||||
#include "esp_flash_partitions.h"
|
||||
|
||||
|
||||
#ifdef CONFIG_IDF_TARGET_ESP32
|
||||
#include "esp32/rom/ets_sys.h"
|
||||
@ -34,6 +36,11 @@ typedef struct {
|
||||
int host_id;
|
||||
} app_func_arg_t;
|
||||
|
||||
typedef struct {
|
||||
int host_id;
|
||||
bool no_protect; //to decide whether to check protected region (for the main chip) or not.
|
||||
} spi1_app_func_arg_t;
|
||||
|
||||
// in the future we will have arbitration among devices, including flash on the same flash bus
|
||||
static IRAM_ATTR esp_err_t spi_bus_acquire(int host_id)
|
||||
{
|
||||
@ -50,7 +57,7 @@ static IRAM_ATTR esp_err_t spi1_start(void *arg)
|
||||
{
|
||||
g_flash_guard_default_ops.start();
|
||||
|
||||
spi_bus_acquire(((app_func_arg_t *)arg)->host_id);
|
||||
spi_bus_acquire(((spi1_app_func_arg_t *)arg)->host_id);
|
||||
|
||||
return ESP_OK;
|
||||
}
|
||||
@ -58,7 +65,7 @@ static IRAM_ATTR esp_err_t spi1_end(void *arg)
|
||||
{
|
||||
g_flash_guard_default_ops.end();
|
||||
|
||||
spi_bus_release(((app_func_arg_t *)arg)->host_id);
|
||||
spi_bus_release(((spi1_app_func_arg_t *)arg)->host_id);
|
||||
|
||||
return ESP_OK;
|
||||
}
|
||||
@ -81,8 +88,24 @@ static IRAM_ATTR esp_err_t delay_ms(void *arg, unsigned ms)
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
static DRAM_ATTR app_func_arg_t spi1_arg = {
|
||||
static IRAM_ATTR esp_err_t main_flash_region_protected(void* arg, size_t start_addr, size_t size)
|
||||
{
|
||||
if (((spi1_app_func_arg_t*)arg)->no_protect || esp_partition_main_flash_region_safe(start_addr, size)) {
|
||||
//ESP_OK = 0, also means protected==0
|
||||
return ESP_OK;
|
||||
} else {
|
||||
return ESP_ERR_NOT_SUPPORTED;
|
||||
}
|
||||
}
|
||||
|
||||
static DRAM_ATTR spi1_app_func_arg_t spi1_arg = {
|
||||
.host_id = 0, //for SPI1,
|
||||
.no_protect = true,
|
||||
};
|
||||
|
||||
static DRAM_ATTR spi1_app_func_arg_t main_flash_arg = {
|
||||
.host_id = 0, //for SPI1,
|
||||
.no_protect = false,
|
||||
};
|
||||
|
||||
static app_func_arg_t spi2_arg = {
|
||||
@ -98,6 +121,7 @@ const DRAM_ATTR esp_flash_os_functions_t esp_flash_spi1_default_os_functions = {
|
||||
.start = spi1_start,
|
||||
.end = spi1_end,
|
||||
.delay_ms = delay_ms,
|
||||
.region_protected = main_flash_region_protected,
|
||||
};
|
||||
|
||||
const esp_flash_os_functions_t esp_flash_spi23_default_os_functions = {
|
||||
@ -122,4 +146,11 @@ esp_err_t esp_flash_init_os_functions(esp_flash_t *chip, int host_id)
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
esp_err_t esp_flash_app_init_os_functions(esp_flash_t* chip)
|
||||
{
|
||||
chip->os_func = &esp_flash_spi1_default_os_functions;
|
||||
chip->os_func_data = &main_flash_arg;
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
|
||||
|
@ -25,13 +25,15 @@
|
||||
#include "esp32s2beta/rom/cache.h"
|
||||
#endif
|
||||
|
||||
static esp_err_t start(void *arg)
|
||||
|
||||
static IRAM_ATTR esp_err_t start(void *arg)
|
||||
{
|
||||
Cache_Read_Disable(0);
|
||||
Cache_Read_Disable(1);
|
||||
return ESP_OK;
|
||||
}
|
||||
static esp_err_t end(void *arg)
|
||||
|
||||
static IRAM_ATTR esp_err_t end(void *arg)
|
||||
{
|
||||
Cache_Flush(0);
|
||||
Cache_Flush(1);
|
||||
@ -40,14 +42,21 @@ static esp_err_t end(void *arg)
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
static esp_err_t delay_ms(void *arg, unsigned ms)
|
||||
static IRAM_ATTR esp_err_t delay_ms(void *arg, unsigned ms)
|
||||
{
|
||||
ets_delay_us(1000 * ms);
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
const esp_flash_os_functions_t esp_flash_noos_functions = {
|
||||
const DRAM_ATTR esp_flash_os_functions_t esp_flash_noos_functions = {
|
||||
.start = start,
|
||||
.end = end,
|
||||
.delay_ms = delay_ms,
|
||||
.region_protected = NULL,
|
||||
};
|
||||
|
||||
esp_err_t IRAM_ATTR esp_flash_app_disable_os_functions(esp_flash_t* chip)
|
||||
{
|
||||
chip->os_func = &esp_flash_noos_functions;
|
||||
return ESP_OK;
|
||||
}
|
||||
|
@ -2,4 +2,7 @@ COMPONENT_ADD_INCLUDEDIRS := include
|
||||
COMPONENT_PRIV_INCLUDEDIRS := . spiffs/src
|
||||
COMPONENT_SRCDIRS := . spiffs/src
|
||||
|
||||
# To avoid warning for strncpy in "spiffs_nucleus.c"
|
||||
CPPFLAGS += -Wno-stringop-truncation
|
||||
|
||||
COMPONENT_SUBMODULES := spiffs
|
||||
|
@ -20,3 +20,9 @@ idf_component_register(SRCS "${srcs}"
|
||||
PRIV_INCLUDE_DIRS src proto-c ../protocomm/proto-c
|
||||
REQUIRES lwip protocomm
|
||||
PRIV_REQUIRES protobuf-c bt mdns json)
|
||||
|
||||
# To avoid warning for strncpy
|
||||
set_source_files_properties(src/handlers.c src/scheme_softap.c
|
||||
PROPERTIES COMPILE_FLAGS
|
||||
-Wno-stringop-truncation
|
||||
)
|
||||
|
@ -2,6 +2,9 @@ COMPONENT_SRCDIRS := src proto-c
|
||||
COMPONENT_ADD_INCLUDEDIRS := include
|
||||
COMPONENT_PRIV_INCLUDEDIRS := src proto-c ../protocomm/proto-c/
|
||||
|
||||
# To avoid warning for strncpy in "handlers.c" and "scheme_softap.c"
|
||||
CPPFLAGS += -Wno-stringop-truncation
|
||||
|
||||
ifndef CONFIG_BT_BLUEDROID_ENABLED
|
||||
ifndef CONFIG_BT_NIMBLE_ENABLED
|
||||
COMPONENT_OBJEXCLUDE := src/scheme_ble.o
|
||||
|
@ -157,7 +157,7 @@ static int tlsv1_set_cert_chain(struct x509_certificate **chain,
|
||||
|
||||
if (cert) {
|
||||
u8 *buf = NULL;
|
||||
size_t len;
|
||||
size_t len = 0;
|
||||
int ret;
|
||||
|
||||
if (buf == NULL) {
|
||||
@ -328,7 +328,7 @@ int tlsv1_set_private_key(struct tlsv1_credentials *cred,
|
||||
|
||||
if (private_key) {
|
||||
u8 *buf = NULL;
|
||||
size_t len;
|
||||
size_t len = 0;
|
||||
int ret;
|
||||
|
||||
if (buf == NULL) {
|
||||
@ -484,7 +484,7 @@ int tlsv1_set_dhparams(struct tlsv1_credentials *cred, const char *dh_file,
|
||||
|
||||
if (dh_file) {
|
||||
u8 *buf = NULL;
|
||||
size_t len;
|
||||
size_t len = 0;
|
||||
int ret;
|
||||
|
||||
if (buf == NULL) {
|
||||
|
@ -360,7 +360,7 @@ Advanced Make Targets
|
||||
---------------------
|
||||
|
||||
- ``make app``, ``make bootloader``, ``make partition table`` can be used to build only the app, bootloader, or partition table from the project as applicable.
|
||||
- ``make erase_flash`` and ``make erase_ota`` will use esptool.py to erase the entire flash chip and the OTA selection setting from the flash chip, respectively.
|
||||
- ``make erase_flash`` and ``make erase_otadata`` will use esptool.py to erase the entire flash chip and the OTA selection setting from the flash chip, respectively.
|
||||
- ``make size`` prints some size information about the app. ``make size-components`` and ``make size-files`` are similar targets which print more detailed per-component or per-source-file information, respectively.
|
||||
|
||||
|
||||
|
@ -1130,7 +1130,8 @@ For example, to get the Python interpreter used for the build:
|
||||
message(STATUS "The Python intepreter is: ${python}")
|
||||
|
||||
- BUILD_DIR - build directory; set from ``idf_build_process`` BUILD_DIR argument
|
||||
- BUILD_COMPONENTS - list of components (more specifically, component aliases) included in the build; set by ``idf_build_process``
|
||||
- BUILD_COMPONENTS - list of components included in the build; set by ``idf_build_process``
|
||||
- BUILD_COMPONENT_ALIASES - list of library alias of components included in the build; set by ``idf_build_process``
|
||||
- C_COMPILE_OPTIONS - compile options applied to all components' C source files
|
||||
- COMPILE_OPTIONS - compile options applied to all components' source files, regardless of it being C or C++
|
||||
- COMPILE_DEFINITIONS - compile definitions applied to all component source files
|
||||
|
@ -1,6 +1,8 @@
|
||||
Touch Sensor
|
||||
============
|
||||
|
||||
:link_to_translation:`zh_CN:[中文]`
|
||||
|
||||
Introduction
|
||||
------------
|
||||
|
||||
|
@ -1,6 +1,8 @@
|
||||
SD/SDIO/MMC Driver
|
||||
==================
|
||||
|
||||
:link_to_translation:`zh_CN:[中文]`
|
||||
|
||||
Overview
|
||||
--------
|
||||
|
||||
|
@ -3,10 +3,8 @@ Build and Flash with Eclipse IDE
|
||||
********************************
|
||||
:link_to_translation:`zh_CN:[中文]`
|
||||
|
||||
ESP-IDF V4.0 will be released with a new CMake-based build system as the default build system.
|
||||
ESP-IDF V4.0 has a new CMake-based build system as the default build system.
|
||||
|
||||
Eclipse CDT IDE support for CMake-based build system will be available before the ESP-IDF V4.0 release but
|
||||
is not available yet. We apologise for the inconvenience.
|
||||
|
||||
If you require Eclipse IDE support for this pre-release version of ESP-IDF, you can follow the :doc:`legacy GNU Make build system Getting Started guide </get-started-legacy/index>` which has steps for :doc:`Building and Flashing with Eclipse IDE </get-started-legacy/eclipse-setup>`.
|
||||
There is a new ESP-IDF Eclipse Plugin that works with the CMake-based build system. Please refer to https://github.com/espressif/idf-eclipse-plugin/blob/master/README.md for further instructions.
|
||||
|
||||
If you require Eclipse IDE support for legacy ESP_IDF Make build system, you can follow the :doc:`legacy GNU Make build system Getting Started guide </get-started-legacy/index>` which has steps for :doc:`Building and Flashing with Eclipse IDE </get-started-legacy/eclipse-setup>`.
|
||||
|
@ -59,10 +59,9 @@ ESP-IDF uses `Semantic Versioning <http://semver.org/>`_. This means that:
|
||||
Checking the Current Version
|
||||
----------------------------
|
||||
|
||||
The local ESP-IDF version can be checked by using git::
|
||||
The local ESP-IDF version can be checked by using idf.py::
|
||||
|
||||
cd $IDF_PATH
|
||||
git describe --tags --dirty
|
||||
idf.py --version
|
||||
|
||||
The ESP-IDF version is also compiled into the firmware and can be accessed (as a string) via the macro ``IDF_VER``. The default ESP-IDF bootloader will print the version on boot (the version information is not always updated in code, it only changes if that particular source file is recompiled).
|
||||
|
||||
|
@ -289,7 +289,7 @@ ESP-IDF 构建系统会在命令行中添加以下 C 预处理定义:
|
||||
~~~~~~~~~~~~~~~~~~
|
||||
|
||||
- ``make app``,``make bootloader``,``make partition table`` 可以根据需要为项目单独构建生成应用程序文件、启动引导文件和分区表文件。
|
||||
- ``make erase_flash`` 和 ``make erase_ota`` 会调用 esptool.py 脚本分别擦除整块闪存芯片或者其中 OTA 分区的内容。
|
||||
- ``make erase_flash`` 和 ``make erase_otadata`` 会调用 esptool.py 脚本分别擦除整块闪存芯片或者其中 OTA 分区的内容。
|
||||
- ``make size`` 会打印应用程序的大小信息。``make size-components`` 和 ``make size-files`` 两者功能相似,分别打印每个组件或者每个源文件大小的详细信息。
|
||||
|
||||
调试 Make 的过程
|
||||
|
@ -1 +1,168 @@
|
||||
.. include:: ../../../en/api-reference/peripherals/touch_pad.rst
|
||||
触摸传感器
|
||||
============
|
||||
|
||||
:link_to_translation:`en:[English]`
|
||||
|
||||
概述
|
||||
------------
|
||||
|
||||
触摸传感器系统由保护覆盖层、触摸电极、绝缘基板和走线组成,保护覆盖层位于最上层,绝缘基板上设有电极及走线。用户触摸覆盖层将产生电容变化,根据电容变化判断此次触摸是否为有效触摸行为。
|
||||
|
||||
ESP32 可支持最多 10 个电容式触摸板/GPIO,触摸板可以以矩阵或滑条等方式组合使用,从而覆盖更大触感区域及更多触感点。触摸传感由有限状态机 (FSM) 硬件控制,由软件或专用硬件计时器发起。
|
||||
|
||||
如需了解触摸传感器设计、操作及其控制寄存器等相关信息,请参考《`ESP32 技术参考手册 <https://www.espressif.com/sites/default/files/documentation/esp32_technical_reference_manual_cn.pdf>`_》(PDF),您也可以在《ESP32 技术参考手册》中查看这一子系统是如何运行的。
|
||||
|
||||
请参考 `触摸传感器应用方案简介 <https://github.com/espressif/esp-iot-solution/blob/master/documents/touch_pad_solution/touch_sensor_design_cn.md>`_,查看触摸传感器设计详情和固件开发指南。如果不想亲自在多种配置环境下测试触摸传感器,请查看 `ESP32 触摸功能开发套件 <https://github.com/espressif/esp-iot-solution/blob/master/documents/evaluation_boards/esp32_sense_kit_guide_cn.md>`_。
|
||||
|
||||
功能介绍
|
||||
----------------------
|
||||
|
||||
下面将 API 分解成几个函数组进行介绍,帮助您快速了解以下功能:
|
||||
|
||||
- 初始化触摸板驱动程序
|
||||
- 配置触摸板 GPIO 管脚
|
||||
- 触摸状态测量
|
||||
- 调整测量参数(优化测量)
|
||||
- 过滤触摸测量
|
||||
- 触摸监测方式
|
||||
- 设置中断信号监测触碰动作
|
||||
- 中断触发
|
||||
|
||||
请前往 :ref:`touch_pad-api-reference` 章节,查看某一函数的具体描述。:ref:`touch_pad-api-examples` 章节则介绍了此 API 的具体实现。
|
||||
|
||||
|
||||
初始化触摸板驱动程序
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
使用触摸板之前,需要先调用 :cpp:func:`touch_pad_init` 函数初始化触摸板驱动程序。此函数设置了 :ref:`touch_pad-api-reference` 项下的 *Macros* 中列出的几项 ``.._DEFAULT`` 驱动程序参数,同时删除之前设置过的触摸板信息(如有),并禁用中断。
|
||||
|
||||
如果不再需要该驱动程序,可以调用 :cpp:func:`touch_pad_deinit` 释放已初始化的驱动程序。
|
||||
|
||||
配置触摸板 GPIO 管脚
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
调用 :cpp:func:`touch_pad_config` 使能某一 GPIO 的触感功能。
|
||||
|
||||
使用 :cpp:func:`touch_pad_set_fsm_mode` 选择触摸板测量(由 FSM 操作)是由硬件计时器自动启动,还是由软件自动启动。如果选择软件模式,请使用 :cpp:func:`touch_pad_sw_start` 启动 FSM。
|
||||
|
||||
触摸状态测量
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
借助以下两个函数从传感器读取原始数据或过滤后的数据:
|
||||
|
||||
* :cpp:func:`touch_pad_read`
|
||||
* :cpp:func:`touch_pad_read_filtered`
|
||||
|
||||
这两个函数也可以用于检查触碰和释放触摸板时传感器读数变化范围,来评估触摸板设计,然后根据这些信息设定触摸阈值。
|
||||
|
||||
.. note::
|
||||
|
||||
使用 :cpp:func:`touch_pad_read_filtered` 之前,需要先调用 `过滤触摸测量`_ 中特定的滤波器函数初始化并配置该滤波器。
|
||||
|
||||
请参考应用示例 :example:`peripherals/touch_pad_read`,查看如何使用这两个读值函数。
|
||||
|
||||
优化测量
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
触摸传感器设有数个可配置参数,以适应触摸板设计特点。例如,如果需要感知较细微的电容变化,则可以缩小触摸板充放电的参考电压范围。您可以使用 :cpp:func:`touch_pad_set_voltage` 函数设置电压参考低值和参考高值。
|
||||
|
||||
优化测量除了可以识别细微的电容变化之外,还可以降低应用程序功耗,但可能会增加测量噪声干扰。如果得到的动态读数范围结果比较理想,则可以调用 :cpp:func:`touch_pad_set_meas_time` 函数来减少测量时间,从而进一步降低功耗。
|
||||
|
||||
可用的测量参数及相应的 'set' 函数总结如下:
|
||||
|
||||
* 触摸板充放电参数:
|
||||
|
||||
* 电压门限::cpp:func:`touch_pad_set_voltage`
|
||||
* 速率(斜率) :cpp:func:`touch_pad_set_cnt_mode`
|
||||
|
||||
* 测量时间::cpp:func:`touch_pad_set_meas_time`
|
||||
|
||||
电压门限(参考低值/参考高值)、速率(斜率)与测量时间的关系如下图所示:
|
||||
|
||||
.. figure:: ../../../_static/touch_pad-measurement-parameters.jpg
|
||||
:align: center
|
||||
:alt: Touch Pad - relationship between measurement parameters
|
||||
:figclass: align-center
|
||||
|
||||
触摸板 - 测量参数之间的关系
|
||||
|
||||
上图中的 *Output* 代表触摸传感器读值,即一个测量周期内测得的脉冲计数值。
|
||||
|
||||
所有函数均成对出现,用于设定某一特定参数,并获取当前参数值。例如::cpp:func:`touch_pad_set_voltage` 和 :cpp:func:`touch_pad_get_voltage`。
|
||||
|
||||
.. _touch_pad-api-filtering-of-measurements:
|
||||
|
||||
过滤触摸测量
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
如果测量中存在噪声,可以使用提供的 API 函数对测量进行过滤。使用滤波器之前,请先调用 :cpp:func:`touch_pad_filter_start` 启动该滤波器。
|
||||
|
||||
滤波器类型为 IIR(无限脉冲响应滤波器),您可以调用 :cpp:func:`touch_pad_set_filter_period` 配置此类滤波器的采样周期。
|
||||
|
||||
如需停止滤波器,请调用 :cpp:func:`touch_pad_filter_stop` 函数。如果不再使用该滤波器,请调用 :cpp:func:`touch_pad_filter_delete` 删除此滤波器。
|
||||
|
||||
触摸监测
|
||||
^^^^^^^^^^^^^^^
|
||||
|
||||
触摸监测基于用户配置的阈值和 FSM 执行的原始测量,并由 ESP32 硬件实现。你可以调用 :cpp:func:`touch_pad_get_status` 查看被触碰的触摸板,或调用 :cpp:func:`touch_pad_clear_status` 清除触摸状态信息。
|
||||
|
||||
您也可以将硬件触摸监测连接至中断,详细介绍见下一章节。
|
||||
|
||||
如果测量中存在噪声,且电容变化幅度较小,硬件触摸监测结果可能就不太理想。如需解决这一问题,不建议使用硬件监测或中断信号,建议您在自己的应用程序中采用测量过滤,并执行触摸监测。请参考 :example:`peripherals/touch_pad_interrupt`,查看以上两种触摸监测的实现方式。
|
||||
|
||||
中断触发
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
在对触摸监测启用中断之前,请先设置一个触摸监测阈值。然后使用 `触摸状态测量`_ 中所述的函数读取并显示触摸和释放触摸板时测得的结果。如果测量中存在噪声且相对电容变化较小,请使用滤波器。您也可以根据应用程序和环境条件,测试温度和电源电压变化对测量值的影响。
|
||||
|
||||
确定监测阈值后就可以在初始化时调用 :cpp:func:`touch_pad_config` 设置此阈值,或在运行时调用 :cpp:func:`touch_pad_set_thresh` 设置此阈值。
|
||||
|
||||
下一步就是设置如何触发中断。您可以设置在阈值以下或以上触发中断,具体触发模式由函数 :cpp:func:`touch_pad_set_trigger_mode` 设置。
|
||||
|
||||
最后您可以使用以下函数配置和管理中断调用:
|
||||
|
||||
* :cpp:func:`touch_pad_isr_register` / :cpp:func:`touch_pad_isr_deregister`
|
||||
* :cpp:func:`touch_pad_intr_enable` / :cpp:func:`touch_pad_intr_disable`
|
||||
|
||||
中断配置完成后,您可以调用 :cpp:func:`touch_pad_get_status` 查看中断信号来自哪个触摸板,也可以调用 :cpp:func:`touch_pad_clear_status` 清除触摸板状态信息。
|
||||
|
||||
.. note::
|
||||
|
||||
触摸监测中的中断信号基于原始/未经过滤的测量值(对比用户设置的阈值),并在硬件中实现。启用软件滤波 API 并不会影响这一过程,见 :ref:`touch_pad-api-filtering-of-measurements`。
|
||||
|
||||
|
||||
|
||||
从睡眠模式唤醒
|
||||
^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
如果使用触摸板中断将芯片从睡眠模式唤醒,您可以选择配置一些触摸板,例如 SET1 或 SET1 和 SET2,触摸这些触摸板将触发中断并唤醒芯片。请调用 :cpp:func:`touch_pad_set_trigger_source` 实现上述操作。
|
||||
|
||||
您可以使用以下函数管理 'SET' 中触摸板所需的位模式配置:
|
||||
|
||||
* :cpp:func:`touch_pad_set_group_mask` / :cpp:func:`touch_pad_get_group_mask`
|
||||
* :cpp:func:`touch_pad_clear_group_mask`
|
||||
|
||||
|
||||
.. _touch_pad-api-examples:
|
||||
|
||||
应用示例
|
||||
--------------------
|
||||
|
||||
- 触摸传感器读值示例::example:`peripherals/touch_pad_read`
|
||||
- 触摸传感器中断示例::example:`peripherals/touch_pad_interrupt`
|
||||
|
||||
.. _touch_pad-api-reference:
|
||||
|
||||
API 参考
|
||||
-------------
|
||||
|
||||
.. include:: /_build/inc/touch_pad.inc
|
||||
|
||||
GPIO 宏查找表
|
||||
^^^^^^^^^^^^^^^^^^
|
||||
您可以使用宏定义某一触摸板通道的 GPIO,或定义某一 GPIO 的通道。例如:
|
||||
|
||||
1. ``TOUCH_PAD_NUM5_GPIO_NUM`` 定义了通道 5 的 GPIO(即 GPIO 12);
|
||||
2. ``TOUCH_PAD_GPIO4_CHANNEL`` 定义了 GPIO 4 的通道(即通道 0)。
|
||||
|
||||
.. include:: /_build/inc/touch_channel.inc
|
||||
|
@ -1 +1,97 @@
|
||||
.. include:: ../../../en/api-reference/storage/sdmmc.rst
|
||||
SD/SDIO/MMC 驱动程序
|
||||
=========================
|
||||
|
||||
:link_to_translation:`en:[English]`
|
||||
|
||||
概述
|
||||
--------
|
||||
|
||||
SD/SDIO/MMC 驱动是一种基于 SDMMC 和 SD SPI 主机驱动的协议级驱动程序,目前已支持 SD 存储器、SDIO 卡和 eMMC 芯片。
|
||||
|
||||
SDMMC 主机驱动和 SD SPI 主机驱动(:component:`driver/include/driver/sdmmc_host.h`)为以下功能提供 API:
|
||||
|
||||
- 发送命令至从设备
|
||||
- 接收和发送数据
|
||||
- 处理总线错误
|
||||
|
||||
初始化函数及配置函数:
|
||||
|
||||
- 如需初始化和配置 SDMMC 主机,请参阅 :doc:`SDMMC 主机 API <../peripherals/sdmmc_host>`
|
||||
- 如需初始化和配置 SD SPI 主机,请参阅 :doc:`SD SPI 主机 API <../peripherals/sdspi_host>`
|
||||
|
||||
本文档中所述的 SDMMC 协议层仅处理 SD 协议相关事项,例如卡初始化和数据传输命令。
|
||||
|
||||
协议层通过 :cpp:class:`sdmmc_host_t` 结构体和主机协同工作,该结构体包含指向主机各类函数的指针。
|
||||
|
||||
应用示例
|
||||
-------------------
|
||||
|
||||
ESP-IDF :example:`storage/sd_card` 目录下提供了 SDMMC 驱动与 FatFs 库组合使用的示例,演示了先初始化卡,然后使用 POSIX 和 C 库 API 向卡读写数据。请参考示例目录下 README.md 文件,查看更多详细信息。
|
||||
|
||||
协议层 API
|
||||
------------------
|
||||
|
||||
协议层具备 :cpp:class:`sdmmc_host_t` 结构体,此结构体描述了 SD/MMC 主机驱动,列出了其功能,并提供指向驱动程序函数的指针。协议层将卡信息储存于 :cpp:class:`sdmmc_card_t` 结构体中。向 SD/MMC 主机发送命令时,协议层调用时需要一个 :cpp:class:`sdmmc_command_t` 结构体来描述命令、参数、预期返回值和需传输的数据(如有)。
|
||||
|
||||
用于 SD 存储卡的 API
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
1. 初始化主机,请调用主机驱动函数,例如 :cpp:func:`sdmmc_host_init` 和 :cpp:func:`sdmmc_host_init_slot`;
|
||||
2. 初始化卡,请调用 :cpp:func:`sdmmc_card_init`,并将参数 ``host`` (即主机驱动信息)和参数 ``card`` (指向 :cpp:class:`sdmmc_card_t` 结构体的指针)传递给此函数。函数运行结束后,将会向 :cpp:class:`sdmmc_card_t` 结构体填充该卡的信息;
|
||||
3. 读取或写入卡的扇区,请分别调用 :cpp:func:`sdmmc_read_sectors` 和 :cpp:func:`sdmmc_write_sectors`,并将参数 ``card`` (指向卡信息结构的指针)传递给函数;
|
||||
4. 如果不再使用该卡,请调用主机驱动函数,例如 :cpp:func:`sdmmc_host_deinit`,以禁用主机外设,并释放驱动程序分配的资源。
|
||||
|
||||
用于 eMMC 芯片的 API
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
从协议层的角度而言,eMMC 存储芯片与 SD 存储卡相同。尽管 eMMC 是芯片,不具备卡的外形,但由于协议相似 (`sdmmc_card_t`, `sdmmc_card_init`),用于 SD 卡的一些概念同样适用于 eMMC 芯片。注意,eMMC 芯片不可通过 SPI 使用,因此它与 SD API 主机驱动不兼容。
|
||||
|
||||
如需初始化 eMMC 内存并执行读/写操作,请参照上一章节 SD 卡操作步骤。
|
||||
|
||||
用于 SDIO 卡的 API
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
SDIO 卡初始化和检测过程与 SD 存储卡相同,唯一的区别是 SDIO 模式下数据传输命令不同。
|
||||
|
||||
在卡初始化和卡检测(通过运行 :cpp:func:`sdmmc_card_init`)期间,驱动仅配置 SDIO 卡如下寄存器:
|
||||
|
||||
1. I/O 中止 (0x06) 寄存器:在该寄存器中设置 RES 位可重置卡的 I/O 部分;
|
||||
2. 总线接口控制 (0x07) 寄存器:如果主机和插槽配置中启用 4 线模式,则驱动程序会尝试在该寄存器中设置总线宽度字段。如果字段设置成功,则从机支持 4 线模式,主机也切换至 4 线模式;
|
||||
3. 高速(0x13)寄存器:如果主机配置中启用高速模式,则会在该寄存器中设置 SHS 位。
|
||||
|
||||
注意,驱动程序不会在 (1) I/O 使能寄存器和 Int 使能寄存器,及 (2) I/O 块大小中,设置任何位。应用程序可通过调用 :cpp:func:`sdmmc_io_write_byte` 来设置相关位。
|
||||
|
||||
如需设置卡配置或传输数据,请根据您的具体情况选择下表中的函数:
|
||||
|
||||
========================================================================= ================================= =================================
|
||||
操作 读函数 写函数
|
||||
========================================================================= ================================= =================================
|
||||
使用 IO_RW_DIRECT (CMD52) 读写单个字节。 :cpp:func:`sdmmc_io_read_byte` :cpp:func:`sdmmc_io_write_byte`
|
||||
使用 IO_RW_EXTENDED (CMD53) 的字节模式读写多个字节。 :cpp:func:`sdmmc_io_read_bytes` :cpp:func:`sdmmc_io_write_bytes`
|
||||
块模式下,使用 IO_RW_EXTENDED (CMD53) 读写数据块。 :cpp:func:`sdmmc_io_read_blocks` :cpp:func:`sdmmc_io_write_blocks`
|
||||
========================================================================= ================================= =================================
|
||||
|
||||
使用 :cpp:func:`sdmmc_io_enable_int` 函数,应用程序可启用 SDIO 中断。
|
||||
|
||||
在单线模式下使用 SDIO 时,还需要连接 D1 线来启用 SDIO 中断。
|
||||
|
||||
如果您需要应用程序保持等待直至发生 SDIO 中断,请使用 :cpp:func:`sdmmc_io_wait_int` 函数。
|
||||
|
||||
|
||||
复合卡(存储 + SDIO)
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
该驱动程序不支持 SDIO 复合卡,复合卡会被视为 SDIO 卡。
|
||||
|
||||
|
||||
线程安全
|
||||
^^^^^^^^^^^^^
|
||||
|
||||
多数应用程序仅需在一个任务中使用协议层。因此,协议层在 :cpp:class:`sdmmc_card_t` 结构体或在访问 SDMMC 或 SD SPI 主机驱动程序时不使用任何类型的锁。这种锁通常在较高层级实现,例如文件系统驱动程序。
|
||||
|
||||
API 参考
|
||||
-------------
|
||||
|
||||
.. include:: /_build/inc/sdmmc_cmd.inc
|
||||
|
||||
.. include:: /_build/inc/sdmmc_types.inc
|
@ -57,10 +57,9 @@ ESP-IDF 采用了 `语义版本管理方法 <http://semver.org/>`_,即您可
|
||||
查看当前版本
|
||||
----------------------------
|
||||
|
||||
查看 ESP-IDF 本地副本的版本,请使用 git 命令::
|
||||
查看 ESP-IDF 本地副本的版本,请使用 idf.py 命令::
|
||||
|
||||
cd $IDF_PATH
|
||||
git describe --tags --dirty
|
||||
idf.py --version
|
||||
|
||||
此外,由于 ESP-IDF 的版本也已编译至固件中,因此您也可以使用宏 ``IDF_VER`` 查看 ESP-IDF 的版本(以字符串的格式)。ESP-IDF 默认引导程序可以在设备启动时打印 ESP-IDF 的版本,但注意代码中的版本信息仅会在源代码重新编译时才会更新,因此打印出来的版本可能并不是最新的。
|
||||
|
||||
|
@ -12,7 +12,7 @@ CONFIG_DUPLICATE_SCAN_CACHE_SIZE=200
|
||||
CONFIG_BLE_MESH_SCAN_DUPLICATE_EN=y
|
||||
CONFIG_MESH_DUPLICATE_SCAN_CACHE_SIZE=200
|
||||
CONFIG_BTDM_CONTROLLER_FULL_SCAN_SUPPORTED=y
|
||||
CONFIG_BLE_ADV_REPORT_FLOW_CONTROL_SUPPORTED=n
|
||||
CONFIG_BLE_ADV_REPORT_FLOW_CONTROL_SUPPORTED=y
|
||||
CONFIG_GATTS_ENABLE=y
|
||||
CONFIG_GATTS_SEND_SERVICE_CHANGE_MANUAL=y
|
||||
CONFIG_BLE_MESH=y
|
||||
|
@ -15,7 +15,7 @@ CONFIG_DUPLICATE_SCAN_CACHE_SIZE=200
|
||||
CONFIG_BLE_MESH_SCAN_DUPLICATE_EN=y
|
||||
CONFIG_MESH_DUPLICATE_SCAN_CACHE_SIZE=200
|
||||
CONFIG_BTDM_CONTROLLER_FULL_SCAN_SUPPORTED=y
|
||||
CONFIG_BLE_ADV_REPORT_FLOW_CONTROL_SUPPORTED=n
|
||||
CONFIG_BLE_ADV_REPORT_FLOW_CONTROL_SUPPORTED=y
|
||||
CONFIG_GATTS_ENABLE=y
|
||||
CONFIG_GATTS_SEND_SERVICE_CHANGE_MANUAL=y
|
||||
CONFIG_BLE_MESH=y
|
||||
|
@ -12,7 +12,7 @@ CONFIG_DUPLICATE_SCAN_CACHE_SIZE=200
|
||||
CONFIG_BLE_MESH_SCAN_DUPLICATE_EN=y
|
||||
CONFIG_MESH_DUPLICATE_SCAN_CACHE_SIZE=200
|
||||
CONFIG_BTDM_CONTROLLER_FULL_SCAN_SUPPORTED=y
|
||||
CONFIG_BLE_ADV_REPORT_FLOW_CONTROL_SUPPORTED=n
|
||||
CONFIG_BLE_ADV_REPORT_FLOW_CONTROL_SUPPORTED=y
|
||||
CONFIG_BLE_MESH=y
|
||||
CONFIG_BLE_MESH_HCI_5_0=y
|
||||
CONFIG_BLE_MESH_USE_DUPLICATE_SCAN=y
|
||||
|
@ -12,7 +12,7 @@ CONFIG_DUPLICATE_SCAN_CACHE_SIZE=200
|
||||
CONFIG_BLE_MESH_SCAN_DUPLICATE_EN=y
|
||||
CONFIG_MESH_DUPLICATE_SCAN_CACHE_SIZE=200
|
||||
CONFIG_BTDM_CONTROLLER_FULL_SCAN_SUPPORTED=y
|
||||
CONFIG_BLE_ADV_REPORT_FLOW_CONTROL_SUPPORTED=n
|
||||
CONFIG_BLE_ADV_REPORT_FLOW_CONTROL_SUPPORTED=y
|
||||
CONFIG_BLE_MESH=y
|
||||
CONFIG_BLE_MESH_HCI_5_0=y
|
||||
CONFIG_BLE_MESH_USE_DUPLICATE_SCAN=y
|
||||
|
@ -12,7 +12,7 @@ CONFIG_DUPLICATE_SCAN_CACHE_SIZE=200
|
||||
CONFIG_BLE_MESH_SCAN_DUPLICATE_EN=y
|
||||
CONFIG_MESH_DUPLICATE_SCAN_CACHE_SIZE=200
|
||||
CONFIG_BTDM_CONTROLLER_FULL_SCAN_SUPPORTED=y
|
||||
CONFIG_BLE_ADV_REPORT_FLOW_CONTROL_SUPPORTED=n
|
||||
CONFIG_BLE_ADV_REPORT_FLOW_CONTROL_SUPPORTED=y
|
||||
CONFIG_GATTS_ENABLE=y
|
||||
CONFIG_GATTS_SEND_SERVICE_CHANGE_MANUAL=y
|
||||
CONFIG_BLE_MESH=y
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user