Merge branch 'master' into feature/btdm_avrc

1. merge master into feature/btdm_avrc
2. add call of esp_bt_controller_enable() in app_main
This commit is contained in:
wangmengyang 2017-02-23 15:10:25 +08:00
commit 41070f6768
387 changed files with 4708 additions and 2298 deletions

10
.gitignore vendored
View File

@ -15,15 +15,19 @@ GPATH
.#*
\#*#
# eclipse setting
.settings
# Example project files
examples/*/sdkconfig
examples/*/sdkconfig.old
examples/*/build
examples/*/*/sdkconfig
examples/*/*/sdkconfig.old
examples/*/*/build
#Doc build artifacts
docs/_build/
docs/doxygen-warning-log.txt
docs/xml/
docs/man/
# Unit test app files
tools/unit-test-app/sdkconfig

View File

@ -31,6 +31,7 @@ build_template_app:
SDK_PATH: "$CI_PROJECT_DIR"
IDF_PATH: "$CI_PROJECT_DIR"
GIT_STRATEGY: clone
BATCH_BUILD: "1"
script:
- git clone https://github.com/espressif/esp-idf-template.git
@ -39,13 +40,11 @@ build_template_app:
# using on esp-idf. If it doesn't exist then just stick to the default
# branch
- git checkout ${CI_BUILD_REF_NAME} || echo "Using esp-idf-template default branch..."
- make defconfig
# Test debug build (default)
- make all V=1
# Now test release build
- make clean
- sed -i.bak -e's/CONFIG_OPTIMIZATION_LEVEL_DEBUG\=y/CONFIG_OPTIMIZATION_LEVEL_RELEASE=y/' sdkconfig
- make defconfig
- make all V=1
# Check if there are any stray printf/ets_printf references in WiFi libs
- cd ../components/esp32/lib
@ -63,6 +62,8 @@ build_template_app:
SDK_PATH: "$CI_PROJECT_DIR"
IDF_PATH: "$CI_PROJECT_DIR"
GIT_STRATEGY: clone
BATCH_BUILD: "1"
build_ssc:
<<: *build_template
@ -79,6 +80,15 @@ build_ssc:
- chmod +x gen_misc_ng.sh
- ./gen_misc_ng.sh
build_at:
<<: *build_template
script:
- git clone $GITLAB_SSH_SERVER/application/esp-at.git
- cd esp-at
- git checkout ${CI_BUILD_REF_NAME} || echo "Using esp-at default branch..."
- make defconfig
- make
build_esp_idf_tests:
<<: *build_template
artifacts:
@ -87,13 +97,15 @@ build_esp_idf_tests:
- ./tools/unit-test-app/build/*.elf
- ./tools/unit-test-app/build/*.map
- ./tools/unit-test-app/build/bootloader/*.bin
- ./components/idf_test/unit_test/TestCaseAll.yml
- ./components/idf_test/unit_test/CIConfigs/*.yml
expire_in: 6 mos
script:
- cd tools/unit-test-app
- git checkout ${CI_BUILD_REF_NAME} || echo "Using default branch..."
- make defconfig
- make TESTS_ALL=1
- python UnitTestParser.py
build_examples:
<<: *build_template
@ -122,6 +134,7 @@ build_docs:
- doxygen
# If not building master branch, and there are Doxygen warnings, print them and bail out
- test "${CI_BUILD_REF_NAME}" = "master" || test $(cat doxygen-warning-log.txt | wc -l) -eq 0 || ( echo "Doxygen pass had some warnings:" && cat doxygen-warning-log.txt && false )
- make gh-linkcheck
- make html
artifacts:
paths:
@ -160,6 +173,7 @@ test_report:
LOG_PATH: "$CI_PROJECT_DIR/$CI_BUILD_REF"
TEST_CASE_FILE_PATH: "$CI_PROJECT_DIR/components/idf_test"
REPORT_PATH: "$CI_PROJECT_DIR/CI_Test_Report"
MODULE_UPDATE_FILE: "$CI_PROJECT_DIR/tools/unit-test-app/ModuleDefinition.yml"
artifacts:
when: always
paths:
@ -181,7 +195,7 @@ test_report:
- cd auto_test_script
# generate report
- TEST_RESULT=Pass
- python CITestReport.py -l $LOG_PATH -t $TEST_CASE_FILE_PATH -p $REPORT_PATH -r $RESULT_PATH -a $ARTIFACTS_PATH || TEST_RESULT=Fail
- python CITestReport.py -l $LOG_PATH -t $TEST_CASE_FILE_PATH -p $REPORT_PATH -r $RESULT_PATH -a $ARTIFACTS_PATH -m $MODULE_UPDATE_FILE || TEST_RESULT=Fail
# commit to CI-test-result project
- git clone $GITLAB_SSH_SERVER/qa/CI-test-result.git
- rm -rf CI-test-result/RawData/$RESULT_PATH
@ -202,6 +216,7 @@ push_master_to_github:
stage: deploy
only:
- master
- /^release\/v.*$/
tags:
- deploy
when: on_success
@ -225,6 +240,7 @@ deploy_docs:
stage: deploy
only:
- master
- /^release\/v.*$/
- triggers
tags:
- deploy
@ -243,6 +259,26 @@ deploy_docs:
- scp $GIT_VER.tar.gz $DOCS_SERVER:$DOCS_PATH
- ssh $DOCS_SERVER -x "cd $DOCS_PATH && tar xzvf $GIT_VER.tar.gz && rm -f latest && ln -s $GIT_VER latest"
check_doc_links:
stage: test
image: espressif/esp32-ci-env
tags:
- check_doc_links
only:
# can only be triggered
- triggers
script:
# must be triggered with CHECK_LINKS=Yes, otherwise exit without test
- test $CHECK_LINKS = "Yes" || exit 0
# can only run on master branch (otherwise the commit is not on Github yet)
- test "${CI_BUILD_REF_NAME}" = "master" || exit 0
- cd docs
- make linkcheck
artifacts:
paths:
- docs/_build/linkcheck
expire_in: 1 mos
# AUTO GENERATED PART START, DO NOT MODIFY CONTENT BELOW
# template for test jobs
@ -255,14 +291,14 @@ deploy_docs:
allow_failure: true
variables:
# LOCAL_ENV_CONFIG_PATH: define in template and jobs can overwrite if required
LOCAL_ENV_CONFIG_PATH: /home/gitlab-runner/LocalConfig/ESP32_IDF
LOCAL_ENV_CONFIG_PATH: $CI_PROJECT_DIR/ci-test-runner-configs/$CI_RUNNER_DESCRIPTION/ESP32_IDF
BIN_PATH: "$CI_PROJECT_DIR/SSC/ssc_bin/SSC"
APP_NAME: "ssc"
LOG_PATH: "$CI_PROJECT_DIR/$CI_BUILD_REF"
# append test level folder to TEST_CASE_FILE_PATH in before_script of test job
TEST_CASE_FILE_PATH: "$CI_PROJECT_DIR/components/idf_test/integration_test"
# jobs MUST set CONFIG_FILE in before_script, and overwrite the variables above if necessary
MODULE_UPDATE_FILE: "$CI_PROJECT_DIR/components/idf_test/unit_test/ModuleDefinition.yml"
artifacts:
when: always
@ -280,11 +316,13 @@ deploy_docs:
- base64 --decode --ignore-garbage ~/.ssh/id_rsa_base64 > ~/.ssh/id_rsa
- chmod 600 ~/.ssh/id_rsa
- echo -e "Host gitlab.espressif.cn\n\tStrictHostKeyChecking no\n" >> ~/.ssh/config
# clone local test env configs
- git clone $GITLAB_SSH_SERVER/qa/ci-test-runner-configs.git
# clone test bench
- git clone $GITLAB_SSH_SERVER/yinling/auto_test_script.git
- cd auto_test_script
# run test
- python CIRunner.py -l $LOG_PATH -c $CONFIG_FILE -e $LOCAL_ENV_CONFIG_PATH -t $TEST_CASE_FILE_PATH bin_path $APP_NAME $BIN_PATH
- python CIRunner.py -l $LOG_PATH -c $CONFIG_FILE -e $LOCAL_ENV_CONFIG_PATH -t $TEST_CASE_FILE_PATH -m $MODULE_UPDATE_FILE bin_path $APP_NAME $BIN_PATH
# template for overnight test jobs
@ -305,11 +343,13 @@ deploy_docs:
- base64 --decode --ignore-garbage ~/.ssh/id_rsa_base64 > ~/.ssh/id_rsa
- chmod 600 ~/.ssh/id_rsa
- echo -e "Host gitlab.espressif.cn\n\tStrictHostKeyChecking no\n" >> ~/.ssh/config
# clone local test env configs
- git clone $GITLAB_SSH_SERVER/qa/ci-test-runner-configs.git
# clone test bench
- git clone $GITLAB_SSH_SERVER/yinling/auto_test_script.git
- cd auto_test_script
# run test
- python CIRunner.py -l $LOG_PATH -c $CONFIG_FILE -e $LOCAL_ENV_CONFIG_PATH -t $TEST_CASE_FILE_PATH bin_path $APP_NAME $BIN_PATH
- python CIRunner.py -l $LOG_PATH -c $CONFIG_FILE -e $LOCAL_ENV_CONFIG_PATH -t $TEST_CASE_FILE_PATH -m $MODULE_UPDATE_FILE bin_path $APP_NAME $BIN_PATH
# template for unit test jobs
.unit_test_template: &unit_test_template
@ -318,12 +358,15 @@ deploy_docs:
stage: unit_test
variables:
# jobs MUST set CONFIG_FILE in before_script, and overwrite the variables above if necessary
LOCAL_ENV_CONFIG_PATH: /home/gitlab-runner/LocalConfig/ESP32_IDF
LOCAL_ENV_CONFIG_PATH: $CI_PROJECT_DIR/ci-test-runner-configs/$CI_RUNNER_DESCRIPTION/ESP32_IDF
BIN_PATH: "$CI_PROJECT_DIR/tools/unit-test-app/build/"
LOG_PATH: "$CI_PROJECT_DIR/$CI_BUILD_REF"
APP_NAME: "ut"
TEST_CASE_FILE_PATH: "$CI_PROJECT_DIR/components/idf_test/unit_test"
MODULE_UPDATE_FILE: "$CI_PROJECT_DIR/tools/unit-test-app/ModuleDefinition.yml"
dependencies:
- build_esp_idf_tests
UT_Function_SYS_01:
<<: *unit_test_template
@ -333,6 +376,14 @@ UT_Function_SYS_01:
before_script:
- CONFIG_FILE=$TEST_CASE_FILE_PATH/CIConfigs/UT_Function_SYS_01.yml
UT_Function_SYS_02:
<<: *unit_test_template
tags:
- ESP32_IDF
- UT_T1_1
before_script:
- CONFIG_FILE=$TEST_CASE_FILE_PATH/CIConfigs/UT_Function_SYS_02.yml
IT_Function_SYS_01:
<<: *test_template
tags:

2
.gitmodules vendored
View File

@ -3,7 +3,7 @@
url = https://github.com/espressif/esp32-wifi-lib.git
[submodule "components/esptool_py/esptool"]
path = components/esptool_py/esptool
url = https://github.com/themadinventor/esptool.git
url = https://github.com/espressif/esptool.git
[submodule "components/bt/lib"]
path = components/bt/lib
url = https://github.com/espressif/esp32-bt-lib.git

View File

@ -21,7 +21,7 @@ Before sending us a Pull Request, please consider this list of points:
* Is the code adequately commented for people to understand how it is structured?
* Is there documentation or examples that go with code contributions? `There are additional suggestions for writing good examples in the examples README <https://github.com/espressif/esp-idf/tree/master/examples>`_.
* Is there documentation or examples that go with code contributions? There are additional suggestions for writing good examples in :idf:`examples` readme.
* Are comments and documentation written in clear English, with no spelling or grammar errors?

View File

@ -2,7 +2,7 @@
[![alt text](https://readthedocs.org/projects/docs/badge/?version=latest "Documentation Status")](http://esp-idf.readthedocs.io/en/latest/?badge=latest)
ESP-IDF is the official development framework for the `ESP32 <https://espressif.com/en/products/hardware/esp32/overview>`_ chip.
ESP-IDF is the official development framework for the [ESP32](https://espressif.com/en/products/hardware/esp32/overview>) chip.
# Developing With the ESP-IDF
@ -24,6 +24,16 @@ Once you've found the project you want to work with, change to its directory and
`make menuconfig`
* Opens a text-based configuration menu for the project.
* Use up & down arrow keys to navigate the menu.
* Use Enter key to go into a submenu, Escape key to go out or to exit.
* Type `?` to see a help screen. Enter key exits the help screen.
* Use Space key, or `Y` and `N` keys to enable (Yes) and disable (No) configuration items with checkboxes "`[*]`"
* Pressing `?` while highlighting a configuration item displays help about that item.
* Type `/` to search the configuration items.
Once done configuring, press Escape multiple times to exit and say "Yes" to save the new configuration when prompted.
## Compiling the Project
`make all`
@ -59,7 +69,7 @@ After the initial flash, you may just want to build and flash just your app, not
`make app-flash` will automatically rebuild the app if it needs it.
(There's no downside to reflashing the bootloader and partition table each time, if they haven't changed.)
(In normal development there's no downside to reflashing the bootloader and partition table each time, if they haven't changed.)
## Parallel Builds

View File

@ -9,7 +9,7 @@
if [ -z ${IDF_PATH} ]; then
echo "IDF_PATH must be set before including this script."
else
IDF_ADD_PATHS_EXTRAS="${IDF_PATH}/components/esptool_py/esptool:${IDF_PATH}/components/partition_table/"
IDF_ADD_PATHS_EXTRAS="${IDF_PATH}/components/esptool_py/esptool:${IDF_PATH}/components/espcoredump:${IDF_PATH}/components/partition_table/"
export PATH="${PATH}:${IDF_ADD_PATHS_EXTRAS}"
echo "Added to PATH: ${IDF_ADD_PATHS_EXTRAS}"
fi

View File

@ -27,6 +27,7 @@
#include "esp_spi_flash.h"
#include "esp_image_format.h"
#include "esp_secure_boot.h"
#include "esp_flash_encrypt.h"
#include "sdkconfig.h"
#include "esp_ota_ops.h"
@ -44,6 +45,10 @@ typedef struct ota_ops_entry_ {
esp_partition_t part;
uint32_t erased_size;
uint32_t wrote_size;
#ifdef CONFIG_FLASH_ENCRYPTION_ENABLED
uint8_t partial_bytes;
uint8_t partial_data[16];
#endif
LIST_ENTRY(ota_ops_entry_) entries;
} ota_ops_entry_t;
@ -106,6 +111,7 @@ esp_err_t esp_ota_begin(const esp_partition_t *partition, size_t image_size, esp
esp_err_t esp_ota_write(esp_ota_handle_t handle, const void *data, size_t size)
{
const uint8_t *data_bytes = (const uint8_t *)data;
esp_err_t ret;
ota_ops_entry_t *it;
@ -119,7 +125,47 @@ esp_err_t esp_ota_write(esp_ota_handle_t handle, const void *data, size_t size)
if (it->handle == handle) {
// must erase the partition before writing to it
assert(it->erased_size > 0 && "must erase the partition before writing to it");
ret = esp_partition_write(&it->part, it->wrote_size, data, size);
if(it->wrote_size == 0 && size > 0 && data_bytes[0] != 0xE9) {
ESP_LOGE(TAG, "OTA image has invalid magic byte (expected 0xE9, saw 0x%02x", data_bytes[0]);
return ESP_ERR_OTA_VALIDATE_FAILED;
}
#ifdef CONFIG_FLASH_ENCRYPTION_ENABLED
if (esp_flash_encryption_enabled()) {
/* Can only write 16 byte blocks to flash, so need to cache anything else */
size_t copy_len;
/* check if we have partially written data from earlier */
if (it->partial_bytes != 0) {
copy_len = OTA_MIN(16 - it->partial_bytes, size);
memcpy(it->partial_data + it->partial_bytes, data_bytes, copy_len);
it->partial_bytes += copy_len;
if (it->partial_bytes != 16) {
return ESP_OK; /* nothing to write yet, just filling buffer */
}
/* write 16 byte to partition */
ret = esp_partition_write(&it->part, it->wrote_size, it->partial_data, 16);
if (ret != ESP_OK) {
return ret;
}
it->partial_bytes = 0;
memset(it->partial_data, 0xFF, 16);
it->wrote_size += 16;
data_bytes += copy_len;
size -= copy_len;
}
/* check if we need to save trailing data that we're about to write */
it->partial_bytes = size % 16;
if (it->partial_bytes != 0) {
size -= it->partial_bytes;
memcpy(it->partial_data, data_bytes + size, it->partial_bytes);
}
}
#endif
ret = esp_partition_write(&it->part, it->wrote_size, data_bytes, size);
if(ret == ESP_OK){
it->wrote_size += size;
}
@ -135,26 +181,11 @@ esp_err_t esp_ota_write(esp_ota_handle_t handle, const void *data, size_t size)
esp_err_t esp_ota_end(esp_ota_handle_t handle)
{
ota_ops_entry_t *it;
size_t image_size;
esp_err_t ret = ESP_OK;
for (it = LIST_FIRST(&s_ota_ops_entries_head); it != NULL; it = LIST_NEXT(it, entries)) {
if (it->handle == handle) {
// an ota handle need to be ended after erased and wrote data in it
if ((it->erased_size == 0) || (it->wrote_size == 0)) {
return ESP_ERR_INVALID_ARG;
}
#ifdef CONFIG_SECUREBOOTLOADER
esp_err_t ret;
size_t image_size;
if (esp_image_basic_verify(it->part.address, &image_size) != ESP_OK) {
return ESP_ERR_OTA_VALIDATE_FAILED;
}
ret = esp_secure_boot_verify_signature(it->part.address, image_size);
if (ret != ESP_OK) {
return ESP_ERR_OTA_VALIDATE_FAILED;
}
#endif
LIST_REMOVE(it, entries);
break;
}
}
@ -163,8 +194,44 @@ esp_err_t esp_ota_end(esp_ota_handle_t handle)
return ESP_ERR_NOT_FOUND;
}
/* 'it' holds the ota_ops_entry_t for 'handle' */
// esp_ota_end() is only valid if some data was written to this handle
if ((it->erased_size == 0) || (it->wrote_size == 0)) {
ret = ESP_ERR_INVALID_ARG;
goto cleanup;
}
#ifdef CONFIG_FLASH_ENCRYPTION_ENABLED
if (it->partial_bytes > 0 && esp_flash_encryption_enabled()) {
/* Write out last 16 bytes, if necessary */
ret = esp_partition_write(&it->part, it->wrote_size, it->partial_data, 16);
if (ret != ESP_OK) {
ret = ESP_ERR_INVALID_STATE;
goto cleanup;
}
it->wrote_size += 16;
it->partial_bytes = 0;
}
#endif
if (esp_image_basic_verify(it->part.address, true, &image_size) != ESP_OK) {
ret = ESP_ERR_OTA_VALIDATE_FAILED;
goto cleanup;
}
#ifdef CONFIG_SECURE_BOOT_ENABLED
ret = esp_secure_boot_verify_signature(it->part.address, image_size);
if (ret != ESP_OK) {
ret = ESP_ERR_OTA_VALIDATE_FAILED;
goto cleanup;
}
#endif
cleanup:
LIST_REMOVE(it, entries);
free(it);
return ESP_OK;
return ret;
}
static uint32_t ota_select_crc(const ota_select *s)
@ -271,11 +338,9 @@ static esp_err_t esp_rewrite_ota_data(esp_partition_subtype_t subtype)
}
return rewrite_ota_seq((SUB_TYPE_ID(subtype) + 1) % ota_app_count + i * ota_app_count, 0, find_partition);
} else if (s_ota_select[0].ota_seq == 0xFFFFFFFF && s_ota_select[1].ota_seq == 0xFFFFFFFF) {
return rewrite_ota_seq(SUB_TYPE_ID(subtype) + 1, 0, find_partition);
} else {
return ESP_ERR_OTA_SELECT_INFO_INVALID;
/* Both OTA slots are invalid, probably because unformatted... */
return rewrite_ota_seq(SUB_TYPE_ID(subtype) + 1, 0, find_partition);
}
} else {
@ -285,17 +350,18 @@ static esp_err_t esp_rewrite_ota_data(esp_partition_subtype_t subtype)
esp_err_t esp_ota_set_boot_partition(const esp_partition_t *partition)
{
size_t image_size;
const esp_partition_t *find_partition = NULL;
if (partition == NULL) {
return ESP_ERR_INVALID_ARG;
}
#ifdef CONFIG_SECUREBOOTLOADER
size_t image_size;
if (esp_image_basic_verify(partition->address, &image_size) != ESP_OK) {
if (esp_image_basic_verify(partition->address, true, &image_size) != ESP_OK) {
return ESP_ERR_OTA_VALIDATE_FAILED;
}
ret = esp_secure_boot_verify_signature(partition->address, image_size);
#ifdef CONFIG_SECURE_BOOT_ENABLED
esp_err_t ret = esp_secure_boot_verify_signature(partition->address, image_size);
if (ret != ESP_OK) {
return ESP_ERR_OTA_VALIDATE_FAILED;
}
@ -349,33 +415,34 @@ const esp_partition_t *esp_ota_get_boot_partition(void)
}
ota_app_count = get_ota_partition_count();
ESP_LOGD(TAG, "found ota bin max = %d", ota_app_count);
ESP_LOGD(TAG, "found ota app max = %d", ota_app_count);
if (s_ota_select[0].ota_seq == 0xFFFFFFFF && s_ota_select[1].ota_seq == 0xFFFFFFFF) {
ESP_LOGD(TAG, "finding factory bin......");
ESP_LOGD(TAG, "finding factory app......");
return esp_partition_find_first(ESP_PARTITION_TYPE_APP, ESP_PARTITION_SUBTYPE_APP_FACTORY, NULL);
} else if (ota_select_valid(&s_ota_select[0]) && ota_select_valid(&s_ota_select[1])) {
ESP_LOGD(TAG, "finding ota_%d bin......", \
ESP_LOGD(TAG, "finding ota_%d app......", \
ESP_PARTITION_SUBTYPE_APP_OTA_MIN + ((OTA_MAX(s_ota_select[0].ota_seq, s_ota_select[1].ota_seq) - 1) % ota_app_count));
return esp_partition_find_first(ESP_PARTITION_TYPE_APP, \
ESP_PARTITION_SUBTYPE_APP_OTA_MIN + ((OTA_MAX(s_ota_select[0].ota_seq, s_ota_select[1].ota_seq) - 1) % ota_app_count), NULL);
} else if (ota_select_valid(&s_ota_select[0])) {
ESP_LOGD(TAG, "finding ota_%d bin......", \
ESP_LOGD(TAG, "finding ota_%d app......", \
ESP_PARTITION_SUBTYPE_APP_OTA_MIN + (s_ota_select[0].ota_seq - 1) % ota_app_count);
return esp_partition_find_first(ESP_PARTITION_TYPE_APP, \
ESP_PARTITION_SUBTYPE_APP_OTA_MIN + (s_ota_select[0].ota_seq - 1) % ota_app_count, NULL);
} else if (ota_select_valid(&s_ota_select[1])) {
ESP_LOGD(TAG, "finding ota_%d bin......", \
ESP_LOGD(TAG, "finding ota_%d app......", \
ESP_PARTITION_SUBTYPE_APP_OTA_MIN + (s_ota_select[1].ota_seq - 1) % ota_app_count);
return esp_partition_find_first(ESP_PARTITION_TYPE_APP, \
ESP_PARTITION_SUBTYPE_APP_OTA_MIN + (s_ota_select[1].ota_seq - 1) % ota_app_count, NULL);
} else {
ESP_LOGE(TAG, "not found current bin");
return NULL;
ESP_LOGE(TAG, "ota data invalid, no current app. Assuming factory");
return esp_partition_find_first(ESP_PARTITION_TYPE_APP, ESP_PARTITION_SUBTYPE_APP_FACTORY, NULL);
}
}

View File

@ -73,11 +73,16 @@ esp_err_t esp_ota_write(esp_ota_handle_t handle, const void* data, size_t size);
/**
* @brief Finish the update and validate written data
*
* @param handle Handle obtained from esp_ota_begin
* @param handle Handle obtained from esp_ota_begin.
*
* @return:
* - ESP_OK: if validate ota image pass
* - ESP_ERR_OTA_VALIDATE_FAILED: validate the ota image is invalid
* @note After calling esp_ota_end(), the handle is no longer valid and any memory associated with it is freed (regardless of result).
*
* @return:
* - ESP_OK: Newly written OTA app image is valid.
* - ESP_ERR_NOT_FOUND: OTA handle was not found.
* - ESP_ERR_INVALID_ARG: Handle was never written to.
* - ESP_ERR_OTA_VALIDATE_FAILED: OTA image is invalid (either not a valid app image, or - if secure boot is enabled - signature failed to verify.)
* - ESP_ERR_INVALID_STATE: If flash encryption is enabled, this result indicates an internal error writing the final encrypted bytes to flash.
*/
esp_err_t esp_ota_end(esp_ota_handle_t handle);

View File

@ -35,16 +35,16 @@ endmenu
menu "Security features"
config SECURE_BOOT_ENABLED
bool "Enable secure boot in bootloader"
bool "Enable secure boot in bootloader (READ DOCS FIRST)"
default N
help
Build a bootloader which enables secure boot on first boot.
Once enabled, secure boot will not boot a modified bootloader. The bootloader will only load a partition table or boot an app if the data has a verified digital signature.
Once enabled, secure boot will not boot a modified bootloader. The bootloader will only load a partition table or boot an app if the data has a verified digital signature. There are implications for reflashing updated apps once secure boot is enabled.
When enabling secure boot, JTAG and ROM BASIC Interpreter are permanently disabled by default.
See docs/security/secure-boot.rst for details.
Refer to http://esp-idf.readthedocs.io/en/latest/security/secure-boot.html before enabling.
choice SECURE_BOOTLOADER_MODE
bool "Secure bootloader mode"
@ -108,7 +108,7 @@ config SECURE_BOOT_VERIFICATION_KEY
PEM formatted private key using the espsecure.py
extract_public_key command.
See docs/security/secure-boot.rst for details.
Refer to http://esp-idf.readthedocs.io/en/latest/security/secure-boot.html before enabling.
config SECURE_BOOT_INSECURE
bool "Allow potentially insecure options"
@ -119,16 +119,18 @@ config SECURE_BOOT_INSECURE
Only enable these options if you are very sure.
Refer to docs/security/secure-boot.rst and docs/security/flash-encryption.rst for details.
Refer to http://esp-idf.readthedocs.io/en/latest/security/secure-boot.html before enabling.
config FLASH_ENCRYPTION_ENABLED
bool "Enable flash encryption on boot"
bool "Enable flash encryption on boot (READ DOCS FIRST)"
default N
help
If this option is set, flash contents will be encrypted by the bootloader on first boot.
Note: After first boot, the system will be permanently encrypted.
See docs/securityflash-encryption.rst for details.
Note: After first boot, the system will be permanently encrypted. Re-flashing an encrypted
system is complicated and not always possible.
Read http://esp-idf.readthedocs.io/en/latest/security/flash-encryption.html before enabling.
config FLASH_ENCRYPTION_INSECURE
bool "Allow potentially insecure options"

View File

@ -0,0 +1,4 @@
# Submodules normally added in component.mk, but fully qualified
# paths can be added at this level (we need binary librtc to be
# available to link bootloader).
COMPONENT_SUBMODULES += $(IDF_PATH)/components/esp32/lib

View File

@ -323,12 +323,15 @@ void bootloader_main()
} else {
if(ota_select_valid(&sa) && ota_select_valid(&sb)) {
load_part_pos = bs.ota[(((sa.ota_seq > sb.ota_seq)?sa.ota_seq:sb.ota_seq) - 1)%bs.app_count];
}else if(ota_select_valid(&sa)) {
} else if(ota_select_valid(&sa)) {
load_part_pos = bs.ota[(sa.ota_seq - 1) % bs.app_count];
}else if(ota_select_valid(&sb)) {
} else if(ota_select_valid(&sb)) {
load_part_pos = bs.ota[(sb.ota_seq - 1) % bs.app_count];
}else {
ESP_LOGE(TAG, "ota data partition info error");
} else if (bs.factory.offset != 0) {
ESP_LOGE(TAG, "ota data partition invalid, falling back to factory");
load_part_pos = bs.factory;
} else {
ESP_LOGE(TAG, "ota data partition invalid and no factory, can't boot");
return;
}
}

View File

@ -14,10 +14,10 @@ COMPONENT_ADD_LDFLAGS := -L $(COMPONENT_PATH) -lmain $(addprefix -T ,$(LINKER_SC
COMPONENT_ADD_LINKER_DEPS := $(LINKER_SCRIPTS)
ifdef IS_BOOTLOADER_BUILD
# following lines are a workaround to link librtc into the
# bootloader, until clock setting code is in a source-based esp-idf
# component. See also rtc_printf() in bootloader_start.c
COMPONENT_ADD_LDFLAGS += -L $(IDF_PATH)/components/esp32/lib/ -lrtc
#
# See also matching COMPONENT_SUBMODULES line in Makefile.projbuild
COMPONENT_ADD_LDFLAGS += -L $(IDF_PATH)/components/esp32/lib/ -lrtc_clk -lrtc
COMPONENT_EXTRA_INCLUDES += $(IDF_PATH)/components/esp32/
endif

View File

@ -15,14 +15,17 @@
#define __ESP32_FLASH_ENCRYPT_H
#include <stdbool.h>
#include <esp_err.h>
#include "esp_attr.h"
#include "esp_err.h"
#include "esp_spi_flash.h"
#include "soc/efuse_reg.h"
/* Support functions for flash encryption features.
Can be compiled as part of app or bootloader code.
*/
/**
* @file esp_partition.h
* @brief Support functions for flash encryption features
*
* Can be compiled as part of app or bootloader code.
*/
/** @brief Is flash encryption currently enabled in hardware?
*
@ -30,9 +33,17 @@
*
* @return true if flash encryption is enabled.
*/
static inline bool esp_flash_encryption_enabled(void) {
static inline IRAM_ATTR bool esp_flash_encryption_enabled(void) {
uint32_t flash_crypt_cnt = REG_GET_FIELD(EFUSE_BLK0_RDATA0_REG, EFUSE_RD_FLASH_CRYPT_CNT);
return __builtin_parity(flash_crypt_cnt) == 1;
/* __builtin_parity is in flash, so we calculate parity inline */
bool enabled = false;
while(flash_crypt_cnt) {
if (flash_crypt_cnt & 1) {
enabled = !enabled;
}
flash_crypt_cnt >>= 1;
}
return enabled;
}
/* @brief Update on-device flash encryption

View File

@ -16,6 +16,7 @@
#include <bootloader_flash.h>
#include <esp_log.h>
#include <esp_spi_flash.h> /* including in bootloader for error values */
#include <esp_flash_encrypt.h>
#ifndef BOOTLOADER_BUILD
/* Normal app version maps to esp_spi_flash.h operations...
@ -48,7 +49,11 @@ void bootloader_munmap(const void *mapping)
esp_err_t bootloader_flash_read(size_t src, void *dest, size_t size, bool allow_decrypt)
{
return spi_flash_read(src, dest, size);
if (allow_decrypt && esp_flash_encryption_enabled()) {
return spi_flash_read_encrypted(src, dest, size);
} else {
return spi_flash_read(src, dest, size);
}
}
esp_err_t bootloader_flash_write(size_t dest_addr, void *src, size_t size, bool write_encrypted)

View File

@ -135,4 +135,8 @@ void bootloader_random_disable(void)
/* Reset i2s peripheral */
SET_PERI_REG_MASK(DPORT_PERIP_RST_EN_REG, DPORT_I2S0_RST);
CLEAR_PERI_REG_MASK(DPORT_PERIP_RST_EN_REG, DPORT_I2S0_RST);
/* Disable pull supply voltage to SAR ADC */
CLEAR_PERI_REG_MASK(RTC_CNTL_TEST_MUX_REG, RTC_CNTL_ENT_RTC);
SET_PERI_REG_BITS(RTC_CNTL_TEST_MUX_REG, RTC_CNTL_DTEST_RTC, 0, RTC_CNTL_DTEST_RTC_S);
}

View File

@ -285,6 +285,9 @@ static esp_err_t encrypt_partition(int index, const esp_partition_info_t *partit
} else {
should_encrypt = false;
}
} else if (partition->type == PART_TYPE_DATA && partition->subtype == PART_SUBTYPE_DATA_OTA) {
/* check if we have ota data partition and the partition should be encrypted unconditionally */
should_encrypt = true;
}
if (!should_encrypt) {

View File

@ -16,6 +16,7 @@
#include "esp_bt_main.h"
#include "btc_task.h"
#include "btc_main.h"
#include "bt.h"
#include "future.h"
static bool esp_already_enable = false;
@ -103,6 +104,11 @@ esp_err_t esp_bluedroid_init(void)
btc_msg_t msg;
future_t **future_p;
if (esp_bt_controller_get_status() != ESP_BT_CONTROLLER_STATUS_ENABLED) {
LOG_ERROR("%s conroller not init\n", __func__);
return ESP_ERR_INVALID_STATE;
}
if (esp_already_init) {
LOG_ERROR("%s already init\n", __func__);
return ESP_ERR_INVALID_STATE;

View File

@ -252,3 +252,50 @@ uint8_t *esp_ble_resolve_adv_data( uint8_t *adv_data, uint8_t type, uint8_t *len
return (BTM_CheckAdvData( adv_data, type, length));
}
esp_err_t esp_ble_gap_config_adv_data_raw(uint8_t *raw_data, uint32_t raw_data_len)
{
btc_msg_t msg;
btc_ble_gap_args_t arg;
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
return ESP_ERR_INVALID_STATE;
}
if (raw_data == NULL
|| (raw_data_len <= 0 || raw_data_len > ESP_BLE_ADV_DATA_LEN_MAX)) {
return ESP_ERR_INVALID_ARG;
}
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_GAP_BLE;
msg.act = BTC_GAP_BLE_ACT_CFG_ADV_DATA_RAW;
arg.cfg_adv_data_raw.raw_adv = raw_data;
arg.cfg_adv_data_raw.raw_adv_len = raw_data_len;
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gap_args_t), btc_gap_ble_arg_deep_copy) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
esp_err_t esp_ble_gap_config_scan_rsp_data_raw(uint8_t *raw_data, uint32_t raw_data_len)
{
btc_msg_t msg;
btc_ble_gap_args_t arg;
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
return ESP_ERR_INVALID_STATE;
}
if (raw_data == NULL
|| (raw_data_len <= 0 || raw_data_len > ESP_BLE_SCAN_RSP_DATA_LEN_MAX)) {
return ESP_ERR_INVALID_ARG;
}
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_GAP_BLE;
msg.act = BTC_GAP_BLE_ACT_CFG_SCAN_RSP_DATA_RAW;
arg.cfg_scan_rsp_data_raw.raw_scan_rsp = raw_data;
arg.cfg_scan_rsp_data_raw.raw_scan_rsp_len = raw_data_len;
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gap_args_t), btc_gap_ble_arg_deep_copy) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}

View File

@ -44,6 +44,8 @@ typedef enum {
ESP_GAP_BLE_SCAN_RSP_DATA_SET_COMPLETE_EVT, /*!< When scan response data set complete, the event comes */
ESP_GAP_BLE_SCAN_PARAM_SET_COMPLETE_EVT, /*!< When scan parameters set complete, the event comes */
ESP_GAP_BLE_SCAN_RESULT_EVT, /*!< When one scan result ready, the event comes each time */
ESP_GAP_BLE_ADV_DATA_RAW_SET_COMPLETE_EVT, /*!< When raw advertising data set complete, the event comes */
ESP_GAP_BLE_SCAN_RSP_DATA_RAW_SET_COMPLETE_EVT, /*!< When raw advertising data set complete, the event comes */
} esp_gap_ble_cb_event_t;
/// Advertising data maximum length
@ -93,7 +95,7 @@ typedef enum {
typedef enum {
ADV_CHNL_37 = 0x01,
ADV_CHNL_38 = 0x02,
ADV_CHNL_39 = 0x03,
ADV_CHNL_39 = 0x04,
ADV_CHNL_ALL = 0x07,
} esp_ble_adv_channel_t;
@ -270,6 +272,18 @@ typedef union {
int flag; /*!< Advertising data flag bit */
int num_resps; /*!< Scan result number */
} scan_rst; /*!< Event parameter of ESP_GAP_BLE_SCAN_RESULT_EVT */
/**
* @brief ESP_GAP_BLE_ADV_DATA_RAW_SET_COMPLETE_EVT
*/
struct ble_adv_data_raw_cmpl_evt_param {
esp_bt_status_t status; /*!< Indicate the set raw advertising data operation success status */
} adv_data_raw_cmpl; /*!< Event parameter of ESP_GAP_BLE_ADV_DATA_RAW_SET_COMPLETE_EVT */
/**
* @brief ESP_GAP_BLE_SCAN_RSP_DATA_RAW_SET_COMPLETE_EVT
*/
struct ble_scan_rsp_data_raw_cmpl_evt_param {
esp_bt_status_t status; /*!< Indicate the set raw advertising data operation success status */
} scan_rsp_data_raw_cmpl; /*!< Event parameter of ESP_GAP_BLE_SCAN_RSP_DATA_RAW_SET_COMPLETE_EVT */
} esp_ble_gap_cb_param_t;
/**
@ -448,6 +462,33 @@ esp_err_t esp_ble_gap_set_device_name(const char *name);
*/
uint8_t *esp_ble_resolve_adv_data(uint8_t *adv_data, uint8_t type, uint8_t *length);
/**
* @brief This function is called to set raw advertising data. User need to fill
* ADV data by self.
*
* @param[in] raw_data : raw advertising data
* @param[in] raw_data_len : raw advertising data length , less than 31 bytes
*
* @return
* - ESP_OK : success
* - other : failed
*
*/
esp_err_t esp_ble_gap_config_adv_data_raw(uint8_t *raw_data, uint32_t raw_data_len);
/**
* @brief This function is called to set raw scan response data. User need to fill
* scan response data by self.
*
* @param[in] raw_data : raw scan response data
* @param[in] raw_data_len : raw scan response data length , less than 31 bytes
*
* @return
* - ESP_OK : success
* - other : failed
*/
esp_err_t esp_ble_gap_config_scan_rsp_data_raw(uint8_t *raw_data, uint32_t raw_data_len);
#ifdef __cplusplus
}
#endif

View File

@ -449,7 +449,8 @@ esp_err_t esp_ble_gatts_stop_service(uint16_t service_handle);
* @param[in] attr_handle - attribute handle to indicate.
* @param[in] value_len - indicate value length.
* @param[in] value: value to indicate.
* @param[in] need_confirm - if this indication expects a confirmation or not.
* @param[in] need_confirm - Whether a confirmation is required.
* false sends a GATT notification, true sends a GATT indication.
*
* @return
* - ESP_OK : success

View File

@ -4608,6 +4608,30 @@ void bta_dm_ble_set_adv_config (tBTA_DM_MSG *p_data)
}
}
/*******************************************************************************
**
** Function bta_dm_ble_set_adv_config_raw
**
** Description This function set the customized ADV data configuration
**
** Parameters:
**
*******************************************************************************/
void bta_dm_ble_set_adv_config_raw (tBTA_DM_MSG *p_data)
{
tBTA_STATUS status = BTA_FAILURE;
if (BTM_BleWriteAdvDataRaw(p_data->ble_set_adv_data_raw.p_raw_adv,
p_data->ble_set_adv_data_raw.raw_adv_len) == BTM_SUCCESS) {
status = BTA_SUCCESS;
}
if (p_data->ble_set_adv_data_raw.p_adv_data_cback) {
(*p_data->ble_set_adv_data_raw.p_adv_data_cback)(status);
}
}
/*******************************************************************************
**
** Function bta_dm_ble_set_scan_rsp
@ -4631,6 +4655,29 @@ void bta_dm_ble_set_scan_rsp (tBTA_DM_MSG *p_data)
}
}
/*******************************************************************************
**
** Function bta_dm_ble_set_scan_rsp_raw
**
** Description This function set the raw scan response data
**
** Parameters:
**
*******************************************************************************/
void bta_dm_ble_set_scan_rsp_raw (tBTA_DM_MSG *p_data)
{
tBTA_STATUS status = BTA_FAILURE;
if (BTM_BleWriteScanRspRaw(p_data->ble_set_adv_data_raw.p_raw_adv,
p_data->ble_set_adv_data_raw.raw_adv_len) == BTM_SUCCESS) {
status = BTA_SUCCESS;
}
if (p_data->ble_set_adv_data_raw.p_adv_data_cback) {
(*p_data->ble_set_adv_data_raw.p_adv_data_cback)(status);
}
}
/*******************************************************************************
**
** Function bta_dm_ble_set_data_length

View File

@ -1077,6 +1077,35 @@ void BTA_DmBleSetAdvConfig (tBTA_BLE_AD_MASK data_mask, tBTA_BLE_ADV_DATA *p_adv
}
}
/*******************************************************************************
**
** Function BTA_DmBleSetAdvConfigRaw
**
** Description This function is called to set raw Advertising data
**
** Parameters p_raw_adv : raw advertising data.
** raw_adv_len : raw advertising data length.
** p_adv_data_cback : set adv data complete callback.
**
** Returns None
**
*******************************************************************************/
void BTA_DmBleSetAdvConfigRaw (UINT8 *p_raw_adv, UINT32 raw_adv_len,
tBTA_SET_ADV_DATA_CMPL_CBACK *p_adv_data_cback)
{
tBTA_DM_API_SET_ADV_CONFIG_RAW *p_msg;
if ((p_msg = (tBTA_DM_API_SET_ADV_CONFIG_RAW *)
GKI_getbuf(sizeof(tBTA_DM_API_SET_ADV_CONFIG_RAW))) != NULL) {
p_msg->hdr.event = BTA_DM_API_BLE_SET_ADV_CONFIG_RAW_EVT;
p_msg->p_adv_data_cback = p_adv_data_cback;
p_msg->p_raw_adv = p_raw_adv;
p_msg->raw_adv_len = raw_adv_len;
bta_sys_sendmsg(p_msg);
}
}
/*******************************************************************************
**
** Function BTA_DmBleSetScanRsp
@ -1104,6 +1133,35 @@ extern void BTA_DmBleSetScanRsp (tBTA_BLE_AD_MASK data_mask, tBTA_BLE_ADV_DATA *
}
}
/*******************************************************************************
**
** Function BTA_DmBleSetScanRspRaw
**
** Description This function is called to set raw scan response data
**
** Parameters p_raw_scan_rsp : raw scan_rspertising data.
** raw_scan_rsp_len : raw scan_rspertising data length.
** p_scan_rsp_data_cback : set scan_rsp data complete callback.
**
** Returns None
**
*******************************************************************************/
void BTA_DmBleSetScanRspRaw (UINT8 *p_raw_scan_rsp, UINT32 raw_scan_rsp_len,
tBTA_SET_ADV_DATA_CMPL_CBACK *p_scan_rsp_data_cback)
{
tBTA_DM_API_SET_ADV_CONFIG_RAW *p_msg;
if ((p_msg = (tBTA_DM_API_SET_ADV_CONFIG_RAW *)
GKI_getbuf(sizeof(tBTA_DM_API_SET_ADV_CONFIG_RAW))) != NULL) {
p_msg->hdr.event = BTA_DM_API_BLE_SET_SCAN_RSP_RAW_EVT;
p_msg->p_adv_data_cback = p_scan_rsp_data_cback;
p_msg->p_raw_adv = p_raw_scan_rsp;
p_msg->raw_adv_len = raw_scan_rsp_len;
bta_sys_sendmsg(p_msg);
}
}
/*******************************************************************************
**
** Function BTA_DmBleSetStorageParams

View File

@ -109,7 +109,11 @@ enum {
support setting the ble advertising param by the APP******/
BTA_DM_API_BLE_ADV_PARAM_All_EVT,
BTA_DM_API_BLE_SET_ADV_CONFIG_EVT,
/* Add for set raw advertising data */
BTA_DM_API_BLE_SET_ADV_CONFIG_RAW_EVT,
BTA_DM_API_BLE_SET_SCAN_RSP_EVT,
/* Add for set raw scan response data */
BTA_DM_API_BLE_SET_SCAN_RSP_RAW_EVT,
BTA_DM_API_BLE_BROADCAST_EVT,
BTA_DM_API_SET_DATA_LENGTH_EVT,
@ -545,6 +549,15 @@ typedef struct {
tBTA_SET_ADV_DATA_CMPL_CBACK *p_adv_data_cback;
} tBTA_DM_API_SET_ADV_CONFIG;
/* raw scan response and raw advertising data use
the same structure */
typedef struct {
BT_HDR hdr;
UINT8 *p_raw_adv;
UINT32 raw_adv_len;
tBTA_SET_ADV_DATA_CMPL_CBACK *p_adv_data_cback;
} tBTA_DM_API_SET_ADV_CONFIG_RAW;
typedef struct {
BT_HDR hdr;
UINT8 batch_scan_full_max;
@ -708,6 +721,7 @@ typedef union {
tBTA_DM_API_BLE_ADV_PARAMS ble_set_adv_params;
tBTA_DM_API_BLE_ADV_PARAMS_ALL ble_set_adv_params_all;
tBTA_DM_API_SET_ADV_CONFIG ble_set_adv_data;
tBTA_DM_API_SET_ADV_CONFIG_RAW ble_set_adv_data_raw;
#if BLE_ANDROID_CONTROLLER_SCAN_FILTER == TRUE
tBTA_DM_API_SCAN_FILTER_PARAM_SETUP ble_scan_filt_param_setup;
tBTA_DM_API_CFG_FILTER_COND ble_cfg_filter_cond;
@ -1093,9 +1107,11 @@ extern void bta_dm_ble_set_rand_address(tBTA_DM_MSG *p_data);
extern void bta_dm_ble_stop_advertising(tBTA_DM_MSG *p_data);
extern void bta_dm_ble_config_local_privacy (tBTA_DM_MSG *p_data);
extern void bta_dm_ble_set_adv_params (tBTA_DM_MSG *p_data);
extern void bta_dm_ble_set_adv_params_all (tBTA_DM_MSG *p_data);
extern void bta_dm_ble_set_adv_params_all(tBTA_DM_MSG *p_data);
extern void bta_dm_ble_set_adv_config (tBTA_DM_MSG *p_data);
extern void bta_dm_ble_set_adv_config_raw (tBTA_DM_MSG *p_data);
extern void bta_dm_ble_set_scan_rsp (tBTA_DM_MSG *p_data);
extern void bta_dm_ble_set_scan_rsp_raw (tBTA_DM_MSG *p_data);
extern void bta_dm_ble_broadcast (tBTA_DM_MSG *p_data);
extern void bta_dm_ble_set_data_length(tBTA_DM_MSG *p_data);

View File

@ -47,86 +47,95 @@ typedef void (*tBTA_DM_ACTION)(tBTA_DM_MSG *p_data);
const tBTA_DM_ACTION bta_dm_action[BTA_DM_MAX_EVT] = {
/* device manager local device API events */
bta_dm_enable, /* 0 BTA_DM_API_ENABLE_EVT */
bta_dm_disable, /* 1 BTA_DM_API_DISABLE_EVT */
bta_dm_set_dev_name, /* 2 BTA_DM_API_SET_NAME_EVT */
bta_dm_set_visibility, /* 3 BTA_DM_API_SET_VISIBILITY_EVT */
bta_dm_acl_change, /* 8 BTA_DM_ACL_CHANGE_EVT */
bta_dm_add_device, /* 9 BTA_DM_API_ADD_DEVICE_EVT */
bta_dm_close_acl, /* 10 BTA_DM_API_ADD_DEVICE_EVT */
bta_dm_enable, /* 0 BTA_DM_API_ENABLE_EVT */
bta_dm_disable, /* 1 BTA_DM_API_DISABLE_EVT */
bta_dm_set_dev_name, /* 2 BTA_DM_API_SET_NAME_EVT */
bta_dm_set_visibility, /* 3 BTA_DM_API_SET_VISIBILITY_EVT */
bta_dm_acl_change, /* 8 BTA_DM_ACL_CHANGE_EVT */
bta_dm_add_device, /* 9 BTA_DM_API_ADD_DEVICE_EVT */
bta_dm_close_acl, /* 10 BTA_DM_API_ADD_DEVICE_EVT */
/* security API events */
bta_dm_bond, /* 11 BTA_DM_API_BOND_EVT */
bta_dm_bond_cancel, /* 12 BTA_DM_API_BOND_CANCEL_EVT */
bta_dm_pin_reply, /* 13 BTA_DM_API_PIN_REPLY_EVT */
bta_dm_bond, /* 11 BTA_DM_API_BOND_EVT */
bta_dm_bond_cancel, /* 12 BTA_DM_API_BOND_CANCEL_EVT */
bta_dm_pin_reply, /* 13 BTA_DM_API_PIN_REPLY_EVT */
/* power manger events */
bta_dm_pm_btm_status, /* 16 BTA_DM_PM_BTM_STATUS_EVT */
bta_dm_pm_timer, /* 17 BTA_DM_PM_TIMER_EVT*/
bta_dm_pm_btm_status, /* 16 BTA_DM_PM_BTM_STATUS_EVT */
bta_dm_pm_timer, /* 17 BTA_DM_PM_TIMER_EVT*/
/* simple pairing events */
bta_dm_confirm, /* 18 BTA_DM_API_CONFIRM_EVT */
bta_dm_confirm, /* 18 BTA_DM_API_CONFIRM_EVT */
bta_dm_set_encryption, /* BTA_DM_API_SET_ENCRYPTION_EVT */
bta_dm_set_encryption, /* BTA_DM_API_SET_ENCRYPTION_EVT */
#if (BTM_OOB_INCLUDED == TRUE)
bta_dm_loc_oob, /* 20 BTA_DM_API_LOC_OOB_EVT */
bta_dm_ci_io_req_act, /* 21 BTA_DM_CI_IO_REQ_EVT */
bta_dm_ci_rmt_oob_act, /* 22 BTA_DM_CI_RMT_OOB_EVT */
bta_dm_loc_oob, /* 20 BTA_DM_API_LOC_OOB_EVT */
bta_dm_ci_io_req_act, /* 21 BTA_DM_CI_IO_REQ_EVT */
bta_dm_ci_rmt_oob_act, /* 22 BTA_DM_CI_RMT_OOB_EVT */
#endif /* BTM_OOB_INCLUDED */
#if BLE_INCLUDED == TRUE
bta_dm_add_blekey, /* BTA_DM_API_ADD_BLEKEY_EVT */
bta_dm_add_ble_device, /* BTA_DM_API_ADD_BLEDEVICE_EVT */
bta_dm_ble_passkey_reply, /* BTA_DM_API_BLE_PASSKEY_REPLY_EVT */
bta_dm_ble_confirm_reply, /* BTA_DM_API_BLE_CONFIRM_REPLY_EVT */
bta_dm_add_blekey, /* BTA_DM_API_ADD_BLEKEY_EVT */
bta_dm_add_ble_device, /* BTA_DM_API_ADD_BLEDEVICE_EVT */
bta_dm_ble_passkey_reply, /* BTA_DM_API_BLE_PASSKEY_REPLY_EVT */
bta_dm_ble_confirm_reply, /* BTA_DM_API_BLE_CONFIRM_REPLY_EVT */
bta_dm_security_grant,
bta_dm_ble_set_bg_conn_type,
bta_dm_ble_set_conn_params, /* BTA_DM_API_BLE_CONN_PARAM_EVT */
bta_dm_ble_set_conn_scan_params, /* BTA_DM_API_BLE_CONN_SCAN_PARAM_EVT */
bta_dm_ble_set_scan_params, /* BTA_DM_API_BLE_SCAN_PARAM_EVT */
bta_dm_ble_set_scan_fil_params, /* BTA_DM_API_BLE_SCAN_FIL_PARAM_EVT */
bta_dm_ble_observe, /* BTA_DM_API_BLE_OBSERVE_EVT*/
bta_dm_ble_update_conn_params, /* BTA_DM_API_UPDATE_CONN_PARAM_EVT */
/*******This handler function added by Yulong at 2016/9/9 to
support the random address setting for the APP******/
bta_dm_ble_set_rand_address, /*BTA_DM_API_SET_RAND_ADDR_EVT*/
/*******This handler function added by Yulong at 2016/10/19 to
support stop the ble advertising setting by the APP******/
bta_dm_ble_stop_advertising, /*BTA_DM_API_BLE_STOP_ADV_EVT*/
bta_dm_ble_set_conn_params, /* BTA_DM_API_BLE_CONN_PARAM_EVT */
bta_dm_ble_set_conn_scan_params, /* BTA_DM_API_BLE_CONN_SCAN_PARAM_EVT */
bta_dm_ble_set_scan_params, /* BTA_DM_API_BLE_SCAN_PARAM_EVT */
bta_dm_ble_set_scan_fil_params, /* BTA_DM_API_BLE_SCAN_FIL_PARAM_EVT */
bta_dm_ble_observe, /* BTA_DM_API_BLE_OBSERVE_EVT*/
bta_dm_ble_update_conn_params, /* BTA_DM_API_UPDATE_CONN_PARAM_EVT */
/* This handler function added by
Yulong at 2016/9/9 to support the
random address setting for the APP */
bta_dm_ble_set_rand_address, /* BTA_DM_API_SET_RAND_ADDR_EVT*/
/* This handler function added by
Yulong at 2016/10/19 to support
stop the ble advertising setting
by the APP */
bta_dm_ble_stop_advertising, /* BTA_DM_API_BLE_STOP_ADV_EVT*/
#if BLE_PRIVACY_SPT == TRUE
bta_dm_ble_config_local_privacy, /* BTA_DM_API_LOCAL_PRIVACY_EVT */
bta_dm_ble_config_local_privacy, /* BTA_DM_API_LOCAL_PRIVACY_EVT */
#endif
bta_dm_ble_set_adv_params, /* BTA_DM_API_BLE_ADV_PARAM_EVT */
bta_dm_ble_set_adv_params_all, /* BTA_DM_API_BLE_ADV_PARAM_All_EVT */
bta_dm_ble_set_adv_config, /* BTA_DM_API_BLE_SET_ADV_CONFIG_EVT */
bta_dm_ble_set_scan_rsp, /* BTA_DM_API_BLE_SET_SCAN_RSPT */
bta_dm_ble_broadcast, /* BTA_DM_API_BLE_BROADCAST_EVT */
bta_dm_ble_set_data_length, /* BTA_DM_API_SET_DATA_LENGTH_EVT */
bta_dm_ble_set_adv_params, /* BTA_DM_API_BLE_ADV_PARAM_EVT */
bta_dm_ble_set_adv_params_all, /* BTA_DM_API_BLE_ADV_PARAM_All_EVT */
bta_dm_ble_set_adv_config, /* BTA_DM_API_BLE_SET_ADV_CONFIG_EVT */
/* New function to allow set raw adv
data to HCI */
bta_dm_ble_set_adv_config_raw, /* BTA_DM_API_BLE_SET_ADV_CONFIG_RAW_EVT */
bta_dm_ble_set_scan_rsp, /* BTA_DM_API_BLE_SET_SCAN_RSP_EVT */
/* New function to allow set raw scan
response data to HCI */
bta_dm_ble_set_scan_rsp_raw, /* BTA_DM_API_BLE_SET_SCAN_RSP_RAW_EVT */
bta_dm_ble_broadcast, /* BTA_DM_API_BLE_BROADCAST_EVT */
bta_dm_ble_set_data_length, /* BTA_DM_API_SET_DATA_LENGTH_EVT */
#if BLE_ANDROID_CONTROLLER_SCAN_FILTER == TRUE
bta_dm_cfg_filter_cond, /* BTA_DM_API_CFG_FILTER_COND_EVT */
bta_dm_scan_filter_param_setup, /* BTA_DM_API_SCAN_FILTER_SETUP_EVT */
bta_dm_enable_scan_filter, /* BTA_DM_API_SCAN_FILTER_ENABLE_EVT */
bta_dm_cfg_filter_cond, /* BTA_DM_API_CFG_FILTER_COND_EVT */
bta_dm_scan_filter_param_setup, /* BTA_DM_API_SCAN_FILTER_SETUP_EVT */
bta_dm_enable_scan_filter, /* BTA_DM_API_SCAN_FILTER_ENABLE_EVT */
#endif
bta_dm_ble_multi_adv_enb, /* BTA_DM_API_BLE_MULTI_ADV_ENB_EVT*/
bta_dm_ble_multi_adv_upd_param, /* BTA_DM_API_BLE_MULTI_ADV_PARAM_UPD_EVT */
bta_dm_ble_multi_adv_data, /* BTA_DM_API_BLE_MULTI_ADV_DATA_EVT */
btm_dm_ble_multi_adv_disable, /* BTA_DM_API_BLE_MULTI_ADV_DISABLE_EVT */
bta_dm_ble_setup_storage, /* BTA_DM_API_BLE_SETUP_STORAGE_EVT */
bta_dm_ble_enable_batch_scan, /* BTA_DM_API_BLE_ENABLE_BATCH_SCAN_EVT */
bta_dm_ble_disable_batch_scan, /* BTA_DM_API_BLE_DISABLE_BATCH_SCAN_EVT */
bta_dm_ble_read_scan_reports, /* BTA_DM_API_BLE_READ_SCAN_REPORTS_EVT */
bta_dm_ble_track_advertiser, /* BTA_DM_API_BLE_TRACK_ADVERTISER_EVT */
bta_dm_ble_get_energy_info, /* BTA_DM_API_BLE_ENERGY_INFO_EVT */
bta_dm_ble_multi_adv_enb, /* BTA_DM_API_BLE_MULTI_ADV_ENB_EVT*/
bta_dm_ble_multi_adv_upd_param, /* BTA_DM_API_BLE_MULTI_ADV_PARAM_UPD_EVT */
bta_dm_ble_multi_adv_data, /* BTA_DM_API_BLE_MULTI_ADV_DATA_EVT */
btm_dm_ble_multi_adv_disable, /* BTA_DM_API_BLE_MULTI_ADV_DISABLE_EVT */
bta_dm_ble_setup_storage, /* BTA_DM_API_BLE_SETUP_STORAGE_EVT */
bta_dm_ble_enable_batch_scan, /* BTA_DM_API_BLE_ENABLE_BATCH_SCAN_EVT */
bta_dm_ble_disable_batch_scan, /* BTA_DM_API_BLE_DISABLE_BATCH_SCAN_EVT */
bta_dm_ble_read_scan_reports, /* BTA_DM_API_BLE_READ_SCAN_REPORTS_EVT */
bta_dm_ble_track_advertiser, /* BTA_DM_API_BLE_TRACK_ADVERTISER_EVT */
bta_dm_ble_get_energy_info, /* BTA_DM_API_BLE_ENERGY_INFO_EVT */
#endif
bta_dm_enable_test_mode, /* BTA_DM_API_ENABLE_TEST_MODE_EVT */
bta_dm_disable_test_mode, /* BTA_DM_API_DISABLE_TEST_MODE_EVT */
bta_dm_execute_callback, /* BTA_DM_API_EXECUTE_CBACK_EVT */
bta_dm_enable_test_mode, /* BTA_DM_API_ENABLE_TEST_MODE_EVT */
bta_dm_disable_test_mode, /* BTA_DM_API_DISABLE_TEST_MODE_EVT */
bta_dm_execute_callback, /* BTA_DM_API_EXECUTE_CBACK_EVT */
bta_dm_remove_all_acl, /* BTA_DM_API_REMOVE_ALL_ACL_EVT */
bta_dm_remove_device, /* BTA_DM_API_REMOVE_DEVICE_EVT */
bta_dm_remove_all_acl, /* BTA_DM_API_REMOVE_ALL_ACL_EVT */
bta_dm_remove_device, /* BTA_DM_API_REMOVE_DEVICE_EVT */
};
@ -161,24 +170,24 @@ enum {
/* action function list */
const tBTA_DM_ACTION bta_dm_search_action[] = {
bta_dm_search_start, /* 0 BTA_DM_API_SEARCH */
bta_dm_search_cancel, /* 1 BTA_DM_API_SEARCH_CANCEL */
bta_dm_discover, /* 2 BTA_DM_API_DISCOVER */
bta_dm_inq_cmpl, /* 3 BTA_DM_INQUIRY_CMPL */
bta_dm_rmt_name, /* 4 BTA_DM_REMT_NAME */
bta_dm_sdp_result, /* 5 BTA_DM_SDP_RESULT */
bta_dm_search_cmpl, /* 6 BTA_DM_SEARCH_CMPL */
bta_dm_free_sdp_db, /* 7 BTA_DM_FREE_SDP_DB */
bta_dm_disc_result, /* 8 BTA_DM_DISC_RESULT */
bta_dm_search_result, /* 9 BTA_DM_SEARCH_RESULT */
bta_dm_queue_search, /* 10 BTA_DM_QUEUE_SEARCH */
bta_dm_queue_disc, /* 11 BTA_DM_QUEUE_DISC */
bta_dm_search_clear_queue, /* 12 BTA_DM_SEARCH_CLEAR_QUEUE */
bta_dm_search_cancel_cmpl, /* 13 BTA_DM_SEARCH_CANCEL_CMPL */
bta_dm_search_cancel_notify, /* 14 BTA_DM_SEARCH_CANCEL_NOTIFY */
bta_dm_search_cancel_transac_cmpl, /* 15 BTA_DM_SEARCH_CANCEL_TRANSAC_CMPL */
bta_dm_disc_rmt_name, /* 16 BTA_DM_DISC_RMT_NAME */
bta_dm_di_disc /* 17 BTA_DM_API_DI_DISCOVER */
bta_dm_search_start, /* 0 BTA_DM_API_SEARCH */
bta_dm_search_cancel, /* 1 BTA_DM_API_SEARCH_CANCEL */
bta_dm_discover, /* 2 BTA_DM_API_DISCOVER */
bta_dm_inq_cmpl, /* 3 BTA_DM_INQUIRY_CMPL */
bta_dm_rmt_name, /* 4 BTA_DM_REMT_NAME */
bta_dm_sdp_result, /* 5 BTA_DM_SDP_RESULT */
bta_dm_search_cmpl, /* 6 BTA_DM_SEARCH_CMPL */
bta_dm_free_sdp_db, /* 7 BTA_DM_FREE_SDP_DB */
bta_dm_disc_result, /* 8 BTA_DM_DISC_RESULT */
bta_dm_search_result, /* 9 BTA_DM_SEARCH_RESULT */
bta_dm_queue_search, /* 10 BTA_DM_QUEUE_SEARCH */
bta_dm_queue_disc, /* 11 BTA_DM_QUEUE_DISC */
bta_dm_search_clear_queue, /* 12 BTA_DM_SEARCH_CLEAR_QUEUE */
bta_dm_search_cancel_cmpl, /* 13 BTA_DM_SEARCH_CANCEL_CMPL */
bta_dm_search_cancel_notify, /* 14 BTA_DM_SEARCH_CANCEL_NOTIFY */
bta_dm_search_cancel_transac_cmpl, /* 15 BTA_DM_SEARCH_CANCEL_TRANSAC_CMPL */
bta_dm_disc_rmt_name, /* 16 BTA_DM_DISC_RMT_NAME */
bta_dm_di_disc /* 17 BTA_DM_API_DI_DISCOVER */
#if BLE_INCLUDED == TRUE
, bta_dm_close_gatt_conn
#endif

View File

@ -2050,6 +2050,22 @@ extern void BTA_DmBleSetAdvConfig (tBTA_BLE_AD_MASK data_mask,
tBTA_BLE_ADV_DATA *p_adv_cfg,
tBTA_SET_ADV_DATA_CMPL_CBACK *p_adv_data_cback);
/*******************************************************************************
**
** Function BTA_DmBleSetAdvConfigRaw
**
** Description This function is called to set raw Advertising data
**
** Parameters p_raw_adv : raw advertising data.
** raw_adv_len : raw advertising data length.
** p_adv_data_cback : set adv data complete callback.
**
** Returns None
**
*******************************************************************************/
extern void BTA_DmBleSetAdvConfigRaw (UINT8 *p_raw_adv, UINT32 raw_adv_len,
tBTA_SET_ADV_DATA_CMPL_CBACK *p_adv_data_cback);
/*******************************************************************************
**
** Function BTA_DmBleSetScanRsp
@ -2065,6 +2081,22 @@ extern void BTA_DmBleSetScanRsp (tBTA_BLE_AD_MASK data_mask,
tBTA_BLE_ADV_DATA *p_adv_cfg,
tBTA_SET_ADV_DATA_CMPL_CBACK *p_adv_data_cback);
/*******************************************************************************
**
** Function BTA_DmBleSetScanRspRaw
**
** Description This function is called to set raw scan response data
**
** Parameters p_raw_scan_rsp : raw scan_rspertising data.
** raw_scan_rsp_len : raw scan_rspertising data length.
** p_scan_rsp_data_cback : set scan_rsp data complete callback.
**
** Returns None
**
*******************************************************************************/
extern void BTA_DmBleSetScanRspRaw (UINT8 *p_raw_scan_rsp, UINT32 raw_scan_rsp_len,
tBTA_SET_ADV_DATA_CMPL_CBACK *p_scan_rsp_data_cback);
/*******************************************************************************
**
** Function BTA_DmBleBroadcast

View File

@ -177,6 +177,10 @@ static void blufi_profile_cb(tBTA_GATTS_EVT event, tBTA_GATTS *p_data)
blufi_env.prepare_buf = NULL;
}
break;
case BTA_GATTS_MTU_EVT:
LOG_DEBUG("MTU size %d\n", p_data->req_data.p_data->mtu);
blufi_env.frag_size = p_data->req_data.p_data->mtu - BLUFI_MTU_RESERVED_SIZE;
break;
case BTA_GATTS_CONF_EVT:
LOG_DEBUG("CONIRM EVT\n");
@ -198,7 +202,7 @@ static void blufi_profile_cb(tBTA_GATTS_EVT event, tBTA_GATTS *p_data)
BTA_GATTS_AddCharacteristic(blufi_env.handle_srvc, &blufi_char_uuid_e2p,
(GATT_PERM_READ),
(GATT_PERM_READ | GATT_CHAR_PROP_BIT_NOTIFY),
(GATT_CHAR_PROP_BIT_READ | GATT_CHAR_PROP_BIT_NOTIFY),
NULL, NULL);
break;
case BLUFI_CHAR_E2P_UUID: /* ESP32 to Phone */
@ -294,6 +298,7 @@ static tGATT_STATUS btc_blufi_profile_init(void)
memset(&blufi_env, 0x0, sizeof(blufi_env));
blufi_env.cbs = store_p; /* if set callback prior, restore the point */
blufi_env.frag_size = BLUFI_FRAG_DATA_DEFAULT_LEN;
/* register the BLUFI profile to the BTA_GATTS module*/
BTA_GATTS_AppRegister(&blufi_app_uuid, blufi_profile_cb);
@ -406,16 +411,16 @@ void btc_blufi_send_encap(uint8_t type, uint8_t *data, int total_data_len)
int ret;
while (remain_len > 0) {
if (remain_len > BLUFI_FRAG_DATA_MAX_LEN) {
hdr = GKI_getbuf(sizeof(struct blufi_hdr) + 2 + BLUFI_FRAG_DATA_MAX_LEN + 2);
if (remain_len > blufi_env.frag_size) {
hdr = GKI_getbuf(sizeof(struct blufi_hdr) + 2 + blufi_env.frag_size + 2);
if (hdr == NULL) {
LOG_ERROR("%s no mem\n", __func__);
return;
}
hdr->fc = 0x0;
hdr->data_len = BLUFI_FRAG_DATA_MAX_LEN + 2;
hdr->data_len = blufi_env.frag_size + 2;
*(uint16_t *)hdr->data = remain_len;
memcpy(hdr->data + 2, &data[total_data_len - remain_len], BLUFI_FRAG_DATA_MAX_LEN); //copy first, easy for check sum
memcpy(hdr->data + 2, &data[total_data_len - remain_len], blufi_env.frag_size); //copy first, easy for check sum
hdr->fc |= BLUFI_FC_FRAG;
} else {
hdr = GKI_getbuf(sizeof(struct blufi_hdr) + remain_len + 2);

View File

@ -33,6 +33,7 @@ typedef struct {
BD_ADDR remote_bda;
UINT32 trans_id;
UINT8 congest;
UINT16 frag_size;
#define BLUFI_PREPAIR_BUF_MAX_SIZE 1024
uint8_t *prepare_buf;
int prepare_len;
@ -160,7 +161,9 @@ typedef struct blufi_frag_hdr blufi_frag_hdr_t;
#define BLUFI_FC_IS_REQ_ACK(fc) ((fc) & BLUFI_FC_REQ_ACK_MASK)
#define BLUFI_FC_IS_FRAG(fc) ((fc) & BLUFI_FC_FRAG_MASK)
#define BLUFI_FRAG_DATA_MAX_LEN 50
/* BLUFI HEADER + TOTAL(REMAIN) LENGTH + CRC + L2CAP RESERVED */
#define BLUFI_MTU_RESERVED_SIZE (sizeof(struct blufi_hdr) + 2 + 2 + 3)
#define BLUFI_FRAG_DATA_DEFAULT_LEN (GATT_DEF_BLE_MTU_SIZE - BLUFI_MTU_RESERVED_SIZE)
//function declare
void btc_blufi_protocol_handler(uint8_t type, uint8_t *data, int len);

View File

@ -30,7 +30,7 @@ static inline void btc_gap_ble_cb_to_app(esp_gap_ble_cb_event_t event, esp_ble_g
{
esp_gap_ble_cb_t btc_gap_ble_cb = (esp_gap_ble_cb_t)btc_profile_cb_get(BTC_PID_GAP_BLE);
if (btc_gap_ble_cb) {
btc_gap_ble_cb(event, param);
btc_gap_ble_cb(event, param);
}
}
@ -303,6 +303,44 @@ static void btc_scan_rsp_data_callback(tBTA_STATUS status)
}
}
static void btc_adv_data_raw_callback(tBTA_STATUS status)
{
esp_ble_gap_cb_param_t param;
bt_status_t ret;
btc_msg_t msg;
msg.sig = BTC_SIG_API_CB;
msg.pid = BTC_PID_GAP_BLE;
msg.act = ESP_GAP_BLE_ADV_DATA_RAW_SET_COMPLETE_EVT;
param.adv_data_raw_cmpl.status = status;
ret = btc_transfer_context(&msg, &param,
sizeof(esp_ble_gap_cb_param_t), NULL);
if (ret != BT_STATUS_SUCCESS) {
LOG_ERROR("%s btc_transfer_context failed\n", __func__);
}
}
static void btc_scan_rsp_data_raw_callback(tBTA_STATUS status)
{
esp_ble_gap_cb_param_t param;
bt_status_t ret;
btc_msg_t msg;
msg.sig = BTC_SIG_API_CB;
msg.pid = BTC_PID_GAP_BLE;
msg.act = ESP_GAP_BLE_SCAN_RSP_DATA_RAW_SET_COMPLETE_EVT;
param.scan_rsp_data_raw_cmpl.status = status;
ret = btc_transfer_context(&msg, &param,
sizeof(esp_ble_gap_cb_param_t), NULL);
if (ret != BT_STATUS_SUCCESS) {
LOG_ERROR("%s btc_transfer_context failed\n", __func__);
}
}
static void btc_ble_set_adv_data(esp_ble_adv_data_t *adv_data,
tBTA_SET_ADV_DATA_CMPL_CBACK p_adv_data_cback)
{
@ -317,6 +355,18 @@ static void btc_ble_set_adv_data(esp_ble_adv_data_t *adv_data,
}
}
static void btc_ble_set_adv_data_raw(uint8_t *raw_adv, uint32_t raw_adv_len,
tBTA_SET_ADV_DATA_CMPL_CBACK p_adv_data_cback)
{
BTA_DmBleSetAdvConfigRaw(raw_adv, raw_adv_len, p_adv_data_cback);
}
static void btc_ble_set_scan_rsp_data_raw(uint8_t *raw_scan_rsp, uint32_t raw_scan_rsp_len,
tBTA_SET_ADV_DATA_CMPL_CBACK p_scan_rsp_data_cback)
{
BTA_DmBleSetScanRspRaw(raw_scan_rsp, raw_scan_rsp_len, p_scan_rsp_data_cback);
}
static void btc_ble_start_advertising (esp_ble_adv_params_t *ble_adv_params)
{
tBLE_BD_ADDR peer_addr;
@ -520,6 +570,12 @@ void btc_gap_ble_cb_handler(btc_msg_t *msg)
case ESP_GAP_BLE_SCAN_RESULT_EVT:
btc_gap_ble_cb_to_app(ESP_GAP_BLE_SCAN_RESULT_EVT, param);
break;
case ESP_GAP_BLE_ADV_DATA_RAW_SET_COMPLETE_EVT:
btc_gap_ble_cb_to_app(ESP_GAP_BLE_ADV_DATA_RAW_SET_COMPLETE_EVT, param);
break;
case ESP_GAP_BLE_SCAN_RSP_DATA_RAW_SET_COMPLETE_EVT:
btc_gap_ble_cb_to_app(ESP_GAP_BLE_SCAN_RSP_DATA_RAW_SET_COMPLETE_EVT, param);
break;
default:
break;
@ -551,6 +607,30 @@ void btc_gap_ble_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src)
}
break;
}
case BTC_GAP_BLE_ACT_CFG_ADV_DATA_RAW: {
btc_ble_gap_args_t *src = (btc_ble_gap_args_t *)p_src;
btc_ble_gap_args_t *dst = (btc_ble_gap_args_t *) p_dest;
if (src && src->cfg_adv_data_raw.raw_adv && src->cfg_adv_data_raw.raw_adv_len > 0) {
dst->cfg_adv_data_raw.raw_adv = GKI_getbuf(src->cfg_adv_data_raw.raw_adv_len);
if (dst->cfg_adv_data_raw.raw_adv) {
memcpy(dst->cfg_adv_data_raw.raw_adv, src->cfg_adv_data_raw.raw_adv, src->cfg_adv_data_raw.raw_adv_len);
}
}
break;
}
case BTC_GAP_BLE_ACT_CFG_SCAN_RSP_DATA_RAW: {
btc_ble_gap_args_t *src = (btc_ble_gap_args_t *)p_src;
btc_ble_gap_args_t *dst = (btc_ble_gap_args_t *) p_dest;
if (src && src->cfg_scan_rsp_data_raw.raw_scan_rsp && src->cfg_scan_rsp_data_raw.raw_scan_rsp_len > 0) {
dst->cfg_scan_rsp_data_raw.raw_scan_rsp = GKI_getbuf(src->cfg_scan_rsp_data_raw.raw_scan_rsp_len);
if (dst->cfg_scan_rsp_data_raw.raw_scan_rsp) {
memcpy(dst->cfg_scan_rsp_data_raw.raw_scan_rsp, src->cfg_scan_rsp_data_raw.raw_scan_rsp, src->cfg_scan_rsp_data_raw.raw_scan_rsp_len);
}
}
break;
}
default:
LOG_ERROR("Unhandled deep copy %d\n", msg->act);
break;
@ -576,6 +656,20 @@ static void btc_gap_ble_arg_deep_free(btc_msg_t *msg)
}
break;
}
case BTC_GAP_BLE_ACT_CFG_ADV_DATA_RAW: {
uint8_t *raw_adv = ((btc_ble_gap_args_t *)msg->arg)->cfg_adv_data_raw.raw_adv;
if (raw_adv) {
GKI_freebuf(raw_adv);
}
break;
}
case BTC_GAP_BLE_ACT_CFG_SCAN_RSP_DATA_RAW: {
uint8_t *raw_scan_rsp = ((btc_ble_gap_args_t *)msg->arg)->cfg_scan_rsp_data_raw.raw_scan_rsp;
if (raw_scan_rsp) {
GKI_freebuf(raw_scan_rsp);
}
break;
}
default:
LOG_DEBUG("Unhandled deep free %d\n", msg->act);
break;
@ -631,6 +725,16 @@ void btc_gap_ble_call_handler(btc_msg_t *msg)
case BTC_GAP_BLE_ACT_SET_DEV_NAME:
BTA_DmSetDeviceName(arg->set_dev_name.device_name);
break;
case BTC_GAP_BLE_ACT_CFG_ADV_DATA_RAW:
btc_ble_set_adv_data_raw(arg->cfg_adv_data_raw.raw_adv,
arg->cfg_adv_data_raw.raw_adv_len,
btc_adv_data_raw_callback);
break;
case BTC_GAP_BLE_ACT_CFG_SCAN_RSP_DATA_RAW:
btc_ble_set_scan_rsp_data_raw(arg->cfg_scan_rsp_data_raw.raw_scan_rsp,
arg->cfg_scan_rsp_data_raw.raw_scan_rsp_len,
btc_scan_rsp_data_raw_callback);
break;
default:
break;
}

View File

@ -448,7 +448,7 @@ static void btc_gattc_unreg_for_notify(btc_ble_gattc_args_t *arg)
memset(&param, 0, sizeof(esp_ble_gattc_cb_param_t));
param.unreg_for_notify.status = status;
memcpy(&param.unreg_for_notify.srvc_id, &arg->unreg_for_notify.service_id, sizeof(esp_gatt_srvc_id_t));
memcpy(&param.unreg_for_notify.char_id, &arg->unreg_for_notify.service_id, sizeof(esp_gatt_id_t));
memcpy(&param.unreg_for_notify.char_id, &arg->unreg_for_notify.char_id, sizeof(esp_gatt_id_t));
btc_gattc_cb_to_app(ESP_GATTC_UNREG_FOR_NOTIFY_EVT, arg->unreg_for_notify.gattc_if, &param);
}

View File

@ -32,6 +32,8 @@ typedef enum {
BTC_GAP_BLE_ACT_SET_RAND_ADDRESS,
BTC_GAP_BLE_ACT_CONFIG_LOCAL_PRIVACY,
BTC_GAP_BLE_ACT_SET_DEV_NAME,
BTC_GAP_BLE_ACT_CFG_ADV_DATA_RAW,
BTC_GAP_BLE_ACT_CFG_SCAN_RSP_DATA_RAW,
} btc_gap_ble_act_t;
/* btc_ble_gap_args_t */
@ -76,6 +78,16 @@ typedef union {
#define ESP_GAP_DEVICE_NAME_MAX (32)
char device_name[ESP_GAP_DEVICE_NAME_MAX + 1];
} set_dev_name;
//BTC_GAP_BLE_ACT_CFG_ADV_DATA_RAW,
struct config_adv_data_raw_args {
uint8_t *raw_adv;
uint32_t raw_adv_len;
} cfg_adv_data_raw;
//BTC_GAP_BLE_ACT_CFG_SCAN_RSP_DATA_RAW,
struct config_scan_rsp_data_raw_args {
uint8_t *raw_scan_rsp;
uint32_t raw_scan_rsp_len;
} cfg_scan_rsp_data_raw;
} btc_ble_gap_args_t;
void btc_gap_ble_call_handler(btc_msg_t *msg);

View File

@ -221,6 +221,10 @@ static void start_up(void)
}
if (HCI_LE_DATA_LEN_EXT_SUPPORTED(features_ble.as_array)) {
/* set default tx data length to MAX 251 */
response = AWAIT_COMMAND(packet_factory->make_ble_write_suggested_default_data_length(BTM_BLE_DATA_SIZE_MAX, BTM_BLE_DATA_TX_TIME_MAX));
packet_parser->parse_generic_command_complete(response);
response = AWAIT_COMMAND(packet_factory->make_ble_read_suggested_default_data_length());
packet_parser->parse_ble_read_suggested_default_data_length_response(
response,

View File

@ -154,6 +154,17 @@ static BT_HDR *make_ble_read_suggested_default_data_length(void)
return make_command_no_params(HCI_BLE_READ_DEFAULT_DATA_LENGTH);
}
static BT_HDR *make_ble_write_suggested_default_data_length(uint16_t SuggestedMaxTxOctets, uint16_t SuggestedMaxTxTime)
{
uint8_t *stream;
uint8_t parameter_size = sizeof(uint16_t) + sizeof(uint16_t);
BT_HDR *packet = make_command(HCI_BLE_WRITE_DEFAULT_DATA_LENGTH, parameter_size, &stream);
UINT16_TO_STREAM(stream, SuggestedMaxTxOctets);
UINT16_TO_STREAM(stream, SuggestedMaxTxTime);
return packet;
}
static BT_HDR *make_ble_set_event_mask(const bt_event_mask_t *event_mask)
{
uint8_t *stream;
@ -215,6 +226,7 @@ static const hci_packet_factory_t interface = {
make_ble_read_local_supported_features,
make_ble_read_resolving_list_size,
make_ble_read_suggested_default_data_length,
make_ble_write_suggested_default_data_length,
make_ble_set_event_mask
};

View File

@ -40,6 +40,7 @@ typedef struct {
BT_HDR *(*make_ble_read_local_supported_features)(void);
BT_HDR *(*make_ble_read_resolving_list_size)(void);
BT_HDR *(*make_ble_read_suggested_default_data_length)(void);
BT_HDR *(*make_ble_write_suggested_default_data_length)(uint16_t SuggestedMaxTxOctets, uint16_t SuggestedMaxTxTime);
BT_HDR *(*make_ble_set_event_mask)(const bt_event_mask_t *event_mask);
} hci_packet_factory_t;

View File

@ -1298,6 +1298,26 @@ tBTM_STATUS BTM_BleWriteScanRsp(tBTM_BLE_AD_MASK data_mask, tBTM_BLE_ADV_DATA *p
return status;
}
/*******************************************************************************
**
** Function BTM_BleWriteScanRspRaw
**
** Description This function is called to write raw scan response data
**
** Parameters: None.
**
** Returns void
**
*******************************************************************************/
tBTM_STATUS BTM_BleWriteScanRspRaw(UINT8 *p_raw_scan_rsp, UINT32 raw_scan_rsp_len)
{
if (btsnd_hcic_ble_set_scan_rsp_data((UINT8)raw_scan_rsp_len, p_raw_scan_rsp)) {
return BTM_SUCCESS;
} else {
return BTM_NO_RESOURCES;
}
}
/*******************************************************************************
**
** Function BTM_BleWriteAdvData
@ -1345,6 +1365,27 @@ tBTM_STATUS BTM_BleWriteAdvData(tBTM_BLE_AD_MASK data_mask, tBTM_BLE_ADV_DATA *p
}
/*******************************************************************************
**
** Function BTM_BleWriteAdvDataRaw
**
** Description This function is called to write raw advertising data.
**
** Parameters: None.
**
** Returns void
**
*******************************************************************************/
tBTM_STATUS BTM_BleWriteAdvDataRaw(UINT8 *p_raw_adv, UINT32 raw_adv_len)
{
if (btsnd_hcic_ble_set_adv_data((UINT8)raw_adv_len, p_raw_adv)) {
return BTM_SUCCESS;
} else {
return BTM_NO_RESOURCES;
}
}
/*******************************************************************************
**
** Function BTM_BleSetRandAddress

View File

@ -651,27 +651,28 @@ tGATT_STATUS gatts_set_attribute_value(tGATT_SVC_DB *p_db, UINT16 attr_handle,
case GATT_UUID_INCLUDE_SERVICE:
return GATT_NOT_FOUND;
default:
if (p_cur->p_value->attr_val.attr_max_len < length) {
if (p_cur->p_value != NULL && p_cur->p_value->attr_val.attr_max_len < length) {
GATT_TRACE_ERROR("gatts_set_attribute_vaule failt:Invalid value length");
return GATT_INVALID_ATTR_LEN;
} else {
} else if (p_cur->p_value != NULL && p_cur->p_value->attr_val.attr_max_len > 0) {
memcpy(p_cur->p_value->attr_val.attr_val, value, length);
p_cur->p_value->attr_val.attr_len = length;
} else {
return GATT_INVALID_ATTR_LEN;
}
break;
}
} else {
if (p_cur->p_value->attr_val.attr_max_len < length) {
if (p_cur->p_value != NULL && p_cur->p_value->attr_val.attr_max_len < length) {
GATT_TRACE_ERROR("gatts_set_attribute_vaule failt:Invalid value length");
} else {
} else if (p_cur->p_value != NULL && p_cur->p_value->attr_val.attr_max_len > 0) {
memcpy(p_cur->p_value->attr_val.attr_val, value, length);
p_cur->p_value->attr_val.attr_len = length;
} else {
return GATT_INVALID_ATTR_LEN;
}
}
break;
}
p_cur = p_cur->p_next;
@ -699,8 +700,9 @@ tGATT_STATUS gatts_get_attribute_value(tGATT_SVC_DB *p_db, UINT16 attr_handle,
UINT16 *length, UINT8 **value)
{
tGATT_ATTR16 *p_cur;
GATT_TRACE_DEBUG("***********%s*************\n", __func__);
GATT_TRACE_DEBUG("attr_handle = %x\n", attr_handle);
if (p_db == NULL) {
GATT_TRACE_ERROR("gatts_get_attribute_value Fail:p_db is NULL.\n");
return GATT_INVALID_PDU;
@ -713,7 +715,6 @@ tGATT_STATUS gatts_get_attribute_value(tGATT_SVC_DB *p_db, UINT16 attr_handle,
p_cur = (tGATT_ATTR16 *) p_db->p_attr_list;
while (p_cur != NULL) {
LOG_ERROR("p_ur->handle = %x\n", p_cur->handle);
if (p_cur->handle == attr_handle) {
if (p_cur->uuid_type == GATT_ATTR_UUID_TYPE_16) {
@ -722,7 +723,7 @@ tGATT_STATUS gatts_get_attribute_value(tGATT_SVC_DB *p_db, UINT16 attr_handle,
case GATT_UUID_INCLUDE_SERVICE:
break;
default:
if (p_cur->p_value->attr_val.attr_len != 0) {
if (p_cur->p_value && p_cur->p_value->attr_val.attr_len != 0) {
*length = p_cur->p_value->attr_val.attr_len;
*value = p_cur->p_value->attr_val.attr_val;
return GATT_SUCCESS;
@ -748,7 +749,6 @@ tGATT_STATUS gatts_get_attribute_value(tGATT_SVC_DB *p_db, UINT16 attr_handle,
}
p_cur = p_cur->p_next;
}
@ -1332,7 +1332,13 @@ static tGATT_STATUS gatts_send_app_read_request(tGATT_TCB *p_tcb, UINT8 op_code,
gatt_sr_send_req_callback(conn_id,
trans_id, GATTS_REQ_TYPE_READ, &sr_data);
return (tGATT_STATUS) GATT_PENDING;
if (need_rsp) {
return (tGATT_STATUS) GATT_PENDING;
}
else{
return (tGATT_STATUS) GATT_STACK_RSP;
}
} else {
return (tGATT_STATUS) GATT_BUSY; /* max pending command, application error */
}

View File

@ -1073,9 +1073,11 @@ void gatts_process_write_req (tGATT_TCB *p_tcb, UINT8 i_rcb, UINT16 handle,
GATTS_REQ_TYPE_WRITE,
&sr_data);
if(status == GATT_SUCCESS){
if (status == GATT_SUCCESS) {
attp_send_sr_msg(p_tcb, p_msg);
gatt_dequeue_sr_cmd(p_tcb);
} else {
GKI_freebuf(p_msg);
}
} else {
@ -1159,9 +1161,13 @@ static void gatts_process_read_req(tGATT_TCB *p_tcb, tGATT_SR_REG *p_rcb, UINT8
gatt_send_error_rsp (p_tcb, reason, op_code, handle, FALSE);
gatt_dequeue_sr_cmd(p_tcb);
}
} else {
} else if (reason == GATT_SUCCESS || reason == GATT_STACK_RSP) {
attp_send_sr_msg(p_tcb, p_msg);
gatt_dequeue_sr_cmd(p_tcb);
} else {
if (p_msg) {
GKI_freebuf(p_msg);
}
}
}

View File

@ -936,6 +936,22 @@ tBTM_STATUS BTM_BleSetAdvParamsStartAdv(UINT16 adv_int_min, UINT16 adv_int_max,
tBTM_STATUS BTM_BleWriteAdvData(tBTM_BLE_AD_MASK data_mask,
tBTM_BLE_ADV_DATA *p_data);
/*******************************************************************************
**
** Function BTM_BleWriteAdvDataRaw
**
** Description This function is called to write raw advertising data.
**
** Parameters: p_raw_adv : point to raw advertising data
** raw_adv_len : raw advertising data
**
** Returns BTM_SUCCESS means success.
**
*******************************************************************************/
//extern
tBTM_STATUS BTM_BleWriteAdvDataRaw(UINT8 *p_raw_adv, UINT32 raw_adv_len);
BOOLEAN BTM_BleSetRandAddress(BD_ADDR rand_addr);
@ -1136,6 +1152,20 @@ tBTM_STATUS BTM_BleTrackAdvertiser(tBTM_BLE_TRACK_ADV_CBACK *p_track_cback,
tBTM_STATUS BTM_BleWriteScanRsp(tBTM_BLE_AD_MASK data_mask,
tBTM_BLE_ADV_DATA *p_data);
/*******************************************************************************
**
** Function BTM_BleWriteScanRspRaw
**
** Description This function is called to write raw scan response data
**
** Parameters: None.
**
** Returns void
**
*******************************************************************************/
//extern
tBTM_STATUS BTM_BleWriteScanRspRaw(UINT8 *p_raw_scan_rsp, UINT32 raw_scan_rsp_len);
/*******************************************************************************
**
** Function BTM_BleObserve

View File

@ -27,6 +27,7 @@
#include "esp_task.h"
#include "esp_intr.h"
#include "esp_attr.h"
#include "esp_phy_init.h"
#include "bt.h"
#if CONFIG_BT_ENABLED
@ -34,6 +35,11 @@
/* not for user call, so don't put to include file */
extern void btdm_osi_funcs_register(void *osi_funcs);
extern void btdm_controller_init(void);
extern void btdm_controller_schedule(void);
extern void btdm_controller_deinit(void);
extern int btdm_controller_enable(esp_bt_mode_t mode);
extern int btdm_controller_disable(esp_bt_mode_t mode);
extern void btdm_rf_bb_init(void);
/* VHCI function interface */
typedef struct vhci_host_callback {
@ -70,6 +76,12 @@ struct osi_funcs_t {
esp_err_t (* _read_efuse_mac)(uint8_t mac[6]);
};
/* Static variable declare */
static bool btdm_bb_init_flag = false;
static esp_bt_controller_status_t btdm_controller_status = ESP_BT_CONTROLLER_STATUS_IDLE;
static xTaskHandle btControllerTaskHandle;
static portMUX_TYPE global_int_mux = portMUX_INITIALIZER_UNLOCKED;
static void IRAM_ATTR interrupt_disable(void)
@ -145,14 +157,87 @@ void esp_vhci_host_register_callback(const esp_vhci_host_callback_t *callback)
static void bt_controller_task(void *pvParam)
{
btdm_osi_funcs_register(&osi_funcs);
btdm_controller_init();
btdm_controller_status = ESP_BT_CONTROLLER_STATUS_INITED;
/* Loop */
btdm_controller_schedule();
}
void esp_bt_controller_init()
{
if (btdm_controller_status != ESP_BT_CONTROLLER_STATUS_IDLE) {
return;
}
xTaskCreatePinnedToCore(bt_controller_task, "btController",
ESP_TASK_BT_CONTROLLER_STACK, NULL,
ESP_TASK_BT_CONTROLLER_PRIO, NULL, 0);
ESP_TASK_BT_CONTROLLER_PRIO, &btControllerTaskHandle, 0);
}
void esp_bt_controller_deinit(void)
{
vTaskDelete(btControllerTaskHandle);
btdm_controller_status = ESP_BT_CONTROLLER_STATUS_IDLE;
}
esp_err_t esp_bt_controller_enable(esp_bt_mode_t mode)
{
int ret;
if (btdm_controller_status != ESP_BT_CONTROLLER_STATUS_INITED) {
return ESP_ERR_INVALID_STATE;
}
if (mode != ESP_BT_MODE_BTDM) {
return ESP_ERR_INVALID_ARG;
}
esp_phy_load_cal_and_init();
if (btdm_bb_init_flag == false) {
btdm_bb_init_flag = true;
btdm_rf_bb_init(); /* only initialise once */
}
ret = btdm_controller_enable(mode);
if (ret) {
return ESP_ERR_INVALID_STATE;
}
btdm_controller_status = ESP_BT_CONTROLLER_STATUS_ENABLED;
return ESP_OK;
}
esp_err_t esp_bt_controller_disable(esp_bt_mode_t mode)
{
int ret;
if (btdm_controller_status != ESP_BT_CONTROLLER_STATUS_ENABLED) {
return ESP_ERR_INVALID_STATE;
}
if (mode != ESP_BT_MODE_BTDM) {
return ESP_ERR_INVALID_ARG;
}
ret = btdm_controller_disable(mode);
if (ret) {
return ESP_ERR_INVALID_STATE;
}
esp_phy_rf_deinit();
btdm_controller_status = ESP_BT_CONTROLLER_STATUS_INITED;
return ESP_OK;
}
esp_bt_controller_status_t esp_bt_controller_get_status(void)
{
return btdm_controller_status;
}
#endif

View File

@ -23,14 +23,63 @@
extern "C" {
#endif
/**
* @brief Bluetooth mode for controller enable/disable
*/
typedef enum {
ESP_BT_MODE_ILDE = 0x00, /*!< Bluetooth is not run */
ESP_BT_MODE_BLE = 0x01, /*!< Run BLE mode */
ESP_BT_MODE_CLASSIC_BT = 0x02, /*!< Run Classic BT mode */
ESP_BT_MODE_BTDM = 0x03, /*!< Run dual mode */
} esp_bt_mode_t;
/**
* @brief Initialize BT controller
* @brief Bluetooth controller enable/disable/initialised/de-initialised status
*/
typedef enum {
ESP_BT_CONTROLLER_STATUS_IDLE = 0,
ESP_BT_CONTROLLER_STATUS_INITED,
ESP_BT_CONTROLLER_STATUS_ENABLED,
ESP_BT_CONTROLLER_STATUS_NUM,
} esp_bt_controller_status_t;
/**
* @brief Initialize BT controller to allocate task and other resource.
*
* This function should be called only once, before any other BT functions are called.
*/
void esp_bt_controller_init(void);
/**
* @brief De-initialize BT controller to free resource and delete task.
*
* This function should be called only once, after any other BT functions are called.
* This function is not whole completed, esp_bt_controller_init cannot called after this function.
*/
void esp_bt_controller_deinit(void);
/**
* @brief Enable BT controller
* @param mode : the mode(BLE/BT/BTDM) to enable.
* Now only support BTDM.
* @return ESP_OK - success, other - failed
*/
esp_err_t esp_bt_controller_enable(esp_bt_mode_t mode);
/**
* @brief Disable BT controller
* @param mode : the mode(BLE/BT/BTDM) to disable.
* Now only support BTDM.
* @return ESP_OK - success, other - failed
*/
esp_err_t esp_bt_controller_disable(esp_bt_mode_t mode);
/**
* @brief Get BT controller is initialised/de-initialised/enabled/disabled
* @return status value
*/
esp_bt_controller_status_t esp_bt_controller_get_status(void);
/** @brief esp_vhci_host_callback
* used for vhci call host function to notify what host need to do
*/

@ -1 +1 @@
Subproject commit 9c1eea6bb03adc3b3847fff79c3f017652840a46
Subproject commit dbac82b5c2694f2639161b0a2b3c0bd8c7d3efc5

View File

@ -133,10 +133,10 @@ esp_err_t gpio_set_intr_type(gpio_num_t gpio_num, gpio_int_type_t intr_type)
return ESP_OK;
}
esp_err_t gpio_intr_enable(gpio_num_t gpio_num)
static esp_err_t gpio_intr_enable_on_core (gpio_num_t gpio_num, uint32_t core_id)
{
GPIO_CHECK(GPIO_IS_VALID_GPIO(gpio_num), "GPIO number error", ESP_ERR_INVALID_ARG);
if (xPortGetCoreID() == 0) {
if (core_id == 0) {
GPIO.pin[gpio_num].int_ena = GPIO_PRO_CPU_INTR_ENA; //enable pro cpu intr
} else {
GPIO.pin[gpio_num].int_ena = GPIO_APP_CPU_INTR_ENA; //enable pro cpu intr
@ -144,6 +144,11 @@ esp_err_t gpio_intr_enable(gpio_num_t gpio_num)
return ESP_OK;
}
esp_err_t gpio_intr_enable(gpio_num_t gpio_num)
{
return gpio_intr_enable_on_core (gpio_num, xPortGetCoreID());
}
esp_err_t gpio_intr_disable(gpio_num_t gpio_num)
{
GPIO_CHECK(GPIO_IS_VALID_GPIO(gpio_num), "GPIO number error", ESP_ERR_INVALID_ARG);
@ -380,7 +385,7 @@ esp_err_t gpio_isr_handler_add(gpio_num_t gpio_num, gpio_isr_t isr_handler, void
gpio_isr_func[gpio_num].fn = isr_handler;
gpio_isr_func[gpio_num].args = args;
}
gpio_intr_enable(gpio_num);
gpio_intr_enable_on_core (gpio_num, esp_intr_get_cpu(gpio_isr_handle));
portEXIT_CRITICAL(&gpio_spinlock);
return ESP_OK;
}

View File

@ -49,11 +49,11 @@ typedef enum {
} adc1_channel_t;
/**
* @brief Configuration ADC1 capture width.
* @brief Configure ADC1 capture width.
*
* The configuration is in effect for all channels of ADC1
* The configuration is for all channels of ADC1
*
* @param width_bit ADC1
* @param width_bit Bit capture width for ADC1
*
* @return
* - ESP_OK success
@ -62,10 +62,29 @@ typedef enum {
esp_err_t adc1_config_width(adc_bits_width_t width_bit);
/**
* @brief Configuration ADC1 capture attenuation of channels.
* @brief Configure the ADC1 channel, including setting attenuation.
*
* @param channel the ADC1 channel
* @param atten attenuation
* @note This function also configures the input GPIO pin mux to
* connect it to the ADC1 channel. It must be called before calling
* adc1_get_voltage() for this channel.
*
* The default ADC full-scale voltage is 1.1V. To read higher voltages (up to the pin maximum voltage,
* usually 3.3V) requires setting >0dB signal attenuation for that ADC channel.
*
* When VDD_A is 3.3V:
*
* - 0dB attenuaton (ADC_ATTEN_0db) gives full-scale voltage 1.1V
* - 2.5dB attenuation (ADC_ATTEN_2_5db) gives full-scale voltage 1.5V
* - 6dB attenuation (ADC_ATTEN_6db) gives full-scale voltage 2.2V
* - 11dB attenuation (ADC_ATTEN_11db) gives full-scale voltage 3.9V (see note below)
*
* @note The full-scale voltage is the voltage corresponding to a maximum reading (depending on ADC1 configured
* bit width, this value is: 4095 for 12-bits, 2047 for 11-bits, 1023 for 10-bits, 511 for 9 bits.)
*
* @note At 11dB attenuation the maximum voltage is limited by VDD_A, not the full scale voltage.
*
* @param channel ADC1 channel to configure
* @param atten Attenuation level
*
* @return
* - ESP_OK success
@ -74,46 +93,38 @@ esp_err_t adc1_config_width(adc_bits_width_t width_bit);
esp_err_t adc1_config_channel_atten(adc1_channel_t channel, adc_atten_t atten);
/**
* @brief ADC1 get the value of the voltage.
* @brief Take an ADC1 reading on a single channel
*
* @param channel the ADC1 channel
* @note Call adc1_config_width() before the first time this
* function is called.
*
* @note For a given channel, adc1_config_channel_atten(channel)
* must be called before the first time this function is called.
*
* @param channel ADC1 channel to read
*
* @return
* - -1 Parameter error
* - Other the value of ADC1 channel
* - -1: Parameter error
* - Other: ADC1 channel reading.
*/
int adc1_get_voltage(adc1_channel_t channel);
/**
* @brief Hall Sensor output value.
* @note
* The Hall Sensor uses Channel_0 and Channel_3 of ADC1.
* So, firstly: please configure ADC1 module by calling adc1_config_width before calling hall_sensor_read.
We recommend that the WIDTH ADC1 be configured as 12Bit, because the values of hall_sensor_read are small and almost the same if WIDTH ADC1 is configured as 9Bit, 10Bit or 11Bit.
* secondly: when you use the hall sensor, please do not use Channel_0 and Channel_3 of ADC1 as
* ADC channels.
* @brief Read Hall Sensor
*
* @return the value of hall sensor
* @note The Hall Sensor uses channels 0 and 3 of ADC1. Do not configure
* these channels for use as ADC channels.
*
* @note The ADC1 module must be enabled by calling
* adc1_config_width() before calling hall_sensor_read(). ADC1
* should be configured for 12 bit readings, as the hall sensor
* readings are low values and do not cover the full range of the
* ADC.
*
* @return The hall sensor reading.
*/
int hall_sensor_read();
/**
*----------EXAMPLE TO USE ADC1------------ *
* @code{c}
* adc1_config_width(ADC_WIDTH_12Bit);//config adc1 width
* adc1_config_channel_atten(ADC1_CHANNEL_0,ADC_ATTEN_0db);//config channel0 attenuation
* int val=adc1_get_voltage(ADC1_CHANNEL_0);//get the val of channel0
* @endcode
**/
/**
*----------EXAMPLE TO USE HALL SENSOR------------ *
* @code{c}
* adc1_config_width(ADC_WIDTH_12Bit);//config adc1 width
* int val=hall_sensor_read();
* @endcode
**/
#ifdef __cplusplus
}
#endif

View File

@ -29,12 +29,15 @@ typedef enum {
} dac_channel_t;
/**
* @brief Set Dac output voltage.
* @brief Set DAC output voltage.
*
* Dac width is 8bit ,and the voltage max is vdd
* DAC output is 8-bit. Maximum (255) corresponds to VDD.
*
* @param channel dac channel
* @param dac_value dac output value
* @note When this function is called, function for the DAC
* channel's GPIO pin is reconfigured for RTC DAC function.
*
* @param channel DAC channel
* @param dac_value DAC output value
*
* @return
* - ESP_OK success
@ -42,13 +45,6 @@ typedef enum {
*/
esp_err_t dac_out_voltage(dac_channel_t channel, uint8_t dac_value);
/**
*----------EXAMPLE TO USE DAC------------ *
* @code{c}
* dac_out_voltage(DAC_CHANNEL_1,200);//the dac out voltage ≈ 200*vdd/255
* @endcode
**/
#ifdef __cplusplus
}
#endif

View File

@ -302,9 +302,9 @@ int gpio_get_level(gpio_num_t gpio_num);
esp_err_t gpio_set_direction(gpio_num_t gpio_num, gpio_mode_t mode);
/**
* @brief GPIO set pull
* @brief Configure GPIO pull-up/pull-down resistors
*
* User this Function,configure GPIO pull mode,such as pull-up,pull-down
* Only pins that support both input & output have integrated pull-up and pull-down resistors. Input-only GPIOs 34-39 do not.
*
* @param gpio_num GPIO number. If you want to set pull up or down mode for e.g. GPIO16, gpio_num should be GPIO_NUM_16 (16);
* @param pull GPIO pull up/down mode.
@ -317,7 +317,7 @@ esp_err_t gpio_set_direction(gpio_num_t gpio_num, gpio_mode_t mode);
esp_err_t gpio_set_pull_mode(gpio_num_t gpio_num, gpio_pull_mode_t pull);
/**
* @brief enable GPIO wake-up function.
* @brief Enable GPIO wake-up function.
*
* @param gpio_num GPIO number.
*
@ -341,15 +341,23 @@ esp_err_t gpio_wakeup_enable(gpio_num_t gpio_num, gpio_int_type_t intr_type);
esp_err_t gpio_wakeup_disable(gpio_num_t gpio_num);
/**
* @brief register GPIO interrupt handler, the handler is an ISR.
* @brief Register GPIO interrupt handler, the handler is an ISR.
* The handler will be attached to the same CPU core that this function is running on.
*
* This ISR function is called whenever any GPIO interrupt occurs. See
* the alternative gpio_install_isr_service() and
* gpio_isr_handler_add() API in order to have the driver support
* per-GPIO ISRs.
*
* @param fn Interrupt handler function.
* @param intr_alloc_flags Flags used to allocate the interrupt. One or multiple (ORred)
* ESP_INTR_FLAG_* values. See esp_intr_alloc.h for more info.
* @param arg Parameter for handler function
* @param handle Pointer to return handle. If non-NULL, a handle for the interrupt will
* be returned here.
* @param handle Pointer to return handle. If non-NULL, a handle for the interrupt will be returned here.
*
* \verbatim embed:rst:leading-asterisk
* To disable or remove the ISR, pass the returned handle to the :doc:`interrupt allocation functions </api/system/intr_alloc>`.
* \endverbatim
*
* @return
* - ESP_OK Success ;
@ -402,7 +410,9 @@ esp_err_t gpio_pulldown_en(gpio_num_t gpio_num);
esp_err_t gpio_pulldown_dis(gpio_num_t gpio_num);
/**
* @brief Install a GPIO ISR service, so we can assign different ISR handler for different pins
* @brief Install the driver's GPIO ISR handler service, which allows per-pin GPIO interrupt handlers.
*
* This function is incompatible with gpio_isr_register() - if that function is used, a single global ISR is registered for all GPIO interrupts. If this function is used, the ISR service provides a global GPIO ISR and individual pin handlers are registered via the gpio_isr_register() function.
*
* @param intr_alloc_flags Flags used to allocate the interrupt. One or multiple (ORred)
* ESP_INTR_FLAG_* values. See esp_intr_alloc.h for more info.
@ -415,17 +425,24 @@ esp_err_t gpio_pulldown_dis(gpio_num_t gpio_num);
esp_err_t gpio_install_isr_service(int intr_alloc_flags);
/**
* @brief Un-install GPIO ISR service, free the resources.
* @brief Uninstall the driver's GPIO ISR service, freeing related resources.
*/
void gpio_uninstall_isr_service();
/**
* @brief Add ISR handler for the corresponding GPIO.
* @brief Add ISR handler for the corresponding GPIO pin.
*
* Interrupt handlers no longer need to be declared with IRAM_ATTR, unless you pass the ESP_INTR_FLAG_IRAM flag
* when allocating the ISR in gpio_install_isr_service().
* This ISR handler will be called from an ISR. So there probably is some stack size limit, and this limit
* is smaller compared to a "raw" interrupt handler due to another level of indirection.
* Call this function after using gpio_install_isr_service() to
* install the driver's GPIO ISR handler service.
*
* The pin ISR handlers no longer need to be declared with IRAM_ATTR,
* unless you pass the ESP_INTR_FLAG_IRAM flag when allocating the
* ISR in gpio_install_isr_service().
*
* This ISR handler will be called from an ISR. So there is a stack
* size limit (configurable as "ISR stack size" in menuconfig). This
* limit is smaller compared to a global GPIO interrupt handler due
* to the additional level of indirection.
*
* @param gpio_num GPIO number
* @param isr_handler ISR handler function for the corresponding GPIO number.
@ -439,7 +456,7 @@ void gpio_uninstall_isr_service();
esp_err_t gpio_isr_handler_add(gpio_num_t gpio_num, gpio_isr_t isr_handler, void* args);
/**
* @brief Remove ISR handler for the corresponding GPIO.
* @brief Remove ISR handler for the corresponding GPIO pin.
*
* @param gpio_num GPIO number
*

View File

@ -32,9 +32,6 @@
extern "C" {
#endif
#define I2S_PIN_NO_CHANGE (-1)
/**
* @brief I2S bit width per sample.
*
@ -147,6 +144,8 @@ typedef struct {
size_t size; /*!< I2S data size for I2S_DATA event*/
} i2s_event_t;
#define I2S_PIN_NO_CHANGE (-1) /*!< Use in i2s_pin_config_t for pins which should not be changed */
/**
* @brief I2S pin number for i2s_set_pin
*
@ -160,15 +159,18 @@ typedef struct {
typedef intr_handle_t i2s_isr_handle_t;
/**
* @brief Set I2S pin number
* @brief Set I2S pin number
*
* @note
* Internal signal can be output to multiple GPIO pads
* Only one GPIO pad can connect with input signal
* @note
* The I2S peripheral output signals can be connected to multiple GPIO pads.
* However, the I2S peripheral input signal can only be connected to one GPIO pad.
*
* @param i2s_num I2S_NUM_0 or I2S_NUM_1
*
* @param pin I2S Pin struct, or NULL for 2-channels, 8-bits DAC pin configuration (GPIO25 & GPIO26)
* @param pin I2S Pin structure, or NULL to set 2-channel 8-bit internal DAC pin configuration (GPIO25 & GPIO26)
*
* Inside the pin configuration structure, set I2S_PIN_NO_CHANGE for any pin where
* the current configuration should not be changed.
*
* @return
* - ESP_OK Success
@ -177,15 +179,17 @@ typedef intr_handle_t i2s_isr_handle_t;
esp_err_t i2s_set_pin(i2s_port_t i2s_num, const i2s_pin_config_t *pin);
/**
* @brief i2s install and start driver
* @brief Install and start I2S driver.
*
* @param i2s_num I2S_NUM_0, I2S_NUM_1
* @param i2s_num I2S_NUM_0, I2S_NUM_1
*
* @param i2s_config I2S configurations - see i2s_config_t struct
* @param i2s_config I2S configurations - see i2s_config_t struct
*
* @param queue_size I2S event queue size/depth.
* @param queue_size I2S event queue size/depth.
*
* @param i2s_queue I2S event queue handle, if set NULL, driver will not use an event queue.
* @param i2s_queue I2S event queue handle, if set NULL, driver will not use an event queue.
*
* This function must be called before any I2S driver read/write operations.
*
* @return
* - ESP_OK Success
@ -205,68 +209,88 @@ 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 i2s read data buffer to i2s dma buffer
* @brief Write data to I2S DMA transmit buffer.
*
* @param i2s_num I2S_NUM_0, I2S_NUM_1
*
* @param src source address to write
* @param src Source address to write from
*
* @param size size of data (size in bytes)
* @param size Size of data in bytes
*
* @param ticks_to_wait Write timeout
* @param ticks_to_wait TX buffer wait timeout in RTOS ticks. If this
* many ticks pass without space becoming available in the DMA
* transmit buffer, then the function will return (note that if the
* data is written to the DMA buffer in pieces, the overall operation
* may still take longer than this timeout.) Pass portMAX_DELAY for no
* timeout.
*
* @return number of written bytes
* Format of the data in source buffer is determined by the I2S
* configuration (see i2s_config_t).
*
* @return Number of bytes written, or ESP_FAIL (-1) for parameter error. If a timeout occurred, bytes written will be less than total size.
*/
int i2s_write_bytes(i2s_port_t i2s_num, const char *src, size_t size, TickType_t ticks_to_wait);
/**
* @brief i2s write data buffer to i2s dma buffer
* @brief Read data from I2S DMA receive buffer
*
* @param i2s_num I2S_NUM_0, I2S_NUM_1
*
* @param dest destination address to read
* @param dest Destination address to read into
*
* @param size size of data (size in bytes)
* @param size Size of data in bytes
*
* @param ticks_to_wait Read timeout
* @param ticks_to_wait RX buffer wait timeout in RTOS ticks. If this many ticks pass without bytes becoming available in the DMA receive buffer, then the function will return (note that if data is read from the DMA buffer in pieces, the overall operation may still take longer than this timeout.) Pass portMAX_DELAY for no timeout.
*
* @return number of read bytes
* Format of the data in source buffer is determined by the I2S
* configuration (see i2s_config_t).
*
* @return Number of bytes read, or ESP_FAIL (-1) for parameter error. If a timeout occurred, bytes read will be less than total size.
*/
int i2s_read_bytes(i2s_port_t i2s_num, char* dest, size_t size, TickType_t ticks_to_wait);
/**
* @brief i2s push 1 sample to i2s dma buffer, with the size parameter equal to one sample's size in bytes = bits_per_sample/8.
* @brief Push (write) a single sample to the I2S DMA TX buffer.
*
* Size of the sample is determined by the channel_format (mono or stereo)) & bits_per_sample configuration (see i2s_config_t).
*
* @param i2s_num I2S_NUM_0, I2S_NUM_1
*
* @param sample destination address to write (depend on bits_per_sample, size of sample (in bytes) = 2*bits_per_sample/8)
* @param sample Pointer to buffer containing sample to write. Size of buffer (in bytes) = (number of channels) * bits_per_sample / 8.
*
* @param ticks_to_wait Push timeout
* @param ticks_to_wait Push timeout in RTOS ticks. If space is not available in the DMA TX buffer within this period, no data is written and function returns 0.
*
* @return number of push bytes
* @return Number of bytes successfully pushed to DMA buffer, or ESP_FAIL (-1) for parameter error. Will be either zero or the size of configured sample buffer.
*/
int i2s_push_sample(i2s_port_t i2s_num, const char *sample, TickType_t ticks_to_wait);
/**
* @brief Pop 1 sample to i2s dma buffer, with the size parameter equal to one sample's size in bytes = bits_per_sample/8.
* @brief Pop (read) a single sample from the I2S DMA RX buffer.
*
* Size of the sample is determined by the channel_format (mono or stereo)) & bits_per_sample configuration (see i2s_config_t).
*
* @param i2s_num I2S_NUM_0, I2S_NUM_1
*
* @param sample destination address to write (depend on bits_per_sample, size of sample (in bytes) = 2*bits_per_sample/8)
* @param sample Buffer sample data will be read into. Size of buffer (in bytes) = (number of channels) * bits_per_sample / 8.
*
* @param ticks_to_wait Pop timeout
* @param ticks_to_wait Pop 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 pop bytes
* @return Number of bytes successfully read from DMA buffer, or ESP_FAIL (-1) for parameter error. Byte count will be either zero or the size of the configured sample buffer.
*/
int i2s_pop_sample(i2s_port_t i2s_num, char *sample, TickType_t ticks_to_wait);
/**
* @brief Set clock rate used for I2S RX and TX
* @brief Set sample rate used for I2S RX and TX.
*
* The bit clock rate is determined by the sample rate and i2s_config_t configuration parameters (number of channels, bits_per_sample).
*
* `bit_clock = rate * (number of channels) * bits_per_sample`
*
* @param i2s_num I2S_NUM_0, I2S_NUM_1
*
* @param rate I2S clock (ex: 8000, 44100...)
* @param rate I2S sample rate (ex: 8000, 44100...)
*
* @return
* - ESP_OK Success
@ -275,18 +299,9 @@ int i2s_pop_sample(i2s_port_t i2s_num, char *sample, TickType_t ticks_to_wait);
esp_err_t i2s_set_sample_rates(i2s_port_t i2s_num, uint32_t rate);
/**
* @brief Start driver
* @brief Stop I2S driver
*
* @param i2s_num I2S_NUM_0, I2S_NUM_1
*
* @return
* - ESP_OK Success
* - ESP_FAIL Parameter error
*/
esp_err_t i2s_start(i2s_port_t i2s_num);
/**
* @brief Stop driver
* Disables I2S TX/RX, until i2s_start() is called.
*
* @param i2s_num I2S_NUM_0, I2S_NUM_1
*
@ -297,7 +312,23 @@ esp_err_t i2s_start(i2s_port_t i2s_num);
esp_err_t i2s_stop(i2s_port_t i2s_num);
/**
* @brief Set the TX DMA buffer contents to all zeroes
* @brief Start I2S driver
*
* It is not necessary to call this function after i2s_driver_install() (it is started automatically), however it is necessary to call it after i2s_stop().
*
*
* @param i2s_num I2S_NUM_0, I2S_NUM_1
*
* @return
* - ESP_OK Success
* - ESP_FAIL Parameter error
*/
esp_err_t i2s_start(i2s_port_t i2s_num);
/**
* @brief Zero the contents of the TX DMA buffer.
*
* Pushes zero-byte samples into the TX DMA buffer, until it is full.
*
* @param i2s_num I2S_NUM_0, I2S_NUM_1
*
@ -307,72 +338,6 @@ esp_err_t i2s_stop(i2s_port_t i2s_num);
*/
esp_err_t i2s_zero_dma_buffer(i2s_port_t i2s_num);
/***************************EXAMPLE**********************************
*
*
* ----------------EXAMPLE OF I2S SETTING ---------------------
* @code{c}
*
* #include "freertos/queue.h"
* #define I2S_INTR_NUM 17 //choose one interrupt number from soc.h
* int i2s_num = 0; //i2s port number
* i2s_config_t i2s_config = {
* .mode = I2S_MODE_MASTER | I2S_MODE_TX,
* .sample_rate = 44100,
* .bits_per_sample = 16, //16, 32
* .channel_format = I2S_CHANNEL_FMT_RIGHT_LEFT, //format LEFT_RIGHT
* .communication_format = I2S_COMM_FORMAT_I2S | I2S_COMM_FORMAT_I2S_MSB,
* .intr_alloc_flags = ESP_INTR_FLAG_LEVEL1,
* .dma_buf_count = 8,
* .dma_buf_len = 64
* };
*
* i2s_pin_config_t pin_config = {
* .bck_io_num = 26,
* .ws_io_num = 25,
* .data_out_num = 22,
* .data_in_num = I2S_PIN_NO_CHANGE
* };
*
* i2s_driver_install(i2s_num, &i2s_config, 0, NULL); //install and start i2s driver
*
* i2s_set_pin(i2s_num, &pin_config);
*
* i2s_set_sample_rates(i2s_num, 22050); //set sample rates
*
*
* i2s_driver_uninstall(i2s_num); //stop & destroy i2s driver
*@endcode
*
* ----------------EXAMPLE USING I2S WITH DAC ---------------------
* @code{c}
*
* #include "freertos/queue.h"
* #define I2S_INTR_NUM 17 //choose one interrupt number from soc.h
* int i2s_num = 0; //i2s port number
* i2s_config_t i2s_config = {
* .mode = I2S_MODE_MASTER | I2S_MODE_TX | I2S_MODE_DAC_BUILT_IN,
* .sample_rate = 44100,
* .bits_per_sample = 8, // Only 8-bit DAC support
* .channel_format = I2S_CHANNEL_FMT_RIGHT_LEFT, //
* .communication_format = I2S_COMM_FORMAT_I2S_MSB,
* .intr_alloc_flags = ESP_INTR_FLAG_LEVEL1,
* .dma_buf_count = 8,
* .dma_buf_len = 64
* };
*
*
* i2s_driver_install(i2s_num, &i2s_config, 0, NULL); //install and start i2s driver
*
* i2s_set_pin(i2s_num, NULL); //for internal DAC
*
* i2s_set_sample_rates(i2s_num, 22050); //set sample rates
*
* i2s_driver_uninstall(i2s_num); //stop & destroy i2s driver
*@endcode
*-----------------------------------------------------------------------------*
***************************END OF EXAMPLE**********************************/
#ifdef __cplusplus
}
#endif

View File

@ -24,7 +24,10 @@ extern "C" {
#endif
/**
* @brief Pullup/pulldown information for a single GPIO pad
* @brief Pin function information for a single GPIO pad's RTC functions.
*
* This is an internal function of the driver, and is not usually useful
* for external use.
*/
typedef struct {
uint32_t reg; /*!< Register of RTC pad, or 0 if not an RTC GPIO */
@ -46,10 +49,29 @@ typedef enum {
RTC_GPIO_MODE_DISABLED, /*!< Pad (output + input) disable */
} rtc_gpio_mode_t;
#define RTC_GPIO_IS_VALID_GPIO(gpio_num) ((gpio_num < GPIO_PIN_COUNT && rtc_gpio_desc[gpio_num].reg != 0)) //to decide whether it is a valid GPIO number
/**
* @brief Provides access to a constant table of RTC I/O pin
* function information.
*
* This is an internal function of the driver, and is not usually useful
* for external use.
*/
extern const rtc_gpio_desc_t rtc_gpio_desc[GPIO_PIN_COUNT];
/**
* @brief Determine if the specified GPIO is a valid RTC GPIO.
*
* @param gpio_num GPIO number
* @return true if GPIO is valid for RTC GPIO use. talse otherwise.
*/
inline static bool rtc_gpio_is_valid_gpio(gpio_num_t gpio_num)
{
return gpio_num < GPIO_PIN_COUNT
&& rtc_gpio_desc[gpio_num].reg != 0;
}
#define RTC_GPIO_IS_VALID_GPIO(gpio_num) rtc_gpio_is_valid_gpio(gpio_num) // Deprecated, use rtc_gpio_is_valid_gpio()
/**
* @brief Init a GPIO as RTC GPIO
*

View File

@ -469,8 +469,6 @@ esp_err_t uart_intr_config(uart_port_t uart_num, const uart_intr_config_t *intr_
* @brief Install UART driver.
*
* UART ISR handler will be attached to the same CPU core that this function is running on.
* Users should know that which CPU is running and then pick a INUM that is not used by system.
* We can find the information of INUM and interrupt level in soc.h.
*
* @param uart_num UART_NUM_0, UART_NUM_1 or UART_NUM_2
* @param rx_buffer_size UART RX ring buffer size, rx_buffer_size should be greater than UART_FIFO_LEN.
@ -644,7 +642,6 @@ esp_err_t uart_enable_pattern_det_intr(uart_port_t uart_num, char pattern_chr, u
* @code{c}
* //1. Setup UART
* #include "freertos/queue.h"
* #define UART_INTR_NUM 17 //choose one interrupt number from soc.h
* //a. Set UART parameter
* int uart_num = 0; //uart port number
* uart_config_t uart_config = {

View File

@ -87,7 +87,7 @@ const rtc_gpio_desc_t rtc_gpio_desc[GPIO_PIN_COUNT] = {
---------------------------------------------------------------*/
esp_err_t rtc_gpio_init(gpio_num_t gpio_num)
{
RTC_MODULE_CHECK(RTC_GPIO_IS_VALID_GPIO(gpio_num), "RTC_GPIO number error", ESP_ERR_INVALID_ARG);
RTC_MODULE_CHECK(rtc_gpio_is_valid_gpio(gpio_num), "RTC_GPIO number error", ESP_ERR_INVALID_ARG);
portENTER_CRITICAL(&rtc_spinlock);
// 0: GPIO connected to digital GPIO module. 1: GPIO connected to analog RTC module.
SET_PERI_REG_MASK(rtc_gpio_desc[gpio_num].reg, (rtc_gpio_desc[gpio_num].mux));
@ -100,7 +100,7 @@ esp_err_t rtc_gpio_init(gpio_num_t gpio_num)
esp_err_t rtc_gpio_deinit(gpio_num_t gpio_num)
{
RTC_MODULE_CHECK(RTC_GPIO_IS_VALID_GPIO(gpio_num), "RTC_GPIO number error", ESP_ERR_INVALID_ARG);
RTC_MODULE_CHECK(rtc_gpio_is_valid_gpio(gpio_num), "RTC_GPIO number error", ESP_ERR_INVALID_ARG);
portENTER_CRITICAL(&rtc_spinlock);
//Select Gpio as Digital Gpio
CLEAR_PERI_REG_MASK(rtc_gpio_desc[gpio_num].reg, (rtc_gpio_desc[gpio_num].mux));
@ -131,7 +131,7 @@ static esp_err_t rtc_gpio_output_disable(gpio_num_t gpio_num)
static esp_err_t rtc_gpio_input_enable(gpio_num_t gpio_num)
{
RTC_MODULE_CHECK(RTC_GPIO_IS_VALID_GPIO(gpio_num), "RTC_GPIO number error", ESP_ERR_INVALID_ARG);
RTC_MODULE_CHECK(rtc_gpio_is_valid_gpio(gpio_num), "RTC_GPIO number error", ESP_ERR_INVALID_ARG);
portENTER_CRITICAL(&rtc_spinlock);
SET_PERI_REG_MASK(rtc_gpio_desc[gpio_num].reg, rtc_gpio_desc[gpio_num].ie);
portEXIT_CRITICAL(&rtc_spinlock);
@ -141,7 +141,7 @@ static esp_err_t rtc_gpio_input_enable(gpio_num_t gpio_num)
static esp_err_t rtc_gpio_input_disable(gpio_num_t gpio_num)
{
RTC_MODULE_CHECK(RTC_GPIO_IS_VALID_GPIO(gpio_num), "RTC_GPIO number error", ESP_ERR_INVALID_ARG);
RTC_MODULE_CHECK(rtc_gpio_is_valid_gpio(gpio_num), "RTC_GPIO number error", ESP_ERR_INVALID_ARG);
portENTER_CRITICAL(&rtc_spinlock);
CLEAR_PERI_REG_MASK(rtc_gpio_desc[gpio_num].reg, rtc_gpio_desc[gpio_num].ie);
portEXIT_CRITICAL(&rtc_spinlock);
@ -152,7 +152,7 @@ static esp_err_t rtc_gpio_input_disable(gpio_num_t gpio_num)
esp_err_t rtc_gpio_set_level(gpio_num_t gpio_num, uint32_t level)
{
int rtc_gpio_num = rtc_gpio_num = rtc_gpio_desc[gpio_num].rtc_num;;
RTC_MODULE_CHECK(RTC_GPIO_IS_VALID_GPIO(gpio_num), "RTC_GPIO number error", ESP_ERR_INVALID_ARG);
RTC_MODULE_CHECK(rtc_gpio_is_valid_gpio(gpio_num), "RTC_GPIO number error", ESP_ERR_INVALID_ARG);
if (level) {
WRITE_PERI_REG(RTC_GPIO_OUT_W1TS_REG, (1 << (rtc_gpio_num + RTC_GPIO_OUT_DATA_W1TS_S)));
@ -167,7 +167,7 @@ uint32_t rtc_gpio_get_level(gpio_num_t gpio_num)
{
uint32_t level = 0;
int rtc_gpio_num = rtc_gpio_desc[gpio_num].rtc_num;
RTC_MODULE_CHECK(RTC_GPIO_IS_VALID_GPIO(gpio_num), "RTC_GPIO number error", ESP_ERR_INVALID_ARG);
RTC_MODULE_CHECK(rtc_gpio_is_valid_gpio(gpio_num), "RTC_GPIO number error", ESP_ERR_INVALID_ARG);
portENTER_CRITICAL(&rtc_spinlock);
level = READ_PERI_REG(RTC_GPIO_IN_REG);
@ -177,7 +177,7 @@ uint32_t rtc_gpio_get_level(gpio_num_t gpio_num)
esp_err_t rtc_gpio_set_direction(gpio_num_t gpio_num, rtc_gpio_mode_t mode)
{
RTC_MODULE_CHECK(RTC_GPIO_IS_VALID_GPIO(gpio_num), "RTC_GPIO number error", ESP_ERR_INVALID_ARG);
RTC_MODULE_CHECK(rtc_gpio_is_valid_gpio(gpio_num), "RTC_GPIO number error", ESP_ERR_INVALID_ARG);
switch (mode) {
case RTC_GPIO_MODE_INPUT_ONLY:

View File

@ -502,6 +502,7 @@ static void IRAM_ATTR spi_intr(void *arg)
//We have a transaction. Send it.
spi_device_t *dev=host->device[i];
host->cur_trans=trans;
host->cur_cs=i;
//We should be done with the transmission.
assert(host->hw->cmd.usr == 0);
@ -510,7 +511,7 @@ static void IRAM_ATTR spi_intr(void *arg)
trans->rxlength=trans->length;
}
//Reconfigure accoding to device settings, but only if we change CSses.
//Reconfigure according to device settings, but only if we change CSses.
if (i!=prevCs) {
//Assumes a hardcoded 80MHz Fapb for now. ToDo: figure out something better once we have
//clock scaling working.
@ -599,7 +600,7 @@ static void IRAM_ATTR spi_intr(void *arg)
} else {
data=trans->rx_buffer;
}
if (trans->rxlength<THRESH_DMA_TRANS) {
if (trans->rxlength <= THRESH_DMA_TRANS) {
//No need for DMA; we'll copy the result out of the work registers directly later.
} else {
host->hw->user.usr_miso_highpart=0;
@ -624,9 +625,9 @@ static void IRAM_ATTR spi_intr(void *arg)
} else {
data=(uint32_t *)trans->tx_buffer;
}
if (trans->rxlength < 8*32) {
if (trans->length <= THRESH_DMA_TRANS) {
//No need for DMA.
for (int x=0; x < trans->rxlength; x+=32) {
for (int x=0; x < trans->length; x+=32) {
//Use memcpy to get around alignment issues for txdata
uint32_t word;
memcpy(&word, &data[x/32], 4);
@ -655,7 +656,7 @@ static void IRAM_ATTR spi_intr(void *arg)
host->hw->addr=trans->address & 0xffffffff;
}
host->hw->user.usr_mosi=(trans->tx_buffer==NULL)?0:1;
host->hw->user.usr_miso=(trans->tx_buffer==NULL)?0:1;
host->hw->user.usr_miso=(trans->rx_buffer==NULL)?0:1;
//Call pre-transmission callback, if any
if (dev->cfg.pre_cb) dev->cfg.pre_cb(trans);

View File

@ -80,7 +80,7 @@ TEST_CASE("SPI Master clockdiv calculation routines", "[spi]")
}
TEST_CASE("SPI Master test", "[spi]")
TEST_CASE("SPI Master test", "[spi][ignore]")
{
spi_bus_config_t buscfg={
.mosi_io_num=4,

View File

@ -1,4 +1,4 @@
menu "ESP32-specific config"
menu "ESP32-specific"
choice ESP32_DEFAULT_CPU_FREQ_MHZ
prompt "CPU frequency"
@ -113,7 +113,7 @@ config SYSTEM_EVENT_QUEUE_SIZE
config SYSTEM_EVENT_TASK_STACK_SIZE
int "Event loop task stack size"
default 2048
default 4096
help
Config system event task stack size in different application.
@ -490,24 +490,38 @@ config SW_COEXIST_ENABLE
Recommended for heavy traffic scenarios. Both coexistence configuration options are
automatically managed, no user intervention is required.
config ESP32_PHY_AUTO_INIT
bool "Initialize PHY in startup code"
config ESP32_WIFI_RX_BUFFER_NUM
int "Max number of WiFi RX buffers"
depends on WIFI_ENABLED
range 2 25
default 10
help
Set the number of WiFi rx buffers. Each buffer takes approximately 1.6KB of RAM.
Larger number for higher throughput but more memory. Smaller number for lower
throughput but less memory.
config PHY_ENABLED
bool
default y if WIFI_ENABLED || BT_ENABLED
menu PHY
visible if PHY_ENABLED
config ESP32_PHY_CALIBRATION_AND_DATA_STORAGE
bool "Do phy calibration and store calibration data in NVS"
depends on PHY_ENABLED
default y
help
If enabled, PHY will be initialized in startup code, before
app_main function runs.
If this is undesired, disable this option and call esp_phy_init
from the application before enabling WiFi or BT.
If this option is enabled, startup code will also initialize
NVS prior to initializing PHY.
If this option is enabled, NVS will be initialized and calibration data will be loaded from there.
PHY calibration will be skipped on deep sleep wakeup. If calibration data is not found, full calibration
will be performed and stored in NVS. In all other cases, only partial calibration will be performed.
If unsure, choose 'y'.
config ESP32_PHY_INIT_DATA_IN_PARTITION
bool "Use a partition to store PHY init data"
depends on WIFI_ENABLED
depends on PHY_ENABLED
default n
help
If enabled, PHY init data will be loaded from a partition.
@ -521,22 +535,20 @@ config ESP32_PHY_INIT_DATA_IN_PARTITION
into the application binary.
If unsure, choose 'n'.
config ESP32_PHY_MAX_TX_POWER
int "Max TX power (dBm)"
config ESP32_PHY_MAX_WIFI_TX_POWER
int "Max WiFi TX power (dBm)"
range 0 20
default 20
depends on WIFI_ENABLED
depends on PHY_ENABLED && WIFI_ENABLED
help
Set maximum transmit power. Actual transmit power for high
Set maximum transmit power for WiFi radio. Actual transmit power for high
data rates may be lower than this setting.
config ESP32_WIFI_RX_BUFFER_NUM
int "Max number of WiFi RX buffers"
depends on WIFI_ENABLED
range 2 25
default 25
help
Set the number of WiFi rx buffers. Each buffer takes approximately 1.6KB of RAM.
Larger number for higher throughput but more memory. Smaller number for lower
throughput but less memory.
config ESP32_PHY_MAX_TX_POWER
int
depends on PHY_ENABLED
default 20 if !WIFI_ENABLED
default ESP32_PHY_MAX_WIFI_TX_POWER if WIFI_ENABLED
endmenu

View File

@ -3,16 +3,14 @@
#
COMPONENT_SRCDIRS := . hwcrypto
LIBS := core rtc phy
ifdef CONFIG_BT_ENABLED
LIBS += coexist
LIBS := core rtc rtc_clk
ifdef CONFIG_PHY_ENABLED # BT || WIFI
LIBS += phy coexist
endif
ifdef CONFIG_WIFI_ENABLED
LIBS += net80211 pp wpa smartconfig coexist wps wpa2
endif
LIBS := $(sort $(LIBS)) # de-duplicate, we can handle different orders here
LINKER_SCRIPTS += esp32.common.ld esp32.rom.ld esp32.peripherals.ld
ifeq ("$(CONFIG_NEWLIB_NANO_FORMAT)","y")

View File

@ -26,16 +26,17 @@
#if CONFIG_ESP32_ENABLE_COREDUMP
#define LOG_LOCAL_LEVEL CONFIG_ESP32_CORE_DUMP_LOG_LEVEL
#include "esp_log.h"
const static char *TAG = "esp_core_dump";
const static DRAM_ATTR char TAG[] = "esp_core_dump";
#define ESP_COREDUMP_LOGE( format, ... ) if (LOG_LOCAL_LEVEL >= ESP_LOG_ERROR) { ets_printf(LOG_FORMAT(E, format), esp_log_early_timestamp(), TAG, ##__VA_ARGS__); }
#define ESP_COREDUMP_LOGW( format, ... ) if (LOG_LOCAL_LEVEL >= ESP_LOG_WARN) { ets_printf(LOG_FORMAT(W, format), esp_log_early_timestamp(), TAG, ##__VA_ARGS__); }
#define ESP_COREDUMP_LOGI( format, ... ) if (LOG_LOCAL_LEVEL >= ESP_LOG_INFO) { ets_printf(LOG_FORMAT(I, format), esp_log_early_timestamp(), TAG, ##__VA_ARGS__); }
#define ESP_COREDUMP_LOGD( format, ... ) if (LOG_LOCAL_LEVEL >= ESP_LOG_DEBUG) { ets_printf(LOG_FORMAT(D, format), esp_log_early_timestamp(), TAG, ##__VA_ARGS__); }
#define ESP_COREDUMP_LOGV( format, ... ) if (LOG_LOCAL_LEVEL >= ESP_LOG_VERBOSE) { ets_printf(LOG_FORMAT(V, format), esp_log_early_timestamp(), TAG, ##__VA_ARGS__); }
#define ESP_COREDUMP_LOG( level, format, ... ) if (LOG_LOCAL_LEVEL >= level) { ets_printf(DRAM_STR(format), esp_log_early_timestamp(), (const char *)TAG, ##__VA_ARGS__); }
#define ESP_COREDUMP_LOGE( format, ... ) ESP_COREDUMP_LOG(ESP_LOG_ERROR, LOG_FORMAT(E, format), ##__VA_ARGS__)
#define ESP_COREDUMP_LOGW( format, ... ) ESP_COREDUMP_LOG(ESP_LOG_WARN, LOG_FORMAT(W, format), ##__VA_ARGS__)
#define ESP_COREDUMP_LOGI( format, ... ) ESP_COREDUMP_LOG(ESP_LOG_INFO, LOG_FORMAT(I, format), ##__VA_ARGS__)
#define ESP_COREDUMP_LOGD( format, ... ) ESP_COREDUMP_LOG(ESP_LOG_DEBUG, LOG_FORMAT(D, format), ##__VA_ARGS__)
#define ESP_COREDUMP_LOGV( format, ... ) ESP_COREDUMP_LOG(ESP_LOG_VERBOSE, LOG_FORMAT(V, format), ##__VA_ARGS__)
#if CONFIG_ESP32_ENABLE_COREDUMP_TO_FLASH
#define ESP_COREDUMP_LOG_PROCESS( format, ... ) if (LOG_LOCAL_LEVEL >= ESP_LOG_DEBUG) { ets_printf(LOG_FORMAT(D, format), esp_log_early_timestamp(), TAG, ##__VA_ARGS__); }
#define ESP_COREDUMP_LOG_PROCESS( format, ... ) ESP_COREDUMP_LOGD(format, ##__VA_ARGS__)
#else
#define ESP_COREDUMP_LOG_PROCESS( format, ... ) do{/*(__VA_ARGS__);*/}while(0)
#endif
@ -345,8 +346,9 @@ void esp_core_dump_to_flash(XtExcFrame *frame)
#endif
#if CONFIG_ESP32_ENABLE_COREDUMP_TO_UART
static void esp_core_dump_b64_encode(const uint8_t *src, uint32_t src_len, uint8_t *dst) {
static const char *b64 =
const static DRAM_ATTR char b64[] =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
int i, j, a, b, c;
@ -373,14 +375,14 @@ static void esp_core_dump_b64_encode(const uint8_t *src, uint32_t src_len, uint8
static esp_err_t esp_core_dump_uart_write_start(void *priv)
{
esp_err_t err = ESP_OK;
ets_printf("================= CORE DUMP START =================\r\n");
ets_printf(DRAM_STR("================= CORE DUMP START =================\r\n"));
return err;
}
static esp_err_t esp_core_dump_uart_write_end(void *priv)
{
esp_err_t err = ESP_OK;
ets_printf("================= CORE DUMP END =================\r\n");
ets_printf(DRAM_STR("================= CORE DUMP END =================\r\n"));
return err;
}
@ -398,7 +400,7 @@ static esp_err_t esp_core_dump_uart_write_data(void *priv, void * data, uint32_t
memcpy(tmp, addr, len);
esp_core_dump_b64_encode((const uint8_t *)tmp, len, (uint8_t *)buf);
addr += len;
ets_printf("%s\r\n", buf);
ets_printf(DRAM_STR("%s\r\n"), buf);
}
return err;
@ -427,7 +429,8 @@ void esp_core_dump_to_uart(XtExcFrame *frame)
wr_cfg.priv = NULL;
//Make sure txd/rxd are enabled
gpio_pullup_dis(1);
// use direct reg access instead of gpio_pullup_dis which can cause exception when flash cache is disabled
REG_CLR_BIT(GPIO_PIN_REG_1, FUN_PU);
PIN_FUNC_SELECT(PERIPHS_IO_MUX_U0RXD_U, FUNC_U0RXD_U0RXD);
PIN_FUNC_SELECT(PERIPHS_IO_MUX_U0TXD_U, FUNC_U0TXD_U0TXD);
@ -438,10 +441,6 @@ void esp_core_dump_to_uart(XtExcFrame *frame)
tm_cur = xthal_get_ccount() / (XT_CLOCK_FREQ / 1000);
if (tm_cur >= tm_end)
break;
/* Feed the Cerberus. */
TIMERG0.wdt_wprotect = TIMG_WDT_WKEY_VALUE;
TIMERG0.wdt_feed = 1;
TIMERG0.wdt_wprotect = 0;
ch = esp_core_dump_uart_get_char();
}
ESP_COREDUMP_LOGI("Print core dump to uart...");
@ -455,18 +454,18 @@ void esp_core_dump_init()
#if CONFIG_ESP32_ENABLE_COREDUMP_TO_FLASH
const esp_partition_t *core_part;
ESP_LOGI(TAG, "Init core dump to flash");
ESP_COREDUMP_LOGI("Init core dump to flash");
core_part = esp_partition_find_first(ESP_PARTITION_TYPE_DATA, ESP_PARTITION_SUBTYPE_DATA_COREDUMP, NULL);
if (!core_part) {
ESP_LOGE(TAG, "No core dump partition found!");
ESP_COREDUMP_LOGE("No core dump partition found!");
return;
}
ESP_LOGI(TAG, "Found partition '%s' @ %x %d bytes", core_part->label, core_part->address, core_part->size);
ESP_COREDUMP_LOGI("Found partition '%s' @ %x %d bytes", core_part->label, core_part->address, core_part->size);
s_core_part_start = core_part->address;
s_core_part_size = core_part->size;
#endif
#if CONFIG_ESP32_ENABLE_COREDUMP_TO_UART
ESP_LOGI(TAG, "Init core dump to UART");
ESP_COREDUMP_LOGI("Init core dump to UART");
#endif
}

View File

@ -17,7 +17,6 @@
#include "rom/ets_sys.h"
#include "rom/uart.h"
#include "sdkconfig.h"
#include "phy.h"
#include "rtc.h"
#include "soc/soc.h"
#include "soc/rtc_cntl_reg.h"
@ -32,7 +31,6 @@
void esp_set_cpu_freq(void)
{
uint32_t freq_mhz = CONFIG_ESP32_DEFAULT_CPU_FREQ_MHZ;
phy_get_romfunc_addr();
// freq will be changed to 40MHz in rtc_init_lite,
// wait uart tx finish, otherwise some uart output will be lost

View File

@ -73,9 +73,6 @@ static bool app_cpu_started = false;
static void do_global_ctors(void);
static void main_task(void* args);
extern void app_main(void);
#if CONFIG_ESP32_PHY_AUTO_INIT
static void do_phy_init();
#endif
extern int _bss_start;
extern int _bss_end;
@ -175,7 +172,9 @@ void start_cpu0_default(void)
trax_start_trace(TRAX_DOWNCOUNT_WORDS);
#endif
esp_set_cpu_freq(); // set CPU frequency configured in menuconfig
#ifndef CONFIG_CONSOLE_UART_NONE
uart_div_modify(CONFIG_CONSOLE_UART_NUM, (APB_CLK_FREQ << 4) / CONFIG_CONSOLE_UART_BAUDRATE);
#endif
#if CONFIG_BROWNOUT_DET
esp_brownout_init();
#endif
@ -208,17 +207,6 @@ void start_cpu0_default(void)
/* init default OS-aware flash access critical section */
spi_flash_guard_set(&g_flash_guard_default_ops);
#if CONFIG_ESP32_PHY_AUTO_INIT
nvs_flash_init();
do_phy_init();
#endif
#if CONFIG_SW_COEXIST_ENABLE
if (coex_init() == ESP_OK) {
coexist_set_enable(true);
}
#endif
#if CONFIG_ESP32_ENABLE_COREDUMP
esp_core_dump_init();
#endif
@ -266,39 +254,3 @@ static void main_task(void* args)
vTaskDelete(NULL);
}
#if CONFIG_ESP32_PHY_AUTO_INIT
static void do_phy_init()
{
esp_phy_calibration_mode_t calibration_mode = PHY_RF_CAL_PARTIAL;
if (rtc_get_reset_reason(0) == DEEPSLEEP_RESET) {
calibration_mode = PHY_RF_CAL_NONE;
}
const esp_phy_init_data_t* init_data = esp_phy_get_init_data();
if (init_data == NULL) {
ESP_LOGE(TAG, "failed to obtain PHY init data");
abort();
}
esp_phy_calibration_data_t* cal_data =
(esp_phy_calibration_data_t*) calloc(sizeof(esp_phy_calibration_data_t), 1);
if (cal_data == NULL) {
ESP_LOGE(TAG, "failed to allocate memory for RF calibration data");
abort();
}
esp_err_t err = esp_phy_load_cal_data_from_nvs(cal_data);
if (err != ESP_OK) {
ESP_LOGW(TAG, "failed to load RF calibration data, falling back to full calibration");
calibration_mode = PHY_RF_CAL_FULL;
}
esp_phy_init(init_data, calibration_mode, cal_data);
if (calibration_mode != PHY_RF_CAL_NONE) {
err = esp_phy_store_cal_data_to_nvs(cal_data);
} else {
err = ESP_OK;
}
esp_phy_release_init_data(init_data);
free(cal_data); // PHY maintains a copy of calibration data, so we can free this
}
#endif //CONFIG_ESP32_PHY_AUTO_INIT

View File

@ -82,7 +82,7 @@ void esp_crosscore_int_init() {
assert(err == ESP_OK);
}
void esp_crosscore_int_send_yield(int coreId) {
void IRAM_ATTR esp_crosscore_int_send_yield(int coreId) {
assert(coreId<portNUM_PROCESSORS);
//Mark the reason we interrupt the other CPU
portENTER_CRITICAL(&reasonSpinlock);

View File

@ -22,6 +22,7 @@
#include "rom/uart.h"
#include "soc/cpu.h"
#include "soc/rtc_cntl_reg.h"
#include "soc/sens_reg.h"
#include "soc/dport_reg.h"
#include "driver/rtc_io.h"
#include "freertos/FreeRTOS.h"
@ -111,6 +112,13 @@ void IRAM_ATTR esp_deep_sleep_start()
// Decide which power domains can be powered down
uint32_t pd_flags = get_power_down_flags();
// Shut down parts of RTC which may have been left enabled by the wireless drivers
CLEAR_PERI_REG_MASK(RTC_CNTL_ANA_CONF_REG,
RTC_CNTL_CKGEN_I2C_PU | RTC_CNTL_PLL_I2C_PU |
RTC_CNTL_RFRX_PBUS_PU | RTC_CNTL_TXRF_I2C_PU);
SET_PERI_REG_BITS(SENS_SAR_MEAS_WAIT2_REG, SENS_FORCE_XPD_SAR_M, 0, SENS_FORCE_XPD_SAR_S);
// Configure pins for external wakeup
if (s_config.wakeup_triggers & EXT_EVENT0_TRIG_EN) {
ext0_wakeup_prepare();

View File

@ -25,6 +25,11 @@ extern "C" {
*/
esp_err_t coex_init(void);
/**
* @brief De-init software coexist
*/
void coex_deinit(void);
/**
* @brief Get software coexist enable or not
*

View File

@ -164,6 +164,14 @@ void esp_deep_sleep_start() __attribute__((noreturn));
* Call to this function is equivalent to a call to esp_deep_sleep_enable_timer_wakeup
* followed by a call to esp_deep_sleep_start.
*
* esp_deep_sleep does not shut down WiFi, BT, and higher level protocol
* connections gracefully.
* Make sure relevant WiFi and BT stack functions are called to close any
* connections and deinitialize the peripherals. These include:
* - esp_bluedroid_disable
* - esp_bt_controller_disable
* - esp_wifi_stop
*
* This function does not return.
*
* @param time_in_us deep-sleep time, unit: microsecond

View File

@ -1,6 +1,10 @@
#ifndef PANIC_H
#define PANIC_H
#ifdef __cplusplus
extern "C"
{
#endif
#define PANIC_RSN_NONE 0
#define PANIC_RSN_DEBUGEXCEPTION 1
@ -59,4 +63,8 @@ void esp_clear_watchpoint(int no);
#endif
#ifdef __cplusplus
}
#endif
#endif

View File

@ -14,6 +14,7 @@
#pragma once
#include <stdint.h>
#include <stdbool.h>
#include "esp_err.h"
#ifdef __cplusplus
@ -192,7 +193,7 @@ void esp_phy_release_init_data(const esp_phy_init_data_t* data);
* mechanism for loading calibration data, disable
* "Initialize PHY in startup code" option in menuconfig and call esp_phy_init
* function from the application. For an example usage of esp_phy_init and
* this function, see do_phy_init function in cpu_start.c
* this function, see esp_phy_store_cal_data_to_nvs function in cpu_start.c
*
* @param out_cal_data pointer to calibration data structure to be filled with
* loaded data.
@ -220,28 +221,39 @@ esp_err_t esp_phy_load_cal_data_from_nvs(esp_phy_calibration_data_t* out_cal_dat
esp_err_t esp_phy_store_cal_data_to_nvs(const esp_phy_calibration_data_t* cal_data);
/**
* @brief Initialize PHY module
* @brief Initialize PHY and RF module
*
* PHY module should be initialized in order to use WiFi or BT.
* If "Initialize PHY in startup code" option is set in menuconfig,
* this function will be called automatically before app_main is called,
* using parameters obtained from esp_phy_get_init_data.
*
* Applications which don't need to enable PHY on every start up should
* disable this menuconfig option and call esp_phy_init before calling
* esp_wifi_init or esp_bt_controller_init. See do_phy_init function in
* cpu_start.c for an example of using this function.
* PHY and RF module should be initialized in order to use WiFi or BT.
* Now PHY and RF initializing job is done automatically when start WiFi or BT. Users should not
* call this API in their application.
*
* @param init_data PHY parameters. Default set of parameters can
* be obtained by calling esp_phy_get_default_init_data
* function.
* @param mode Calibration mode (Full, partial, or no calibration)
* @param[inout] calibration_data
* @param is_sleep WiFi wakes up from sleep or not
* @return ESP_OK on success.
* @return ESP_FAIL on fail.
*/
esp_err_t esp_phy_rf_init(const esp_phy_init_data_t* init_data,
esp_phy_calibration_mode_t mode, esp_phy_calibration_data_t* calibration_data, bool is_sleep);
/**
* @brief De-initialize PHY and RF module
*
* PHY module should be de-initialized in order to shutdown WiFi or BT.
* Now PHY and RF de-initializing job is done automatically when stop WiFi or BT. Users should not
* call this API in their application.
*
* @return ESP_OK on success.
*/
esp_err_t esp_phy_init(const esp_phy_init_data_t* init_data,
esp_phy_calibration_mode_t mode, esp_phy_calibration_data_t* calibration_data);
esp_err_t esp_phy_rf_deinit(void);
/**
* @brief Load calibration data from NVS and initialize PHY and RF module
*/
void esp_phy_load_cal_and_init(void);
#ifdef __cplusplus
}

View File

@ -124,7 +124,12 @@ esp_err_t system_efuse_read_mac(uint8_t mac[6]) __attribute__ ((deprecated));
*/
const char* system_get_sdk_version(void) __attribute__ ((deprecated));
/**
* Get IDF version
*
* @return constant string from IDF_VER
*/
const char* esp_get_idf_version(void);
#ifdef __cplusplus
}

View File

@ -130,6 +130,7 @@ esp_err_t esp_wifi_init(wifi_init_config_t *config);
* Free all resource allocated in esp_wifi_init and stop WiFi task
*
* @attention 1. This API should be called if you want to remove WiFi driver from the system
* @attention 2. This API can not be called yet and will be done in the future.
*
* @return ESP_OK: succeed
*/

View File

@ -122,6 +122,7 @@ typedef volatile struct {
uint32_t lstimer1_ovf: 1; /*The interrupt status bit for low speed channel1 counter overflow event.*/
uint32_t lstimer2_ovf: 1; /*The interrupt status bit for low speed channel2 counter overflow event.*/
uint32_t lstimer3_ovf: 1; /*The interrupt status bit for low speed channel3 counter overflow event.*/
uint32_t duty_chng_end_hsch0: 1; /*The interrupt enable bit for high speed channel 0 duty change done event.*/
uint32_t duty_chng_end_hsch1: 1; /*The interrupt status bit for high speed channel 1 duty change done event.*/
uint32_t duty_chng_end_hsch2: 1; /*The interrupt status bit for high speed channel 2 duty change done event.*/
uint32_t duty_chng_end_hsch3: 1; /*The interrupt status bit for high speed channel 3 duty change done event.*/

View File

@ -268,10 +268,10 @@
* 2 1 extern level
* 3 1 extern level
* 4 1 extern level WBB
* 5 1 extern level BT Controller
* 5 1 extern level BT/BLE Controller
* 6 1 timer FreeRTOS Tick(L1) FreeRTOS Tick(L1)
* 7 1 software Reserved Reserved
* 8 1 extern level BLE Controller
* 8 1 extern level BT/BLE BB(RX/TX)
* 9 1 extern level
* 10 1 extern edge Internal Timer
* 11 3 profiling

View File

@ -89,12 +89,6 @@ typedef struct {
#define INT15RES INTDESC_SPECIAL
#endif
#if CONFIG_FREERTOS_CORETIMER_2
#define INT16RES INTDESC_RESVD
#else
#define INT16RES INTDESC_SPECIAL
#endif
//This is basically a software-readable version of the interrupt usage table in include/soc/soc.h
const static int_desc_t int_desc[32]={
{ 1, INTTP_LEVEL, {INTDESC_RESVD, INTDESC_RESVD } }, //0
@ -113,7 +107,7 @@ const static int_desc_t int_desc[32]={
{ 1, INTTP_LEVEL, {INTDESC_NORMAL, INTDESC_NORMAL} }, //13
{ 7, INTTP_LEVEL, {INTDESC_RESVD, INTDESC_RESVD } }, //14, NMI
{ 3, INTTP_NA, {INT15RES, INT15RES } }, //15
{ 5, INTTP_NA, {INT16RES, INT16RES } }, //16
{ 5, INTTP_NA, {INTDESC_SPECIAL,INTDESC_SPECIAL} }, //16
{ 1, INTTP_LEVEL, {INTDESC_NORMAL, INTDESC_NORMAL} }, //17
{ 1, INTTP_LEVEL, {INTDESC_NORMAL, INTDESC_NORMAL} }, //18
{ 2, INTTP_LEVEL, {INTDESC_NORMAL, INTDESC_NORMAL} }, //19
@ -692,7 +686,7 @@ esp_err_t IRAM_ATTR esp_intr_disable(intr_handle_t handle)
}
void esp_intr_noniram_disable()
void IRAM_ATTR esp_intr_noniram_disable()
{
int oldint;
int cpu=xPortGetCoreID();
@ -706,12 +700,12 @@ void esp_intr_noniram_disable()
"and a3,%0,%1\n" //mask ints that need disabling
"wsr a3,INTENABLE\n" //write back
"rsync\n"
:"=r"(oldint):"r"(intmask):"a3");
:"=&r"(oldint):"r"(intmask):"a3");
//Save which ints we did disable
non_iram_int_disabled[cpu]=oldint&non_iram_int_mask[cpu];
}
void esp_intr_noniram_enable()
void IRAM_ATTR esp_intr_noniram_enable()
{
int cpu=xPortGetCoreID();
int intmask=non_iram_int_disabled[cpu];

View File

@ -80,10 +80,17 @@ SECTIONS
*(.iram1 .iram1.*)
*libfreertos.a:(.literal .text .literal.* .text.*)
*libesp32.a:panic.o(.literal .text .literal.* .text.*)
*libesp32.a:core_dump.o(.literal .text .literal.* .text.*)
*libphy.a:(.literal .text .literal.* .text.*)
*librtc.a:(.literal .text .literal.* .text.*)
*libpp.a:(.literal .text .literal.* .text.*)
*librtc_clk.a:(.literal .text .literal.* .text.*)
*libpp.a:pp.o(.literal .text .literal.* .text.*)
*libpp.a:lmac.o(.literal .text .literal.* .text.*)
*libpp.a:wdev.o(.literal .text .literal.* .text.*)
*libcore.a:ets_timer.o(.literal .text .literal.* .text.*)
*libnet80211.a:ieee80211_misc.o(.literal .text .literal.* .text.*)
*libhal.a:(.literal .text .literal.* .text.*)
*libcoexist.a:(.literal .text .literal.* .text.*)
_iram_text_end = ABSOLUTE(.);
} > iram0_0_seg

@ -1 +1 @@
Subproject commit b26cd217641acf08da932f4de8e858083ea83113
Subproject commit ed85cf9156f2ef358c29d07fb849a73c5758eecb

View File

@ -267,7 +267,7 @@ static void reconfigureAllWdts()
TIMERG1.wdt_wprotect = 0;
}
#if CONFIG_ESP32_PANIC_GDBSTUB || CONFIG_ESP32_PANIC_PRINT_HALT
#if CONFIG_ESP32_PANIC_GDBSTUB || CONFIG_ESP32_PANIC_PRINT_HALT || CONFIG_ESP32_ENABLE_COREDUMP
/*
This disables all the watchdogs for when we call the gdbstub.
*/
@ -367,11 +367,15 @@ static void commonErrorHandler(XtExcFrame *frame)
panicPutStr("Entering gdb stub now.\r\n");
esp_gdbstub_panic_handler(frame);
#else
#if CONFIG_ESP32_ENABLE_COREDUMP
disableAllWdts();
#if CONFIG_ESP32_ENABLE_COREDUMP_TO_FLASH
esp_core_dump_to_flash(frame);
#endif
#if CONFIG_ESP32_ENABLE_COREDUMP_TO_UART && !CONFIG_ESP32_PANIC_SILENT_REBOOT
esp_core_dump_to_uart(frame);
#endif
reconfigureAllWdts();
#endif
#if CONFIG_ESP32_PANIC_PRINT_REBOOT || CONFIG_ESP32_PANIC_SILENT_REBOOT
panicPutStr("Rebooting...\r\n");

View File

@ -25,8 +25,7 @@ extern "C" {
*/
/**
* @brief Initialize function pointer table in PHY library.
* @note This function should be called before register_chipv7_phy.
* @brief Return ROM function pointer table from PHY library.
*/
void phy_get_romfunc_addr(void);

View File

@ -17,7 +17,10 @@
#include <string.h>
#include <stdbool.h>
#include <sys/lock.h>
#include "rom/ets_sys.h"
#include "rom/rtc.h"
#include "soc/dport_reg.h"
#include "esp_err.h"
@ -25,31 +28,71 @@
#include "esp_system.h"
#include "esp_log.h"
#include "nvs.h"
#include "nvs_flash.h"
#include "sdkconfig.h"
#ifdef CONFIG_WIFI_ENABLED
#ifdef CONFIG_PHY_ENABLED
#include "phy.h"
#include "phy_init_data.h"
#include "rtc.h"
#include "esp_coexist.h"
static const char* TAG = "phy_init";
/* Count value to indicate if there is peripheral that has initialized PHY and RF */
static int s_phy_rf_init_count = 0;
static bool s_mac_rst_flag = false;
esp_err_t esp_phy_init(const esp_phy_init_data_t* init_data,
esp_phy_calibration_mode_t mode, esp_phy_calibration_data_t* calibration_data)
static _lock_t s_phy_rf_init_lock;
esp_err_t esp_phy_rf_init(const esp_phy_init_data_t* init_data,
esp_phy_calibration_mode_t mode, esp_phy_calibration_data_t* calibration_data, bool is_sleep)
{
assert(init_data);
assert(calibration_data);
// Initialize PHY pointer table
phy_get_romfunc_addr();
REG_SET_BIT(DPORT_CORE_RST_EN_REG, DPORT_MAC_RST);
REG_CLR_BIT(DPORT_CORE_RST_EN_REG, DPORT_MAC_RST);
// Enable WiFi peripheral clock
SET_PERI_REG_MASK(DPORT_WIFI_CLK_EN_REG, 0x87cf);
ESP_LOGV(TAG, "register_chipv7_phy, init_data=%p, cal_data=%p, mode=%d",
init_data, calibration_data, mode);
phy_set_wifi_mode_only(0);
register_chipv7_phy(init_data, calibration_data, mode);
coex_bt_high_prio();
assert((s_phy_rf_init_count <= 1) && (s_phy_rf_init_count >= 0));
_lock_acquire(&s_phy_rf_init_lock);
if (s_phy_rf_init_count == 0) {
if (is_sleep == false) {
if (s_mac_rst_flag == false) {
s_mac_rst_flag = true;
REG_SET_BIT(DPORT_CORE_RST_EN_REG, DPORT_MAC_RST);
REG_CLR_BIT(DPORT_CORE_RST_EN_REG, DPORT_MAC_RST);
}
}
// Enable WiFi peripheral clock
SET_PERI_REG_MASK(DPORT_WIFI_CLK_EN_REG, 0x87cf);
ESP_LOGV(TAG, "register_chipv7_phy, init_data=%p, cal_data=%p, mode=%d",
init_data, calibration_data, mode);
phy_set_wifi_mode_only(0);
register_chipv7_phy(init_data, calibration_data, mode);
coex_bt_high_prio();
} else {
#if CONFIG_SW_COEXIST_ENABLE
coex_init();
#endif
}
s_phy_rf_init_count++;
_lock_release(&s_phy_rf_init_lock);
return ESP_OK;
}
esp_err_t esp_phy_rf_deinit(void)
{
assert((s_phy_rf_init_count <= 2) && (s_phy_rf_init_count >= 1));
_lock_acquire(&s_phy_rf_init_lock);
if (s_phy_rf_init_count == 1) {
// Disable PHY and RF. TODO: convert this function to another one.
pm_close_rf();
// Disable WiFi peripheral clock
CLEAR_PERI_REG_MASK(DPORT_WIFI_CLK_EN_REG, 0x87cf);
} else {
#if CONFIG_SW_COEXIST_ENABLE
coex_deinit();
#endif
}
s_phy_rf_init_count--;
_lock_release(&s_phy_rf_init_lock);
return ESP_OK;
}
@ -221,4 +264,43 @@ static esp_err_t store_cal_data_to_nvs_handle(nvs_handle handle,
return err;
}
#endif // CONFIG_WIFI_ENABLED
void esp_phy_load_cal_and_init(void)
{
#ifdef CONFIG_ESP32_PHY_CALIBRATION_AND_DATA_STORAGE
nvs_flash_init();
esp_phy_calibration_mode_t calibration_mode = PHY_RF_CAL_PARTIAL;
if (rtc_get_reset_reason(0) == DEEPSLEEP_RESET) {
calibration_mode = PHY_RF_CAL_NONE;
}
const esp_phy_init_data_t* init_data = esp_phy_get_init_data();
if (init_data == NULL) {
ESP_LOGE(TAG, "failed to obtain PHY init data");
abort();
}
esp_phy_calibration_data_t* cal_data =
(esp_phy_calibration_data_t*) calloc(sizeof(esp_phy_calibration_data_t), 1);
if (cal_data == NULL) {
ESP_LOGE(TAG, "failed to allocate memory for RF calibration data");
abort();
}
esp_err_t err = esp_phy_load_cal_data_from_nvs(cal_data);
if (err != ESP_OK) {
ESP_LOGW(TAG, "failed to load RF calibration data, falling back to full calibration");
calibration_mode = PHY_RF_CAL_FULL;
}
esp_phy_rf_init(init_data, calibration_mode, cal_data, false);
if (calibration_mode != PHY_RF_CAL_NONE && err != ESP_OK) {
err = esp_phy_store_cal_data_to_nvs(cal_data);
} else {
err = ESP_OK;
}
esp_phy_release_init_data(init_data);
free(cal_data); // PHY maintains a copy of calibration data, so we can free this
#else
esp_phy_rf_init(NULL, PHY_RF_CAL_NONE, NULL, false);
#endif
}
#endif // CONFIG_PHY_ENABLED

View File

@ -135,6 +135,10 @@ void rtc_slp_prep_lite(uint32_t deep_slp, uint32_t cpu_lp_mode);
*/
uint32_t rtc_sleep(uint32_t cycles_h, uint32_t cycles_l, uint32_t wakeup_opt, uint32_t reject_opt);
/**
* @brief Shutdown PHY and RF. TODO: convert this function to another one.
*/
void pm_close_rf(void);
#ifdef __cplusplus
}

View File

@ -179,4 +179,8 @@ const char* system_get_sdk_version(void)
return "master";
}
const char* esp_get_idf_version(void)
{
return IDF_VER;
}

View File

@ -269,7 +269,7 @@ static void tskTwo(void *pvParameters)
}
TEST_CASE("S32C1I vs AHB test (needs I2S)", "[hw]")
TEST_CASE("S32C1I vs AHB test (needs I2S)", "[hw][ignore]")
{
int i;
TaskHandle_t th[3];

View File

@ -4,7 +4,7 @@
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
TEST_CASE("esp_deepsleep works", "[deepsleep]")
TEST_CASE("esp_deepsleep works", "[deepsleep][ignore]")
{
esp_deep_sleep(2000000);
}
@ -25,20 +25,20 @@ static void do_deep_sleep_from_app_cpu()
}
}
TEST_CASE("wake up using timer", "[deepsleep]")
TEST_CASE("wake up using timer", "[deepsleep][ignore]")
{
esp_deep_sleep_enable_timer_wakeup(2000000);
esp_deep_sleep_start();
}
TEST_CASE("enter deep sleep on APP CPU and wake up using timer", "[deepsleep]")
TEST_CASE("enter deep sleep on APP CPU and wake up using timer", "[deepsleep][ignore]")
{
esp_deep_sleep_enable_timer_wakeup(2000000);
do_deep_sleep_from_app_cpu();
}
TEST_CASE("wake up using ext0 (13 high)", "[deepsleep]")
TEST_CASE("wake up using ext0 (13 high)", "[deepsleep][ignore]")
{
ESP_ERROR_CHECK(rtc_gpio_init(GPIO_NUM_13));
ESP_ERROR_CHECK(gpio_pullup_dis(GPIO_NUM_13));
@ -47,7 +47,7 @@ TEST_CASE("wake up using ext0 (13 high)", "[deepsleep]")
esp_deep_sleep_start();
}
TEST_CASE("wake up using ext0 (13 low)", "[deepsleep]")
TEST_CASE("wake up using ext0 (13 low)", "[deepsleep][ignore]")
{
ESP_ERROR_CHECK(rtc_gpio_init(GPIO_NUM_13));
ESP_ERROR_CHECK(gpio_pullup_en(GPIO_NUM_13));
@ -56,7 +56,7 @@ TEST_CASE("wake up using ext0 (13 low)", "[deepsleep]")
esp_deep_sleep_start();
}
TEST_CASE("wake up using ext1 when RTC_PERIPH is off (13 high)", "[deepsleep]")
TEST_CASE("wake up using ext1 when RTC_PERIPH is off (13 high)", "[deepsleep][ignore]")
{
// This test needs external pulldown
ESP_ERROR_CHECK(rtc_gpio_init(GPIO_NUM_13));
@ -64,7 +64,7 @@ TEST_CASE("wake up using ext1 when RTC_PERIPH is off (13 high)", "[deepsleep]")
esp_deep_sleep_start();
}
TEST_CASE("wake up using ext1 when RTC_PERIPH is off (13 low)", "[deepsleep]")
TEST_CASE("wake up using ext1 when RTC_PERIPH is off (13 low)", "[deepsleep][ignore]")
{
// This test needs external pullup
ESP_ERROR_CHECK(rtc_gpio_init(GPIO_NUM_13));
@ -72,7 +72,7 @@ TEST_CASE("wake up using ext1 when RTC_PERIPH is off (13 low)", "[deepsleep]")
esp_deep_sleep_start();
}
TEST_CASE("wake up using ext1 when RTC_PERIPH is on (13 high)", "[deepsleep]")
TEST_CASE("wake up using ext1 when RTC_PERIPH is on (13 high)", "[deepsleep][ignore]")
{
ESP_ERROR_CHECK(rtc_gpio_init(GPIO_NUM_13));
ESP_ERROR_CHECK(gpio_pullup_dis(GPIO_NUM_13));
@ -82,7 +82,7 @@ TEST_CASE("wake up using ext1 when RTC_PERIPH is on (13 high)", "[deepsleep]")
esp_deep_sleep_start();
}
TEST_CASE("wake up using ext1 when RTC_PERIPH is on (13 low)", "[deepsleep]")
TEST_CASE("wake up using ext1 when RTC_PERIPH is on (13 low)", "[deepsleep][ignore]")
{
ESP_ERROR_CHECK(rtc_gpio_init(GPIO_NUM_13));
ESP_ERROR_CHECK(gpio_pullup_en(GPIO_NUM_13));

View File

@ -37,7 +37,7 @@ static void test_delay_task(void* p)
vTaskDelete(NULL);
}
TEST_CASE("ets_delay produces correct delay on both CPUs", "[delay]")
TEST_CASE("ets_delay produces correct delay on both CPUs", "[delay][ignore]")
{
int delay_ms = 50;
const delay_test_arg_t args = { .delay_us = delay_ms * 1000, .method = 0 };

View File

@ -96,7 +96,7 @@ static void tskTwo(void *pvParameters)
// TODO: split this thing into separate orthogonal tests
TEST_CASE("Fast I/O bus test", "[hw]")
TEST_CASE("Fast I/O bus test", "[hw][ignore]")
{
int i;
if ((REG_UART_BASE(0) >> 16) != 0x3ff4) {

View File

@ -7,7 +7,7 @@
#define DATASIZE (1024*64)
TEST_CASE("Test miniz compression/decompression", "[miniz]")
TEST_CASE("Test miniz compression/decompression", "[miniz][ignore]")
{
int x;
char b;

View File

@ -183,7 +183,7 @@ int mymemcmp(char *a, char *b, int len)
TEST_CASE("Unaligned DMA test (needs I2S)", "[hw]")
TEST_CASE("Unaligned DMA test (needs I2S)", "[hw][ignore]")
{
int x;
char src[2049], dest[2049];

View File

@ -12,15 +12,15 @@ import array
import errno
import base64
idf_path = os.getenv('IDF_PATH')
if idf_path:
sys.path.insert(0, os.path.join(idf_path, 'components', 'esptool_py', 'esptool'))
try:
import esptool
except ImportError:
idf_path = os.getenv('IDF_PATH')
if idf_path is None:
print "Esptool is not found! Install it or set proper $IDF_PATH in environment."
sys.exit(2)
sys.path.append('%s/components/esptool_py/esptool' % idf_path)
import esptool
print "Esptool is not found! Set proper $IDF_PATH in environment."
sys.exit(2)
__version__ = "0.1-dev"

View File

@ -29,7 +29,7 @@ endif
ESPTOOL_ELF2IMAGE_OPTIONS :=
ESPTOOLPY_WRITE_FLASH=$(ESPTOOLPY_SERIAL) write_flash $(if $(CONFIG_ESPTOOLPY_COMPRESSED),-z) $(ESPTOOL_WRITE_FLASH_OPTIONS)
ESPTOOLPY_WRITE_FLASH=$(ESPTOOLPY_SERIAL) write_flash $(if $(CONFIG_ESPTOOLPY_COMPRESSED),-z,-u) $(ESPTOOL_WRITE_FLASH_OPTIONS)
ESPTOOL_ALL_FLASH_ARGS += $(CONFIG_APP_OFFSET) $(APP_BIN)

@ -1 +1 @@
Subproject commit fe69994270e2a450aad3e94a409b58460b1a214f
Subproject commit e9e9179f6fc3f2ecfc568987d3224b5e53a05f06

View File

@ -5,30 +5,48 @@ menuconfig ETHERNET
Select this option to enable ethernet driver and show the submenu with ethernet features.
config DMA_RX_BUF_NUM
int "DMA Rx Buf Num"
default 10
depends on ETHERNET
help
Dma rx buf num ,can not be 0 .
config DMA_TX_BUF_NUM
int "DMA Tx Buf Num"
int "Number of DMA RX buffers"
range 3 20
default 10
depends on ETHERNET
help
Dma tx Buf num ,can not be 0.
Number of DMA receive buffers. Each buffer is 1600 bytes.
Buffers are allocated statically.
Larger number of buffers increases throughput.
If enable flow ctrl, the num must be above 9 .
config DMA_TX_BUF_NUM
int "Number of DMA RX buffers"
range 3 20
default 10
depends on ETHERNET
help
Number of DMA transmit buffers. Each buffer is 1600 bytes.
Buffers are allocated statically.
Larger number of buffers increases throughput.
config EMAC_L2_TO_L3_RX_BUF_MODE
bool "L2 To L3 RX BUF COPY MODE"
bool "Enable copy between Layer2 and Layer3"
default n
depends on ETHERNET
help
Receive Buf user copy mode or pointer mode.
If this options is selected, a copy of each received buffer will be created when
passing it from the Ethernet MAC (L2) to the IP stack (L3). Otherwise, IP stack
will receive pointers to the DMA buffers used by Ethernet MAC.
When Ethernet MAC doesn't have any unused buffers left, it will drop incomming
packets (flow control may help with this problem, to some extent).
The buffers for the IP stack are allocated from the heap, so the total number of
receive buffers is limited by the available heap size, if this option is selected.
If unsure, choose n.
config EMAC_TASK_PRIORITY
int "EMAC_TASK_PRIORITY"
default 20
range 3 22
depends on ETHERNET
help
Emac task priority ,suggest 3 ~ 23.
Ethernet MAC task priority.

View File

@ -75,6 +75,7 @@ struct emac_config_data {
bool emac_flow_ctrl_enable;
bool emac_flow_ctrl_partner_support;
eth_phy_get_partner_pause_enable_func emac_phy_get_partner_pause_enable;
eth_phy_power_enable_func emac_phy_power_enable;
};
enum emac_post_type {

View File

@ -216,8 +216,16 @@ static void emac_set_user_config_data(eth_config_t *config )
emac_config.emac_phy_check_init = config->phy_check_init;
emac_config.emac_phy_get_speed_mode = config->phy_get_speed_mode;
emac_config.emac_phy_get_duplex_mode = config->phy_get_duplex_mode;
#if DMA_RX_BUF_NUM > 9
emac_config.emac_flow_ctrl_enable = config->flow_ctrl_enable;
#else
if(config->flow_ctrl_enable == true) {
ESP_LOGE(TAG, "eth flow ctrl init err!!! Please run make menuconfig and make sure DMA_RX_BUF_NUM > 9 .");
}
emac_config.emac_flow_ctrl_enable = false;
#endif
emac_config.emac_phy_get_partner_pause_enable = config->phy_get_partner_pause_enable;
emac_config.emac_phy_power_enable = config->phy_power_enable;
}
static void emac_enable_intr()
@ -284,6 +292,11 @@ static esp_err_t emac_verify_args(void)
ret = ESP_FAIL;
}
if(emac_config.emac_phy_power_enable == NULL) {
ESP_LOGE(TAG, "phy power enable func is null");
ret = ESP_FAIL;
}
return ret;
}
@ -530,6 +543,10 @@ static void emac_check_phy_init(void)
} else {
REG_CLR_BIT(EMAC_GMACCONFIG_REG, EMAC_GMACFESPEED);
}
#if CONFIG_EMAC_L2_TO_L3_RX_BUF_MODE
emac_disable_flowctrl();
emac_config.emac_flow_ctrl_partner_support = false;
#else
if (emac_config.emac_flow_ctrl_enable == true) {
if (emac_config.emac_phy_get_partner_pause_enable() == true && emac_config.emac_phy_get_duplex_mode() == ETH_MDOE_FULLDUPLEX) {
emac_enable_flowctrl();
@ -542,6 +559,7 @@ static void emac_check_phy_init(void)
emac_disable_flowctrl();
emac_config.emac_flow_ctrl_partner_support = false;
}
#endif
emac_mac_enable_txrx();
}
static void emac_process_link_updown(bool link_status)
@ -588,7 +606,7 @@ esp_err_t esp_eth_tx(uint8_t *buf, uint16_t size)
if (emac_config.emac_status != EMAC_RUNTIME_START || emac_config.emac_status == EMAC_RUNTIME_NOT_INIT) {
ESP_LOGI(TAG, "tx netif close");
ret = ERR_IF;
goto _exit;
return ret;
}
xSemaphoreTakeRecursive( emac_tx_xMutex, ( TickType_t ) portMAX_DELAY );
@ -931,6 +949,8 @@ esp_err_t esp_eth_init(eth_config_t *config)
emac_set_user_config_data(config);
}
emac_config.emac_phy_power_enable(true);
ret = emac_verify_args();
if (ret != ESP_OK) {

View File

@ -80,7 +80,7 @@ typedef void (*eth_phy_func)(void);
typedef esp_err_t (*eth_tcpip_input_func)(void *buffer, uint16_t len, void *eb);
typedef void (*eth_gpio_config_func)(void);
typedef bool (*eth_phy_get_partner_pause_enable_func)(void);
typedef void (*eth_phy_power_enable_func)(bool enable);
/**
* @brief ethernet configuration
@ -98,6 +98,7 @@ typedef struct {
eth_gpio_config_func gpio_config; /*!< gpio config func */
bool flow_ctrl_enable; /*!< flag of flow ctrl enable */
eth_phy_get_partner_pause_enable_func phy_get_partner_pause_enable; /*!< get partner pause enable */
eth_phy_power_enable_func phy_power_enable; /*!< enable or disable phy power */
} eth_config_t;

View File

@ -152,7 +152,7 @@ static int fat_mode_conv(int m)
}
if ((m & O_CREAT) && (m & O_EXCL)) {
res |= FA_CREATE_NEW;
} else if (m & O_CREAT) {
} else if ((m & O_CREAT) && (m & O_TRUNC)) {
res |= FA_CREATE_ALWAYS;
} else if (m & O_APPEND) {
res |= FA_OPEN_ALWAYS;

View File

@ -52,7 +52,7 @@ static void create_file_with_text(const char* name, const char* text)
TEST_ASSERT_EQUAL(0, fclose(f));
}
TEST_CASE("can create and write file on sd card", "[fatfs]")
TEST_CASE("can create and write file on sd card", "[fatfs][ignore]")
{
HEAP_SIZE_CAPTURE();
sdmmc_host_t host = SDMMC_HOST_DEFAULT();
@ -69,7 +69,56 @@ TEST_CASE("can create and write file on sd card", "[fatfs]")
HEAP_SIZE_CHECK(0);
}
TEST_CASE("can read file on sd card", "[fatfs]")
TEST_CASE("overwrite and append file on sd card", "[fatfs][ignore]")
{
HEAP_SIZE_CAPTURE();
sdmmc_host_t host = SDMMC_HOST_DEFAULT();
sdmmc_slot_config_t slot_config = SDMMC_SLOT_CONFIG_DEFAULT();
esp_vfs_fat_sdmmc_mount_config_t mount_config = {
.format_if_mount_failed = true,
.max_files = 5
};
TEST_ESP_OK(esp_vfs_fat_sdmmc_mount("/sdcard", &host, &slot_config, &mount_config, NULL));
/* Create new file with 'aaaa' */
const char *NAME = "/sdcard/hello.txt";
create_file_with_text(NAME, "aaaa");
/* Append 'bbbb' to file */
FILE *f_a = fopen(NAME, "a");
TEST_ASSERT_NOT_NULL(f_a);
TEST_ASSERT_NOT_EQUAL(EOF, fputs("bbbb", f_a));
TEST_ASSERT_EQUAL(0, fclose(f_a));
/* Read back 8 bytes from file, verify it's 'aaaabbbb' */
char buf[10] = { 0 };
FILE *f_r = fopen(NAME, "r");
TEST_ASSERT_NOT_NULL(f_r);
TEST_ASSERT_EQUAL(8, fread(buf, 1, 8, f_r));
TEST_ASSERT_EQUAL_STRING_LEN("aaaabbbb", buf, 8);
/* Be sure we're at end of file */
TEST_ASSERT_EQUAL(0, fread(buf, 1, 8, f_r));
TEST_ASSERT_EQUAL(0, fclose(f_r));
/* Overwrite file with 'cccc' */
create_file_with_text(NAME, "cccc");
/* Verify file now only contains 'cccc' */
f_r = fopen(NAME, "r");
TEST_ASSERT_NOT_NULL(f_r);
bzero(buf, sizeof(buf));
TEST_ASSERT_EQUAL(4, fread(buf, 1, 8, f_r)); // trying to read 8 bytes, only expecting 4
TEST_ASSERT_EQUAL_STRING_LEN("cccc", buf, 4);
TEST_ASSERT_EQUAL(0, fclose(f_r));
TEST_ESP_OK(esp_vfs_fat_sdmmc_unmount());
HEAP_SIZE_CHECK(0);
}
TEST_CASE("can read file on sd card", "[fatfs][ignore]")
{
HEAP_SIZE_CAPTURE();
@ -134,7 +183,7 @@ static void speed_test(void* buf, size_t buf_size, size_t file_size, bool write)
}
TEST_CASE("read speed test", "[fatfs]")
TEST_CASE("read speed test", "[fatfs][ignore]")
{
HEAP_SIZE_CAPTURE();
@ -151,7 +200,7 @@ TEST_CASE("read speed test", "[fatfs]")
HEAP_SIZE_CHECK(0);
}
TEST_CASE("write speed test", "[fatfs]")
TEST_CASE("write speed test", "[fatfs][ignore]")
{
HEAP_SIZE_CAPTURE();
@ -171,7 +220,7 @@ TEST_CASE("write speed test", "[fatfs]")
HEAP_SIZE_CHECK(0);
}
TEST_CASE("can lseek", "[fatfs]")
TEST_CASE("can lseek", "[fatfs][ignore]")
{
HEAP_SIZE_CAPTURE();
sdmmc_host_t host = SDMMC_HOST_DEFAULT();
@ -208,7 +257,7 @@ TEST_CASE("can lseek", "[fatfs]")
HEAP_SIZE_CHECK(0);
}
TEST_CASE("stat returns correct values", "[fatfs]")
TEST_CASE("stat returns correct values", "[fatfs][ignore]")
{
HEAP_SIZE_CAPTURE();
sdmmc_host_t host = SDMMC_HOST_DEFAULT();
@ -249,7 +298,7 @@ TEST_CASE("stat returns correct values", "[fatfs]")
HEAP_SIZE_CHECK(0);
}
TEST_CASE("unlink removes a file", "[fatfs]")
TEST_CASE("unlink removes a file", "[fatfs][ignore]")
{
HEAP_SIZE_CAPTURE();
sdmmc_host_t host = SDMMC_HOST_DEFAULT();
@ -271,7 +320,7 @@ TEST_CASE("unlink removes a file", "[fatfs]")
HEAP_SIZE_CHECK(0);
}
TEST_CASE("link copies a file, rename moves a file", "[fatfs]")
TEST_CASE("link copies a file, rename moves a file", "[fatfs][ignore]")
{
HEAP_SIZE_CAPTURE();
sdmmc_host_t host = SDMMC_HOST_DEFAULT();
@ -373,7 +422,7 @@ done:
}
TEST_CASE("multiple tasks can use same volume", "[fatfs]")
TEST_CASE("multiple tasks can use same volume", "[fatfs][ignore]")
{
HEAP_SIZE_CAPTURE();
sdmmc_host_t host = SDMMC_HOST_DEFAULT();
@ -434,7 +483,7 @@ TEST_CASE("multiple tasks can use same volume", "[fatfs]")
HEAP_SIZE_CHECK(0);
}
TEST_CASE("can create and remove directories", "[fatfs]")
TEST_CASE("can create and remove directories", "[fatfs][ignore]")
{
HEAP_SIZE_CAPTURE();
sdmmc_host_t host = SDMMC_HOST_DEFAULT();
@ -470,7 +519,7 @@ TEST_CASE("can create and remove directories", "[fatfs]")
HEAP_SIZE_CHECK(0);
}
TEST_CASE("opendir, readdir, rewinddir, seekdir work as expected", "[fatfs]")
TEST_CASE("opendir, readdir, rewinddir, seekdir work as expected", "[fatfs][ignore]")
{
HEAP_SIZE_CAPTURE();
sdmmc_host_t host = SDMMC_HOST_DEFAULT();

View File

@ -30,11 +30,6 @@ config FREERTOS_CORETIMER_1
help
Select this to use timer 1
config FREERTOS_CORETIMER_2
bool "Timer 2 (int 16, level 5)"
help
Select this to use timer 2
endchoice
config FREERTOS_HZ

View File

@ -90,10 +90,6 @@
#define XT_TIMER_INDEX 0
#elif CONFIG_FREERTOS_CORETIMER_1
#define XT_TIMER_INDEX 1
#elif CONFIG_FREERTOS_CORETIMER_2
#define XT_TIMER_INDEX 2
#elif CONFIG_FREERTOS_CORETIMER_3
#define XT_TIMER_INDEX 3
#endif
#define configNUM_THREAD_LOCAL_STORAGE_POINTERS CONFIG_FREERTOS_THREAD_LOCAL_STORAGE_POINTERS

View File

@ -216,6 +216,9 @@ static inline uint32_t xPortGetCoreID() {
return id;
}
/* Get tick rate per second */
uint32_t xPortGetTickRateHz(void);
#ifdef __cplusplus
}
#endif

View File

@ -406,7 +406,9 @@ void vPortSetStackWatchpoint( void* pxStackStart ) {
esp_set_watchpoint(1, (char*)addr, 32, ESP_WATCHPOINT_STORE);
}
uint32_t xPortGetTickRateHz(void) {
return (uint32_t)configTICK_RATE_HZ;
}

View File

@ -632,7 +632,7 @@ static void prvAddNewTaskToReadyList( TCB_t *pxNewTCB, TaskFunction_t pxTaskCode
*/
void taskYIELD_OTHER_CORE( BaseType_t xCoreID, UBaseType_t uxPriority )
{
TCB_t *curTCB = xTaskGetCurrentTaskHandle();
TCB_t *curTCB = pxCurrentTCB[xCoreID];
BaseType_t i;
if (xCoreID != tskNO_AFFINITY) {
@ -1056,11 +1056,15 @@ static void prvAddNewTaskToReadyList( TCB_t *pxNewTCB, TaskFunction_t pxTaskCode
taskENTER_CRITICAL(&xTaskQueueMutex);
{
uxCurrentNumberOfTasks++;
if( pxCurrentTCB[ xPortGetCoreID() ] == NULL )
//If the task has no affinity and nothing is scheduled on this core, just throw it this core.
//If it has affinity, throw it on the core that needs it if nothing is already scheduled there.
BaseType_t xMyCore = xCoreID;
if ( xMyCore == tskNO_AFFINITY) xMyCore = xPortGetCoreID();
if( pxCurrentTCB[ xMyCore ] == NULL )
{
/* There are no other tasks, or all the other tasks are in
the suspended state - make this the current task. */
pxCurrentTCB[ xPortGetCoreID() ] = pxNewTCB;
pxCurrentTCB[ xMyCore ] = pxNewTCB;
if( uxCurrentNumberOfTasks == ( UBaseType_t ) 1 )
{
@ -1121,12 +1125,13 @@ static void prvAddNewTaskToReadyList( TCB_t *pxNewTCB, TaskFunction_t pxTaskCode
portSETUP_TCB( pxNewTCB );
}
curTCB = pxCurrentTCB[ xPortGetCoreID() ];
taskEXIT_CRITICAL(&xTaskQueueMutex);
if( xSchedulerRunning != pdFALSE )
{
taskENTER_CRITICAL(&xTaskQueueMutex);
curTCB = pxCurrentTCB[ xPortGetCoreID() ];
/* Scheduler is running. If the created task is of a higher priority than an executing task
then it should run now.
ToDo: This only works for the current core. If a task is scheduled on an other processor,
@ -1141,7 +1146,7 @@ static void prvAddNewTaskToReadyList( TCB_t *pxNewTCB, TaskFunction_t pxTaskCode
*/
if( tskCAN_RUN_HERE( xCoreID ) && curTCB->uxPriority < pxNewTCB->uxPriority )
{
taskYIELD_IF_USING_PREEMPTION();
taskYIELD_IF_USING_PREEMPTION_MUX(&xTaskQueueMutex);
}
else if( xCoreID != xPortGetCoreID() ) {
taskYIELD_OTHER_CORE(xCoreID, pxNewTCB->uxPriority);
@ -2381,26 +2386,15 @@ BaseType_t xSwitchRequired = pdFALSE;
switch, even when this routine (running on core 0) unblocks a bunch of high-priority
tasks... this is less than optimal -- JD. */
if ( xPortGetCoreID()!=0 ) {
#if ( configUSE_TICK_HOOK == 1 )
vApplicationTickHook();
#endif /* configUSE_TICK_HOOK */
esp_vApplicationTickHook();
/*
We can't really calculate what we need, that's done on core 0... just assume we need a switch.
ToDo: Make this more intelligent? -- JD
*/
{
/* Guard against the tick hook being called when the pended tick
count is being unwound (when the scheduler is being unlocked). */
if( ( uxSchedulerSuspended[ xPortGetCoreID() ] != ( UBaseType_t ) pdFALSE ) || uxPendedTicks == ( UBaseType_t ) 0U )
{
#if ( configUSE_TICK_HOOK == 1 )
vApplicationTickHook();
#endif /* configUSE_TICK_HOOK */
esp_vApplicationTickHook();
}
else
{
mtCOVERAGE_TEST_MARKER();
}
}
return pdTRUE;
}
@ -2670,11 +2664,13 @@ BaseType_t xSwitchRequired = pdFALSE;
void vTaskSwitchContext( void )
{
tskTCB * pxTCB;
//This can be called both from IRQ as well as normal context, so we can't
//use taskENTER_CRITICAL() here. Instead, save the irq status and disable
//IRQs, so we can use taskENTER_CRITICAL_ISR and friends.
//Note: This can be called from interrupt context as well as from non-interrupt context (voluntary yield). The
//taskENTER_CRITICAL/taskEXIT_CRITICAL is modified to work in both scenarios for the ESP32, so we can freely use
//them here. However, in case of a voluntary yield, a nonvoluntary yield can still happen *during* the voluntary
//yield. Disabling interrupts using portENTER_CRITICAL_NESTED puts a stop to this and makes the rest of the code a
//bit neater.
int irqstate=portENTER_CRITICAL_NESTED();
tskTCB * pxTCB;
if( uxSchedulerSuspended[ xPortGetCoreID() ] != ( UBaseType_t ) pdFALSE )
{
/* The scheduler is currently suspended - do not allow a context
@ -3023,9 +3019,14 @@ BaseType_t xReturn;
This function assumes that a check has already been made to ensure that
pxEventList is not empty. */
pxUnblockedTCB = ( TCB_t * ) listGET_OWNER_OF_HEAD_ENTRY( pxEventList );
configASSERT( pxUnblockedTCB );
( void ) uxListRemove( &( pxUnblockedTCB->xEventListItem ) );
if ( ( listLIST_IS_EMPTY( pxEventList ) ) == pdFALSE ) {
pxUnblockedTCB = ( TCB_t * ) listGET_OWNER_OF_HEAD_ENTRY( pxEventList );
configASSERT( pxUnblockedTCB );
( void ) uxListRemove( &( pxUnblockedTCB->xEventListItem ) );
} else {
taskEXIT_CRITICAL_ISR(&xTaskQueueMutex);
return pdFALSE;
}
if( uxSchedulerSuspended[ xPortGetCoreID() ] == ( UBaseType_t ) pdFALSE )
{
@ -3036,9 +3037,7 @@ BaseType_t xReturn;
{
/* The delayed and ready lists cannot be accessed, so hold this task
pending until the scheduler is resumed. */
taskENTER_CRITICAL(&xTaskQueueMutex);
vListInsertEnd( &( xPendingReadyList[ xPortGetCoreID() ] ), &( pxUnblockedTCB->xEventListItem ) );
taskEXIT_CRITICAL(&xTaskQueueMutex);
}
if ( tskCAN_RUN_HERE(pxUnblockedTCB->xCoreID) && pxUnblockedTCB->uxPriority >= pxCurrentTCB[ xPortGetCoreID() ]->uxPriority )

View File

@ -187,7 +187,7 @@ static void uartRxInit(xQueueHandle q)
}
// TODO: split this thing into separate orthogonal tests
TEST_CASE("Bunch of FreeRTOS tests", "[freertos]")
TEST_CASE("Bunch of FreeRTOS tests", "[freertos][ignore]")
{
char *tst;
TaskHandle_t th[12];

View File

@ -38,7 +38,7 @@ static void task_event_group_call_response(void *param)
vTaskDelete(NULL);
}
TEST_CASE("FreeRTOS Event Groups", "[freertos]")
TEST_CASE("FreeRTOS Event Groups", "[freertos][ignore]")
{
eg = xEventGroupCreate();
@ -89,7 +89,7 @@ static void task_test_sync(void *param)
vTaskDelete(NULL);
}
TEST_CASE("FreeRTOS Event Group Sync", "[freertos]")
TEST_CASE("FreeRTOS Event Group Sync", "[freertos][ignore]")
{
eg = xEventGroupCreate();

View File

@ -13,7 +13,7 @@ static void task_delete_self(void *param)
vTaskDelete(NULL);
}
TEST_CASE("FreeRTOS Delete Tasks", "[freertos]")
TEST_CASE("FreeRTOS Delete Tasks", "[freertos][ignore]")
{
xTaskCreatePinnedToCore(task_delete_self, "tsk_self_a", 4096, NULL, configMAX_PRIORITIES - 1, NULL, 0);
xTaskCreatePinnedToCore(task_delete_self, "tsk_self_a", 4096, NULL, configMAX_PRIORITIES - 1, NULL, 0);

View File

@ -17,7 +17,7 @@
#include "soc/io_mux_reg.h"
TEST_CASE("Panic handler", "[freertos]")
TEST_CASE("Panic handler", "[freertos][ignore]")
{
volatile int *i;
i = (volatile int *)0x0;

View File

@ -185,12 +185,12 @@ static void testRingbuffer(int type)
}
// TODO: split this thing into separate orthogonal tests
TEST_CASE("FreeRTOS ringbuffer test, no splitting items", "[freertos]")
TEST_CASE("FreeRTOS ringbuffer test, no splitting items", "[freertos][ignore]")
{
testRingbuffer(0);
}
TEST_CASE("FreeRTOS ringbuffer test, w/ splitting items", "[freertos]")
TEST_CASE("FreeRTOS ringbuffer test, w/ splitting items", "[freertos][ignore]")
{
testRingbuffer(1);
}

View File

@ -1,7 +0,0 @@
Config: {execute count: 1, execute order: in order}
DUT: [UT1]
Filter:
- Add:
ID: [SYS_OS_0102, SYS_MISC_0102, SYS_MISC_0107, SYS_MISC_0106, SYS_MISC_0109,
SYS_MISC_0108, SYS_MISC_0112, SYS_MISC_0113, SYS_MISC_0110, SYS_MISC_0111, SYS_LIB_0103,
SYS_LIB_0102, SYS_LIB_0101, SYS_LIB_0106, SYS_LIB_0105, SYS_LIB_0104]

View File

@ -1,461 +0,0 @@
test cases:
- CI ready: 'Yes'
ID: SYS_LIB_0101
SDK: ESP32_IDF
Test App: UT
auto test: 'Yes'
category: Function
cmd set:
- IDFUnitTest/UnitTest
- - test_case = "check if ROM or Flash is used for functions"
- [dummy]
comment: check if ROM or Flash is used for functions
execution time: 0
expected result: 1. set succeed
initial condition: UTINIT1
level: Unit
module: System
steps: 1. run lib test
sub module: Std Lib
summary: lib unit test
test environment: UT_T1_1
test point 1: basic function
test point 2: lib
version: v1 (2016-10-26)
- CI ready: 'Yes'
ID: SYS_LIB_0102
SDK: ESP32_IDF
Test App: UT
auto test: 'Yes'
category: Function
cmd set:
- IDFUnitTest/UnitTest
- - test_case = "test time functions"
- [dummy]
comment: test time functions
execution time: 0
expected result: 1. set succeed
initial condition: UTINIT1
level: Unit
module: System
steps: 1. run lib test
sub module: Std Lib
summary: lib unit test
test environment: UT_T1_1
test point 1: basic function
test point 2: lib
version: v1 (2016-10-26)
- CI ready: 'Yes'
ID: SYS_LIB_0103
SDK: ESP32_IDF
Test App: UT
auto test: 'Yes'
category: Function
cmd set:
- IDFUnitTest/UnitTest
- - test_case = "test sscanf function"
- [dummy]
comment: test sscanf function
execution time: 0
expected result: 1. set succeed
initial condition: UTINIT1
level: Unit
module: System
steps: 1. run lib test
sub module: Std Lib
summary: lib unit test
test environment: UT_T1_1
test point 1: basic function
test point 2: lib
version: v1 (2016-10-26)
- CI ready: 'Yes'
ID: SYS_LIB_0104
SDK: ESP32_IDF
Test App: UT
auto test: 'Yes'
category: Function
cmd set:
- IDFUnitTest/UnitTest
- - test_case = "test sprintf function"
- [dummy]
comment: test sprintf function
execution time: 0
expected result: 1. set succeed
initial condition: UTINIT1
level: Unit
module: System
steps: 1. run lib test
sub module: Std Lib
summary: lib unit test
test environment: UT_T1_1
test point 1: basic function
test point 2: lib
version: v1 (2016-10-26)
- CI ready: 'Yes'
ID: SYS_LIB_0105
SDK: ESP32_IDF
Test App: UT
auto test: 'Yes'
category: Function
cmd set:
- IDFUnitTest/UnitTest
- - test_case = "test atoX functions"
- [dummy]
comment: test atoX functions
execution time: 0
expected result: 1. set succeed
initial condition: UTINIT1
level: Unit
module: System
steps: 1. run lib test
sub module: Std Lib
summary: lib unit test
test environment: UT_T1_1
test point 1: basic function
test point 2: lib
version: v1 (2016-10-26)
- CI ready: 'Yes'
ID: SYS_LIB_0106
SDK: ESP32_IDF
Test App: UT
auto test: 'Yes'
category: Function
cmd set:
- IDFUnitTest/UnitTest
- - test_case = "test ctype functions"
- [dummy]
comment: test ctype functions
execution time: 0
expected result: 1. set succeed
initial condition: UTINIT1
level: Unit
module: System
steps: 1. run lib test
sub module: Std Lib
summary: lib unit test
test environment: UT_T1_1
test point 1: basic function
test point 2: lib
version: v1 (2016-10-26)
- CI ready: 'Yes'
ID: SYS_MISC_0102
SDK: ESP32_IDF
Test App: UT
auto test: 'Yes'
category: Function
cmd set:
- IDFUnitTest/UnitTest
- - test_case = "mbedtls MPI self-tests"
- [dummy]
comment: mbedtls MPI self-tests
execution time: 0
expected result: 1. set succeed
initial condition: UTINIT1
level: Unit
module: System
steps: 1. run bignum test
sub module: Misc
summary: bignum unit test
test environment: UT_T1_1
test point 1: basic function
test point 2: bignum
version: v1 (2016-10-26)
- CI ready: 'Yes'
ID: SYS_MISC_0103
SDK: ESP32_IDF
Test App: UT
auto test: 'Yes'
category: Function
cmd set:
- IDFUnitTest/UnitTest
- - test_case = "test AES thread safety"
- [dummy]
comment: test AES thread safety
execution time: 0
expected result: 1. set succeed
initial condition: UTINIT1
level: Unit
module: System
steps: 1. run hwcrypto test
sub module: Misc
summary: hwcrypto unit test
test environment: UT_T1_1
test point 1: basic function
test point 2: hwcrypto
version: v1 (2016-10-26)
- CI ready: 'Yes'
ID: SYS_MISC_0104
SDK: ESP32_IDF
Test App: UT
auto test: 'Yes'
category: Function
cmd set:
- IDFUnitTest/UnitTest
- - test_case = "test AES acceleration"
- [dummy]
comment: test AES acceleration
execution time: 0
expected result: 1. set succeed
initial condition: UTINIT1
level: Unit
module: System
steps: 1. run hwcrypto test
sub module: Misc
summary: hwcrypto unit test
test environment: UT_T1_1
test point 1: basic function
test point 2: hwcrypto
version: v1 (2016-10-26)
- CI ready: 'Yes'
ID: SYS_MISC_0105
SDK: ESP32_IDF
Test App: UT
auto test: 'Yes'
category: Function
cmd set:
- IDFUnitTest/UnitTest
- - test_case = "test SHA thread safety"
- [dummy]
comment: test SHA thread safety
execution time: 0
expected result: 1. set succeed
initial condition: UTINIT1
level: Unit
module: System
steps: 1. run hwcrypto test
sub module: Misc
summary: hwcrypto unit test
test environment: UT_T1_1
test point 1: basic function
test point 2: hwcrypto
version: v1 (2016-10-26)
- CI ready: 'Yes'
ID: SYS_MISC_0106
SDK: ESP32_IDF
Test App: UT
auto test: 'Yes'
category: Function
cmd set:
- IDFUnitTest/UnitTest
- - test_case = "context switch saves FP registers"
- [dummy]
comment: context switch saves FP registers
execution time: 0
expected result: 1. set succeed
initial condition: UTINIT1
level: Unit
module: System
steps: 1. run fp test
sub module: Misc
summary: fp unit test
test environment: UT_T1_1
test point 1: basic function
test point 2: fp
version: v1 (2016-10-26)
- CI ready: 'Yes'
ID: SYS_MISC_0107
SDK: ESP32_IDF
Test App: UT
auto test: 'Yes'
category: Function
cmd set:
- IDFUnitTest/UnitTest
- - test_case = "test FP sqrt"
- [dummy]
comment: test FP sqrt
execution time: 0
expected result: 1. set succeed
initial condition: UTINIT1
level: Unit
module: System
steps: 1. run fp test
sub module: Misc
summary: fp unit test
test environment: UT_T1_1
test point 1: basic function
test point 2: fp
version: v1 (2016-10-26)
- CI ready: 'Yes'
ID: SYS_MISC_0108
SDK: ESP32_IDF
Test App: UT
auto test: 'Yes'
category: Function
cmd set:
- IDFUnitTest/UnitTest
- - test_case = "test FP div"
- [dummy]
comment: test FP div
execution time: 0
expected result: 1. set succeed
initial condition: UTINIT1
level: Unit
module: System
steps: 1. run fp test
sub module: Misc
summary: fp unit test
test environment: UT_T1_1
test point 1: basic function
test point 2: fp
version: v1 (2016-10-26)
- CI ready: 'Yes'
ID: SYS_MISC_0109
SDK: ESP32_IDF
Test App: UT
auto test: 'Yes'
category: Function
cmd set:
- IDFUnitTest/UnitTest
- - test_case = "test FP mul"
- [dummy]
comment: test FP mul
execution time: 0
expected result: 1. set succeed
initial condition: UTINIT1
level: Unit
module: System
steps: 1. run fp test
sub module: Misc
summary: fp unit test
test environment: UT_T1_1
test point 1: basic function
test point 2: fp
version: v1 (2016-10-26)
- CI ready: 'Yes'
ID: SYS_MISC_0110
SDK: ESP32_IDF
Test App: UT
auto test: 'Yes'
category: Function
cmd set:
- IDFUnitTest/UnitTest
- - test_case = "test FP add"
- [dummy]
comment: test FP add
execution time: 0
expected result: 1. set succeed
initial condition: UTINIT1
level: Unit
module: System
steps: 1. run fp test
sub module: Misc
summary: fp unit test
test environment: UT_T1_1
test point 1: basic function
test point 2: fp
version: v1 (2016-10-26)
- CI ready: 'Yes'
ID: SYS_MISC_0111
SDK: ESP32_IDF
Test App: UT
auto test: 'Yes'
category: Function
cmd set:
- IDFUnitTest/UnitTest
- - test_case = "Test JPEG decompression library"
- [dummy]
comment: Test JPEG decompression library
execution time: 0
expected result: 1. set succeed
initial condition: UTINIT1
level: Unit
module: System
steps: 1. run JPEG decompression test
sub module: Misc
summary: JPEG decompression library unit test
test environment: UT_T1_1
test point 1: basic function
test point 2: tjpgd
version: v1 (2016-10-31)
- CI ready: 'Yes'
ID: SYS_MISC_0112
SDK: ESP32_IDF
Test App: UT
auto test: 'Yes'
category: Function
cmd set:
- IDFUnitTest/UnitTest
- - test_case = "mbedtls AES self-tests"
- [dummy]
comment: mbedtls AES self-tests
execution time: 0
expected result: 1. set succeed
initial condition: UTINIT1
level: Unit
module: System
steps: 1. run mbedtls AES self-tests
sub module: Misc
summary: mbedtls AES unit test
test environment: UT_T1_1
test point 1: basic function
test point 2: mbedtls AES
version: v1 (2016-10-31)
- CI ready: 'Yes'
ID: SYS_MISC_0113
SDK: ESP32_IDF
Test App: UT
auto test: 'Yes'
category: Function
cmd set:
- IDFUnitTest/UnitTest
- - test_case = "mbedtls SHA self-tests"
- [dummy]
comment: mbedtls SHA self-tests
execution time: 0
expected result: 1. set succeed
initial condition: UTINIT1
level: Unit
module: System
steps: 1. run mbedtls SHA self-tests
sub module: Misc
summary: mbedtls SHA unit test
test environment: UT_T1_1
test point 1: basic function
test point 2: mbedtls SHA
version: v1 (2016-10-31)
- CI ready: 'Yes'
ID: SYS_MISC_0115
SDK: ESP32_IDF
Test App: UT
auto test: 'Yes'
category: Function
cmd set:
- IDFUnitTest/UnitTest
- - test_case = "test SHA acceleration"
- [dummy]
comment: test SHA acceleration
execution time: 0
expected result: 1. set succeed
initial condition: UTINIT1
level: Unit
module: System
steps: 1. run SHA acceleration test
sub module: Misc
summary: SHA acceleration unit test
test environment: UT_T1_1
test point 1: basic function
test point 2: SHA acceleration
version: v1 (2016-10-31)
- CI ready: 'Yes'
ID: SYS_OS_0102
SDK: ESP32_IDF
Test App: UT
auto test: 'Yes'
category: Function
cmd set:
- IDFUnitTest/UnitTest
- - test_case = "Freertos TLS delete cb"
- [dummy]
comment: Freertos TLS delete cb
execution time: 0
expected result: 1. set succeed
initial condition: UTINIT1
level: Unit
module: System
steps: 1. run Freertos TLS delete cb test
sub module: OS
summary: Freertos TLS delete cb unit test
test environment: UT_T1_1
test point 1: basic function
test point 2: Freertos TLS delete cb
version: v1 (2016-10-31)

Some files were not shown because too many files have changed in this diff Show More