forked from espressif/esp-idf
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d998d76627 |
@@ -1,4 +1,4 @@
|
||||
[codespell]
|
||||
skip = build,*.yuv,components/fatfs/src/*,alice.txt,*.rgb,components/wpa_supplicant/*,components/esp_wifi/*,*.pem
|
||||
ignore-words-list = ser,dout,rsource,fram,inout,shs,ans,aci,unstall,unstalling,hart,wheight,wel,ot,fane,assertIn,registr,oen,parms
|
||||
ignore-words-list = ser,dout,rsource,fram,inout,shs,ans,aci,unstall,unstalling,hart,wheight,wel,ot,fane,assertIn,registr,oen
|
||||
write-changes = true
|
||||
|
||||
@@ -2,5 +2,248 @@
|
||||
#
|
||||
# https://docs.gitlab.com/ee/user/project/code_owners.html#the-syntax-of-code-owners-files
|
||||
#
|
||||
# If more than one rule matches a given file, the latest rule is used.
|
||||
# The file should be generally kept sorted, except when it is necessary
|
||||
# to use a different order due to the fact above. In that case, use
|
||||
# '# sort-order-reset' comment line to reset the sort order.
|
||||
#
|
||||
# Recipes for a few common cases:
|
||||
#
|
||||
# 1. Specific directory with all its contents:
|
||||
#
|
||||
# /components/app_trace/
|
||||
#
|
||||
# Note the trailing slash!
|
||||
#
|
||||
# 2. File with certain extension in any subdirectory of a certain directory:
|
||||
#
|
||||
# /examples/**/*.py
|
||||
#
|
||||
# This includes an *.py files in /examples/ directory as well.
|
||||
#
|
||||
# 3. Contents of a directory with a certain name, anywhere in the tree:
|
||||
#
|
||||
# test_*_host/
|
||||
#
|
||||
# Will match everything under components/efuse/test_efuse_host/,
|
||||
# components/heap/test_multi_heap_host/, components/lwip/test_afl_host/, etc.
|
||||
#
|
||||
# 4. Same as above, except limited to a specific place in the tree:
|
||||
#
|
||||
# /components/esp32*/
|
||||
#
|
||||
# Matches everything under /components/esp32, /components/esp32s2, etc.
|
||||
# Doesn't match /tools/some-test/components/esp32s5.
|
||||
#
|
||||
# 5. Specific file:
|
||||
#
|
||||
# /tools/tools.json
|
||||
#
|
||||
# 6. File with a certain name anywhere in the tree
|
||||
#
|
||||
# .gitignore
|
||||
#
|
||||
|
||||
* @esp-idf-codeowners/all-maintainers
|
||||
* @esp-idf-codeowners/other
|
||||
|
||||
/.* @esp-idf-codeowners/tools
|
||||
/.codespellrc @esp-idf-codeowners/ci
|
||||
/.github/workflows/ @esp-idf-codeowners/ci
|
||||
/.gitlab-ci.yml @esp-idf-codeowners/ci
|
||||
/.gitlab/ci/ @esp-idf-codeowners/ci
|
||||
/.pre-commit-config.yaml @esp-idf-codeowners/ci
|
||||
/.readthedocs.yml @esp-idf-codeowners/docs
|
||||
/.vale.ini @esp-idf-codeowners/docs
|
||||
/CMakeLists.txt @esp-idf-codeowners/build-config
|
||||
/COMPATIBILITY*.md @esp-idf-codeowners/peripherals
|
||||
/CONTRIBUTING.md @esp-idf-codeowners/docs
|
||||
/Kconfig @esp-idf-codeowners/build-config
|
||||
/README*.md @esp-idf-codeowners/docs
|
||||
/ROADMAP*.md @esp-idf-codeowners/docs
|
||||
/SUPPORT_POLICY*.md @esp-idf-codeowners/docs
|
||||
/add_path.sh @esp-idf-codeowners/tools
|
||||
/conftest.py @esp-idf-codeowners/ci
|
||||
/export.* @esp-idf-codeowners/tools
|
||||
/install.* @esp-idf-codeowners/tools
|
||||
/pytest.ini @esp-idf-codeowners/ci
|
||||
/sdkconfig.rename @esp-idf-codeowners/build-config
|
||||
/sonar-project.properties @esp-idf-codeowners/ci
|
||||
|
||||
# sort-order-reset
|
||||
|
||||
/components/app_trace/ @esp-idf-codeowners/debugging
|
||||
/components/app_update/ @esp-idf-codeowners/system @esp-idf-codeowners/app-utilities
|
||||
/components/bootloader*/ @esp-idf-codeowners/system @esp-idf-codeowners/security
|
||||
/components/bootloader_support/bootloader_flash/ @esp-idf-codeowners/peripherals
|
||||
/components/bt/ @esp-idf-codeowners/bluetooth
|
||||
/components/cmock/ @esp-idf-codeowners/system
|
||||
/components/console/ @esp-idf-codeowners/system @esp-idf-codeowners/app-utilities/console
|
||||
/components/cxx/ @esp-idf-codeowners/system
|
||||
/components/driver/ @esp-idf-codeowners/peripherals
|
||||
/components/efuse/ @esp-idf-codeowners/system
|
||||
/components/esp_adc/ @esp-idf-codeowners/peripherals
|
||||
/components/esp_app_format/ @esp-idf-codeowners/system @esp-idf-codeowners/app-utilities
|
||||
/components/esp_bootloader_format/ @esp-idf-codeowners/system @esp-idf-codeowners/app-utilities
|
||||
/components/esp_coex/ @esp-idf-codeowners/wifi @esp-idf-codeowners/bluetooth @esp-idf-codeowners/ieee802154
|
||||
/components/esp_common/ @esp-idf-codeowners/system
|
||||
/components/esp_driver_*/ @esp-idf-codeowners/peripherals
|
||||
/components/esp_driver_sdmmc/ @esp-idf-codeowners/peripherals @esp-idf-codeowners/storage
|
||||
/components/esp_eth/ @esp-idf-codeowners/network
|
||||
/components/esp_event/ @esp-idf-codeowners/system
|
||||
/components/esp_gdbstub/ @esp-idf-codeowners/debugging
|
||||
/components/esp_hid/ @esp-idf-codeowners/bluetooth
|
||||
/components/esp_http_client/ @esp-idf-codeowners/app-utilities
|
||||
/components/esp_http_server/ @esp-idf-codeowners/app-utilities
|
||||
/components/esp_https_ota/ @esp-idf-codeowners/app-utilities
|
||||
/components/esp_https_server/ @esp-idf-codeowners/app-utilities
|
||||
/components/esp_hw_support/ @esp-idf-codeowners/system @esp-idf-codeowners/peripherals
|
||||
/components/esp_hw_support/lowpower/ @esp-idf-codeowners/power-management
|
||||
/components/esp_lcd/ @esp-idf-codeowners/peripherals
|
||||
/components/esp_local_ctrl/ @esp-idf-codeowners/app-utilities
|
||||
/components/esp_mm/ @esp-idf-codeowners/peripherals
|
||||
/components/esp_netif/ @esp-idf-codeowners/network
|
||||
/components/esp_netif_stack/ @esp-idf-codeowners/network
|
||||
/components/esp_partition/ @esp-idf-codeowners/storage
|
||||
/components/esp_phy/ @esp-idf-codeowners/bluetooth @esp-idf-codeowners/wifi @esp-idf-codeowners/ieee802154
|
||||
/components/esp_pm/ @esp-idf-codeowners/power-management @esp-idf-codeowners/bluetooth @esp-idf-codeowners/wifi @esp-idf-codeowners/system
|
||||
/components/esp_psram/ @esp-idf-codeowners/peripherals @esp-idf-codeowners/system
|
||||
/components/esp_ringbuf/ @esp-idf-codeowners/system
|
||||
/components/esp_rom/ @esp-idf-codeowners/system @esp-idf-codeowners/bluetooth @esp-idf-codeowners/wifi
|
||||
/components/esp_security/ @esp-idf-codeowners/security
|
||||
/components/esp_system/ @esp-idf-codeowners/system
|
||||
/components/esp_timer/ @esp-idf-codeowners/system
|
||||
/components/esp-tls/ @esp-idf-codeowners/app-utilities
|
||||
/components/esp_vfs_*/ @esp-idf-codeowners/storage
|
||||
/components/esp_vfs_console/ @esp-idf-codeowners/storage @esp-idf-codeowners/system
|
||||
/components/esp_wifi/ @esp-idf-codeowners/wifi
|
||||
/components/espcoredump/ @esp-idf-codeowners/debugging
|
||||
/components/esptool_py/ @esp-idf-codeowners/tools
|
||||
/components/fatfs/ @esp-idf-codeowners/storage
|
||||
/components/freertos/ @esp-idf-codeowners/system
|
||||
/components/hal/ @esp-idf-codeowners/peripherals
|
||||
/components/hal/test_apps/crypto/ @esp-idf-codeowners/peripherals @esp-idf-codeowners/security
|
||||
/components/heap/ @esp-idf-codeowners/system
|
||||
/components/http_parser/ @esp-idf-codeowners/app-utilities
|
||||
/components/idf_test/ @esp-idf-codeowners/ci
|
||||
/components/ieee802154/ @esp-idf-codeowners/ieee802154
|
||||
/components/json/ @esp-idf-codeowners/app-utilities
|
||||
/components/linux/ @esp-idf-codeowners/system
|
||||
/components/log/ @esp-idf-codeowners/system
|
||||
/components/lwip/ @esp-idf-codeowners/lwip
|
||||
/components/mbedtls/ @esp-idf-codeowners/app-utilities/mbedtls @esp-idf-codeowners/security
|
||||
/components/mqtt/ @esp-idf-codeowners/network
|
||||
/components/newlib/ @esp-idf-codeowners/system @esp-idf-codeowners/toolchain
|
||||
/components/nvs_flash/ @esp-idf-codeowners/storage
|
||||
/components/nvs_sec_provider/ @esp-idf-codeowners/storage @esp-idf-codeowners/security
|
||||
/components/openthread/ @esp-idf-codeowners/ieee802154
|
||||
/components/partition_table/ @esp-idf-codeowners/system
|
||||
/components/perfmon/ @esp-idf-codeowners/debugging
|
||||
/components/protobuf-c/ @esp-idf-codeowners/app-utilities
|
||||
/components/protocomm/ @esp-idf-codeowners/app-utilities/provisioning
|
||||
/components/pthread/ @esp-idf-codeowners/system
|
||||
/components/riscv/ @esp-idf-codeowners/system
|
||||
/components/rt/ @esp-idf-codeowners/system
|
||||
/components/sdmmc/ @esp-idf-codeowners/storage
|
||||
/components/soc/ @esp-idf-codeowners/peripherals @esp-idf-codeowners/system
|
||||
/components/spi_flash/ @esp-idf-codeowners/peripherals
|
||||
/components/spiffs/ @esp-idf-codeowners/storage
|
||||
/components/tcp_transport/ @esp-idf-codeowners/network
|
||||
/components/touch_element/ @esp-idf-codeowners/peripherals
|
||||
/components/ulp/ @esp-idf-codeowners/system
|
||||
/components/unity/ @esp-idf-codeowners/ci
|
||||
/components/usb/ @esp-idf-codeowners/peripherals/usb
|
||||
/components/vfs/ @esp-idf-codeowners/storage
|
||||
/components/wear_levelling/ @esp-idf-codeowners/storage
|
||||
/components/wifi_provisioning/ @esp-idf-codeowners/app-utilities/provisioning
|
||||
/components/wpa_supplicant/ @esp-idf-codeowners/wifi @esp-idf-codeowners/app-utilities/mbedtls
|
||||
/components/xtensa/ @esp-idf-codeowners/system
|
||||
|
||||
/docs/ @esp-idf-codeowners/docs
|
||||
/docs/docs_not_updated/ @esp-idf-codeowners/all-maintainers
|
||||
/docs/**/api-guides/tools/ @esp-idf-codeowners/tools
|
||||
/docs/en/api-guides/core_dump.rst @esp-idf-codeowners/debugging
|
||||
/docs/**/api-guides/wifi* @esp-idf-codeowners/wifi
|
||||
/docs/**/api-guides/esp-wifi-mesh.rst @esp-idf-codeowners/wifi
|
||||
/docs/en/api-guides/jtag-debugging/ @esp-idf-codeowners/debugging
|
||||
/docs/**/api-reference/bluetooth/ @esp-idf-codeowners/bluetooth
|
||||
/docs/**/api-reference/network/ @esp-idf-codeowners/network @esp-idf-codeowners/wifi
|
||||
/docs/**/api-reference/peripherals/ @esp-idf-codeowners/peripherals
|
||||
/docs/**/api-reference/peripherals/usb* @esp-idf-codeowners/peripherals @esp-idf-codeowners/peripherals/usb
|
||||
/docs/**/api-reference/peripherals/usb*/ @esp-idf-codeowners/peripherals @esp-idf-codeowners/peripherals/usb
|
||||
/docs/**/api-reference/protocols/ @esp-idf-codeowners/network @esp-idf-codeowners/app-utilities
|
||||
/docs/**/api-reference/provisioning/ @esp-idf-codeowners/app-utilities/provisioning
|
||||
/docs/**/api-reference/storage/ @esp-idf-codeowners/storage
|
||||
/docs/**/api-reference/system/ @esp-idf-codeowners/system
|
||||
/docs/**/security/ @esp-idf-codeowners/security
|
||||
/docs/**/migration-guides/ @esp-idf-codeowners/docs @esp-idf-codeowners/all-maintainers
|
||||
/docs/**/contribute/install-pre-commit-hook.rst @esp-idf-codeowners/ci @esp-idf-codeowners/tools
|
||||
|
||||
/examples/README.md @esp-idf-codeowners/docs @esp-idf-codeowners/ci
|
||||
/examples/**/*.py @esp-idf-codeowners/ci @esp-idf-codeowners/tools
|
||||
/examples/bluetooth/ @esp-idf-codeowners/bluetooth
|
||||
/examples/build_system/ @esp-idf-codeowners/build-config
|
||||
/examples/common_components/ @esp-idf-codeowners/system @esp-idf-codeowners/wifi @esp-idf-codeowners/lwip @esp-idf-codeowners/network
|
||||
/examples/custom_bootloader/ @esp-idf-codeowners/system
|
||||
/examples/cxx/ @esp-idf-codeowners/system
|
||||
/examples/ethernet/ @esp-idf-codeowners/network
|
||||
/examples/get-started/ @esp-idf-codeowners/system
|
||||
/examples/ieee802154/ @esp-idf-codeowners/ieee802154
|
||||
/examples/mesh/ @esp-idf-codeowners/wifi
|
||||
/examples/network/ @esp-idf-codeowners/network @esp-idf-codeowners/wifi
|
||||
/examples/openthread/ @esp-idf-codeowners/ieee802154
|
||||
/examples/peripherals/ @esp-idf-codeowners/peripherals
|
||||
/examples/peripherals/usb/ @esp-idf-codeowners/peripherals @esp-idf-codeowners/peripherals/usb
|
||||
/examples/phy/ @esp-idf-codeowners/bluetooth @esp-idf-codeowners/wifi @esp-idf-codeowners/ieee802154
|
||||
/examples/protocols/ @esp-idf-codeowners/network @esp-idf-codeowners/app-utilities
|
||||
/examples/provisioning/ @esp-idf-codeowners/app-utilities/provisioning
|
||||
/examples/security/ @esp-idf-codeowners/security
|
||||
/examples/storage/ @esp-idf-codeowners/storage
|
||||
/examples/system/ @esp-idf-codeowners/system
|
||||
/examples/system/ota/ @esp-idf-codeowners/app-utilities
|
||||
/examples/wifi/ @esp-idf-codeowners/wifi
|
||||
/examples/zigbee/ @esp-idf-codeowners/ieee802154
|
||||
|
||||
/tools/ @esp-idf-codeowners/tools
|
||||
/tools/ble/ @esp-idf-codeowners/app-utilities
|
||||
/tools/catch/ @esp-idf-codeowners/ci
|
||||
/tools/ci/ @esp-idf-codeowners/ci
|
||||
/tools/cmake/ @esp-idf-codeowners/build-config
|
||||
/tools/cmake/toolchain-*.cmake @esp-idf-codeowners/toolchain
|
||||
/tools/esp_app_trace/ @esp-idf-codeowners/debugging
|
||||
/tools/esp_prov/ @esp-idf-codeowners/app-utilities
|
||||
/tools/gdb_panic_server.py @esp-idf-codeowners/debugging
|
||||
/tools/kconfig*/ @esp-idf-codeowners/build-config
|
||||
/tools/ldgen/ @esp-idf-codeowners/build-config
|
||||
/tools/mass_mfg/ @esp-idf-codeowners/app-utilities
|
||||
/tools/mocks/ @esp-idf-codeowners/system
|
||||
|
||||
/tools/test_apps/ @esp-idf-codeowners/ci
|
||||
/tools/test_apps/README.md @esp-idf-codeowners/docs @esp-idf-codeowners/ci
|
||||
|
||||
## Note: owners here should be the same as the owners for the same example subdir, above
|
||||
/tools/test_apps/build_system/ @esp-idf-codeowners/build-config
|
||||
/tools/test_apps/configs/ @esp-idf-codeowners/system
|
||||
/tools/test_apps/linux_compatible/ @esp-idf-codeowners/system
|
||||
/tools/test_apps/peripherals/ @esp-idf-codeowners/peripherals
|
||||
/tools/test_apps/phy/ @esp-idf-codeowners/bluetooth @esp-idf-codeowners/wifi @esp-idf-codeowners/ieee802154
|
||||
/tools/test_apps/protocols/ @esp-idf-codeowners/network @esp-idf-codeowners/app-utilities
|
||||
/tools/test_apps/security/ @esp-idf-codeowners/security
|
||||
/tools/test_apps/storage/ @esp-idf-codeowners/storage
|
||||
/tools/test_apps/system/ @esp-idf-codeowners/system
|
||||
|
||||
/tools/test_apps/**/*.py @esp-idf-codeowners/ci @esp-idf-codeowners/tools
|
||||
|
||||
/tools/test_build_system/ @esp-idf-codeowners/tools @esp-idf-codeowners/build-config
|
||||
|
||||
/tools/tools.json @esp-idf-codeowners/tools @esp-idf-codeowners/toolchain @esp-idf-codeowners/debugging
|
||||
|
||||
/tools/unit-test-app/ @esp-idf-codeowners/system @esp-idf-codeowners/tools
|
||||
|
||||
# sort-order-reset
|
||||
|
||||
/components/**/test_apps/**/*.py @esp-idf-codeowners/ci @esp-idf-codeowners/tools
|
||||
|
||||
# ignore lists
|
||||
/tools/ci/check_copyright_config.yaml @esp-idf-codeowners/all-maintainers
|
||||
/tools/ci/check_copyright_ignore.txt @esp-idf-codeowners/all-maintainers
|
||||
/tools/ci/mypy_ignore_list.txt @esp-idf-codeowners/tools
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
.build_template:
|
||||
stage: build
|
||||
extends:
|
||||
- .after_script:build:ccache-show-stats:upload-failed-job-logs
|
||||
- .after_script:build:ccache:upload-when-fail
|
||||
image: $ESP_ENV_IMAGE
|
||||
tags:
|
||||
- build
|
||||
@@ -12,11 +12,11 @@
|
||||
IDF_CCACHE_ENABLE: "1"
|
||||
dependencies: []
|
||||
|
||||
.build_cmake_clang_template:
|
||||
.build_cmake_template:
|
||||
extends:
|
||||
- .build_template
|
||||
- .before_script:build
|
||||
- .after_script:build:ccache-show-stats
|
||||
- .after_script:build:ccache
|
||||
dependencies: # set dependencies to null to avoid missing artifacts issue
|
||||
needs:
|
||||
- job: fast_template_app
|
||||
@@ -34,11 +34,29 @@
|
||||
- "**/build*/size.json"
|
||||
expire_in: 1 week
|
||||
when: always
|
||||
script:
|
||||
# CI specific options start from "--parallel-count xxx". could ignore when running locally
|
||||
- run_cmd python tools/ci/ci_build_apps.py $TEST_DIR -v
|
||||
-t $IDF_TARGET
|
||||
--copy-sdkconfig
|
||||
--parallel-count ${CI_NODE_TOTAL:-1}
|
||||
--parallel-index ${CI_NODE_INDEX:-1}
|
||||
--extra-preserve-dirs
|
||||
examples/bluetooth/esp_ble_mesh/ble_mesh_console
|
||||
examples/bluetooth/hci/controller_hci_uart_esp32
|
||||
examples/wifi/iperf
|
||||
--modified-components ${MR_MODIFIED_COMPONENTS}
|
||||
--modified-files ${MR_MODIFIED_FILES}
|
||||
# for detailed documents, please refer to .gitlab/ci/README.md#uploaddownload-artifacts-to-internal-minio-server
|
||||
- python tools/ci/artifacts_handler.py upload
|
||||
|
||||
.build_cmake_clang_template:
|
||||
extends:
|
||||
- .build_cmake_template
|
||||
variables:
|
||||
IDF_TOOLCHAIN: clang
|
||||
TEST_BUILD_OPTS_EXTRA: ""
|
||||
TEST_DIR: tools/test_apps/system/clang_build_test
|
||||
PYTEST_IGNORE_COLLECT_IMPORT_ERROR: "1"
|
||||
script:
|
||||
# CI specific options start from "--parallel-count xxx". could ignore when running locally
|
||||
- run_cmd python tools/ci/ci_build_apps.py $TEST_DIR -v
|
||||
@@ -108,7 +126,7 @@ gcc_static_analyzer:
|
||||
ANALYZING_APP: "examples/get-started/hello_world"
|
||||
script:
|
||||
- echo "CONFIG_COMPILER_STATIC_ANALYZER=y" >> ${ANALYZING_APP}/sdkconfig.defaults
|
||||
- python -m idf_build_apps build -v -p ${ANALYZING_APP} -t all
|
||||
- python -m idf_build_apps build -vv -p ${ANALYZING_APP} -t all
|
||||
|
||||
########################################
|
||||
# Clang Build Apps Without Tests Cases #
|
||||
@@ -228,16 +246,15 @@ pytest_build_system_macos:
|
||||
extends:
|
||||
- .test_build_system_template
|
||||
- .before_script:build:macos
|
||||
- .after_script:build:macos:upload-failed-job-logs:ccache-show-stats
|
||||
- .after_script:build:macos:upload-when-fail
|
||||
- .rules:build:macos
|
||||
tags:
|
||||
- macos_shell
|
||||
parallel: 3
|
||||
variables:
|
||||
PYENV_VERSION: "3.8"
|
||||
# CCACHE_DIR: "/cache/idf_ccache". On macOS, you cannot write to this folder due to insufficient permissions.
|
||||
CCACHE_DIR: "" # ccache will use "$HOME/Library/Caches/ccache".
|
||||
CCACHE_MAXSIZE: "5G" # To preserve the limited Macbook storage. CCACHE automatically prunes old caches to fit the set limit.
|
||||
CI_CCACHE_DISABLE: "1" # ccache: error: Read-only file system
|
||||
|
||||
build_docker:
|
||||
extends:
|
||||
- .before_script:minimal
|
||||
|
||||
@@ -6,9 +6,9 @@ stages:
|
||||
- pre_check
|
||||
- build
|
||||
- assign_test
|
||||
- build_doc
|
||||
- target_test
|
||||
- host_test
|
||||
- build_doc
|
||||
- test_deploy
|
||||
- deploy
|
||||
- post_deploy
|
||||
@@ -40,7 +40,7 @@ variables:
|
||||
GIT_FETCH_EXTRA_FLAGS: "--no-recurse-submodules --prune --prune-tags"
|
||||
# we're using .cache folder for caches
|
||||
GIT_CLEAN_FLAGS: -ffdx -e .cache/
|
||||
LATEST_GIT_TAG: v5.4.2
|
||||
LATEST_GIT_TAG: v5.4-dev
|
||||
|
||||
SUBMODULE_FETCH_TOOL: "tools/ci/ci_fetch_submodule.py"
|
||||
# by default we will fetch all submodules
|
||||
@@ -55,9 +55,9 @@ variables:
|
||||
CHECKOUT_REF_SCRIPT: "$CI_PROJECT_DIR/tools/ci/checkout_project_ref.py"
|
||||
|
||||
# Docker images
|
||||
ESP_ENV_IMAGE: "${CI_DOCKER_REGISTRY}/esp-env-v5.4:2"
|
||||
ESP_IDF_DOC_ENV_IMAGE: "${CI_DOCKER_REGISTRY}/esp-idf-doc-env-v5.4:2-1"
|
||||
TARGET_TEST_ENV_IMAGE: "${CI_DOCKER_REGISTRY}/target-test-env-v5.4:2"
|
||||
ESP_ENV_IMAGE: "${CI_DOCKER_REGISTRY}/esp-env-v5.5:1"
|
||||
ESP_IDF_DOC_ENV_IMAGE: "${CI_DOCKER_REGISTRY}/esp-idf-doc-env-v5.5:1-1"
|
||||
TARGET_TEST_ENV_IMAGE: "${CI_DOCKER_REGISTRY}/target-test-env-v5.5:1"
|
||||
SONARQUBE_SCANNER_IMAGE: "${CI_DOCKER_REGISTRY}/sonarqube-scanner:5"
|
||||
PRE_COMMIT_IMAGE: "${CI_DOCKER_REGISTRY}/esp-idf-pre-commit:1"
|
||||
|
||||
@@ -70,7 +70,7 @@ variables:
|
||||
CI_PYTHON_CONSTRAINT_BRANCH: ""
|
||||
|
||||
# Update the filename for a specific ESP-IDF release. It is used only with CI_PYTHON_CONSTRAINT_BRANCH.
|
||||
CI_PYTHON_CONSTRAINT_FILE: "espidf.constraints.v5.4.txt"
|
||||
CI_PYTHON_CONSTRAINT_FILE: "espidf.constraints.v5.5.txt"
|
||||
|
||||
# Set this variable to repository name of a Python tool you wish to install and test in the context of ESP-IDF CI.
|
||||
# Keep the variable empty when not used.
|
||||
@@ -88,7 +88,7 @@ variables:
|
||||
CI_CLANG_DISTRO_URL: ""
|
||||
|
||||
# Set this variable to specify the file name for the known failure cases.
|
||||
KNOWN_FAILURE_CASES_FILE_NAME: "5.4.txt"
|
||||
KNOWN_FAILURE_CASES_FILE_NAME: "master.txt"
|
||||
|
||||
IDF_CI_BUILD: 1
|
||||
|
||||
@@ -141,48 +141,40 @@ variables:
|
||||
export IDF_MIRROR_PREFIX_MAP=
|
||||
fi
|
||||
|
||||
if [[ "${CI_JOB_STAGE}" != "target_test" ]]; then
|
||||
section_start "running_install_sh" "Running install.sh"
|
||||
if [[ "${CI_JOB_STAGE}" == "build_doc" ]]; then
|
||||
run_cmd bash install.sh --enable-ci --enable-docs
|
||||
elif [[ "${CI_JOB_STAGE}" == "build" ]]; then
|
||||
# install latest python packages
|
||||
# target test jobs
|
||||
if [[ "${CI_JOB_STAGE}" == "target_test" ]]; then
|
||||
run_cmd bash install.sh --enable-ci --enable-pytest --enable-test-specific
|
||||
elif [[ "${CI_JOB_STAGE}" == "build_doc" ]]; then
|
||||
run_cmd bash install.sh --enable-ci --enable-docs
|
||||
elif [[ "${CI_JOB_STAGE}" == "build" ]]; then
|
||||
run_cmd bash install.sh --enable-ci
|
||||
else
|
||||
if ! echo "${CI_JOB_NAME}" | egrep ".*pytest.*"; then
|
||||
run_cmd bash install.sh --enable-ci
|
||||
else
|
||||
if ! echo "${CI_JOB_NAME}" | egrep ".*pytest.*"; then
|
||||
run_cmd bash install.sh --enable-ci
|
||||
else
|
||||
run_cmd bash install.sh --enable-ci --enable-pytest --enable-test-specific
|
||||
fi
|
||||
run_cmd bash install.sh --enable-ci --enable-pytest --enable-test-specific
|
||||
fi
|
||||
section_end "running_install_sh"
|
||||
else
|
||||
section_start "install_python_env" "Install Python environment"
|
||||
run_cmd python tools/idf_tools.py install-python-env --features ci,pytest,test-specific
|
||||
section_end "install_python_env"
|
||||
fi
|
||||
|
||||
if [[ ! -z "$INSTALL_EXTRA_TOOLS" ]]; then
|
||||
section_start "installing_optional_tools" "Install optional tools ${INSTALL_EXTRA_TOOLS}"
|
||||
$IDF_PATH/tools/idf_tools.py --non-interactive install $INSTALL_EXTRA_TOOLS
|
||||
section_end "installing_optional_tools"
|
||||
fi
|
||||
|
||||
# Install esp-clang if necessary (esp-clang is separately installed)
|
||||
# Install esp-clang if necessary
|
||||
if [[ "$IDF_TOOLCHAIN" == "clang" && -z "$CI_CLANG_DISTRO_URL" ]]; then
|
||||
$IDF_PATH/tools/idf_tools.py --non-interactive install esp-clang
|
||||
fi
|
||||
|
||||
if [[ "${CI_JOB_STAGE}" == "target_test" ]]; then
|
||||
section_start "IDF_SKIP_TOOLS_CHECK" "Skip required tools check"
|
||||
export IDF_SKIP_TOOLS_CHECK=1
|
||||
section_end "IDF_SKIP_TOOLS_CHECK"
|
||||
# Install QEMU if necessary
|
||||
if [[ ! -z "$INSTALL_QEMU" ]]; then
|
||||
$IDF_PATH/tools/idf_tools.py --non-interactive install qemu-xtensa qemu-riscv32
|
||||
fi
|
||||
section_start "source_export" "Source export.sh"
|
||||
|
||||
# Since the version 3.21 CMake passes source files and include dirs to ninja using absolute paths.
|
||||
# Needed for pytest junit reports.
|
||||
$IDF_PATH/tools/idf_tools.py --non-interactive install cmake
|
||||
|
||||
source ./export.sh
|
||||
section_end "source_export"
|
||||
|
||||
# Custom clang toolchain
|
||||
if [[ "$IDF_TOOLCHAIN" == "clang" && ! -z "$CI_CLANG_DISTRO_URL" ]]; then
|
||||
if [[ ! -z "$CI_CLANG_DISTRO_URL" ]]; then
|
||||
echo "Using custom clang from ${CI_CLANG_DISTRO_URL}"
|
||||
wget $CI_CLANG_DISTRO_URL
|
||||
ARCH_NAME=$(basename $CI_CLANG_DISTRO_URL)
|
||||
@@ -191,21 +183,13 @@ variables:
|
||||
fi
|
||||
|
||||
# Custom OpenOCD
|
||||
if [[ "$CI_JOB_STAGE" == "target_test" ]]; then
|
||||
machine="$(uname -m)"
|
||||
if [[ "$machine" == "armv7l" ]] ; then
|
||||
OOCD_DISTRO_URL="$OOCD_DISTRO_URL_ARMHF"
|
||||
elif [[ "$machine" == "aarch64" ]] ; then
|
||||
OOCD_DISTRO_URL="$OOCD_DISTRO_URL_ARM64"
|
||||
fi
|
||||
if [[ ! -z "$OOCD_DISTRO_URL" ]]; then
|
||||
echo "Using custom OpenOCD from ${OOCD_DISTRO_URL}"
|
||||
wget $OOCD_DISTRO_URL
|
||||
ARCH_NAME=$(basename $OOCD_DISTRO_URL)
|
||||
tar -x -f $ARCH_NAME
|
||||
export OPENOCD_SCRIPTS=$PWD/openocd-esp32/share/openocd/scripts
|
||||
export PATH=$PWD/openocd-esp32/bin:$PATH
|
||||
fi
|
||||
if [[ ! -z "$OOCD_DISTRO_URL" && "$CI_JOB_STAGE" == "target_test" ]]; then
|
||||
echo "Using custom OpenOCD from ${OOCD_DISTRO_URL}"
|
||||
wget $OOCD_DISTRO_URL
|
||||
ARCH_NAME=$(basename $OOCD_DISTRO_URL)
|
||||
tar -x -f $ARCH_NAME
|
||||
export OPENOCD_SCRIPTS=$PWD/openocd-esp32/share/openocd/scripts
|
||||
export PATH=$PWD/openocd-esp32/bin:$PATH
|
||||
fi
|
||||
|
||||
if [[ -n "$CI_PYTHON_TOOL_REPO" ]]; then
|
||||
@@ -214,8 +198,6 @@ variables:
|
||||
rm -rf ${CI_PYTHON_TOOL_REPO}
|
||||
fi
|
||||
|
||||
info "setup tools and python venv done"
|
||||
|
||||
.show_ccache_statistics: &show_ccache_statistics |
|
||||
# Show ccache statistics if enabled globally
|
||||
test "$CI_CCACHE_STATS" == 1 && test -n "$(which ccache)" && ccache --show-stats -vv || true
|
||||
@@ -240,20 +222,18 @@ variables:
|
||||
- export IDF_TOOLS_PATH="${HOME}/.espressif_runner_${CI_RUNNER_ID}_${CI_CONCURRENT_ID}"
|
||||
# remove idf-env.json, since it may contains enabled "features"
|
||||
- rm -f $IDF_TOOLS_PATH/idf-env.json
|
||||
- $IDF_PATH/tools/idf_tools.py --non-interactive install cmake ninja
|
||||
# This adds tools (compilers) and the version-specific Python environment to PATH
|
||||
- *setup_tools_and_idf_python_venv
|
||||
- fetch_submodules
|
||||
variables:
|
||||
INSTALL_EXTRA_TOOLS: cmake ninja
|
||||
|
||||
.after_script:build:macos:upload-failed-job-logs:ccache-show-stats:
|
||||
.after_script:build:macos:upload-when-fail:
|
||||
after_script:
|
||||
# macos is running shell executor, which means it would use
|
||||
# the system installed /usr/local/bin/python3 by default.
|
||||
# Ensure pyenv and PYENV_VERSION installed
|
||||
- eval "$(pyenv init -)"
|
||||
- *upload_failed_job_log_artifacts
|
||||
- *show_ccache_statistics
|
||||
|
||||
.before_script:build:
|
||||
before_script:
|
||||
@@ -264,11 +244,11 @@ variables:
|
||||
- export EXTRA_CFLAGS=${PEDANTIC_CFLAGS}
|
||||
- export EXTRA_CXXFLAGS=${PEDANTIC_CXXFLAGS}
|
||||
|
||||
.after_script:build:ccache-show-stats:
|
||||
.after_script:build:ccache:
|
||||
after_script:
|
||||
- *show_ccache_statistics
|
||||
|
||||
.after_script:build:ccache-show-stats:upload-failed-job-logs:
|
||||
.after_script:build:ccache:upload-when-fail:
|
||||
after_script:
|
||||
- *show_ccache_statistics
|
||||
- *upload_failed_job_log_artifacts
|
||||
|
||||
@@ -7,12 +7,11 @@
|
||||
#
|
||||
# This file should ONLY be used during bringup. Should be reset to empty after the bringup process
|
||||
extra_default_build_targets:
|
||||
|
||||
|
||||
bypass_check_test_targets:
|
||||
- esp32c5
|
||||
- esp32c61
|
||||
|
||||
bypass_check_test_targets:
|
||||
|
||||
#
|
||||
# These lines would
|
||||
# - enable the README.md check for esp32c6. Don't forget to add the build jobs in .gitlab/ci/build.yml
|
||||
|
||||
@@ -37,16 +37,25 @@
|
||||
.if-dev-push: &if-dev-push
|
||||
if: '$CI_COMMIT_REF_NAME != "master" && $CI_COMMIT_BRANCH !~ /^release\/v/ && $CI_COMMIT_TAG !~ /^v\d+\.\d+(\.\d+)?($|-)/ && $CI_COMMIT_TAG !~ /^qa-test/ && ($CI_PIPELINE_SOURCE == "push" || $CI_PIPELINE_SOURCE == "merge_request_event")'
|
||||
|
||||
.if-schedule: &if-schedule
|
||||
if: '$CI_PIPELINE_SOURCE == "schedule"'
|
||||
|
||||
.doc-rules:build:docs-full:
|
||||
rules:
|
||||
- <<: *if-qa-test-tag
|
||||
when: never
|
||||
- <<: *if-protected
|
||||
- <<: *if-schedule
|
||||
- <<: *if-label-build_docs
|
||||
- <<: *if-label-docs_full
|
||||
- <<: *if-dev-push
|
||||
changes: *patterns-docs-full
|
||||
|
||||
.doc-rules:build:docs-full-prod:
|
||||
rules:
|
||||
- <<: *if-qa-test-tag
|
||||
when: never
|
||||
- <<: *if-protected-no_label
|
||||
|
||||
.doc-rules:build:docs-partial:
|
||||
rules:
|
||||
- <<: *if-qa-test-tag
|
||||
@@ -83,14 +92,13 @@ check_docs_lang_sync:
|
||||
stage: build_doc
|
||||
tags:
|
||||
- build_docs
|
||||
needs:
|
||||
- job: fast_template_app
|
||||
artifacts: false
|
||||
optional: true
|
||||
script:
|
||||
- if [ -n "${BREATHE_ALT_INSTALL_URL}" ]; then pip uninstall -y breathe && pip install -U ${BREATHE_ALT_INSTALL_URL}; fi
|
||||
- cd docs
|
||||
- build-docs -t $DOCTGT -bs $DOC_BUILDERS -l $DOCLANG build
|
||||
artifacts:
|
||||
expire_in: 4 days
|
||||
when: always
|
||||
parallel:
|
||||
matrix:
|
||||
- DOCLANG: ["en", "zh_CN"]
|
||||
@@ -111,12 +119,26 @@ build_docs_html_full:
|
||||
extends:
|
||||
- .build_docs_template
|
||||
- .doc-rules:build:docs-full
|
||||
needs:
|
||||
- job: fast_template_app
|
||||
artifacts: false
|
||||
optional: true
|
||||
artifacts:
|
||||
paths:
|
||||
- docs/_build/*/*/*.txt
|
||||
- docs/_build/*/*/html/*
|
||||
variables:
|
||||
DOC_BUILDERS: "html"
|
||||
|
||||
build_docs_html_full_prod:
|
||||
extends:
|
||||
- .build_docs_template
|
||||
- .doc-rules:build:docs-full-prod
|
||||
dependencies: [] # Stop build_docs jobs from downloading all previous job's artifacts
|
||||
artifacts:
|
||||
when: always
|
||||
paths:
|
||||
- docs/_build/*/*/*.txt
|
||||
- docs/_build/*/*/html/*
|
||||
expire_in: 4 days
|
||||
variables:
|
||||
DOC_BUILDERS: "html"
|
||||
|
||||
@@ -124,12 +146,14 @@ build_docs_html_partial:
|
||||
extends:
|
||||
- .build_docs_template
|
||||
- .doc-rules:build:docs-partial
|
||||
needs:
|
||||
- job: fast_template_app
|
||||
artifacts: false
|
||||
optional: true
|
||||
artifacts:
|
||||
when: always
|
||||
paths:
|
||||
- docs/_build/*/*/*.txt
|
||||
- docs/_build/*/*/html/*
|
||||
expire_in: 4 days
|
||||
variables:
|
||||
DOC_BUILDERS: "html"
|
||||
parallel:
|
||||
@@ -139,6 +163,33 @@ build_docs_html_partial:
|
||||
- DOCLANG: "zh_CN"
|
||||
DOCTGT: "esp32p4"
|
||||
|
||||
build_docs_pdf:
|
||||
extends:
|
||||
- .build_docs_template
|
||||
- .doc-rules:build:docs-full
|
||||
needs:
|
||||
- job: fast_template_app
|
||||
artifacts: false
|
||||
optional: true
|
||||
allow_failure: true # TODO IDFCI-2216
|
||||
artifacts:
|
||||
paths:
|
||||
- docs/_build/*/*/latex/*
|
||||
variables:
|
||||
DOC_BUILDERS: "latex"
|
||||
|
||||
build_docs_pdf_prod:
|
||||
extends:
|
||||
- .build_docs_template
|
||||
- .doc-rules:build:docs-full-prod
|
||||
dependencies: [] # Stop build_docs jobs from downloading all previous job's artifacts
|
||||
allow_failure: true # TODO IDFCI-2216
|
||||
artifacts:
|
||||
paths:
|
||||
- docs/_build/*/*/latex/*
|
||||
variables:
|
||||
DOC_BUILDERS: "latex"
|
||||
|
||||
.deploy_docs_template:
|
||||
image: $ESP_IDF_DOC_ENV_IMAGE
|
||||
variables:
|
||||
@@ -167,6 +218,8 @@ deploy_docs_preview:
|
||||
optional: true
|
||||
- job: build_docs_html_full
|
||||
optional: true
|
||||
- job: build_docs_pdf
|
||||
optional: true
|
||||
variables:
|
||||
TYPE: "preview"
|
||||
# older branches use DOCS_DEPLOY_KEY, DOCS_SERVER, DOCS_SERVER_USER, DOCS_PATH for preview server so we keep these names for 'preview'
|
||||
@@ -181,12 +234,12 @@ deploy_docs_production:
|
||||
# The DOCS_PROD_* variables used by this job are "Protected" so these branches must all be marked "Protected" in Gitlab settings
|
||||
extends:
|
||||
- .deploy_docs_template
|
||||
rules:
|
||||
- <<: *if-protected-no_label
|
||||
- .doc-rules:build:docs-full-prod
|
||||
stage: post_deploy
|
||||
dependencies: # set dependencies to null to avoid missing artifacts issue
|
||||
needs: # ensure runs after push_to_github succeeded
|
||||
- build_docs_html_full
|
||||
- build_docs_html_full_prod
|
||||
- build_docs_pdf_prod
|
||||
- job: push_to_github
|
||||
artifacts: false
|
||||
variables:
|
||||
@@ -201,19 +254,16 @@ deploy_docs_production:
|
||||
check_doc_links:
|
||||
extends:
|
||||
- .build_docs_template
|
||||
rules:
|
||||
- <<: *if-protected-no_label
|
||||
- .doc-rules:build:docs-full-prod
|
||||
stage: post_deploy
|
||||
needs:
|
||||
- job: deploy_docs_production
|
||||
artifacts: false
|
||||
tags: ["build", "amd64", "internet"]
|
||||
artifacts:
|
||||
when: always
|
||||
paths:
|
||||
- docs/_build/*/*/*.txt
|
||||
- docs/_build/*/*/linkcheck/*.txt
|
||||
expire_in: 1 week
|
||||
allow_failure: true
|
||||
script:
|
||||
- cd docs
|
||||
|
||||
@@ -195,7 +195,7 @@ test_tools:
|
||||
junit: ${IDF_PATH}/XUNIT_*.xml
|
||||
variables:
|
||||
LC_ALL: C.UTF-8
|
||||
INSTALL_EXTRA_TOOLS: "qemu-xtensa qemu-riscv32" # for test_idf_qemu.py
|
||||
INSTALL_QEMU: 1 # for test_idf_qemu.py
|
||||
script:
|
||||
- stat=0
|
||||
- cd ${IDF_PATH}/tools/ci/test_autocomplete
|
||||
@@ -233,7 +233,6 @@ test_mqtt_on_host:
|
||||
|
||||
test_transport_on_host:
|
||||
extends: .host_test_template
|
||||
allow_failure: true # IDFCI-2781 [v5.5, v5.4] test_transport_on_host fails on ubuntu 24.04
|
||||
script:
|
||||
- cd ${IDF_PATH}/components/tcp_transport/host_test
|
||||
- idf.py build
|
||||
@@ -283,10 +282,9 @@ test_pytest_qemu:
|
||||
junit: XUNIT_RESULT.xml
|
||||
parallel:
|
||||
matrix:
|
||||
- IDF_TARGET: "esp32"
|
||||
INSTALL_EXTRA_TOOLS: "qemu-xtensa"
|
||||
- IDF_TARGET: "esp32c3"
|
||||
INSTALL_EXTRA_TOOLS: "qemu-riscv32"
|
||||
- IDF_TARGET: [esp32, esp32c3]
|
||||
variables:
|
||||
INSTALL_QEMU: 1
|
||||
script:
|
||||
- run_cmd python tools/ci/ci_build_apps.py . -v
|
||||
--target $IDF_TARGET
|
||||
@@ -350,7 +348,7 @@ test_pytest_macos:
|
||||
variables:
|
||||
PYTEST_IGNORE_COLLECT_IMPORT_ERROR: "1"
|
||||
script:
|
||||
- run_cmd python tools/ci/ci_build_apps.py components examples tools/test_apps -v
|
||||
- run_cmd python tools/ci/ci_build_apps.py components examples tools/test_apps -vv
|
||||
--target linux
|
||||
--pytest-apps
|
||||
-m \"host_test and macos_shell\"
|
||||
@@ -399,17 +397,6 @@ test_nvs_gen_check:
|
||||
- cd ${IDF_PATH}/components/nvs_flash/nvs_partition_tool
|
||||
- pytest --noconftest test_nvs_gen_check.py --junitxml=XUNIT_RESULT.xml
|
||||
|
||||
test_esp_rom:
|
||||
extends: .host_test_template
|
||||
artifacts:
|
||||
paths:
|
||||
- XUNIT_RESULT.xml
|
||||
reports:
|
||||
junit: XUNIT_RESULT.xml
|
||||
script:
|
||||
- cd ${IDF_PATH}/components/esp_rom/
|
||||
- pytest --noconftest test_esp_rom.py --junitxml=XUNIT_RESULT.xml
|
||||
|
||||
make_sure_soc_caps_compatible_in_idf_build_apps:
|
||||
extends:
|
||||
- .host_test_template
|
||||
|
||||
@@ -165,8 +165,6 @@ pipeline_variables:
|
||||
if [ -n "$CI_PYTHON_CONSTRAINT_BRANCH" ]; then
|
||||
echo "BUILD_AND_TEST_ALL_APPS=1" >> pipeline.env
|
||||
fi
|
||||
- echo "OOCD_DISTRO_URL_ARMHF=$OOCD_DISTRO_URL_ARMHF" >> pipeline.env
|
||||
- echo "OOCD_DISTRO_URL_ARM64=$OOCD_DISTRO_URL_ARM64" >> pipeline.env
|
||||
- python tools/ci/ci_process_description.py
|
||||
- cat pipeline.env
|
||||
- python tools/ci/artifacts_handler.py upload --type modified_files_and_components_report
|
||||
@@ -185,24 +183,12 @@ baseline_manifest_sha:
|
||||
tags: [fast_run, shiny]
|
||||
script:
|
||||
- |
|
||||
# merged results pipelines, by default
|
||||
# diff between target-branch-head and merged-result-head
|
||||
if [ -n "$CI_MERGE_REQUEST_TARGET_BRANCH_SHA" ]; then
|
||||
git fetch origin $CI_MERGE_REQUEST_TARGET_BRANCH_SHA --depth=1
|
||||
git checkout FETCH_HEAD
|
||||
idf-build-apps dump-manifest-sha \
|
||||
--manifest-files $(find . -name ".build-test-rules.yml" | xargs) \
|
||||
--output .manifest_sha
|
||||
# merge request pipelines, when the mr got conflicts
|
||||
# diff between diff-base-sha and merge-request-head
|
||||
elif [ -n "$CI_MERGE_REQUEST_DIFF_BASE_SHA" ]; then
|
||||
if [ -n "$CI_MERGE_REQUEST_DIFF_BASE_SHA" ]; then
|
||||
git fetch origin $CI_MERGE_REQUEST_DIFF_BASE_SHA --depth=1
|
||||
git checkout FETCH_HEAD
|
||||
idf-build-apps dump-manifest-sha \
|
||||
--manifest-files $(find . -name ".build-test-rules.yml" | xargs) \
|
||||
--output .manifest_sha
|
||||
# other pipelines, like the protected branches pipelines
|
||||
# not triggered in this job
|
||||
fi
|
||||
artifacts:
|
||||
paths:
|
||||
|
||||
4
.gitmodules
vendored
4
.gitmodules
vendored
@@ -54,10 +54,8 @@
|
||||
sbom-supplier = Person: Dave Gamble
|
||||
sbom-url = https://github.com/DaveGamble/cJSON
|
||||
sbom-description = Ultralightweight JSON parser in ANSI C
|
||||
sbom-hash = 8f2beb57ddad1f94bed899790b00f46df893ccac
|
||||
sbom-hash = acc76239bee01d8e9c858ae2cab296704e52d916
|
||||
sbom-cve-exclude-list = CVE-2024-31755 Resolved in v1.7.18
|
||||
sbom-cve-exclude-list = CVE-2023-26819 Resolved in commit a328d65ad490b64da8c87523cbbfe16050ba5bf6
|
||||
sbom-cve-exclude-list = CVE-2023-53154 Resolved in v1.7.18
|
||||
|
||||
[submodule "components/mbedtls/mbedtls"]
|
||||
path = components/mbedtls/mbedtls
|
||||
|
||||
@@ -23,8 +23,7 @@ repos:
|
||||
.*.pb-c.h|
|
||||
.*.pb-c.c|
|
||||
.*.yuv|
|
||||
.*.rgb|
|
||||
docs/sphinx-known-warnings\.txt
|
||||
.*.rgb
|
||||
)$
|
||||
- id: end-of-file-fixer
|
||||
exclude: *whitespace_excludes
|
||||
@@ -57,7 +56,6 @@ repos:
|
||||
rev: v2.3.0
|
||||
hooks:
|
||||
- id: codespell
|
||||
exclude: ^docs/sphinx-known-warnings\.txt$
|
||||
- repo: local
|
||||
hooks:
|
||||
- id: check-executables
|
||||
@@ -72,6 +70,11 @@ repos:
|
||||
language: python
|
||||
pass_filenames: false
|
||||
always_run: true
|
||||
- id: check-deprecated-kconfigs-options
|
||||
name: Check if any Kconfig Options Deprecated
|
||||
entry: tools/ci/check_deprecated_kconfigs.py
|
||||
language: python
|
||||
files: 'sdkconfig\.ci$|sdkconfig\.rename$|sdkconfig.*$'
|
||||
- id: cmake-lint
|
||||
name: Check CMake Files Format
|
||||
entry: cmakelint --linelength=120 --spaces=4 --filter=-whitespace/indent
|
||||
@@ -151,7 +154,7 @@ repos:
|
||||
require_serial: true
|
||||
additional_dependencies:
|
||||
- PyYAML == 5.3.1
|
||||
- idf-build-apps~=2.5
|
||||
- idf-build-apps~=2.0
|
||||
- id: sort-yaml-files
|
||||
name: sort yaml files
|
||||
entry: tools/ci/sort_yaml.py
|
||||
@@ -238,7 +241,6 @@ repos:
|
||||
name: Lint rST files in docs folder using Sphinx Lint
|
||||
files: ^(docs/en|docs/zh_CN)/.*\.(rst|inc)$
|
||||
- repo: https://github.com/espressif/esp-idf-kconfig.git
|
||||
rev: v2.5.0
|
||||
rev: v2.3.0
|
||||
hooks:
|
||||
- id: check-kconfig-files
|
||||
- id: check-deprecated-kconfig-options
|
||||
|
||||
1
Kconfig
1
Kconfig
@@ -678,4 +678,5 @@ mainmenu "Espressif IoT Development Framework Configuration"
|
||||
- CONFIG_BOOTLOADER_CACHE_32BIT_ADDR_QUAD_FLASH
|
||||
- CONFIG_ESP_WIFI_EAP_TLS1_3
|
||||
- CONFIG_ESP_WIFI_ENABLE_ROAMING_APP
|
||||
- CONFIG_USB_HOST_EXT_PORT_SUPPORT_LS
|
||||
- CONFIG_USB_HOST_EXT_PORT_RESET_ATTEMPTS
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2021-2025 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2021-2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*/
|
||||
@@ -148,18 +148,6 @@ static esp_err_t esp_apptrace_membufs_swap_waitus(esp_apptrace_membufs_proto_dat
|
||||
if (res != ESP_OK) {
|
||||
break;
|
||||
}
|
||||
#if CONFIG_IDF_TARGET_ESP32S3
|
||||
/*
|
||||
* ESP32S3 has a serious data corruption issue with the transferred data to host.
|
||||
* This delay helps reduce the failure rate by temporarily reducing heavy memory writes
|
||||
* from RTOS-level tracing and giving OpenOCD more time to read trace memory before
|
||||
* the current thread continues execution. While this doesn't completely prevent
|
||||
* memory access from other threads/cores/ISRs, it has shown to significantly improve
|
||||
* reliability when combined with CRC checks in OpenOCD. In practice, this reduces the
|
||||
* number of retries needed to read an entire block without corruption.
|
||||
*/
|
||||
esp_rom_delay_us(100);
|
||||
#endif
|
||||
}
|
||||
return res;
|
||||
}
|
||||
@@ -351,7 +339,7 @@ uint8_t *esp_apptrace_membufs_up_buffer_get(esp_apptrace_membufs_proto_data_t *p
|
||||
esp_err_t esp_apptrace_membufs_up_buffer_put(esp_apptrace_membufs_proto_data_t *proto, uint8_t *ptr, esp_apptrace_tmo_t *tmo)
|
||||
{
|
||||
esp_apptrace_membufs_pkt_end(ptr);
|
||||
// TODO: mark block as busy in order not to reuse it for other tracing calls until it is completely written
|
||||
// TODO: mark block as busy in order not to re-use it for other tracing calls until it is completely written
|
||||
// TODO: avoid potential situation when all memory is consumed by low prio tasks which can not complete writing due to
|
||||
// higher prio tasks and the latter can not allocate buffers at all
|
||||
// this is abnormal situation can be detected on host which will receive only uncompleted buffers
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*/
|
||||
@@ -12,7 +12,7 @@
|
||||
// ======================
|
||||
|
||||
// Xtensa has useful feature: TRAX debug module. It allows recording program execution flow at run-time without disturbing CPU.
|
||||
// Execution flow data are written to configurable Trace RAM block. Besides accessing Trace RAM itself TRAX module also allows to read/write
|
||||
// Exectution flow data are written to configurable Trace RAM block. Besides accessing Trace RAM itself TRAX module also allows to read/write
|
||||
// trace memory via its registers by means of JTAG, APB or ERI transactions.
|
||||
// ESP32 has two Xtensa cores with separate TRAX modules on them and provides two special memory regions to be used as trace memory.
|
||||
// Chip allows muxing access to those trace memory blocks in such a way that while one block is accessed by CPUs another one can be accessed by host
|
||||
@@ -47,7 +47,7 @@
|
||||
// 2. TRAX Registers layout
|
||||
// ========================
|
||||
|
||||
// This module uses two TRAX HW registers and one Performance Monitor register to communicate with host SW (OpenOCD).
|
||||
// This module uses two TRAX HW registers to communicate with host SW (OpenOCD).
|
||||
// - Control register uses TRAX_DELAYCNT as storage. Only lower 24 bits of TRAX_DELAYCNT are writable. Control register has the following bitfields:
|
||||
// | 31..XXXXXX..24 | 23 .(host_connect). 23| 22..(block_id)..15 | 14..(block_len)..0 |
|
||||
// 14..0 bits - actual length of user data in trace memory block. Target updates it every time it fills memory block and exposes it to host.
|
||||
@@ -55,15 +55,9 @@
|
||||
// 21..15 bits - trace memory block transfer ID. Block counter. It can overflow. Updated by target, host should not modify it. Actually can be 2 bits;
|
||||
// 22 bit - 'host data present' flag. If set to one there is data from host, otherwise - no host data;
|
||||
// 23 bit - 'host connected' flag. If zero then host is not connected and tracing module works in post-mortem mode, otherwise in streaming mode;
|
||||
// - Status register uses TRAX_TRIGGERPC as storage. If this register is not zero then current CPU is changing TRAX registers and
|
||||
// this register holds address of the instruction which application will execute when it finishes with those registers modifications.
|
||||
// See 'Targets Connection' section for details.
|
||||
// - CRC16 register uses ERI_PERFMON_PM1 as storage. This register is used to store CRC16 checksum of the exposed trace memory block.
|
||||
// The register has the following format:
|
||||
// | 31..16 (CRC indicator) | 15..0 (CRC16 value) |
|
||||
// CRC indicator (0xA55A) is used to distinguish valid CRC values from other data that might be in the register.
|
||||
// CRC16 is calculated over the entire exposed block and is updated every time a block is exposed to the host.
|
||||
// This allows the host to verify data integrity of the received trace data.
|
||||
// - Status register uses TRAX_TRIGGERPC as storage. If this register is not zero then current CPU is changing TRAX registers and
|
||||
// this register holds address of the instruction which application will execute when it finishes with those registers modifications.
|
||||
// See 'Targets Connection' setion for details.
|
||||
|
||||
// 3. Modes of operation
|
||||
// =====================
|
||||
@@ -133,7 +127,7 @@
|
||||
|
||||
// Access to internal module's data is synchronized with custom mutex. Mutex is a wrapper for portMUX_TYPE and uses almost the same sync mechanism as in
|
||||
// vPortCPUAcquireMutex/vPortCPUReleaseMutex. The mechanism uses S32C1I Xtensa instruction to implement exclusive access to module's data from tasks and
|
||||
// ISRs running on both cores. Also custom mutex allows specifying timeout for locking operation. Locking routine checks underlying mutex in cycle until
|
||||
// ISRs running on both cores. Also custom mutex allows specifying timeout for locking operation. Locking routine checks underlaying mutex in cycle until
|
||||
// it gets its ownership or timeout expires. The differences of application tracing module's mutex implementation from vPortCPUAcquireMutex/vPortCPUReleaseMutex are:
|
||||
// - Support for timeouts.
|
||||
// - Local IRQs for CPU which owns the mutex are disabled till the call to unlocking routine. This is made to avoid possible task's prio inversion.
|
||||
@@ -148,9 +142,9 @@
|
||||
|
||||
// Timeout mechanism is based on xthal_get_ccount() routine and supports timeout values in microseconds.
|
||||
// There are two situations when task/ISR can be delayed by tracing API call. Timeout mechanism takes into account both conditions:
|
||||
// - Trace data are locked by another task/ISR. When waiting on trace data lock.
|
||||
// - Trace data are locked by another task/ISR. When wating on trace data lock.
|
||||
// - Current TRAX memory input block is full when working in streaming mode (host is connected). When waiting for host to complete previous block reading.
|
||||
// When waiting for any of above conditions xthal_get_ccount() is called periodically to calculate time elapsed from trace API routine entry. When elapsed
|
||||
// When wating for any of above conditions xthal_get_ccount() is called periodically to calculate time elapsed from trace API routine entry. When elapsed
|
||||
// time exceeds specified timeout value operation is canceled and ESP_ERR_TIMEOUT code is returned.
|
||||
#include "sdkconfig.h"
|
||||
#include "soc/soc.h"
|
||||
@@ -165,15 +159,11 @@
|
||||
#include "esp_log.h"
|
||||
#include "esp_app_trace_membufs_proto.h"
|
||||
#include "esp_app_trace_port.h"
|
||||
#include "esp_rom_crc.h"
|
||||
|
||||
// TRAX is disabled, so we use its registers for our own purposes
|
||||
// | 31..XXXXXX..24 | 23 .(host_connect). 23 | 22 .(host_data). 22| 21..(block_id)..15 | 14..(block_len)..0 |
|
||||
#define ESP_APPTRACE_TRAX_CTRL_REG ERI_TRAX_DELAYCNT
|
||||
#define ESP_APPTRACE_TRAX_STAT_REG ERI_TRAX_TRIGGERPC
|
||||
#define ESP_APPTRACE_TRAX_CRC16_REG ERI_PERFMON_PM1
|
||||
|
||||
#define ESP_APPTRACE_CRC_INDICATOR (0xA55AU << 16)
|
||||
|
||||
#define ESP_APPTRACE_TRAX_BLOCK_LEN_MSK 0x7FFFUL
|
||||
#define ESP_APPTRACE_TRAX_BLOCK_LEN(_l_) ((_l_) & ESP_APPTRACE_TRAX_BLOCK_LEN_MSK)
|
||||
@@ -508,8 +498,7 @@ static esp_err_t esp_apptrace_trax_buffer_swap_start(uint32_t curr_block_id)
|
||||
uint32_t acked_block = ESP_APPTRACE_TRAX_BLOCK_ID_GET(ctrl_reg);
|
||||
uint32_t host_to_read = ESP_APPTRACE_TRAX_BLOCK_LEN_GET(ctrl_reg);
|
||||
if (host_to_read != 0 || acked_block != (curr_block_id & ESP_APPTRACE_TRAX_BLOCK_ID_MSK)) {
|
||||
ESP_APPTRACE_LOGD("HC[%d]: Can not switch %" PRIx32 " %" PRIu32 " %" PRIx32 " %" PRIx32 "/%" PRIx32,
|
||||
esp_cpu_get_core_id(), ctrl_reg, host_to_read, acked_block,
|
||||
ESP_APPTRACE_LOGD("HC[%d]: Can not switch %" PRIx32 " %" PRIu32 " %" PRIx32 " %" PRIx32 "/%" PRIx32, esp_cpu_get_core_id(), ctrl_reg, host_to_read, acked_block,
|
||||
curr_block_id & ESP_APPTRACE_TRAX_BLOCK_ID_MSK, curr_block_id);
|
||||
res = ESP_ERR_NO_MEM;
|
||||
goto _on_err;
|
||||
@@ -525,14 +514,6 @@ static esp_err_t esp_apptrace_trax_buffer_swap_end(uint32_t new_block_id, uint32
|
||||
{
|
||||
uint32_t ctrl_reg = eri_read(ESP_APPTRACE_TRAX_CTRL_REG);
|
||||
uint32_t host_connected = ESP_APPTRACE_TRAX_HOST_CONNECT & ctrl_reg;
|
||||
|
||||
/* calculate CRC16 of the already switched block */
|
||||
if (prev_block_len > 0) {
|
||||
const uint8_t *prev_block_start = s_trax_blocks[!((new_block_id % 2))];
|
||||
uint16_t crc16 = esp_rom_crc16_le(0, prev_block_start, prev_block_len);
|
||||
eri_write(ESP_APPTRACE_TRAX_CRC16_REG, crc16 | ESP_APPTRACE_CRC_INDICATOR);
|
||||
ESP_APPTRACE_LOGD("CRC16:%x %d @%x", crc16, prev_block_len, prev_block_start);
|
||||
}
|
||||
eri_write(ESP_APPTRACE_TRAX_CTRL_REG, ESP_APPTRACE_TRAX_BLOCK_ID(new_block_id) |
|
||||
host_connected | ESP_APPTRACE_TRAX_BLOCK_LEN(prev_block_len));
|
||||
esp_apptrace_trax_buffer_swap_unlock();
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-1-Clause
|
||||
*
|
||||
* SPDX-FileContributor: 2017-2024 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileContributor: 2017-2022 Espressif Systems (Shanghai) CO LTD
|
||||
*/
|
||||
/*********************************************************************
|
||||
* SEGGER Microcontroller GmbH *
|
||||
@@ -58,7 +58,6 @@ File : SEGGER_SYSVIEW_Config_FreeRTOS.c
|
||||
Purpose : Sample setup configuration of SystemView with FreeRTOS.
|
||||
Revision: $Rev: 7745 $
|
||||
*/
|
||||
#include <string.h>
|
||||
#include "sdkconfig.h"
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "SEGGER_SYSVIEW.h"
|
||||
@@ -157,16 +156,15 @@ static esp_apptrace_lock_t s_sys_view_lock = {.mux = portMUX_INITIALIZER_UNLOCKE
|
||||
* Sends SystemView description strings.
|
||||
*/
|
||||
static void _cbSendSystemDesc(void) {
|
||||
char irq_str[32] = "I#";
|
||||
char irq_str[32];
|
||||
SEGGER_SYSVIEW_SendSysDesc("N="SYSVIEW_APP_NAME",D="SYSVIEW_DEVICE_NAME",C="SYSVIEW_CORE_NAME",O=FreeRTOS");
|
||||
strcat(itoa(SYSTICK_INTR_ID, irq_str + 2, 10), "=SysTick");
|
||||
snprintf(irq_str, sizeof(irq_str), "I#%d=SysTick", SYSTICK_INTR_ID);
|
||||
SEGGER_SYSVIEW_SendSysDesc(irq_str);
|
||||
size_t isr_count = sizeof(esp_isr_names)/sizeof(esp_isr_names[0]);
|
||||
for (size_t i = 0; i < isr_count; ++i) {
|
||||
if (esp_isr_names[i] == NULL || (ETS_INTERNAL_INTR_SOURCE_OFF + i) == SYSTICK_INTR_ID)
|
||||
continue;
|
||||
strcat(itoa(ETS_INTERNAL_INTR_SOURCE_OFF + i, irq_str + 2, 10), "=");
|
||||
strncat(irq_str, esp_isr_names[i], sizeof(irq_str) - strlen(irq_str) - 1);
|
||||
snprintf(irq_str, sizeof(irq_str), "I#%d=%s", ETS_INTERNAL_INTR_SOURCE_OFF + i, esp_isr_names[i]);
|
||||
SEGGER_SYSVIEW_SendSysDesc(irq_str);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -108,7 +108,7 @@ static void _cbSendTaskList(void) {
|
||||
* Called from SystemView when asked by the host, returns the
|
||||
* current system time in micro seconds.
|
||||
*/
|
||||
__attribute__((unused)) static U64 _cbGetTime(void) {
|
||||
static U64 _cbGetTime(void) {
|
||||
U64 Time;
|
||||
|
||||
Time = xTaskGetTickCountFromISR();
|
||||
@@ -260,10 +260,7 @@ void SYSVIEW_SendTaskInfo(U32 TaskID, const char* sName, unsigned Prio, U32 Stac
|
||||
*/
|
||||
// Callbacks provided to SYSTEMVIEW by FreeRTOS
|
||||
const SEGGER_SYSVIEW_OS_API SYSVIEW_X_OS_TraceAPI = {
|
||||
/* Callback _cbGetTime locks xKernelLock inside xTaskGetTickCountFromISR, this can cause deadlock on multi-core.
|
||||
To prevent deadlock, always lock xKernelLock before s_sys_view_lock. Omitting the callback here results in sending
|
||||
SYSVIEW_EVTID_SYSTIME_CYCLES events instead of SYSVIEW_EVTID_SYSTIME_US */
|
||||
NULL,
|
||||
_cbGetTime,
|
||||
_cbSendTaskList,
|
||||
};
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ const static char *TAG = "sysview_heap_trace";
|
||||
#endif
|
||||
|
||||
static SEGGER_SYSVIEW_MODULE s_esp_sysview_heap_module = {
|
||||
.sModule = "M=ESP32 SystemView Heap Tracing Module",
|
||||
.sModule = "ESP32 SystemView Heap Tracing Module",
|
||||
.NumEvents = 2,
|
||||
};
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -41,7 +41,6 @@ typedef struct ota_ops_entry_ {
|
||||
bool need_erase;
|
||||
uint32_t wrote_size;
|
||||
uint8_t partial_bytes;
|
||||
bool ota_resumption;
|
||||
WORD_ALIGNED_ATTR uint8_t partial_data[16];
|
||||
LIST_ENTRY(ota_ops_entry_) entries;
|
||||
} ota_ops_entry_t;
|
||||
@@ -112,22 +111,6 @@ static esp_ota_img_states_t set_new_state_otadata(void)
|
||||
#endif
|
||||
}
|
||||
|
||||
static ota_ops_entry_t* esp_ota_init_entry(const esp_partition_t *partition)
|
||||
{
|
||||
ota_ops_entry_t *new_entry = (ota_ops_entry_t *) calloc(1, sizeof(ota_ops_entry_t));
|
||||
if (new_entry == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
LIST_INSERT_HEAD(&s_ota_ops_entries_head, new_entry, entries);
|
||||
|
||||
new_entry->part = partition;
|
||||
new_entry->handle = ++s_ota_ops_last_handle;
|
||||
|
||||
return new_entry;
|
||||
}
|
||||
|
||||
|
||||
esp_err_t esp_ota_begin(const esp_partition_t *partition, size_t image_size, esp_ota_handle_t *out_handle)
|
||||
{
|
||||
ota_ops_entry_t *new_entry;
|
||||
@@ -161,13 +144,6 @@ esp_err_t esp_ota_begin(const esp_partition_t *partition, size_t image_size, esp
|
||||
}
|
||||
#endif
|
||||
|
||||
new_entry = esp_ota_init_entry(partition);
|
||||
if (new_entry == NULL) {
|
||||
return ESP_ERR_NO_MEM;
|
||||
}
|
||||
new_entry->need_erase = (image_size == OTA_WITH_SEQUENTIAL_WRITES);
|
||||
*out_handle = new_entry->handle;
|
||||
|
||||
if (image_size != OTA_WITH_SEQUENTIAL_WRITES) {
|
||||
// If input image size is 0 or OTA_SIZE_UNKNOWN, erase entire partition
|
||||
if ((image_size == 0) || (image_size == OTA_SIZE_UNKNOWN)) {
|
||||
@@ -181,44 +157,16 @@ esp_err_t esp_ota_begin(const esp_partition_t *partition, size_t image_size, esp
|
||||
}
|
||||
}
|
||||
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
esp_err_t esp_ota_resume(const esp_partition_t *partition, const size_t erase_size, const size_t image_offset, esp_ota_handle_t *out_handle)
|
||||
{
|
||||
ota_ops_entry_t *new_entry;
|
||||
|
||||
if ((partition == NULL) || (out_handle == NULL)) {
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
if (image_offset > partition->size) {
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
partition = esp_partition_verify(partition);
|
||||
if (partition == NULL) {
|
||||
return ESP_ERR_NOT_FOUND;
|
||||
}
|
||||
|
||||
// The staging partition cannot be of type Factory, but the final partition can be.
|
||||
if (!is_ota_partition(partition)) {
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
const esp_partition_t* running_partition = esp_ota_get_running_partition();
|
||||
if (partition == running_partition) {
|
||||
return ESP_ERR_OTA_PARTITION_CONFLICT;
|
||||
}
|
||||
|
||||
new_entry = esp_ota_init_entry(partition);
|
||||
new_entry = (ota_ops_entry_t *) calloc(1, sizeof(ota_ops_entry_t));
|
||||
if (new_entry == NULL) {
|
||||
return ESP_ERR_NO_MEM;
|
||||
}
|
||||
|
||||
new_entry->ota_resumption = true;
|
||||
new_entry->wrote_size = image_offset;
|
||||
new_entry->need_erase = (erase_size == OTA_WITH_SEQUENTIAL_WRITES);
|
||||
LIST_INSERT_HEAD(&s_ota_ops_entries_head, new_entry, entries);
|
||||
|
||||
new_entry->part = partition;
|
||||
new_entry->handle = ++s_ota_ops_last_handle;
|
||||
new_entry->need_erase = (image_size == OTA_WITH_SEQUENTIAL_WRITES);
|
||||
*out_handle = new_entry->handle;
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -99,32 +99,6 @@ int esp_ota_get_app_elf_sha256(char* dst, size_t size) __attribute__((deprecated
|
||||
*/
|
||||
esp_err_t esp_ota_begin(const esp_partition_t* partition, size_t image_size, esp_ota_handle_t* out_handle);
|
||||
|
||||
/**
|
||||
* @brief Resume an interrupted OTA update by continuing to write to the specified partition.
|
||||
*
|
||||
* This function is used when an OTA update was previously started and needs to be resumed after an interruption.
|
||||
* It continues the OTA process from the specified offset within the partition.
|
||||
*
|
||||
* Unlike esp_ota_begin(), this function does not erase the partition which receives the OTA update, but rather expects that part of the image
|
||||
* has already been written correctly, and it resumes writing from the given offset.
|
||||
*
|
||||
* @param partition Pointer to info for the partition which is receiving the OTA update. Required.
|
||||
* @param erase_size Specifies how much flash memory to erase before resuming OTA, depending on whether a sequential write or a bulk erase is being used.
|
||||
* @param image_offset Offset from where to resume the OTA process. Should be set to the number of bytes already written.
|
||||
* @param out_handle On success, returns a handle that should be used for subsequent esp_ota_write() and esp_ota_end() calls.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: OTA operation resumed successfully.
|
||||
* - ESP_ERR_INVALID_ARG: partition, out_handle were NULL or image_offset arguments is negative, or partition doesn't point to an OTA app partition.
|
||||
* - ESP_ERR_NO_MEM: Cannot allocate memory for OTA operation.
|
||||
* - ESP_ERR_OTA_PARTITION_CONFLICT: Partition holds the currently running firmware, cannot update in place.
|
||||
* - ESP_ERR_NOT_FOUND: Partition argument not found in partition table.
|
||||
* - ESP_ERR_OTA_SELECT_INFO_INVALID: The OTA data partition contains invalid data.
|
||||
* - ESP_ERR_INVALID_SIZE: Partition doesn't fit in configured flash size.
|
||||
* - ESP_ERR_FLASH_OP_TIMEOUT or ESP_ERR_FLASH_OP_FAIL: Flash write failed.
|
||||
*/
|
||||
esp_err_t esp_ota_resume(const esp_partition_t *partition, const size_t erase_size, const size_t image_offset, esp_ota_handle_t *out_handle);
|
||||
|
||||
/**
|
||||
* @brief Write OTA update data to partition
|
||||
*
|
||||
|
||||
@@ -1134,44 +1134,6 @@ menu "Security features"
|
||||
|
||||
If not set, the app does not care if the flash encryption eFuse bit is set or not.
|
||||
|
||||
config SECURE_FLASH_PSEUDO_ROUND_FUNC
|
||||
bool "Permanently enable XTS-AES's pseudo rounds function"
|
||||
default y
|
||||
depends on SECURE_FLASH_ENCRYPTION_MODE_RELEASE && SOC_FLASH_ENCRYPTION_XTS_AES_SUPPORT_PSEUDO_ROUND
|
||||
help
|
||||
If set (default), the bootloader will permanently enable the XTS-AES peripheral's pseudo rounds function.
|
||||
Note: Enabling this config would burn an efuse.
|
||||
|
||||
choice SECURE_FLASH_PSEUDO_ROUND_FUNC_STRENGTH
|
||||
prompt "Strength of the pseudo rounds function"
|
||||
depends on SECURE_FLASH_PSEUDO_ROUND_FUNC
|
||||
default SECURE_FLASH_PSEUDO_ROUND_FUNC_STRENGTH_LOW
|
||||
help
|
||||
The strength of the pseudo rounds functions can be configured to low, medium and high,
|
||||
each denoting the values that would be stored in the efuses field.
|
||||
By default the value to set to low.
|
||||
You can configure the strength of the pseudo rounds functions according to your use cases,
|
||||
for example, increasing the strength would provide higher security but would slow down the
|
||||
flash encryption/decryption operations.
|
||||
For more info regarding the performance impact, please checkout the pseudo round function section of the
|
||||
security guide documentation.
|
||||
|
||||
config SECURE_FLASH_PSEUDO_ROUND_FUNC_STRENGTH_LOW
|
||||
bool "Low"
|
||||
|
||||
config SECURE_FLASH_PSEUDO_ROUND_FUNC_STRENGTH_MEDIUM
|
||||
bool "Medium"
|
||||
|
||||
config SECURE_FLASH_PSEUDO_ROUND_FUNC_STRENGTH_HIGH
|
||||
bool "High"
|
||||
endchoice
|
||||
|
||||
config SECURE_FLASH_PSEUDO_ROUND_FUNC_STRENGTH
|
||||
int
|
||||
default 1 if SECURE_FLASH_PSEUDO_ROUND_FUNC_STRENGTH_LOW
|
||||
default 2 if SECURE_FLASH_PSEUDO_ROUND_FUNC_STRENGTH_MEDIUM
|
||||
default 3 if SECURE_FLASH_PSEUDO_ROUND_FUNC_STRENGTH_HIGH
|
||||
|
||||
config SECURE_ROM_DL_MODE_ENABLED
|
||||
bool
|
||||
default y if SOC_SUPPORTS_SECURE_DL_MODE && !SECURE_FLASH_ENCRYPTION_MODE_DEVELOPMENT
|
||||
|
||||
@@ -36,10 +36,6 @@ if(CONFIG_APP_BUILD_TYPE_APP_2NDBOOT)
|
||||
)
|
||||
endif()
|
||||
|
||||
if(CONFIG_ESP_ROM_REV0_HAS_NO_ECDSA_INTERFACE)
|
||||
list(APPEND srcs "src/${IDF_TARGET}/bootloader_ecdsa.c")
|
||||
endif()
|
||||
|
||||
if(BOOTLOADER_BUILD OR CONFIG_APP_BUILD_TYPE_RAM)
|
||||
set(include_dirs "include" "bootloader_flash/include"
|
||||
"private_include")
|
||||
@@ -54,6 +50,10 @@ if(BOOTLOADER_BUILD OR CONFIG_APP_BUILD_TYPE_RAM)
|
||||
"src/${IDF_TARGET}/bootloader_${IDF_TARGET}.c"
|
||||
)
|
||||
list(APPEND priv_requires hal)
|
||||
if(CONFIG_ESP_ROM_REV0_HAS_NO_ECDSA_INTERFACE)
|
||||
list(APPEND srcs
|
||||
"src/${IDF_TARGET}/bootloader_ecdsa.c")
|
||||
endif()
|
||||
else()
|
||||
list(APPEND srcs
|
||||
"src/idf/bootloader_sha.c")
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -13,7 +13,6 @@
|
||||
#include <spi_flash_mmap.h> /* including in bootloader for error values */
|
||||
#include "sdkconfig.h"
|
||||
#include "bootloader_flash.h"
|
||||
#include "soc/ext_mem_defs.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@@ -21,11 +20,8 @@ extern "C" {
|
||||
|
||||
#define FLASH_SECTOR_SIZE 0x1000
|
||||
#define FLASH_BLOCK_SIZE 0x10000
|
||||
|
||||
#define MMAP_ALIGNED_MASK (SPI_FLASH_MMU_PAGE_SIZE - 1)
|
||||
#define MMU_FLASH_MASK (~(SPI_FLASH_MMU_PAGE_SIZE - 1))
|
||||
#define MMU_FLASH_MASK_FROM_VAL(PAGE_SZ) (~((PAGE_SZ) - 1))
|
||||
#define MMU_DROM_END_ENTRY_VADDR_FROM_VAL(PAGE_SZ) (SOC_DRAM_FLASH_ADDRESS_HIGH - (PAGE_SZ))
|
||||
|
||||
/**
|
||||
* MMU mapping must always be in the unit of a SPI_FLASH_MMU_PAGE_SIZE
|
||||
@@ -93,7 +89,7 @@ uint32_t bootloader_mmap_get_free_pages(void);
|
||||
* @param length - Length of data to map.
|
||||
*
|
||||
* @return Pointer to mapped data memory (at src_addr), or NULL
|
||||
* if an allocation error occurred.
|
||||
* if an allocation error occured.
|
||||
*/
|
||||
const void *bootloader_mmap(uint32_t src_addr, uint32_t size);
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2010-2025 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2010-2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -28,21 +28,7 @@ extern "C" {
|
||||
*/
|
||||
__attribute__((always_inline))
|
||||
inline static bool esp_dram_match_iram(void) {
|
||||
return ((SOC_DRAM_LOW == SOC_IRAM_LOW) && (SOC_DRAM_HIGH == SOC_IRAM_HIGH));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Check if the RTC IRAM and RTC DRAM are separate or using the same memory space
|
||||
*
|
||||
* @return true if the RTC DRAM and RTC IRAM are sharing the same memory space, false otherwise
|
||||
*/
|
||||
__attribute__((always_inline))
|
||||
inline static bool esp_rtc_dram_match_rtc_iram(void) {
|
||||
#if SOC_RTC_FAST_MEM_SUPPORTED
|
||||
return ((SOC_RTC_IRAM_LOW == SOC_RTC_DRAM_LOW) && (SOC_RTC_IRAM_HIGH == SOC_RTC_DRAM_HIGH));
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
return (SOC_DRAM_LOW == SOC_IRAM_LOW && SOC_DRAM_HIGH == SOC_IRAM_HIGH);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -96,7 +82,6 @@ __attribute__((always_inline))
|
||||
inline static bool esp_ptr_in_diram_iram(const void *p) {
|
||||
// TODO: IDF-5980 esp32c6 D/I RAM share the same address
|
||||
#if SOC_DIRAM_IRAM_LOW == SOC_DIRAM_DRAM_LOW
|
||||
(void)p;
|
||||
return false;
|
||||
#else
|
||||
return ((intptr_t)p >= SOC_DIRAM_IRAM_LOW && (intptr_t)p < SOC_DIRAM_IRAM_HIGH);
|
||||
@@ -115,7 +100,6 @@ inline static bool esp_ptr_in_rtc_iram_fast(const void *p) {
|
||||
#if SOC_RTC_FAST_MEM_SUPPORTED
|
||||
return ((intptr_t)p >= SOC_RTC_IRAM_LOW && (intptr_t)p < SOC_RTC_IRAM_HIGH);
|
||||
#else
|
||||
(void)p;
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
@@ -132,7 +116,6 @@ inline static bool esp_ptr_in_rtc_dram_fast(const void *p) {
|
||||
#if SOC_RTC_FAST_MEM_SUPPORTED
|
||||
return ((intptr_t)p >= SOC_RTC_DRAM_LOW && (intptr_t)p < SOC_RTC_DRAM_HIGH);
|
||||
#else
|
||||
(void)p;
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
@@ -168,21 +151,6 @@ inline static void * esp_ptr_diram_dram_to_iram(const void *p) {
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Convert a RTC DRAM pointer to equivalent word address in RTC IRAM
|
||||
|
||||
- Address must be word aligned
|
||||
- Address must pass esp_ptr_in_rtc_dram_fast() test, or result will be invalid pointer
|
||||
*/
|
||||
__attribute__((always_inline))
|
||||
inline static void * esp_ptr_rtc_dram_to_iram(const void *p) {
|
||||
intptr_t ptr = (intptr_t)p;
|
||||
#if SOC_RTC_FAST_MEM_SUPPORTED && (SOC_RTC_IRAM_LOW != SOC_RTC_DRAM_LOW)
|
||||
return (void *) ( SOC_RTC_IRAM_LOW + (ptr - SOC_RTC_DRAM_LOW) );
|
||||
#else
|
||||
return (void *) ptr;
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Convert a D/IRAM IRAM pointer to equivalent word address in DRAM
|
||||
|
||||
- Address must be word aligned
|
||||
|
||||
@@ -34,7 +34,6 @@ typedef struct {
|
||||
uint32_t image_len; /* Length of image on flash, in bytes */
|
||||
uint8_t image_digest[32]; /* appended SHA-256 digest */
|
||||
uint32_t secure_version; /* secure version for anti-rollback, it is covered by sha256 (set if CONFIG_BOOTLOADER_APP_ANTI_ROLLBACK=y) */
|
||||
uint32_t mmu_page_size; /* Flash MMU page size per binary header */
|
||||
} esp_image_metadata_t;
|
||||
|
||||
typedef enum {
|
||||
|
||||
@@ -28,7 +28,6 @@
|
||||
|
||||
#define ESP_PARTITION_HASH_LEN 32 /* SHA-256 digest length */
|
||||
#define IS_FIELD_SET(rev_full) (((rev_full) != 65535) && ((rev_full) != 0))
|
||||
#define ALIGN_UP(num, align) (((num) + ((align) - 1)) & ~((align) - 1))
|
||||
|
||||
static const char* TAG = "boot_comm";
|
||||
|
||||
@@ -243,10 +242,7 @@ rtc_retain_mem_t* bootloader_common_get_rtc_retain_mem(void)
|
||||
#if ESP_ROM_HAS_LP_ROM
|
||||
#define RTC_RETAIN_MEM_ADDR (SOC_RTC_DRAM_LOW)
|
||||
#else
|
||||
/* Since the structure containing the retain_mem_t is aligned on 8 by the linker, make sure we align this
|
||||
* structure size here too */
|
||||
#define RETAIN_MEM_SIZE ALIGN_UP(sizeof(rtc_retain_mem_t), 8)
|
||||
#define RTC_RETAIN_MEM_ADDR (SOC_RTC_DRAM_HIGH - RETAIN_MEM_SIZE)
|
||||
#define RTC_RETAIN_MEM_ADDR (SOC_RTC_DRAM_HIGH - sizeof(rtc_retain_mem_t))
|
||||
#endif //ESP_ROM_HAS_LP_ROM
|
||||
static rtc_retain_mem_t *const s_bootloader_retain_mem = (rtc_retain_mem_t *)RTC_RETAIN_MEM_ADDR;
|
||||
return s_bootloader_retain_mem;
|
||||
|
||||
@@ -74,12 +74,6 @@ void bootloader_console_init(void)
|
||||
// Enable the peripheral
|
||||
uart_ll_enable_bus_clock(uart_num, true);
|
||||
uart_ll_reset_register(uart_num);
|
||||
// Set clock source
|
||||
#if SOC_UART_SUPPORT_XTAL_CLK
|
||||
uart_ll_set_sclk(UART_LL_GET_HW(uart_num), (soc_module_clk_t)UART_SCLK_XTAL);
|
||||
#else
|
||||
uart_ll_set_sclk(UART_LL_GET_HW(uart_num), (soc_module_clk_t)UART_SCLK_APB);
|
||||
#endif
|
||||
// Reset TX and RX FIFOs
|
||||
uart_ll_txfifo_rst(UART_LL_GET_HW(uart_num));
|
||||
uart_ll_rxfifo_rst(UART_LL_GET_HW(uart_num));
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2023-2025 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -30,8 +30,8 @@ static void adc1_fix_initcode_set(uint32_t initcode_value)
|
||||
{
|
||||
uint32_t msb = initcode_value >> 8;
|
||||
uint32_t lsb = initcode_value & 0xff;
|
||||
REGI2C_WRITE_MASK(I2C_SAR_ADC, ADC_SAR1_INITIAL_CODE_HIGH_ADDR, msb);
|
||||
REGI2C_WRITE_MASK(I2C_SAR_ADC, ADC_SAR1_INITIAL_CODE_LOW_ADDR, lsb);
|
||||
REGI2C_WRITE_MASK(I2C_SAR_ADC, I2C_SAR_ADC_SAR1_INIT_CODE_MSB, msb);
|
||||
REGI2C_WRITE_MASK(I2C_SAR_ADC, I2C_SAR_ADC_SAR1_INIT_CODE_LSB, lsb);
|
||||
}
|
||||
|
||||
//total 4 tables
|
||||
@@ -94,8 +94,7 @@ void bootloader_random_enable(void)
|
||||
|
||||
void bootloader_random_disable(void)
|
||||
{
|
||||
REGI2C_WRITE_MASK(I2C_SAR_ADC, ADC_SAR1_INITIAL_CODE_LOW_ADDR, 0);
|
||||
REGI2C_WRITE_MASK(I2C_SAR_ADC, ADC_SAR1_INITIAL_CODE_HIGH_ADDR, 0);
|
||||
REGI2C_WRITE_MASK(I2C_SAR_ADC, I2C_SAR_ADC_ENT_VDD_GRP1, 0);
|
||||
REGI2C_WRITE_MASK(I2C_SAR_ADC, I2C_SAR_ADC_DTEST_VDD_GRP1, 0);
|
||||
// No-op for now TODO IDF-6497
|
||||
// ADC should be set to defaults here, once ADC API is implemented
|
||||
// OR just keep this empty and let application continue to use RNG initialized by the bootloader
|
||||
}
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
#include "esp_rom_spiflash.h"
|
||||
|
||||
#include "soc/soc.h"
|
||||
#include "soc/soc_caps.h"
|
||||
#include "soc/rtc.h"
|
||||
#include "soc/efuse_periph.h"
|
||||
#include "soc/rtc_periph.h"
|
||||
@@ -67,7 +66,7 @@ static void set_cache_and_start_app(uint32_t drom_addr,
|
||||
uint32_t irom_addr,
|
||||
uint32_t irom_load_addr,
|
||||
uint32_t irom_size,
|
||||
const esp_image_metadata_t *data);
|
||||
uint32_t entry_addr);
|
||||
|
||||
esp_err_t bootloader_common_read_otadata(const esp_partition_pos_t *ota_info, esp_ota_select_entry_t *two_otadata)
|
||||
{
|
||||
@@ -790,7 +789,7 @@ static void unpack_load_app(const esp_image_metadata_t *data)
|
||||
rom_addr[1],
|
||||
rom_load_addr[1],
|
||||
rom_size[1],
|
||||
data);
|
||||
data->image.entry_addr);
|
||||
}
|
||||
|
||||
#else //!SOC_MMU_DI_VADDR_SHARED
|
||||
@@ -835,7 +834,7 @@ static void unpack_load_app(const esp_image_metadata_t *data)
|
||||
irom_addr,
|
||||
irom_load_addr,
|
||||
irom_size,
|
||||
data);
|
||||
data->image.entry_addr);
|
||||
}
|
||||
#endif //#if SOC_MMU_DI_VADDR_SHARED
|
||||
|
||||
@@ -860,11 +859,9 @@ static void set_cache_and_start_app(
|
||||
uint32_t irom_addr,
|
||||
uint32_t irom_load_addr,
|
||||
uint32_t irom_size,
|
||||
const esp_image_metadata_t *data)
|
||||
uint32_t entry_addr)
|
||||
{
|
||||
int rc __attribute__((unused));
|
||||
const uint32_t entry_addr = data->image.entry_addr;
|
||||
const uint32_t mmu_page_size = data->mmu_page_size;
|
||||
|
||||
ESP_EARLY_LOGD(TAG, "configure drom and irom and start");
|
||||
//-----------------------Disable Cache to do the mapping---------
|
||||
@@ -874,18 +871,12 @@ static void set_cache_and_start_app(
|
||||
#else
|
||||
cache_hal_disable(CACHE_LL_LEVEL_EXT_MEM, CACHE_TYPE_ALL);
|
||||
#endif
|
||||
|
||||
#if SOC_MMU_PAGE_SIZE_CONFIGURABLE
|
||||
// re-configure MMU page size
|
||||
mmu_ll_set_page_size(0, mmu_page_size);
|
||||
#endif //SOC_MMU_PAGE_SIZE_CONFIGURABLE
|
||||
|
||||
//reset MMU table first
|
||||
mmu_hal_unmap_all();
|
||||
|
||||
//-----------------------MAP DROM--------------------------
|
||||
uint32_t drom_load_addr_aligned = drom_load_addr & MMU_FLASH_MASK_FROM_VAL(mmu_page_size);
|
||||
uint32_t drom_addr_aligned = drom_addr & MMU_FLASH_MASK_FROM_VAL(mmu_page_size);
|
||||
uint32_t drom_load_addr_aligned = drom_load_addr & MMU_FLASH_MASK;
|
||||
uint32_t drom_addr_aligned = drom_addr & MMU_FLASH_MASK;
|
||||
ESP_EARLY_LOGV(TAG, "rodata starts from paddr=0x%08" PRIx32 ", vaddr=0x%08" PRIx32 ", size=0x%" PRIx32, drom_addr, drom_load_addr, drom_size);
|
||||
//The addr is aligned, so we add the mask off length to the size, to make sure the corresponding buses are enabled.
|
||||
drom_size = (drom_load_addr - drom_load_addr_aligned) + drom_size;
|
||||
@@ -903,13 +894,13 @@ static void set_cache_and_start_app(
|
||||
ESP_EARLY_LOGV(TAG, "after mapping rodata, starting from paddr=0x%08" PRIx32 " and vaddr=0x%08" PRIx32 ", 0x%" PRIx32 " bytes are mapped", drom_addr_aligned, drom_load_addr_aligned, actual_mapped_len);
|
||||
}
|
||||
//we use the MMU_LL_END_DROM_ENTRY_ID mmu entry as a map page for app to find the boot partition
|
||||
mmu_hal_map_region(0, MMU_TARGET_FLASH0, MMU_DROM_END_ENTRY_VADDR_FROM_VAL(mmu_page_size), drom_addr_aligned, mmu_page_size, &actual_mapped_len);
|
||||
mmu_hal_map_region(0, MMU_TARGET_FLASH0, MMU_LL_END_DROM_ENTRY_VADDR, drom_addr_aligned, CONFIG_MMU_PAGE_SIZE, &actual_mapped_len);
|
||||
ESP_EARLY_LOGV(TAG, "mapped one page of the rodata, from paddr=0x%08" PRIx32 " and vaddr=0x%08" PRIx32 ", 0x%" PRIx32 " bytes are mapped", drom_addr_aligned, MMU_LL_END_DROM_ENTRY_VADDR, actual_mapped_len);
|
||||
#endif
|
||||
|
||||
//-----------------------MAP IROM--------------------------
|
||||
uint32_t irom_load_addr_aligned = irom_load_addr & MMU_FLASH_MASK_FROM_VAL(mmu_page_size);
|
||||
uint32_t irom_addr_aligned = irom_addr & MMU_FLASH_MASK_FROM_VAL(mmu_page_size);
|
||||
uint32_t irom_load_addr_aligned = irom_load_addr & MMU_FLASH_MASK;
|
||||
uint32_t irom_addr_aligned = irom_addr & MMU_FLASH_MASK;
|
||||
ESP_EARLY_LOGV(TAG, "text starts from paddr=0x%08" PRIx32 ", vaddr=0x%08" PRIx32 ", size=0x%" PRIx32, irom_addr, irom_load_addr, irom_size);
|
||||
//The addr is aligned, so we add the mask off length to the size, to make sure the corresponding buses are enabled.
|
||||
irom_size = (irom_load_addr - irom_load_addr_aligned) + irom_size;
|
||||
|
||||
@@ -92,8 +92,6 @@ static inline void bootloader_hardware_init(void)
|
||||
|
||||
regi2c_ctrl_ll_master_enable_clock(true);
|
||||
regi2c_ctrl_ll_master_configure_clock();
|
||||
REGI2C_WRITE_MASK(I2C_BIAS, I2C_BIAS_DREG_0P8, 8); // fix low temp issue, need to increase this internal voltage
|
||||
|
||||
}
|
||||
|
||||
static inline void bootloader_ana_reset_config(void)
|
||||
|
||||
@@ -1,18 +1,15 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2022-2025 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <strings.h>
|
||||
#include "esp_flash_encrypt.h"
|
||||
#include "esp_secure_boot.h"
|
||||
#include "esp_efuse.h"
|
||||
#include "esp_efuse_table.h"
|
||||
#include "esp_log.h"
|
||||
#include "hal/spi_flash_encrypted_ll.h"
|
||||
#include "soc/soc_caps.h"
|
||||
#include "sdkconfig.h"
|
||||
|
||||
static __attribute__((unused)) const char *TAG = "flash_encrypt";
|
||||
@@ -36,14 +33,6 @@ esp_err_t esp_flash_encryption_enable_secure_features(void)
|
||||
|
||||
esp_efuse_write_field_bit(ESP_EFUSE_DIS_DIRECT_BOOT);
|
||||
|
||||
#if defined(CONFIG_SECURE_FLASH_ENCRYPTION_MODE_RELEASE) && defined(SOC_FLASH_ENCRYPTION_XTS_AES_SUPPORT_PSEUDO_ROUND)
|
||||
if (spi_flash_encrypt_ll_is_pseudo_rounds_function_supported()) {
|
||||
ESP_LOGI(TAG, "Enable XTS-AES pseudo rounds function...");
|
||||
uint8_t xts_pseudo_level = CONFIG_SECURE_FLASH_PSEUDO_ROUND_FUNC_STRENGTH;
|
||||
esp_efuse_write_field_blob(ESP_EFUSE_XTS_DPA_PSEUDO_LEVEL, &xts_pseudo_level, ESP_EFUSE_XTS_DPA_PSEUDO_LEVEL[0]->bit_count);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_SECURE_BOOT_V2_ENABLED) && !defined(CONFIG_SECURE_BOOT_V2_ALLOW_EFUSE_RD_DIS)
|
||||
// This bit is set when enabling Secure Boot V2, but we can't enable it until this later point in the first boot
|
||||
// otherwise the Flash Encryption key cannot be read protected
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -22,7 +22,6 @@
|
||||
#include "bootloader_memory_utils.h"
|
||||
#include "soc/soc_caps.h"
|
||||
#include "hal/cache_ll.h"
|
||||
#include "spi_flash_mmap.h"
|
||||
|
||||
#define ALIGN_UP(num, align) (((num) + ((align) - 1)) & ~((align) - 1))
|
||||
|
||||
@@ -48,12 +47,7 @@ static const char *TAG = "esp_image";
|
||||
|
||||
#define HASH_LEN ESP_IMAGE_HASH_LEN
|
||||
|
||||
#if SOC_SPI_MEM_SUPPORT_CACHE_32BIT_ADDR_MAP
|
||||
#define ESP_IMAGE_MAX_FLASH_ADDR_SIZE UINT32_MAX
|
||||
#else
|
||||
#define ESP_IMAGE_MAX_FLASH_ADDR_SIZE 0x1000000
|
||||
#endif
|
||||
|
||||
#define SIXTEEN_MB 0x1000000
|
||||
#define ESP_ROM_CHECKSUM_INITIAL 0xEF
|
||||
|
||||
/* Headroom to ensure between stack SP (at time of checking) and data loaded from flash */
|
||||
@@ -83,7 +77,7 @@ static esp_err_t process_segment_data(int segment, intptr_t load_addr, uint32_t
|
||||
static esp_err_t verify_image_header(uint32_t src_addr, const esp_image_header_t *image, bool silent);
|
||||
|
||||
/* Verify a segment header */
|
||||
static esp_err_t verify_segment_header(int index, const esp_image_segment_header_t *segment, uint32_t segment_data_offs, esp_image_metadata_t *metadata, bool silent);
|
||||
static esp_err_t verify_segment_header(int index, const esp_image_segment_header_t *segment, uint32_t segment_data_offs, bool silent);
|
||||
|
||||
/* Log-and-fail macro for use in esp_image_load */
|
||||
#define FAIL_LOAD(...) do { \
|
||||
@@ -144,7 +138,7 @@ static esp_err_t image_load(esp_image_load_mode_t mode, const esp_partition_pos_
|
||||
verify_sha = (part->offset != ESP_BOOTLOADER_OFFSET) && do_verify;
|
||||
#endif
|
||||
|
||||
if (part->size > ESP_IMAGE_MAX_FLASH_ADDR_SIZE) {
|
||||
if (part->size > SIXTEEN_MB) {
|
||||
err = ESP_ERR_INVALID_ARG;
|
||||
FAIL_LOAD("partition size 0x%"PRIx32" invalid, larger than 16MB", part->size);
|
||||
}
|
||||
@@ -303,7 +297,7 @@ esp_err_t esp_image_verify(esp_image_load_mode_t mode, const esp_partition_pos_t
|
||||
esp_err_t esp_image_get_metadata(const esp_partition_pos_t *part, esp_image_metadata_t *metadata)
|
||||
{
|
||||
esp_err_t err;
|
||||
if (metadata == NULL || part == NULL || part->size > ESP_IMAGE_MAX_FLASH_ADDR_SIZE) {
|
||||
if (metadata == NULL || part == NULL || part->size > SIXTEEN_MB) {
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
@@ -565,7 +559,7 @@ static esp_err_t process_segment(int index, uint32_t flash_addr, esp_image_segme
|
||||
|
||||
ESP_LOGV(TAG, "segment data length 0x%"PRIx32" data starts 0x%"PRIx32, data_len, data_addr);
|
||||
|
||||
CHECK_ERR(verify_segment_header(index, header, data_addr, metadata, silent));
|
||||
CHECK_ERR(verify_segment_header(index, header, data_addr, silent));
|
||||
|
||||
if (data_len % 4 != 0) {
|
||||
FAIL_LOAD("unaligned segment length 0x%"PRIx32, data_len);
|
||||
@@ -754,10 +748,10 @@ static esp_err_t process_segment_data(int segment, intptr_t load_addr, uint32_t
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
static esp_err_t verify_segment_header(int index, const esp_image_segment_header_t *segment, uint32_t segment_data_offs, esp_image_metadata_t *metadata, bool silent)
|
||||
static esp_err_t verify_segment_header(int index, const esp_image_segment_header_t *segment, uint32_t segment_data_offs, bool silent)
|
||||
{
|
||||
if ((segment->data_len & 3) != 0
|
||||
|| segment->data_len >= ESP_IMAGE_MAX_FLASH_ADDR_SIZE) {
|
||||
|| segment->data_len >= SIXTEEN_MB) {
|
||||
if (!silent) {
|
||||
ESP_LOGE(TAG, "invalid segment length 0x%"PRIx32, segment->data_len);
|
||||
}
|
||||
@@ -767,46 +761,13 @@ static esp_err_t verify_segment_header(int index, const esp_image_segment_header
|
||||
uint32_t load_addr = segment->load_addr;
|
||||
bool map_segment = should_map(load_addr);
|
||||
|
||||
#if SOC_MMU_PAGE_SIZE_CONFIGURABLE
|
||||
esp_err_t err = ESP_FAIL;
|
||||
|
||||
/* ESP APP descriptor is present in the DROM segment #0 */
|
||||
if (index == 0 && metadata->start_addr != ESP_BOOTLOADER_OFFSET) {
|
||||
uint32_t mmu_page_size = 0, magic_word = 0;
|
||||
const uint32_t mmu_page_size_offset = segment_data_offs + offsetof(esp_app_desc_t, mmu_page_size);
|
||||
CHECK_ERR(bootloader_flash_read(segment_data_offs, &magic_word, sizeof(uint32_t), true));
|
||||
CHECK_ERR(bootloader_flash_read(mmu_page_size_offset, &mmu_page_size, sizeof(uint32_t), true));
|
||||
// Extract only the lowest byte from mmu_page_size (as per image format)
|
||||
mmu_page_size &= 0xFF;
|
||||
|
||||
if (magic_word != ESP_APP_DESC_MAGIC_WORD) {
|
||||
ESP_LOGE(TAG, "Failed to fetch app description header!");
|
||||
return ESP_FAIL;
|
||||
}
|
||||
|
||||
// Convert from log base 2 number to actual size while handling legacy image case (value 0)
|
||||
metadata->mmu_page_size = (mmu_page_size > 0) ? (1UL << mmu_page_size) : SPI_FLASH_MMU_PAGE_SIZE;
|
||||
if (metadata->mmu_page_size != SPI_FLASH_MMU_PAGE_SIZE) {
|
||||
ESP_LOGI(TAG, "MMU page size mismatch, configured: 0x%x, found: 0x%"PRIx32, SPI_FLASH_MMU_PAGE_SIZE, metadata->mmu_page_size);
|
||||
}
|
||||
} else if (index == 0 && metadata->start_addr == ESP_BOOTLOADER_OFFSET) {
|
||||
// Bootloader always uses the default MMU page size
|
||||
metadata->mmu_page_size = SPI_FLASH_MMU_PAGE_SIZE;
|
||||
}
|
||||
#else // SOC_MMU_PAGE_SIZE_CONFIGURABLE
|
||||
metadata->mmu_page_size = SPI_FLASH_MMU_PAGE_SIZE;
|
||||
#endif // !SOC_MMU_PAGE_SIZE_CONFIGURABLE
|
||||
|
||||
const int mmu_page_size = metadata->mmu_page_size;
|
||||
ESP_LOGV(TAG, "MMU page size 0x%x", mmu_page_size);
|
||||
|
||||
/* Check that flash cache mapped segment aligns correctly from flash to its mapped address,
|
||||
relative to the MMU page mapping size.
|
||||
relative to the 64KB page mapping size.
|
||||
*/
|
||||
ESP_LOGV(TAG, "segment %d map_segment %d segment_data_offs 0x%"PRIx32" load_addr 0x%"PRIx32,
|
||||
index, map_segment, segment_data_offs, load_addr);
|
||||
if (map_segment
|
||||
&& ((segment_data_offs % mmu_page_size) != (load_addr % mmu_page_size))) {
|
||||
&& ((segment_data_offs % SPI_FLASH_MMU_PAGE_SIZE) != (load_addr % SPI_FLASH_MMU_PAGE_SIZE))) {
|
||||
if (!silent) {
|
||||
ESP_LOGE(TAG, "Segment %d load address 0x%08"PRIx32", doesn't match data 0x%08"PRIx32,
|
||||
index, load_addr, segment_data_offs);
|
||||
@@ -815,10 +776,6 @@ static esp_err_t verify_segment_header(int index, const esp_image_segment_header
|
||||
}
|
||||
|
||||
return ESP_OK;
|
||||
#if SOC_MMU_PAGE_SIZE_CONFIGURABLE
|
||||
err:
|
||||
return err;
|
||||
#endif
|
||||
}
|
||||
|
||||
static bool should_map(uint32_t load_addr)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -12,9 +12,6 @@
|
||||
#include "esp_flash_encrypt.h"
|
||||
#include "esp_secure_boot.h"
|
||||
#include "hal/efuse_hal.h"
|
||||
#include "hal/spi_flash_encrypted_ll.h"
|
||||
#include "hal/spi_flash_encrypt_hal.h"
|
||||
#include "soc/soc_caps.h"
|
||||
|
||||
#if CONFIG_IDF_TARGET_ESP32
|
||||
#define CRYPT_CNT ESP_EFUSE_FLASH_CRYPT_CNT
|
||||
@@ -210,13 +207,6 @@ void esp_flash_encryption_set_release_mode(void)
|
||||
#endif // CONFIG_SOC_FLASH_ENCRYPTION_XTS_AES_128_DERIVED
|
||||
#endif // !CONFIG_IDF_TARGET_ESP32
|
||||
|
||||
#ifdef SOC_FLASH_ENCRYPTION_XTS_AES_SUPPORT_PSEUDO_ROUND
|
||||
if (spi_flash_encrypt_ll_is_pseudo_rounds_function_supported()) {
|
||||
uint8_t xts_pseudo_level = ESP_XTS_AES_PSEUDO_ROUNDS_LOW;
|
||||
esp_efuse_write_field_blob(ESP_EFUSE_XTS_DPA_PSEUDO_LEVEL, &xts_pseudo_level, ESP_EFUSE_XTS_DPA_PSEUDO_LEVEL[0]->bit_count);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_IDF_TARGET_ESP32
|
||||
esp_efuse_write_field_bit(ESP_EFUSE_WR_DIS_DIS_CACHE);
|
||||
#else
|
||||
@@ -478,17 +468,6 @@ bool esp_flash_encryption_cfg_verify_release_mode(void)
|
||||
}
|
||||
result &= secure;
|
||||
|
||||
#if SOC_FLASH_ENCRYPTION_XTS_AES_SUPPORT_PSEUDO_ROUND
|
||||
if (spi_flash_encrypt_ll_is_pseudo_rounds_function_supported()) {
|
||||
uint8_t xts_pseudo_level = 0;
|
||||
esp_efuse_read_field_blob(ESP_EFUSE_XTS_DPA_PSEUDO_LEVEL, &xts_pseudo_level, ESP_EFUSE_XTS_DPA_PSEUDO_LEVEL[0]->bit_count);
|
||||
if (!xts_pseudo_level) {
|
||||
result &= false;
|
||||
ESP_LOGW(TAG, "Not enabled XTS-AES pseudo rounds function (set XTS_DPA_PSEUDO_LEVEL->1 or more)");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
return result;
|
||||
}
|
||||
#endif // not CONFIG_IDF_TARGET_ESP32
|
||||
|
||||
@@ -154,12 +154,13 @@ esp_err_t esp_secure_boot_verify_sbv2_signature_block(const ets_secure_boot_sign
|
||||
ets_secure_boot_key_digests_t trusted_key_digests = {0};
|
||||
bool valid_sig_blk = false;
|
||||
for (unsigned i = 0; i < SECURE_BOOT_NUM_BLOCKS; i++) {
|
||||
trusted_key_digests.key_digests[i] = &trusted.key_digests[i];
|
||||
if (sig_block->block[i].version != ESP_SECURE_BOOT_SCHEME) {
|
||||
ESP_LOGD(TAG, "%s signing scheme selected but signature block %d generated for %s scheme", esp_secure_boot_get_scheme_name(ESP_SECURE_BOOT_SCHEME), i, esp_secure_boot_get_scheme_name(sig_block->block[i].version));
|
||||
continue;
|
||||
} else {
|
||||
valid_sig_blk = true;
|
||||
}
|
||||
trusted_key_digests.key_digests[i] = &trusted.key_digests[i];
|
||||
}
|
||||
if (valid_sig_blk != true) {
|
||||
ESP_LOGE(TAG, "No signature block generated for valid scheme");
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
| Supported Targets | ESP32 | ESP32-C2 | ESP32-C3 | ESP32-C6 | ESP32-H2 | ESP32-P4 | ESP32-S2 | ESP32-S3 |
|
||||
| ----------------- | ----- | -------- | -------- | -------- | -------- | -------- | -------- | -------- |
|
||||
| Supported Targets | ESP32 | ESP32-C2 | ESP32-C3 | ESP32-C5 | ESP32-C6 | ESP32-C61 | ESP32-H2 | ESP32-P4 | ESP32-S2 | ESP32-S3 |
|
||||
| ----------------- | ----- | -------- | -------- | -------- | -------- | --------- | -------- | -------- | -------- | -------- |
|
||||
|
||||
@@ -24,7 +24,6 @@ set(common_include_dirs
|
||||
common/btc/profile/esp/blufi/include
|
||||
common/btc/profile/esp/include
|
||||
common/hci_log/include
|
||||
common/ble_log/include
|
||||
)
|
||||
|
||||
set(ble_mesh_include_dirs
|
||||
@@ -86,13 +85,8 @@ if(CONFIG_BT_ENABLED)
|
||||
elseif(CONFIG_IDF_TARGET_ESP32S3)
|
||||
list(APPEND ldscripts "linker_rw_bt_controller.lf")
|
||||
elseif(CONFIG_IDF_TARGET_ESP32C2)
|
||||
list(APPEND srcs "controller/esp32c2/ble.c")
|
||||
if(CONFIG_BT_CTRL_RUN_IN_FLASH_ONLY)
|
||||
list(APPEND srcs "controller/esp32c2/dummy.c")
|
||||
endif()
|
||||
set(ldscripts "linker_esp32c2.lf")
|
||||
else()
|
||||
list(APPEND srcs "controller/${target_name}/ble.c")
|
||||
list(APPEND ldscripts "linker_esp_ble_controller.lf")
|
||||
endif()
|
||||
|
||||
@@ -133,7 +127,6 @@ if(CONFIG_BT_ENABLED)
|
||||
"common/osi/osi.c"
|
||||
"common/osi/semaphore.c"
|
||||
"porting/mem/bt_osi_mem.c"
|
||||
"common/ble_log/ble_log_spi_out.c"
|
||||
)
|
||||
|
||||
# Host Bluedroid
|
||||
@@ -451,19 +444,6 @@ if(CONFIG_BT_ENABLED)
|
||||
list(APPEND srcs "esp_ble_mesh/core/bluedroid_host/adapter.c")
|
||||
endif()
|
||||
|
||||
if(CONFIG_BT_BLE_FEAT_ISO_EN)
|
||||
list(APPEND srcs "host/bluedroid/stack/btm/btm_ble_iso.c"
|
||||
"host/bluedroid/btc/profile/std/iso/btc_iso_ble.c"
|
||||
"host/bluedroid/api/esp_ble_iso_api.c"
|
||||
"host/bluedroid/hci/ble_hci_iso.c")
|
||||
endif()
|
||||
|
||||
if(CONFIG_BT_BLE_FEAT_CTE_EN)
|
||||
list(APPEND srcs "host/bluedroid/stack/btm/btm_ble_cte.c"
|
||||
"host/bluedroid/btc/profile/std/cte/btc_ble_cte.c"
|
||||
"host/bluedroid/api/esp_ble_cte_api.c")
|
||||
endif()
|
||||
|
||||
endif()
|
||||
|
||||
if(CONFIG_BLE_MESH)
|
||||
@@ -641,25 +621,23 @@ if(CONFIG_BT_ENABLED)
|
||||
|
||||
if(NOT (CONFIG_BT_LE_CRYPTO_STACK_MBEDTLS OR CONFIG_BT_NIMBLE_CRYPTO_STACK_MBEDTLS))
|
||||
list(APPEND include_dirs
|
||||
common/tinycrypt/include
|
||||
common/tinycrypt/port
|
||||
porting/ext/tinycrypt/include
|
||||
)
|
||||
list(APPEND srcs "common/tinycrypt/src/utils.c"
|
||||
"common/tinycrypt/src/sha256.c"
|
||||
"common/tinycrypt/src/ecc.c"
|
||||
"common/tinycrypt/src/ctr_prng.c"
|
||||
"common/tinycrypt/src/ctr_mode.c"
|
||||
"common/tinycrypt/src/aes_decrypt.c"
|
||||
"common/tinycrypt/src/aes_encrypt.c"
|
||||
"common/tinycrypt/src/ccm_mode.c"
|
||||
"common/tinycrypt/src/ecc_dsa.c"
|
||||
"common/tinycrypt/src/cmac_mode.c"
|
||||
"common/tinycrypt/src/ecc_dh.c"
|
||||
"common/tinycrypt/src/hmac_prng.c"
|
||||
"common/tinycrypt/src/ecc_platform_specific.c"
|
||||
"common/tinycrypt/src/hmac.c"
|
||||
"common/tinycrypt/src/cbc_mode.c"
|
||||
"common/tinycrypt/port/esp_tinycrypt_port.c")
|
||||
list(APPEND srcs "porting/ext/tinycrypt/src/utils.c"
|
||||
"porting/ext/tinycrypt/src/sha256.c"
|
||||
"porting/ext/tinycrypt/src/ecc.c"
|
||||
"porting/ext/tinycrypt/src/ctr_prng.c"
|
||||
"porting/ext/tinycrypt/src/ctr_mode.c"
|
||||
"porting/ext/tinycrypt/src/aes_decrypt.c"
|
||||
"porting/ext/tinycrypt/src/aes_encrypt.c"
|
||||
"porting/ext/tinycrypt/src/ccm_mode.c"
|
||||
"porting/ext/tinycrypt/src/ecc_dsa.c"
|
||||
"porting/ext/tinycrypt/src/cmac_mode.c"
|
||||
"porting/ext/tinycrypt/src/ecc_dh.c"
|
||||
"porting/ext/tinycrypt/src/hmac_prng.c"
|
||||
"porting/ext/tinycrypt/src/ecc_platform_specific.c"
|
||||
"porting/ext/tinycrypt/src/hmac.c"
|
||||
"porting/ext/tinycrypt/src/cbc_mode.c")
|
||||
endif()
|
||||
|
||||
if(CONFIG_BT_NIMBLE_ENABLED)
|
||||
@@ -756,7 +734,6 @@ if(CONFIG_BT_ENABLED)
|
||||
"host/nimble/nimble/nimble/host/store/config/src/ble_store_nvs.c"
|
||||
"host/nimble/nimble/nimble/host/src/ble_gattc_cache.c"
|
||||
"host/nimble/nimble/nimble/host/src/ble_gattc_cache_conn.c"
|
||||
"host/nimble/nimble/nimble/host/src/ble_eatt.c"
|
||||
)
|
||||
|
||||
if(CONFIG_BT_CONTROLLER_DISABLED AND CONFIG_BT_NIMBLE_TRANSPORT_UART)
|
||||
@@ -871,27 +848,11 @@ if(CONFIG_BT_ENABLED)
|
||||
|
||||
endif()
|
||||
|
||||
|
||||
set(bt_priv_requires
|
||||
nvs_flash
|
||||
soc
|
||||
esp_pm
|
||||
esp_phy
|
||||
esp_coex
|
||||
mbedtls
|
||||
esp_driver_uart
|
||||
vfs
|
||||
esp_ringbuf
|
||||
esp_driver_spi
|
||||
esp_driver_gpio
|
||||
esp_gdbstub
|
||||
)
|
||||
|
||||
idf_component_register(SRCS "${srcs}"
|
||||
INCLUDE_DIRS "${include_dirs}"
|
||||
PRIV_INCLUDE_DIRS "${priv_include_dirs}"
|
||||
REQUIRES esp_timer esp_wifi
|
||||
PRIV_REQUIRES "${bt_priv_requires}"
|
||||
PRIV_REQUIRES nvs_flash soc esp_pm esp_phy esp_coex mbedtls esp_driver_uart vfs esp_ringbuf
|
||||
LDFRAGMENTS "${ldscripts}")
|
||||
|
||||
if(CONFIG_BT_ENABLED)
|
||||
@@ -904,41 +865,21 @@ if(CONFIG_BT_ENABLED)
|
||||
elseif(CONFIG_IDF_TARGET_ESP32C3)
|
||||
target_link_directories(${COMPONENT_LIB} INTERFACE
|
||||
"${CMAKE_CURRENT_LIST_DIR}/controller/lib_esp32c3_family/esp32c3")
|
||||
if(CONFIG_BT_CTRL_RUN_IN_FLASH_ONLY)
|
||||
target_link_libraries(${COMPONENT_LIB} PUBLIC btdm_app_flash)
|
||||
else()
|
||||
target_link_libraries(${COMPONENT_LIB} PUBLIC btdm_app)
|
||||
endif()
|
||||
target_link_libraries(${COMPONENT_LIB} PUBLIC btdm_app)
|
||||
elseif(CONFIG_IDF_TARGET_ESP32S3)
|
||||
target_link_directories(${COMPONENT_LIB} INTERFACE
|
||||
"${CMAKE_CURRENT_LIST_DIR}/controller/lib_esp32c3_family/esp32s3")
|
||||
if(CONFIG_BT_CTRL_RUN_IN_FLASH_ONLY)
|
||||
target_link_libraries(${COMPONENT_LIB} PUBLIC btdm_app_flash)
|
||||
else()
|
||||
target_link_libraries(${COMPONENT_LIB} PUBLIC btdm_app)
|
||||
endif()
|
||||
target_link_libraries(${COMPONENT_LIB} PUBLIC btdm_app)
|
||||
elseif(CONFIG_BT_CONTROLLER_ENABLED)
|
||||
if(CONFIG_BT_LE_CONTROLLER_LOG_WRAP_PANIC_HANDLER_ENABLE)
|
||||
target_link_libraries(${COMPONENT_LIB} INTERFACE "-Wl,--wrap=esp_panic_handler")
|
||||
endif()
|
||||
if(CONFIG_IDF_TARGET_ESP32C6)
|
||||
add_prebuilt_library(libble_app
|
||||
"${CMAKE_CURRENT_LIST_DIR}/controller/lib_esp32c6/esp32c6-bt-lib/esp32c6/libble_app.a"
|
||||
REQUIRES esp_phy)
|
||||
"${CMAKE_CURRENT_LIST_DIR}/controller/lib_esp32c6/esp32c6-bt-lib/esp32c6/libble_app.a")
|
||||
elseif(CONFIG_IDF_TARGET_ESP32C61)
|
||||
add_prebuilt_library(libble_app
|
||||
"${CMAKE_CURRENT_LIST_DIR}/controller/lib_esp32c6/esp32c6-bt-lib/esp32c61/libble_app.a"
|
||||
REQUIRES esp_phy)
|
||||
"${CMAKE_CURRENT_LIST_DIR}/controller/lib_esp32c6/esp32c6-bt-lib/esp32c61/libble_app.a")
|
||||
else()
|
||||
if(CONFIG_BT_CTRL_RUN_IN_FLASH_ONLY AND CONFIG_IDF_TARGET_ESP32C2)
|
||||
add_prebuilt_library(libble_app
|
||||
"controller/lib_${target_name}/${target_name}-bt-lib/libble_app_flash.a"
|
||||
REQUIRES esp_phy)
|
||||
else()
|
||||
add_prebuilt_library(libble_app
|
||||
"controller/lib_${target_name}/${target_name}-bt-lib/libble_app.a"
|
||||
REQUIRES esp_phy)
|
||||
endif()
|
||||
add_prebuilt_library(libble_app
|
||||
"controller/lib_${target_name}/${target_name}-bt-lib/libble_app.a")
|
||||
endif()
|
||||
target_link_libraries(${COMPONENT_LIB} PRIVATE libble_app)
|
||||
endif()
|
||||
|
||||
@@ -81,6 +81,8 @@ menu "Bluetooth"
|
||||
So this option will disable the PMP (ESP_SYSTEM_PMP_IDRAM_SPLIT)
|
||||
|
||||
menu "Common Options"
|
||||
visible if (BT_BLUEDROID_ENABLED || BT_NIMBLE_ENABLED)
|
||||
|
||||
source "$IDF_PATH/components/bt/common/Kconfig.in"
|
||||
endmenu
|
||||
|
||||
|
||||
@@ -1,140 +1,6 @@
|
||||
config BT_ALARM_MAX_NUM
|
||||
int "Maximum number of Bluetooth alarms"
|
||||
default 50
|
||||
depends on (BT_BLUEDROID_ENABLED || BT_NIMBLE_ENABLED)
|
||||
help
|
||||
This option decides the maximum number of alarms which
|
||||
could be used by Bluetooth host.
|
||||
|
||||
config BT_BLE_LOG_SPI_OUT_ENABLED
|
||||
bool "Output ble logs to SPI bus (Experimental)"
|
||||
default n
|
||||
help
|
||||
Output ble logs to SPI bus
|
||||
|
||||
config BT_BLE_LOG_SPI_OUT_UL_TASK_BUF_SIZE
|
||||
int "SPI transaction buffer size for upper layer task logs"
|
||||
depends on BT_BLE_LOG_SPI_OUT_ENABLED
|
||||
default 512
|
||||
help
|
||||
SPI transaction buffer size for upper layer task logs.
|
||||
There will be 2 SPI DMA buffers with the same size.
|
||||
|
||||
config BT_BLE_LOG_SPI_OUT_HCI_ENABLED
|
||||
bool "Enable HCI log output to SPI"
|
||||
depends on BT_BLE_LOG_SPI_OUT_ENABLED
|
||||
default n
|
||||
help
|
||||
Enable logging of HCI packets to the SPI bus when BLE SPI log output is enabled.
|
||||
|
||||
config BT_BLE_LOG_SPI_OUT_HOST_ENABLED
|
||||
bool "Enable Host log output to SPI"
|
||||
depends on BT_BLE_LOG_SPI_OUT_ENABLED
|
||||
default n
|
||||
help
|
||||
This configuration applies to the logs of both Bluedroid Host and NimBLE Host.
|
||||
When BLE SPI log output is enabled, this option allows host logs to be transmitted via SPI.
|
||||
|
||||
config BT_BLE_LOG_SPI_OUT_LL_ENABLED
|
||||
bool "Enable Controller log output to SPI"
|
||||
depends on BT_BLE_LOG_SPI_OUT_ENABLED
|
||||
depends on BT_LE_CONTROLLER_LOG_SPI_OUT_ENABLED
|
||||
default n
|
||||
help
|
||||
Enable controller log output to SPI bus.
|
||||
|
||||
config BT_BLE_LOG_SPI_OUT_LL_TASK_BUF_SIZE
|
||||
int "SPI transaction buffer size for lower layer task logs"
|
||||
depends on BT_BLE_LOG_SPI_OUT_LL_ENABLED
|
||||
default 1024
|
||||
help
|
||||
SPI transaction buffer size for lower layer task logs.
|
||||
There will be 2 SPI DMA buffers with the same size.
|
||||
|
||||
config BT_BLE_LOG_SPI_OUT_LL_ISR_BUF_SIZE
|
||||
int "SPI transaction buffer size for lower layer ISR logs"
|
||||
depends on BT_BLE_LOG_SPI_OUT_LL_ENABLED
|
||||
default 512
|
||||
help
|
||||
SPI transaction buffer size for lower layer ISR logs.
|
||||
There will be 2 SPI DMA buffers with the same size.
|
||||
|
||||
config BT_BLE_LOG_SPI_OUT_LL_HCI_BUF_SIZE
|
||||
int "SPI transaction buffer size for lower layer HCI logs"
|
||||
depends on BT_BLE_LOG_SPI_OUT_LL_ENABLED
|
||||
default 512
|
||||
help
|
||||
SPI transaction buffer size for upper layer HCI logs.
|
||||
There will be 2 SPI DMA buffers with the same size
|
||||
|
||||
config BT_BLE_LOG_SPI_OUT_MOSI_IO_NUM
|
||||
int "GPIO number of SPI MOSI"
|
||||
depends on BT_BLE_LOG_SPI_OUT_ENABLED
|
||||
default 0
|
||||
help
|
||||
GPIO number of SPI MOSI
|
||||
|
||||
config BT_BLE_LOG_SPI_OUT_SCLK_IO_NUM
|
||||
int "GPIO number of SPI SCLK"
|
||||
depends on BT_BLE_LOG_SPI_OUT_ENABLED
|
||||
default 1
|
||||
help
|
||||
GPIO number of SPI SCLK
|
||||
|
||||
config BT_BLE_LOG_SPI_OUT_CS_IO_NUM
|
||||
int "GPIO number of SPI CS"
|
||||
depends on BT_BLE_LOG_SPI_OUT_ENABLED
|
||||
default 2
|
||||
help
|
||||
GPIO number of SPI CS
|
||||
|
||||
config BT_BLE_LOG_SPI_OUT_TS_SYNC_ENABLED
|
||||
bool "Enable ble log & logic analyzer log time sync"
|
||||
depends on BT_BLE_LOG_SPI_OUT_ENABLED
|
||||
default y
|
||||
help
|
||||
Enable ble log & logic analyzer log time sync
|
||||
|
||||
config BT_BLE_LOG_SPI_OUT_SYNC_IO_NUM
|
||||
int "GPIO number of SYNC IO"
|
||||
depends on BT_BLE_LOG_SPI_OUT_TS_SYNC_ENABLED
|
||||
default 3
|
||||
help
|
||||
GPIO number of SYNC IO
|
||||
|
||||
config BT_BLE_LOG_SPI_OUT_TS_SYNC_SLEEP_SUPPORT
|
||||
bool "Enable ble log & logic analyzer log time sync sleep support"
|
||||
depends on BT_BLE_LOG_SPI_OUT_LL_ENABLED
|
||||
default n
|
||||
help
|
||||
Enable ble log & logic analyzer log time sync sleep support
|
||||
|
||||
config BT_BLE_LOG_SPI_OUT_FLUSH_TIMER_ENABLED
|
||||
bool "Enable periodic buffer flush out"
|
||||
depends on BT_BLE_LOG_SPI_OUT_ENABLED
|
||||
default n
|
||||
help
|
||||
Enable periodic buffer flush out
|
||||
Not recommended when SPI receiver is unavailable
|
||||
|
||||
config BT_BLE_LOG_SPI_OUT_FLUSH_TIMEOUT
|
||||
int "Buffer flush out period in unit of ms"
|
||||
depends on BT_BLE_LOG_SPI_OUT_FLUSH_TIMER_ENABLED
|
||||
default 1000
|
||||
help
|
||||
Buffer flush out period in unit of ms
|
||||
|
||||
config BT_BLE_LOG_SPI_OUT_LE_AUDIO_ENABLED
|
||||
bool "Enable LE Audio log output to SPI"
|
||||
depends on BT_BLE_LOG_SPI_OUT_ENABLED
|
||||
default n
|
||||
help
|
||||
Enable LE Audio log output to SPI
|
||||
|
||||
config BT_BLE_LOG_SPI_OUT_LE_AUDIO_BUF_SIZE
|
||||
int "SPI transaction buffer size for LE Audio logs"
|
||||
depends on BT_BLE_LOG_SPI_OUT_LE_AUDIO_ENABLED
|
||||
default 1024
|
||||
help
|
||||
SPI transaction buffer size for LE Audio logs.
|
||||
There will be 2 SPI DMA buffers with the same size.
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,63 +0,0 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
#ifndef __BT_SPI_OUT_H__
|
||||
#define __BT_SPI_OUT_H__
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
#include "driver/spi_master.h"
|
||||
#include "driver/gpio.h"
|
||||
#include "esp_timer.h"
|
||||
#include "esp_log.h"
|
||||
#include "freertos/semphr.h"
|
||||
|
||||
// Public enums
|
||||
enum {
|
||||
BLE_LOG_SPI_OUT_SOURCE_ESP = 0,
|
||||
BLE_LOG_SPI_OUT_SOURCE_ESP_LEGACY,
|
||||
BLE_LOG_SPI_OUT_SOURCE_BLUEDROID,
|
||||
BLE_LOG_SPI_OUT_SOURCE_NIMBLE,
|
||||
BLE_LOG_SPI_OUT_SOURCE_HCI_UPSTREAM,
|
||||
BLE_LOG_SPI_OUT_SOURCE_HCI_DOWNSTREAM,
|
||||
BLE_LOG_SPI_OUT_SOURCE_ESP_ISR,
|
||||
BLE_LOG_SPI_OUT_SOURCE_ESP_LEGACY_ISR,
|
||||
BLE_LOG_SPI_OUT_SOURCE_LL_HCI,
|
||||
BLE_LOG_SPI_OUT_SOURCE_LE_AUDIO,
|
||||
BLE_LOG_SPI_OUT_SOURCE_USER = 0x10,
|
||||
BLE_LOG_SPI_OUT_SOURCE_SSC = 0xFD,
|
||||
BLE_LOG_SPI_OUT_SOURCE_SYNC,
|
||||
BLE_LOG_SPI_OUT_SOURCE_LOSS,
|
||||
};
|
||||
|
||||
enum {
|
||||
BLE_LOG_SPI_OUT_LEVEL_NONE = 0,
|
||||
BLE_LOG_SPI_OUT_LEVEL_ERROR,
|
||||
BLE_LOG_SPI_OUT_LEVEL_WARN,
|
||||
BLE_LOG_SPI_OUT_LEVEL_INFO,
|
||||
BLE_LOG_SPI_OUT_LEVEL_DEBUG,
|
||||
BLE_LOG_SPI_OUT_LEVEL_VERBOSE,
|
||||
BLE_LOG_SPI_OUT_LEVEL_MAX,
|
||||
};
|
||||
|
||||
// Public functions
|
||||
int ble_log_spi_out_init(void);
|
||||
void ble_log_spi_out_deinit(void);
|
||||
void ble_log_spi_out_timer_control(bool enable);
|
||||
int ble_log_spi_out_write(uint8_t source, const uint8_t *addr, uint16_t len);
|
||||
void ble_log_spi_out_ll_write(uint32_t len, const uint8_t *addr, uint32_t len_append,\
|
||||
const uint8_t *addr_append, uint32_t flag);
|
||||
void ble_log_spi_out_ll_log_ev_proc(void);
|
||||
void ble_log_spi_out_ts_sync_start(void);
|
||||
void ble_log_spi_out_ts_sync_stop(void);
|
||||
int ble_log_spi_out_printf(uint8_t source, const char *format, ...);
|
||||
int ble_log_spi_out_printf_enh(uint8_t source, uint8_t level, const char *tag, const char *format, ...);
|
||||
int ble_log_spi_out_write_with_ts(uint8_t source, const uint8_t *addr, uint16_t len);
|
||||
void ble_log_spi_out_dump_all(void);
|
||||
void ble_log_spi_out_enable(bool enable);
|
||||
void ble_log_spi_out_flush(void);
|
||||
void ble_log_spi_out_le_audio_write(const uint8_t *addr, uint16_t len);
|
||||
|
||||
#endif // __BT_SPI_OUT_H__
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -16,12 +16,6 @@ void **btc_profile_cb_tab;
|
||||
|
||||
void esp_profile_cb_reset(void)
|
||||
{
|
||||
#if BTC_DYNAMIC_MEMORY == TRUE
|
||||
if (btc_profile_cb_tab == NULL) {
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
int i;
|
||||
|
||||
for (i = 0; i < BTC_PID_NUM; i++) {
|
||||
@@ -31,12 +25,6 @@ void esp_profile_cb_reset(void)
|
||||
|
||||
int btc_profile_cb_set(btc_pid_t profile_id, void *cb)
|
||||
{
|
||||
#if BTC_DYNAMIC_MEMORY == TRUE
|
||||
if (btc_profile_cb_tab == NULL) {
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (profile_id < 0 || profile_id >= BTC_PID_NUM) {
|
||||
return -1;
|
||||
}
|
||||
@@ -48,12 +36,6 @@ int btc_profile_cb_set(btc_pid_t profile_id, void *cb)
|
||||
|
||||
void *btc_profile_cb_get(btc_pid_t profile_id)
|
||||
{
|
||||
#if BTC_DYNAMIC_MEMORY == TRUE
|
||||
if (btc_profile_cb_tab == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (profile_id < 0 || profile_id >= BTC_PID_NUM) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -24,8 +24,6 @@
|
||||
#include "btc_gattc.h"
|
||||
#include "btc_gatt_common.h"
|
||||
#include "btc_gap_ble.h"
|
||||
#include "btc_iso_ble.h"
|
||||
#include "btc_ble_cte.h"
|
||||
#include "btc/btc_dm.h"
|
||||
#include "bta/bta_gatt_api.h"
|
||||
#if CLASSIC_BT_INCLUDED
|
||||
@@ -212,7 +210,7 @@ static const btc_func_t profile_tab[BTC_PID_NUM] = {
|
||||
[BTC_PID_RPR_CLIENT] = {btc_ble_mesh_rpr_client_call_handler, btc_ble_mesh_rpr_client_cb_handler },
|
||||
#endif /* CONFIG_BLE_MESH_RPR_CLI */
|
||||
#if CONFIG_BLE_MESH_RPR_SRV
|
||||
[BTC_PID_RPR_SERVER] = {btc_ble_mesh_rpr_server_call_handler, btc_ble_mesh_rpr_server_cb_handler },
|
||||
[BTC_PID_RPR_SERVER] = {NULL, btc_ble_mesh_rpr_server_cb_handler },
|
||||
#endif /* CONFIG_BLE_MESH_RPR_SRV */
|
||||
#if CONFIG_BLE_MESH_SAR_CLI
|
||||
[BTC_PID_SAR_CLIENT] = {btc_ble_mesh_sar_client_call_handler, btc_ble_mesh_sar_client_cb_handler },
|
||||
@@ -260,12 +258,6 @@ static const btc_func_t profile_tab[BTC_PID_NUM] = {
|
||||
[BTC_PID_BLE_MESH_BLE_COEX] = {btc_ble_mesh_ble_call_handler, btc_ble_mesh_ble_cb_handler },
|
||||
#endif /* CONFIG_BLE_MESH_BLE_COEX_SUPPORT */
|
||||
#endif /* #if CONFIG_BLE_MESH */
|
||||
#if (BLE_FEAT_ISO_EN == TRUE)
|
||||
[BTC_PID_ISO_BLE] = {btc_iso_ble_call_handler, btc_iso_ble_cb_handler },
|
||||
#endif // #if (BLE_FEAT_ISO_EN == TRUE)
|
||||
#if (BLE_FEAT_CTE_EN == TRUE)
|
||||
[BTC_PID_BLE_CTE] = {btc_ble_cte_call_handler, btc_ble_cte_cb_handler },
|
||||
#endif // #if (BLE_FEAT_CTE_EN == TRUE)
|
||||
};
|
||||
|
||||
/*****************************************************************************
|
||||
@@ -390,8 +382,7 @@ static void btc_deinit_mem(void) {
|
||||
btc_profile_cb_tab = NULL;
|
||||
}
|
||||
|
||||
#if (BLE_42_FEATURE_SUPPORT == TRUE)
|
||||
#if (BLE_42_ADV_EN == TRUE)
|
||||
#if (BLE_INCLUDED == TRUE)
|
||||
if (gl_bta_adv_data_ptr) {
|
||||
osi_free(gl_bta_adv_data_ptr);
|
||||
gl_bta_adv_data_ptr = NULL;
|
||||
@@ -401,8 +392,7 @@ static void btc_deinit_mem(void) {
|
||||
osi_free(gl_bta_scan_rsp_data_ptr);
|
||||
gl_bta_scan_rsp_data_ptr = NULL;
|
||||
}
|
||||
#endif // #if (BLE_42_ADV_EN == TRUE)
|
||||
#endif // BLE_42_FEATURE_SUPPORT
|
||||
#endif ///BLE_INCLUDED == TRUE
|
||||
|
||||
#if GATTS_INCLUDED == TRUE && GATT_DYNAMIC_MEMORY == TRUE
|
||||
if (btc_creat_tab_env_ptr) {
|
||||
@@ -454,9 +444,7 @@ static bt_status_t btc_init_mem(void) {
|
||||
}
|
||||
memset((void *)btc_profile_cb_tab, 0, sizeof(void *) * BTC_PID_NUM);
|
||||
|
||||
#if BTC_DYNAMIC_MEMORY == TRUE
|
||||
#if (BLE_42_FEATURE_SUPPORT == TRUE)
|
||||
#if (BLE_42_ADV_EN == TRUE)
|
||||
#if (BLE_INCLUDED == TRUE)
|
||||
if ((gl_bta_adv_data_ptr = (tBTA_BLE_ADV_DATA *)osi_malloc(sizeof(tBTA_BLE_ADV_DATA))) == NULL) {
|
||||
goto error_exit;
|
||||
}
|
||||
@@ -466,9 +454,7 @@ static bt_status_t btc_init_mem(void) {
|
||||
goto error_exit;
|
||||
}
|
||||
memset((void *)gl_bta_scan_rsp_data_ptr, 0, sizeof(tBTA_BLE_ADV_DATA));
|
||||
#endif // #if (BLE_42_ADV_EN == TRUE)
|
||||
#endif // (BLE_42_FEATURE_SUPPORT == TRUE)
|
||||
#endif // BTC_DYNAMIC_MEMORY == TRUE
|
||||
#endif ///BLE_INCLUDED == TRUE
|
||||
|
||||
#if GATTS_INCLUDED == TRUE && GATT_DYNAMIC_MEMORY == TRUE
|
||||
if ((btc_creat_tab_env_ptr = (esp_btc_creat_tab_t *)osi_malloc(sizeof(esp_btc_creat_tab_t))) == NULL) {
|
||||
@@ -530,30 +516,21 @@ bt_status_t btc_init(void)
|
||||
return BT_STATUS_NOMEM;
|
||||
}
|
||||
#endif
|
||||
#if BTC_GAP_BT_INCLUDED
|
||||
btc_gap_bt_init();
|
||||
#endif
|
||||
|
||||
#if (BLE_INCLUDED == TRUE)
|
||||
btc_gap_callback_init();
|
||||
#if (BLE_FEAT_ISO_EN == TRUE)
|
||||
btc_iso_callback_init();
|
||||
#endif // #if (BLE_FEAT_ISO_EN == TRUE)
|
||||
#if (BLE_FEAT_CTE_EN == TRUE)
|
||||
btc_cte_callback_init();
|
||||
#endif // #if (BLE_FEAT_CTE_EN == TRUE)
|
||||
btc_gap_ble_init();
|
||||
#endif ///BLE_INCLUDED == TRUE
|
||||
|
||||
#if SCAN_QUEUE_CONGEST_CHECK
|
||||
btc_adv_list_init();
|
||||
#endif
|
||||
/* TODO: initial the profile_tab */
|
||||
return BT_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
void btc_deinit(void)
|
||||
{
|
||||
#if BTC_GAP_BT_INCLUDED
|
||||
btc_gap_bt_deinit();
|
||||
#endif
|
||||
#if BTC_DYNAMIC_MEMORY
|
||||
btc_deinit_mem();
|
||||
#endif
|
||||
@@ -563,6 +540,18 @@ void btc_deinit(void)
|
||||
#if (BLE_INCLUDED == TRUE)
|
||||
btc_gap_ble_deinit();
|
||||
#endif ///BLE_INCLUDED == TRUE
|
||||
#if SCAN_QUEUE_CONGEST_CHECK
|
||||
btc_adv_list_deinit();
|
||||
#endif
|
||||
}
|
||||
|
||||
bool btc_check_queue_is_congest(void)
|
||||
{
|
||||
if (osi_thread_queue_wait_size(btc_thread, 0) >= BT_QUEUE_CONGEST_SIZE) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
int get_btc_work_queue_size(void)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -105,12 +105,6 @@ typedef enum {
|
||||
BTC_PID_MBT_SERVER,
|
||||
BTC_PID_BLE_MESH_BLE_COEX,
|
||||
#endif /* CONFIG_BLE_MESH */
|
||||
#if (BLE_FEAT_ISO_EN == TRUE)
|
||||
BTC_PID_ISO_BLE,
|
||||
#endif // #if (BLE_FEAT_ISO_EN == TRUE)
|
||||
#if (BLE_FEAT_CTE_EN == TRUE)
|
||||
BTC_PID_BLE_CTE,
|
||||
#endif // #if (BLE_FEAT_CTE_EN == TRUE)
|
||||
BTC_PID_NUM,
|
||||
} btc_pid_t; //btc profile id
|
||||
|
||||
@@ -129,8 +123,8 @@ extern "C" {
|
||||
/**
|
||||
* transfer an message to another module in the different task.
|
||||
* @param msg message
|
||||
* @param arg parameter
|
||||
* @param arg_len length of parameter
|
||||
* @param arg paramter
|
||||
* @param arg_len length of paramter
|
||||
* @param copy_func deep copy function
|
||||
* @param free_func deep free function
|
||||
* @return BT_STATUS_SUCCESS: success
|
||||
@@ -140,7 +134,7 @@ bt_status_t btc_transfer_context(btc_msg_t *msg, void *arg, int arg_len, btc_arg
|
||||
btc_arg_deep_free_t free_func);
|
||||
|
||||
/**
|
||||
* transfer an message to another module in the same task.
|
||||
* transfer an message to another module in tha same task.
|
||||
* @param msg message
|
||||
* @return BT_STATUS_SUCCESS: success
|
||||
* others: fail
|
||||
@@ -149,6 +143,7 @@ bt_status_t btc_inter_profile_call(btc_msg_t *msg);
|
||||
|
||||
bt_status_t btc_init(void);
|
||||
void btc_deinit(void);
|
||||
bool btc_check_queue_is_congest(void);
|
||||
int get_btc_work_queue_size(void);
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -160,31 +160,20 @@ static void blufi_profile_cb(tBTA_GATTS_EVT event, tBTA_GATTS *p_data)
|
||||
if (p_data->req_data.p_data->write_req.is_prep) {
|
||||
tBTA_GATT_STATUS status = GATT_SUCCESS;
|
||||
|
||||
do {
|
||||
if (p_data->req_data.p_data->write_req.offset > BLUFI_PREPARE_BUF_MAX_SIZE) {
|
||||
status = ESP_GATT_INVALID_OFFSET;
|
||||
break;
|
||||
}
|
||||
|
||||
if ((p_data->req_data.p_data->write_req.offset + p_data->req_data.p_data->write_req.len) > BLUFI_PREPARE_BUF_MAX_SIZE) {
|
||||
status = ESP_GATT_INVALID_ATTR_LEN;
|
||||
break;
|
||||
}
|
||||
|
||||
if (blufi_env.prepare_buf == NULL) {
|
||||
blufi_env.prepare_buf = osi_malloc(BLUFI_PREPAIR_BUF_MAX_SIZE);
|
||||
blufi_env.prepare_len = 0;
|
||||
if (blufi_env.prepare_buf == NULL) {
|
||||
if (p_data->req_data.p_data->write_req.offset != 0) {
|
||||
status = GATT_INVALID_OFFSET;
|
||||
break;
|
||||
}
|
||||
blufi_env.prepare_buf = osi_malloc(BLUFI_PREPARE_BUF_MAX_SIZE);
|
||||
blufi_env.prepare_len = 0;
|
||||
if (blufi_env.prepare_buf == NULL) {
|
||||
BLUFI_TRACE_ERROR("Blufi prep no mem\n");
|
||||
status = GATT_NO_RESOURCES;
|
||||
break;
|
||||
}
|
||||
BLUFI_TRACE_ERROR("Blufi prep no mem\n");
|
||||
status = GATT_NO_RESOURCES;
|
||||
}
|
||||
} while (0);
|
||||
} else {
|
||||
if (p_data->req_data.p_data->write_req.offset > BLUFI_PREPAIR_BUF_MAX_SIZE) {
|
||||
status = GATT_INVALID_OFFSET;
|
||||
} else if ((p_data->req_data.p_data->write_req.offset + p_data->req_data.p_data->write_req.len) > BLUFI_PREPAIR_BUF_MAX_SIZE) {
|
||||
status = GATT_INVALID_ATTR_LEN;
|
||||
}
|
||||
}
|
||||
|
||||
memset(&rsp, 0, sizeof(tGATTS_RSP));
|
||||
rsp.attr_value.handle = p_data->req_data.p_data->write_req.handle;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -95,29 +95,7 @@ void btc_blufi_report_error(esp_blufi_error_state_t state)
|
||||
|
||||
void btc_blufi_recv_handler(uint8_t *data, int len)
|
||||
{
|
||||
if (len < sizeof(struct blufi_hdr)) {
|
||||
BTC_TRACE_ERROR("%s invalid data length: %d", __func__, len);
|
||||
btc_blufi_report_error(ESP_BLUFI_DATA_FORMAT_ERROR);
|
||||
return;
|
||||
}
|
||||
|
||||
struct blufi_hdr *hdr = (struct blufi_hdr *)data;
|
||||
|
||||
// Verify if the received data length matches the expected length based on the BLUFI protocol
|
||||
int target_data_len;
|
||||
|
||||
if (BLUFI_FC_IS_CHECK(hdr->fc)) {
|
||||
target_data_len = hdr->data_len + 4 + 2; // Data + (Type + Frame Control + Sequence Number + Data Length) + Checksum
|
||||
} else {
|
||||
target_data_len = hdr->data_len + 4; // Data + (Type + Frame Control + Sequence Number + Data Length)
|
||||
}
|
||||
|
||||
if (len != target_data_len) {
|
||||
BTC_TRACE_ERROR("%s: Invalid data length: %d, expected: %d", __func__, len, target_data_len);
|
||||
btc_blufi_report_error(ESP_BLUFI_DATA_FORMAT_ERROR);
|
||||
return;
|
||||
}
|
||||
|
||||
uint16_t checksum, checksum_pkt;
|
||||
int ret;
|
||||
|
||||
|
||||
@@ -36,9 +36,7 @@ typedef struct {
|
||||
UINT32 trans_id;
|
||||
UINT8 congest;
|
||||
UINT16 frag_size;
|
||||
// Deprecated: This macro will be removed in the future
|
||||
#define BLUFI_PREPAIR_BUF_MAX_SIZE 1024
|
||||
#define BLUFI_PREPARE_BUF_MAX_SIZE 1024
|
||||
uint8_t *prepare_buf;
|
||||
int prepare_len;
|
||||
/* Control reference */
|
||||
|
||||
@@ -44,7 +44,6 @@ void esp_blufi_gatt_svr_register_cb(struct ble_gatt_register_ctxt *ctxt, void *a
|
||||
|
||||
/* Initialise gatt server */
|
||||
int esp_blufi_gatt_svr_init(void);
|
||||
int esp_blufi_gatt_svr_deinit(void);
|
||||
void esp_blufi_btc_init(void);
|
||||
void esp_blufi_btc_deinit(void);
|
||||
#endif
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -240,32 +240,6 @@ static void init_gatt_values(void)
|
||||
|
||||
}
|
||||
|
||||
static void deinit_gatt_values(void)
|
||||
{
|
||||
int i = 0;
|
||||
const struct ble_gatt_svc_def *svc;
|
||||
const struct ble_gatt_chr_def *chr;
|
||||
const struct ble_gatt_dsc_def *dsc;
|
||||
|
||||
for (svc = gatt_svr_svcs; svc && svc->uuid; svc++) {
|
||||
for (chr = svc->characteristics; chr && chr->uuid; chr++) {
|
||||
if (i < SERVER_MAX_VALUES && gatt_values[i].buf != NULL) {
|
||||
os_mbuf_free(gatt_values[i].buf); /* Free the buffer */
|
||||
gatt_values[i].buf = NULL; /* Nullify the pointer to avoid dangling references */
|
||||
}
|
||||
++i;
|
||||
|
||||
for (dsc = chr->descriptors; dsc && dsc->uuid; dsc++) {
|
||||
if (i < SERVER_MAX_VALUES && gatt_values[i].buf != NULL) {
|
||||
os_mbuf_free(gatt_values[i].buf); /* Free the buffer */
|
||||
gatt_values[i].buf = NULL; /* Nullify the pointer to avoid dangling references */
|
||||
}
|
||||
++i;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int esp_blufi_gatt_svr_init(void)
|
||||
{
|
||||
int rc;
|
||||
@@ -286,18 +260,6 @@ int esp_blufi_gatt_svr_init(void)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int esp_blufi_gatt_svr_deinit(void)
|
||||
{
|
||||
deinit_gatt_values();
|
||||
|
||||
ble_gatts_free_svcs();
|
||||
/* Deinitialize BLE GATT and GAP services */
|
||||
ble_svc_gatt_deinit();
|
||||
ble_svc_gap_deinit();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
esp_blufi_gap_event(struct ble_gap_event *event, void *arg)
|
||||
{
|
||||
@@ -511,10 +473,7 @@ void esp_blufi_disconnect(void)
|
||||
ble_gap_terminate(blufi_env.conn_id, BLE_ERR_REM_USER_CONN_TERM);
|
||||
}
|
||||
|
||||
void esp_blufi_adv_stop(void)
|
||||
{
|
||||
ble_gap_adv_stop();
|
||||
}
|
||||
void esp_blufi_adv_stop(void) {}
|
||||
|
||||
void esp_blufi_send_encap(void *arg)
|
||||
{
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2024-2025 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -124,11 +124,6 @@ static char IRAM_ATTR *bt_data_type_to_str(uint8_t data_type)
|
||||
// self-defining data
|
||||
tag = "S";
|
||||
break;
|
||||
case HCI_LOG_DATA_TYPE_ISO_DATA:
|
||||
// 5.2 iso data
|
||||
tag = "I";
|
||||
break;
|
||||
break;
|
||||
default:
|
||||
// unknown data type
|
||||
tag = "U";
|
||||
|
||||
@@ -21,7 +21,6 @@ extern "C" {
|
||||
#define HCI_LOG_DATA_TYPE_ADV (5)
|
||||
#define HCI_LOG_DATA_TYPE_SELF_DEFINE (6)
|
||||
#define HCI_LOG_DATA_TYPE_C2H_ACL (7)
|
||||
#define HCI_LOG_DATA_TYPE_ISO_DATA (8)
|
||||
|
||||
/**
|
||||
*
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -84,20 +84,6 @@
|
||||
#define BT_HCI_LOG_INCLUDED FALSE
|
||||
#endif
|
||||
|
||||
// HCI LOG TO SPI
|
||||
#if UC_BT_BLE_LOG_SPI_OUT_HCI_ENABLED
|
||||
#define BT_BLE_LOG_SPI_OUT_HCI_ENABLED UC_BT_BLE_LOG_SPI_OUT_HCI_ENABLED
|
||||
#else
|
||||
#define BT_BLE_LOG_SPI_OUT_HCI_ENABLED FALSE
|
||||
#endif
|
||||
|
||||
// BLURDROID LOG TO SPI
|
||||
#if UC_BT_BLE_LOG_SPI_OUT_HOST_ENABLED
|
||||
#define BT_BLE_LOG_SPI_OUT_HOST_ENABLED UC_BT_BLE_LOG_SPI_OUT_HOST_ENABLED
|
||||
#else
|
||||
#define BT_BLE_LOG_SPI_OUT_HOST_ENABLED FALSE
|
||||
#endif
|
||||
|
||||
#if UC_BT_HCI_LOG_DATA_BUFFER_SIZE
|
||||
#define HCI_LOG_DATA_BUFFER_SIZE UC_BT_HCI_LOG_DATA_BUFFER_SIZE
|
||||
#else
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -126,20 +126,6 @@
|
||||
#define UC_BT_HCI_LOG_DEBUG_EN FALSE
|
||||
#endif
|
||||
|
||||
//HCI LOG TO SPI
|
||||
#ifdef CONFIG_BT_BLE_LOG_SPI_OUT_HCI_ENABLED
|
||||
#define UC_BT_BLE_LOG_SPI_OUT_HCI_ENABLED TRUE
|
||||
#else
|
||||
#define UC_BT_BLE_LOG_SPI_OUT_HCI_ENABLED FALSE
|
||||
#endif
|
||||
|
||||
//BLUEDROID LOG TO SPI
|
||||
#ifdef CONFIG_BT_BLE_LOG_SPI_OUT_HOST_ENABLED
|
||||
#define UC_BT_BLE_LOG_SPI_OUT_HOST_ENABLED TRUE
|
||||
#else
|
||||
#define UC_BT_BLE_LOG_SPI_OUT_HOST_ENABLED FALSE
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_BT_HCI_LOG_DATA_BUFFER_SIZE
|
||||
#define UC_BT_HCI_LOG_DATA_BUFFER_SIZE CONFIG_BT_HCI_LOG_DATA_BUFFER_SIZE
|
||||
#else
|
||||
|
||||
@@ -241,8 +241,5 @@ void *osi_calloc_func(size_t size)
|
||||
|
||||
void osi_free_func(void *ptr)
|
||||
{
|
||||
#if HEAP_MEMORY_DEBUG
|
||||
osi_mem_dbg_clean(ptr, __func__, __LINE__);
|
||||
#endif
|
||||
free(ptr);
|
||||
}
|
||||
|
||||
@@ -29,15 +29,6 @@ void *osi_malloc_func(size_t size);
|
||||
void *osi_calloc_func(size_t size);
|
||||
void osi_free_func(void *ptr);
|
||||
|
||||
// Memory alloc function without print and assertion
|
||||
#if HEAP_ALLOCATION_FROM_SPIRAM_FIRST
|
||||
#define osi_malloc_base(size) heap_caps_malloc_prefer(size, 2, MALLOC_CAP_DEFAULT|MALLOC_CAP_SPIRAM, MALLOC_CAP_DEFAULT|MALLOC_CAP_INTERNAL)
|
||||
#define osi_calloc_base(size) heap_caps_calloc_prefer(1, size, 2, MALLOC_CAP_DEFAULT|MALLOC_CAP_SPIRAM, MALLOC_CAP_DEFAULT|MALLOC_CAP_INTERNAL)
|
||||
#else
|
||||
#define osi_malloc_base(size) malloc((size))
|
||||
#define osi_calloc_base(size) calloc(1, (size))
|
||||
#endif /* #if HEAP_ALLOCATION_FROM_SPIRAM_FIRST */
|
||||
|
||||
#if HEAP_MEMORY_DEBUG
|
||||
|
||||
void osi_mem_dbg_init(void);
|
||||
@@ -50,10 +41,13 @@ void osi_men_dbg_set_section_start(uint8_t index);
|
||||
void osi_men_dbg_set_section_end(uint8_t index);
|
||||
uint32_t osi_mem_dbg_get_max_size_section(uint8_t index);
|
||||
|
||||
#if HEAP_ALLOCATION_FROM_SPIRAM_FIRST
|
||||
#define osi_malloc(size) \
|
||||
({ \
|
||||
void *p; \
|
||||
p = osi_malloc_base(size); \
|
||||
p = heap_caps_malloc_prefer(size, 2, \
|
||||
MALLOC_CAP_DEFAULT|MALLOC_CAP_SPIRAM, \
|
||||
MALLOC_CAP_DEFAULT|MALLOC_CAP_INTERNAL); \
|
||||
osi_mem_dbg_record(p, size, __func__, __LINE__); \
|
||||
(void *)p; \
|
||||
})
|
||||
@@ -61,11 +55,34 @@ uint32_t osi_mem_dbg_get_max_size_section(uint8_t index);
|
||||
#define osi_calloc(size) \
|
||||
({ \
|
||||
void *p; \
|
||||
p = osi_calloc_base(size); \
|
||||
p = heap_caps_calloc_prefer(1, size, 2, \
|
||||
MALLOC_CAP_DEFAULT|MALLOC_CAP_SPIRAM, \
|
||||
MALLOC_CAP_DEFAULT|MALLOC_CAP_INTERNAL); \
|
||||
osi_mem_dbg_record(p, size, __func__, __LINE__); \
|
||||
(void *)p; \
|
||||
})
|
||||
|
||||
#else
|
||||
|
||||
#define osi_malloc(size) \
|
||||
({ \
|
||||
void *p; \
|
||||
p = malloc((size)); \
|
||||
osi_mem_dbg_record(p, size, __func__, __LINE__); \
|
||||
(void *)p; \
|
||||
})
|
||||
|
||||
#define osi_calloc(size) \
|
||||
({ \
|
||||
void *p; \
|
||||
p = calloc(1, (size)); \
|
||||
osi_mem_dbg_record(p, size, __func__, __LINE__); \
|
||||
(void *)p; \
|
||||
})
|
||||
|
||||
#endif /* #if HEAP_ALLOCATION_FROM_SPIRAM_FIRST */
|
||||
|
||||
|
||||
#if 0
|
||||
#define osi_malloc(size) \
|
||||
do { \
|
||||
@@ -105,6 +122,15 @@ do { \
|
||||
|
||||
#else
|
||||
|
||||
// Memory alloc function without print and assertion
|
||||
#if HEAP_ALLOCATION_FROM_SPIRAM_FIRST
|
||||
#define osi_malloc_base(size) heap_caps_malloc_prefer(size, 2, MALLOC_CAP_DEFAULT|MALLOC_CAP_SPIRAM, MALLOC_CAP_DEFAULT|MALLOC_CAP_INTERNAL)
|
||||
#define osi_calloc_base(size) heap_caps_calloc_prefer(1, size, 2, MALLOC_CAP_DEFAULT|MALLOC_CAP_SPIRAM, MALLOC_CAP_DEFAULT|MALLOC_CAP_INTERNAL)
|
||||
#else
|
||||
#define osi_malloc_base(size) malloc((size))
|
||||
#define osi_calloc_base(size) calloc(1, (size))
|
||||
#endif /* #if HEAP_ALLOCATION_FROM_SPIRAM_FIRST */
|
||||
|
||||
// Memory alloc function with print and assertion when fails
|
||||
#define osi_malloc(size) osi_malloc_func((size))
|
||||
#define osi_calloc(size) osi_calloc_func((size))
|
||||
|
||||
@@ -76,8 +76,4 @@ void fixed_pkt_queue_unregister_dequeue(fixed_pkt_queue_t *queue);
|
||||
|
||||
void fixed_pkt_queue_process(fixed_pkt_queue_t *queue);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -25,7 +25,6 @@ struct pkt_queue *pkt_queue_create(void)
|
||||
}
|
||||
if (osi_mutex_new(&queue->lock) != 0) {
|
||||
osi_free(queue);
|
||||
return NULL;
|
||||
}
|
||||
struct pkt_queue_header *p = &queue->header;
|
||||
STAILQ_INIT(p);
|
||||
|
||||
@@ -1,87 +0,0 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
#include "esp_tinycrypt_port.h"
|
||||
|
||||
#include "esp_crypto_lock.h"
|
||||
#include "esp_private/esp_crypto_lock_internal.h"
|
||||
|
||||
#if SOC_ECC_SUPPORTED
|
||||
#include "hal/ecc_hal.h"
|
||||
#include "hal/ecc_ll.h"
|
||||
#endif /* SOC_ECC_SUPPORTED */
|
||||
|
||||
|
||||
#if SOC_ECC_SUPPORTED
|
||||
static void esp_tinycrypt_acquire_ecc_hardware(void)
|
||||
{
|
||||
esp_crypto_ecc_lock_acquire();
|
||||
|
||||
ECC_RCC_ATOMIC() {
|
||||
ecc_ll_enable_bus_clock(true);
|
||||
ecc_ll_power_up();
|
||||
ecc_ll_reset_register();
|
||||
}
|
||||
}
|
||||
|
||||
static void esp_tinycrypt_release_ecc_hardware(void)
|
||||
{
|
||||
ECC_RCC_ATOMIC() {
|
||||
ecc_ll_enable_bus_clock(false);
|
||||
ecc_ll_power_down();
|
||||
}
|
||||
|
||||
esp_crypto_ecc_lock_release();
|
||||
}
|
||||
|
||||
int esp_tinycrypt_verify_ecc_point(const uint8_t *pk_x, const uint8_t *pk_y, uint8_t length)
|
||||
{
|
||||
int result;
|
||||
|
||||
esp_tinycrypt_acquire_ecc_hardware();
|
||||
|
||||
ecc_hal_write_verify_param(pk_x, pk_y, length);
|
||||
ecc_hal_set_mode(ECC_MODE_VERIFY);
|
||||
ecc_hal_start_calc();
|
||||
while (!ecc_hal_is_calc_finished());
|
||||
result = ecc_hal_read_verify_result();
|
||||
|
||||
esp_tinycrypt_release_ecc_hardware();
|
||||
|
||||
if (result == 1) {
|
||||
return 0;
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
int esp_tinycrypt_calc_ecc_mult(const uint8_t *p_x, const uint8_t *p_y, const uint8_t *scalar,
|
||||
uint8_t *r_x, uint8_t *r_y, uint8_t num_bytes, bool verify_first)
|
||||
{
|
||||
int ret = -1;
|
||||
ecc_mode_t work_mode = verify_first ? ECC_MODE_VERIFY_THEN_POINT_MUL : ECC_MODE_POINT_MUL;
|
||||
|
||||
esp_tinycrypt_acquire_ecc_hardware();
|
||||
|
||||
ecc_hal_write_mul_param(scalar, p_x, p_y, num_bytes);
|
||||
ecc_hal_set_mode(work_mode);
|
||||
/*
|
||||
* Enable constant-time point multiplication operations for the ECC hardware accelerator,
|
||||
* if supported for the given target. This protects the ECC multiplication operation from
|
||||
* timing attacks. This increases the time taken (by almost 50%) for some point
|
||||
* multiplication operations performed by the ECC hardware accelerator.
|
||||
*/
|
||||
ecc_hal_enable_constant_time_point_mul(true);
|
||||
ecc_hal_start_calc();
|
||||
|
||||
while (!ecc_hal_is_calc_finished());
|
||||
|
||||
ret = ecc_hal_read_mul_result(r_x, r_y, num_bytes);
|
||||
|
||||
esp_tinycrypt_release_ecc_hardware();
|
||||
|
||||
return ret;
|
||||
}
|
||||
#endif /* SOC_ECC_SUPPORTED */
|
||||
@@ -1,15 +0,0 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "soc/soc_caps.h"
|
||||
|
||||
#if SOC_ECC_SUPPORTED
|
||||
int esp_tinycrypt_verify_ecc_point(const uint8_t *pk_x, const uint8_t *pk_y, uint8_t length);
|
||||
|
||||
int esp_tinycrypt_calc_ecc_mult(const uint8_t *p_x, const uint8_t *p_y, const uint8_t *scalar,
|
||||
uint8_t *r_x, uint8_t *r_y, uint8_t num_bytes, bool verify_first);
|
||||
#endif /* SOC_ECC_SUPPORTED */
|
||||
@@ -23,14 +23,6 @@ config BTDM_CTRL_BLE_MAX_CONN
|
||||
BLE maximum connections of bluetooth controller.
|
||||
Each connection uses 1KB static DRAM whenever the BT controller is enabled.
|
||||
|
||||
config BTDM_CTRL_BR_EDR_MIN_ENC_KEY_SZ_DFT
|
||||
int "BR/EDR default minimum size of encryption key"
|
||||
depends on BTDM_CTRL_MODE_BR_EDR_ONLY || BTDM_CTRL_MODE_BTDM
|
||||
default 7
|
||||
range 7 16
|
||||
help
|
||||
BR/EDR default minimum size of encryption key when start encryption.
|
||||
|
||||
config BTDM_CTRL_BR_EDR_MAX_ACL_CONN
|
||||
int "BR/EDR ACL Max Connections"
|
||||
depends on BTDM_CTRL_MODE_BR_EDR_ONLY || BTDM_CTRL_MODE_BTDM
|
||||
@@ -185,11 +177,6 @@ config BTDM_CTRL_BLE_MAX_CONN_EFF
|
||||
default BTDM_CTRL_BLE_MAX_CONN if BTDM_CTRL_MODE_BLE_ONLY || BTDM_CTRL_MODE_BTDM
|
||||
default 0
|
||||
|
||||
config BTDM_CTRL_BR_EDR_MIN_ENC_KEY_SZ_DFT_EFF
|
||||
int
|
||||
default BTDM_CTRL_BR_EDR_MIN_ENC_KEY_SZ_DFT if BTDM_CTRL_MODE_BR_EDR_ONLY || BTDM_CTRL_MODE_BTDM
|
||||
default 0
|
||||
|
||||
config BTDM_CTRL_BR_EDR_MAX_ACL_CONN_EFF
|
||||
int
|
||||
default BTDM_CTRL_BR_EDR_MAX_ACL_CONN if BTDM_CTRL_MODE_BR_EDR_ONLY || BTDM_CTRL_MODE_BTDM
|
||||
@@ -333,7 +320,7 @@ choice BTDM_BLE_SLEEP_CLOCK_ACCURACY
|
||||
needs a larger RX window to synchronize with master in each anchor point, thus resulting in an
|
||||
increase of power consumption but a higher level of robustness in keeping connected. According
|
||||
to the requirements of Bluetooth Core specification 4.2, the worst-case accuracy of Classic
|
||||
Bluetooth Low Power Oscillator (LPO) is +/-250ppm in STANDBY and in low power modes such as
|
||||
Bluetooth low power oscialltor(LPO) is +/-250ppm in STANDBY and in low power modes such as
|
||||
sniff. For BLE the worst-case SCA is +/-500ppm.
|
||||
|
||||
- "151ppm to 250ppm" option is the default value for Bluetooth Dual mode
|
||||
@@ -457,15 +444,6 @@ config BTDM_CTRL_SCAN_BACKOFF_UPPERLIMITMAX
|
||||
minimize collision of scan request PDUs from nultiple scanners. If scan backoff is disabled, in active
|
||||
scanning, scan request PDU will be sent every time when HW receives scannable ADV PDU.
|
||||
|
||||
config BTDM_CTRL_CHECK_CONNECT_IND_ACCESS_ADDRESS
|
||||
bool "Enable enhanced Access Address check in CONNECT_IND"
|
||||
default n
|
||||
help
|
||||
Enabling this option will add stricter verification of the Access Address in the CONNECT_IND PDU.
|
||||
This improves security by ensuring that only connection requests with valid Access Addresses are accepted.
|
||||
If disabled, only basic checks are applied, improving compatibility.
|
||||
|
||||
|
||||
config BTDM_BLE_ADV_REPORT_FLOW_CTRL_SUPP
|
||||
bool "BLE adv report flow control supported"
|
||||
depends on (BTDM_CTRL_MODE_BTDM || BTDM_CTRL_MODE_BLE_ONLY)
|
||||
@@ -500,14 +478,14 @@ config BTDM_BLE_ADV_REPORT_DISCARD_THRSHOLD
|
||||
If you set `BTDM_BLE_ADV_REPORT_DISCARD_THRSHOLD` to a small value or printf every adv lost event, it
|
||||
may cause adv packets lost more.
|
||||
|
||||
menu "BLE disconnects when Instant Passed (0x28) occurs"
|
||||
menu "BLE disconnect when instant passed"
|
||||
config BTDM_BLE_LLCP_CONN_UPDATE
|
||||
bool "BLE ACL connection update procedure"
|
||||
depends on (BTDM_CTRL_MODE_BLE_ONLY || BTDM_CTRL_MODE_BTDM)
|
||||
default n
|
||||
help
|
||||
If this option is enabled, Controller will terminate the connection
|
||||
when Instant Passed (0x28) error occurs during connection update procedure.
|
||||
when instant passed during connection update procedure.
|
||||
|
||||
config BTDM_BLE_LLCP_CHAN_MAP_UPDATE
|
||||
bool "BLE ACL channel map update procedure"
|
||||
@@ -515,34 +493,9 @@ menu "BLE disconnects when Instant Passed (0x28) occurs"
|
||||
default n
|
||||
help
|
||||
If this option is enabled, Controller will terminate the connection
|
||||
when Instant Passed (0x28) error occurs in channel map update procedure.
|
||||
when instant passed in channel map update procedure.
|
||||
endmenu
|
||||
|
||||
config BTDM_BLE_CHAN_ASS_EN
|
||||
bool "Enable channel assessment"
|
||||
depends on (BTDM_CTRL_MODE_BLE_ONLY || BTDM_CTRL_MODE_BTDM)
|
||||
default y
|
||||
help
|
||||
If this option is enabled, The Controller will records the communication quality
|
||||
for each channel and then start a timer to check and update the channel map every 4 seconds.
|
||||
|
||||
config BTDM_BLE_PING_EN
|
||||
bool "Enable LE Ping procedure"
|
||||
depends on (BTDM_CTRL_MODE_BTDM || BTDM_CTRL_MODE_BLE_ONLY)
|
||||
default y
|
||||
help
|
||||
If this option is disabled, The Controller will not start the LE authenticated payload timer.
|
||||
This option is used for some compatibility problems related to LE ping procedure.
|
||||
|
||||
config BTDM_CTRL_CONTROLLER_DEBUG_MODE_1
|
||||
bool "Enable Bluetooth controller debugging mode 1 (for internal use only)"
|
||||
default n
|
||||
depends on BT_ENABLED
|
||||
help
|
||||
Enables specific debugging features for the Bluetooth controller.
|
||||
This option is strictly for internal debugging purposes and should not be enabled in production environments,
|
||||
as it may impact performance and stability.
|
||||
|
||||
config BTDM_RESERVE_DRAM
|
||||
hex
|
||||
default 0xdb5c if BT_ENABLED
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -48,10 +48,6 @@
|
||||
#include "esp_rom_sys.h"
|
||||
#include "hli_api.h"
|
||||
|
||||
#if CONFIG_BT_BLE_LOG_SPI_OUT_ENABLED
|
||||
#include "ble_log/ble_log_spi_out.h"
|
||||
#endif // CONFIG_BT_BLE_LOG_SPI_OUT_ENABLED
|
||||
|
||||
#if CONFIG_BT_ENABLED
|
||||
|
||||
/* Macro definition
|
||||
@@ -253,16 +249,6 @@ extern void config_bt_funcs_reset(void);
|
||||
extern void config_ble_funcs_reset(void);
|
||||
extern void config_btdm_funcs_reset(void);
|
||||
|
||||
#ifdef CONFIG_BT_BLUEDROID_ENABLED
|
||||
extern void bt_stack_enableSecCtrlVsCmd(bool en);
|
||||
#endif // CONFIG_BT_BLUEDROID_ENABLED
|
||||
#if defined(CONFIG_BT_NIMBLE_ENABLED) || defined(CONFIG_BT_BLUEDROID_ENABLED)
|
||||
extern void bt_stack_enableCoexVsCmd(bool en);
|
||||
extern void scan_stack_enableAdvFlowCtrlVsCmd(bool en);
|
||||
extern void adv_stack_enableClearLegacyAdvVsCmd(bool en);
|
||||
extern void advFilter_stack_enableDupExcListVsCmd(bool en);
|
||||
#endif // (CONFIG_BT_NIMBLE_ENABLED) || (CONFIG_BT_BLUEDROID_ENABLED)
|
||||
|
||||
/* Local Function Declare
|
||||
*********************************************************************
|
||||
*/
|
||||
@@ -463,11 +449,7 @@ static DRAM_ATTR uint8_t btdm_lpcycle_us_frac = 0; // number of fractional bit f
|
||||
|
||||
#if CONFIG_BTDM_CTRL_MODEM_SLEEP_MODE_ORIG
|
||||
// used low power clock
|
||||
#if CONFIG_BTDM_CTRL_LPCLK_SEL_EXT_32K_XTAL
|
||||
static DRAM_ATTR uint8_t btdm_lpclk_sel = ESP_BT_SLEEP_CLOCK_EXT_32K_XTAL;
|
||||
#else
|
||||
static DRAM_ATTR uint8_t btdm_lpclk_sel = ESP_BT_SLEEP_CLOCK_MAIN_XTAL;
|
||||
#endif /* CONFIG_BTDM_CTRL_LPCLK_SEL_EXT_32K_XTAL */
|
||||
static DRAM_ATTR uint8_t btdm_lpclk_sel;
|
||||
#endif /* #ifdef CONFIG_BTDM_CTRL_MODEM_SLEEP_MODE_ORIG */
|
||||
|
||||
static DRAM_ATTR QueueHandle_t s_wakeup_req_sem = NULL;
|
||||
@@ -965,7 +947,7 @@ static void btdm_sleep_enter_phase1_wrapper(uint32_t lpcycles)
|
||||
assert(us_to_sleep > BTDM_MIN_TIMER_UNCERTAINTY_US);
|
||||
// allow a maximum time uncertainty to be about 488ppm(1/2048) at least as clock drift
|
||||
// and set the timer in advance
|
||||
uint32_t uncertainty = (us_to_sleep / 1000);
|
||||
uint32_t uncertainty = (us_to_sleep >> 11);
|
||||
if (uncertainty < BTDM_MIN_TIMER_UNCERTAINTY_US) {
|
||||
uncertainty = BTDM_MIN_TIMER_UNCERTAINTY_US;
|
||||
}
|
||||
@@ -1060,8 +1042,9 @@ static bool async_wakeup_request(int event)
|
||||
|
||||
switch (event) {
|
||||
case BTDM_ASYNC_WAKEUP_REQ_HCI:
|
||||
case BTDM_ASYNC_WAKEUP_REQ_CTRL_DISA:
|
||||
btdm_in_wakeup_requesting_set(true);
|
||||
// NO break
|
||||
case BTDM_ASYNC_WAKEUP_REQ_CTRL_DISA:
|
||||
if (!btdm_power_state_active()) {
|
||||
do_wakeup_request = true;
|
||||
|
||||
@@ -1094,10 +1077,10 @@ static void async_wakeup_request_end(int event)
|
||||
bool request_lock = false;
|
||||
switch (event) {
|
||||
case BTDM_ASYNC_WAKEUP_REQ_HCI:
|
||||
case BTDM_ASYNC_WAKEUP_REQ_CTRL_DISA:
|
||||
request_lock = true;
|
||||
break;
|
||||
case BTDM_ASYNC_WAKEUP_REQ_COEX:
|
||||
case BTDM_ASYNC_WAKEUP_REQ_CTRL_DISA:
|
||||
request_lock = false;
|
||||
break;
|
||||
default:
|
||||
@@ -1362,8 +1345,7 @@ static esp_err_t esp_bt_controller_rom_mem_release(esp_bt_mode_t mode)
|
||||
|
||||
//already released
|
||||
if (!(mode & btdm_dram_available_region[0].mode)) {
|
||||
ESP_LOGW(BTDM_LOG_TAG, "%s already released, mode %d",__func__, mode);
|
||||
return ESP_OK;
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
for (int i = 0; i < sizeof(btdm_dram_available_region)/sizeof(btdm_dram_available_region_t); i++) {
|
||||
@@ -1508,117 +1490,6 @@ static void hli_queue_setup_pinned_to_core(int core_id)
|
||||
}
|
||||
#endif /* CONFIG_BTDM_CTRL_HLI */
|
||||
|
||||
// init low-power control resources
|
||||
static esp_err_t btdm_low_power_mode_init(void)
|
||||
{
|
||||
esp_err_t err = ESP_OK;
|
||||
|
||||
#ifdef CONFIG_PM_ENABLE
|
||||
s_btdm_allow_light_sleep = false;
|
||||
#endif
|
||||
|
||||
// set default sleep clock cycle and its fractional bits
|
||||
btdm_lpcycle_us_frac = RTC_CLK_CAL_FRACT;
|
||||
btdm_lpcycle_us = 2 << (btdm_lpcycle_us_frac);
|
||||
|
||||
#if CONFIG_BTDM_CTRL_MODEM_SLEEP_MODE_ORIG
|
||||
if (btdm_lpclk_sel == ESP_BT_SLEEP_CLOCK_EXT_32K_XTAL) {
|
||||
// check whether or not EXT_CRYS is working
|
||||
if (rtc_clk_slow_src_get() == SOC_RTC_SLOW_CLK_SRC_XTAL32K) {
|
||||
#ifdef CONFIG_PM_ENABLE
|
||||
s_btdm_allow_light_sleep = true;
|
||||
#endif
|
||||
} else {
|
||||
ESP_LOGW(BTDM_LOG_TAG, "32.768kHz XTAL not detected, fall back to main XTAL as Bluetooth sleep clock\n"
|
||||
"light sleep mode will not be able to apply when bluetooth is enabled");
|
||||
btdm_lpclk_sel = ESP_BT_SLEEP_CLOCK_MAIN_XTAL; // set default value
|
||||
}
|
||||
} else if (btdm_lpclk_sel != ESP_BT_SLEEP_CLOCK_MAIN_XTAL) {
|
||||
assert(0);
|
||||
}
|
||||
|
||||
bool select_src_ret __attribute__((unused));
|
||||
bool set_div_ret __attribute__((unused));
|
||||
if (btdm_lpclk_sel == ESP_BT_SLEEP_CLOCK_MAIN_XTAL) {
|
||||
select_src_ret = btdm_lpclk_select_src(BTDM_LPCLK_SEL_XTAL);
|
||||
set_div_ret = btdm_lpclk_set_div(esp_clk_xtal_freq() * 2 / MHZ - 1);
|
||||
assert(select_src_ret && set_div_ret);
|
||||
btdm_lpcycle_us_frac = RTC_CLK_CAL_FRACT;
|
||||
btdm_lpcycle_us = 2 << (btdm_lpcycle_us_frac);
|
||||
} else { // btdm_lpclk_sel == BTDM_LPCLK_SEL_XTAL32K
|
||||
select_src_ret = btdm_lpclk_select_src(BTDM_LPCLK_SEL_XTAL32K);
|
||||
set_div_ret = btdm_lpclk_set_div(0);
|
||||
assert(select_src_ret && set_div_ret);
|
||||
btdm_lpcycle_us_frac = RTC_CLK_CAL_FRACT;
|
||||
btdm_lpcycle_us = (RTC_CLK_CAL_FRACT > 15) ? (1000000 << (RTC_CLK_CAL_FRACT - 15)) :
|
||||
(1000000 >> (15 - RTC_CLK_CAL_FRACT));
|
||||
assert(btdm_lpcycle_us != 0);
|
||||
}
|
||||
btdm_controller_set_sleep_mode(BTDM_MODEM_SLEEP_MODE_ORIG);
|
||||
|
||||
#elif CONFIG_BTDM_CTRL_MODEM_SLEEP_MODE_EVED
|
||||
btdm_controller_set_sleep_mode(BTDM_MODEM_SLEEP_MODE_EVED);
|
||||
#else
|
||||
btdm_controller_set_sleep_mode(BTDM_MODEM_SLEEP_MODE_NONE);
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_PM_ENABLE
|
||||
if (!s_btdm_allow_light_sleep) {
|
||||
if ((err = esp_pm_lock_create(ESP_PM_NO_LIGHT_SLEEP, 0, "btLS", &s_light_sleep_pm_lock)) != ESP_OK) {
|
||||
return err;
|
||||
}
|
||||
}
|
||||
if ((err = esp_pm_lock_create(ESP_PM_APB_FREQ_MAX, 0, "bt", &s_pm_lock)) != ESP_OK) {
|
||||
return err;
|
||||
}
|
||||
esp_timer_create_args_t create_args = {
|
||||
.callback = btdm_slp_tmr_callback,
|
||||
.arg = NULL,
|
||||
.name = "btSlp"
|
||||
};
|
||||
if ((err = esp_timer_create(&create_args, &s_btdm_slp_tmr)) != ESP_OK) {
|
||||
return err;
|
||||
}
|
||||
|
||||
s_pm_lock_acquired = true;
|
||||
#endif
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
esp_bt_sleep_clock_t esp_bt_get_lpclk_src(void)
|
||||
{
|
||||
#if CONFIG_BTDM_CTRL_MODEM_SLEEP_MODE_ORIG
|
||||
if (btdm_controller_status != ESP_BT_CONTROLLER_STATUS_INITED &&
|
||||
btdm_controller_status != ESP_BT_CONTROLLER_STATUS_ENABLED) {
|
||||
return ESP_BT_SLEEP_CLOCK_NONE;
|
||||
}
|
||||
return btdm_lpclk_sel;
|
||||
#else
|
||||
return ESP_BT_SLEEP_CLOCK_NONE;
|
||||
#endif
|
||||
}
|
||||
|
||||
esp_err_t esp_bt_set_lpclk_src(esp_bt_sleep_clock_t lpclk)
|
||||
{
|
||||
#if CONFIG_BTDM_CTRL_MODEM_SLEEP_MODE_ORIG
|
||||
if (lpclk < ESP_BT_SLEEP_CLOCK_MAIN_XTAL || lpclk > ESP_BT_SLEEP_CLOCK_EXT_32K_XTAL) {
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
if (btdm_controller_status == ESP_BT_CONTROLLER_STATUS_INITED ||
|
||||
btdm_controller_status == ESP_BT_CONTROLLER_STATUS_ENABLED) {
|
||||
ESP_LOGW(BTDM_LOG_TAG, "Please set the Bluetooth sleep clock source before Bluetooth initialization");
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
btdm_lpclk_sel = lpclk;
|
||||
return ESP_OK;
|
||||
#else
|
||||
return ESP_ERR_NOT_SUPPORTED;
|
||||
#endif
|
||||
}
|
||||
|
||||
esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg)
|
||||
{
|
||||
esp_err_t err;
|
||||
@@ -1681,7 +1552,58 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg)
|
||||
btdm_controller_mem_init();
|
||||
|
||||
periph_module_enable(PERIPH_BT_MODULE);
|
||||
periph_module_reset(PERIPH_BT_MODULE);
|
||||
|
||||
#ifdef CONFIG_PM_ENABLE
|
||||
s_btdm_allow_light_sleep = false;
|
||||
#endif
|
||||
|
||||
// set default sleep clock cycle and its fractional bits
|
||||
btdm_lpcycle_us_frac = RTC_CLK_CAL_FRACT;
|
||||
btdm_lpcycle_us = 2 << (btdm_lpcycle_us_frac);
|
||||
|
||||
#if CONFIG_BTDM_CTRL_MODEM_SLEEP_MODE_ORIG
|
||||
|
||||
btdm_lpclk_sel = BTDM_LPCLK_SEL_XTAL; // set default value
|
||||
#if CONFIG_BTDM_CTRL_LPCLK_SEL_EXT_32K_XTAL
|
||||
// check whether or not EXT_CRYS is working
|
||||
if (rtc_clk_slow_src_get() == SOC_RTC_SLOW_CLK_SRC_XTAL32K) {
|
||||
btdm_lpclk_sel = BTDM_LPCLK_SEL_XTAL32K; // External 32kHz XTAL
|
||||
#ifdef CONFIG_PM_ENABLE
|
||||
s_btdm_allow_light_sleep = true;
|
||||
#endif
|
||||
} else {
|
||||
ESP_LOGW(BTDM_LOG_TAG, "32.768kHz XTAL not detected, fall back to main XTAL as Bluetooth sleep clock\n"
|
||||
"light sleep mode will not be able to apply when bluetooth is enabled");
|
||||
btdm_lpclk_sel = BTDM_LPCLK_SEL_XTAL; // set default value
|
||||
}
|
||||
#else
|
||||
btdm_lpclk_sel = BTDM_LPCLK_SEL_XTAL; // set default value
|
||||
#endif
|
||||
|
||||
bool select_src_ret __attribute__((unused));
|
||||
bool set_div_ret __attribute__((unused));
|
||||
if (btdm_lpclk_sel == BTDM_LPCLK_SEL_XTAL) {
|
||||
select_src_ret = btdm_lpclk_select_src(BTDM_LPCLK_SEL_XTAL);
|
||||
set_div_ret = btdm_lpclk_set_div(esp_clk_xtal_freq() * 2 / MHZ - 1);
|
||||
assert(select_src_ret && set_div_ret);
|
||||
btdm_lpcycle_us_frac = RTC_CLK_CAL_FRACT;
|
||||
btdm_lpcycle_us = 2 << (btdm_lpcycle_us_frac);
|
||||
} else { // btdm_lpclk_sel == BTDM_LPCLK_SEL_XTAL32K
|
||||
select_src_ret = btdm_lpclk_select_src(BTDM_LPCLK_SEL_XTAL32K);
|
||||
set_div_ret = btdm_lpclk_set_div(0);
|
||||
assert(select_src_ret && set_div_ret);
|
||||
btdm_lpcycle_us_frac = RTC_CLK_CAL_FRACT;
|
||||
btdm_lpcycle_us = (RTC_CLK_CAL_FRACT > 15) ? (1000000 << (RTC_CLK_CAL_FRACT - 15)) :
|
||||
(1000000 >> (15 - RTC_CLK_CAL_FRACT));
|
||||
assert(btdm_lpcycle_us != 0);
|
||||
}
|
||||
btdm_controller_set_sleep_mode(BTDM_MODEM_SLEEP_MODE_ORIG);
|
||||
|
||||
#elif CONFIG_BTDM_CTRL_MODEM_SLEEP_MODE_EVED
|
||||
btdm_controller_set_sleep_mode(BTDM_MODEM_SLEEP_MODE_EVED);
|
||||
#else
|
||||
btdm_controller_set_sleep_mode(BTDM_MODEM_SLEEP_MODE_NONE);
|
||||
#endif
|
||||
|
||||
#if CONFIG_BTDM_CTRL_HCI_UART_FLOW_CTRL_EN
|
||||
sdk_config_set_uart_flow_ctrl_enable(true);
|
||||
@@ -1689,23 +1611,31 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg)
|
||||
sdk_config_set_uart_flow_ctrl_enable(false);
|
||||
#endif
|
||||
|
||||
if ((err = btdm_low_power_mode_init()) != ESP_OK) {
|
||||
ESP_LOGE(BTDM_LOG_TAG, "Low power module initialization failed");
|
||||
#ifdef CONFIG_PM_ENABLE
|
||||
if (!s_btdm_allow_light_sleep) {
|
||||
if ((err = esp_pm_lock_create(ESP_PM_NO_LIGHT_SLEEP, 0, "btLS", &s_light_sleep_pm_lock)) != ESP_OK) {
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
if ((err = esp_pm_lock_create(ESP_PM_APB_FREQ_MAX, 0, "bt", &s_pm_lock)) != ESP_OK) {
|
||||
goto error;
|
||||
}
|
||||
esp_timer_create_args_t create_args = {
|
||||
.callback = btdm_slp_tmr_callback,
|
||||
.arg = NULL,
|
||||
.name = "btSlp"
|
||||
};
|
||||
if ((err = esp_timer_create(&create_args, &s_btdm_slp_tmr)) != ESP_OK) {
|
||||
goto error;
|
||||
}
|
||||
|
||||
s_pm_lock_acquired = true;
|
||||
#endif
|
||||
|
||||
#if CONFIG_SW_COEXIST_ENABLE
|
||||
coex_init();
|
||||
#endif
|
||||
|
||||
#if CONFIG_BT_BLE_LOG_SPI_OUT_ENABLED
|
||||
if (ble_log_spi_out_init() != 0) {
|
||||
ESP_LOGE(BTDM_LOG_TAG, "BLE Log SPI output init failed");
|
||||
err = ESP_ERR_NO_MEM;
|
||||
goto error;
|
||||
}
|
||||
#endif // CONFIG_BT_BLE_LOG_SPI_OUT_ENABLED
|
||||
|
||||
btdm_cfg_mask = btdm_config_mask_load();
|
||||
|
||||
err = btdm_controller_init(btdm_cfg_mask, cfg);
|
||||
@@ -1716,26 +1646,12 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg)
|
||||
goto error;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_BT_BLUEDROID_ENABLED
|
||||
bt_stack_enableSecCtrlVsCmd(true);
|
||||
#endif // CONFIG_BT_BLUEDROID_ENABLED
|
||||
#if defined(CONFIG_BT_NIMBLE_ENABLED) || defined(CONFIG_BT_BLUEDROID_ENABLED)
|
||||
bt_stack_enableCoexVsCmd(true);
|
||||
scan_stack_enableAdvFlowCtrlVsCmd(true);
|
||||
adv_stack_enableClearLegacyAdvVsCmd(true);
|
||||
advFilter_stack_enableDupExcListVsCmd(true);
|
||||
#endif // (CONFIG_BT_NIMBLE_ENABLED) || (CONFIG_BT_BLUEDROID_ENABLED)
|
||||
|
||||
btdm_controller_status = ESP_BT_CONTROLLER_STATUS_INITED;
|
||||
|
||||
return ESP_OK;
|
||||
|
||||
error:
|
||||
|
||||
#if CONFIG_BT_BLE_LOG_SPI_OUT_ENABLED
|
||||
ble_log_spi_out_deinit();
|
||||
#endif // CONFIG_BT_BLE_LOG_SPI_OUT_ENABLED
|
||||
|
||||
bt_controller_deinit_internal();
|
||||
|
||||
return err;
|
||||
@@ -1747,30 +1663,17 @@ esp_err_t esp_bt_controller_deinit(void)
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
#if CONFIG_BT_BLE_LOG_SPI_OUT_ENABLED
|
||||
ble_log_spi_out_deinit();
|
||||
#endif // CONFIG_BT_BLE_LOG_SPI_OUT_ENABLED
|
||||
|
||||
btdm_controller_deinit();
|
||||
|
||||
bt_controller_deinit_internal();
|
||||
|
||||
#ifdef CONFIG_BT_BLUEDROID_ENABLED
|
||||
bt_stack_enableSecCtrlVsCmd(false);
|
||||
#endif // CONFIG_BT_BLUEDROID_ENABLED
|
||||
#if defined(CONFIG_BT_NIMBLE_ENABLED) || defined(CONFIG_BT_BLUEDROID_ENABLED)
|
||||
bt_stack_enableCoexVsCmd(false);
|
||||
scan_stack_enableAdvFlowCtrlVsCmd(false);
|
||||
adv_stack_enableClearLegacyAdvVsCmd(false);
|
||||
advFilter_stack_enableDupExcListVsCmd(false);
|
||||
#endif // (CONFIG_BT_NIMBLE_ENABLED) || (CONFIG_BT_BLUEDROID_ENABLED)
|
||||
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
// deinit low power control resources
|
||||
static void btdm_low_power_mode_deinit(void)
|
||||
static void bt_controller_deinit_internal(void)
|
||||
{
|
||||
periph_module_disable(PERIPH_BT_MODULE);
|
||||
|
||||
#ifdef CONFIG_PM_ENABLE
|
||||
if (!s_btdm_allow_light_sleep) {
|
||||
esp_pm_lock_delete(s_light_sleep_pm_lock);
|
||||
@@ -1791,16 +1694,6 @@ static void btdm_low_power_mode_deinit(void)
|
||||
s_pm_lock_acquired = false;
|
||||
#endif
|
||||
|
||||
btdm_lpcycle_us = 0;
|
||||
btdm_controller_set_sleep_mode(BTDM_MODEM_SLEEP_MODE_NONE);
|
||||
}
|
||||
|
||||
static void bt_controller_deinit_internal(void)
|
||||
{
|
||||
periph_module_disable(PERIPH_BT_MODULE);
|
||||
|
||||
btdm_low_power_mode_deinit();
|
||||
|
||||
if (s_wakeup_req_sem) {
|
||||
semphr_delete_wrapper(s_wakeup_req_sem);
|
||||
s_wakeup_req_sem = NULL;
|
||||
@@ -1813,6 +1706,9 @@ static void bt_controller_deinit_internal(void)
|
||||
|
||||
btdm_controller_status = ESP_BT_CONTROLLER_STATUS_IDLE;
|
||||
|
||||
btdm_lpcycle_us = 0;
|
||||
btdm_controller_set_sleep_mode(BTDM_MODEM_SLEEP_MODE_NONE);
|
||||
|
||||
esp_bt_power_domain_off();
|
||||
|
||||
esp_phy_modem_deinit();
|
||||
@@ -1923,7 +1819,6 @@ esp_err_t esp_bt_controller_disable(void)
|
||||
while (!btdm_power_state_active()) {
|
||||
esp_rom_delay_us(1000);
|
||||
}
|
||||
async_wakeup_request_end(BTDM_ASYNC_WAKEUP_REQ_CTRL_DISA);
|
||||
}
|
||||
|
||||
btdm_controller_disable();
|
||||
@@ -2036,7 +1931,7 @@ esp_err_t esp_bredr_sco_datapath_set(esp_sco_data_path_t data_path)
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
esp_err_t esp_ble_scan_duplicate_list_flush(void)
|
||||
esp_err_t esp_ble_scan_dupilcate_list_flush(void)
|
||||
{
|
||||
if (btdm_controller_status != ESP_BT_CONTROLLER_STATUS_ENABLED) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
@@ -2045,11 +1940,6 @@ esp_err_t esp_ble_scan_duplicate_list_flush(void)
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
esp_err_t esp_ble_scan_dupilcate_list_flush(void)
|
||||
{
|
||||
return esp_ble_scan_duplicate_list_flush();
|
||||
}
|
||||
|
||||
/**
|
||||
* This function re-write controller's function,
|
||||
* As coredump can not show parameters in function which is in a .a file.
|
||||
|
||||
@@ -90,7 +90,7 @@ menu "HCI Config"
|
||||
config BT_LE_HCI_TRANS_TASK_STACK_SIZE
|
||||
int "HCI transport task stack size"
|
||||
depends on !BT_LE_HCI_INTERFACE_USE_RAM
|
||||
default 2048
|
||||
default 1024
|
||||
help
|
||||
This configures stack size of hci transport task
|
||||
endmenu
|
||||
@@ -109,100 +109,86 @@ menuconfig BT_LE_50_FEATURE_SUPPORT
|
||||
help
|
||||
Enable BLE 5 feature
|
||||
|
||||
if BT_LE_50_FEATURE_SUPPORT
|
||||
config BT_LE_LL_CFG_FEAT_LE_2M_PHY
|
||||
bool "Enable 2M Phy"
|
||||
depends on BT_LE_50_FEATURE_SUPPORT
|
||||
config BT_LE_LL_CFG_FEAT_LE_2M_PHY
|
||||
bool "Enable 2M Phy"
|
||||
depends on BT_LE_50_FEATURE_SUPPORT
|
||||
default y
|
||||
help
|
||||
Enable 2M-PHY
|
||||
|
||||
config BT_LE_LL_CFG_FEAT_LE_CODED_PHY
|
||||
bool "Enable coded Phy"
|
||||
depends on BT_LE_50_FEATURE_SUPPORT
|
||||
default y
|
||||
help
|
||||
Enable coded-PHY
|
||||
|
||||
config BT_LE_EXT_ADV
|
||||
bool "Enable extended advertising"
|
||||
depends on BT_LE_50_FEATURE_SUPPORT
|
||||
default y
|
||||
help
|
||||
Enable this option to do extended advertising. Extended advertising
|
||||
will be supported from BLE 5.0 onwards.
|
||||
|
||||
if BT_LE_EXT_ADV
|
||||
config BT_LE_MAX_EXT_ADV_INSTANCES
|
||||
int "Maximum number of extended advertising instances."
|
||||
range 0 4
|
||||
default 1
|
||||
depends on BT_LE_EXT_ADV
|
||||
help
|
||||
Change this option to set maximum number of extended advertising
|
||||
instances. Minimum there is always one instance of
|
||||
advertising. Enter how many more advertising instances you
|
||||
want.
|
||||
Each extended advertising instance will take about 0.5k DRAM.
|
||||
|
||||
config BT_LE_EXT_ADV_MAX_SIZE
|
||||
int "Maximum length of the advertising data."
|
||||
range 0 1650
|
||||
default 1650
|
||||
depends on BT_LE_EXT_ADV
|
||||
help
|
||||
Defines the length of the extended adv data. The value should not
|
||||
exceed 1650.
|
||||
|
||||
config BT_LE_ENABLE_PERIODIC_ADV
|
||||
bool "Enable periodic advertisement."
|
||||
default y
|
||||
depends on BT_LE_EXT_ADV
|
||||
help
|
||||
Enable this option to start periodic advertisement.
|
||||
|
||||
config BT_LE_PERIODIC_ADV_SYNC_TRANSFER
|
||||
bool "Enable Transfer Sync Events"
|
||||
depends on BT_LE_ENABLE_PERIODIC_ADV
|
||||
default y
|
||||
help
|
||||
Enable 2M-PHY
|
||||
This enables controller transfer periodic sync events to host
|
||||
|
||||
config BT_LE_LL_CFG_FEAT_LE_CODED_PHY
|
||||
bool "Enable coded Phy"
|
||||
depends on BT_LE_50_FEATURE_SUPPORT
|
||||
default y
|
||||
help
|
||||
Enable coded-PHY
|
||||
|
||||
config BT_LE_EXT_ADV
|
||||
bool "Enable extended advertising"
|
||||
depends on BT_LE_50_FEATURE_SUPPORT
|
||||
default y
|
||||
help
|
||||
Enable this option to do extended advertising. Extended advertising
|
||||
will be supported from BLE 5.0 onwards.
|
||||
|
||||
if BT_LE_EXT_ADV
|
||||
config BT_LE_MAX_EXT_ADV_INSTANCES
|
||||
int "Maximum number of extended advertising instances."
|
||||
range 0 4
|
||||
default 1
|
||||
depends on BT_LE_EXT_ADV
|
||||
help
|
||||
Change this option to set maximum number of extended advertising
|
||||
instances. Minimum there is always one instance of
|
||||
advertising. Enter how many more advertising instances you
|
||||
want.
|
||||
Each extended advertising instance will take about 0.5k DRAM.
|
||||
|
||||
config BT_LE_EXT_ADV_MAX_SIZE
|
||||
int "Maximum length of the advertising data."
|
||||
range 0 1650
|
||||
default 1650
|
||||
depends on BT_LE_EXT_ADV
|
||||
help
|
||||
Defines the length of the extended adv data. The value should not
|
||||
exceed 1650.
|
||||
|
||||
config BT_LE_ENABLE_PERIODIC_ADV
|
||||
bool "Enable periodic advertisement."
|
||||
default y
|
||||
depends on BT_LE_EXT_ADV
|
||||
help
|
||||
Enable this option to start periodic advertisement.
|
||||
|
||||
config BT_LE_PERIODIC_ADV_SYNC_TRANSFER
|
||||
bool "Enable Transfer Sync Events"
|
||||
depends on BT_LE_ENABLE_PERIODIC_ADV
|
||||
default y
|
||||
help
|
||||
This enables controller transfer periodic sync events to host
|
||||
endif
|
||||
|
||||
config BT_LE_EXT_SCAN
|
||||
bool "Enable extended scanning"
|
||||
depends on BT_LE_50_FEATURE_SUPPORT && BT_LE_ROLE_OBSERVER_ENABLE
|
||||
default y
|
||||
help
|
||||
Enable this option to do extended scanning.
|
||||
|
||||
config BT_LE_ENABLE_PERIODIC_SYNC
|
||||
bool "Enable periodic sync"
|
||||
default y
|
||||
depends on BT_LE_EXT_SCAN
|
||||
help
|
||||
Enable this option to receive periodic advertisement.
|
||||
|
||||
if BT_LE_ENABLE_PERIODIC_SYNC
|
||||
config BT_LE_MAX_PERIODIC_SYNCS
|
||||
int "Maximum number of periodic advertising syncs"
|
||||
range 0 3
|
||||
default 1 if BT_LE_ENABLE_PERIODIC_ADV
|
||||
default 0
|
||||
help
|
||||
Set this option to set the upper limit for number of periodic sync
|
||||
connections. This should be less than maximum connections allowed by
|
||||
controller.
|
||||
|
||||
config BT_LE_MAX_PERIODIC_ADVERTISER_LIST
|
||||
int "Maximum number of periodic advertiser list"
|
||||
range 1 5
|
||||
default 5
|
||||
help
|
||||
Set this option to set the upper limit for number of periodic advertiser list.
|
||||
endif
|
||||
endif
|
||||
|
||||
config BT_LE_MAX_PERIODIC_SYNCS
|
||||
int "Maximum number of periodic advertising syncs"
|
||||
depends on BT_LE_50_FEATURE_SUPPORT && !BT_NIMBLE_ENABLED
|
||||
|
||||
range 0 3
|
||||
default 1 if BT_LE_ENABLE_PERIODIC_ADV
|
||||
default 0
|
||||
help
|
||||
Set this option to set the upper limit for number of periodic sync
|
||||
connections. This should be less than maximum connections allowed by
|
||||
controller.
|
||||
|
||||
config BT_LE_MAX_PERIODIC_ADVERTISER_LIST
|
||||
int "Maximum number of periodic advertiser list"
|
||||
depends on BT_LE_50_FEATURE_SUPPORT && !BT_NIMBLE_ENABLED
|
||||
range 1 5
|
||||
default 5
|
||||
help
|
||||
Set this option to set the upper limit for number of periodic advertiser list.
|
||||
|
||||
menu "Memory Settings"
|
||||
depends on !BT_NIMBLE_ENABLED
|
||||
|
||||
@@ -308,15 +294,6 @@ config BT_LE_CONTROLLER_LOG_DUMP_ONLY
|
||||
help
|
||||
Only operate in dump mode
|
||||
|
||||
config BT_LE_CONTROLLER_LOG_SPI_OUT_ENABLED
|
||||
bool "Output ble controller logs to SPI bus (Experimental)"
|
||||
depends on BT_LE_CONTROLLER_LOG_ENABLED
|
||||
depends on !BT_LE_CONTROLLER_LOG_DUMP_ONLY
|
||||
select BT_BLE_LOG_SPI_OUT_ENABLED
|
||||
default n
|
||||
help
|
||||
Output ble controller logs to SPI bus
|
||||
|
||||
config BT_LE_CONTROLLER_LOG_STORAGE_ENABLE
|
||||
bool "Store ble controller logs to flash(Experimental)"
|
||||
depends on !BT_LE_CONTROLLER_LOG_DUMP_ONLY
|
||||
@@ -356,19 +333,6 @@ config BT_LE_LOG_HCI_BUF_SIZE
|
||||
help
|
||||
Configure the size of the BLE HCI LOG buffer.
|
||||
|
||||
config BT_LE_CONTROLLER_LOG_WRAP_PANIC_HANDLER_ENABLE
|
||||
bool "Enable wrap panic handler"
|
||||
depends on BT_LE_CONTROLLER_LOG_ENABLED
|
||||
default n
|
||||
help
|
||||
Wrap esp_panic_handler to get controller logs when PC pointer exception crashes.
|
||||
|
||||
config BT_LE_CONTROLLER_LOG_TASK_WDT_USER_HANDLER_ENABLE
|
||||
bool "Enable esp_task_wdt_isr_user_handler implementation"
|
||||
depends on BT_LE_CONTROLLER_LOG_ENABLED
|
||||
default n
|
||||
help
|
||||
Implement esp_task_wdt_isr_user_handler to get controller logs when task wdt issue is triggered.
|
||||
config BT_LE_LL_RESOLV_LIST_SIZE
|
||||
int "BLE LL Resolving list size"
|
||||
range 1 5
|
||||
@@ -424,7 +388,7 @@ config BT_LE_CRYPTO_STACK_MBEDTLS
|
||||
|
||||
config BT_LE_WHITELIST_SIZE
|
||||
int "BLE white list size"
|
||||
range 1 31
|
||||
range 1 15
|
||||
default 12
|
||||
depends on !BT_NIMBLE_ENABLED
|
||||
|
||||
@@ -445,23 +409,6 @@ config BT_LE_LL_SCA
|
||||
help
|
||||
Sleep clock accuracy of our device (in ppm)
|
||||
|
||||
config BT_LE_LL_PEER_SCA_SET_ENABLE
|
||||
bool "Enable to set constant peer SCA"
|
||||
default n
|
||||
help
|
||||
Enable setting of constant peer SCA, use this if peer device has SCA larger than 500 PPM.
|
||||
Enable this option, the controller will always use BT_LE_LL_PEER_SCA as the peer SCA value
|
||||
to calculate the window widening instead of the value received from peer device.
|
||||
|
||||
|
||||
config BT_LE_LL_PEER_SCA
|
||||
int "Constant peer sleep clock accuracy value"
|
||||
range 0 10000
|
||||
depends on BT_LE_LL_PEER_SCA_SET_ENABLE
|
||||
default 0
|
||||
help
|
||||
Set the sleep clock accuracy of peer device
|
||||
|
||||
config BT_LE_MAX_CONNECTIONS
|
||||
int "Maximum number of concurrent connections"
|
||||
depends on !BT_NIMBLE_ENABLED
|
||||
@@ -576,10 +523,6 @@ config BT_LE_TX_CCA_ENABLED
|
||||
help
|
||||
Enable CCA feature to cancel sending the packet if the signal power is stronger than CCA threshold.
|
||||
|
||||
config BT_LE_DTM_ENABLED
|
||||
bool "Enable Direct Test Mode (DTM) feature"
|
||||
default n
|
||||
|
||||
config BT_LE_CCA_RSSI_THRESH
|
||||
int "CCA RSSI threshold value"
|
||||
depends on BT_LE_TX_CCA_ENABLED
|
||||
@@ -588,10 +531,6 @@ config BT_LE_CCA_RSSI_THRESH
|
||||
help
|
||||
Power threshold of CCA in unit of -1 dBm.
|
||||
|
||||
config BT_LE_FEAT_LL_ENCRYPTION
|
||||
bool "Enable controller ACL encryption"
|
||||
default y
|
||||
|
||||
config BT_LE_ROLE_CENTROL_ENABLE
|
||||
bool "Enable BLE Centrol role function"
|
||||
depends on !BT_NIMBLE_ENABLED
|
||||
@@ -678,66 +617,3 @@ config BT_LE_DFT_TX_POWER_LEVEL_DBM_EFF
|
||||
default 18 if BT_LE_DFT_TX_POWER_LEVEL_P18
|
||||
default 20 if BT_LE_DFT_TX_POWER_LEVEL_P20
|
||||
default 0
|
||||
|
||||
config BT_CTRL_RUN_IN_FLASH_ONLY
|
||||
bool "Reduce BLE IRAM usage (READ DOCS FIRST) (EXPERIMENTAL)"
|
||||
default n
|
||||
help
|
||||
Move most IRAM into flash. This will increase the usage of flash and reduce ble performance.
|
||||
Because the code is moved to the flash, the execution speed of the code is reduced.
|
||||
To have a small impact on performance, you need to enable flash suspend (SPI_FLASH_AUTO_SUSPEND).
|
||||
|
||||
- Only one Tx-Rx can be performed in each connection interval. Therefore, reduce the connection interval
|
||||
as much as possible to improve the throughput. If you want higher connection performance, you can
|
||||
enable BT_LE_PLACE_CONN_RELATED_INTO_IRAM to put the connection-related code into iram.
|
||||
- For HCI_LE_Extended_Create_Connection command, only 1M phy's connection parameters will be applied.
|
||||
Other phys' will be ignored.
|
||||
- For extended scanning, we may be unable to receive the extended adv with 300us MAFS.
|
||||
|
||||
config BT_LE_PLACE_CONN_RELATED_INTO_IRAM
|
||||
bool "Place the connection-related code into IRAM"
|
||||
depends on BT_CTRL_RUN_IN_FLASH_ONLY
|
||||
default n
|
||||
|
||||
config BT_LE_PLACE_SLEEP_RELATED_INTO_IRAM
|
||||
bool
|
||||
depends on BT_CTRL_RUN_IN_FLASH_ONLY && BT_LE_SLEEP_ENABLE
|
||||
default y
|
||||
|
||||
config BT_LE_CTRL_CHECK_CONNECT_IND_ACCESS_ADDRESS
|
||||
bool "Enable enhanced Access Address check in CONNECT_IND"
|
||||
default n
|
||||
help
|
||||
Enabling this option will add stricter verification of the Access Address in the CONNECT_IND PDU.
|
||||
This improves security by ensuring that only connection requests with valid Access Addresses are accepted.
|
||||
If disabled, only basic checks are applied, improving compatibility.
|
||||
|
||||
menu "BLE disconnects when Instant Passed (0x28) occurs"
|
||||
config BT_LE_CTRL_LLCP_CONN_UPDATE
|
||||
bool "BLE ACL connection update procedure"
|
||||
default n
|
||||
help
|
||||
If this option is enabled, Controller will terminate the connection
|
||||
when Instant Passed (0x28) error occurs during connection update procedure.
|
||||
|
||||
config BT_LE_CTRL_LLCP_CHAN_MAP_UPDATE
|
||||
bool "BLE ACL channel map update procedure"
|
||||
default n
|
||||
help
|
||||
If this option is enabled, Controller will terminate the connection
|
||||
when Instant Passed (0x28) error occurs in channel map update procedure.
|
||||
|
||||
config BT_LE_CTRL_LLCP_PHY_UPDATE
|
||||
bool "BLE ACL PHY update procedure"
|
||||
default n
|
||||
help
|
||||
If this option is enabled, Controller will terminate the connection
|
||||
when Instant Passed (0x28) error occurs in PHY update procedure.
|
||||
endmenu
|
||||
|
||||
config BT_CTRL_SCAN_BACKOFF_UPPERLIMITMAX
|
||||
int "The value of upperlimitmax during scan backoff procedure"
|
||||
range 1 256
|
||||
default 32
|
||||
help
|
||||
The value of upperlimitmax needs to be a power of 2.
|
||||
|
||||
@@ -1,71 +0,0 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "sdkconfig.h"
|
||||
#include "esp_bt_cfg.h"
|
||||
|
||||
/* External functions or variables
|
||||
************************************************************************
|
||||
*/
|
||||
#if (CONFIG_BT_NIMBLE_ENABLED || CONFIG_BT_BLUEDROID_ENABLED)
|
||||
void scan_stack_enableAdvFlowCtrlVsCmd(bool en);
|
||||
void adv_stack_enableClearLegacyAdvVsCmd(bool en);
|
||||
void chanSel_stack_enableSetCsaVsCmd(bool en);
|
||||
void hci_stack_enableSetVsEvtMaskVsCmd(bool en);
|
||||
|
||||
void adv_stack_enableScanReqRxdVsEvent(bool en);
|
||||
void conn_stack_enableChanMapUpdCompVsEvent(bool en);
|
||||
void sleep_stack_enableWakeupVsEvent(bool en);
|
||||
#endif // (CONFIG_BT_NIMBLE_ENABLED || CONFIG_BT_BLUEDROID_ENABLED)
|
||||
|
||||
/* Local functions definition
|
||||
***************************************************************************
|
||||
*/
|
||||
#if (CONFIG_BT_NIMBLE_ENABLED || CONFIG_BT_BLUEDROID_ENABLED)
|
||||
void ble_stack_enableVsCmds(bool en)
|
||||
{
|
||||
#if DEFAULT_BT_LE_ROLE_BROADCASTER
|
||||
adv_stack_enableClearLegacyAdvVsCmd(en);
|
||||
#endif // DEFAULT_BT_LE_ROLE_BROADCASTER
|
||||
|
||||
#if DEFAULT_BT_LE_ROLE_OBSERVER
|
||||
scan_stack_enableAdvFlowCtrlVsCmd(en);
|
||||
#endif // DEFAULT_BT_LE_ROLE_OBSERVER
|
||||
|
||||
chanSel_stack_enableSetCsaVsCmd(en);
|
||||
hci_stack_enableSetVsEvtMaskVsCmd(en);
|
||||
}
|
||||
|
||||
void ble_stack_enableVsEvents(bool en)
|
||||
{
|
||||
#if DEFAULT_BT_LE_ROLE_BROADCASTER
|
||||
adv_stack_enableScanReqRxdVsEvent(en);
|
||||
#endif // DEFAULT_BT_LE_ROLE_BROADCASTER
|
||||
conn_stack_enableChanMapUpdCompVsEvent(en);
|
||||
#if CONFIG_BT_LE_SLEEP_ENABLE
|
||||
sleep_stack_enableWakeupVsEvent(en);
|
||||
#endif // CONFIG_BT_LE_SLEEP_ENABLE
|
||||
}
|
||||
#endif // (CONFIG_BT_NIMBLE_ENABLED || CONFIG_BT_BLUEDROID_ENABLED)
|
||||
|
||||
int ble_stack_enable(void)
|
||||
{
|
||||
#if (CONFIG_BT_NIMBLE_ENABLED || CONFIG_BT_BLUEDROID_ENABLED)
|
||||
ble_stack_enableVsCmds(true);
|
||||
ble_stack_enableVsEvents(true);
|
||||
#endif // (CONFIG_BT_NIMBLE_ENABLED || CONFIG_BT_BLUEDROID_ENABLED)
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void ble_stack_disable(void)
|
||||
{
|
||||
#if (CONFIG_BT_NIMBLE_ENABLED || CONFIG_BT_BLUEDROID_ENABLED)
|
||||
ble_stack_enableVsEvents(false);
|
||||
ble_stack_enableVsCmds(false);
|
||||
#endif // (CONFIG_BT_NIMBLE_ENABLED || CONFIG_BT_BLUEDROID_ENABLED)
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
#ifndef _BLE_PRIV_H_
|
||||
#define _BLE_PRIV_H_
|
||||
|
||||
int ble_stack_enable(void);
|
||||
|
||||
void ble_stack_disable(void);
|
||||
|
||||
#endif // _BLE_PRIV_H_
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -35,7 +35,6 @@
|
||||
#include "os/endian.h"
|
||||
|
||||
#include "esp_bt.h"
|
||||
#include "ble_priv.h"
|
||||
#include "esp_intr_alloc.h"
|
||||
#include "esp_sleep.h"
|
||||
#include "esp_pm.h"
|
||||
@@ -45,7 +44,6 @@
|
||||
#include "soc/syscon_reg.h"
|
||||
#include "soc/modem_clkrst_reg.h"
|
||||
#include "esp_private/periph_ctrl.h"
|
||||
#include "esp_private/esp_clk_tree_common.h"
|
||||
#include "bt_osi_mem.h"
|
||||
|
||||
#if CONFIG_FREERTOS_USE_TICKLESS_IDLE
|
||||
@@ -66,10 +64,6 @@
|
||||
#include "hal/efuse_ll.h"
|
||||
#include "soc/rtc.h"
|
||||
|
||||
#if CONFIG_BT_BLE_LOG_SPI_OUT_ENABLED
|
||||
#include "ble_log/ble_log_spi_out.h"
|
||||
#endif // CONFIG_BT_BLE_LOG_SPI_OUT_ENABLED
|
||||
|
||||
/* Macro definition
|
||||
************************************************************************
|
||||
*/
|
||||
@@ -118,12 +112,7 @@ struct ext_funcs_t {
|
||||
};
|
||||
|
||||
#if CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
|
||||
typedef void (*interface_func_t) (uint32_t len, const uint8_t *addr, uint32_t len_append, const uint8_t *addr_append, uint32_t flag);
|
||||
|
||||
enum {
|
||||
BLE_LOG_INTERFACE_FLAG_CONTINUE = 0,
|
||||
BLE_LOG_INTERFACE_FLAG_END,
|
||||
};
|
||||
typedef void (*interface_func_t) (uint32_t len, const uint8_t*addr, bool end);
|
||||
#endif // CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
|
||||
|
||||
/* External functions or variables
|
||||
@@ -132,12 +121,10 @@ enum {
|
||||
extern int ble_osi_coex_funcs_register(struct osi_coex_funcs_t *coex_funcs);
|
||||
extern int ble_controller_init(esp_bt_controller_config_t *cfg);
|
||||
#if CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
|
||||
extern int ble_log_init_async(interface_func_t interface, bool task_create, uint8_t buffers, uint32_t *bufs_size);
|
||||
extern int ble_log_init_async(interface_func_t bt_controller_log_interface, bool task_create, uint8_t buffers, uint32_t *bufs_size);
|
||||
extern int ble_log_deinit_async(void);
|
||||
extern int ble_log_init_simple(interface_func_t interface, void *handler);
|
||||
extern void ble_log_deinit_simple(void);
|
||||
extern void ble_log_async_output_dump_all(bool output);
|
||||
extern void esp_panic_handler_feed_wdts(void);
|
||||
extern void esp_panic_handler_reconfigure_wdts(uint32_t timeout_ms);
|
||||
#endif // CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
|
||||
extern int ble_controller_deinit(void);
|
||||
extern int ble_controller_enable(uint8_t mode);
|
||||
@@ -157,9 +144,6 @@ extern void r_ble_rtc_wake_up_state_clr(void);
|
||||
#if CONFIG_FREERTOS_USE_TICKLESS_IDLE
|
||||
extern void esp_ble_set_wakeup_overhead(uint32_t overhead);
|
||||
#endif /* CONFIG_FREERTOS_USE_TICKLESS_IDLE */
|
||||
#if CONFIG_BT_LE_LL_PEER_SCA_SET_ENABLE
|
||||
extern void r_ble_ll_customize_peer_sca_set(uint16_t peer_sca);
|
||||
#endif // CONFIG_BT_LE_LL_PEER_SCA_SET_ENABLE
|
||||
extern int os_msys_init(void);
|
||||
extern void os_msys_buf_free(void);
|
||||
extern int ble_sm_alg_gen_dhkey(const uint8_t *peer_pub_key_x,
|
||||
@@ -172,10 +156,6 @@ extern int ble_get_npl_element_info(esp_bt_controller_config_t *cfg, ble_npl_cou
|
||||
extern void bt_track_pll_cap(void);
|
||||
extern char *ble_controller_get_compile_version(void);
|
||||
extern const char *r_ble_controller_get_rom_compile_version(void);
|
||||
#if CONFIG_BT_CTRL_RUN_IN_FLASH_ONLY
|
||||
extern void ble_ll_supported_features_init(void);
|
||||
#endif //CONFIG_BT_CTRL_RUN_IN_FLASH_ONLY
|
||||
|
||||
#if CONFIG_BT_RELEASE_IRAM
|
||||
extern uint32_t _iram_bt_text_start;
|
||||
extern uint32_t _bss_bt_end;
|
||||
@@ -207,44 +187,57 @@ static int esp_ecc_gen_key_pair(uint8_t *pub, uint8_t *priv);
|
||||
static int esp_ecc_gen_dh_key(const uint8_t *peer_pub_key_x, const uint8_t *peer_pub_key_y,
|
||||
const uint8_t *our_priv_key, uint8_t *out_dhkey);
|
||||
#if CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
|
||||
#if !CONFIG_BT_LE_CONTROLLER_LOG_SPI_OUT_ENABLED
|
||||
static void esp_bt_controller_log_interface(uint32_t len, const uint8_t *addr, uint32_t len_append, const uint8_t *addr_append, uint32_t flag);
|
||||
#endif // !CONFIG_BT_LE_CONTROLLER_LOG_SPI_OUT_ENABLED
|
||||
static void esp_bt_controller_log_interface(uint32_t len, const uint8_t *addr, bool end);
|
||||
#if CONFIG_BT_LE_CONTROLLER_LOG_STORAGE_ENABLE
|
||||
static void esp_bt_ctrl_log_partition_get_and_erase_first_block(void);
|
||||
#endif // CONFIG_BT_LE_CONTROLLER_LOG_STORAGE_ENABLE
|
||||
#endif // #if CONFIG_BT_LE_CONTROLLER_LOG_STORAGE_ENABLE
|
||||
#endif // CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
|
||||
/* Local variable definition
|
||||
***************************************************************************
|
||||
*/
|
||||
#if (CONFIG_ESP32C2_REV_MIN_FULL < 200) && (!CONFIG_BT_CTRL_RUN_IN_FLASH_ONLY)
|
||||
void *g_ble_lll_rfmgmt_env_p;
|
||||
#endif
|
||||
/* Static variable declare */
|
||||
static DRAM_ATTR esp_bt_controller_status_t ble_controller_status = ESP_BT_CONTROLLER_STATUS_IDLE;
|
||||
|
||||
#if CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
|
||||
const static uint32_t log_bufs_size[] = {CONFIG_BT_LE_LOG_CTRL_BUF1_SIZE, CONFIG_BT_LE_LOG_HCI_BUF_SIZE, CONFIG_BT_LE_LOG_CTRL_BUF2_SIZE};
|
||||
static bool log_is_inited = false;
|
||||
enum log_out_mode {
|
||||
LOG_DUMP_MEMORY,
|
||||
LOG_ASYNC_OUT,
|
||||
LOG_STORAGE_TO_FLASH,
|
||||
};
|
||||
|
||||
esp_err_t esp_bt_controller_log_init(void)
|
||||
bool log_is_inited = false;
|
||||
#if CONFIG_BT_LE_CONTROLLER_LOG_DUMP_ONLY
|
||||
uint8_t log_output_mode = LOG_DUMP_MEMORY;
|
||||
#else
|
||||
#if CONFIG_BT_LE_CONTROLLER_LOG_STORAGE_ENABLE
|
||||
uint8_t log_output_mode = LOG_STORAGE_TO_FLASH;
|
||||
#else
|
||||
uint8_t log_output_mode = LOG_ASYNC_OUT;
|
||||
#endif // CONFIG_BT_LE_CONTROLLER_LOG_STORAGE_ENABLE
|
||||
#endif // CONFIG_BT_LE_CONTROLLER_LOG_DUMP_ONLY
|
||||
|
||||
void esp_bt_log_output_mode_set(uint8_t output_mode)
|
||||
{
|
||||
if (log_is_inited) {
|
||||
return ESP_OK;
|
||||
}
|
||||
log_output_mode = output_mode;
|
||||
}
|
||||
|
||||
#if CONFIG_BT_BLE_LOG_SPI_OUT_ENABLED
|
||||
if (ble_log_spi_out_init() != 0) {
|
||||
goto spi_out_init_failed;
|
||||
}
|
||||
#endif // CONFIG_BT_BLE_LOG_SPI_OUT_ENABLED
|
||||
uint8_t esp_bt_log_output_mode_get(void)
|
||||
{
|
||||
return log_output_mode;
|
||||
}
|
||||
|
||||
#if CONFIG_BT_LE_CONTROLLER_LOG_SPI_OUT_ENABLED
|
||||
if (ble_log_init_simple(ble_log_spi_out_ll_write, ble_log_spi_out_ll_log_ev_proc) != 0) {
|
||||
goto log_init_failed;
|
||||
}
|
||||
#else // !CONFIG_BT_LE_CONTROLLER_LOG_SPI_OUT_ENABLED
|
||||
esp_err_t esp_bt_controller_log_init(uint8_t log_output_mode)
|
||||
{
|
||||
esp_err_t ret = ESP_OK;
|
||||
interface_func_t bt_controller_log_interface;
|
||||
bt_controller_log_interface = esp_bt_controller_log_interface;
|
||||
bool task_create;
|
||||
uint8_t buffers = 0;
|
||||
|
||||
if (log_is_inited) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
#if CONFIG_BT_LE_CONTROLLER_LOG_CTRL_ENABLED
|
||||
buffers |= ESP_BLE_LOG_BUF_CONTROLLER;
|
||||
#endif // CONFIG_BT_LE_CONTROLLER_LOG_CTRL_ENABLED
|
||||
@@ -252,41 +245,34 @@ esp_err_t esp_bt_controller_log_init(void)
|
||||
buffers |= ESP_BLE_LOG_BUF_HCI;
|
||||
#endif // CONFIG_BT_LE_CONTROLLER_LOG_HCI_ENABLED
|
||||
|
||||
bool task_create = true;
|
||||
#if CONFIG_BT_LE_CONTROLLER_LOG_DUMP_ONLY
|
||||
task_create = false;
|
||||
#elif CONFIG_BT_LE_CONTROLLER_LOG_STORAGE_ENABLE
|
||||
esp_bt_ctrl_log_partition_get_and_erase_first_block();
|
||||
#endif // CONFIG_BT_LE_CONTROLLER_LOG_SPI_OUT_ENABLED
|
||||
|
||||
if (ble_log_init_async(esp_bt_controller_log_interface, task_create, buffers, (uint32_t *)log_bufs_size) != 0) {
|
||||
goto log_init_failed;
|
||||
switch (log_output_mode) {
|
||||
case LOG_DUMP_MEMORY:
|
||||
task_create = false;
|
||||
break;
|
||||
case LOG_ASYNC_OUT:
|
||||
case LOG_STORAGE_TO_FLASH:
|
||||
task_create = true;
|
||||
#if CONFIG_BT_LE_CONTROLLER_LOG_STORAGE_ENABLE
|
||||
if (log_output_mode == LOG_STORAGE_TO_FLASH) {
|
||||
esp_bt_ctrl_log_partition_get_and_erase_first_block();
|
||||
}
|
||||
#endif // CONFIG_BT_LE_CONTROLLER_LOG_STORAGE_ENABLE
|
||||
break;
|
||||
default:
|
||||
assert(0);
|
||||
}
|
||||
#endif // CONFIG_BT_LE_CONTROLLER_LOG_SPI_OUT_ENABLED
|
||||
|
||||
log_is_inited = true;
|
||||
return ESP_OK;
|
||||
ret = ble_log_init_async(bt_controller_log_interface, task_create, buffers, (uint32_t *)log_bufs_size);
|
||||
if (ret == ESP_OK) {
|
||||
log_is_inited = true;
|
||||
}
|
||||
|
||||
log_init_failed:
|
||||
#if CONFIG_BT_BLE_LOG_SPI_OUT_ENABLED
|
||||
ble_log_spi_out_deinit();
|
||||
spi_out_init_failed:
|
||||
#endif // CONFIG_BT_BLE_LOG_SPI_OUT_ENABLED
|
||||
return ESP_FAIL;
|
||||
return ret;
|
||||
}
|
||||
|
||||
void esp_bt_controller_log_deinit(void)
|
||||
void esp_bt_ontroller_log_deinit(void)
|
||||
{
|
||||
#if CONFIG_BT_BLE_LOG_SPI_OUT_ENABLED
|
||||
ble_log_spi_out_deinit();
|
||||
#endif // CONFIG_BT_BLE_LOG_SPI_OUT_ENABLED
|
||||
|
||||
#if CONFIG_BT_LE_CONTROLLER_LOG_SPI_OUT_ENABLED
|
||||
ble_log_deinit_simple();
|
||||
#else // !CONFIG_BT_LE_CONTROLLER_LOG_SPI_OUT_ENABLED
|
||||
ble_log_deinit_async();
|
||||
#endif // CONFIG_BT_LE_CONTROLLER_LOG_SPI_OUT_ENABLED
|
||||
|
||||
log_is_inited = false;
|
||||
}
|
||||
|
||||
@@ -379,13 +365,13 @@ void esp_bt_read_ctrl_log_from_flash(bool output)
|
||||
|
||||
portMUX_TYPE spinlock = portMUX_INITIALIZER_UNLOCKED;
|
||||
portENTER_CRITICAL_SAFE(&spinlock);
|
||||
esp_panic_handler_feed_wdts();
|
||||
esp_panic_handler_reconfigure_wdts(5000);
|
||||
ble_log_async_output_dump_all(true);
|
||||
esp_bt_controller_log_deinit();
|
||||
stop_write = true;
|
||||
esp_bt_ontroller_log_deinit();
|
||||
portEXIT_CRITICAL_SAFE(&spinlock);
|
||||
|
||||
buffer = (const uint8_t *)mapped_ptr;
|
||||
esp_panic_handler_feed_wdts();
|
||||
if (is_filled) {
|
||||
read_index = next_erase_index;
|
||||
} else {
|
||||
@@ -397,7 +383,7 @@ void esp_bt_read_ctrl_log_from_flash(bool output)
|
||||
while (read_index != write_index) {
|
||||
esp_rom_printf("%02x ", buffer[read_index]);
|
||||
if (print_len > max_print_len) {
|
||||
esp_panic_handler_feed_wdts();
|
||||
vTaskDelay(2);
|
||||
print_len = 0;
|
||||
}
|
||||
|
||||
@@ -405,72 +391,45 @@ void esp_bt_read_ctrl_log_from_flash(bool output)
|
||||
read_index = (read_index + 1) % MAX_STORAGE_SIZE;
|
||||
}
|
||||
esp_rom_printf(":DUMP_END]\r\n");
|
||||
portEXIT_CRITICAL_SAFE(&spinlock);
|
||||
esp_partition_munmap(mmap_handle);
|
||||
err = esp_bt_controller_log_init();
|
||||
err = esp_bt_controller_log_init(log_output_mode);
|
||||
assert(err == ESP_OK);
|
||||
|
||||
}
|
||||
#endif // CONFIG_BT_LE_CONTROLLER_LOG_STORAGE_ENABLE
|
||||
|
||||
#if !CONFIG_BT_LE_CONTROLLER_LOG_SPI_OUT_ENABLED
|
||||
static void esp_bt_controller_log_interface(uint32_t len, const uint8_t *addr, uint32_t len_append, const uint8_t *addr_append, uint32_t flag)
|
||||
static void esp_bt_controller_log_interface(uint32_t len, const uint8_t *addr, bool end)
|
||||
{
|
||||
bool end = (flag & BIT(BLE_LOG_INTERFACE_FLAG_END));
|
||||
if (log_output_mode == LOG_STORAGE_TO_FLASH) {
|
||||
#if CONFIG_BT_LE_CONTROLLER_LOG_STORAGE_ENABLE
|
||||
esp_bt_controller_log_storage(len, addr, end);
|
||||
#else // !CONFIG_BT_LE_CONTROLLER_LOG_STORAGE_ENABLE
|
||||
portMUX_TYPE spinlock = portMUX_INITIALIZER_UNLOCKED;
|
||||
portENTER_CRITICAL_SAFE(&spinlock);
|
||||
esp_panic_handler_feed_wdts();
|
||||
esp_bt_controller_log_storage(len, addr, end);
|
||||
#endif //CONFIG_BT_LE_CONTROLLER_LOG_STORAGE_ENABLE
|
||||
} else {
|
||||
for (int i = 0; i < len; i++) {
|
||||
esp_rom_printf("%02x ", addr[i]);
|
||||
}
|
||||
|
||||
if (len && addr) {
|
||||
for (int i = 0; i < len; i++) { esp_rom_printf("%02x ", addr[i]); }
|
||||
if (end) {
|
||||
esp_rom_printf("\n");
|
||||
}
|
||||
}
|
||||
if (len_append && addr_append) {
|
||||
for (int i = 0; i < len_append; i++) { esp_rom_printf("%02x ", addr_append[i]); }
|
||||
}
|
||||
if (end) { esp_rom_printf("\n"); }
|
||||
|
||||
portEXIT_CRITICAL_SAFE(&spinlock);
|
||||
#endif // CONFIG_BT_LE_CONTROLLER_LOG_STORAGE_ENABLE
|
||||
}
|
||||
#endif // !CONFIG_BT_LE_CONTROLLER_LOG_SPI_OUT_ENABLED
|
||||
|
||||
void esp_ble_controller_log_dump_all(bool output)
|
||||
{
|
||||
#if CONFIG_BT_BLE_LOG_SPI_OUT_ENABLED
|
||||
ble_log_spi_out_dump_all();
|
||||
#endif // CONFIG_BT_BLE_LOG_SPI_OUT_ENABLED
|
||||
|
||||
if (log_output_mode == LOG_STORAGE_TO_FLASH) {
|
||||
#if CONFIG_BT_LE_CONTROLLER_LOG_STORAGE_ENABLE
|
||||
esp_bt_read_ctrl_log_from_flash(output);
|
||||
#elif !CONFIG_BT_LE_CONTROLLER_LOG_SPI_OUT_ENABLED
|
||||
portMUX_TYPE spinlock = portMUX_INITIALIZER_UNLOCKED;
|
||||
portENTER_CRITICAL_SAFE(&spinlock);
|
||||
esp_panic_handler_feed_wdts();
|
||||
BT_ASSERT_PRINT("\r\n[DUMP_START:");
|
||||
ble_log_async_output_dump_all(output);
|
||||
BT_ASSERT_PRINT(":DUMP_END]\r\n");
|
||||
portEXIT_CRITICAL_SAFE(&spinlock);
|
||||
#endif
|
||||
esp_bt_read_ctrl_log_from_flash(output);
|
||||
#endif // CONFIG_BT_LE_CONTROLLER_LOG_STORAGE_ENABLE
|
||||
} else {
|
||||
portMUX_TYPE spinlock = portMUX_INITIALIZER_UNLOCKED;
|
||||
portENTER_CRITICAL_SAFE(&spinlock);
|
||||
esp_panic_handler_reconfigure_wdts(5000);
|
||||
BT_ASSERT_PRINT("\r\n[DUMP_START:");
|
||||
ble_log_async_output_dump_all(output);
|
||||
BT_ASSERT_PRINT(":DUMP_END]\r\n");
|
||||
portEXIT_CRITICAL_SAFE(&spinlock);
|
||||
}
|
||||
}
|
||||
|
||||
#if CONFIG_BT_LE_CONTROLLER_LOG_TASK_WDT_USER_HANDLER_ENABLE
|
||||
void esp_task_wdt_isr_user_handler(void)
|
||||
{
|
||||
esp_ble_controller_log_dump_all(true);
|
||||
}
|
||||
#endif // CONFIG_BT_LE_CONTROLLER_LOG_TASK_WDT_USER_HANDLER_ENABLE
|
||||
|
||||
#if CONFIG_BT_LE_CONTROLLER_LOG_WRAP_PANIC_HANDLER_ENABLE
|
||||
void __real_esp_panic_handler(void *info);
|
||||
void __wrap_esp_panic_handler (void *info)
|
||||
{
|
||||
esp_ble_controller_log_dump_all(true);
|
||||
__real_esp_panic_handler(info);
|
||||
}
|
||||
#endif // CONFIG_BT_LE_CONTROLLER_LOG_WRAP_PANIC_HANDLER_ENABLE
|
||||
#endif // CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
|
||||
|
||||
/* This variable tells if BLE is running */
|
||||
@@ -479,28 +438,10 @@ static bool s_ble_active = false;
|
||||
static DRAM_ATTR esp_pm_lock_handle_t s_pm_lock = NULL;
|
||||
#define BTDM_MIN_TIMER_UNCERTAINTY_US (200)
|
||||
#endif // CONFIG_PM_ENABLE
|
||||
#ifdef CONFIG_XTAL_FREQ_26
|
||||
#define MAIN_XTAL_FREQ_HZ (26000000)
|
||||
static DRAM_ATTR uint32_t s_bt_lpclk_freq = 40000;
|
||||
#else
|
||||
#define MAIN_XTAL_FREQ_HZ (40000000)
|
||||
static DRAM_ATTR uint32_t s_bt_lpclk_freq = 32000;
|
||||
#endif
|
||||
static DRAM_ATTR modem_clock_lpclk_src_t s_bt_lpclk_src = MODEM_CLOCK_LPCLK_SRC_INVALID;
|
||||
|
||||
#define BLE_RTC_DELAY_US (1800)
|
||||
|
||||
#define BLE_CONTROLLER_MALLOC_CAPS (MALLOC_CAP_INTERNAL|MALLOC_CAP_8BIT|MALLOC_CAP_DMA)
|
||||
void *malloc_ble_controller_mem(size_t size)
|
||||
{
|
||||
return heap_caps_malloc(size, BLE_CONTROLLER_MALLOC_CAPS);
|
||||
}
|
||||
|
||||
uint32_t get_ble_controller_free_heap_size(void)
|
||||
{
|
||||
return heap_caps_get_free_size(BLE_CONTROLLER_MALLOC_CAPS);
|
||||
}
|
||||
|
||||
static const struct osi_coex_funcs_t s_osi_coex_funcs_ro = {
|
||||
._magic = OSI_COEX_MAGIC_VALUE,
|
||||
._version = OSI_COEX_VERSION,
|
||||
@@ -593,12 +534,7 @@ static int esp_ecc_gen_dh_key(const uint8_t *peer_pub_key_x, const uint8_t *peer
|
||||
|
||||
static int esp_intr_alloc_wrapper(int source, int flags, intr_handler_t handler, void *arg, void **ret_handle_in)
|
||||
{
|
||||
#if CONFIG_BT_CTRL_RUN_IN_FLASH_ONLY
|
||||
int rc = esp_intr_alloc(source, flags, handler, arg, (intr_handle_t *)ret_handle_in);
|
||||
#else
|
||||
int rc = esp_intr_alloc(source, flags | ESP_INTR_FLAG_IRAM, handler, arg, (intr_handle_t *)ret_handle_in);
|
||||
#endif
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
@@ -610,6 +546,13 @@ static int esp_intr_free_wrapper(void **ret_handle)
|
||||
return rc;
|
||||
}
|
||||
|
||||
#if CONFIG_FREERTOS_USE_TICKLESS_IDLE
|
||||
void sleep_modem_light_sleep_overhead_set(uint32_t overhead)
|
||||
{
|
||||
esp_ble_set_wakeup_overhead(overhead);
|
||||
}
|
||||
#endif /* CONFIG_FREERTOS_USE_TICKLESS_IDLE */
|
||||
|
||||
modem_clock_lpclk_src_t esp_bt_get_lpclk_src(void)
|
||||
{
|
||||
return s_bt_lpclk_src;
|
||||
@@ -617,10 +560,6 @@ modem_clock_lpclk_src_t esp_bt_get_lpclk_src(void)
|
||||
|
||||
void esp_bt_set_lpclk_src(modem_clock_lpclk_src_t clk_src)
|
||||
{
|
||||
if (ble_controller_status != ESP_BT_CONTROLLER_STATUS_IDLE) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (clk_src >= MODEM_CLOCK_LPCLK_SRC_MAX) {
|
||||
return;
|
||||
}
|
||||
@@ -628,28 +567,7 @@ void esp_bt_set_lpclk_src(modem_clock_lpclk_src_t clk_src)
|
||||
s_bt_lpclk_src = clk_src;
|
||||
}
|
||||
|
||||
uint32_t esp_bt_get_lpclk_freq(void)
|
||||
{
|
||||
return s_bt_lpclk_freq;
|
||||
}
|
||||
|
||||
void esp_bt_set_lpclk_freq(uint32_t clk_freq)
|
||||
{
|
||||
if (ble_controller_status != ESP_BT_CONTROLLER_STATUS_IDLE) {
|
||||
return;
|
||||
}
|
||||
if (!clk_freq) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (MAIN_XTAL_FREQ_HZ % clk_freq) {
|
||||
return;
|
||||
}
|
||||
|
||||
s_bt_lpclk_freq = clk_freq;
|
||||
}
|
||||
|
||||
void controller_sleep_cb(uint32_t enable_tick, void *arg)
|
||||
IRAM_ATTR void controller_sleep_cb(uint32_t enable_tick, void *arg)
|
||||
{
|
||||
if (!s_ble_active) {
|
||||
return;
|
||||
@@ -662,23 +580,16 @@ void controller_sleep_cb(uint32_t enable_tick, void *arg)
|
||||
s_ble_active = false;
|
||||
}
|
||||
|
||||
void controller_wakeup_cb(void *arg)
|
||||
IRAM_ATTR void controller_wakeup_cb(void *arg)
|
||||
{
|
||||
if (s_ble_active) {
|
||||
return;
|
||||
}
|
||||
#ifdef CONFIG_PM_ENABLE
|
||||
esp_pm_config_t pm_config;
|
||||
esp_pm_lock_acquire(s_pm_lock);
|
||||
esp_pm_get_configuration(&pm_config);
|
||||
assert(esp_rom_get_cpu_ticks_per_us() == pm_config.max_freq_mhz);
|
||||
#endif //CONFIG_PM_ENABLE
|
||||
esp_phy_enable(PHY_MODEM_BT);
|
||||
if (s_bt_lpclk_src == MODEM_CLOCK_LPCLK_SRC_RC_SLOW) {
|
||||
uint32_t *clk_freq = (uint32_t *)arg;
|
||||
*clk_freq = esp_clk_tree_lp_slow_get_freq_hz(ESP_CLK_TREE_SRC_FREQ_PRECISION_CACHED) / 5;
|
||||
}
|
||||
// need to check if need to call pm lock here
|
||||
#ifdef CONFIG_PM_ENABLE
|
||||
esp_pm_lock_acquire(s_pm_lock);
|
||||
#endif //CONFIG_PM_ENABLE
|
||||
s_ble_active = true;
|
||||
}
|
||||
|
||||
@@ -709,7 +620,7 @@ esp_err_t controller_sleep_init(modem_clock_lpclk_src_t slow_clk_src)
|
||||
esp_sleep_enable_bt_wakeup();
|
||||
ESP_LOGW(NIMBLE_PORT_LOG_TAG, "Enable light sleep, the wake up source is BLE timer");
|
||||
|
||||
rc = esp_pm_register_inform_out_light_sleep_overhead_callback(esp_ble_set_wakeup_overhead);
|
||||
rc = esp_pm_register_inform_out_light_sleep_overhead_callback(sleep_modem_light_sleep_overhead_set);
|
||||
if (rc != ESP_OK) {
|
||||
goto error;
|
||||
}
|
||||
@@ -719,7 +630,7 @@ esp_err_t controller_sleep_init(modem_clock_lpclk_src_t slow_clk_src)
|
||||
error:
|
||||
#if CONFIG_FREERTOS_USE_TICKLESS_IDLE
|
||||
esp_sleep_disable_bt_wakeup();
|
||||
esp_pm_unregister_inform_out_light_sleep_overhead_callback(esp_ble_set_wakeup_overhead);
|
||||
esp_pm_unregister_inform_out_light_sleep_overhead_callback(sleep_modem_light_sleep_overhead_set);
|
||||
#endif /* CONFIG_FREERTOS_USE_TICKLESS_IDLE */
|
||||
/*lock should release first and then delete*/
|
||||
if (s_pm_lock != NULL) {
|
||||
@@ -736,7 +647,7 @@ void controller_sleep_deinit(void)
|
||||
r_ble_rtc_wake_up_state_clr();
|
||||
esp_sleep_disable_bt_wakeup();
|
||||
esp_sleep_pd_config(ESP_PD_DOMAIN_XTAL, ESP_PD_OPTION_AUTO);
|
||||
esp_pm_unregister_inform_out_light_sleep_overhead_callback(esp_ble_set_wakeup_overhead);
|
||||
esp_pm_unregister_inform_out_light_sleep_overhead_callback(sleep_modem_light_sleep_overhead_set);
|
||||
#endif // CONFIG_FREERTOS_USE_TICKLESS_IDLE
|
||||
#ifdef CONFIG_PM_ENABLE
|
||||
/*lock should release first and then delete*/
|
||||
@@ -755,7 +666,11 @@ static void esp_bt_rtc_slow_clk_select(modem_clock_lpclk_src_t slow_clk_src)
|
||||
SET_PERI_REG_BITS(MODEM_CLKRST_MODEM_LP_TIMER_CONF_REG, 1, 1, MODEM_CLKRST_LP_TIMER_SEL_XTAL_S);
|
||||
SET_PERI_REG_BITS(MODEM_CLKRST_MODEM_LP_TIMER_CONF_REG, 1, 0, MODEM_CLKRST_LP_TIMER_SEL_8M_S);
|
||||
SET_PERI_REG_BITS(MODEM_CLKRST_MODEM_LP_TIMER_CONF_REG, 1, 0, MODEM_CLKRST_LP_TIMER_SEL_RTC_SLOW_S);
|
||||
SET_PERI_REG_BITS(MODEM_CLKRST_MODEM_LP_TIMER_CONF_REG, MODEM_CLKRST_LP_TIMER_CLK_DIV_NUM, (MAIN_XTAL_FREQ_HZ/(5 * s_bt_lpclk_freq) - 1), MODEM_CLKRST_LP_TIMER_CLK_DIV_NUM_S);
|
||||
#ifdef CONFIG_XTAL_FREQ_26
|
||||
SET_PERI_REG_BITS(MODEM_CLKRST_MODEM_LP_TIMER_CONF_REG, MODEM_CLKRST_LP_TIMER_CLK_DIV_NUM, 129, MODEM_CLKRST_LP_TIMER_CLK_DIV_NUM_S);
|
||||
#else
|
||||
SET_PERI_REG_BITS(MODEM_CLKRST_MODEM_LP_TIMER_CONF_REG, MODEM_CLKRST_LP_TIMER_CLK_DIV_NUM, 249, MODEM_CLKRST_LP_TIMER_CLK_DIV_NUM_S);
|
||||
#endif // CONFIG_XTAL_FREQ_26
|
||||
break;
|
||||
case MODEM_CLOCK_LPCLK_SRC_EXT32K:
|
||||
ESP_LOGI(NIMBLE_PORT_LOG_TAG, "Using external 32.768 kHz XTAL as clock source");
|
||||
@@ -765,14 +680,6 @@ static void esp_bt_rtc_slow_clk_select(modem_clock_lpclk_src_t slow_clk_src)
|
||||
SET_PERI_REG_BITS(MODEM_CLKRST_MODEM_LP_TIMER_CONF_REG, 1, 0, MODEM_CLKRST_LP_TIMER_SEL_RTC_SLOW_S);
|
||||
SET_PERI_REG_BITS(MODEM_CLKRST_MODEM_LP_TIMER_CONF_REG, MODEM_CLKRST_LP_TIMER_CLK_DIV_NUM, 0, MODEM_CLKRST_LP_TIMER_CLK_DIV_NUM_S);
|
||||
break;
|
||||
case MODEM_CLOCK_LPCLK_SRC_RC_SLOW:
|
||||
ESP_LOGW(NIMBLE_PORT_LOG_TAG, "Using 136 kHz RC as clock source, use with caution as it may not maintain ACL or Sync process due to low clock accuracy!");
|
||||
SET_PERI_REG_BITS(MODEM_CLKRST_MODEM_LP_TIMER_CONF_REG, 1, 0, MODEM_CLKRST_LP_TIMER_SEL_XTAL32K_S);
|
||||
SET_PERI_REG_BITS(MODEM_CLKRST_MODEM_LP_TIMER_CONF_REG, 1, 0, MODEM_CLKRST_LP_TIMER_SEL_XTAL_S);
|
||||
SET_PERI_REG_BITS(MODEM_CLKRST_MODEM_LP_TIMER_CONF_REG, 1, 0, MODEM_CLKRST_LP_TIMER_SEL_8M_S);
|
||||
SET_PERI_REG_BITS(MODEM_CLKRST_MODEM_LP_TIMER_CONF_REG, 1, 1, MODEM_CLKRST_LP_TIMER_SEL_RTC_SLOW_S);
|
||||
SET_PERI_REG_BITS(MODEM_CLKRST_MODEM_LP_TIMER_CONF_REG, MODEM_CLKRST_LP_TIMER_CLK_DIV_NUM, 0, MODEM_CLKRST_LP_TIMER_CLK_DIV_NUM_S);
|
||||
break;
|
||||
default:
|
||||
ESP_LOGE(NIMBLE_PORT_LOG_TAG, "Unsupported slow clock");
|
||||
assert(0);
|
||||
@@ -788,26 +695,23 @@ static modem_clock_lpclk_src_t ble_rtc_clk_init(esp_bt_controller_config_t *cfg)
|
||||
#if CONFIG_BT_LE_LP_CLK_SRC_MAIN_XTAL
|
||||
s_bt_lpclk_src = MODEM_CLOCK_LPCLK_SRC_MAIN_XTAL;
|
||||
#else
|
||||
#if CONFIG_RTC_CLK_SRC_INT_RC
|
||||
s_bt_lpclk_src = MODEM_CLOCK_LPCLK_SRC_RC_SLOW;
|
||||
#elif CONFIG_RTC_CLK_SRC_EXT_OSC
|
||||
if (rtc_clk_slow_src_get() == SOC_RTC_SLOW_CLK_SRC_OSC_SLOW) {
|
||||
s_bt_lpclk_src = MODEM_CLOCK_LPCLK_SRC_EXT32K;
|
||||
} else {
|
||||
ESP_LOGW(NIMBLE_PORT_LOG_TAG, "32.768kHz XTAL not detected, fall back to main XTAL as Bluetooth sleep clock");
|
||||
s_bt_lpclk_src = MODEM_CLOCK_LPCLK_SRC_MAIN_XTAL;
|
||||
}
|
||||
#endif // CONFIG_RTC_CLK_SRC_INT_RC
|
||||
#endif // CONFIG_BT_LE_LP_CLK_SRC_MAIN_XTAL
|
||||
}
|
||||
|
||||
if (s_bt_lpclk_src == MODEM_CLOCK_LPCLK_SRC_EXT32K) {
|
||||
cfg->rtc_freq = 32768;
|
||||
} else if (s_bt_lpclk_src == MODEM_CLOCK_LPCLK_SRC_MAIN_XTAL) {
|
||||
cfg->rtc_freq = s_bt_lpclk_freq;
|
||||
} else if (s_bt_lpclk_src == MODEM_CLOCK_LPCLK_SRC_RC_SLOW) {
|
||||
cfg->rtc_freq = esp_clk_tree_lp_slow_get_freq_hz(ESP_CLK_TREE_SRC_FREQ_PRECISION_CACHED) / 5;
|
||||
cfg->ble_ll_sca = 3000;
|
||||
#ifdef CONFIG_XTAL_FREQ_26
|
||||
cfg->rtc_freq = 40000;
|
||||
#else
|
||||
cfg->rtc_freq = 32000;
|
||||
#endif // CONFIG_XTAL_FREQ_26
|
||||
}
|
||||
esp_bt_rtc_slow_clk_select(s_bt_lpclk_src);
|
||||
return s_bt_lpclk_src;
|
||||
@@ -839,8 +743,6 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg)
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* If we place the ble code into flash, don't need to initialize ROM. */
|
||||
#if !CONFIG_BT_CTRL_RUN_IN_FLASH_ONLY
|
||||
#if DEFAULT_BT_LE_50_FEATURE_SUPPORT || DEFAULT_BT_LE_ROLE_CENTROL || DEFAULT_BT_LE_ROLE_OBSERVER
|
||||
extern int esp_ble_rom_func_ptr_init_all(void);
|
||||
esp_ble_rom_func_ptr_init_all();
|
||||
@@ -849,7 +751,6 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg)
|
||||
extern int esp_ble_rom_func_ptr_init_legacy_adv_and_slave(void);
|
||||
esp_ble_rom_func_ptr_init_legacy_adv_and_slave();
|
||||
#endif
|
||||
#endif //!CONFIG_BT_CTRL_RUN_IN_FLASH_ONLY
|
||||
|
||||
/* Initialize the function pointers for OS porting */
|
||||
npl_freertos_funcs_init();
|
||||
@@ -899,26 +800,17 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg)
|
||||
#if CONFIG_SW_COEXIST_ENABLE
|
||||
coex_init();
|
||||
#endif
|
||||
|
||||
#if CONFIG_BT_CTRL_RUN_IN_FLASH_ONLY
|
||||
ble_ll_supported_features_init();
|
||||
#endif //CONFIG_BT_CTRL_RUN_IN_FLASH_ONLY
|
||||
|
||||
ret = ble_controller_init(cfg);
|
||||
if (ret != ESP_OK) {
|
||||
ESP_LOGW(NIMBLE_PORT_LOG_TAG, "ble_controller_init failed %d", ret);
|
||||
goto modem_deint;
|
||||
}
|
||||
|
||||
#if CONFIG_BT_LE_LL_PEER_SCA_SET_ENABLE
|
||||
r_ble_ll_customize_peer_sca_set(CONFIG_BT_LE_LL_PEER_SCA);
|
||||
#endif // CONFIG_BT_LE_LL_PEER_SCA_SET_ENABLE
|
||||
|
||||
ESP_LOGI(NIMBLE_PORT_LOG_TAG, "ble controller commit:[%s]", ble_controller_get_compile_version());
|
||||
ESP_LOGI(NIMBLE_PORT_LOG_TAG, "ble rom commit:[%s]", r_ble_controller_get_rom_compile_version());
|
||||
|
||||
#if CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
|
||||
ret = esp_bt_controller_log_init();
|
||||
ret = esp_bt_controller_log_init(log_output_mode);
|
||||
if (ret != ESP_OK) {
|
||||
ESP_LOGW(NIMBLE_PORT_LOG_TAG, "ble_controller_log_init failed %d", ret);
|
||||
goto controller_init_err;
|
||||
@@ -959,7 +851,7 @@ free_controller:
|
||||
controller_sleep_deinit();
|
||||
#if CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
|
||||
controller_init_err:
|
||||
esp_bt_controller_log_deinit();
|
||||
esp_bt_ontroller_log_deinit();
|
||||
#endif // CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
|
||||
ble_controller_deinit();
|
||||
modem_deint:
|
||||
@@ -988,7 +880,7 @@ esp_err_t esp_bt_controller_deinit(void)
|
||||
controller_sleep_deinit();
|
||||
|
||||
#if CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
|
||||
esp_bt_controller_log_deinit();
|
||||
esp_bt_ontroller_log_deinit();
|
||||
#endif // CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
|
||||
ble_controller_deinit();
|
||||
|
||||
@@ -1042,12 +934,6 @@ esp_err_t esp_bt_controller_enable(esp_bt_mode_t mode)
|
||||
#if CONFIG_SW_COEXIST_ENABLE
|
||||
coex_enable();
|
||||
#endif
|
||||
|
||||
if (ble_stack_enable() != 0) {
|
||||
ret = ESP_FAIL;
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (ble_controller_enable(mode) != 0) {
|
||||
ret = ESP_FAIL;
|
||||
goto error;
|
||||
@@ -1057,7 +943,6 @@ esp_err_t esp_bt_controller_enable(esp_bt_mode_t mode)
|
||||
return ESP_OK;
|
||||
|
||||
error:
|
||||
ble_stack_disable();
|
||||
#if CONFIG_SW_COEXIST_ENABLE
|
||||
coex_disable();
|
||||
#endif
|
||||
@@ -1080,7 +965,7 @@ esp_err_t esp_bt_controller_disable(void)
|
||||
if (ble_controller_disable() != 0) {
|
||||
return ESP_FAIL;
|
||||
}
|
||||
ble_stack_disable();
|
||||
|
||||
if (s_ble_active) {
|
||||
esp_phy_disable(PHY_MODEM_BT);
|
||||
#if CONFIG_PM_ENABLE
|
||||
@@ -1231,17 +1116,9 @@ esp_err_t esp_ble_tx_power_set(esp_ble_power_type_t power_type, esp_power_level_
|
||||
|
||||
switch (power_type) {
|
||||
case ESP_BLE_PWR_TYPE_DEFAULT:
|
||||
if (ble_txpwr_set(ESP_BLE_ENHANCED_PWR_TYPE_DEFAULT, 0, power_level) == 0) {
|
||||
stat = ESP_OK;
|
||||
}
|
||||
break;
|
||||
case ESP_BLE_PWR_TYPE_ADV:
|
||||
if (ble_txpwr_set(ESP_BLE_ENHANCED_PWR_TYPE_ADV, 0xFF, power_level) == 0) {
|
||||
stat = ESP_OK;
|
||||
}
|
||||
break;
|
||||
case ESP_BLE_PWR_TYPE_SCAN:
|
||||
if (ble_txpwr_set(ESP_BLE_ENHANCED_PWR_TYPE_SCAN, 0, power_level) == 0) {
|
||||
if (ble_txpwr_set(ESP_BLE_ENHANCED_PWR_TYPE_DEFAULT, 0, power_level) == 0) {
|
||||
stat = ESP_OK;
|
||||
}
|
||||
break;
|
||||
@@ -1271,13 +1148,9 @@ esp_err_t esp_ble_tx_power_set_enhanced(esp_ble_enhanced_power_type_t power_type
|
||||
esp_err_t stat = ESP_FAIL;
|
||||
switch (power_type) {
|
||||
case ESP_BLE_ENHANCED_PWR_TYPE_DEFAULT:
|
||||
if (ble_txpwr_set(ESP_BLE_ENHANCED_PWR_TYPE_DEFAULT, 0, power_level) == 0) {
|
||||
stat = ESP_OK;
|
||||
}
|
||||
break;
|
||||
case ESP_BLE_ENHANCED_PWR_TYPE_SCAN:
|
||||
case ESP_BLE_ENHANCED_PWR_TYPE_INIT:
|
||||
if (ble_txpwr_set(ESP_BLE_ENHANCED_PWR_TYPE_SCAN, 0, power_level) == 0) {
|
||||
if (ble_txpwr_set(ESP_BLE_ENHANCED_PWR_TYPE_DEFAULT, 0, power_level) == 0) {
|
||||
stat = ESP_OK;
|
||||
}
|
||||
break;
|
||||
@@ -1300,15 +1173,11 @@ esp_power_level_t esp_ble_tx_power_get(esp_ble_power_type_t power_type)
|
||||
int tx_level = 0;
|
||||
|
||||
switch (power_type) {
|
||||
case ESP_BLE_PWR_TYPE_ADV:
|
||||
case ESP_BLE_PWR_TYPE_SCAN:
|
||||
case ESP_BLE_PWR_TYPE_DEFAULT:
|
||||
tx_level = ble_txpwr_get(ESP_BLE_ENHANCED_PWR_TYPE_DEFAULT, 0);
|
||||
break;
|
||||
case ESP_BLE_PWR_TYPE_ADV:
|
||||
tx_level = ble_txpwr_get(ESP_BLE_ENHANCED_PWR_TYPE_ADV, 0);
|
||||
break;
|
||||
case ESP_BLE_PWR_TYPE_SCAN:
|
||||
tx_level = ble_txpwr_get(ESP_BLE_ENHANCED_PWR_TYPE_SCAN, 0);
|
||||
break;
|
||||
case ESP_BLE_PWR_TYPE_CONN_HDL0:
|
||||
case ESP_BLE_PWR_TYPE_CONN_HDL1:
|
||||
case ESP_BLE_PWR_TYPE_CONN_HDL2:
|
||||
@@ -1337,11 +1206,9 @@ esp_power_level_t esp_ble_tx_power_get_enhanced(esp_ble_enhanced_power_type_t po
|
||||
|
||||
switch (power_type) {
|
||||
case ESP_BLE_ENHANCED_PWR_TYPE_DEFAULT:
|
||||
tx_level = ble_txpwr_get(ESP_BLE_ENHANCED_PWR_TYPE_DEFAULT, 0);
|
||||
break;
|
||||
case ESP_BLE_ENHANCED_PWR_TYPE_SCAN:
|
||||
case ESP_BLE_ENHANCED_PWR_TYPE_INIT:
|
||||
tx_level = ble_txpwr_get(ESP_BLE_ENHANCED_PWR_TYPE_SCAN, 0);
|
||||
tx_level = ble_txpwr_get(ESP_BLE_ENHANCED_PWR_TYPE_DEFAULT, 0);
|
||||
break;
|
||||
case ESP_BLE_ENHANCED_PWR_TYPE_ADV:
|
||||
case ESP_BLE_ENHANCED_PWR_TYPE_CONN:
|
||||
|
||||
@@ -1,320 +0,0 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
#include "esp_bt_cfg.h"
|
||||
|
||||
#define BLE_ERR_UNKNOWN_HCI_CMD (0x01)
|
||||
/* LL Features */
|
||||
#define BLE_LL_FEAT_LE_ENCRYPTION (0x0000000001)
|
||||
#define BLE_LL_FEAT_CONN_PARM_REQ (0x0000000002)
|
||||
#define BLE_LL_FEAT_EXTENDED_REJ (0x0000000004)
|
||||
#define BLE_LL_FEAT_PERIPH_INIT (0x0000000008)
|
||||
#define BLE_LL_FEAT_LE_PING (0x0000000010)
|
||||
#define BLE_LL_FEAT_DATA_LEN_EXT (0x0000000020)
|
||||
#define BLE_LL_FEAT_LL_PRIVACY (0x0000000040)
|
||||
#define BLE_LL_FEAT_EXT_SCAN_FILT (0x0000000080)
|
||||
#define BLE_LL_FEAT_LE_2M_PHY (0x0000000100)
|
||||
#define BLE_LL_FEAT_STABLE_MOD_ID_TX (0x0000000200)
|
||||
#define BLE_LL_FEAT_STABLE_MOD_ID_RX (0x0000000400)
|
||||
#define BLE_LL_FEAT_LE_CODED_PHY (0x0000000800)
|
||||
#define BLE_LL_FEAT_EXT_ADV (0x0000001000)
|
||||
#define BLE_LL_FEAT_PERIODIC_ADV (0x0000002000)
|
||||
#define BLE_LL_FEAT_CSA2 (0x0000004000)
|
||||
#define BLE_LL_FEAT_LE_POWER_CLASS_1 (0x0000008000)
|
||||
#define BLE_LL_FEAT_MIN_USED_CHAN (0x0000010000)
|
||||
#define BLE_LL_FEAT_CTE_REQ (0x0000020000)
|
||||
#define BLE_LL_FEAT_CTE_RSP (0x0000040000)
|
||||
#define BLE_LL_FEAT_CTE_TX (0x0000080000)
|
||||
#define BLE_LL_FEAT_CTE_RX (0x0000100000)
|
||||
#define BLE_LL_FEAT_CTE_AOD (0x0000200000)
|
||||
#define BLE_LL_FEAT_CTE_AOA (0x0000400000)
|
||||
#define BLE_LL_FEAT_CTE_RECV (0x0000800000)
|
||||
#define BLE_LL_FEAT_SYNC_TRANS_SEND (0x0001000000)
|
||||
#define BLE_LL_FEAT_SYNC_TRANS_RECV (0x0002000000)
|
||||
#define BLE_LL_FEAT_SCA_UPDATE (0x0004000000)
|
||||
#define BLE_LL_FEAT_REM_PKEY (0x0008000000)
|
||||
#define BLE_LL_FEAT_CIS_CENTRAL (0x0010000000)
|
||||
#define BLE_LL_FEAT_CIS_PERIPH (0x0020000000)
|
||||
#define BLE_LL_FEAT_ISO_BROADCASTER (0x0040000000)
|
||||
#define BLE_LL_FEAT_SYNC_RECV (0x0080000000)
|
||||
#define BLE_LL_FEAT_CIS_HOST (0x0100000000)
|
||||
#define BLE_LL_FEAT_POWER_CTRL_REQ (0x0200000000)
|
||||
#define BLE_LL_FEAT_POWER_CHANGE_IND (0x0400000000)
|
||||
#define BLE_LL_FEAT_PATH_LOSS_MON (0x0800000000)
|
||||
#define BLE_LL_FEAT_PERIODIC_ADV_ADI (0x1000000000)
|
||||
#define BLE_LL_FEAT_CONN_SUBRATING (0x2000000000)
|
||||
#define BLE_LL_FEAT_CONN_SUBRATING_HOST (0x4000000000)
|
||||
#define BLE_LL_FEAT_CHANNEL_CLASS (0x8000000000)
|
||||
|
||||
uint64_t ble_ll_supported_features;
|
||||
|
||||
void
|
||||
ble_ll_supported_features_init(void)
|
||||
{
|
||||
ble_ll_supported_features = BLE_LL_FEAT_EXTENDED_REJ;
|
||||
ble_ll_supported_features |= BLE_LL_FEAT_DATA_LEN_EXT;
|
||||
|
||||
#if DEFAULT_BT_LE_ROLE_CENTROL || DEFAULT_BT_LE_ROLE_PERIPHERAL
|
||||
ble_ll_supported_features |= BLE_LL_FEAT_PERIPH_INIT;
|
||||
ble_ll_supported_features |= BLE_LL_FEAT_CONN_PARM_REQ;
|
||||
#endif
|
||||
|
||||
#if CONFIG_BT_LE_FEAT_LL_ENCRYPTION
|
||||
ble_ll_supported_features |= BLE_LL_FEAT_LE_ENCRYPTION;
|
||||
#endif
|
||||
|
||||
ble_ll_supported_features |= (BLE_LL_FEAT_LL_PRIVACY | BLE_LL_FEAT_EXT_SCAN_FILT);
|
||||
ble_ll_supported_features |= BLE_LL_FEAT_LE_PING;
|
||||
|
||||
#if DEFAULT_BT_LE_EXT_ADV
|
||||
ble_ll_supported_features |= BLE_LL_FEAT_EXT_ADV;
|
||||
#endif
|
||||
|
||||
#if DEFAULT_BT_LE_PERIODIC_ADV
|
||||
ble_ll_supported_features |= BLE_LL_FEAT_PERIODIC_ADV;
|
||||
ble_ll_supported_features |= BLE_LL_FEAT_PERIODIC_ADV_ADI;
|
||||
#endif
|
||||
|
||||
#if DEFAULT_BT_LE_PAST
|
||||
ble_ll_supported_features |= BLE_LL_FEAT_SYNC_TRANS_RECV;
|
||||
ble_ll_supported_features |= BLE_LL_FEAT_SYNC_TRANS_SEND;
|
||||
#endif
|
||||
|
||||
#if DEGAULT_BT_LE_2M_PHY
|
||||
ble_ll_supported_features |= BLE_LL_FEAT_LE_2M_PHY;
|
||||
#endif
|
||||
|
||||
#if DEGAULT_BT_LE_CODED_PHY
|
||||
ble_ll_supported_features |= BLE_LL_FEAT_LE_CODED_PHY;
|
||||
#endif
|
||||
|
||||
#if DEFAULT_BT_LE_50_FEATURE_SUPPORT
|
||||
ble_ll_supported_features |= BLE_LL_FEAT_CSA2;
|
||||
ble_ll_supported_features |= BLE_LL_FEAT_SCA_UPDATE;
|
||||
ble_ll_supported_features |= BLE_LL_FEAT_REM_PKEY;
|
||||
ble_ll_supported_features |= BLE_LL_FEAT_CHANNEL_CLASS;
|
||||
#endif
|
||||
}
|
||||
|
||||
#if !DEFAULT_BT_LE_ROLE_BROADCASTER
|
||||
void r_ble_ll_adv_rpa_timeout(void) { }
|
||||
void r_ble_lll_adv_halt(void) { }
|
||||
void r_ble_lll_adv_event_rmvd_from_sched(void) { }
|
||||
void r_ble_lll_adv_ext_event_rmvd_from_sched(void) { }
|
||||
int r_ble_ll_adv_enabled(void) { return 0; }
|
||||
int r_ble_ll_adv_can_chg_whitelist(void) { return 1; }
|
||||
int r_ble_ll_adv_set_random_addr(void) { return BLE_ERR_UNKNOWN_HCI_CMD; }
|
||||
void r_ble_ll_adv_reset(void) { }
|
||||
void r_ble_ll_adv_init(void) { }
|
||||
void r_ble_ll_adv_deinit(void) { }
|
||||
int r_ble_ll_adv_env_init(void) { return 0; }
|
||||
void r_ble_ll_adv_env_deinit(void) { }
|
||||
int r_ble_lll_adv_rx_pkt_isr(void) { return -1; }
|
||||
void r_ble_ll_adv_rx_pkt_in(void) { }
|
||||
int r_ble_ll_adv_set_adv_params(void) { return BLE_ERR_UNKNOWN_HCI_CMD; }
|
||||
int r_ble_ll_adv_read_txpwr(void) { return BLE_ERR_UNKNOWN_HCI_CMD; }
|
||||
int r_ble_ll_hci_set_adv_data(void) { return BLE_ERR_UNKNOWN_HCI_CMD; }
|
||||
int r_ble_ll_hci_set_scan_rsp_data(void) { return BLE_ERR_UNKNOWN_HCI_CMD; }
|
||||
int r_ble_ll_hci_adv_set_enable(void) { return BLE_ERR_UNKNOWN_HCI_CMD; }
|
||||
int r_ble_ll_adv_vendor_hci_legacy_adv_clear(void) { return BLE_ERR_UNKNOWN_HCI_CMD; }
|
||||
int r_ble_ll_adv_set_data_related_addr_change(void) { return BLE_ERR_UNKNOWN_HCI_CMD; }
|
||||
#endif // !DEFAULT_BT_LE_ROLE_BROADCASTER
|
||||
|
||||
#if !DEFAULT_BT_LE_EXT_ADV
|
||||
bool r_ble_ll_adv_ext_check_data_itvl(void) { return true; }
|
||||
void r_ble_lll_adv_coex_dpc_update_on_aux_scheduled(void) { }
|
||||
void r_ble_lll_adv_coex_dpc_calc_pti_update_itvl(void) { }
|
||||
void r_ble_lll_adv_sec_done(void) { }
|
||||
int r_ble_lll_adv_sec_schedule_next_aux(void) { return 0; }
|
||||
void r_ble_lll_adv_sec_event_done(void) { }
|
||||
int r_ble_lll_adv_secondary_tx_start_cb(void) { return 0; }
|
||||
void r_ble_lll_adv_aux_schedule(void) { }
|
||||
void r_ble_lll_adv_update_rsp_offset(void) { }
|
||||
int r_ble_ll_adv_hci_set_random_addr(void) { return BLE_ERR_UNKNOWN_HCI_CMD; }
|
||||
int r_ble_ll_adv_ext_set_param(void) { return BLE_ERR_UNKNOWN_HCI_CMD; }
|
||||
int r_ble_ll_adv_ext_set_adv_data(void) { return BLE_ERR_UNKNOWN_HCI_CMD; }
|
||||
int r_ble_ll_adv_ext_set_scan_rsp(void) { return BLE_ERR_UNKNOWN_HCI_CMD; }
|
||||
int r_ble_ll_adv_ext_set_enable(void) { return BLE_ERR_UNKNOWN_HCI_CMD; }
|
||||
int r_ble_ll_adv_rd_max_adv_data_len(void) { return BLE_ERR_UNKNOWN_HCI_CMD; }
|
||||
int r_ble_ll_adv_rd_sup_adv_sets(void) { return BLE_ERR_UNKNOWN_HCI_CMD; }
|
||||
int r_ble_ll_adv_remove(void) { return BLE_ERR_UNKNOWN_HCI_CMD; }
|
||||
int r_ble_ll_adv_clear_all(void) { return BLE_ERR_UNKNOWN_HCI_CMD; }
|
||||
#endif //!DEFAULT_BT_LE_EXT_ADV
|
||||
|
||||
#if !DEFAULT_BT_LE_PERIODIC_ADV
|
||||
void r_ble_ll_adv_sm_stop_periodic(void) { }
|
||||
void r_ble_lll_adv_periodic_event_done(void) { }
|
||||
int r_ble_lll_adv_sync_tx_start_cb(void) { return 0; }
|
||||
void r_ble_lll_adv_sync_tx_end(void) { }
|
||||
int r_ble_lll_adv_periodic_start(void) { return 0; }
|
||||
void r_ble_lll_adv_periodic_rmvd_from_sched(void) { }
|
||||
int r_ble_ll_adv_periodic_set_param(void) { return BLE_ERR_UNKNOWN_HCI_CMD; }
|
||||
int r_ble_ll_adv_periodic_set_data(void) { return BLE_ERR_UNKNOWN_HCI_CMD; }
|
||||
int r_ble_ll_adv_periodic_enable(void) { return BLE_ERR_UNKNOWN_HCI_CMD; }
|
||||
#endif //!DEFAULT_BT_LE_PERIODIC_ADV
|
||||
|
||||
#if !DEFAULT_BT_LE_ROLE_OBSERVER
|
||||
void r_ble_lll_scan_halt(void) { }
|
||||
void r_ble_ll_scan_end_adv_evt(void) { }
|
||||
void r_ble_ll_scan_rx_pkt_in(void) { }
|
||||
int r_ble_lll_scan_rx_pkt_isr(void) { return -1; }
|
||||
int r_ble_ll_scan_env_init(void) { return 0; }
|
||||
void r_ble_ll_scan_env_deinit(void) { }
|
||||
void r_ble_ll_scan_init(void) { }
|
||||
void r_ble_ll_scan_deinit(void) { }
|
||||
void r_ble_ll_scan_reset(void) { }
|
||||
int r_ble_ll_scan_can_chg_whitelist(void) { return 1; }
|
||||
int r_ble_ll_scan_enabled(void) { return false; }
|
||||
int r_ble_lll_scan_chk_resume(void) { return -1; }
|
||||
int r_ble_ll_scan_set_scan_params(void) { return BLE_ERR_UNKNOWN_HCI_CMD; }
|
||||
int r_ble_ll_hci_scan_set_enable(void) { return BLE_ERR_UNKNOWN_HCI_CMD; }
|
||||
int r_ble_ll_scan_hci_update_adv_report_flow_ctrl(void) { return BLE_ERR_UNKNOWN_HCI_CMD; }
|
||||
int r_ble_ll_scan_hci_set_adv_report_flow_ctrl(void) { return BLE_ERR_UNKNOWN_HCI_CMD; }
|
||||
#endif //!DEFAULT_BT_LE_ROLE_OBSERVER
|
||||
|
||||
#if !DEFAULT_BT_LE_EXT_SCAN
|
||||
void r_ble_lll_scan_duration_period_timers_restart(void) { }
|
||||
void r_ble_lll_scan_duration_period_timers_stop(void) { }
|
||||
int r_ble_ll_hci_send_legacy_ext_adv_report(void) { return -1; }
|
||||
void r_ble_lll_sched_rmv_elem_type(void) { }
|
||||
void r_ble_ll_scan_send_truncated(void) { }
|
||||
void r_ble_ll_scan_aux_data_unref(void) { }
|
||||
void r_ble_lll_scan_sched_remove(void) { }
|
||||
void r_ble_lll_scan_aux_data_free(void) { }
|
||||
void r_ble_lll_aux_scan_drop(void) { }
|
||||
int r_ble_lll_sched_aux_scan(void) { return -1; }
|
||||
int r_ble_lll_scan_rx_isr_on_aux(void) { return -1; }
|
||||
void r_ble_lll_scan_period_timer_cb(void) { }
|
||||
void r_ble_lll_scan_duration_timer_cb(void) { }
|
||||
void r_ble_ll_scan_rx_pkt_in_on_aux(void) { }
|
||||
int r_ble_ll_set_ext_scan_params(void) { return BLE_ERR_UNKNOWN_HCI_CMD; }
|
||||
int r_ble_ll_hci_ext_scan_set_enable(void) { return BLE_ERR_UNKNOWN_HCI_CMD; }
|
||||
#endif //!DEFAULT_BT_LE_EXT_SCAN
|
||||
|
||||
#if !DEFAULT_BT_LE_ROLE_CENTROL
|
||||
void r_ble_ll_init_rx_pkt_in(void) { }
|
||||
int r_ble_lll_init_rx_pkt_isr(void) { return -1; }
|
||||
int r_ble_ll_conn_create(void) { return BLE_ERR_UNKNOWN_HCI_CMD; }
|
||||
int r_ble_ll_conn_create_cancel(void) { return BLE_ERR_UNKNOWN_HCI_CMD; }
|
||||
#endif //!DEFAULT_BT_LE_ROLE_CENTROL
|
||||
|
||||
#if !DEFAULT_BT_LE_ROLE_CENTROL || !DEFAULT_BT_LE_EXT_SCAN
|
||||
int r_ble_ll_ext_conn_create(void) { return BLE_ERR_UNKNOWN_HCI_CMD; }
|
||||
#endif //!DEFAULT_BT_LE_ROLE_CENTROL || !DEFAULT_BT_LE_EXT_SCAN
|
||||
|
||||
#if !DEFAULT_BT_LE_ROLE_PERIPHERAL
|
||||
int r_ble_ll_conn_slave_start(void) { return 0; }
|
||||
#endif //!DEFAULT_BT_LE_ROLE_PERIPHERAL
|
||||
|
||||
#if !DEFAULT_BT_LE_ROLE_CENTROL && !DEFAULT_BT_LE_ROLE_PERIPHERAL
|
||||
void r_ble_ll_conn_rx_data_pdu(void) { }
|
||||
int r_ble_lll_conn_rx_pkt_isr(void) { return -1; }
|
||||
int r_ble_ll_hci_disconnect(void) { return BLE_ERR_UNKNOWN_HCI_CMD; }
|
||||
int r_ble_ll_conn_hci_rd_rem_ver_cmd(void) { return BLE_ERR_UNKNOWN_HCI_CMD; }
|
||||
int r_ble_ll_conn_hci_update(void) { return BLE_ERR_UNKNOWN_HCI_CMD; }
|
||||
int r_ble_ll_conn_hci_rd_chan_map(void) { return BLE_ERR_UNKNOWN_HCI_CMD; }
|
||||
int r_ble_ll_conn_hci_read_rem_features(void) { return BLE_ERR_UNKNOWN_HCI_CMD; }
|
||||
int r_ble_ll_conn_hci_param_rr(void) { return BLE_ERR_UNKNOWN_HCI_CMD; }
|
||||
int r_ble_ll_conn_hci_param_nrr(void) { return BLE_ERR_UNKNOWN_HCI_CMD; }
|
||||
#endif //!DEFAULT_BT_LE_ROLE_CENTROL && !DEFAULT_BT_LE_ROLE_PERIPHERAL
|
||||
|
||||
#if !CONFIG_BT_LE_FEAT_LL_ENCRYPTION
|
||||
int r_ble_ll_conn_chk_phy_upd_start(void) { return -1; }
|
||||
void r_ble_ll_hci_ev_encrypt_chg(void) { }
|
||||
int r_ble_ll_ctrl_enc_allowed_pdu_rx(void) { return 1; }
|
||||
int r_ble_ll_ctrl_enc_allowed_pdu_tx(void) { return 1; }
|
||||
uint8_t r_ble_ll_ctrl_rx_start_enc_rsp(void) { return 0x07; }
|
||||
uint8_t r_ble_ll_ctrl_rx_pause_enc_rsp(void) { return 0x07; }
|
||||
int r_ble_ll_hci_le_encrypt(void) { return BLE_ERR_UNKNOWN_HCI_CMD; }
|
||||
#endif //!CONFIG_BT_LE_FEAT_LL_ENCRYPTION
|
||||
|
||||
#if !DEFAULT_BT_LE_ROLE_PERIPHERAL || !CONFIG_BT_LE_FEAT_LL_ENCRYPTION
|
||||
uint8_t r_ble_ll_ctrl_rx_pause_enc_req(void) { return 0x07; }
|
||||
uint8_t r_ble_ll_ctrl_rx_enc_req(void) { return 0x07; }
|
||||
int r_ble_ll_conn_hci_le_ltk_reply(void) { return BLE_ERR_UNKNOWN_HCI_CMD; }
|
||||
int r_ble_ll_conn_hci_le_ltk_neg_reply(void) { return BLE_ERR_UNKNOWN_HCI_CMD; }
|
||||
#endif //!DEFAULT_BT_LE_ROLE_PERIPHERAL || !CONFIG_BT_LE_FEAT_LL_ENCRYPTION
|
||||
|
||||
#if !DEFAULT_BT_LE_ROLE_CENTROL || !CONFIG_BT_LE_FEAT_LL_ENCRYPTION
|
||||
uint8_t r_ble_ll_ctrl_rx_start_enc_req(void) { return 0x07; }
|
||||
void r_ble_ll_ctrl_rx_enc_rsp(void) { }
|
||||
void r_ble_ll_ctrl_enc_req_make(void) { }
|
||||
int r_ble_ll_conn_hci_le_start_encrypt(void) { return BLE_ERR_UNKNOWN_HCI_CMD; }
|
||||
#endif //!DEFAULT_BT_LE_ROLE_CENTROL || !CONFIG_BT_LE_FEAT_LL_ENCRYPTION
|
||||
|
||||
#if !DEGAULT_BT_LE_2M_PHY && !DEGAULT_BT_LE_CODED_PHY
|
||||
void r_ble_ll_ctrl_phy_update_proc_complete(void) { }
|
||||
void r_ble_ll_ctrl_phy_update_cancel(void) { }
|
||||
uint8_t r_ble_ll_ctrl_rx_phy_update_ind(void) { return 0x07; }
|
||||
uint8_t r_ble_ll_ctrl_rx_phy_rsp(void) { return 0x07; }
|
||||
uint8_t r_ble_ll_ctrl_rx_phy_req(void) { return 0x07; }
|
||||
void r_ble_ll_ctrl_phy_req_rsp_make(void) { }
|
||||
#endif //DEGAULT_BT_LE_2M_PHY && DEGAULT_BT_LE_CODED_PHY
|
||||
|
||||
#if !DEFAULT_BT_LE_PERIODIC_SYNC
|
||||
void r_ble_lll_sync_halt(void) { }
|
||||
void r_ble_lll_sync_rmvd_from_sched(void) { }
|
||||
int r_ble_ll_sync_list_search(void) { return -1; }
|
||||
uint8_t r_ble_ll_ctrl_rx_periodic_sync_ind(void) { return 0x07; }
|
||||
void r_ble_ll_sync_rx_pkt_in(void) { }
|
||||
int r_ble_lll_sync_rx_pkt_isr(void) { return -1; }
|
||||
int r_ble_ll_sync_env_init(void) { return 0; }
|
||||
void r_ble_ll_sync_env_deinit(void) { }
|
||||
void r_ble_ll_sync_init(void) { }
|
||||
void r_ble_ll_sync_deinit(void) { }
|
||||
void r_ble_ll_sync_reset(void) { }
|
||||
bool r_ble_ll_sync_enabled(void) { return false; }
|
||||
int r_ble_ll_sync_create(void) { return BLE_ERR_UNKNOWN_HCI_CMD; }
|
||||
int r_ble_ll_sync_cancel(void) { return BLE_ERR_UNKNOWN_HCI_CMD; }
|
||||
int r_ble_ll_sync_terminate(void) { return BLE_ERR_UNKNOWN_HCI_CMD; }
|
||||
int r_ble_ll_sync_list_add(void) { return BLE_ERR_UNKNOWN_HCI_CMD; }
|
||||
int r_ble_ll_sync_list_remove(void) { return BLE_ERR_UNKNOWN_HCI_CMD; }
|
||||
int r_ble_ll_sync_list_clear(void) { return BLE_ERR_UNKNOWN_HCI_CMD; }
|
||||
int r_ble_ll_sync_list_size(void) { return BLE_ERR_UNKNOWN_HCI_CMD; }
|
||||
int r_ble_ll_sync_receive_enable(void) { return BLE_ERR_UNKNOWN_HCI_CMD; }
|
||||
#endif //!DEFAULT_BT_LE_PERIODIC_SYNC
|
||||
|
||||
#if !DEFAULT_BT_LE_PAST || !DEFAULT_BT_LE_PERIODIC_ADV
|
||||
int r_ble_ll_adv_periodic_set_info_transfer(void) { return BLE_ERR_UNKNOWN_HCI_CMD; }
|
||||
#endif //!DEFAULT_BT_LE_PAST || !DEFAULT_BT_LE_PERIODIC_ADV
|
||||
|
||||
#if !DEFAULT_BT_LE_PAST || !DEFAULT_BT_LE_PERIODIC_SYNC
|
||||
int r_ble_ll_sync_transfer(void) { return BLE_ERR_UNKNOWN_HCI_CMD; }
|
||||
int r_ble_ll_set_sync_transfer_params(void) { return BLE_ERR_UNKNOWN_HCI_CMD; }
|
||||
int r_ble_ll_set_default_sync_transfer_params(void) { return BLE_ERR_UNKNOWN_HCI_CMD; }
|
||||
#endif //!DEFAULT_BT_LE_PAST || !DEFAULT_BT_LE_PERIODIC_SYNC
|
||||
|
||||
#if !DEFAULT_BT_LE_50_FEATURE_SUPPORT
|
||||
uint8_t r_ble_ll_ctrl_rx_channel_reporting_ind(void) { return 0x07; }
|
||||
uint8_t r_ble_ll_ctrl_rx_channel_status_ind(void) { return 0x07; }
|
||||
uint8_t r_ble_ll_ctrl_rx_sca_req(void) { return 0x07; }
|
||||
uint8_t r_ble_ll_ctrl_rx_sca_rsp(void) { return 0x07; }
|
||||
void r_ble_ll_ctrl_channel_class_reporting_make(void) { }
|
||||
void r_ble_ll_ctrl_channel_class_enable_make(void) { }
|
||||
void r_ble_ll_ctrl_sca_req_rsp_make(void) { }
|
||||
int r_ble_ll_modify_sca(void) { return BLE_ERR_UNKNOWN_HCI_CMD; }
|
||||
int r_ble_ll_conn_req_peer_sca(void) { return BLE_ERR_UNKNOWN_HCI_CMD; }
|
||||
#endif //!DEFAULT_BT_LE_50_FEATURE_SUPPORT
|
||||
|
||||
#if !DEFAULT_BT_LE_50_FEATURE_SUPPORT
|
||||
int r_ble_ll_conn_hci_le_rd_phy(void) { return BLE_ERR_UNKNOWN_HCI_CMD; }
|
||||
int r_ble_ll_hci_le_set_def_phy(void) { return BLE_ERR_UNKNOWN_HCI_CMD; }
|
||||
int r_ble_ll_conn_hci_le_set_phy(void) { return BLE_ERR_UNKNOWN_HCI_CMD; }
|
||||
#endif //!DEFAULT_BT_LE_50_FEATURE_SUPPORT
|
||||
|
||||
#if !CONFIG_BT_LE_DTM_ENABLED
|
||||
void r_ble_lll_dtm_rx_pkt_in(void) { }
|
||||
int r_ble_lll_dtm_rx_isr_end(void) { return -1; }
|
||||
void r_ble_lll_dtm_reset(void) { }
|
||||
void r_ble_lll_dtm_init(void) { }
|
||||
void r_ble_lll_dtm_deinit(void) { }
|
||||
int r_ble_lll_dtm_env_init(void) { return 0; }
|
||||
void r_ble_lll_dtm_env_deinit(void) { }
|
||||
int r_ble_lll_hci_dtm_tx_test(void) { return BLE_ERR_UNKNOWN_HCI_CMD; }
|
||||
int r_ble_lll_hci_dtm_rx_test(void) { return BLE_ERR_UNKNOWN_HCI_CMD; }
|
||||
int r_ble_lll_dtm_end_test(void) { return BLE_ERR_UNKNOWN_HCI_CMD; }
|
||||
int r_ble_lll_hci_dtm_rx_test_v2(void) { return BLE_ERR_UNKNOWN_HCI_CMD; }
|
||||
int r_ble_lll_hci_dtm_tx_test_v2(void) { return BLE_ERR_UNKNOWN_HCI_CMD; }
|
||||
#endif //!CONFIG_BT_LE_DTM_ENABLED
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -45,14 +45,6 @@ extern "C" {
|
||||
#define DEFAULT_BT_LE_50_FEATURE_SUPPORT (0)
|
||||
#endif
|
||||
|
||||
#define DEGAULT_BT_LE_2M_PHY (CONFIG_BT_NIMBLE_LL_CFG_FEAT_LE_2M_PHY)
|
||||
#define DEGAULT_BT_LE_CODED_PHY (CONFIG_BT_NIMBLE_LL_CFG_FEAT_LE_CODED_PHY)
|
||||
#define DEFAULT_BT_LE_EXT_ADV (CONFIG_BT_NIMBLE_EXT_ADV)
|
||||
#define DEFAULT_BT_LE_PERIODIC_ADV (CONFIG_BT_NIMBLE_ENABLE_PERIODIC_ADV)
|
||||
#define DEFAULT_BT_LE_EXT_SCAN (CONFIG_BT_NIMBLE_EXT_SCAN)
|
||||
#define DEFAULT_BT_LE_PERIODIC_SYNC (CONFIG_BT_NIMBLE_ENABLE_PERIODIC_SYNC)
|
||||
#define DEFAULT_BT_LE_PAST (CONFIG_BT_NIMBLE_PERIODIC_ADV_SYNC_TRANSFER)
|
||||
|
||||
#define DEFAULT_BT_LE_ROLE_OBSERVER MYNEWT_VAL(BLE_ROLE_OBSERVER)
|
||||
#define DEFAULT_BT_LE_ROLE_CENTROL MYNEWT_VAL(BLE_ROLE_CENTRAL)
|
||||
#define DEFAULT_BT_LE_ROLE_PERIPHERAL MYNEWT_VAL(BLE_ROLE_PERIPHERAL)
|
||||
@@ -130,55 +122,12 @@ extern "C" {
|
||||
#else
|
||||
#define DEFAULT_BT_LE_HCI_EVT_LO_BUF_COUNT (8)
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_BT_LE_50_FEATURE_SUPPORT)
|
||||
#define DEFAULT_BT_LE_50_FEATURE_SUPPORT (1)
|
||||
#else
|
||||
#define DEFAULT_BT_LE_50_FEATURE_SUPPORT (0)
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_BT_LE_LL_CFG_FEAT_LE_2M_PHY)
|
||||
#define DEGAULT_BT_LE_2M_PHY (CONFIG_BT_LE_LL_CFG_FEAT_LE_2M_PHY)
|
||||
#else
|
||||
#define DEGAULT_BT_LE_2M_PHY (0)
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_BT_LE_LL_CFG_FEAT_LE_CODED_PHY)
|
||||
#define DEGAULT_BT_LE_CODED_PHY (CONFIG_BT_LE_LL_CFG_FEAT_LE_CODED_PHY)
|
||||
#else
|
||||
#define DEGAULT_BT_LE_CODED_PHY (0)
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_BT_LE_EXT_ADV)
|
||||
#define DEFAULT_BT_LE_EXT_ADV (CONFIG_BT_LE_EXT_ADV)
|
||||
#else
|
||||
#define DEFAULT_BT_LE_EXT_ADV (0)
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_BT_LE_ENABLE_PERIODIC_ADV)
|
||||
#define DEFAULT_BT_LE_PERIODIC_ADV (CONFIG_BT_LE_ENABLE_PERIODIC_ADV)
|
||||
#else
|
||||
#define DEFAULT_BT_LE_PERIODIC_ADV (0)
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_BT_LE_EXT_SCAN)
|
||||
#define DEFAULT_BT_LE_EXT_SCAN (CONFIG_BT_LE_EXT_SCAN)
|
||||
#else
|
||||
#define DEFAULT_BT_LE_EXT_SCAN (0)
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_BT_LE_ENABLE_PERIODIC_SYNC)
|
||||
#define DEFAULT_BT_LE_PERIODIC_SYNC (CONFIG_BT_LE_ENABLE_PERIODIC_SYNC)
|
||||
#else
|
||||
#define DEFAULT_BT_LE_PERIODIC_SYNC (0)
|
||||
#endif
|
||||
|
||||
#if defined(BT_LE_PERIODIC_ADV_SYNC_TRANSFER)
|
||||
#define DEFAULT_BT_LE_PAST (BT_LE_PERIODIC_ADV_SYNC_TRANSFER)
|
||||
#else
|
||||
#define DEFAULT_BT_LE_PAST (0)
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_BT_LE_ROLE_CENTROL_ENABLE)
|
||||
#define DEFAULT_BT_LE_ROLE_CENTROL (1)
|
||||
#else
|
||||
@@ -220,50 +169,12 @@ extern "C" {
|
||||
|
||||
#define DEFAULT_BT_LE_COEX_PHY_CODED_TX_RX_TLIM_EFF CONFIG_BT_LE_COEX_PHY_CODED_TX_RX_TLIM_EFF
|
||||
|
||||
#ifdef CONFIG_BT_LE_CTRL_CHECK_CONNECT_IND_ACCESS_ADDRESS
|
||||
#define DEFAULT_BT_LE_CTRL_CHECK_CONNECT_IND_ACCESS_ADDRESS (CONFIG_BT_LE_CTRL_CHECK_CONNECT_IND_ACCESS_ADDRESS)
|
||||
#else
|
||||
#define DEFAULT_BT_LE_CTRL_CHECK_CONNECT_IND_ACCESS_ADDRESS (0)
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_BT_LE_CTRL_LLCP_CONN_UPDATE
|
||||
#define BT_CTRL_BLE_LLCP_CONN_UPDATE (1<<0)
|
||||
#else
|
||||
#define BT_CTRL_BLE_LLCP_CONN_UPDATE (0<<0)
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_BT_LE_CTRL_LLCP_CHAN_MAP_UPDATE
|
||||
#define BT_CTRL_BLE_LLCP_CHAN_MAP_UPDATE (1<<1)
|
||||
#else
|
||||
#define BT_CTRL_BLE_LLCP_CHAN_MAP_UPDATE (0<<1)
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_BT_LE_CTRL_LLCP_PHY_UPDATE
|
||||
#define BT_CTRL_BLE_LLCP_PHY_UPDATE (1<<2)
|
||||
#else
|
||||
#define BT_CTRL_BLE_LLCP_PHY_UPDATE (0<<2)
|
||||
#endif
|
||||
|
||||
#define BT_LE_CTRL_LLCP_DISC_FLAG (BT_CTRL_BLE_LLCP_CONN_UPDATE | BT_CTRL_BLE_LLCP_CHAN_MAP_UPDATE | BT_CTRL_BLE_LLCP_PHY_UPDATE)
|
||||
|
||||
#ifdef CONFIG_BT_CTRL_SCAN_BACKOFF_UPPERLIMITMAX
|
||||
#define BT_CTRL_SCAN_BACKOFF_UPPERLIMITMAX (CONFIG_BT_CTRL_SCAN_BACKOFF_UPPERLIMITMAX)
|
||||
#else
|
||||
#define BT_CTRL_SCAN_BACKOFF_UPPERLIMITMAX (256)
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_BT_LE_HCI_INTERFACE_USE_UART
|
||||
#define HCI_UART_EN CONFIG_BT_LE_HCI_INTERFACE_USE_UART
|
||||
#else
|
||||
#define HCI_UART_EN 0 // hci ram mode
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_BT_LE_HCI_INTERFACE_USE_RAM
|
||||
#define DEFAULT_BT_LE_VHCI_ENABLED (CONFIG_BT_LE_HCI_INTERFACE_USE_RAM)
|
||||
#else
|
||||
#define DEFAULT_BT_LE_VHCI_ENABLED (0)
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_BT_LE_SLEEP_ENABLE
|
||||
#define NIMBLE_SLEEP_ENABLE CONFIG_BT_LE_SLEEP_ENABLE
|
||||
#else
|
||||
|
||||
@@ -66,7 +66,7 @@ endchoice
|
||||
config BT_CTRL_HCI_TL
|
||||
int
|
||||
default 0 if BT_CTRL_HCI_MODE_UART_H4
|
||||
default 1 if BT_CTRL_HCI_MODE_VHCI
|
||||
default 1 if BT_CTRL_HCI_M0DE_VHCI
|
||||
default 1
|
||||
help
|
||||
HCI mode as VHCI or UART(H4)
|
||||
@@ -76,23 +76,20 @@ config BT_CTRL_ADV_DUP_FILT_MAX
|
||||
range 1 500
|
||||
default 30
|
||||
help
|
||||
The maximum number of 5.0 extend duplicate
|
||||
The maximum number of suplicate scan filter
|
||||
|
||||
choice BT_BLE_CCA_MODE
|
||||
prompt "BLE CCA mode"
|
||||
default BT_BLE_CCA_MODE_NONE
|
||||
help
|
||||
Define BT BLE CCA mode
|
||||
Note that if CCA feature is enabled, the hardware may not transmit packets due to channel busy.
|
||||
Therefore, it may potentially lead to an increase in the time taken for scanning advertising packet
|
||||
and establishing connections, or a decrease in the throughput rate of the connection.
|
||||
|
||||
config BT_BLE_CCA_MODE_NONE
|
||||
bool "NONE"
|
||||
config BT_BLE_CCA_MODE_HW
|
||||
bool "Hardware"
|
||||
config BT_BLE_CCA_MODE_SW
|
||||
bool "Software (experimental)"
|
||||
bool "Software"
|
||||
endchoice
|
||||
|
||||
config BT_BLE_CCA_MODE
|
||||
@@ -229,7 +226,6 @@ config BT_CTRL_DFT_TX_POWER_LEVEL_EFF
|
||||
|
||||
config BT_CTRL_BLE_ADV_REPORT_FLOW_CTRL_SUPP
|
||||
bool "BLE adv report flow control supported"
|
||||
depends on BT_CTRL_BLE_SCAN
|
||||
default y
|
||||
help
|
||||
The function is mainly used to enable flow control for advertising reports. When it is enabled,
|
||||
@@ -448,7 +444,7 @@ config BT_CTRL_SLEEP_CLOCK_EFF
|
||||
config BT_CTRL_HCI_TL_EFF
|
||||
int
|
||||
default 0 if BT_CTRL_HCI_MODE_UART_H4
|
||||
default 1 if BT_CTRL_HCI_MODE_VHCI
|
||||
default 1 if BT_CTRL_HCI_M0DE_VHCI
|
||||
default 1
|
||||
|
||||
config BT_CTRL_AGC_RECORRECT_EN
|
||||
@@ -494,137 +490,25 @@ config BT_CTRL_LE_PING_EN
|
||||
If this option is disabled, The Controller will not start the LE authenticated payload timer.
|
||||
This option is used for some compatibility problems related to LE ping procedure.
|
||||
|
||||
menu "BLE disconnects when Instant Passed (0x28) occurs"
|
||||
menu "BLE disconnect when instant passed"
|
||||
config BT_CTRL_BLE_LLCP_CONN_UPDATE
|
||||
bool "BLE ACL connection update procedure"
|
||||
default n
|
||||
help
|
||||
If this option is enabled, Controller will terminate the connection
|
||||
when Instant Passed (0x28) error occurs during connection update procedure.
|
||||
when instant passed during connection update procedure.
|
||||
|
||||
config BT_CTRL_BLE_LLCP_CHAN_MAP_UPDATE
|
||||
bool "BLE ACL channel map update procedure"
|
||||
default n
|
||||
help
|
||||
If this option is enabled, Controller will terminate the connection
|
||||
when Instant Passed (0x28) error occurs in channel map update procedure.
|
||||
when instant passed in channel map update procedure.
|
||||
|
||||
config BT_CTRL_BLE_LLCP_PHY_UPDATE
|
||||
bool "BLE ACL PHY update procedure"
|
||||
default n
|
||||
help
|
||||
If this option is enabled, Controller will terminate the connection
|
||||
when Instant Passed (0x28) error occurs in PHY update procedure.
|
||||
endmenu
|
||||
config BT_CTRL_RUN_IN_FLASH_ONLY
|
||||
bool "Put all BLE Controller code in flash"
|
||||
default n
|
||||
help
|
||||
If this option is enabled, all code for the Bluetooth controller will be moved from ROM and IRAM
|
||||
to flash, saving over 20K bytes of memory. However, it will require more flash resources and the
|
||||
performance of Bluetooth will decrease If this option is enabled, Bluetooth may not work properly
|
||||
during erasing flash. It is recommended to turn on the auto suspend function of flash. After auto
|
||||
suspend is turned on, Bluetooth interrupts can be executed normally during erasing flash, with less
|
||||
impact on Bluetooth performance.
|
||||
|
||||
config BT_CTRL_DTM_ENABLE
|
||||
bool "Enable direct test mode feature"
|
||||
default y
|
||||
|
||||
config BT_CTRL_BLE_MASTER
|
||||
bool "Enable BLE connection feature"
|
||||
default y
|
||||
help
|
||||
If this option is disabled, it is not recommended to use connectable ADV.
|
||||
|
||||
config BT_CTRL_BLE_TEST
|
||||
bool "Enable BLE QA test feature (Not Used)"
|
||||
default n
|
||||
|
||||
config BT_CTRL_BLE_SCAN
|
||||
bool "Enable BLE scan feature"
|
||||
default y
|
||||
|
||||
config BT_CTRL_BLE_SECURITY_ENABLE
|
||||
bool "Enable BLE security feature"
|
||||
default y
|
||||
|
||||
config BT_CTRL_BLE_ADV
|
||||
bool "Enable BLE ADV feature"
|
||||
default y
|
||||
|
||||
config BT_CTRL_CHECK_CONNECT_IND_ACCESS_ADDRESS
|
||||
bool "Enable enhanced Access Address check in CONNECT_IND"
|
||||
default n
|
||||
help
|
||||
Enabling this option will add stricter verification of the Access Address in the CONNECT_IND PDU.
|
||||
This improves security by ensuring that only connection requests with valid Access Addresses are accepted.
|
||||
If disabled, only basic checks are applied, improving compatibility.
|
||||
|
||||
menu "Controller debug log Options (Experimental)"
|
||||
config BT_CTRL_LE_LOG_EN
|
||||
depends on BT_CTRL_RUN_IN_FLASH_ONLY
|
||||
bool "Enable BLE debug log"
|
||||
default n
|
||||
|
||||
config BT_CTRL_LE_HCI_LOG_EN
|
||||
depends on BT_CTRL_LE_LOG_EN
|
||||
bool "Enable BLE HCI log"
|
||||
default n
|
||||
|
||||
config BT_CTRL_LE_LOG_DUMP_ONLY
|
||||
depends on BT_CTRL_LE_LOG_EN
|
||||
bool "Enable BLE log dump only"
|
||||
default n
|
||||
|
||||
config BT_CTRL_LE_LOG_STORAGE_EN
|
||||
depends on BT_CTRL_LE_LOG_EN
|
||||
bool "Enable BLE log storage to flash"
|
||||
default n
|
||||
|
||||
config BT_CTRL_LE_LOG_PARTITION_SIZE
|
||||
int "The size of ble controller log partition(Multiples of 4K)"
|
||||
depends on BT_CTRL_LE_LOG_STORAGE_EN
|
||||
default 65536
|
||||
help
|
||||
The size of ble controller log partition shall be a multiples of 4K.
|
||||
The name of log partition shall be "bt_ctrl_log".
|
||||
The partition type shall be ESP_PARTITION_TYPE_DATA.
|
||||
The partition sub_type shall be ESP_PARTITION_SUBTYPE_ANY.
|
||||
|
||||
config BT_CTRL_LE_LOG_SPI_OUT_EN
|
||||
bool "Output ble controller logs to SPI bus"
|
||||
depends on BT_CTRL_LE_LOG_EN
|
||||
depends on !BT_CTRL_LE_LOG_DUMP_ONLY
|
||||
select BT_BLE_LOG_SPI_OUT_ENABLED
|
||||
default n
|
||||
help
|
||||
Output ble controller logs to SPI bus
|
||||
|
||||
config BT_CTRL_LE_LOG_MODE_EN
|
||||
depends on BT_CTRL_LE_LOG_EN
|
||||
int "Enable log for specified BLE mode"
|
||||
range 0 4095
|
||||
default 4093
|
||||
|
||||
config BT_CTRL_LE_LOG_LEVEL
|
||||
depends on BT_CTRL_LE_LOG_EN
|
||||
int "The level of BLE log"
|
||||
range 0 5
|
||||
default 2
|
||||
|
||||
config BT_CTRL_LE_LOG_BUF1_SIZE
|
||||
depends on BT_CTRL_LE_LOG_EN
|
||||
int "The size of BLE log buffer1"
|
||||
default 1024
|
||||
|
||||
config BT_CTRL_LE_LOG_HCI_BUF_SIZE
|
||||
depends on BT_CTRL_LE_LOG_EN
|
||||
int "The size of BLE log HCI buffer"
|
||||
default 1024
|
||||
|
||||
config BT_CTRL_LE_LOG_BUF2_SIZE
|
||||
depends on BT_CTRL_LE_LOG_EN
|
||||
int "The size of BLE log buffer2"
|
||||
default 1024
|
||||
when instant passed in PHY update procedure.
|
||||
endmenu
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -49,13 +49,6 @@
|
||||
#else //CONFIG_IDF_TARGET_ESP32S3
|
||||
#include "esp32s3/rom/rom_layout.h"
|
||||
#endif
|
||||
#if CONFIG_BT_BLE_LOG_SPI_OUT_ENABLED
|
||||
#include "ble_log/ble_log_spi_out.h"
|
||||
#endif // CONFIG_BT_BLE_LOG_SPI_OUT_ENABLED
|
||||
#if CONFIG_BT_CTRL_LE_LOG_STORAGE_EN
|
||||
#include "esp_partition.h"
|
||||
#include "hal/wdt_hal.h"
|
||||
#endif // CONFIG_BT_CTRL_LE_LOG_STORAGE_EN
|
||||
#if CONFIG_BT_ENABLED
|
||||
|
||||
/* Macro definition
|
||||
@@ -122,20 +115,12 @@ do{\
|
||||
} while(0)
|
||||
|
||||
#define OSI_FUNCS_TIME_BLOCKING 0xffffffff
|
||||
#define OSI_VERSION 0x0001000A
|
||||
#define OSI_VERSION 0x00010009
|
||||
#define OSI_MAGIC_VALUE 0xFADEBEAD
|
||||
|
||||
#define BLE_PWR_HDL_INVL 0xFFFF
|
||||
|
||||
#define BLE_CONTROLLER_MALLOC_CAPS (MALLOC_CAP_INTERNAL|MALLOC_CAP_DMA)
|
||||
|
||||
#if CONFIG_BT_CTRL_LE_LOG_STORAGE_EN
|
||||
#define MAX_STORAGE_SIZE (CONFIG_BT_CTRL_LE_LOG_PARTITION_SIZE)
|
||||
#define BLOCK_SIZE (4096)
|
||||
#define THRESHOLD (3072)
|
||||
#define PARTITION_NAME "bt_ctrl_log"
|
||||
#endif
|
||||
|
||||
/* Types definition
|
||||
************************************************************************
|
||||
*/
|
||||
@@ -231,13 +216,8 @@ struct osi_funcs_t {
|
||||
void (* _btdm_rom_table_ready)(void);
|
||||
bool (* _coex_bt_wakeup_request)(void);
|
||||
void (* _coex_bt_wakeup_request_end)(void);
|
||||
int64_t (*_get_time_us)(void);
|
||||
void (* _assert)(void);
|
||||
};
|
||||
|
||||
#if CONFIG_BT_CTRL_LE_LOG_EN
|
||||
typedef void (*interface_func_t) (uint32_t len, const uint8_t*addr, bool end);
|
||||
#endif // CONFIG_BT_CTRL_LE_LOG_EN
|
||||
|
||||
/* External functions or values
|
||||
************************************************************************
|
||||
@@ -280,6 +260,7 @@ extern int API_vhci_host_register_callback(const vhci_host_callback_t *callback)
|
||||
extern int ble_txpwr_set(int power_type, uint16_t handle, int power_level);
|
||||
extern int ble_txpwr_get(int power_type, uint16_t handle);
|
||||
|
||||
extern uint16_t l2c_ble_link_get_tx_buf_num(void);
|
||||
extern void coex_pti_v2(void);
|
||||
|
||||
extern bool btdm_deep_sleep_mem_init(void);
|
||||
@@ -295,34 +276,6 @@ extern void ets_backup_dma_copy(uint32_t reg, uint32_t mem_addr, uint32_t num, b
|
||||
#endif
|
||||
|
||||
extern void btdm_cca_feature_enable(void);
|
||||
extern void btdm_aa_check_enhance_enable(void);
|
||||
|
||||
#if (CONFIG_BT_BLUEDROID_ENABLED || CONFIG_BT_NIMBLE_ENABLED)
|
||||
extern void scan_stack_enableAdvFlowCtrlVsCmd(bool en);
|
||||
extern void adv_stack_enableClearLegacyAdvVsCmd(bool en);
|
||||
extern void advFilter_stack_enableDupExcListVsCmd(bool en);
|
||||
extern void chanSel_stack_enableSetCsaVsCmd(bool en);
|
||||
#endif // (CONFIG_BT_BLUEDROID_ENABLED || CONFIG_BT_NIMBLE_ENABLED)
|
||||
|
||||
/* BLE Log module */
|
||||
#if CONFIG_BT_CTRL_LE_LOG_EN
|
||||
extern int r_ble_log_init_async(interface_func_t bt_controller_log_interface, bool task_create, uint8_t buffers, uint32_t *bufs_size);
|
||||
extern int r_ble_log_deinit_async(void);
|
||||
extern void r_ble_log_async_select_dump_buffers(uint8_t buffers);
|
||||
extern void r_ble_log_async_output_dump_all(bool output);
|
||||
extern void esp_panic_handler_feed_wdts(void);
|
||||
#endif // CONFIG_BT_CTRL_LE_LOG_EN
|
||||
|
||||
extern void ble_dtm_funcs_reset(void);
|
||||
extern void ble_scan_funcs_reset(void);
|
||||
extern void ble_42_adv_funcs_reset(void);
|
||||
extern void ble_init_funcs_reset(void);
|
||||
extern void ble_con_funcs_reset(void);
|
||||
extern void ble_cca_funcs_reset(void);
|
||||
extern void ble_ext_adv_funcs_reset(void);
|
||||
extern void ble_ext_scan_funcs_reset(void);
|
||||
extern void ble_base_funcs_reset(void);
|
||||
extern void ble_enc_funcs_reset(void);
|
||||
|
||||
extern uint32_t _bt_bss_start;
|
||||
extern uint32_t _bt_bss_end;
|
||||
@@ -385,8 +338,6 @@ static void btdm_backup_dma_copy_wrapper(uint32_t reg, uint32_t mem_addr, uint32
|
||||
static void btdm_funcs_table_ready_wrapper(void);
|
||||
static bool coex_bt_wakeup_request(void);
|
||||
static void coex_bt_wakeup_request_end(void);
|
||||
static int64_t get_time_us_wrapper(void);
|
||||
static void assert_wrapper(void);
|
||||
|
||||
static void btdm_slp_tmr_callback(void *arg);
|
||||
|
||||
@@ -394,15 +345,6 @@ static esp_err_t try_heap_caps_add_region(intptr_t start, intptr_t end);
|
||||
|
||||
static void bt_controller_deinit_internal(void);
|
||||
|
||||
#if CONFIG_BT_CTRL_LE_LOG_EN
|
||||
static void esp_bt_controller_log_interface(uint32_t len, const uint8_t *addr, bool end);
|
||||
#if CONFIG_BT_CTRL_LE_LOG_STORAGE_EN
|
||||
void esp_bt_read_ctrl_log_from_flash(bool output);
|
||||
static int esp_bt_controller_log_storage(uint32_t len, const uint8_t *addr, bool end);
|
||||
static void esp_bt_ctrl_log_partition_get_and_erase_first_block(void);
|
||||
#endif // #if CONFIG_BT_CTRL_LE_LOG_STORAGE_EN
|
||||
#endif // CONFIG_BT_CTRL_LE_LOG_EN
|
||||
|
||||
/* Local variable definition
|
||||
***************************************************************************
|
||||
*/
|
||||
@@ -468,8 +410,6 @@ static const struct osi_funcs_t osi_funcs_ro = {
|
||||
._btdm_rom_table_ready = btdm_funcs_table_ready_wrapper,
|
||||
._coex_bt_wakeup_request = coex_bt_wakeup_request,
|
||||
._coex_bt_wakeup_request_end = coex_bt_wakeup_request_end,
|
||||
._get_time_us = get_time_us_wrapper,
|
||||
._assert = assert_wrapper,
|
||||
};
|
||||
|
||||
static DRAM_ATTR struct osi_funcs_t *osi_funcs_p;
|
||||
@@ -498,255 +438,6 @@ static DRAM_ATTR esp_pm_lock_handle_t s_pm_lock;
|
||||
static DRAM_ATTR esp_pm_lock_handle_t s_light_sleep_pm_lock;
|
||||
#endif
|
||||
|
||||
#if CONFIG_BT_CTRL_LE_LOG_EN
|
||||
enum log_out_mode {
|
||||
LOG_DUMP_MEMORY,
|
||||
LOG_ASYNC_OUT,
|
||||
LOG_STORAGE_TO_FLASH,
|
||||
LOG_SPI_OUT,
|
||||
};
|
||||
|
||||
const static uint32_t log_bufs_size[] = {CONFIG_BT_CTRL_LE_LOG_BUF1_SIZE, CONFIG_BT_CTRL_LE_LOG_HCI_BUF_SIZE, CONFIG_BT_CTRL_LE_LOG_BUF2_SIZE};
|
||||
bool log_is_inited = false;
|
||||
#if CONFIG_BT_CTRL_LE_LOG_DUMP_ONLY
|
||||
uint8_t log_output_mode = LOG_DUMP_MEMORY;
|
||||
#else
|
||||
#if CONFIG_BT_CTRL_LE_LOG_STORAGE_EN
|
||||
uint8_t log_output_mode = LOG_STORAGE_TO_FLASH;
|
||||
#elif CONFIG_BT_CTRL_LE_LOG_SPI_OUT_EN
|
||||
uint8_t log_output_mode = LOG_SPI_OUT;
|
||||
#else
|
||||
uint8_t log_output_mode = LOG_ASYNC_OUT;
|
||||
#endif // CONFIG_BT_CTRL_LE_LOG_STORAGE_EN
|
||||
#endif // CONFIG_BT_CTRL_LE_LOG_DUMP_ONLY
|
||||
#if CONFIG_BT_CTRL_LE_LOG_STORAGE_EN
|
||||
static const esp_partition_t *log_partition;
|
||||
static uint32_t write_index = 0;
|
||||
static uint32_t next_erase_index = BLOCK_SIZE;
|
||||
static bool block_erased = false;
|
||||
static bool stop_write = false;
|
||||
static bool is_filled = false;
|
||||
#endif // CONFIG_BT_CTRL_LE_LOG_STORAGE_EN
|
||||
|
||||
static void esp_bt_controller_log_interface(uint32_t len, const uint8_t *addr, bool end)
|
||||
{
|
||||
if (log_output_mode == LOG_STORAGE_TO_FLASH) {
|
||||
#if CONFIG_BT_CTRL_LE_LOG_STORAGE_EN
|
||||
esp_bt_controller_log_storage(len, addr, end);
|
||||
#endif //CONFIG_BT_CTRL_LE_LOG_STORAGE_EN
|
||||
} else {
|
||||
portMUX_TYPE spinlock = portMUX_INITIALIZER_UNLOCKED;
|
||||
portENTER_CRITICAL_SAFE(&spinlock);
|
||||
esp_panic_handler_feed_wdts();
|
||||
for (int i = 0; i < len; i++) {
|
||||
esp_rom_printf("%02x ", addr[i]);
|
||||
}
|
||||
|
||||
if (end) {
|
||||
esp_rom_printf("\n");
|
||||
}
|
||||
portEXIT_CRITICAL_SAFE(&spinlock);
|
||||
}
|
||||
}
|
||||
|
||||
#if CONFIG_BT_CTRL_LE_LOG_SPI_OUT_EN
|
||||
static IRAM_ATTR void esp_bt_controller_spi_log_interface(uint32_t len, const uint8_t *addr, bool end)
|
||||
{
|
||||
ble_log_spi_out_write(BLE_LOG_SPI_OUT_SOURCE_ESP_LEGACY, addr, len);
|
||||
}
|
||||
#endif // CONFIG_BT_CTRL_LE_LOG_SPI_OUT_EN
|
||||
|
||||
void esp_ble_controller_log_dump_all(bool output)
|
||||
{
|
||||
if (log_output_mode == LOG_STORAGE_TO_FLASH) {
|
||||
#if CONFIG_BT_CTRL_LE_LOG_STORAGE_EN
|
||||
esp_bt_read_ctrl_log_from_flash(output);
|
||||
#endif // CONFIG_BT_CTRL_LE_LOG_STORAGE_EN
|
||||
} else {
|
||||
portMUX_TYPE spinlock = portMUX_INITIALIZER_UNLOCKED;
|
||||
portENTER_CRITICAL_SAFE(&spinlock);
|
||||
esp_panic_handler_feed_wdts();
|
||||
esp_rom_printf("\r\n[DUMP_START:");
|
||||
r_ble_log_async_output_dump_all(output);
|
||||
esp_rom_printf(":DUMP_END]\r\n");
|
||||
portEXIT_CRITICAL_SAFE(&spinlock);
|
||||
}
|
||||
}
|
||||
|
||||
void esp_bt_log_output_mode_set(uint8_t output_mode)
|
||||
{
|
||||
log_output_mode = output_mode;
|
||||
}
|
||||
|
||||
uint8_t esp_bt_log_output_mode_get(void)
|
||||
{
|
||||
return log_output_mode;
|
||||
}
|
||||
|
||||
esp_err_t esp_bt_controller_log_init(uint8_t log_output_mode)
|
||||
{
|
||||
esp_err_t ret = ESP_OK;
|
||||
interface_func_t bt_controller_log_interface;
|
||||
bt_controller_log_interface = esp_bt_controller_log_interface;
|
||||
bool task_create;
|
||||
uint8_t buffers = 0;
|
||||
|
||||
if (log_is_inited) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
#if CONFIG_BT_CTRL_LE_LOG_EN
|
||||
buffers |= ESP_BLE_LOG_BUF_CONTROLLER;
|
||||
#endif // CONFIG_BT_CTRL_LE_LOG_EN
|
||||
#if CONFIG_BT_CTRL_LE_HCI_LOG_EN
|
||||
buffers |= ESP_BLE_LOG_BUF_HCI;
|
||||
#endif // CONFIG_BT_CTRL_LE_HCI_LOG_EN
|
||||
|
||||
switch (log_output_mode) {
|
||||
case LOG_DUMP_MEMORY:
|
||||
task_create = false;
|
||||
break;
|
||||
case LOG_ASYNC_OUT:
|
||||
case LOG_STORAGE_TO_FLASH:
|
||||
task_create = true;
|
||||
#if CONFIG_BT_CTRL_LE_LOG_STORAGE_EN
|
||||
if (log_output_mode == LOG_STORAGE_TO_FLASH) {
|
||||
esp_bt_ctrl_log_partition_get_and_erase_first_block();
|
||||
}
|
||||
#endif // CONFIG_BT_CTRL_LE_LOG_STORAGE_EN
|
||||
break;
|
||||
case LOG_SPI_OUT:
|
||||
task_create = true;
|
||||
#if CONFIG_BT_CTRL_LE_LOG_SPI_OUT_EN
|
||||
bt_controller_log_interface = esp_bt_controller_spi_log_interface;
|
||||
#endif // CONFIG_BT_CTRL_LE_LOG_SPI_OUT_EN
|
||||
break;
|
||||
default:
|
||||
assert(0);
|
||||
}
|
||||
|
||||
ret = r_ble_log_init_async(bt_controller_log_interface, task_create, buffers, (uint32_t *)log_bufs_size);
|
||||
if (ret == ESP_OK) {
|
||||
log_is_inited = true;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void esp_bt_ontroller_log_deinit(void)
|
||||
{
|
||||
r_ble_log_deinit_async();
|
||||
log_is_inited = false;
|
||||
}
|
||||
|
||||
#if CONFIG_BT_CTRL_LE_LOG_STORAGE_EN
|
||||
static void esp_bt_ctrl_log_partition_get_and_erase_first_block(void)
|
||||
{
|
||||
log_partition = NULL;
|
||||
assert(MAX_STORAGE_SIZE % BLOCK_SIZE == 0);
|
||||
// Find the partition map in the partition table
|
||||
log_partition = esp_partition_find_first(ESP_PARTITION_TYPE_DATA, ESP_PARTITION_SUBTYPE_ANY, PARTITION_NAME);
|
||||
assert(log_partition != NULL);
|
||||
// Prepare data to be read later using the mapped address
|
||||
ESP_ERROR_CHECK(esp_partition_erase_range(log_partition, 0, BLOCK_SIZE));
|
||||
write_index = 0;
|
||||
next_erase_index = BLOCK_SIZE;
|
||||
block_erased = false;
|
||||
is_filled = false;
|
||||
stop_write = false;
|
||||
}
|
||||
|
||||
static int esp_bt_controller_log_storage(uint32_t len, const uint8_t *addr, bool end)
|
||||
{
|
||||
if (len > MAX_STORAGE_SIZE) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (stop_write) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (((write_index) % BLOCK_SIZE) >= THRESHOLD && !block_erased) {
|
||||
// esp_rom_printf("Ers nxt: %d,%d\n", next_erase_index, write_index);
|
||||
esp_partition_erase_range(log_partition, next_erase_index, BLOCK_SIZE);
|
||||
next_erase_index = (next_erase_index + BLOCK_SIZE) % MAX_STORAGE_SIZE;
|
||||
block_erased = true;
|
||||
}
|
||||
|
||||
if (((write_index + len) / BLOCK_SIZE) > (write_index / BLOCK_SIZE)) {
|
||||
block_erased = false;
|
||||
}
|
||||
|
||||
if (write_index + len <= MAX_STORAGE_SIZE) {
|
||||
esp_partition_write(log_partition, write_index, addr, len);
|
||||
write_index = (write_index + len) % MAX_STORAGE_SIZE;
|
||||
} else {
|
||||
uint32_t first_part_len = MAX_STORAGE_SIZE - write_index;
|
||||
esp_partition_write(log_partition, write_index, addr, first_part_len);
|
||||
esp_partition_write(log_partition, 0, addr + first_part_len, len - first_part_len);
|
||||
write_index = len - first_part_len;
|
||||
is_filled = true;
|
||||
// esp_rom_printf("old idx: %d,%d\n",next_erase_index, write_index);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void esp_bt_read_ctrl_log_from_flash(bool output)
|
||||
{
|
||||
esp_partition_mmap_handle_t mmap_handle;
|
||||
uint32_t read_index;
|
||||
const void *mapped_ptr;
|
||||
const uint8_t *buffer;
|
||||
uint32_t print_len;
|
||||
uint32_t max_print_len;
|
||||
esp_err_t err;
|
||||
|
||||
print_len = 0;
|
||||
max_print_len = 4096;
|
||||
err = esp_partition_mmap(log_partition, 0, MAX_STORAGE_SIZE, ESP_PARTITION_MMAP_DATA, &mapped_ptr, &mmap_handle);
|
||||
if (err != ESP_OK) {
|
||||
ESP_LOGE("FLASH", "Mmap failed: %s", esp_err_to_name(err));
|
||||
return;
|
||||
}
|
||||
|
||||
portMUX_TYPE spinlock = portMUX_INITIALIZER_UNLOCKED;
|
||||
portENTER_CRITICAL_SAFE(&spinlock);
|
||||
esp_panic_handler_feed_wdts();
|
||||
r_ble_log_async_output_dump_all(true);
|
||||
esp_bt_ontroller_log_deinit();
|
||||
stop_write = true;
|
||||
|
||||
buffer = (const uint8_t *)mapped_ptr;
|
||||
esp_panic_handler_feed_wdts();
|
||||
if (is_filled) {
|
||||
read_index = next_erase_index;
|
||||
} else {
|
||||
read_index = 0;
|
||||
}
|
||||
|
||||
esp_rom_printf("\r\nREAD_CHECK:%ld,%ld,%d\r\n",read_index, write_index, is_filled);
|
||||
esp_rom_printf("\r\n[DUMP_START:");
|
||||
while (read_index != write_index) {
|
||||
esp_rom_printf("%02x ", buffer[read_index]);
|
||||
if (print_len > max_print_len) {
|
||||
esp_panic_handler_feed_wdts();
|
||||
print_len = 0;
|
||||
}
|
||||
|
||||
print_len++;
|
||||
read_index = (read_index + 1) % MAX_STORAGE_SIZE;
|
||||
}
|
||||
|
||||
esp_rom_printf(":DUMP_END]\r\n");
|
||||
portEXIT_CRITICAL_SAFE(&spinlock);
|
||||
esp_partition_munmap(mmap_handle);
|
||||
err = esp_bt_controller_log_init(log_output_mode);
|
||||
assert(err == ESP_OK);
|
||||
}
|
||||
#endif // CONFIG_BT_CTRL_LE_LOG_STORAGE_EN
|
||||
#endif // CONFIG_BT_CTRL_LE_LOG_EN
|
||||
|
||||
void IRAM_ATTR btdm_hw_mac_power_down_wrapper(void)
|
||||
{
|
||||
#if CONFIG_MAC_BB_PD
|
||||
@@ -808,11 +499,7 @@ static int interrupt_alloc_wrapper(int cpu_id, int source, intr_handler_t handle
|
||||
{
|
||||
btdm_isr_alloc_t p;
|
||||
p.source = source;
|
||||
#if CONFIG_BT_CTRL_RUN_IN_FLASH_ONLY
|
||||
p.flags = ESP_INTR_FLAG_LEVEL3;
|
||||
#else
|
||||
p.flags = ESP_INTR_FLAG_LEVEL3 | ESP_INTR_FLAG_IRAM;
|
||||
#endif
|
||||
p.fn = handler;
|
||||
p.arg = arg;
|
||||
p.handle = (intr_handle_t *)ret_handle;
|
||||
@@ -1274,49 +961,6 @@ static void btdm_funcs_table_ready_wrapper(void)
|
||||
#if BT_BLE_CCA_MODE == 2
|
||||
btdm_cca_feature_enable();
|
||||
#endif
|
||||
#if BLE_CTRL_CHECK_CONNECT_IND_ACCESS_ADDRESS_ENABLED
|
||||
btdm_aa_check_enhance_enable();
|
||||
#endif
|
||||
#if CONFIG_BT_CTRL_RUN_IN_FLASH_ONLY
|
||||
// do nothing
|
||||
#else
|
||||
ESP_LOGI(BT_LOG_TAG, "Feature Config, ADV:%d, BLE_50:%d, DTM:%d, SCAN:%d, CCA:%d, SMP:%d, CONNECT:%d",
|
||||
BT_CTRL_BLE_ADV, BT_CTRL_50_FEATURE_SUPPORT, BT_CTRL_DTM_ENABLE, BT_CTRL_BLE_SCAN,
|
||||
BT_BLE_CCA_MODE, BLE_SECURITY_ENABLE, BT_CTRL_BLE_MASTER);
|
||||
|
||||
ble_base_funcs_reset();
|
||||
#if CONFIG_BT_CTRL_BLE_ADV
|
||||
ble_42_adv_funcs_reset();
|
||||
#if (BT_CTRL_50_FEATURE_SUPPORT == 1)
|
||||
ble_ext_adv_funcs_reset();
|
||||
#endif //
|
||||
#endif // CONFIG_BT_CTRL_BLE_ADV
|
||||
|
||||
#if CONFIG_BT_CTRL_DTM_ENABLE
|
||||
ble_dtm_funcs_reset();
|
||||
#endif // CONFIG_BT_CTRL_DTM_ENABLE
|
||||
|
||||
#if CONFIG_BT_CTRL_BLE_SCAN
|
||||
ble_scan_funcs_reset();
|
||||
#if (BT_CTRL_50_FEATURE_SUPPORT == 1)
|
||||
ble_ext_scan_funcs_reset();
|
||||
#endif // (BT_CTRL_50_FEATURE_SUPPORT == 1)
|
||||
#endif // CONFIG_BT_CTRL_BLE_SCAN
|
||||
|
||||
#if (BT_BLE_CCA_MODE != 0)
|
||||
ble_cca_funcs_reset();
|
||||
#endif // (BT_BLE_CCA_MODE != 0)
|
||||
|
||||
#if CONFIG_BT_CTRL_BLE_SECURITY_ENABLE
|
||||
ble_enc_funcs_reset();
|
||||
#endif // CONFIG_BT_CTRL_BLE_SECURITY_ENABLE
|
||||
|
||||
#if CONFIG_BT_CTRL_BLE_MASTER
|
||||
ble_init_funcs_reset();
|
||||
ble_con_funcs_reset();
|
||||
#endif // CONFIG_BT_CTRL_BLE_MASTER
|
||||
|
||||
#endif // CONFIG_BT_CTRL_RUN_IN_FLASH_ONLY
|
||||
}
|
||||
|
||||
bool bt_async_wakeup_request(void)
|
||||
@@ -1340,18 +984,6 @@ static void coex_bt_wakeup_request_end(void)
|
||||
return;
|
||||
}
|
||||
|
||||
static IRAM_ATTR int64_t get_time_us_wrapper(void)
|
||||
{
|
||||
return esp_timer_get_time();
|
||||
}
|
||||
|
||||
static IRAM_ATTR void assert_wrapper(void)
|
||||
{
|
||||
#if CONFIG_BT_CTRL_LE_LOG_EN
|
||||
esp_ble_controller_log_dump_all(true);
|
||||
#endif // CONFIG_BT_CTRL_LE_LOG_EN
|
||||
}
|
||||
|
||||
bool esp_vhci_host_check_send_available(void)
|
||||
{
|
||||
if (btdm_controller_status != ESP_BT_CONTROLLER_STATUS_ENABLED) {
|
||||
@@ -1794,10 +1426,6 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg)
|
||||
|
||||
ESP_LOGI(BT_LOG_TAG, "BT controller compile version [%s]", btdm_controller_get_compile_version());
|
||||
|
||||
#if (CONFIG_BT_CTRL_RUN_IN_FLASH_ONLY)
|
||||
ESP_LOGI(BT_LOG_TAG,"Put all controller code in flash");
|
||||
#endif
|
||||
|
||||
if ((err = btdm_low_power_mode_init(cfg)) != ESP_OK) {
|
||||
ESP_LOGE(BT_LOG_TAG, "Low power module initialization failed");
|
||||
goto error;
|
||||
@@ -1807,24 +1435,9 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg)
|
||||
coex_init();
|
||||
#endif
|
||||
|
||||
#if CONFIG_BT_BLE_LOG_SPI_OUT_ENABLED
|
||||
if (ble_log_spi_out_init() != 0) {
|
||||
ESP_LOGE(BT_LOG_TAG, "BLE Log SPI output init failed");
|
||||
goto error;
|
||||
}
|
||||
#endif // CONFIG_BT_BLE_LOG_SPI_OUT_ENABLED
|
||||
|
||||
periph_module_enable(PERIPH_BT_MODULE);
|
||||
periph_module_reset(PERIPH_BT_MODULE);
|
||||
|
||||
#if CONFIG_BT_CTRL_LE_LOG_EN
|
||||
err = esp_bt_controller_log_init(log_output_mode);
|
||||
if (err != ESP_OK) {
|
||||
ESP_LOGW(BT_LOG_TAG, "ble_controller_log_init failed %d", err);
|
||||
goto error;
|
||||
}
|
||||
#endif // CONFIG_BT_CTRL_LE_LOG_EN
|
||||
|
||||
err = btdm_controller_init(cfg);
|
||||
|
||||
if (err != 0) {
|
||||
@@ -1833,23 +1446,12 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg)
|
||||
goto error;
|
||||
}
|
||||
|
||||
#if (CONFIG_BT_BLUEDROID_ENABLED || CONFIG_BT_NIMBLE_ENABLED)
|
||||
scan_stack_enableAdvFlowCtrlVsCmd(true);
|
||||
adv_stack_enableClearLegacyAdvVsCmd(true);
|
||||
advFilter_stack_enableDupExcListVsCmd(true);
|
||||
chanSel_stack_enableSetCsaVsCmd(true);
|
||||
#endif // (CONFIG_BT_BLUEDROID_ENABLED || CONFIG_BT_NIMBLE_ENABLED)
|
||||
|
||||
btdm_controller_status = ESP_BT_CONTROLLER_STATUS_INITED;
|
||||
|
||||
return ESP_OK;
|
||||
|
||||
error:
|
||||
|
||||
#if CONFIG_BT_BLE_LOG_SPI_OUT_ENABLED
|
||||
ble_log_spi_out_deinit();
|
||||
#endif // CONFIG_BT_BLE_LOG_SPI_OUT_ENABLED
|
||||
|
||||
bt_controller_deinit_internal();
|
||||
|
||||
return err;
|
||||
@@ -1861,17 +1463,6 @@ esp_err_t esp_bt_controller_deinit(void)
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
#if CONFIG_BT_BLE_LOG_SPI_OUT_ENABLED
|
||||
ble_log_spi_out_deinit();
|
||||
#endif // CONFIG_BT_BLE_LOG_SPI_OUT_ENABLED
|
||||
|
||||
#if (CONFIG_BT_BLUEDROID_ENABLED || CONFIG_BT_NIMBLE_ENABLED)
|
||||
scan_stack_enableAdvFlowCtrlVsCmd(false);
|
||||
adv_stack_enableClearLegacyAdvVsCmd(false);
|
||||
advFilter_stack_enableDupExcListVsCmd(false);
|
||||
chanSel_stack_enableSetCsaVsCmd(false);
|
||||
#endif // (CONFIG_BT_BLUEDROID_ENABLED || CONFIG_BT_NIMBLE_ENABLED)
|
||||
|
||||
btdm_controller_deinit();
|
||||
|
||||
bt_controller_deinit_internal();
|
||||
@@ -1950,10 +1541,6 @@ static void bt_controller_deinit_internal(void)
|
||||
#endif
|
||||
esp_phy_modem_deinit();
|
||||
|
||||
#if CONFIG_BT_CTRL_LE_LOG_EN
|
||||
esp_bt_ontroller_log_deinit();
|
||||
#endif // CONFIG_BT_CTRL_LE_LOG_EN
|
||||
|
||||
if (osi_funcs_p != NULL) {
|
||||
free(osi_funcs_p);
|
||||
osi_funcs_p = NULL;
|
||||
@@ -2282,6 +1869,11 @@ int IRAM_ATTR esp_bt_h4tl_eif_io_event_notify(int event)
|
||||
return btdm_hci_tl_io_event_post(event);
|
||||
}
|
||||
|
||||
uint16_t esp_bt_get_tx_buf_num(void)
|
||||
{
|
||||
return l2c_ble_link_get_tx_buf_num();
|
||||
}
|
||||
|
||||
static void coex_wifi_sleep_set_hook(bool sleep)
|
||||
{
|
||||
|
||||
|
||||
@@ -90,7 +90,7 @@ menu "HCI Config"
|
||||
config BT_LE_HCI_TRANS_TASK_STACK_SIZE
|
||||
int "HCI transport task stack size"
|
||||
depends on !BT_LE_HCI_INTERFACE_USE_RAM
|
||||
default 2048
|
||||
default 1024
|
||||
help
|
||||
This configures stack size of hci transport task
|
||||
endmenu
|
||||
@@ -283,131 +283,54 @@ config BT_LE_CONTROLLER_TASK_STACK_SIZE
|
||||
help
|
||||
This configures stack size of NimBLE controller task
|
||||
|
||||
menu "Controller debug features"
|
||||
menuconfig BT_LE_CONTROLLER_LOG_ENABLED
|
||||
bool "Controller log enable"
|
||||
default n
|
||||
help
|
||||
Enable controller log
|
||||
menuconfig BT_LE_CONTROLLER_LOG_ENABLED
|
||||
bool "Controller log enable"
|
||||
default n
|
||||
help
|
||||
Enable controller log
|
||||
|
||||
config BT_LE_CONTROLLER_LOG_CTRL_ENABLED
|
||||
bool "enable controller log module"
|
||||
depends on BT_LE_CONTROLLER_LOG_ENABLED
|
||||
default y
|
||||
help
|
||||
config BT_LE_CONTROLLER_LOG_CTRL_ENABLED
|
||||
bool "enable controller log module"
|
||||
depends on BT_LE_CONTROLLER_LOG_ENABLED
|
||||
default y
|
||||
help
|
||||
Enable controller log module
|
||||
|
||||
config BT_LE_CONTROLLER_LOG_HCI_ENABLED
|
||||
bool "enable HCI log module"
|
||||
depends on BT_LE_CONTROLLER_LOG_ENABLED
|
||||
default y
|
||||
help
|
||||
config BT_LE_CONTROLLER_LOG_HCI_ENABLED
|
||||
bool "enable HCI log module"
|
||||
depends on BT_LE_CONTROLLER_LOG_ENABLED
|
||||
default y
|
||||
help
|
||||
Enable hci log module
|
||||
|
||||
config BT_LE_CONTROLLER_LOG_DUMP_ONLY
|
||||
bool "Controller log dump mode only"
|
||||
depends on BT_LE_CONTROLLER_LOG_ENABLED
|
||||
default y
|
||||
help
|
||||
config BT_LE_CONTROLLER_LOG_DUMP_ONLY
|
||||
bool "Controller log dump mode only"
|
||||
depends on BT_LE_CONTROLLER_LOG_ENABLED
|
||||
default y
|
||||
help
|
||||
Only operate in dump mode
|
||||
|
||||
config BT_LE_CONTROLLER_LOG_SPI_OUT_ENABLED
|
||||
bool "Output ble controller logs to SPI bus (Experimental)"
|
||||
depends on BT_LE_CONTROLLER_LOG_ENABLED
|
||||
depends on !BT_LE_CONTROLLER_LOG_DUMP_ONLY
|
||||
select BT_BLE_LOG_SPI_OUT_ENABLED
|
||||
default n
|
||||
help
|
||||
Output ble controller logs to SPI bus
|
||||
|
||||
config BT_LE_CONTROLLER_LOG_STORAGE_ENABLE
|
||||
bool "Store ble controller logs to flash(Experimental)"
|
||||
depends on !BT_LE_CONTROLLER_LOG_DUMP_ONLY
|
||||
depends on BT_LE_CONTROLLER_LOG_ENABLED
|
||||
default n
|
||||
help
|
||||
Store ble controller logs to flash memory.
|
||||
|
||||
config BT_LE_CONTROLLER_LOG_PARTITION_SIZE
|
||||
int "size of ble controller log partition(Multiples of 4K)"
|
||||
depends on BT_LE_CONTROLLER_LOG_STORAGE_ENABLE
|
||||
default 65536
|
||||
help
|
||||
The size of ble controller log partition shall be a multiples of 4K.
|
||||
The name of log partition shall be "bt_ctrl_log".
|
||||
The partition type shall be ESP_PARTITION_TYPE_DATA.
|
||||
The partition sub_type shall be ESP_PARTITION_SUBTYPE_ANY.
|
||||
|
||||
config BT_LE_LOG_CTRL_BUF1_SIZE
|
||||
int "size of the first BLE controller LOG buffer"
|
||||
depends on BT_LE_CONTROLLER_LOG_ENABLED
|
||||
default 4096
|
||||
help
|
||||
config BT_LE_LOG_CTRL_BUF1_SIZE
|
||||
int "size of the first BLE controller LOG buffer"
|
||||
depends on BT_LE_CONTROLLER_LOG_ENABLED
|
||||
default 4096
|
||||
help
|
||||
Configure the size of the first BLE controller LOG buffer.
|
||||
|
||||
config BT_LE_LOG_CTRL_BUF2_SIZE
|
||||
int "size of the second BLE controller LOG buffer"
|
||||
depends on BT_LE_CONTROLLER_LOG_ENABLED
|
||||
default 1024
|
||||
help
|
||||
config BT_LE_LOG_CTRL_BUF2_SIZE
|
||||
int "size of the second BLE controller LOG buffer"
|
||||
depends on BT_LE_CONTROLLER_LOG_ENABLED
|
||||
default 1024
|
||||
help
|
||||
Configure the size of the second BLE controller LOG buffer.
|
||||
|
||||
config BT_LE_LOG_HCI_BUF_SIZE
|
||||
int "size of the BLE HCI LOG buffer"
|
||||
depends on BT_LE_CONTROLLER_LOG_ENABLED
|
||||
default 4096
|
||||
help
|
||||
config BT_LE_LOG_HCI_BUF_SIZE
|
||||
int "size of the BLE HCI LOG buffer"
|
||||
depends on BT_LE_CONTROLLER_LOG_ENABLED
|
||||
default 4096
|
||||
help
|
||||
Configure the size of the BLE HCI LOG buffer.
|
||||
|
||||
config BT_LE_CONTROLLER_LOG_WRAP_PANIC_HANDLER_ENABLE
|
||||
bool "Enable wrap panic handler"
|
||||
depends on BT_LE_CONTROLLER_LOG_ENABLED
|
||||
default n
|
||||
help
|
||||
Wrap esp_panic_handler to get controller logs when PC pointer exception crashes.
|
||||
|
||||
config BT_LE_CONTROLLER_LOG_TASK_WDT_USER_HANDLER_ENABLE
|
||||
bool "Enable esp_task_wdt_isr_user_handler implementation"
|
||||
depends on BT_LE_CONTROLLER_LOG_ENABLED
|
||||
default n
|
||||
help
|
||||
Implement esp_task_wdt_isr_user_handler to get controller logs when task wdt issue is triggered.
|
||||
|
||||
config BT_LE_CONTROLLER_LOG_OUTPUT_LEVEL
|
||||
int "The output level of controller log"
|
||||
depends on BT_LE_CONTROLLER_LOG_ENABLED
|
||||
range 0 5
|
||||
default 1
|
||||
help
|
||||
The output level of controller log.
|
||||
|
||||
config BT_LE_CONTROLLER_LOG_MOD_OUTPUT_SWITCH
|
||||
hex "The switch of module log output"
|
||||
depends on BT_LE_CONTROLLER_LOG_ENABLED
|
||||
range 0 0xFFFFFFFF
|
||||
default 0xFFFFFFFF
|
||||
help
|
||||
The switch of module log output, this is an unsigned 32-bit hexadecimal value.
|
||||
|
||||
config BT_LE_ERROR_SIM_ENABLED
|
||||
bool "Enable controller features for internal testing"
|
||||
default n
|
||||
|
||||
config BT_LE_ASSERT_WHEN_ABNORMAL_DISCONN_ENABLED
|
||||
bool "When ACL disconnects abnormally, assertion processing is performed(Experimental)"
|
||||
default n
|
||||
|
||||
config BT_LE_DEBUG_REMAIN_SCENE_ENABLED
|
||||
bool "Remain scene with GDB to capture relevant status info(Experimental)"
|
||||
default n
|
||||
help
|
||||
Retain scene with GDB to capture info, requires disabling WDT (CONFIG_ESP_INT_WDT, CONFIG_ESP_TASK_WDT_EN).
|
||||
|
||||
config BT_LE_PTR_CHECK_ENABLED
|
||||
bool "Enable boundary check for internal memory"
|
||||
default n
|
||||
endmenu
|
||||
|
||||
config BT_LE_LL_RESOLV_LIST_SIZE
|
||||
int "BLE LL Resolving list size"
|
||||
range 1 5
|
||||
@@ -463,7 +386,7 @@ config BT_LE_CRYPTO_STACK_MBEDTLS
|
||||
|
||||
config BT_LE_WHITELIST_SIZE
|
||||
int "BLE white list size"
|
||||
range 1 31
|
||||
range 1 15
|
||||
default 12
|
||||
depends on !BT_NIMBLE_ENABLED
|
||||
|
||||
@@ -484,23 +407,6 @@ config BT_LE_LL_SCA
|
||||
help
|
||||
Sleep clock accuracy of our device (in ppm)
|
||||
|
||||
config BT_LE_LL_PEER_SCA_SET_ENABLE
|
||||
bool "Enable to set constant peer SCA"
|
||||
default n
|
||||
help
|
||||
Enable setting of constant peer SCA, use this if peer device has SCA larger than 500 PPM.
|
||||
Enable this option, the controller will always use BT_LE_LL_PEER_SCA as the peer SCA value
|
||||
to calculate the window widening instead of the value received from peer device.
|
||||
|
||||
|
||||
config BT_LE_LL_PEER_SCA
|
||||
int "Constant peer sleep clock accuracy value"
|
||||
range 0 10000
|
||||
depends on BT_LE_LL_PEER_SCA_SET_ENABLE
|
||||
default 0
|
||||
help
|
||||
Set the sleep clock accuracy of peer device
|
||||
|
||||
config BT_LE_MAX_CONNECTIONS
|
||||
int "Maximum number of concurrent connections"
|
||||
depends on !BT_NIMBLE_ENABLED
|
||||
@@ -571,7 +477,6 @@ config BT_LE_USE_ESP_TIMER
|
||||
help
|
||||
Set this option to use Esp Timer which has higher priority timer
|
||||
instead of FreeRTOS timer
|
||||
|
||||
config BT_CTRL_BLE_ADV_REPORT_FLOW_CTRL_SUPP
|
||||
bool "BLE adv report flow control supported"
|
||||
default y
|
||||
@@ -670,145 +575,3 @@ config BT_LE_SCAN_DUPL_CACHE_REFRESH_PERIOD
|
||||
config BT_LE_MSYS_INIT_IN_CONTROLLER
|
||||
bool "Msys Mbuf Init in Controller"
|
||||
default y
|
||||
|
||||
config BT_LE_TX_CCA_ENABLED
|
||||
bool "Enable TX CCA feature"
|
||||
default n
|
||||
help
|
||||
Enable CCA feature to cancel sending the packet if the signal power is stronger than CCA threshold.
|
||||
|
||||
config BT_LE_CCA_RSSI_THRESH
|
||||
int "CCA RSSI threshold value"
|
||||
depends on BT_LE_TX_CCA_ENABLED
|
||||
range 20 100
|
||||
default 20
|
||||
help
|
||||
Power threshold of CCA in unit of -1 dBm.
|
||||
|
||||
choice BT_LE_DFT_TX_POWER_LEVEL_DBM
|
||||
prompt "BLE default Tx power level(dBm)"
|
||||
default BT_LE_DFT_TX_POWER_LEVEL_P9
|
||||
help
|
||||
Specify default Tx power level(dBm).
|
||||
config BT_LE_DFT_TX_POWER_LEVEL_N24
|
||||
bool "-24dBm"
|
||||
config BT_LE_DFT_TX_POWER_LEVEL_N21
|
||||
bool "-21dBm"
|
||||
config BT_LE_DFT_TX_POWER_LEVEL_N18
|
||||
bool "-18dBm"
|
||||
config BT_LE_DFT_TX_POWER_LEVEL_N15
|
||||
bool "-15dBm"
|
||||
config BT_LE_DFT_TX_POWER_LEVEL_N12
|
||||
bool "-12dBm"
|
||||
config BT_LE_DFT_TX_POWER_LEVEL_N9
|
||||
bool "-9dBm"
|
||||
config BT_LE_DFT_TX_POWER_LEVEL_N6
|
||||
bool "-6dBm"
|
||||
config BT_LE_DFT_TX_POWER_LEVEL_N3
|
||||
bool "-3dBm"
|
||||
config BT_LE_DFT_TX_POWER_LEVEL_N0
|
||||
bool "0dBm"
|
||||
config BT_LE_DFT_TX_POWER_LEVEL_P3
|
||||
bool "+3dBm"
|
||||
config BT_LE_DFT_TX_POWER_LEVEL_P6
|
||||
bool "+6dBm"
|
||||
config BT_LE_DFT_TX_POWER_LEVEL_P9
|
||||
bool "+9dBm"
|
||||
config BT_LE_DFT_TX_POWER_LEVEL_P12
|
||||
bool "+12dBm"
|
||||
config BT_LE_DFT_TX_POWER_LEVEL_P15
|
||||
bool "+15dBm"
|
||||
config BT_LE_DFT_TX_POWER_LEVEL_P18
|
||||
bool "+18dBm"
|
||||
config BT_LE_DFT_TX_POWER_LEVEL_P20
|
||||
bool "+20dBm"
|
||||
endchoice
|
||||
|
||||
config BT_LE_DFT_TX_POWER_LEVEL_DBM_EFF
|
||||
int
|
||||
default -15 if BT_LE_DFT_TX_POWER_LEVEL_N15
|
||||
default -12 if BT_LE_DFT_TX_POWER_LEVEL_N12
|
||||
default -9 if BT_LE_DFT_TX_POWER_LEVEL_N9
|
||||
default -6 if BT_LE_DFT_TX_POWER_LEVEL_N6
|
||||
default -3 if BT_LE_DFT_TX_POWER_LEVEL_N3
|
||||
default 0 if BT_LE_DFT_TX_POWER_LEVEL_N0
|
||||
default 3 if BT_LE_DFT_TX_POWER_LEVEL_P3
|
||||
default 6 if BT_LE_DFT_TX_POWER_LEVEL_P6
|
||||
default 9 if BT_LE_DFT_TX_POWER_LEVEL_P9
|
||||
default 12 if BT_LE_DFT_TX_POWER_LEVEL_P12
|
||||
default 15 if BT_LE_DFT_TX_POWER_LEVEL_P15
|
||||
default 18 if BT_LE_DFT_TX_POWER_LEVEL_P18
|
||||
default 20 if BT_LE_DFT_TX_POWER_LEVEL_P20
|
||||
default 0
|
||||
|
||||
config BT_LE_CTRL_CHECK_CONNECT_IND_ACCESS_ADDRESS
|
||||
bool "Enable enhanced Access Address check in CONNECT_IND"
|
||||
default n
|
||||
help
|
||||
Enabling this option will add stricter verification of the Access Address in the CONNECT_IND PDU.
|
||||
This improves security by ensuring that only connection requests with valid Access Addresses are accepted.
|
||||
If disabled, only basic checks are applied, improving compatibility.
|
||||
|
||||
config BT_CTRL_RUN_IN_FLASH_ONLY
|
||||
bool "Reduce BLE IRAM usage (READ DOCS FIRST) (EXPERIMENTAL)"
|
||||
default n
|
||||
help
|
||||
Move most IRAM into flash. This will increase the usage of flash and reduce ble performance.
|
||||
Because the code is moved to the flash, the execution speed of the code is reduced.
|
||||
To have a small impact on performance, you need to enable flash suspend (SPI_FLASH_AUTO_SUSPEND).
|
||||
|
||||
menu "BLE disconnects when Instant Passed (0x28) occurs"
|
||||
config BT_LE_CTRL_LLCP_CONN_UPDATE
|
||||
bool "BLE ACL connection update procedure"
|
||||
default n
|
||||
help
|
||||
If this option is enabled, Controller will terminate the connection
|
||||
when Instant Passed (0x28) error occurs during connection update procedure.
|
||||
|
||||
config BT_LE_CTRL_LLCP_CHAN_MAP_UPDATE
|
||||
bool "BLE ACL channel map update procedure"
|
||||
default n
|
||||
help
|
||||
If this option is enabled, Controller will terminate the connection
|
||||
when Instant Passed (0x28) error occurs in channel map update procedure.
|
||||
|
||||
config BT_LE_CTRL_LLCP_PHY_UPDATE
|
||||
bool "BLE ACL PHY update procedure"
|
||||
default n
|
||||
help
|
||||
If this option is enabled, Controller will terminate the connection
|
||||
when Instant Passed (0x28) error occurs in PHY update procedure.
|
||||
endmenu
|
||||
|
||||
config BT_CTRL_SCAN_BACKOFF_UPPERLIMITMAX
|
||||
int "The value of upperlimitmax during scan backoff procedure"
|
||||
range 1 256
|
||||
default 32
|
||||
help
|
||||
The value of upperlimitmax needs to be a power of 2.
|
||||
|
||||
config BT_LE_CTRL_CHAN_ASS_EN
|
||||
bool "Enable channel assessment(Experimental)"
|
||||
default n
|
||||
help
|
||||
If this option is enabled, The Controller will records the communication quality
|
||||
for each channel and then start a timer to check and update the channel map every 4 seconds.
|
||||
|
||||
config BT_LE_CTRL_ADV_DATA_LENGTH_ZERO_AUX
|
||||
bool "Enable aux packet when ext adv data length is zero(Experimental)"
|
||||
default y
|
||||
help
|
||||
When this option is enabled, auxiliary packets will be present in the events of
|
||||
'Non-Connectable and Non-Scannable' regardless of whether the advertising length is 0.
|
||||
If this option is not enabled, auxiliary packets will only be present when the advertising length is not 0.
|
||||
|
||||
config BT_LE_RXBUF_OPT_ENABLED
|
||||
bool "Enable rxbuf optimization feature"
|
||||
default y
|
||||
|
||||
config BT_LE_CTRL_FAST_CONN_DATA_TX_EN
|
||||
bool "Enable fast sending of connection data"
|
||||
default y
|
||||
help
|
||||
If this option is enabled, The Controller will continue to
|
||||
Send an empty PDU after sending valid connection data within an interval.
|
||||
|
||||
@@ -1,158 +0,0 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "sdkconfig.h"
|
||||
#include "esp_bt_cfg.h"
|
||||
#include "esp_bit_defs.h"
|
||||
|
||||
/* External functions or variables
|
||||
************************************************************************
|
||||
*/
|
||||
int base_stack_initEnv(void);
|
||||
void base_stack_deinitEnv(void);
|
||||
int base_stack_enable(void);
|
||||
void base_stack_disable(void);
|
||||
|
||||
int conn_stack_initEnv(void);
|
||||
void conn_stack_deinitEnv(void);
|
||||
int conn_stack_enable(void);
|
||||
void conn_stack_disable(void);
|
||||
|
||||
#if CONFIG_BT_LE_ERROR_SIM_ENABLED
|
||||
int conn_errorSim_initEnv(void);
|
||||
void conn_errorSim_deinitEnv(void);
|
||||
int conn_errorSim_enable(void);
|
||||
void conn_errorSim_disable(void);
|
||||
#endif // CONFIG_BT_LE_ERROR_SIM_ENABLED
|
||||
|
||||
#if (CONFIG_BT_NIMBLE_ENABLED || CONFIG_BT_BLUEDROID_ENABLED)
|
||||
void adv_stack_enableClearLegacyAdvVsCmd(bool en);
|
||||
void scan_stack_enableAdvFlowCtrlVsCmd(bool en);
|
||||
void advFilter_stack_enableDupExcListVsCmd(bool en);
|
||||
void arr_stack_enableMultiConnVsCmd(bool en);
|
||||
void pcl_stack_enableSetRssiThreshVsCmd(bool en);
|
||||
void chanSel_stack_enableSetCsaVsCmd(bool en);
|
||||
void log_stack_enableLogsRelatedVsCmd(bool en);
|
||||
void hci_stack_enableSetVsEvtMaskVsCmd(bool en);
|
||||
void winWiden_stack_enableSetConstPeerScaVsCmd(bool en);
|
||||
|
||||
void adv_stack_enableScanReqRxdVsEvent(bool en);
|
||||
void conn_stack_enableChanMapUpdCompVsEvent(bool en);
|
||||
void sleep_stack_enableWakeupVsEvent(bool en);
|
||||
#endif // (CONFIG_BT_NIMBLE_ENABLED || CONFIG_BT_BLUEDROID_ENABLED)
|
||||
|
||||
/* Local functions definition
|
||||
***************************************************************************
|
||||
*/
|
||||
#if (CONFIG_BT_NIMBLE_ENABLED || CONFIG_BT_BLUEDROID_ENABLED)
|
||||
void ble_stack_enableVsCmds(bool en)
|
||||
{
|
||||
adv_stack_enableClearLegacyAdvVsCmd(en);
|
||||
advFilter_stack_enableDupExcListVsCmd(en);
|
||||
scan_stack_enableAdvFlowCtrlVsCmd(en);
|
||||
arr_stack_enableMultiConnVsCmd(en);
|
||||
pcl_stack_enableSetRssiThreshVsCmd(en);
|
||||
chanSel_stack_enableSetCsaVsCmd(en);
|
||||
log_stack_enableLogsRelatedVsCmd(en);
|
||||
hci_stack_enableSetVsEvtMaskVsCmd(en);
|
||||
winWiden_stack_enableSetConstPeerScaVsCmd(en);
|
||||
}
|
||||
|
||||
void ble_stack_enableVsEvents(bool en)
|
||||
{
|
||||
adv_stack_enableScanReqRxdVsEvent(en);
|
||||
conn_stack_enableChanMapUpdCompVsEvent(en);
|
||||
|
||||
#if CONFIG_BT_LE_SLEEP_ENABLE
|
||||
sleep_stack_enableWakeupVsEvent(en);
|
||||
#endif // CONFIG_BT_LE_SLEEP_ENABLE
|
||||
}
|
||||
#endif // (CONFIG_BT_NIMBLE_ENABLED || CONFIG_BT_BLUEDROID_ENABLED)
|
||||
|
||||
int ble_stack_initEnv(void)
|
||||
{
|
||||
int rc;
|
||||
|
||||
rc = base_stack_initEnv();
|
||||
if (rc) {
|
||||
return rc;
|
||||
}
|
||||
|
||||
#if DEFAULT_BT_LE_MAX_CONNECTIONS
|
||||
rc = conn_stack_initEnv();
|
||||
if (rc) {
|
||||
return rc;
|
||||
}
|
||||
#if CONFIG_BT_LE_ERROR_SIM_ENABLED
|
||||
rc = conn_errorSim_initEnv();
|
||||
if (rc) {
|
||||
return rc;
|
||||
}
|
||||
#endif // CONFIG_BT_LE_ERROR_SIM_ENABLED
|
||||
#endif // DEFAULT_BT_LE_MAX_CONNECTIONS
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void ble_stack_deinitEnv(void)
|
||||
{
|
||||
#if DEFAULT_BT_LE_MAX_CONNECTIONS
|
||||
#if CONFIG_BT_LE_ERROR_SIM_ENABLED
|
||||
conn_errorSim_deinitEnv();
|
||||
#endif // CONFIG_BT_LE_ERROR_SIM_ENABLED
|
||||
conn_stack_deinitEnv();
|
||||
#endif // DEFAULT_BT_LE_MAX_CONNECTIONS
|
||||
|
||||
base_stack_deinitEnv();
|
||||
}
|
||||
|
||||
int ble_stack_enable(void)
|
||||
{
|
||||
int rc;
|
||||
|
||||
rc = base_stack_enable();
|
||||
if (rc) {
|
||||
return rc;
|
||||
}
|
||||
|
||||
#if DEFAULT_BT_LE_MAX_CONNECTIONS
|
||||
rc = conn_stack_enable();
|
||||
if (rc) {
|
||||
return rc;
|
||||
}
|
||||
#if CONFIG_BT_LE_ERROR_SIM_ENABLED
|
||||
rc = conn_errorSim_enable();
|
||||
if (rc) {
|
||||
return rc;
|
||||
}
|
||||
#endif // CONFIG_BT_LE_ERROR_SIM_ENABLED
|
||||
#endif // DEFAULT_BT_LE_MAX_CONNECTIONS
|
||||
|
||||
#if (CONFIG_BT_NIMBLE_ENABLED || CONFIG_BT_BLUEDROID_ENABLED)
|
||||
ble_stack_enableVsCmds(true);
|
||||
ble_stack_enableVsEvents(true);
|
||||
#endif // (CONFIG_BT_NIMBLE_ENABLED || CONFIG_BT_BLUEDROID_ENABLED)
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void ble_stack_disable(void)
|
||||
{
|
||||
#if (CONFIG_BT_NIMBLE_ENABLED || CONFIG_BT_BLUEDROID_ENABLED)
|
||||
ble_stack_enableVsEvents(false);
|
||||
ble_stack_enableVsCmds(false);
|
||||
#endif // (CONFIG_BT_NIMBLE_ENABLED || CONFIG_BT_BLUEDROID_ENABLED)
|
||||
|
||||
#if DEFAULT_BT_LE_MAX_CONNECTIONS
|
||||
#if CONFIG_BT_LE_ERROR_SIM_ENABLED
|
||||
conn_errorSim_disable();
|
||||
#endif // CONFIG_BT_LE_ERROR_SIM_ENABLED
|
||||
conn_stack_disable();
|
||||
#endif // DEFAULT_BT_LE_MAX_CONNECTIONS
|
||||
|
||||
base_stack_disable();
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
int ble_stack_initEnv(void);
|
||||
|
||||
void ble_stack_deinitEnv(void);
|
||||
|
||||
int ble_stack_enable(void);
|
||||
|
||||
void ble_stack_disable(void);
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -34,7 +34,6 @@
|
||||
#include "os/endian.h"
|
||||
|
||||
#include "esp_bt.h"
|
||||
#include "ble_priv.h"
|
||||
#include "esp_intr_alloc.h"
|
||||
#include "esp_sleep.h"
|
||||
#include "esp_pm.h"
|
||||
@@ -52,14 +51,8 @@
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/task.h"
|
||||
|
||||
#include "esp_private/esp_clk_tree_common.h"
|
||||
#include "hal/efuse_hal.h"
|
||||
#include "soc/rtc.h"
|
||||
|
||||
#if CONFIG_BT_BLE_LOG_SPI_OUT_ENABLED
|
||||
#include "ble_log/ble_log_spi_out.h"
|
||||
#endif // CONFIG_BT_BLE_LOG_SPI_OUT_ENABLED
|
||||
|
||||
/* Macro definition
|
||||
************************************************************************
|
||||
*/
|
||||
@@ -67,7 +60,7 @@
|
||||
#define OSI_COEX_VERSION 0x00010006
|
||||
#define OSI_COEX_MAGIC_VALUE 0xFADEBEAD
|
||||
|
||||
#define EXT_FUNC_VERSION 0x20250415
|
||||
#define EXT_FUNC_VERSION 0x20240422
|
||||
#define EXT_FUNC_MAGIC_VALUE 0xA5A5A5A5
|
||||
|
||||
#define BT_ASSERT_PRINT ets_printf
|
||||
@@ -98,33 +91,25 @@ struct ext_funcs_t {
|
||||
int (* _ecc_gen_key_pair)(uint8_t *public, uint8_t *priv);
|
||||
int (* _ecc_gen_dh_key)(const uint8_t *remote_pub_key_x, const uint8_t *remote_pub_key_y,
|
||||
const uint8_t *local_priv_key, uint8_t *dhkey);
|
||||
void (* _esp_reset_rpa_moudle)(void);
|
||||
uint32_t magic;
|
||||
};
|
||||
|
||||
#if CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
|
||||
typedef void (*interface_func_t) (uint32_t len, const uint8_t *addr, uint32_t len_append, const uint8_t *addr_append, uint32_t flag);
|
||||
|
||||
enum {
|
||||
BLE_LOG_INTERFACE_FLAG_CONTINUE = 0,
|
||||
BLE_LOG_INTERFACE_FLAG_END,
|
||||
};
|
||||
typedef void (*interface_func_t) (uint32_t len, const uint8_t*addr, bool end);
|
||||
#endif // CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
|
||||
|
||||
/* External functions or variables
|
||||
************************************************************************
|
||||
*/
|
||||
extern int ble_osi_coex_funcs_register(struct osi_coex_funcs_t *coex_funcs);
|
||||
extern int r_ble_controller_init(esp_bt_controller_config_t *cfg);
|
||||
extern void esp_ble_controller_info_capture(uint32_t cycle_times);
|
||||
#if CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
|
||||
extern int r_ble_log_init_async(interface_func_t interface, bool task_create, uint8_t buffers, uint32_t *bufs_size);
|
||||
extern int r_ble_log_init_async(interface_func_t bt_controller_log_interface, bool task_create, uint8_t buffers, uint32_t *bufs_size);
|
||||
extern int r_ble_log_deinit_async(void);
|
||||
extern int r_ble_log_init_simple(interface_func_t interface, void *handler);
|
||||
extern void r_ble_log_deinit_simple(void);
|
||||
extern void r_ble_log_async_select_dump_buffers(uint8_t buffers);
|
||||
extern void r_ble_log_async_output_dump_all(bool output);
|
||||
extern void esp_panic_handler_feed_wdts(void);
|
||||
extern int r_ble_log_ctrl_level_and_mod(uint8_t log_level, uint32_t mod_switch);
|
||||
extern int r_ble_ctrl_mod_type(uint16_t mod, uint32_t mod_type_switch);
|
||||
extern void esp_panic_handler_reconfigure_wdts(uint32_t timeout_ms);
|
||||
#endif // CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
|
||||
extern int r_ble_controller_deinit(void);
|
||||
extern int r_ble_controller_enable(uint8_t mode);
|
||||
@@ -142,17 +127,11 @@ extern void r_ble_lll_rfmgmt_set_sleep_cb(void *s_cb, void *w_cb, void *s_arg,
|
||||
extern void r_ble_rtc_wake_up_state_clr(void);
|
||||
extern int os_msys_init(void);
|
||||
extern void os_msys_deinit(void);
|
||||
#if CONFIG_BT_CTRL_RUN_IN_FLASH_ONLY
|
||||
extern void r_ble_ll_scan_start_time_init_compensation(uint32_t init_compensation);
|
||||
extern void r_priv_sdk_config_insert_proc_time_set(uint16_t insert_proc_time);
|
||||
#endif // CONFIG_BT_CTRL_RUN_IN_FLASH_ONLY
|
||||
#if CONFIG_FREERTOS_USE_TICKLESS_IDLE
|
||||
extern sleep_retention_entries_config_t *r_esp_ble_mac_retention_link_get(uint8_t *size, uint8_t extra);
|
||||
extern void r_esp_ble_set_wakeup_overhead(uint32_t overhead);
|
||||
#endif /* CONFIG_FREERTOS_USE_TICKLESS_IDLE */
|
||||
#if CONFIG_BT_LE_LL_PEER_SCA_SET_ENABLE
|
||||
extern void r_ble_ll_customize_peer_sca_set(uint16_t peer_sca);
|
||||
#endif // CONFIG_BT_LE_LL_PEER_SCA_SET_ENABLE
|
||||
extern void r_esp_ble_change_rtc_freq(uint32_t freq);
|
||||
extern int ble_sm_alg_gen_dhkey(const uint8_t *peer_pub_key_x,
|
||||
const uint8_t *peer_pub_key_y,
|
||||
const uint8_t *our_priv_key, uint8_t *out_dhkey);
|
||||
@@ -185,236 +164,20 @@ static int esp_intr_alloc_wrapper(int source, int flags, intr_handler_t handler,
|
||||
static int esp_intr_free_wrapper(void **ret_handle);
|
||||
static void osi_assert_wrapper(const uint32_t ln, const char *fn, uint32_t param1, uint32_t param2);
|
||||
static uint32_t osi_random_wrapper(void);
|
||||
static void esp_reset_rpa_moudle(void);
|
||||
static int esp_ecc_gen_key_pair(uint8_t *pub, uint8_t *priv);
|
||||
static int esp_ecc_gen_dh_key(const uint8_t *peer_pub_key_x, const uint8_t *peer_pub_key_y,
|
||||
const uint8_t *our_priv_key, uint8_t *out_dhkey);
|
||||
#if CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
|
||||
#if !CONFIG_BT_LE_CONTROLLER_LOG_SPI_OUT_ENABLED
|
||||
static void esp_bt_controller_log_interface(uint32_t len, const uint8_t *addr, uint32_t len_append, const uint8_t *addr_append, uint32_t flag);
|
||||
#endif // !CONFIG_BT_LE_CONTROLLER_LOG_SPI_OUT_ENABLED
|
||||
#if CONFIG_BT_LE_CONTROLLER_LOG_STORAGE_ENABLE
|
||||
static void esp_bt_ctrl_log_partition_get_and_erase_first_block(void);
|
||||
#endif // CONFIG_BT_LE_CONTROLLER_LOG_STORAGE_ENABLE
|
||||
static void esp_bt_controller_log_interface(uint32_t len, const uint8_t *addr, bool end);
|
||||
#endif // CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
|
||||
/* Local variable definition
|
||||
***************************************************************************
|
||||
*/
|
||||
/* Static variable declare */
|
||||
static DRAM_ATTR esp_bt_controller_status_t ble_controller_status = ESP_BT_CONTROLLER_STATUS_IDLE;
|
||||
|
||||
#if CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
|
||||
const static uint32_t log_bufs_size[] = {CONFIG_BT_LE_LOG_CTRL_BUF1_SIZE, CONFIG_BT_LE_LOG_HCI_BUF_SIZE, CONFIG_BT_LE_LOG_CTRL_BUF2_SIZE};
|
||||
static bool log_is_inited = false;
|
||||
|
||||
esp_err_t esp_bt_controller_log_init(void)
|
||||
{
|
||||
if (log_is_inited) {
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
#if CONFIG_BT_BLE_LOG_SPI_OUT_ENABLED
|
||||
if (ble_log_spi_out_init() != 0) {
|
||||
goto spi_out_init_failed;
|
||||
}
|
||||
#endif // CONFIG_BT_BLE_LOG_SPI_OUT_ENABLED
|
||||
|
||||
#if CONFIG_BT_LE_CONTROLLER_LOG_SPI_OUT_ENABLED
|
||||
if (r_ble_log_init_simple(ble_log_spi_out_ll_write, ble_log_spi_out_ll_log_ev_proc) != 0) {
|
||||
goto log_init_failed;
|
||||
}
|
||||
#else // !CONFIG_BT_LE_CONTROLLER_LOG_SPI_OUT_ENABLED
|
||||
uint8_t buffers = 0;
|
||||
#if CONFIG_BT_LE_CONTROLLER_LOG_CTRL_ENABLED
|
||||
buffers |= ESP_BLE_LOG_BUF_CONTROLLER;
|
||||
#endif // CONFIG_BT_LE_CONTROLLER_LOG_CTRL_ENABLED
|
||||
#if CONFIG_BT_LE_CONTROLLER_LOG_HCI_ENABLED
|
||||
buffers |= ESP_BLE_LOG_BUF_HCI;
|
||||
#endif // CONFIG_BT_LE_CONTROLLER_LOG_HCI_ENABLED
|
||||
|
||||
bool task_create = true;
|
||||
#if CONFIG_BT_LE_CONTROLLER_LOG_DUMP_ONLY
|
||||
task_create = false;
|
||||
#elif CONFIG_BT_LE_CONTROLLER_LOG_STORAGE_ENABLE
|
||||
esp_bt_ctrl_log_partition_get_and_erase_first_block();
|
||||
#endif // CONFIG_BT_LE_CONTROLLER_LOG_SPI_OUT_ENABLED
|
||||
|
||||
if (r_ble_log_init_async(esp_bt_controller_log_interface, task_create, buffers, (uint32_t *)log_bufs_size) != 0) {
|
||||
goto log_init_failed;
|
||||
}
|
||||
#endif // CONFIG_BT_LE_CONTROLLER_LOG_SPI_OUT_ENABLED
|
||||
|
||||
if (r_ble_log_ctrl_level_and_mod(CONFIG_BT_LE_CONTROLLER_LOG_OUTPUT_LEVEL, CONFIG_BT_LE_CONTROLLER_LOG_MOD_OUTPUT_SWITCH) != ESP_OK) {
|
||||
goto ctrl_level_init_failed;
|
||||
}
|
||||
log_is_inited = true;
|
||||
return ESP_OK;
|
||||
|
||||
ctrl_level_init_failed:
|
||||
#if CONFIG_BT_LE_CONTROLLER_LOG_SPI_OUT_ENABLED
|
||||
r_ble_log_deinit_simple();
|
||||
#else // !CONFIG_BT_LE_CONTROLLER_LOG_SPI_OUT_ENABLED
|
||||
r_ble_log_deinit_async();
|
||||
#endif // CONFIG_BT_LE_CONTROLLER_LOG_SPI_OUT_ENABLED
|
||||
log_init_failed:
|
||||
#if CONFIG_BT_BLE_LOG_SPI_OUT_ENABLED
|
||||
ble_log_spi_out_deinit();
|
||||
spi_out_init_failed:
|
||||
#endif // CONFIG_BT_BLE_LOG_SPI_OUT_ENABLED
|
||||
return ESP_FAIL;
|
||||
}
|
||||
|
||||
void esp_bt_controller_log_deinit(void)
|
||||
{
|
||||
#if CONFIG_BT_BLE_LOG_SPI_OUT_ENABLED
|
||||
ble_log_spi_out_deinit();
|
||||
#endif // CONFIG_BT_BLE_LOG_SPI_OUT_ENABLED
|
||||
|
||||
#if CONFIG_BT_LE_CONTROLLER_LOG_SPI_OUT_ENABLED
|
||||
r_ble_log_deinit_simple();
|
||||
#else // !CONFIG_BT_LE_CONTROLLER_LOG_SPI_OUT_ENABLED
|
||||
r_ble_log_deinit_async();
|
||||
#endif // CONFIG_BT_LE_CONTROLLER_LOG_SPI_OUT_ENABLED
|
||||
|
||||
log_is_inited = false;
|
||||
}
|
||||
|
||||
#if CONFIG_BT_LE_CONTROLLER_LOG_STORAGE_ENABLE
|
||||
#include "esp_partition.h"
|
||||
#include "hal/wdt_hal.h"
|
||||
|
||||
#define MAX_STORAGE_SIZE (CONFIG_BT_LE_CONTROLLER_LOG_PARTITION_SIZE)
|
||||
#define BLOCK_SIZE (4096)
|
||||
#define THRESHOLD (3072)
|
||||
#define PARTITION_NAME "bt_ctrl_log"
|
||||
|
||||
static const esp_partition_t *log_partition;
|
||||
static uint32_t write_index = 0;
|
||||
static uint32_t next_erase_index = BLOCK_SIZE;
|
||||
static bool block_erased = false;
|
||||
static bool stop_write = false;
|
||||
static bool is_filled = false;
|
||||
|
||||
static void esp_bt_ctrl_log_partition_get_and_erase_first_block(void)
|
||||
{
|
||||
log_partition = NULL;
|
||||
assert(MAX_STORAGE_SIZE % BLOCK_SIZE == 0);
|
||||
// Find the partition map in the partition table
|
||||
log_partition = esp_partition_find_first(ESP_PARTITION_TYPE_DATA, ESP_PARTITION_SUBTYPE_ANY, PARTITION_NAME);
|
||||
assert(log_partition != NULL);
|
||||
// Prepare data to be read later using the mapped address
|
||||
ESP_ERROR_CHECK(esp_partition_erase_range(log_partition, 0, BLOCK_SIZE));
|
||||
write_index = 0;
|
||||
next_erase_index = BLOCK_SIZE;
|
||||
block_erased = false;
|
||||
is_filled = false;
|
||||
stop_write = false;
|
||||
}
|
||||
|
||||
static int esp_bt_controller_log_storage(uint32_t len, const uint8_t *addr, bool end)
|
||||
{
|
||||
if (len > MAX_STORAGE_SIZE) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (stop_write) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (((write_index) % BLOCK_SIZE) >= THRESHOLD && !block_erased) {
|
||||
// esp_rom_printf("Ers nxt: %d,%d\n", next_erase_index, write_index);
|
||||
esp_partition_erase_range(log_partition, next_erase_index, BLOCK_SIZE);
|
||||
next_erase_index = (next_erase_index + BLOCK_SIZE) % MAX_STORAGE_SIZE;
|
||||
block_erased = true;
|
||||
}
|
||||
|
||||
if (((write_index + len) / BLOCK_SIZE) > (write_index / BLOCK_SIZE)) {
|
||||
block_erased = false;
|
||||
}
|
||||
|
||||
if (write_index + len <= MAX_STORAGE_SIZE) {
|
||||
esp_partition_write(log_partition, write_index, addr, len);
|
||||
write_index = (write_index + len) % MAX_STORAGE_SIZE;
|
||||
} else {
|
||||
uint32_t first_part_len = MAX_STORAGE_SIZE - write_index;
|
||||
esp_partition_write(log_partition, write_index, addr, first_part_len);
|
||||
esp_partition_write(log_partition, 0, addr + first_part_len, len - first_part_len);
|
||||
write_index = len - first_part_len;
|
||||
is_filled = true;
|
||||
// esp_rom_printf("old idx: %d,%d\n",next_erase_index, write_index);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void esp_bt_read_ctrl_log_from_flash(bool output)
|
||||
{
|
||||
esp_partition_mmap_handle_t mmap_handle;
|
||||
uint32_t read_index;
|
||||
const void *mapped_ptr;
|
||||
const uint8_t *buffer;
|
||||
uint32_t print_len;
|
||||
uint32_t max_print_len;
|
||||
esp_err_t err;
|
||||
|
||||
print_len = 0;
|
||||
max_print_len = 4096;
|
||||
err = esp_partition_mmap(log_partition, 0, MAX_STORAGE_SIZE, ESP_PARTITION_MMAP_DATA, &mapped_ptr, &mmap_handle);
|
||||
if (err != ESP_OK) {
|
||||
ESP_LOGE("FLASH", "Mmap failed: %s", esp_err_to_name(err));
|
||||
return;
|
||||
}
|
||||
|
||||
portMUX_TYPE spinlock = portMUX_INITIALIZER_UNLOCKED;
|
||||
portENTER_CRITICAL_SAFE(&spinlock);
|
||||
esp_panic_handler_feed_wdts();
|
||||
r_ble_log_async_output_dump_all(true);
|
||||
esp_bt_controller_log_deinit();
|
||||
stop_write = true;
|
||||
|
||||
buffer = (const uint8_t *)mapped_ptr;
|
||||
esp_panic_handler_feed_wdts();
|
||||
if (is_filled) {
|
||||
read_index = next_erase_index;
|
||||
} else {
|
||||
read_index = 0;
|
||||
}
|
||||
|
||||
esp_rom_printf("\r\nREAD_CHECK:%ld,%ld,%d\r\n",read_index, write_index, is_filled);
|
||||
esp_rom_printf("\r\n[DUMP_START:");
|
||||
while (read_index != write_index) {
|
||||
esp_rom_printf("%02x ", buffer[read_index]);
|
||||
if (print_len > max_print_len) {
|
||||
esp_panic_handler_feed_wdts();
|
||||
print_len = 0;
|
||||
}
|
||||
|
||||
print_len++;
|
||||
read_index = (read_index + 1) % MAX_STORAGE_SIZE;
|
||||
}
|
||||
|
||||
esp_rom_printf(":DUMP_END]\r\n");
|
||||
portEXIT_CRITICAL_SAFE(&spinlock);
|
||||
esp_partition_munmap(mmap_handle);
|
||||
err = esp_bt_controller_log_init();
|
||||
assert(err == ESP_OK);
|
||||
}
|
||||
#endif // CONFIG_BT_LE_CONTROLLER_LOG_STORAGE_ENABLE
|
||||
|
||||
#if CONFIG_BT_LE_CONTROLLER_LOG_TASK_WDT_USER_HANDLER_ENABLE
|
||||
void esp_task_wdt_isr_user_handler(void)
|
||||
{
|
||||
esp_ble_controller_log_dump_all(true);
|
||||
}
|
||||
#endif // CONFIG_BT_LE_CONTROLLER_LOG_TASK_WDT_USER_HANDLER_ENABLE
|
||||
|
||||
#if CONFIG_BT_LE_CONTROLLER_LOG_WRAP_PANIC_HANDLER_ENABLE
|
||||
void __real_esp_panic_handler(void *info);
|
||||
void __wrap_esp_panic_handler (void *info)
|
||||
{
|
||||
esp_ble_controller_log_dump_all(true);
|
||||
__real_esp_panic_handler(info);
|
||||
}
|
||||
#endif // CONFIG_BT_LE_CONTROLLER_LOG_WRAP_PANIC_HANDLER_ENABLE
|
||||
#endif // CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
|
||||
|
||||
/* This variable tells if BLE is running */
|
||||
@@ -422,24 +185,11 @@ static bool s_ble_active = false;
|
||||
#ifdef CONFIG_PM_ENABLE
|
||||
static DRAM_ATTR esp_pm_lock_handle_t s_pm_lock = NULL;
|
||||
#endif // CONFIG_PM_ENABLE
|
||||
#define MAIN_XTAL_FREQ_HZ (48000000)
|
||||
static DRAM_ATTR modem_clock_lpclk_src_t s_bt_lpclk_src = MODEM_CLOCK_LPCLK_SRC_INVALID;
|
||||
static DRAM_ATTR uint32_t s_bt_lpclk_freq = 100000;
|
||||
|
||||
#define BLE_RTC_DELAY_US_LIGHT_SLEEP (2500)
|
||||
#define BLE_RTC_DELAY_US_MODEM_SLEEP (500)
|
||||
|
||||
#define BLE_CONTROLLER_MALLOC_CAPS (MALLOC_CAP_INTERNAL|MALLOC_CAP_8BIT|MALLOC_CAP_DMA)
|
||||
void *malloc_ble_controller_mem(size_t size)
|
||||
{
|
||||
return heap_caps_malloc(size, BLE_CONTROLLER_MALLOC_CAPS);
|
||||
}
|
||||
|
||||
uint32_t get_ble_controller_free_heap_size(void)
|
||||
{
|
||||
return heap_caps_get_free_size(BLE_CONTROLLER_MALLOC_CAPS);
|
||||
}
|
||||
|
||||
static const struct osi_coex_funcs_t s_osi_coex_funcs_ro = {
|
||||
._magic = OSI_COEX_MAGIC_VALUE,
|
||||
._version = OSI_COEX_VERSION,
|
||||
@@ -461,9 +211,15 @@ struct ext_funcs_t ext_funcs_ro = {
|
||||
._os_random = osi_random_wrapper,
|
||||
._ecc_gen_key_pair = esp_ecc_gen_key_pair,
|
||||
._ecc_gen_dh_key = esp_ecc_gen_dh_key,
|
||||
._esp_reset_rpa_moudle = esp_reset_rpa_moudle,
|
||||
.magic = EXT_FUNC_MAGIC_VALUE,
|
||||
};
|
||||
|
||||
static void IRAM_ATTR esp_reset_rpa_moudle(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
static void IRAM_ATTR osi_assert_wrapper(const uint32_t ln, const char *fn,
|
||||
uint32_t param1, uint32_t param2)
|
||||
{
|
||||
@@ -527,11 +283,8 @@ static int esp_ecc_gen_dh_key(const uint8_t *peer_pub_key_x, const uint8_t *peer
|
||||
static int esp_intr_alloc_wrapper(int source, int flags, intr_handler_t handler,
|
||||
void *arg, void **ret_handle_in)
|
||||
{
|
||||
#if CONFIG_BT_CTRL_RUN_IN_FLASH_ONLY
|
||||
int rc = esp_intr_alloc(source, flags, handler, arg, (intr_handle_t *)ret_handle_in);
|
||||
#else
|
||||
int rc = esp_intr_alloc(source, flags | ESP_INTR_FLAG_IRAM, handler, arg, (intr_handle_t *)ret_handle_in);
|
||||
#endif
|
||||
int rc = esp_intr_alloc(source, flags | ESP_INTR_FLAG_IRAM, handler,
|
||||
arg, (intr_handle_t *)ret_handle_in);
|
||||
return rc;
|
||||
}
|
||||
|
||||
@@ -549,10 +302,10 @@ void esp_bt_rtc_slow_clk_select(uint8_t slow_clk_src)
|
||||
switch (slow_clk_src) {
|
||||
case MODEM_CLOCK_LPCLK_SRC_MAIN_XTAL:
|
||||
ESP_LOGI(NIMBLE_PORT_LOG_TAG, "Using main XTAL as clock source");
|
||||
modem_clock_select_lp_clock_source(PERIPH_BT_MODULE, slow_clk_src, (MAIN_XTAL_FREQ_HZ/s_bt_lpclk_freq - 1));
|
||||
modem_clock_select_lp_clock_source(PERIPH_BT_MODULE, slow_clk_src, (480 - 1));
|
||||
break;
|
||||
case MODEM_CLOCK_LPCLK_SRC_RC_SLOW:
|
||||
ESP_LOGW(NIMBLE_PORT_LOG_TAG, "Using 136 kHz RC as clock source, use with caution as it may not maintain ACL or Sync process due to low clock accuracy!");
|
||||
ESP_LOGI(NIMBLE_PORT_LOG_TAG, "Using 136 kHz RC as clock source, can only run legacy ADV or SCAN due to low clock accuracy!");
|
||||
modem_clock_select_lp_clock_source(PERIPH_BT_MODULE, slow_clk_src, (5 - 1));
|
||||
break;
|
||||
case MODEM_CLOCK_LPCLK_SRC_XTAL32K:
|
||||
@@ -578,10 +331,6 @@ modem_clock_lpclk_src_t esp_bt_get_lpclk_src(void)
|
||||
|
||||
void esp_bt_set_lpclk_src(modem_clock_lpclk_src_t clk_src)
|
||||
{
|
||||
if (ble_controller_status != ESP_BT_CONTROLLER_STATUS_IDLE) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (clk_src >= MODEM_CLOCK_LPCLK_SRC_MAX) {
|
||||
return;
|
||||
}
|
||||
@@ -589,28 +338,6 @@ void esp_bt_set_lpclk_src(modem_clock_lpclk_src_t clk_src)
|
||||
s_bt_lpclk_src = clk_src;
|
||||
}
|
||||
|
||||
uint32_t esp_bt_get_lpclk_freq(void)
|
||||
{
|
||||
return s_bt_lpclk_freq;
|
||||
}
|
||||
|
||||
void esp_bt_set_lpclk_freq(uint32_t clk_freq)
|
||||
{
|
||||
if (ble_controller_status != ESP_BT_CONTROLLER_STATUS_IDLE) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!clk_freq) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (MAIN_XTAL_FREQ_HZ % clk_freq) {
|
||||
return;
|
||||
}
|
||||
|
||||
s_bt_lpclk_freq = clk_freq;
|
||||
}
|
||||
|
||||
IRAM_ATTR void controller_sleep_cb(uint32_t enable_tick, void *arg)
|
||||
{
|
||||
if (!s_ble_active) {
|
||||
@@ -632,17 +359,10 @@ IRAM_ATTR void controller_wakeup_cb(void *arg)
|
||||
return;
|
||||
}
|
||||
#ifdef CONFIG_PM_ENABLE
|
||||
esp_pm_config_t pm_config;
|
||||
esp_pm_lock_acquire(s_pm_lock);
|
||||
esp_pm_get_configuration(&pm_config);
|
||||
assert(esp_rom_get_cpu_ticks_per_us() == pm_config.max_freq_mhz);
|
||||
r_ble_rtc_wake_up_state_clr();
|
||||
#endif //CONFIG_PM_ENABLE
|
||||
esp_phy_enable(PHY_MODEM_BT);
|
||||
if (s_bt_lpclk_src == MODEM_CLOCK_LPCLK_SRC_RC_SLOW) {
|
||||
uint32_t *clk_freq = (uint32_t *)arg;
|
||||
*clk_freq = esp_clk_tree_lp_slow_get_freq_hz(ESP_CLK_TREE_SRC_FREQ_PRECISION_CACHED) / 5;
|
||||
}
|
||||
s_ble_active = true;
|
||||
}
|
||||
|
||||
@@ -657,6 +377,7 @@ static esp_err_t sleep_modem_ble_mac_retention_init(void *arg)
|
||||
ESP_LOGI(NIMBLE_PORT_LOG_TAG, "Modem BLE MAC retention initialization");
|
||||
}
|
||||
return err;
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
static esp_err_t sleep_modem_ble_mac_modem_state_init(uint8_t extra)
|
||||
@@ -664,7 +385,7 @@ static esp_err_t sleep_modem_ble_mac_modem_state_init(uint8_t extra)
|
||||
int retention_args = extra;
|
||||
sleep_retention_module_init_param_t init_param = {
|
||||
.cbs = { .create = { .handle = sleep_modem_ble_mac_retention_init, .arg = &retention_args } },
|
||||
.depends = RETENTION_MODULE_BITMAP_INIT(BT_BB)
|
||||
.depends = BIT(SLEEP_RETENTION_MODULE_BT_BB)
|
||||
};
|
||||
esp_err_t err = sleep_retention_module_init(SLEEP_RETENTION_MODULE_BLE_MAC, &init_param);
|
||||
if (err == ESP_OK) {
|
||||
@@ -688,7 +409,6 @@ void IRAM_ATTR sleep_modem_light_sleep_overhead_set(uint32_t overhead)
|
||||
}
|
||||
#endif /* CONFIG_FREERTOS_USE_TICKLESS_IDLE */
|
||||
|
||||
|
||||
esp_err_t controller_sleep_init(void)
|
||||
{
|
||||
esp_err_t rc = 0;
|
||||
@@ -703,13 +423,13 @@ esp_err_t controller_sleep_init(void)
|
||||
BLE_RTC_DELAY_US_MODEM_SLEEP);
|
||||
#endif /* FREERTOS_USE_TICKLESS_IDLE */
|
||||
#endif // CONFIG_BT_LE_SLEEP_ENABLE
|
||||
|
||||
#ifdef CONFIG_PM_ENABLE
|
||||
rc = esp_pm_lock_create(ESP_PM_CPU_FREQ_MAX, 0, "bt", &s_pm_lock);
|
||||
if (rc != ESP_OK) {
|
||||
goto error;
|
||||
}
|
||||
#endif // CONFIG_PM_ENABLE
|
||||
|
||||
#if CONFIG_BT_LE_SLEEP_ENABLE && CONFIG_FREERTOS_USE_TICKLESS_IDLE
|
||||
/* Create a new regdma link for BLE related register restoration */
|
||||
rc = sleep_modem_ble_mac_modem_state_init(0);
|
||||
@@ -870,12 +590,11 @@ static void ble_rtc_clk_init(esp_bt_controller_config_t *cfg)
|
||||
}
|
||||
|
||||
if (s_bt_lpclk_src == MODEM_CLOCK_LPCLK_SRC_MAIN_XTAL) {
|
||||
cfg->rtc_freq = s_bt_lpclk_freq;
|
||||
cfg->rtc_freq = 100000;
|
||||
} else if (s_bt_lpclk_src == MODEM_CLOCK_LPCLK_SRC_XTAL32K) {
|
||||
cfg->rtc_freq = 32768;
|
||||
} else if (s_bt_lpclk_src == MODEM_CLOCK_LPCLK_SRC_RC_SLOW) {
|
||||
cfg->rtc_freq = esp_clk_tree_lp_slow_get_freq_hz(ESP_CLK_TREE_SRC_FREQ_PRECISION_CACHED) / 5;
|
||||
cfg->ble_ll_sca = 3000;
|
||||
cfg->rtc_freq = 30000;
|
||||
} else if (s_bt_lpclk_src == MODEM_CLOCK_LPCLK_SRC_RC32K) {
|
||||
cfg->rtc_freq = 32000;
|
||||
} else if (s_bt_lpclk_src == MODEM_CLOCK_LPCLK_SRC_EXT32K) {
|
||||
@@ -892,6 +611,7 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg)
|
||||
uint8_t hci_transport_mode;
|
||||
|
||||
memset(&npl_info, 0, sizeof(ble_npl_count_info_t));
|
||||
|
||||
if (ble_controller_status != ESP_BT_CONTROLLER_STATUS_IDLE) {
|
||||
ESP_LOGW(NIMBLE_PORT_LOG_TAG, "invalid controller state");
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
@@ -954,7 +674,20 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg)
|
||||
#endif // CONFIG_SW_COEXIST_ENABLE
|
||||
|
||||
#if CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
|
||||
ret = esp_bt_controller_log_init();
|
||||
interface_func_t bt_controller_log_interface;
|
||||
bt_controller_log_interface = esp_bt_controller_log_interface;
|
||||
uint8_t buffers = 0;
|
||||
#if CONFIG_BT_LE_CONTROLLER_LOG_CTRL_ENABLED
|
||||
buffers |= ESP_BLE_LOG_BUF_CONTROLLER;
|
||||
#endif // CONFIG_BT_LE_CONTROLLER_LOG_CTRL_ENABLED
|
||||
#if CONFIG_BT_LE_CONTROLLER_LOG_HCI_ENABLED
|
||||
buffers |= ESP_BLE_LOG_BUF_HCI;
|
||||
#endif // CONFIG_BT_LE_CONTROLLER_LOG_HCI_ENABLED
|
||||
#if CONFIG_BT_LE_CONTROLLER_LOG_DUMP_ONLY
|
||||
ret = r_ble_log_init_async(bt_controller_log_interface, false, buffers, (uint32_t *)log_bufs_size);
|
||||
#else
|
||||
ret = r_ble_log_init_async(bt_controller_log_interface, true, buffers, (uint32_t *)log_bufs_size);
|
||||
#endif // CONFIG_BT_CONTROLLER_LOG_DUMP
|
||||
if (ret != ESP_OK) {
|
||||
ESP_LOGW(NIMBLE_PORT_LOG_TAG, "ble_controller_log_init failed %d", ret);
|
||||
goto modem_deint;
|
||||
@@ -966,23 +699,13 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg)
|
||||
goto modem_deint;
|
||||
}
|
||||
|
||||
ESP_LOGI(NIMBLE_PORT_LOG_TAG, "ble controller commit:[%s]", ble_controller_get_compile_version());
|
||||
|
||||
ret = r_ble_controller_init(cfg);
|
||||
if (ret != ESP_OK) {
|
||||
ESP_LOGW(NIMBLE_PORT_LOG_TAG, "r_ble_controller_init failed %d", ret);
|
||||
goto modem_deint;
|
||||
}
|
||||
|
||||
#if CONFIG_BT_LE_LL_PEER_SCA_SET_ENABLE
|
||||
r_ble_ll_customize_peer_sca_set(CONFIG_BT_LE_LL_PEER_SCA);
|
||||
#endif // CONFIG_BT_LE_LL_PEER_SCA_SET_ENABLE
|
||||
|
||||
ret = ble_stack_initEnv();
|
||||
if (ret != ESP_OK) {
|
||||
ESP_LOGW(NIMBLE_PORT_LOG_TAG, "ble_stack_initEnv failed %d", ret);
|
||||
goto free_controller;
|
||||
}
|
||||
ESP_LOGI(NIMBLE_PORT_LOG_TAG, "ble controller commit:[%s]", ble_controller_get_compile_version());
|
||||
|
||||
ble_controller_scan_duplicate_config();
|
||||
|
||||
@@ -997,7 +720,6 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg)
|
||||
ESP_LOGW(NIMBLE_PORT_LOG_TAG, "controller_sleep_init failed %d", ret);
|
||||
goto free_controller;
|
||||
}
|
||||
|
||||
ESP_ERROR_CHECK(esp_read_mac((uint8_t *)mac, ESP_MAC_BT));
|
||||
ESP_LOGI(NIMBLE_PORT_LOG_TAG, "Bluetooth MAC: %02x:%02x:%02x:%02x:%02x:%02x",
|
||||
mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
|
||||
@@ -1022,12 +744,11 @@ free_controller:
|
||||
hci_transport_deinit();
|
||||
controller_sleep_deinit();
|
||||
os_msys_deinit();
|
||||
ble_stack_deinitEnv();
|
||||
r_ble_controller_deinit();
|
||||
modem_deint:
|
||||
esp_ble_unregister_bb_funcs();
|
||||
#if CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
|
||||
esp_bt_controller_log_deinit();
|
||||
r_ble_log_deinit_async();
|
||||
#endif // CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
|
||||
esp_phy_modem_deinit();
|
||||
// modem_clock_deselect_lp_clock_source(PERIPH_BT_MODULE);
|
||||
@@ -1060,11 +781,10 @@ esp_err_t esp_bt_controller_deinit(void)
|
||||
// modem_clock_deselect_lp_clock_source(PERIPH_BT_MODULE);
|
||||
modem_clock_module_disable(PERIPH_BT_MODULE);
|
||||
|
||||
ble_stack_deinitEnv();
|
||||
r_ble_controller_deinit();
|
||||
esp_ble_unregister_bb_funcs();
|
||||
#if CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
|
||||
esp_bt_controller_log_deinit();
|
||||
r_ble_log_deinit_async();
|
||||
#endif // CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
|
||||
|
||||
#if CONFIG_BT_NIMBLE_ENABLED
|
||||
@@ -1110,16 +830,6 @@ esp_err_t esp_bt_controller_enable(esp_bt_mode_t mode)
|
||||
coex_enable();
|
||||
#endif // CONFIG_SW_COEXIST_ENABLE
|
||||
|
||||
#if CONFIG_BT_CTRL_RUN_IN_FLASH_ONLY
|
||||
r_ble_ll_scan_start_time_init_compensation(500);
|
||||
r_priv_sdk_config_insert_proc_time_set(500);
|
||||
#endif // CONFIG_BT_CTRL_RUN_IN_FLASH_ONLY
|
||||
|
||||
if (ble_stack_enable() != 0) {
|
||||
ret = ESP_FAIL;
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (r_ble_controller_enable(mode) != 0) {
|
||||
ret = ESP_FAIL;
|
||||
goto error;
|
||||
@@ -1128,7 +838,6 @@ esp_err_t esp_bt_controller_enable(esp_bt_mode_t mode)
|
||||
return ESP_OK;
|
||||
|
||||
error:
|
||||
ble_stack_disable();
|
||||
#if CONFIG_SW_COEXIST_ENABLE
|
||||
coex_disable();
|
||||
#endif
|
||||
@@ -1152,7 +861,6 @@ esp_err_t esp_bt_controller_disable(void)
|
||||
if (r_ble_controller_disable() != 0) {
|
||||
return ESP_FAIL;
|
||||
}
|
||||
ble_stack_disable();
|
||||
#if CONFIG_SW_COEXIST_ENABLE
|
||||
coex_disable();
|
||||
#endif
|
||||
@@ -1282,17 +990,9 @@ esp_err_t esp_ble_tx_power_set(esp_ble_power_type_t power_type, esp_power_level_
|
||||
|
||||
switch (power_type) {
|
||||
case ESP_BLE_PWR_TYPE_DEFAULT:
|
||||
if (r_ble_txpwr_set(ESP_BLE_ENHANCED_PWR_TYPE_DEFAULT, 0, power_level) == 0) {
|
||||
stat = ESP_OK;
|
||||
}
|
||||
break;
|
||||
case ESP_BLE_PWR_TYPE_ADV:
|
||||
if (r_ble_txpwr_set(ESP_BLE_ENHANCED_PWR_TYPE_ADV, 0xFF, power_level) == 0) {
|
||||
stat = ESP_OK;
|
||||
}
|
||||
break;
|
||||
case ESP_BLE_PWR_TYPE_SCAN:
|
||||
if (r_ble_txpwr_set(ESP_BLE_ENHANCED_PWR_TYPE_SCAN, 0, power_level) == 0) {
|
||||
if (r_ble_txpwr_set(ESP_BLE_ENHANCED_PWR_TYPE_DEFAULT, 0, power_level) == 0) {
|
||||
stat = ESP_OK;
|
||||
}
|
||||
break;
|
||||
@@ -1323,13 +1023,9 @@ esp_err_t esp_ble_tx_power_set_enhanced(esp_ble_enhanced_power_type_t power_type
|
||||
esp_err_t stat = ESP_FAIL;
|
||||
switch (power_type) {
|
||||
case ESP_BLE_ENHANCED_PWR_TYPE_DEFAULT:
|
||||
if (r_ble_txpwr_set(ESP_BLE_ENHANCED_PWR_TYPE_DEFAULT, 0, power_level) == 0) {
|
||||
stat = ESP_OK;
|
||||
}
|
||||
break;
|
||||
case ESP_BLE_ENHANCED_PWR_TYPE_SCAN:
|
||||
case ESP_BLE_ENHANCED_PWR_TYPE_INIT:
|
||||
if (r_ble_txpwr_set(ESP_BLE_ENHANCED_PWR_TYPE_SCAN, 0, power_level) == 0) {
|
||||
if (r_ble_txpwr_set(ESP_BLE_ENHANCED_PWR_TYPE_DEFAULT, 0, power_level) == 0) {
|
||||
stat = ESP_OK;
|
||||
}
|
||||
break;
|
||||
@@ -1352,15 +1048,11 @@ esp_power_level_t esp_ble_tx_power_get(esp_ble_power_type_t power_type)
|
||||
int tx_level = 0;
|
||||
|
||||
switch (power_type) {
|
||||
case ESP_BLE_PWR_TYPE_ADV:
|
||||
case ESP_BLE_PWR_TYPE_SCAN:
|
||||
case ESP_BLE_PWR_TYPE_DEFAULT:
|
||||
tx_level = r_ble_txpwr_get(ESP_BLE_ENHANCED_PWR_TYPE_DEFAULT, 0);
|
||||
break;
|
||||
case ESP_BLE_PWR_TYPE_ADV:
|
||||
tx_level = r_ble_txpwr_get(ESP_BLE_ENHANCED_PWR_TYPE_ADV, 0);
|
||||
break;
|
||||
case ESP_BLE_PWR_TYPE_SCAN:
|
||||
tx_level = r_ble_txpwr_get(ESP_BLE_ENHANCED_PWR_TYPE_SCAN, 0);
|
||||
break;
|
||||
case ESP_BLE_PWR_TYPE_CONN_HDL0:
|
||||
case ESP_BLE_PWR_TYPE_CONN_HDL1:
|
||||
case ESP_BLE_PWR_TYPE_CONN_HDL2:
|
||||
@@ -1390,11 +1082,9 @@ esp_power_level_t esp_ble_tx_power_get_enhanced(esp_ble_enhanced_power_type_t po
|
||||
|
||||
switch (power_type) {
|
||||
case ESP_BLE_ENHANCED_PWR_TYPE_DEFAULT:
|
||||
tx_level = r_ble_txpwr_get(ESP_BLE_ENHANCED_PWR_TYPE_DEFAULT, 0);
|
||||
break;
|
||||
case ESP_BLE_ENHANCED_PWR_TYPE_SCAN:
|
||||
case ESP_BLE_ENHANCED_PWR_TYPE_INIT:
|
||||
tx_level = r_ble_txpwr_get(ESP_BLE_ENHANCED_PWR_TYPE_SCAN, 0);
|
||||
tx_level = r_ble_txpwr_get(ESP_BLE_ENHANCED_PWR_TYPE_DEFAULT, 0);
|
||||
break;
|
||||
case ESP_BLE_ENHANCED_PWR_TYPE_ADV:
|
||||
case ESP_BLE_ENHANCED_PWR_TYPE_CONN:
|
||||
@@ -1412,47 +1102,26 @@ esp_power_level_t esp_ble_tx_power_get_enhanced(esp_ble_enhanced_power_type_t po
|
||||
}
|
||||
|
||||
#if CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
|
||||
#if !CONFIG_BT_LE_CONTROLLER_LOG_SPI_OUT_ENABLED
|
||||
static void esp_bt_controller_log_interface(uint32_t len, const uint8_t *addr, uint32_t len_append, const uint8_t *addr_append, uint32_t flag)
|
||||
static void esp_bt_controller_log_interface(uint32_t len, const uint8_t *addr, bool end)
|
||||
{
|
||||
bool end = (flag & BIT(BLE_LOG_INTERFACE_FLAG_END));
|
||||
#if CONFIG_BT_LE_CONTROLLER_LOG_STORAGE_ENABLE
|
||||
esp_bt_controller_log_storage(len, addr, end);
|
||||
#else // !CONFIG_BT_LE_CONTROLLER_LOG_STORAGE_ENABLE
|
||||
portMUX_TYPE spinlock = portMUX_INITIALIZER_UNLOCKED;
|
||||
portENTER_CRITICAL_SAFE(&spinlock);
|
||||
esp_panic_handler_feed_wdts();
|
||||
|
||||
if (len && addr) {
|
||||
for (int i = 0; i < len; i++) { esp_rom_printf("%02x ", addr[i]); }
|
||||
for (int i = 0; i < len; i++) {
|
||||
esp_rom_printf("%02x ", addr[i]);
|
||||
}
|
||||
if (len_append && addr_append) {
|
||||
for (int i = 0; i < len_append; i++) { esp_rom_printf("%02x ", addr_append[i]); }
|
||||
if (end) {
|
||||
esp_rom_printf("\n");
|
||||
}
|
||||
if (end) { esp_rom_printf("\n"); }
|
||||
|
||||
portEXIT_CRITICAL_SAFE(&spinlock);
|
||||
#endif // CONFIG_BT_LE_CONTROLLER_LOG_STORAGE_ENABLE
|
||||
}
|
||||
#endif // !CONFIG_BT_LE_CONTROLLER_LOG_SPI_OUT_ENABLED
|
||||
|
||||
void esp_ble_controller_log_dump_all(bool output)
|
||||
{
|
||||
#if CONFIG_BT_BLE_LOG_SPI_OUT_ENABLED
|
||||
ble_log_spi_out_dump_all();
|
||||
#endif // CONFIG_BT_BLE_LOG_SPI_OUT_ENABLED
|
||||
|
||||
#if CONFIG_BT_LE_CONTROLLER_LOG_STORAGE_ENABLE
|
||||
esp_bt_read_ctrl_log_from_flash(output);
|
||||
#elif !CONFIG_BT_LE_CONTROLLER_LOG_SPI_OUT_ENABLED
|
||||
portMUX_TYPE spinlock = portMUX_INITIALIZER_UNLOCKED;
|
||||
|
||||
portENTER_CRITICAL_SAFE(&spinlock);
|
||||
esp_panic_handler_feed_wdts();
|
||||
esp_panic_handler_reconfigure_wdts(5000);
|
||||
BT_ASSERT_PRINT("\r\n[DUMP_START:");
|
||||
r_ble_log_async_output_dump_all(output);
|
||||
BT_ASSERT_PRINT(":DUMP_END]\r\n");
|
||||
portEXIT_CRITICAL_SAFE(&spinlock);
|
||||
#endif
|
||||
}
|
||||
#endif // CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
|
||||
|
||||
@@ -1667,36 +1336,3 @@ int ble_sm_alg_gen_key_pair(uint8_t *pub, uint8_t *priv)
|
||||
|
||||
#endif // CONFIG_BT_LE_SM_LEGACY || CONFIG_BT_LE_SM_SC
|
||||
#endif // (!CONFIG_BT_NIMBLE_ENABLED) && (CONFIG_BT_CONTROLLER_ENABLED)
|
||||
|
||||
#if CONFIG_BT_LE_DEBUG_REMAIN_SCENE_ENABLED
|
||||
#include "esp_gdbstub.h"
|
||||
#endif // CONFIG_BT_LE_DEBUG_REMAIN_SCENE_ENABLED
|
||||
|
||||
int IRAM_ATTR
|
||||
ble_capture_info_user_handler(uint8_t type, uint32_t reason)
|
||||
{
|
||||
int i;
|
||||
|
||||
switch(type) {
|
||||
case 0:
|
||||
for (i = 0; i < 2; i++) {
|
||||
esp_ble_controller_info_capture(0x010101);
|
||||
}
|
||||
#if CONFIG_BT_LE_DEBUG_REMAIN_SCENE_ENABLED
|
||||
uintptr_t sp;
|
||||
__asm__ volatile ("mv %0, sp" : "=r" (sp));
|
||||
esp_gdbstub_panic_handler(&sp);
|
||||
#endif // CONFIG_BT_LE_DEBUG_REMAIN_SCENE_ENABLED
|
||||
break;
|
||||
#if CONFIG_BT_LE_ASSERT_WHEN_ABNORMAL_DISCONN_ENABLED
|
||||
case 1:
|
||||
if ((reason == 0x08) || (reason == 0x3d) || (reason == 0x28)) {
|
||||
osi_assert_wrapper(__LINE__,__func__, type, reason);
|
||||
}
|
||||
break;
|
||||
#endif // CONFIG_BT_LE_ASSERT_WHEN_ABNORMAL_DISCONN_ENABLED
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -148,74 +148,12 @@ extern "C" {
|
||||
|
||||
#define DEFAULT_BT_LE_COEX_PHY_CODED_TX_RX_TLIM_EFF CONFIG_BT_LE_COEX_PHY_CODED_TX_RX_TLIM_EFF
|
||||
|
||||
#ifdef CONFIG_BT_LE_CTRL_CHECK_CONNECT_IND_ACCESS_ADDRESS
|
||||
#define DEFAULT_BT_LE_CTRL_CHECK_CONNECT_IND_ACCESS_ADDRESS (CONFIG_BT_LE_CTRL_CHECK_CONNECT_IND_ACCESS_ADDRESS)
|
||||
#else
|
||||
#define DEFAULT_BT_LE_CTRL_CHECK_CONNECT_IND_ACCESS_ADDRESS (0)
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_BT_LE_CTRL_LLCP_CONN_UPDATE
|
||||
#define BT_CTRL_BLE_LLCP_CONN_UPDATE (1<<0)
|
||||
#else
|
||||
#define BT_CTRL_BLE_LLCP_CONN_UPDATE (0<<0)
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_BT_LE_CTRL_LLCP_CHAN_MAP_UPDATE
|
||||
#define BT_CTRL_BLE_LLCP_CHAN_MAP_UPDATE (1<<1)
|
||||
#else
|
||||
#define BT_CTRL_BLE_LLCP_CHAN_MAP_UPDATE (0<<1)
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_BT_LE_CTRL_LLCP_PHY_UPDATE
|
||||
#define BT_CTRL_BLE_LLCP_PHY_UPDATE (1<<2)
|
||||
#else
|
||||
#define BT_CTRL_BLE_LLCP_PHY_UPDATE (0<<2)
|
||||
#endif
|
||||
|
||||
#define BT_LE_CTRL_LLCP_DISC_FLAG (BT_CTRL_BLE_LLCP_CONN_UPDATE | BT_CTRL_BLE_LLCP_CHAN_MAP_UPDATE | BT_CTRL_BLE_LLCP_PHY_UPDATE)
|
||||
|
||||
#ifdef CONFIG_BT_CTRL_SCAN_BACKOFF_UPPERLIMITMAX
|
||||
#define BT_CTRL_SCAN_BACKOFF_UPPERLIMITMAX (CONFIG_BT_CTRL_SCAN_BACKOFF_UPPERLIMITMAX)
|
||||
#else
|
||||
#define BT_CTRL_SCAN_BACKOFF_UPPERLIMITMAX (256)
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_BT_LE_CTRL_CHAN_ASS_EN)
|
||||
#define DEFAULT_BT_LE_CTRL_CHAN_ASS_EN (CONFIG_BT_LE_CTRL_CHAN_ASS_EN)
|
||||
#else
|
||||
#define DEFAULT_BT_LE_CTRL_CHAN_ASS_EN (0)
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_BT_LE_CTRL_ADV_DATA_LENGTH_ZERO_AUX)
|
||||
#define DEFAULT_BT_LE_CTRL_ADV_DATA_LENGTH_ZERO_AUX (CONFIG_BT_LE_CTRL_ADV_DATA_LENGTH_ZERO_AUX)
|
||||
#else
|
||||
#define DEFAULT_BT_LE_CTRL_ADV_DATA_LENGTH_ZERO_AUX (0)
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_BT_LE_CTRL_FAST_CONN_DATA_TX_EN)
|
||||
#define DEFAULT_BT_LE_CTRL_FAST_CONN_DATA_TX_EN (CONFIG_BT_LE_CTRL_FAST_CONN_DATA_TX_EN)
|
||||
#else
|
||||
#define DEFAULT_BT_LE_CTRL_FAST_CONN_DATA_TX_EN (0)
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_BT_LE_HCI_INTERFACE_USE_UART
|
||||
#define HCI_UART_EN CONFIG_BT_LE_HCI_INTERFACE_USE_UART
|
||||
#else
|
||||
#define HCI_UART_EN 0 // hci ram mode
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_BT_LE_HCI_INTERFACE_USE_RAM
|
||||
#define DEFAULT_BT_LE_VHCI_ENABLED (CONFIG_BT_LE_HCI_INTERFACE_USE_RAM)
|
||||
#else
|
||||
#define DEFAULT_BT_LE_VHCI_ENABLED (0)
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_BT_LE_PTR_CHECK_ENABLED
|
||||
#define DEFAULT_BT_LE_PTR_CHECK_ENABLED (CONFIG_BT_LE_PTR_CHECK_ENABLED)
|
||||
#else
|
||||
#define DEFAULT_BT_LE_PTR_CHECK_ENABLED (0)
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_BT_LE_SLEEP_ENABLE
|
||||
#define NIMBLE_SLEEP_ENABLE CONFIG_BT_LE_SLEEP_ENABLE
|
||||
#else
|
||||
@@ -278,7 +216,8 @@ extern "C" {
|
||||
|
||||
#define RTC_FREQ_N (32768) /* in Hz */
|
||||
|
||||
#define BLE_LL_TX_PWR_DBM_N (CONFIG_BT_LE_DFT_TX_POWER_LEVEL_DBM_EFF)
|
||||
#define BLE_LL_TX_PWR_DBM_N (9)
|
||||
|
||||
|
||||
#define RUN_BQB_TEST (0)
|
||||
#define RUN_QA_TEST (0)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
|
||||
menu "HCI Config"
|
||||
|
||||
choice BT_LE_HCI_INTERFACE
|
||||
prompt "HCI mode"
|
||||
default BT_LE_HCI_INTERFACE_USE_RAM
|
||||
@@ -107,7 +108,7 @@ menu "HCI Config"
|
||||
config BT_LE_HCI_TRANS_TASK_STACK_SIZE
|
||||
int "HCI transport task stack size"
|
||||
depends on !BT_LE_HCI_INTERFACE_USE_RAM
|
||||
default 2048
|
||||
default 1024
|
||||
help
|
||||
This configures stack size of hci transport task
|
||||
|
||||
@@ -227,16 +228,6 @@ config BT_LE_POWER_CONTROL_ENABLED
|
||||
help
|
||||
Set this option to enable the Power Control feature on controller
|
||||
|
||||
config BT_LE_CTE_FEATURE_ENABLED
|
||||
bool "Enable Bluetooth LE Direction Finding (AoA/AoD)"
|
||||
depends on BT_LE_50_FEATURE_SUPPORT && SOC_BLE_CTE_SUPPORTED
|
||||
default n
|
||||
help
|
||||
Enable this option to activate Bluetooth LE Direction Finding (AoA/AoD) feature.
|
||||
Note:
|
||||
This feature allows devices to determine the direction of a Bluetooth CTE signal,
|
||||
enabling Angle of Arrival (AoA) and Angle of Departure (AoD) functionality.
|
||||
|
||||
menu "Memory Settings"
|
||||
depends on !BT_NIMBLE_ENABLED
|
||||
|
||||
@@ -324,131 +315,72 @@ config BT_LE_CONTROLLER_TASK_STACK_SIZE
|
||||
help
|
||||
This configures stack size of NimBLE controller task
|
||||
|
||||
menu "Controller debug features"
|
||||
menuconfig BT_LE_CONTROLLER_LOG_ENABLED
|
||||
bool "Controller log enable"
|
||||
default n
|
||||
help
|
||||
Enable controller log
|
||||
menuconfig BT_LE_CONTROLLER_LOG_ENABLED
|
||||
bool "Controller log enable"
|
||||
default n
|
||||
help
|
||||
Enable controller log
|
||||
|
||||
config BT_LE_CONTROLLER_LOG_CTRL_ENABLED
|
||||
bool "enable controller log module"
|
||||
depends on BT_LE_CONTROLLER_LOG_ENABLED
|
||||
default y
|
||||
help
|
||||
config BT_LE_CONTROLLER_LOG_CTRL_ENABLED
|
||||
bool "enable controller log module"
|
||||
depends on BT_LE_CONTROLLER_LOG_ENABLED
|
||||
default y
|
||||
help
|
||||
Enable controller log module
|
||||
|
||||
config BT_LE_CONTROLLER_LOG_HCI_ENABLED
|
||||
bool "enable HCI log module"
|
||||
depends on BT_LE_CONTROLLER_LOG_ENABLED
|
||||
default y
|
||||
help
|
||||
config BT_LE_CONTROLLER_LOG_HCI_ENABLED
|
||||
bool "enable HCI log module"
|
||||
depends on BT_LE_CONTROLLER_LOG_ENABLED
|
||||
default y
|
||||
help
|
||||
Enable hci log module
|
||||
|
||||
config BT_LE_CONTROLLER_LOG_DUMP_ONLY
|
||||
bool "Controller log dump mode only"
|
||||
depends on BT_LE_CONTROLLER_LOG_ENABLED
|
||||
default y
|
||||
help
|
||||
config BT_LE_CONTROLLER_LOG_DUMP_ONLY
|
||||
bool "Controller log dump mode only"
|
||||
depends on BT_LE_CONTROLLER_LOG_ENABLED
|
||||
default y
|
||||
help
|
||||
Only operate in dump mode
|
||||
|
||||
config BT_LE_CONTROLLER_LOG_SPI_OUT_ENABLED
|
||||
bool "Output ble controller logs to SPI bus (Experimental)"
|
||||
depends on BT_LE_CONTROLLER_LOG_ENABLED
|
||||
depends on !BT_LE_CONTROLLER_LOG_DUMP_ONLY
|
||||
select BT_BLE_LOG_SPI_OUT_ENABLED
|
||||
default n
|
||||
help
|
||||
Output ble controller logs to SPI bus
|
||||
|
||||
config BT_LE_CONTROLLER_LOG_STORAGE_ENABLE
|
||||
bool "Store ble controller logs to flash(Experimental)"
|
||||
depends on !BT_LE_CONTROLLER_LOG_DUMP_ONLY
|
||||
depends on BT_LE_CONTROLLER_LOG_ENABLED
|
||||
default n
|
||||
help
|
||||
config BT_LE_CONTROLLER_LOG_STORAGE_ENABLE
|
||||
bool "Store ble controller logs to flash(Experimental)"
|
||||
depends on !BT_LE_CONTROLLER_LOG_DUMP_ONLY
|
||||
depends on BT_LE_CONTROLLER_LOG_ENABLED
|
||||
default n
|
||||
help
|
||||
Store ble controller logs to flash memory.
|
||||
|
||||
config BT_LE_CONTROLLER_LOG_PARTITION_SIZE
|
||||
int "size of ble controller log partition(Multiples of 4K)"
|
||||
depends on BT_LE_CONTROLLER_LOG_STORAGE_ENABLE
|
||||
default 65536
|
||||
help
|
||||
config BT_LE_CONTROLLER_LOG_PARTITION_SIZE
|
||||
int "size of ble controller log partition(Multiples of 4K)"
|
||||
depends on BT_LE_CONTROLLER_LOG_STORAGE_ENABLE
|
||||
default 65536
|
||||
help
|
||||
The size of ble controller log partition shall be a multiples of 4K.
|
||||
The name of log partition shall be "bt_ctrl_log".
|
||||
The partition type shall be ESP_PARTITION_TYPE_DATA.
|
||||
The partition sub_type shall be ESP_PARTITION_SUBTYPE_ANY.
|
||||
|
||||
config BT_LE_LOG_CTRL_BUF1_SIZE
|
||||
int "size of the first BLE controller LOG buffer"
|
||||
depends on BT_LE_CONTROLLER_LOG_ENABLED
|
||||
default 4096
|
||||
help
|
||||
config BT_LE_LOG_CTRL_BUF1_SIZE
|
||||
int "size of the first BLE controller LOG buffer"
|
||||
depends on BT_LE_CONTROLLER_LOG_ENABLED
|
||||
default 4096
|
||||
help
|
||||
Configure the size of the first BLE controller LOG buffer.
|
||||
|
||||
config BT_LE_LOG_CTRL_BUF2_SIZE
|
||||
int "size of the second BLE controller LOG buffer"
|
||||
depends on BT_LE_CONTROLLER_LOG_ENABLED
|
||||
default 1024
|
||||
help
|
||||
config BT_LE_LOG_CTRL_BUF2_SIZE
|
||||
int "size of the second BLE controller LOG buffer"
|
||||
depends on BT_LE_CONTROLLER_LOG_ENABLED
|
||||
default 1024
|
||||
help
|
||||
Configure the size of the second BLE controller LOG buffer.
|
||||
|
||||
config BT_LE_LOG_HCI_BUF_SIZE
|
||||
int "size of the BLE HCI LOG buffer"
|
||||
depends on BT_LE_CONTROLLER_LOG_ENABLED
|
||||
default 4096
|
||||
help
|
||||
config BT_LE_LOG_HCI_BUF_SIZE
|
||||
int "size of the BLE HCI LOG buffer"
|
||||
depends on BT_LE_CONTROLLER_LOG_ENABLED
|
||||
default 4096
|
||||
help
|
||||
Configure the size of the BLE HCI LOG buffer.
|
||||
|
||||
config BT_LE_CONTROLLER_LOG_WRAP_PANIC_HANDLER_ENABLE
|
||||
bool "Enable wrap panic handler"
|
||||
depends on BT_LE_CONTROLLER_LOG_ENABLED
|
||||
default n
|
||||
help
|
||||
Wrap esp_panic_handler to get controller logs when PC pointer exception crashes.
|
||||
|
||||
config BT_LE_CONTROLLER_LOG_TASK_WDT_USER_HANDLER_ENABLE
|
||||
bool "Enable esp_task_wdt_isr_user_handler implementation"
|
||||
depends on BT_LE_CONTROLLER_LOG_ENABLED
|
||||
default n
|
||||
help
|
||||
Implement esp_task_wdt_isr_user_handler to get controller logs when task wdt issue is triggered.
|
||||
|
||||
config BT_LE_CONTROLLER_LOG_OUTPUT_LEVEL
|
||||
int "The output level of controller log"
|
||||
depends on BT_LE_CONTROLLER_LOG_ENABLED
|
||||
range 0 5
|
||||
default 1
|
||||
help
|
||||
The output level of controller log.
|
||||
|
||||
config BT_LE_CONTROLLER_LOG_MOD_OUTPUT_SWITCH
|
||||
hex "The switch of module log output"
|
||||
depends on BT_LE_CONTROLLER_LOG_ENABLED
|
||||
range 0 0xFFFFFFFF
|
||||
default 0xFFFFFFFF
|
||||
help
|
||||
The switch of module log output, this is an unsigned 32-bit hexadecimal value.
|
||||
|
||||
config BT_LE_ERROR_SIM_ENABLED
|
||||
bool "Enable controller features for internal testing"
|
||||
default n
|
||||
|
||||
config BT_LE_ASSERT_WHEN_ABNORMAL_DISCONN_ENABLED
|
||||
bool "When ACL disconnects abnormally, assertion processing is performed(Experimental)"
|
||||
default n
|
||||
|
||||
config BT_LE_DEBUG_REMAIN_SCENE_ENABLED
|
||||
bool "Remain scene with GDB to capture relevant status info(Experimental)"
|
||||
default n
|
||||
help
|
||||
Retain scene with GDB to capture info, requires disabling WDT (CONFIG_ESP_INT_WDT, CONFIG_ESP_TASK_WDT_EN).
|
||||
|
||||
config BT_LE_PTR_CHECK_ENABLED
|
||||
bool "Enable boundary check for internal memory"
|
||||
default n
|
||||
endmenu
|
||||
|
||||
config BT_LE_LL_RESOLV_LIST_SIZE
|
||||
int "BLE LL Resolving list size"
|
||||
range 1 5
|
||||
@@ -504,7 +436,7 @@ config BT_LE_CRYPTO_STACK_MBEDTLS
|
||||
|
||||
config BT_LE_WHITELIST_SIZE
|
||||
int "BLE white list size"
|
||||
range 1 31
|
||||
range 1 15
|
||||
default 12
|
||||
depends on !BT_NIMBLE_ENABLED
|
||||
|
||||
@@ -525,23 +457,6 @@ config BT_LE_LL_SCA
|
||||
help
|
||||
Sleep clock accuracy of our device (in ppm)
|
||||
|
||||
config BT_LE_LL_PEER_SCA_SET_ENABLE
|
||||
bool "Enable to set constant peer SCA"
|
||||
default n
|
||||
help
|
||||
Enable setting of constant peer SCA, use this if peer device has SCA larger than 500 PPM.
|
||||
Enable this option, the controller will always use BT_LE_LL_PEER_SCA as the peer SCA value
|
||||
to calculate the window widening instead of the value received from peer device.
|
||||
|
||||
|
||||
config BT_LE_LL_PEER_SCA
|
||||
int "Constant peer sleep clock accuracy value"
|
||||
range 0 10000
|
||||
depends on BT_LE_LL_PEER_SCA_SET_ENABLE
|
||||
default 0
|
||||
help
|
||||
Set the sleep clock accuracy of peer device
|
||||
|
||||
config BT_LE_MAX_CONNECTIONS
|
||||
int "Maximum number of concurrent connections"
|
||||
depends on !BT_NIMBLE_ENABLED
|
||||
@@ -774,75 +689,3 @@ config BT_LE_DFT_TX_POWER_LEVEL_DBM_EFF
|
||||
default 18 if BT_LE_DFT_TX_POWER_LEVEL_P18
|
||||
default 20 if BT_LE_DFT_TX_POWER_LEVEL_P20
|
||||
default 0
|
||||
|
||||
config BT_LE_CTRL_CHECK_CONNECT_IND_ACCESS_ADDRESS
|
||||
bool "Enable enhanced Access Address check in CONNECT_IND"
|
||||
default n
|
||||
help
|
||||
Enabling this option will add stricter verification of the Access Address in the CONNECT_IND PDU.
|
||||
This improves security by ensuring that only connection requests with valid Access Addresses are accepted.
|
||||
If disabled, only basic checks are applied, improving compatibility.
|
||||
|
||||
config BT_CTRL_RUN_IN_FLASH_ONLY
|
||||
bool "Reduce BLE IRAM usage (READ DOCS FIRST) (EXPERIMENTAL)"
|
||||
default n
|
||||
help
|
||||
Move most IRAM into flash. This will increase the usage of flash and reduce ble performance.
|
||||
Because the code is moved to the flash, the execution speed of the code is reduced.
|
||||
To have a small impact on performance, you need to enable flash suspend (SPI_FLASH_AUTO_SUSPEND).
|
||||
|
||||
menu "BLE disconnects when Instant Passed (0x28) occurs"
|
||||
config BT_LE_CTRL_LLCP_CONN_UPDATE
|
||||
bool "BLE ACL connection update procedure"
|
||||
default n
|
||||
help
|
||||
If this option is enabled, Controller will terminate the connection
|
||||
when Instant Passed (0x28) error occurs during connection update procedure.
|
||||
|
||||
config BT_LE_CTRL_LLCP_CHAN_MAP_UPDATE
|
||||
bool "BLE ACL channel map update procedure"
|
||||
default n
|
||||
help
|
||||
If this option is enabled, Controller will terminate the connection
|
||||
when Instant Passed (0x28) error occurs in channel map update procedure.
|
||||
|
||||
config BT_LE_CTRL_LLCP_PHY_UPDATE
|
||||
bool "BLE ACL PHY update procedure"
|
||||
default n
|
||||
help
|
||||
If this option is enabled, Controller will terminate the connection
|
||||
when Instant Passed (0x28) error occurs in PHY update procedure.
|
||||
endmenu
|
||||
|
||||
config BT_CTRL_SCAN_BACKOFF_UPPERLIMITMAX
|
||||
int "The value of upperlimitmax during scan backoff procedure"
|
||||
range 1 256
|
||||
default 32
|
||||
help
|
||||
The value of upperlimitmax needs to be a power of 2.
|
||||
|
||||
config BT_LE_CTRL_CHAN_ASS_EN
|
||||
bool "Enable channel assessment(Experimental)"
|
||||
default n
|
||||
help
|
||||
If this option is enabled, The Controller will records the communication quality
|
||||
for each channel and then start a timer to check and update the channel map every 4 seconds.
|
||||
|
||||
config BT_LE_CTRL_ADV_DATA_LENGTH_ZERO_AUX
|
||||
bool "Enable aux packet when ext adv data length is zero(Experimental)"
|
||||
default y
|
||||
help
|
||||
When this option is enabled, auxiliary packets will be present in the events of
|
||||
'Non-Connectable and Non-Scannable' regardless of whether the advertising length is 0.
|
||||
If this option is not enabled, auxiliary packets will only be present when the advertising length is not 0.
|
||||
|
||||
config BT_LE_RXBUF_OPT_ENABLED
|
||||
bool "Enable rxbuf optimization feature"
|
||||
default y
|
||||
|
||||
config BT_LE_CTRL_FAST_CONN_DATA_TX_EN
|
||||
bool "Enable fast sending of connection data"
|
||||
default y
|
||||
help
|
||||
If this option is enabled, The Controller will continue to
|
||||
Send an empty PDU after sending valid connection data within an interval.
|
||||
|
||||
@@ -1,171 +0,0 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "sdkconfig.h"
|
||||
#include "esp_bt_cfg.h"
|
||||
#include "esp_bit_defs.h"
|
||||
|
||||
/* External functions or variables
|
||||
************************************************************************
|
||||
*/
|
||||
int base_stack_initEnv(void);
|
||||
void base_stack_deinitEnv(void);
|
||||
int base_stack_enable(void);
|
||||
void base_stack_disable(void);
|
||||
|
||||
int conn_stack_initEnv(void);
|
||||
void conn_stack_deinitEnv(void);
|
||||
int conn_stack_enable(void);
|
||||
void conn_stack_disable(void);
|
||||
|
||||
#if CONFIG_BT_LE_ERROR_SIM_ENABLED
|
||||
int conn_errorSim_initEnv(void);
|
||||
void conn_errorSim_deinitEnv(void);
|
||||
int conn_errorSim_enable(void);
|
||||
void conn_errorSim_disable(void);
|
||||
#endif // CONFIG_BT_LE_ERROR_SIM_ENABLED
|
||||
|
||||
#if (CONFIG_BT_NIMBLE_ENABLED || CONFIG_BT_BLUEDROID_ENABLED)
|
||||
void adv_stack_enableClearLegacyAdvVsCmd(bool en);
|
||||
void scan_stack_enableAdvFlowCtrlVsCmd(bool en);
|
||||
void advFilter_stack_enableDupExcListVsCmd(bool en);
|
||||
void arr_stack_enableMultiConnVsCmd(bool en);
|
||||
void pcl_stack_enableSetRssiThreshVsCmd(bool en);
|
||||
void chanSel_stack_enableSetCsaVsCmd(bool en);
|
||||
void log_stack_enableLogsRelatedVsCmd(bool en);
|
||||
void hci_stack_enableSetVsEvtMaskVsCmd(bool en);
|
||||
void winWiden_stack_enableSetConstPeerScaVsCmd(bool en);
|
||||
#if CONFIG_IDF_TARGET_ESP32C61_ECO3
|
||||
void conn_stack_enableSetPrefTxRxCntVsCmd(bool en);
|
||||
#endif // CONFIG_IDF_TARGET_ESP32C61_ECO3
|
||||
|
||||
void adv_stack_enableScanReqRxdVsEvent(bool en);
|
||||
void conn_stack_enableChanMapUpdCompVsEvent(bool en);
|
||||
void sleep_stack_enableWakeupVsEvent(bool en);
|
||||
#endif // (CONFIG_BT_NIMBLE_ENABLED || CONFIG_BT_BLUEDROID_ENABLED)
|
||||
#if CONFIG_BT_LE_RXBUF_OPT_ENABLED
|
||||
extern void mmgmt_enableRxbufOptFeature(void);
|
||||
#endif // CONFIG_BT_LE_RXBUF_OPT_ENABLED
|
||||
|
||||
/* Local functions definition
|
||||
***************************************************************************
|
||||
*/
|
||||
#if (CONFIG_BT_NIMBLE_ENABLED || CONFIG_BT_BLUEDROID_ENABLED)
|
||||
void ble_stack_enableVsCmds(bool en)
|
||||
{
|
||||
adv_stack_enableClearLegacyAdvVsCmd(en);
|
||||
advFilter_stack_enableDupExcListVsCmd(en);
|
||||
scan_stack_enableAdvFlowCtrlVsCmd(en);
|
||||
arr_stack_enableMultiConnVsCmd(en);
|
||||
pcl_stack_enableSetRssiThreshVsCmd(en);
|
||||
chanSel_stack_enableSetCsaVsCmd(en);
|
||||
log_stack_enableLogsRelatedVsCmd(en);
|
||||
hci_stack_enableSetVsEvtMaskVsCmd(en);
|
||||
winWiden_stack_enableSetConstPeerScaVsCmd(en);
|
||||
#if CONFIG_IDF_TARGET_ESP32C61_ECO3
|
||||
conn_stack_enableSetPrefTxRxCntVsCmd(en);
|
||||
#endif // CONFIG_IDF_TARGET_ESP32C61_ECO3
|
||||
}
|
||||
|
||||
void ble_stack_enableVsEvents(bool en)
|
||||
{
|
||||
adv_stack_enableScanReqRxdVsEvent(en);
|
||||
conn_stack_enableChanMapUpdCompVsEvent(en);
|
||||
|
||||
#if CONFIG_BT_LE_SLEEP_ENABLE
|
||||
sleep_stack_enableWakeupVsEvent(en);
|
||||
#endif // CONFIG_BT_LE_SLEEP_ENABLE
|
||||
}
|
||||
#endif // (CONFIG_BT_NIMBLE_ENABLED || CONFIG_BT_BLUEDROID_ENABLED)
|
||||
|
||||
int ble_stack_initEnv(void)
|
||||
{
|
||||
int rc;
|
||||
|
||||
rc = base_stack_initEnv();
|
||||
if (rc) {
|
||||
return rc;
|
||||
}
|
||||
|
||||
#if DEFAULT_BT_LE_MAX_CONNECTIONS
|
||||
rc = conn_stack_initEnv();
|
||||
if (rc) {
|
||||
return rc;
|
||||
}
|
||||
#if CONFIG_BT_LE_ERROR_SIM_ENABLED
|
||||
rc = conn_errorSim_initEnv();
|
||||
if (rc) {
|
||||
return rc;
|
||||
}
|
||||
#endif // CONFIG_BT_LE_ERROR_SIM_ENABLED
|
||||
#endif // DEFAULT_BT_LE_MAX_CONNECTIONS
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void ble_stack_deinitEnv(void)
|
||||
{
|
||||
#if DEFAULT_BT_LE_MAX_CONNECTIONS
|
||||
#if CONFIG_BT_LE_ERROR_SIM_ENABLED
|
||||
conn_errorSim_deinitEnv();
|
||||
#endif // CONFIG_BT_LE_ERROR_SIM_ENABLED
|
||||
conn_stack_deinitEnv();
|
||||
#endif // DEFAULT_BT_LE_MAX_CONNECTIONS
|
||||
|
||||
base_stack_deinitEnv();
|
||||
}
|
||||
|
||||
int ble_stack_enable(void)
|
||||
{
|
||||
int rc;
|
||||
|
||||
rc = base_stack_enable();
|
||||
if (rc) {
|
||||
return rc;
|
||||
}
|
||||
|
||||
#if DEFAULT_BT_LE_MAX_CONNECTIONS
|
||||
rc = conn_stack_enable();
|
||||
if (rc) {
|
||||
return rc;
|
||||
}
|
||||
#if CONFIG_BT_LE_ERROR_SIM_ENABLED
|
||||
rc = conn_errorSim_enable();
|
||||
if (rc) {
|
||||
return rc;
|
||||
}
|
||||
#endif // CONFIG_BT_LE_ERROR_SIM_ENABLED
|
||||
#endif // DEFAULT_BT_LE_MAX_CONNECTIONS
|
||||
|
||||
#if (CONFIG_BT_NIMBLE_ENABLED || CONFIG_BT_BLUEDROID_ENABLED)
|
||||
ble_stack_enableVsCmds(true);
|
||||
ble_stack_enableVsEvents(true);
|
||||
#endif // (CONFIG_BT_NIMBLE_ENABLED || CONFIG_BT_BLUEDROID_ENABLED)
|
||||
|
||||
#if CONFIG_BT_LE_RXBUF_OPT_ENABLED
|
||||
mmgmt_enableRxbufOptFeature();
|
||||
#endif // CONFIG_BT_LE_RXBUF_OPT_ENABLED
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void ble_stack_disable(void)
|
||||
{
|
||||
#if (CONFIG_BT_NIMBLE_ENABLED || CONFIG_BT_BLUEDROID_ENABLED)
|
||||
ble_stack_enableVsEvents(false);
|
||||
ble_stack_enableVsCmds(false);
|
||||
#endif // (CONFIG_BT_NIMBLE_ENABLED || CONFIG_BT_BLUEDROID_ENABLED)
|
||||
|
||||
#if DEFAULT_BT_LE_MAX_CONNECTIONS
|
||||
#if CONFIG_BT_LE_ERROR_SIM_ENABLED
|
||||
conn_errorSim_disable();
|
||||
#endif // CONFIG_BT_LE_ERROR_SIM_ENABLED
|
||||
conn_stack_disable();
|
||||
#endif // DEFAULT_BT_LE_MAX_CONNECTIONS
|
||||
|
||||
base_stack_disable();
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
int ble_stack_initEnv(void);
|
||||
|
||||
void ble_stack_deinitEnv(void);
|
||||
|
||||
int ble_stack_enable(void);
|
||||
|
||||
void ble_stack_disable(void);
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -35,14 +35,12 @@
|
||||
|
||||
#include "esp_bt.h"
|
||||
#include "esp_intr_alloc.h"
|
||||
#include "ble_priv.h"
|
||||
#include "esp_sleep.h"
|
||||
#include "esp_pm.h"
|
||||
#ifdef CONFIG_ESP_PHY_ENABLED
|
||||
#include "esp_phy_init.h"
|
||||
#endif
|
||||
#include "esp_private/periph_ctrl.h"
|
||||
#include "esp_private/esp_clk_tree_common.h"
|
||||
#include "bt_osi_mem.h"
|
||||
|
||||
#if CONFIG_FREERTOS_USE_TICKLESS_IDLE
|
||||
@@ -58,12 +56,6 @@
|
||||
|
||||
#include "hal/efuse_hal.h"
|
||||
#include "soc/rtc.h"
|
||||
#include "modem/modem_syscon_struct.h"
|
||||
|
||||
#if CONFIG_BT_BLE_LOG_SPI_OUT_ENABLED
|
||||
#include "ble_log/ble_log_spi_out.h"
|
||||
#endif // CONFIG_BT_BLE_LOG_SPI_OUT_ENABLED
|
||||
|
||||
/* Macro definition
|
||||
************************************************************************
|
||||
*/
|
||||
@@ -71,7 +63,7 @@
|
||||
#define OSI_COEX_VERSION 0x00010006
|
||||
#define OSI_COEX_MAGIC_VALUE 0xFADEBEAD
|
||||
|
||||
#define EXT_FUNC_VERSION 0x20250415
|
||||
#define EXT_FUNC_VERSION 0x20240422
|
||||
#define EXT_FUNC_MAGIC_VALUE 0xA5A5A5A5
|
||||
|
||||
#define BT_ASSERT_PRINT ets_printf
|
||||
@@ -102,42 +94,25 @@ struct ext_funcs_t {
|
||||
int (* _ecc_gen_key_pair)(uint8_t *public, uint8_t *priv);
|
||||
int (* _ecc_gen_dh_key)(const uint8_t *remote_pub_key_x, const uint8_t *remote_pub_key_y,
|
||||
const uint8_t *local_priv_key, uint8_t *dhkey);
|
||||
#if CONFIG_IDF_TARGET_ESP32C6
|
||||
void (* _esp_reset_modem)(uint8_t mdl_opts, uint8_t start);
|
||||
#endif // CONFIG_IDF_TARGET_ESP32C6
|
||||
void (* _esp_reset_rpa_moudle)(void);
|
||||
uint32_t magic;
|
||||
};
|
||||
|
||||
#if CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
|
||||
typedef void (*interface_func_t) (uint32_t len, const uint8_t *addr, uint32_t len_append, const uint8_t *addr_append, uint32_t flag);
|
||||
|
||||
enum {
|
||||
BLE_LOG_INTERFACE_FLAG_CONTINUE = 0,
|
||||
BLE_LOG_INTERFACE_FLAG_END,
|
||||
};
|
||||
typedef void (*interface_func_t) (uint32_t len, const uint8_t*addr, bool end);
|
||||
#endif // CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
|
||||
|
||||
/* External functions or variables
|
||||
************************************************************************
|
||||
*/
|
||||
#if CONFIG_SW_COEXIST_ENABLE || CONFIG_EXTERNAL_COEX_ENABLE
|
||||
extern void coex_hw_timer_set(uint8_t idx,uint8_t src, uint8_t pti,uint32_t latency, uint32_t perioidc);
|
||||
extern void coex_hw_timer_enable(uint8_t idx);
|
||||
extern void coex_hw_timer_disable(uint8_t idx);
|
||||
#endif // CONFIG_SW_COEXIST_ENABLE || CONFIG_EXTERNAL_COEX_ENABLE
|
||||
extern int ble_osi_coex_funcs_register(struct osi_coex_funcs_t *coex_funcs);
|
||||
extern int r_ble_controller_init(esp_bt_controller_config_t *cfg);
|
||||
extern void esp_ble_controller_info_capture(uint32_t cycle_times);
|
||||
#if CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
|
||||
extern int r_ble_log_init_async(interface_func_t interface, bool task_create, uint8_t buffers, uint32_t *bufs_size);
|
||||
extern int r_ble_log_init_async(interface_func_t bt_controller_log_interface, bool task_create, uint8_t buffers, uint32_t *bufs_size);
|
||||
extern int r_ble_log_deinit_async(void);
|
||||
extern int r_ble_log_init_simple(interface_func_t interface, void *handler);
|
||||
extern void r_ble_log_deinit_simple(void);
|
||||
extern void r_ble_log_async_select_dump_buffers(uint8_t buffers);
|
||||
extern void r_ble_log_async_output_dump_all(bool output);
|
||||
extern void esp_panic_handler_feed_wdts(void);
|
||||
extern int r_ble_log_ctrl_level_and_mod(uint8_t log_level, uint32_t mod_switch);
|
||||
extern int r_ble_ctrl_mod_type(uint16_t mod, uint32_t mod_type_switch);
|
||||
extern void esp_panic_handler_reconfigure_wdts(uint32_t timeout_ms);
|
||||
#endif // CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
|
||||
extern int r_ble_controller_deinit(void);
|
||||
extern int r_ble_controller_enable(uint8_t mode);
|
||||
@@ -155,17 +130,11 @@ extern void r_ble_lll_rfmgmt_set_sleep_cb(void *s_cb, void *w_cb, void *s_arg,
|
||||
extern void r_ble_rtc_wake_up_state_clr(void);
|
||||
extern int os_msys_init(void);
|
||||
extern void os_msys_deinit(void);
|
||||
#if CONFIG_BT_CTRL_RUN_IN_FLASH_ONLY
|
||||
extern void r_ble_ll_scan_start_time_init_compensation(uint32_t init_compensation);
|
||||
extern void r_priv_sdk_config_insert_proc_time_set(uint16_t insert_proc_time);
|
||||
#endif // CONFIG_BT_CTRL_RUN_IN_FLASH_ONLY
|
||||
#if CONFIG_FREERTOS_USE_TICKLESS_IDLE
|
||||
extern sleep_retention_entries_config_t *r_esp_ble_mac_retention_link_get(uint8_t *size, uint8_t extra);
|
||||
extern void r_esp_ble_set_wakeup_overhead(uint32_t overhead);
|
||||
#endif /* CONFIG_FREERTOS_USE_TICKLESS_IDLE */
|
||||
#if CONFIG_BT_LE_LL_PEER_SCA_SET_ENABLE
|
||||
extern void r_ble_ll_customize_peer_sca_set(uint16_t peer_sca);
|
||||
#endif // CONFIG_BT_LE_LL_PEER_SCA_SET_ENABLE
|
||||
extern void r_esp_ble_change_rtc_freq(uint32_t freq);
|
||||
extern int ble_sm_alg_gen_dhkey(const uint8_t *peer_pub_key_x,
|
||||
const uint8_t *peer_pub_key_y,
|
||||
const uint8_t *our_priv_key, uint8_t *out_dhkey);
|
||||
@@ -198,48 +167,62 @@ static int esp_intr_alloc_wrapper(int source, int flags, intr_handler_t handler,
|
||||
static int esp_intr_free_wrapper(void **ret_handle);
|
||||
static void osi_assert_wrapper(const uint32_t ln, const char *fn, uint32_t param1, uint32_t param2);
|
||||
static uint32_t osi_random_wrapper(void);
|
||||
#if CONFIG_IDF_TARGET_ESP32C6
|
||||
static void esp_reset_modem(uint8_t mdl_opts,uint8_t start);
|
||||
#endif // CONFIG_IDF_TARGET_ESP32C6
|
||||
static void esp_reset_rpa_moudle(void);
|
||||
static int esp_ecc_gen_key_pair(uint8_t *pub, uint8_t *priv);
|
||||
static int esp_ecc_gen_dh_key(const uint8_t *peer_pub_key_x, const uint8_t *peer_pub_key_y,
|
||||
const uint8_t *our_priv_key, uint8_t *out_dhkey);
|
||||
#if CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
|
||||
#if !CONFIG_BT_LE_CONTROLLER_LOG_SPI_OUT_ENABLED
|
||||
static void esp_bt_controller_log_interface(uint32_t len, const uint8_t *addr, uint32_t len_append, const uint8_t *addr_append, uint32_t flag);
|
||||
#endif // !CONFIG_BT_LE_CONTROLLER_LOG_SPI_OUT_ENABLED
|
||||
static void esp_bt_controller_log_interface(uint32_t len, const uint8_t *addr, bool end);
|
||||
#if CONFIG_BT_LE_CONTROLLER_LOG_STORAGE_ENABLE
|
||||
static void esp_bt_ctrl_log_partition_get_and_erase_first_block(void);
|
||||
#endif // CONFIG_BT_LE_CONTROLLER_LOG_STORAGE_ENABLE
|
||||
#endif // #if CONFIG_BT_LE_CONTROLLER_LOG_STORAGE_ENABLE
|
||||
#endif // CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
|
||||
/* Local variable definition
|
||||
***************************************************************************
|
||||
*/
|
||||
/* Static variable declare */
|
||||
static DRAM_ATTR esp_bt_controller_status_t ble_controller_status = ESP_BT_CONTROLLER_STATUS_IDLE;
|
||||
|
||||
#if CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
|
||||
const static uint32_t log_bufs_size[] = {CONFIG_BT_LE_LOG_CTRL_BUF1_SIZE, CONFIG_BT_LE_LOG_HCI_BUF_SIZE, CONFIG_BT_LE_LOG_CTRL_BUF2_SIZE};
|
||||
static bool log_is_inited = false;
|
||||
enum log_out_mode {
|
||||
LOG_DUMP_MEMORY,
|
||||
LOG_ASYNC_OUT,
|
||||
LOG_STORAGE_TO_FLASH,
|
||||
};
|
||||
|
||||
esp_err_t esp_bt_controller_log_init(void)
|
||||
bool log_is_inited = false;
|
||||
#if CONFIG_BT_LE_CONTROLLER_LOG_DUMP_ONLY
|
||||
uint8_t log_output_mode = LOG_DUMP_MEMORY;
|
||||
#else
|
||||
#if CONFIG_BT_LE_CONTROLLER_LOG_STORAGE_ENABLE
|
||||
uint8_t log_output_mode = LOG_STORAGE_TO_FLASH;
|
||||
#else
|
||||
uint8_t log_output_mode = LOG_ASYNC_OUT;
|
||||
#endif // CONFIG_BT_LE_CONTROLLER_LOG_STORAGE_ENABLE
|
||||
#endif // CONFIG_BT_LE_CONTROLLER_LOG_DUMP_ONLY
|
||||
|
||||
void esp_bt_log_output_mode_set(uint8_t output_mode)
|
||||
{
|
||||
if (log_is_inited) {
|
||||
return ESP_OK;
|
||||
}
|
||||
log_output_mode = output_mode;
|
||||
}
|
||||
|
||||
#if CONFIG_BT_BLE_LOG_SPI_OUT_ENABLED
|
||||
if (ble_log_spi_out_init() != 0) {
|
||||
goto spi_out_init_failed;
|
||||
}
|
||||
#endif // CONFIG_BT_BLE_LOG_SPI_OUT_ENABLED
|
||||
uint8_t esp_bt_log_output_mode_get(void)
|
||||
{
|
||||
return log_output_mode;
|
||||
}
|
||||
|
||||
#if CONFIG_BT_LE_CONTROLLER_LOG_SPI_OUT_ENABLED
|
||||
if (r_ble_log_init_simple(ble_log_spi_out_ll_write, ble_log_spi_out_ll_log_ev_proc) != 0) {
|
||||
goto log_init_failed;
|
||||
}
|
||||
#else // !CONFIG_BT_LE_CONTROLLER_LOG_SPI_OUT_ENABLED
|
||||
esp_err_t esp_bt_controller_log_init(uint8_t log_output_mode)
|
||||
{
|
||||
esp_err_t ret = ESP_OK;
|
||||
interface_func_t bt_controller_log_interface;
|
||||
bt_controller_log_interface = esp_bt_controller_log_interface;
|
||||
bool task_create;
|
||||
uint8_t buffers = 0;
|
||||
|
||||
if (log_is_inited) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
#if CONFIG_BT_LE_CONTROLLER_LOG_CTRL_ENABLED
|
||||
buffers |= ESP_BLE_LOG_BUF_CONTROLLER;
|
||||
#endif // CONFIG_BT_LE_CONTROLLER_LOG_CTRL_ENABLED
|
||||
@@ -247,50 +230,34 @@ esp_err_t esp_bt_controller_log_init(void)
|
||||
buffers |= ESP_BLE_LOG_BUF_HCI;
|
||||
#endif // CONFIG_BT_LE_CONTROLLER_LOG_HCI_ENABLED
|
||||
|
||||
bool task_create = true;
|
||||
#if CONFIG_BT_LE_CONTROLLER_LOG_DUMP_ONLY
|
||||
task_create = false;
|
||||
#elif CONFIG_BT_LE_CONTROLLER_LOG_STORAGE_ENABLE
|
||||
esp_bt_ctrl_log_partition_get_and_erase_first_block();
|
||||
#endif // CONFIG_BT_LE_CONTROLLER_LOG_SPI_OUT_ENABLED
|
||||
|
||||
if (r_ble_log_init_async(esp_bt_controller_log_interface, task_create, buffers, (uint32_t *)log_bufs_size) != 0) {
|
||||
goto log_init_failed;
|
||||
switch (log_output_mode) {
|
||||
case LOG_DUMP_MEMORY:
|
||||
task_create = false;
|
||||
break;
|
||||
case LOG_ASYNC_OUT:
|
||||
case LOG_STORAGE_TO_FLASH:
|
||||
task_create = true;
|
||||
#if CONFIG_BT_LE_CONTROLLER_LOG_STORAGE_ENABLE
|
||||
if (log_output_mode == LOG_STORAGE_TO_FLASH) {
|
||||
esp_bt_ctrl_log_partition_get_and_erase_first_block();
|
||||
}
|
||||
#endif // CONFIG_BT_LE_CONTROLLER_LOG_STORAGE_ENABLE
|
||||
break;
|
||||
default:
|
||||
assert(0);
|
||||
}
|
||||
#endif // CONFIG_BT_LE_CONTROLLER_LOG_SPI_OUT_ENABLED
|
||||
|
||||
if (r_ble_log_ctrl_level_and_mod(CONFIG_BT_LE_CONTROLLER_LOG_OUTPUT_LEVEL, CONFIG_BT_LE_CONTROLLER_LOG_MOD_OUTPUT_SWITCH) != ESP_OK) {
|
||||
goto ctrl_level_init_failed;
|
||||
ret = r_ble_log_init_async(bt_controller_log_interface, task_create, buffers, (uint32_t *)log_bufs_size);
|
||||
if (ret == ESP_OK) {
|
||||
log_is_inited = true;
|
||||
}
|
||||
log_is_inited = true;
|
||||
return ESP_OK;
|
||||
|
||||
ctrl_level_init_failed:
|
||||
#if CONFIG_BT_LE_CONTROLLER_LOG_SPI_OUT_ENABLED
|
||||
r_ble_log_deinit_simple();
|
||||
#else // !CONFIG_BT_LE_CONTROLLER_LOG_SPI_OUT_ENABLED
|
||||
r_ble_log_deinit_async();
|
||||
#endif // CONFIG_BT_LE_CONTROLLER_LOG_SPI_OUT_ENABLED
|
||||
log_init_failed:
|
||||
#if CONFIG_BT_BLE_LOG_SPI_OUT_ENABLED
|
||||
ble_log_spi_out_deinit();
|
||||
spi_out_init_failed:
|
||||
#endif // CONFIG_BT_BLE_LOG_SPI_OUT_ENABLED
|
||||
return ESP_FAIL;
|
||||
return ret;
|
||||
}
|
||||
|
||||
void esp_bt_controller_log_deinit(void)
|
||||
void esp_bt_ontroller_log_deinit(void)
|
||||
{
|
||||
#if CONFIG_BT_BLE_LOG_SPI_OUT_ENABLED
|
||||
ble_log_spi_out_deinit();
|
||||
#endif // CONFIG_BT_BLE_LOG_SPI_OUT_ENABLED
|
||||
|
||||
#if CONFIG_BT_LE_CONTROLLER_LOG_SPI_OUT_ENABLED
|
||||
r_ble_log_deinit_simple();
|
||||
#else // !CONFIG_BT_LE_CONTROLLER_LOG_SPI_OUT_ENABLED
|
||||
r_ble_log_deinit_async();
|
||||
#endif // CONFIG_BT_LE_CONTROLLER_LOG_SPI_OUT_ENABLED
|
||||
|
||||
log_is_inited = false;
|
||||
}
|
||||
|
||||
@@ -382,13 +349,13 @@ void esp_bt_read_ctrl_log_from_flash(bool output)
|
||||
|
||||
portMUX_TYPE spinlock = portMUX_INITIALIZER_UNLOCKED;
|
||||
portENTER_CRITICAL_SAFE(&spinlock);
|
||||
esp_panic_handler_feed_wdts();
|
||||
esp_panic_handler_reconfigure_wdts(5000);
|
||||
r_ble_log_async_output_dump_all(true);
|
||||
esp_bt_controller_log_deinit();
|
||||
esp_bt_ontroller_log_deinit();
|
||||
stop_write = true;
|
||||
|
||||
buffer = (const uint8_t *)mapped_ptr;
|
||||
esp_panic_handler_feed_wdts();
|
||||
esp_panic_handler_reconfigure_wdts(5000);
|
||||
if (is_filled) {
|
||||
read_index = next_erase_index;
|
||||
} else {
|
||||
@@ -400,7 +367,7 @@ void esp_bt_read_ctrl_log_from_flash(bool output)
|
||||
while (read_index != write_index) {
|
||||
esp_rom_printf("%02x ", buffer[read_index]);
|
||||
if (print_len > max_print_len) {
|
||||
esp_panic_handler_feed_wdts();
|
||||
esp_panic_handler_reconfigure_wdts(5000);
|
||||
print_len = 0;
|
||||
}
|
||||
|
||||
@@ -415,22 +382,6 @@ void esp_bt_read_ctrl_log_from_flash(bool output)
|
||||
assert(err == ESP_OK);
|
||||
}
|
||||
#endif // CONFIG_BT_LE_CONTROLLER_LOG_STORAGE_ENABLE
|
||||
|
||||
#if CONFIG_BT_LE_CONTROLLER_LOG_TASK_WDT_USER_HANDLER_ENABLE
|
||||
void esp_task_wdt_isr_user_handler(void)
|
||||
{
|
||||
esp_ble_controller_log_dump_all(true);
|
||||
}
|
||||
#endif // CONFIG_BT_LE_CONTROLLER_LOG_TASK_WDT_USER_HANDLER_ENABLE
|
||||
|
||||
#if CONFIG_BT_LE_CONTROLLER_LOG_WRAP_PANIC_HANDLER_ENABLE
|
||||
void __real_esp_panic_handler(void *info);
|
||||
void __wrap_esp_panic_handler (void *info)
|
||||
{
|
||||
esp_ble_controller_log_dump_all(true);
|
||||
__real_esp_panic_handler(info);
|
||||
}
|
||||
#endif // CONFIG_BT_LE_CONTROLLER_LOG_WRAP_PANIC_HANDLER_ENABLE
|
||||
#endif // CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
|
||||
|
||||
/* This variable tells if BLE is running */
|
||||
@@ -438,25 +389,11 @@ static bool s_ble_active = false;
|
||||
#ifdef CONFIG_PM_ENABLE
|
||||
static DRAM_ATTR esp_pm_lock_handle_t s_pm_lock = NULL;
|
||||
#endif // CONFIG_PM_ENABLE
|
||||
#define MAIN_XTAL_FREQ_HZ (40000000)
|
||||
#define MAIN_XTAL_FREQ_HZ_WORKROUND (500000)
|
||||
static DRAM_ATTR modem_clock_lpclk_src_t s_bt_lpclk_src = MODEM_CLOCK_LPCLK_SRC_INVALID;
|
||||
static DRAM_ATTR uint32_t s_bt_lpclk_freq = 100000;
|
||||
|
||||
#define BLE_RTC_DELAY_US_LIGHT_SLEEP (3200)
|
||||
#define BLE_RTC_DELAY_US_LIGHT_SLEEP (2500)
|
||||
#define BLE_RTC_DELAY_US_MODEM_SLEEP (500)
|
||||
|
||||
#define BLE_CONTROLLER_MALLOC_CAPS (MALLOC_CAP_INTERNAL|MALLOC_CAP_8BIT|MALLOC_CAP_DMA)
|
||||
void *malloc_ble_controller_mem(size_t size)
|
||||
{
|
||||
return heap_caps_malloc(size, BLE_CONTROLLER_MALLOC_CAPS);
|
||||
}
|
||||
|
||||
uint32_t get_ble_controller_free_heap_size(void)
|
||||
{
|
||||
return heap_caps_get_free_size(BLE_CONTROLLER_MALLOC_CAPS);
|
||||
}
|
||||
|
||||
static const struct osi_coex_funcs_t s_osi_coex_funcs_ro = {
|
||||
._magic = OSI_COEX_MAGIC_VALUE,
|
||||
._version = OSI_COEX_VERSION,
|
||||
@@ -478,34 +415,15 @@ struct ext_funcs_t ext_funcs_ro = {
|
||||
._os_random = osi_random_wrapper,
|
||||
._ecc_gen_key_pair = esp_ecc_gen_key_pair,
|
||||
._ecc_gen_dh_key = esp_ecc_gen_dh_key,
|
||||
#if CONFIG_IDF_TARGET_ESP32C6
|
||||
._esp_reset_modem = esp_reset_modem,
|
||||
#endif // CONFIG_IDF_TARGET_ESP32C6
|
||||
._esp_reset_rpa_moudle = esp_reset_rpa_moudle,
|
||||
.magic = EXT_FUNC_MAGIC_VALUE,
|
||||
};
|
||||
|
||||
#if CONFIG_IDF_TARGET_ESP32C6
|
||||
static void IRAM_ATTR esp_reset_modem(uint8_t mdl_opts,uint8_t start)
|
||||
static void IRAM_ATTR esp_reset_rpa_moudle(void)
|
||||
{
|
||||
if (mdl_opts == 0x05) {
|
||||
if (start) {
|
||||
#if CONFIG_SW_COEXIST_ENABLE || CONFIG_EXTERNAL_COEX_ENABLE
|
||||
coex_hw_timer_set(0x04, 0x02, 15, 0, 5000);
|
||||
coex_hw_timer_enable(0x04);
|
||||
#endif // CONFIG_SW_COEXIST_ENABLE || CONFIG_EXTERNAL_COEX_ENABLE
|
||||
MODEM_SYSCON.modem_rst_conf.val |= (BIT(16) | BIT(18));
|
||||
MODEM_SYSCON.modem_rst_conf.val &= ~(BIT(16) | BIT(18));
|
||||
} else {
|
||||
#if CONFIG_SW_COEXIST_ENABLE || CONFIG_EXTERNAL_COEX_ENABLE
|
||||
coex_hw_timer_disable(0x04);
|
||||
#endif // CONFIG_SW_COEXIST_ENABLE || CONFIG_EXTERNAL_COEX_ENABLE
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif // CONFIG_IDF_TARGET_ESP32C6
|
||||
|
||||
static void IRAM_ATTR osi_assert_wrapper(const uint32_t ln, const char *fn,
|
||||
uint32_t param1, uint32_t param2)
|
||||
{
|
||||
@@ -566,13 +484,11 @@ static int esp_ecc_gen_dh_key(const uint8_t *peer_pub_key_x, const uint8_t *peer
|
||||
return rc;
|
||||
}
|
||||
|
||||
static int esp_intr_alloc_wrapper(int source, int flags, intr_handler_t handler, void *arg, void **ret_handle_in)
|
||||
static int esp_intr_alloc_wrapper(int source, int flags, intr_handler_t handler,
|
||||
void *arg, void **ret_handle_in)
|
||||
{
|
||||
#if CONFIG_BT_CTRL_RUN_IN_FLASH_ONLY
|
||||
int rc = esp_intr_alloc(source, flags, handler, arg, (intr_handle_t *)ret_handle_in);
|
||||
#else
|
||||
int rc = esp_intr_alloc(source, flags | ESP_INTR_FLAG_IRAM, handler, arg, (intr_handle_t *)ret_handle_in);
|
||||
#endif
|
||||
int rc = esp_intr_alloc(source, flags | ESP_INTR_FLAG_IRAM, handler,
|
||||
arg, (intr_handle_t *)ret_handle_in);
|
||||
return rc;
|
||||
}
|
||||
|
||||
@@ -589,21 +505,16 @@ void esp_bt_rtc_slow_clk_select(uint8_t slow_clk_src)
|
||||
/* Select slow clock source for BT momdule */
|
||||
switch (slow_clk_src) {
|
||||
case MODEM_CLOCK_LPCLK_SRC_MAIN_XTAL:
|
||||
#if SOC_BLE_USE_WIFI_PWR_CLK_WORKAROUND
|
||||
uint32_t chip_version = efuse_hal_chip_revision();
|
||||
ESP_LOGI(NIMBLE_PORT_LOG_TAG, "Using main XTAL as clock source, chip ver: %d", chip_version);
|
||||
if (chip_version == 0) {
|
||||
modem_clock_select_lp_clock_source(PERIPH_BT_MODULE, slow_clk_src, (MAIN_XTAL_FREQ_HZ/s_bt_lpclk_freq - 1));
|
||||
} else{
|
||||
modem_clock_select_lp_clock_source(PERIPH_BT_MODULE, slow_clk_src, (MAIN_XTAL_FREQ_HZ_WORKROUND/s_bt_lpclk_freq - 1));
|
||||
}
|
||||
#else
|
||||
ESP_LOGI(NIMBLE_PORT_LOG_TAG, "Using main XTAL as clock source");
|
||||
modem_clock_select_lp_clock_source(PERIPH_BT_MODULE, slow_clk_src, (MAIN_XTAL_FREQ_HZ/s_bt_lpclk_freq - 1));
|
||||
#endif // SOC_BLE_USE_WIFI_PWR_CLK_WORKAROUND
|
||||
uint32_t chip_version = efuse_hal_chip_revision();
|
||||
if (chip_version == 0) {
|
||||
modem_clock_select_lp_clock_source(PERIPH_BT_MODULE, slow_clk_src, (400 - 1));
|
||||
} else{
|
||||
modem_clock_select_lp_clock_source(PERIPH_BT_MODULE, slow_clk_src, (5 - 1));
|
||||
}
|
||||
break;
|
||||
case MODEM_CLOCK_LPCLK_SRC_RC_SLOW:
|
||||
ESP_LOGW(NIMBLE_PORT_LOG_TAG, "Using 136 kHz RC as clock source, use with caution as it may not maintain ACL or Sync process due to low clock accuracy!");
|
||||
ESP_LOGI(NIMBLE_PORT_LOG_TAG, "Using 136 kHz RC as clock source, can only run legacy ADV or SCAN due to low clock accuracy!");
|
||||
modem_clock_select_lp_clock_source(PERIPH_BT_MODULE, slow_clk_src, (5 - 1));
|
||||
break;
|
||||
case MODEM_CLOCK_LPCLK_SRC_XTAL32K:
|
||||
@@ -629,10 +540,6 @@ modem_clock_lpclk_src_t esp_bt_get_lpclk_src(void)
|
||||
|
||||
void esp_bt_set_lpclk_src(modem_clock_lpclk_src_t clk_src)
|
||||
{
|
||||
if (ble_controller_status != ESP_BT_CONTROLLER_STATUS_IDLE) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (clk_src >= MODEM_CLOCK_LPCLK_SRC_MAX) {
|
||||
return;
|
||||
}
|
||||
@@ -640,38 +547,6 @@ void esp_bt_set_lpclk_src(modem_clock_lpclk_src_t clk_src)
|
||||
s_bt_lpclk_src = clk_src;
|
||||
}
|
||||
|
||||
uint32_t esp_bt_get_lpclk_freq(void)
|
||||
{
|
||||
return s_bt_lpclk_freq;
|
||||
}
|
||||
|
||||
void esp_bt_set_lpclk_freq(uint32_t clk_freq)
|
||||
{
|
||||
uint32_t xtal_freq;
|
||||
|
||||
if (ble_controller_status != ESP_BT_CONTROLLER_STATUS_IDLE) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!clk_freq) {
|
||||
return;
|
||||
}
|
||||
|
||||
xtal_freq = MAIN_XTAL_FREQ_HZ;
|
||||
#if SOC_BLE_USE_WIFI_PWR_CLK_WORKAROUND
|
||||
uint32_t chip_version = efuse_hal_chip_revision();
|
||||
if (chip_version == 1) {
|
||||
xtal_freq = MAIN_XTAL_FREQ_HZ_WORKROUND;
|
||||
}
|
||||
#endif // SOC_BLE_USE_WIFI_PWR_CLK_WORKAROUND
|
||||
|
||||
if (xtal_freq % clk_freq) {
|
||||
return;
|
||||
}
|
||||
|
||||
s_bt_lpclk_freq = clk_freq;
|
||||
}
|
||||
|
||||
IRAM_ATTR void controller_sleep_cb(uint32_t enable_tick, void *arg)
|
||||
{
|
||||
if (!s_ble_active) {
|
||||
@@ -693,17 +568,10 @@ IRAM_ATTR void controller_wakeup_cb(void *arg)
|
||||
return;
|
||||
}
|
||||
#ifdef CONFIG_PM_ENABLE
|
||||
esp_pm_config_t pm_config;
|
||||
esp_pm_lock_acquire(s_pm_lock);
|
||||
esp_pm_get_configuration(&pm_config);
|
||||
assert(esp_rom_get_cpu_ticks_per_us() == pm_config.max_freq_mhz);
|
||||
r_ble_rtc_wake_up_state_clr();
|
||||
#endif //CONFIG_PM_ENABLE
|
||||
esp_phy_enable(PHY_MODEM_BT);
|
||||
if (s_bt_lpclk_src == MODEM_CLOCK_LPCLK_SRC_RC_SLOW) {
|
||||
uint32_t *clk_freq = (uint32_t *)arg;
|
||||
*clk_freq = esp_clk_tree_lp_slow_get_freq_hz(ESP_CLK_TREE_SRC_FREQ_PRECISION_CACHED) / 5;
|
||||
}
|
||||
s_ble_active = true;
|
||||
}
|
||||
|
||||
@@ -725,7 +593,7 @@ static esp_err_t sleep_modem_ble_mac_modem_state_init(uint8_t extra)
|
||||
int retention_args = extra;
|
||||
sleep_retention_module_init_param_t init_param = {
|
||||
.cbs = { .create = { .handle = sleep_modem_ble_mac_retention_init, .arg = &retention_args } },
|
||||
.depends = RETENTION_MODULE_BITMAP_INIT(BT_BB)
|
||||
.depends = BIT(SLEEP_RETENTION_MODULE_BT_BB)
|
||||
};
|
||||
esp_err_t err = sleep_retention_module_init(SLEEP_RETENTION_MODULE_BLE_MAC, &init_param);
|
||||
if (err == ESP_OK) {
|
||||
@@ -938,12 +806,11 @@ static void ble_rtc_clk_init(esp_bt_controller_config_t *cfg)
|
||||
}
|
||||
|
||||
if (s_bt_lpclk_src == MODEM_CLOCK_LPCLK_SRC_MAIN_XTAL) {
|
||||
cfg->rtc_freq = s_bt_lpclk_freq;
|
||||
cfg->rtc_freq = 100000;
|
||||
} else if (s_bt_lpclk_src == MODEM_CLOCK_LPCLK_SRC_XTAL32K) {
|
||||
cfg->rtc_freq = 32768;
|
||||
} else if (s_bt_lpclk_src == MODEM_CLOCK_LPCLK_SRC_RC_SLOW) {
|
||||
cfg->rtc_freq = esp_clk_tree_lp_slow_get_freq_hz(ESP_CLK_TREE_SRC_FREQ_PRECISION_CACHED) / 5;
|
||||
cfg->ble_ll_sca = 3000;
|
||||
cfg->rtc_freq = 30000;
|
||||
} else if (s_bt_lpclk_src == MODEM_CLOCK_LPCLK_SRC_RC32K) {
|
||||
cfg->rtc_freq = 32000;
|
||||
} else if (s_bt_lpclk_src == MODEM_CLOCK_LPCLK_SRC_EXT32K) {
|
||||
@@ -1022,7 +889,7 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg)
|
||||
#endif // CONFIG_SW_COEXIST_ENABLE
|
||||
|
||||
#if CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
|
||||
ret = esp_bt_controller_log_init();
|
||||
ret = esp_bt_controller_log_init(log_output_mode);
|
||||
if (ret != ESP_OK) {
|
||||
ESP_LOGW(NIMBLE_PORT_LOG_TAG, "ble_controller_log_init failed %d", ret);
|
||||
goto modem_deint;
|
||||
@@ -1034,23 +901,13 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg)
|
||||
goto modem_deint;
|
||||
}
|
||||
|
||||
ESP_LOGI(NIMBLE_PORT_LOG_TAG, "ble controller commit:[%s]", ble_controller_get_compile_version());
|
||||
|
||||
ret = r_ble_controller_init(cfg);
|
||||
if (ret != ESP_OK) {
|
||||
ESP_LOGW(NIMBLE_PORT_LOG_TAG, "r_ble_controller_init failed %d", ret);
|
||||
goto modem_deint;
|
||||
}
|
||||
|
||||
#if CONFIG_BT_LE_LL_PEER_SCA_SET_ENABLE
|
||||
r_ble_ll_customize_peer_sca_set(CONFIG_BT_LE_LL_PEER_SCA);
|
||||
#endif // CONFIG_BT_LE_LL_PEER_SCA_SET_ENABLE
|
||||
|
||||
ret = ble_stack_initEnv();
|
||||
if (ret != ESP_OK) {
|
||||
ESP_LOGW(NIMBLE_PORT_LOG_TAG, "ble_stack_initEnv failed %d", ret);
|
||||
goto free_controller;
|
||||
}
|
||||
ESP_LOGI(NIMBLE_PORT_LOG_TAG, "ble controller commit:[%s]", ble_controller_get_compile_version());
|
||||
|
||||
ble_controller_scan_duplicate_config();
|
||||
|
||||
@@ -1093,12 +950,11 @@ free_controller:
|
||||
hci_transport_deinit();
|
||||
controller_sleep_deinit();
|
||||
os_msys_deinit();
|
||||
ble_stack_deinitEnv();
|
||||
r_ble_controller_deinit();
|
||||
modem_deint:
|
||||
esp_ble_unregister_bb_funcs();
|
||||
#if CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
|
||||
esp_bt_controller_log_deinit();
|
||||
esp_bt_ontroller_log_deinit();
|
||||
#endif // CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
|
||||
esp_phy_modem_deinit();
|
||||
modem_clock_deselect_lp_clock_source(PERIPH_BT_MODULE);
|
||||
@@ -1131,11 +987,10 @@ esp_err_t esp_bt_controller_deinit(void)
|
||||
modem_clock_deselect_lp_clock_source(PERIPH_BT_MODULE);
|
||||
modem_clock_module_disable(PERIPH_BT_MODULE);
|
||||
|
||||
ble_stack_deinitEnv();
|
||||
r_ble_controller_deinit();
|
||||
esp_ble_unregister_bb_funcs();
|
||||
#if CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
|
||||
esp_bt_controller_log_deinit();
|
||||
esp_bt_ontroller_log_deinit();
|
||||
#endif // CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
|
||||
|
||||
#if CONFIG_BT_NIMBLE_ENABLED
|
||||
@@ -1181,16 +1036,6 @@ esp_err_t esp_bt_controller_enable(esp_bt_mode_t mode)
|
||||
coex_enable();
|
||||
#endif // CONFIG_SW_COEXIST_ENABLE
|
||||
|
||||
#if CONFIG_BT_CTRL_RUN_IN_FLASH_ONLY
|
||||
r_ble_ll_scan_start_time_init_compensation(500);
|
||||
r_priv_sdk_config_insert_proc_time_set(500);
|
||||
#endif // CONFIG_BT_CTRL_RUN_IN_FLASH_ONLY
|
||||
|
||||
if (ble_stack_enable() != 0) {
|
||||
ret = ESP_FAIL;
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (r_ble_controller_enable(mode) != 0) {
|
||||
ret = ESP_FAIL;
|
||||
goto error;
|
||||
@@ -1199,7 +1044,6 @@ esp_err_t esp_bt_controller_enable(esp_bt_mode_t mode)
|
||||
return ESP_OK;
|
||||
|
||||
error:
|
||||
ble_stack_disable();
|
||||
#if CONFIG_SW_COEXIST_ENABLE
|
||||
coex_disable();
|
||||
#endif
|
||||
@@ -1223,7 +1067,6 @@ esp_err_t esp_bt_controller_disable(void)
|
||||
if (r_ble_controller_disable() != 0) {
|
||||
return ESP_FAIL;
|
||||
}
|
||||
ble_stack_disable();
|
||||
#if CONFIG_SW_COEXIST_ENABLE
|
||||
coex_disable();
|
||||
#endif
|
||||
@@ -1353,17 +1196,9 @@ esp_err_t esp_ble_tx_power_set(esp_ble_power_type_t power_type, esp_power_level_
|
||||
|
||||
switch (power_type) {
|
||||
case ESP_BLE_PWR_TYPE_DEFAULT:
|
||||
if (r_ble_txpwr_set(ESP_BLE_ENHANCED_PWR_TYPE_DEFAULT, 0, power_level) == 0) {
|
||||
stat = ESP_OK;
|
||||
}
|
||||
break;
|
||||
case ESP_BLE_PWR_TYPE_ADV:
|
||||
if (r_ble_txpwr_set(ESP_BLE_ENHANCED_PWR_TYPE_ADV, 0xFF, power_level) == 0) {
|
||||
stat = ESP_OK;
|
||||
}
|
||||
break;
|
||||
case ESP_BLE_PWR_TYPE_SCAN:
|
||||
if (r_ble_txpwr_set(ESP_BLE_ENHANCED_PWR_TYPE_SCAN, 0, power_level) == 0) {
|
||||
if (r_ble_txpwr_set(ESP_BLE_ENHANCED_PWR_TYPE_DEFAULT, 0, power_level) == 0) {
|
||||
stat = ESP_OK;
|
||||
}
|
||||
break;
|
||||
@@ -1394,13 +1229,9 @@ esp_err_t esp_ble_tx_power_set_enhanced(esp_ble_enhanced_power_type_t power_type
|
||||
esp_err_t stat = ESP_FAIL;
|
||||
switch (power_type) {
|
||||
case ESP_BLE_ENHANCED_PWR_TYPE_DEFAULT:
|
||||
if (r_ble_txpwr_set(ESP_BLE_ENHANCED_PWR_TYPE_DEFAULT, 0, power_level) == 0) {
|
||||
stat = ESP_OK;
|
||||
}
|
||||
break;
|
||||
case ESP_BLE_ENHANCED_PWR_TYPE_SCAN:
|
||||
case ESP_BLE_ENHANCED_PWR_TYPE_INIT:
|
||||
if (r_ble_txpwr_set(ESP_BLE_ENHANCED_PWR_TYPE_SCAN, 0, power_level) == 0) {
|
||||
if (r_ble_txpwr_set(ESP_BLE_ENHANCED_PWR_TYPE_DEFAULT, 0, power_level) == 0) {
|
||||
stat = ESP_OK;
|
||||
}
|
||||
break;
|
||||
@@ -1423,15 +1254,11 @@ esp_power_level_t esp_ble_tx_power_get(esp_ble_power_type_t power_type)
|
||||
int tx_level = 0;
|
||||
|
||||
switch (power_type) {
|
||||
case ESP_BLE_PWR_TYPE_ADV:
|
||||
case ESP_BLE_PWR_TYPE_SCAN:
|
||||
case ESP_BLE_PWR_TYPE_DEFAULT:
|
||||
tx_level = r_ble_txpwr_get(ESP_BLE_ENHANCED_PWR_TYPE_DEFAULT, 0);
|
||||
break;
|
||||
case ESP_BLE_PWR_TYPE_ADV:
|
||||
tx_level = r_ble_txpwr_get(ESP_BLE_ENHANCED_PWR_TYPE_ADV, 0);
|
||||
break;
|
||||
case ESP_BLE_PWR_TYPE_SCAN:
|
||||
tx_level = r_ble_txpwr_get(ESP_BLE_ENHANCED_PWR_TYPE_SCAN, 0);
|
||||
break;
|
||||
case ESP_BLE_PWR_TYPE_CONN_HDL0:
|
||||
case ESP_BLE_PWR_TYPE_CONN_HDL1:
|
||||
case ESP_BLE_PWR_TYPE_CONN_HDL2:
|
||||
@@ -1461,11 +1288,9 @@ esp_power_level_t esp_ble_tx_power_get_enhanced(esp_ble_enhanced_power_type_t po
|
||||
|
||||
switch (power_type) {
|
||||
case ESP_BLE_ENHANCED_PWR_TYPE_DEFAULT:
|
||||
tx_level = r_ble_txpwr_get(ESP_BLE_ENHANCED_PWR_TYPE_DEFAULT, 0);
|
||||
break;
|
||||
case ESP_BLE_ENHANCED_PWR_TYPE_SCAN:
|
||||
case ESP_BLE_ENHANCED_PWR_TYPE_INIT:
|
||||
tx_level = r_ble_txpwr_get(ESP_BLE_ENHANCED_PWR_TYPE_SCAN, 0);
|
||||
tx_level = r_ble_txpwr_get(ESP_BLE_ENHANCED_PWR_TYPE_DEFAULT, 0);
|
||||
break;
|
||||
case ESP_BLE_ENHANCED_PWR_TYPE_ADV:
|
||||
case ESP_BLE_ENHANCED_PWR_TYPE_CONN:
|
||||
@@ -1483,47 +1308,42 @@ esp_power_level_t esp_ble_tx_power_get_enhanced(esp_ble_enhanced_power_type_t po
|
||||
}
|
||||
|
||||
#if CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
|
||||
#if !CONFIG_BT_LE_CONTROLLER_LOG_SPI_OUT_ENABLED
|
||||
static void esp_bt_controller_log_interface(uint32_t len, const uint8_t *addr, uint32_t len_append, const uint8_t *addr_append, uint32_t flag)
|
||||
static void esp_bt_controller_log_interface(uint32_t len, const uint8_t *addr, bool end)
|
||||
{
|
||||
bool end = (flag & BIT(BLE_LOG_INTERFACE_FLAG_END));
|
||||
if (log_output_mode == LOG_STORAGE_TO_FLASH) {
|
||||
#if CONFIG_BT_LE_CONTROLLER_LOG_STORAGE_ENABLE
|
||||
esp_bt_controller_log_storage(len, addr, end);
|
||||
#else // !CONFIG_BT_LE_CONTROLLER_LOG_STORAGE_ENABLE
|
||||
portMUX_TYPE spinlock = portMUX_INITIALIZER_UNLOCKED;
|
||||
portENTER_CRITICAL_SAFE(&spinlock);
|
||||
esp_panic_handler_feed_wdts();
|
||||
esp_bt_controller_log_storage(len, addr, end);
|
||||
#endif //CONFIG_BT_LE_CONTROLLER_LOG_STORAGE_ENABLE
|
||||
} else {
|
||||
portMUX_TYPE spinlock = portMUX_INITIALIZER_UNLOCKED;
|
||||
portENTER_CRITICAL_SAFE(&spinlock);
|
||||
esp_panic_handler_reconfigure_wdts(1000);
|
||||
for (int i = 0; i < len; i++) {
|
||||
esp_rom_printf("%02x ", addr[i]);
|
||||
}
|
||||
|
||||
if (len && addr) {
|
||||
for (int i = 0; i < len; i++) { esp_rom_printf("%02x ", addr[i]); }
|
||||
if (end) {
|
||||
esp_rom_printf("\n");
|
||||
}
|
||||
portEXIT_CRITICAL_SAFE(&spinlock);
|
||||
}
|
||||
if (len_append && addr_append) {
|
||||
for (int i = 0; i < len_append; i++) { esp_rom_printf("%02x ", addr_append[i]); }
|
||||
}
|
||||
if (end) { esp_rom_printf("\n"); }
|
||||
|
||||
portEXIT_CRITICAL_SAFE(&spinlock);
|
||||
#endif // CONFIG_BT_LE_CONTROLLER_LOG_STORAGE_ENABLE
|
||||
}
|
||||
#endif // !CONFIG_BT_LE_CONTROLLER_LOG_SPI_OUT_ENABLED
|
||||
|
||||
void esp_ble_controller_log_dump_all(bool output)
|
||||
{
|
||||
#if CONFIG_BT_BLE_LOG_SPI_OUT_ENABLED
|
||||
ble_log_spi_out_dump_all();
|
||||
#endif // CONFIG_BT_BLE_LOG_SPI_OUT_ENABLED
|
||||
|
||||
if (log_output_mode == LOG_STORAGE_TO_FLASH) {
|
||||
#if CONFIG_BT_LE_CONTROLLER_LOG_STORAGE_ENABLE
|
||||
esp_bt_read_ctrl_log_from_flash(output);
|
||||
#elif !CONFIG_BT_LE_CONTROLLER_LOG_SPI_OUT_ENABLED
|
||||
portMUX_TYPE spinlock = portMUX_INITIALIZER_UNLOCKED;
|
||||
portENTER_CRITICAL_SAFE(&spinlock);
|
||||
esp_panic_handler_feed_wdts();
|
||||
BT_ASSERT_PRINT("\r\n[DUMP_START:");
|
||||
r_ble_log_async_output_dump_all(output);
|
||||
BT_ASSERT_PRINT(":DUMP_END]\r\n");
|
||||
portEXIT_CRITICAL_SAFE(&spinlock);
|
||||
#endif
|
||||
esp_bt_read_ctrl_log_from_flash(output);
|
||||
#endif // CONFIG_BT_LE_CONTROLLER_LOG_STORAGE_ENABLE
|
||||
} else {
|
||||
portMUX_TYPE spinlock = portMUX_INITIALIZER_UNLOCKED;
|
||||
portENTER_CRITICAL_SAFE(&spinlock);
|
||||
esp_panic_handler_reconfigure_wdts(5000);
|
||||
BT_ASSERT_PRINT("\r\n[DUMP_START:");
|
||||
r_ble_log_async_output_dump_all(output);
|
||||
BT_ASSERT_PRINT(":DUMP_END]\r\n");
|
||||
portEXIT_CRITICAL_SAFE(&spinlock);
|
||||
}
|
||||
}
|
||||
#endif // CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
|
||||
|
||||
@@ -1738,36 +1558,3 @@ int ble_sm_alg_gen_key_pair(uint8_t *pub, uint8_t *priv)
|
||||
|
||||
#endif // CONFIG_BT_LE_SM_LEGACY || CONFIG_BT_LE_SM_SC
|
||||
#endif // (!CONFIG_BT_NIMBLE_ENABLED) && (CONFIG_BT_CONTROLLER_ENABLED)
|
||||
|
||||
#if CONFIG_BT_LE_DEBUG_REMAIN_SCENE_ENABLED
|
||||
#include "esp_gdbstub.h"
|
||||
#endif // CONFIG_BT_LE_DEBUG_REMAIN_SCENE_ENABLED
|
||||
|
||||
int IRAM_ATTR
|
||||
ble_capture_info_user_handler(uint8_t type, uint32_t reason)
|
||||
{
|
||||
int i;
|
||||
|
||||
switch(type) {
|
||||
case 0:
|
||||
for (i = 0; i < 2; i++) {
|
||||
esp_ble_controller_info_capture(0x010101);
|
||||
}
|
||||
#if CONFIG_BT_LE_DEBUG_REMAIN_SCENE_ENABLED
|
||||
uintptr_t sp;
|
||||
__asm__ volatile ("mv %0, sp" : "=r" (sp));
|
||||
esp_gdbstub_panic_handler(&sp);
|
||||
#endif // CONFIG_BT_LE_DEBUG_REMAIN_SCENE_ENABLED
|
||||
break;
|
||||
#if CONFIG_BT_LE_ASSERT_WHEN_ABNORMAL_DISCONN_ENABLED
|
||||
case 1:
|
||||
if ((reason == 0x08) || (reason == 0x3d) || (reason == 0x28)) {
|
||||
osi_assert_wrapper(__LINE__,__func__, type, reason);
|
||||
}
|
||||
break;
|
||||
#endif // CONFIG_BT_LE_ASSERT_WHEN_ABNORMAL_DISCONN_ENABLED
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -40,7 +40,6 @@ extern "C" {
|
||||
#define DEFAULT_BT_LE_HCI_EVT_HI_BUF_COUNT MYNEWT_VAL(BLE_TRANSPORT_EVT_COUNT)
|
||||
#define DEFAULT_BT_LE_HCI_EVT_LO_BUF_COUNT MYNEWT_VAL(BLE_TRANSPORT_EVT_DISCARDABLE_COUNT)
|
||||
#define DEFAULT_BT_LE_POWER_CONTROL_ENABLED MYNEWT_VAL(BLE_POWER_CONTROL)
|
||||
#define DEFAULT_BT_LE_SUBRATE_ENABLED MYNEWT_VAL(BLE_CONN_SUBRATING)
|
||||
#if defined(CONFIG_BT_NIMBLE_50_FEATURE_SUPPORT)
|
||||
#define DEFAULT_BT_LE_50_FEATURE_SUPPORT (1)
|
||||
#else
|
||||
@@ -145,80 +144,16 @@ extern "C" {
|
||||
#define DEFAULT_BT_LE_HCI_UART_CTS_PIN (-1)
|
||||
#define DEFAULT_BT_LE_HCI_UART_RTS_PIN (-1)
|
||||
#endif
|
||||
|
||||
#define DEFAULT_BT_LE_SUBRATE_ENABLED 0
|
||||
#endif
|
||||
|
||||
#define DEFAULT_BT_LE_COEX_PHY_CODED_TX_RX_TLIM_EFF CONFIG_BT_LE_COEX_PHY_CODED_TX_RX_TLIM_EFF
|
||||
|
||||
#ifdef CONFIG_BT_LE_CTRL_CHECK_CONNECT_IND_ACCESS_ADDRESS
|
||||
#define DEFAULT_BT_LE_CTRL_CHECK_CONNECT_IND_ACCESS_ADDRESS (CONFIG_BT_LE_CTRL_CHECK_CONNECT_IND_ACCESS_ADDRESS)
|
||||
#else
|
||||
#define DEFAULT_BT_LE_CTRL_CHECK_CONNECT_IND_ACCESS_ADDRESS (0)
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_BT_LE_CTRL_LLCP_CONN_UPDATE
|
||||
#define BT_CTRL_BLE_LLCP_CONN_UPDATE (1<<0)
|
||||
#else
|
||||
#define BT_CTRL_BLE_LLCP_CONN_UPDATE (0<<0)
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_BT_LE_CTRL_LLCP_CHAN_MAP_UPDATE
|
||||
#define BT_CTRL_BLE_LLCP_CHAN_MAP_UPDATE (1<<1)
|
||||
#else
|
||||
#define BT_CTRL_BLE_LLCP_CHAN_MAP_UPDATE (0<<1)
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_BT_LE_CTRL_LLCP_PHY_UPDATE
|
||||
#define BT_CTRL_BLE_LLCP_PHY_UPDATE (1<<2)
|
||||
#else
|
||||
#define BT_CTRL_BLE_LLCP_PHY_UPDATE (0<<2)
|
||||
#endif
|
||||
|
||||
#define BT_LE_CTRL_LLCP_DISC_FLAG (BT_CTRL_BLE_LLCP_CONN_UPDATE | BT_CTRL_BLE_LLCP_CHAN_MAP_UPDATE | BT_CTRL_BLE_LLCP_PHY_UPDATE)
|
||||
|
||||
#ifdef CONFIG_BT_CTRL_SCAN_BACKOFF_UPPERLIMITMAX
|
||||
#define BT_CTRL_SCAN_BACKOFF_UPPERLIMITMAX (CONFIG_BT_CTRL_SCAN_BACKOFF_UPPERLIMITMAX)
|
||||
#else
|
||||
#define BT_CTRL_SCAN_BACKOFF_UPPERLIMITMAX (256)
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_BT_LE_CTRL_CHAN_ASS_EN)
|
||||
#define DEFAULT_BT_LE_CTRL_CHAN_ASS_EN (CONFIG_BT_LE_CTRL_CHAN_ASS_EN)
|
||||
#else
|
||||
#define DEFAULT_BT_LE_CTRL_CHAN_ASS_EN (0)
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_BT_LE_CTRL_ADV_DATA_LENGTH_ZERO_AUX)
|
||||
#define DEFAULT_BT_LE_CTRL_ADV_DATA_LENGTH_ZERO_AUX (CONFIG_BT_LE_CTRL_ADV_DATA_LENGTH_ZERO_AUX)
|
||||
#else
|
||||
#define DEFAULT_BT_LE_CTRL_ADV_DATA_LENGTH_ZERO_AUX (0)
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_BT_LE_CTRL_FAST_CONN_DATA_TX_EN)
|
||||
#define DEFAULT_BT_LE_CTRL_FAST_CONN_DATA_TX_EN (CONFIG_BT_LE_CTRL_FAST_CONN_DATA_TX_EN)
|
||||
#else
|
||||
#define DEFAULT_BT_LE_CTRL_FAST_CONN_DATA_TX_EN (0)
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_BT_LE_HCI_INTERFACE_USE_UART
|
||||
#define HCI_UART_EN CONFIG_BT_LE_HCI_INTERFACE_USE_UART
|
||||
#else
|
||||
#define HCI_UART_EN 0 // hci ram mode
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_BT_LE_HCI_INTERFACE_USE_RAM
|
||||
#define DEFAULT_BT_LE_VHCI_ENABLED (CONFIG_BT_LE_HCI_INTERFACE_USE_RAM)
|
||||
#else
|
||||
#define DEFAULT_BT_LE_VHCI_ENABLED (0)
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_BT_LE_PTR_CHECK_ENABLED
|
||||
#define DEFAULT_BT_LE_PTR_CHECK_ENABLED (CONFIG_BT_LE_PTR_CHECK_ENABLED)
|
||||
#else
|
||||
#define DEFAULT_BT_LE_PTR_CHECK_ENABLED (0)
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_BT_LE_SLEEP_ENABLE
|
||||
#define NIMBLE_SLEEP_ENABLE CONFIG_BT_LE_SLEEP_ENABLE
|
||||
#else
|
||||
@@ -283,6 +218,7 @@ extern "C" {
|
||||
|
||||
#define BLE_LL_TX_PWR_DBM_N (CONFIG_BT_LE_DFT_TX_POWER_LEVEL_DBM_EFF)
|
||||
|
||||
|
||||
#define RUN_BQB_TEST (0)
|
||||
#define RUN_QA_TEST (0)
|
||||
#define NIMBLE_DISABLE_SCAN_BACKOFF (0)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
|
||||
menu "HCI Config"
|
||||
|
||||
choice BT_LE_HCI_INTERFACE
|
||||
prompt "HCI mode"
|
||||
default BT_LE_HCI_INTERFACE_USE_RAM
|
||||
@@ -107,7 +108,7 @@ menu "HCI Config"
|
||||
config BT_LE_HCI_TRANS_TASK_STACK_SIZE
|
||||
int "HCI transport task stack size"
|
||||
depends on !BT_LE_HCI_INTERFACE_USE_RAM
|
||||
default 2048
|
||||
default 1024
|
||||
help
|
||||
This configures stack size of hci transport task
|
||||
|
||||
@@ -227,19 +228,6 @@ config BT_LE_POWER_CONTROL_ENABLED
|
||||
help
|
||||
Set this option to enable the Power Control feature on controller
|
||||
|
||||
config BT_LE_CTE_FEATURE_ENABLED
|
||||
bool "Enable Bluetooth LE Direction Finding (AoA/AoD)"
|
||||
depends on BT_LE_50_FEATURE_SUPPORT && SOC_BLE_CTE_SUPPORTED && !(BT_LE_SECURITY_ENABLE)
|
||||
default n
|
||||
help
|
||||
Enable this option to activate Bluetooth LE Direction Finding (AoA/AoD) feature.
|
||||
Note:
|
||||
This feature allows devices to determine the direction of a Bluetooth CTE signal,
|
||||
enabling Angle of Arrival (AoA) and Angle of Departure (AoD) functionality.
|
||||
In chip esp32h2, Direction Finding is not supported in encrypted
|
||||
communication scenarios. If you are using chip esp32h2, ensure that encryption is
|
||||
disabled when using this feature.
|
||||
|
||||
menu "Memory Settings"
|
||||
depends on !BT_NIMBLE_ENABLED
|
||||
|
||||
@@ -318,131 +306,72 @@ config BT_LE_CONTROLLER_TASK_STACK_SIZE
|
||||
help
|
||||
This configures stack size of NimBLE controller task
|
||||
|
||||
menu "Controller debug features"
|
||||
menuconfig BT_LE_CONTROLLER_LOG_ENABLED
|
||||
bool "Controller log enable"
|
||||
default n
|
||||
help
|
||||
Enable controller log
|
||||
menuconfig BT_LE_CONTROLLER_LOG_ENABLED
|
||||
bool "Controller log enable"
|
||||
default n
|
||||
help
|
||||
Enable controller log
|
||||
|
||||
config BT_LE_CONTROLLER_LOG_CTRL_ENABLED
|
||||
bool "enable controller log module"
|
||||
depends on BT_LE_CONTROLLER_LOG_ENABLED
|
||||
default y
|
||||
help
|
||||
config BT_LE_CONTROLLER_LOG_CTRL_ENABLED
|
||||
bool "enable controller log module"
|
||||
depends on BT_LE_CONTROLLER_LOG_ENABLED
|
||||
default y
|
||||
help
|
||||
Enable controller log module
|
||||
|
||||
config BT_LE_CONTROLLER_LOG_HCI_ENABLED
|
||||
bool "enable HCI log module"
|
||||
depends on BT_LE_CONTROLLER_LOG_ENABLED
|
||||
default y
|
||||
help
|
||||
config BT_LE_CONTROLLER_LOG_HCI_ENABLED
|
||||
bool "enable HCI log module"
|
||||
depends on BT_LE_CONTROLLER_LOG_ENABLED
|
||||
default y
|
||||
help
|
||||
Enable hci log module
|
||||
|
||||
config BT_LE_CONTROLLER_LOG_DUMP_ONLY
|
||||
bool "Controller log dump mode only"
|
||||
depends on BT_LE_CONTROLLER_LOG_ENABLED
|
||||
default y
|
||||
help
|
||||
config BT_LE_CONTROLLER_LOG_DUMP_ONLY
|
||||
bool "Controller log dump mode only"
|
||||
depends on BT_LE_CONTROLLER_LOG_ENABLED
|
||||
default y
|
||||
help
|
||||
Only operate in dump mode
|
||||
|
||||
config BT_LE_CONTROLLER_LOG_SPI_OUT_ENABLED
|
||||
bool "Output ble controller logs to SPI bus (Experimental)"
|
||||
depends on BT_LE_CONTROLLER_LOG_ENABLED
|
||||
depends on !BT_LE_CONTROLLER_LOG_DUMP_ONLY
|
||||
select BT_BLE_LOG_SPI_OUT_ENABLED
|
||||
default n
|
||||
help
|
||||
Output ble controller logs to SPI bus
|
||||
|
||||
config BT_LE_CONTROLLER_LOG_STORAGE_ENABLE
|
||||
bool "Store ble controller logs to flash(Experimental)"
|
||||
depends on !BT_LE_CONTROLLER_LOG_DUMP_ONLY
|
||||
depends on BT_LE_CONTROLLER_LOG_ENABLED
|
||||
default n
|
||||
help
|
||||
config BT_LE_CONTROLLER_LOG_STORAGE_ENABLE
|
||||
bool "Store ble controller logs to flash(Experimental)"
|
||||
depends on !BT_LE_CONTROLLER_LOG_DUMP_ONLY
|
||||
depends on BT_LE_CONTROLLER_LOG_ENABLED
|
||||
default n
|
||||
help
|
||||
Store ble controller logs to flash memory.
|
||||
|
||||
config BT_LE_CONTROLLER_LOG_PARTITION_SIZE
|
||||
int "size of ble controller log partition(Multiples of 4K)"
|
||||
depends on BT_LE_CONTROLLER_LOG_STORAGE_ENABLE
|
||||
default 65536
|
||||
help
|
||||
config BT_LE_CONTROLLER_LOG_PARTITION_SIZE
|
||||
int "size of ble controller log partition(Multiples of 4K)"
|
||||
depends on BT_LE_CONTROLLER_LOG_STORAGE_ENABLE
|
||||
default 65536
|
||||
help
|
||||
The size of ble controller log partition shall be a multiples of 4K.
|
||||
The name of log partition shall be "bt_ctrl_log".
|
||||
The partition type shall be ESP_PARTITION_TYPE_DATA.
|
||||
The partition sub_type shall be ESP_PARTITION_SUBTYPE_ANY.
|
||||
|
||||
config BT_LE_LOG_CTRL_BUF1_SIZE
|
||||
int "size of the first BLE controller LOG buffer"
|
||||
depends on BT_LE_CONTROLLER_LOG_ENABLED
|
||||
default 4096
|
||||
help
|
||||
config BT_LE_LOG_CTRL_BUF1_SIZE
|
||||
int "size of the first BLE controller LOG buffer"
|
||||
depends on BT_LE_CONTROLLER_LOG_ENABLED
|
||||
default 4096
|
||||
help
|
||||
Configure the size of the first BLE controller LOG buffer.
|
||||
|
||||
config BT_LE_LOG_CTRL_BUF2_SIZE
|
||||
int "size of the second BLE controller LOG buffer"
|
||||
depends on BT_LE_CONTROLLER_LOG_ENABLED
|
||||
default 1024
|
||||
help
|
||||
config BT_LE_LOG_CTRL_BUF2_SIZE
|
||||
int "size of the second BLE controller LOG buffer"
|
||||
depends on BT_LE_CONTROLLER_LOG_ENABLED
|
||||
default 1024
|
||||
help
|
||||
Configure the size of the second BLE controller LOG buffer.
|
||||
|
||||
config BT_LE_LOG_HCI_BUF_SIZE
|
||||
int "size of the BLE HCI LOG buffer"
|
||||
depends on BT_LE_CONTROLLER_LOG_ENABLED
|
||||
default 4096
|
||||
help
|
||||
config BT_LE_LOG_HCI_BUF_SIZE
|
||||
int "size of the BLE HCI LOG buffer"
|
||||
depends on BT_LE_CONTROLLER_LOG_ENABLED
|
||||
default 4096
|
||||
help
|
||||
Configure the size of the BLE HCI LOG buffer.
|
||||
|
||||
config BT_LE_CONTROLLER_LOG_WRAP_PANIC_HANDLER_ENABLE
|
||||
bool "Enable wrap panic handler"
|
||||
depends on BT_LE_CONTROLLER_LOG_ENABLED
|
||||
default n
|
||||
help
|
||||
Wrap esp_panic_handler to get controller logs when PC pointer exception crashes.
|
||||
|
||||
config BT_LE_CONTROLLER_LOG_TASK_WDT_USER_HANDLER_ENABLE
|
||||
bool "Enable esp_task_wdt_isr_user_handler implementation"
|
||||
depends on BT_LE_CONTROLLER_LOG_ENABLED
|
||||
default n
|
||||
help
|
||||
Implement esp_task_wdt_isr_user_handler to get controller logs when task wdt issue is triggered.
|
||||
|
||||
config BT_LE_CONTROLLER_LOG_OUTPUT_LEVEL
|
||||
int "The output level of controller log"
|
||||
depends on BT_LE_CONTROLLER_LOG_ENABLED
|
||||
range 0 5
|
||||
default 1
|
||||
help
|
||||
The output level of controller log.
|
||||
|
||||
config BT_LE_CONTROLLER_LOG_MOD_OUTPUT_SWITCH
|
||||
hex "The switch of module log output"
|
||||
depends on BT_LE_CONTROLLER_LOG_ENABLED
|
||||
range 0 0xFFFFFFFF
|
||||
default 0xFFFFFFFF
|
||||
help
|
||||
The switch of module log output, this is an unsigned 32-bit hexadecimal value.
|
||||
|
||||
config BT_LE_ERROR_SIM_ENABLED
|
||||
bool "Enable controller features for internal testing"
|
||||
default n
|
||||
|
||||
config BT_LE_ASSERT_WHEN_ABNORMAL_DISCONN_ENABLED
|
||||
bool "When ACL disconnects abnormally, assertion processing is performed(Experimental)"
|
||||
default n
|
||||
|
||||
config BT_LE_DEBUG_REMAIN_SCENE_ENABLED
|
||||
bool "Remain scene with GDB to capture relevant status info(Experimental)"
|
||||
default n
|
||||
help
|
||||
Retain scene with GDB to capture info, requires disabling WDT (CONFIG_ESP_INT_WDT, CONFIG_ESP_TASK_WDT_EN).
|
||||
|
||||
config BT_LE_PTR_CHECK_ENABLED
|
||||
bool "Enable boundary check for internal memory"
|
||||
default n
|
||||
endmenu
|
||||
|
||||
config BT_LE_LL_RESOLV_LIST_SIZE
|
||||
int "BLE LL Resolving list size"
|
||||
range 1 5
|
||||
@@ -498,7 +427,7 @@ config BT_LE_CRYPTO_STACK_MBEDTLS
|
||||
|
||||
config BT_LE_WHITELIST_SIZE
|
||||
int "BLE white list size"
|
||||
range 1 31
|
||||
range 1 15
|
||||
default 12
|
||||
depends on !BT_NIMBLE_ENABLED
|
||||
|
||||
@@ -519,23 +448,6 @@ config BT_LE_LL_SCA
|
||||
help
|
||||
Sleep clock accuracy of our device (in ppm)
|
||||
|
||||
config BT_LE_LL_PEER_SCA_SET_ENABLE
|
||||
bool "Enable to set constant peer SCA"
|
||||
default n
|
||||
help
|
||||
Enable setting of constant peer SCA, use this if peer device has SCA larger than 500 PPM.
|
||||
Enable this option, the controller will always use BT_LE_LL_PEER_SCA as the peer SCA value
|
||||
to calculate the window widening instead of the value received from peer device.
|
||||
|
||||
|
||||
config BT_LE_LL_PEER_SCA
|
||||
int "Constant peer sleep clock accuracy value"
|
||||
range 0 10000
|
||||
depends on BT_LE_LL_PEER_SCA_SET_ENABLE
|
||||
default 0
|
||||
help
|
||||
Set the sleep clock accuracy of peer device
|
||||
|
||||
config BT_LE_MAX_CONNECTIONS
|
||||
int "Maximum number of concurrent connections"
|
||||
depends on !BT_NIMBLE_ENABLED
|
||||
@@ -703,7 +615,7 @@ config BT_LE_SCAN_DUPL_CACHE_REFRESH_PERIOD
|
||||
again.
|
||||
|
||||
config BT_LE_MSYS_INIT_IN_CONTROLLER
|
||||
bool "Msys Mbuf Init in Controller"
|
||||
bool
|
||||
default y
|
||||
|
||||
config BT_LE_TX_CCA_ENABLED
|
||||
@@ -778,75 +690,3 @@ config BT_LE_DFT_TX_POWER_LEVEL_DBM_EFF
|
||||
default 18 if BT_LE_DFT_TX_POWER_LEVEL_P18
|
||||
default 20 if BT_LE_DFT_TX_POWER_LEVEL_P20
|
||||
default 0
|
||||
|
||||
config BT_LE_CTRL_CHECK_CONNECT_IND_ACCESS_ADDRESS
|
||||
bool "Enable enhanced Access Address check in CONNECT_IND"
|
||||
default n
|
||||
help
|
||||
Enabling this option will add stricter verification of the Access Address in the CONNECT_IND PDU.
|
||||
This improves security by ensuring that only connection requests with valid Access Addresses are accepted.
|
||||
If disabled, only basic checks are applied, improving compatibility.
|
||||
|
||||
config BT_CTRL_RUN_IN_FLASH_ONLY
|
||||
bool "Reduce BLE IRAM usage (READ DOCS FIRST) (EXPERIMENTAL)"
|
||||
default n
|
||||
help
|
||||
Move most IRAM into flash. This will increase the usage of flash and reduce ble performance.
|
||||
Because the code is moved to the flash, the execution speed of the code is reduced.
|
||||
To have a small impact on performance, you need to enable flash suspend (SPI_FLASH_AUTO_SUSPEND).
|
||||
|
||||
menu "BLE disconnects when Instant Passed (0x28) occurs"
|
||||
config BT_LE_CTRL_LLCP_CONN_UPDATE
|
||||
bool "BLE ACL connection update procedure"
|
||||
default n
|
||||
help
|
||||
If this option is enabled, Controller will terminate the connection
|
||||
when Instant Passed (0x28) error occurs during connection update procedure.
|
||||
|
||||
config BT_LE_CTRL_LLCP_CHAN_MAP_UPDATE
|
||||
bool "BLE ACL channel map update procedure"
|
||||
default n
|
||||
help
|
||||
If this option is enabled, Controller will terminate the connection
|
||||
when Instant Passed (0x28) error occurs in channel map update procedure.
|
||||
|
||||
config BT_LE_CTRL_LLCP_PHY_UPDATE
|
||||
bool "BLE ACL PHY update procedure"
|
||||
default n
|
||||
help
|
||||
If this option is enabled, Controller will terminate the connection
|
||||
when Instant Passed (0x28) error occurs in PHY update procedure.
|
||||
endmenu
|
||||
|
||||
config BT_CTRL_SCAN_BACKOFF_UPPERLIMITMAX
|
||||
int "The value of upperlimitmax during scan backoff procedure"
|
||||
range 1 256
|
||||
default 32
|
||||
help
|
||||
The value of upperlimitmax needs to be a power of 2.
|
||||
|
||||
config BT_LE_CTRL_CHAN_ASS_EN
|
||||
bool "Enable channel assessment(Experimental)"
|
||||
default n
|
||||
help
|
||||
If this option is enabled, The Controller will records the communication quality
|
||||
for each channel and then start a timer to check and update the channel map every 4 seconds.
|
||||
|
||||
config BT_LE_CTRL_ADV_DATA_LENGTH_ZERO_AUX
|
||||
bool "Enable aux packet when ext adv data length is zero(Experimental)"
|
||||
default y
|
||||
help
|
||||
When this option is enabled, auxiliary packets will be present in the events of
|
||||
'Non-Connectable and Non-Scannable' regardless of whether the advertising length is 0.
|
||||
If this option is not enabled, auxiliary packets will only be present when the advertising length is not 0.
|
||||
|
||||
config BT_LE_RXBUF_OPT_ENABLED
|
||||
bool "Enable rxbuf optimization feature"
|
||||
default y
|
||||
|
||||
config BT_LE_CTRL_FAST_CONN_DATA_TX_EN
|
||||
bool "Enable fast sending of connection data"
|
||||
default y
|
||||
help
|
||||
If this option is enabled, The Controller will continue to
|
||||
Send an empty PDU after sending valid connection data within an interval.
|
||||
|
||||
@@ -1,165 +0,0 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "sdkconfig.h"
|
||||
#include "esp_bt_cfg.h"
|
||||
#include "esp_bit_defs.h"
|
||||
|
||||
/* External functions or variables
|
||||
************************************************************************
|
||||
*/
|
||||
int base_stack_initEnv(void);
|
||||
void base_stack_deinitEnv(void);
|
||||
int base_stack_enable(void);
|
||||
void base_stack_disable(void);
|
||||
|
||||
int conn_stack_initEnv(void);
|
||||
void conn_stack_deinitEnv(void);
|
||||
int conn_stack_enable(void);
|
||||
void conn_stack_disable(void);
|
||||
|
||||
#if CONFIG_BT_LE_ERROR_SIM_ENABLED
|
||||
int conn_errorSim_initEnv(void);
|
||||
void conn_errorSim_deinitEnv(void);
|
||||
int conn_errorSim_enable(void);
|
||||
void conn_errorSim_disable(void);
|
||||
#endif // CONFIG_BT_LE_ERROR_SIM_ENABLED
|
||||
|
||||
#if (CONFIG_BT_NIMBLE_ENABLED || CONFIG_BT_BLUEDROID_ENABLED)
|
||||
void adv_stack_enableClearLegacyAdvVsCmd(bool en);
|
||||
void scan_stack_enableAdvFlowCtrlVsCmd(bool en);
|
||||
void advFilter_stack_enableDupExcListVsCmd(bool en);
|
||||
void arr_stack_enableMultiConnVsCmd(bool en);
|
||||
void pcl_stack_enableSetRssiThreshVsCmd(bool en);
|
||||
void chanSel_stack_enableSetCsaVsCmd(bool en);
|
||||
void log_stack_enableLogsRelatedVsCmd(bool en);
|
||||
void hci_stack_enableSetVsEvtMaskVsCmd(bool en);
|
||||
void winWiden_stack_enableSetConstPeerScaVsCmd(bool en);
|
||||
|
||||
void adv_stack_enableScanReqRxdVsEvent(bool en);
|
||||
void conn_stack_enableChanMapUpdCompVsEvent(bool en);
|
||||
void sleep_stack_enableWakeupVsEvent(bool en);
|
||||
#endif // (CONFIG_BT_NIMBLE_ENABLED || CONFIG_BT_BLUEDROID_ENABLED)
|
||||
#if CONFIG_BT_LE_RXBUF_OPT_ENABLED
|
||||
extern void mmgmt_enableRxbufOptFeature(void);
|
||||
#endif // CONFIG_BT_LE_RXBUF_OPT_ENABLED
|
||||
|
||||
/* Local functions definition
|
||||
***************************************************************************
|
||||
*/
|
||||
#if (CONFIG_BT_NIMBLE_ENABLED || CONFIG_BT_BLUEDROID_ENABLED)
|
||||
void ble_stack_enableVsCmds(bool en)
|
||||
{
|
||||
adv_stack_enableClearLegacyAdvVsCmd(en);
|
||||
advFilter_stack_enableDupExcListVsCmd(en);
|
||||
scan_stack_enableAdvFlowCtrlVsCmd(en);
|
||||
arr_stack_enableMultiConnVsCmd(en);
|
||||
pcl_stack_enableSetRssiThreshVsCmd(en);
|
||||
chanSel_stack_enableSetCsaVsCmd(en);
|
||||
log_stack_enableLogsRelatedVsCmd(en);
|
||||
hci_stack_enableSetVsEvtMaskVsCmd(en);
|
||||
winWiden_stack_enableSetConstPeerScaVsCmd(en);
|
||||
}
|
||||
|
||||
void ble_stack_enableVsEvents(bool en)
|
||||
{
|
||||
adv_stack_enableScanReqRxdVsEvent(en);
|
||||
conn_stack_enableChanMapUpdCompVsEvent(en);
|
||||
|
||||
#if CONFIG_BT_LE_SLEEP_ENABLE
|
||||
sleep_stack_enableWakeupVsEvent(en);
|
||||
#endif // CONFIG_BT_LE_SLEEP_ENABLE
|
||||
}
|
||||
#endif // (CONFIG_BT_NIMBLE_ENABLED || CONFIG_BT_BLUEDROID_ENABLED)
|
||||
|
||||
int ble_stack_initEnv(void)
|
||||
{
|
||||
int rc;
|
||||
|
||||
rc = base_stack_initEnv();
|
||||
if (rc) {
|
||||
return rc;
|
||||
}
|
||||
|
||||
#if DEFAULT_BT_LE_MAX_CONNECTIONS
|
||||
rc = conn_stack_initEnv();
|
||||
if (rc) {
|
||||
return rc;
|
||||
}
|
||||
#if CONFIG_BT_LE_ERROR_SIM_ENABLED
|
||||
rc = conn_errorSim_initEnv();
|
||||
if (rc) {
|
||||
return rc;
|
||||
}
|
||||
#endif // CONFIG_BT_LE_ERROR_SIM_ENABLED
|
||||
#endif // DEFAULT_BT_LE_MAX_CONNECTIONS
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void ble_stack_deinitEnv(void)
|
||||
{
|
||||
#if DEFAULT_BT_LE_MAX_CONNECTIONS
|
||||
#if CONFIG_BT_LE_ERROR_SIM_ENABLED
|
||||
conn_errorSim_deinitEnv();
|
||||
#endif // CONFIG_BT_LE_ERROR_SIM_ENABLED
|
||||
conn_stack_deinitEnv();
|
||||
#endif // DEFAULT_BT_LE_MAX_CONNECTIONS
|
||||
|
||||
base_stack_deinitEnv();
|
||||
}
|
||||
|
||||
int ble_stack_enable(void)
|
||||
{
|
||||
int rc;
|
||||
|
||||
rc = base_stack_enable();
|
||||
if (rc) {
|
||||
return rc;
|
||||
}
|
||||
|
||||
#if DEFAULT_BT_LE_MAX_CONNECTIONS
|
||||
rc = conn_stack_enable();
|
||||
if (rc) {
|
||||
return rc;
|
||||
}
|
||||
#if CONFIG_BT_LE_ERROR_SIM_ENABLED
|
||||
rc = conn_errorSim_enable();
|
||||
if (rc) {
|
||||
return rc;
|
||||
}
|
||||
#endif // CONFIG_BT_LE_ERROR_SIM_ENABLED
|
||||
#endif // DEFAULT_BT_LE_MAX_CONNECTIONS
|
||||
|
||||
#if (CONFIG_BT_NIMBLE_ENABLED || CONFIG_BT_BLUEDROID_ENABLED)
|
||||
ble_stack_enableVsCmds(true);
|
||||
ble_stack_enableVsEvents(true);
|
||||
#endif // (CONFIG_BT_NIMBLE_ENABLED || CONFIG_BT_BLUEDROID_ENABLED)
|
||||
|
||||
#if CONFIG_BT_LE_RXBUF_OPT_ENABLED
|
||||
mmgmt_enableRxbufOptFeature();
|
||||
#endif // CONFIG_BT_LE_RXBUF_OPT_ENABLED
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void ble_stack_disable(void)
|
||||
{
|
||||
#if (CONFIG_BT_NIMBLE_ENABLED || CONFIG_BT_BLUEDROID_ENABLED)
|
||||
ble_stack_enableVsEvents(false);
|
||||
ble_stack_enableVsCmds(false);
|
||||
#endif // (CONFIG_BT_NIMBLE_ENABLED || CONFIG_BT_BLUEDROID_ENABLED)
|
||||
|
||||
#if DEFAULT_BT_LE_MAX_CONNECTIONS
|
||||
#if CONFIG_BT_LE_ERROR_SIM_ENABLED
|
||||
conn_errorSim_disable();
|
||||
#endif // CONFIG_BT_LE_ERROR_SIM_ENABLED
|
||||
conn_stack_disable();
|
||||
#endif // DEFAULT_BT_LE_MAX_CONNECTIONS
|
||||
|
||||
base_stack_disable();
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
int ble_stack_initEnv(void);
|
||||
|
||||
void ble_stack_deinitEnv(void);
|
||||
|
||||
int ble_stack_enable(void);
|
||||
|
||||
void ble_stack_disable(void);
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -34,7 +34,6 @@
|
||||
#include "os/endian.h"
|
||||
|
||||
#include "esp_bt.h"
|
||||
#include "ble_priv.h"
|
||||
#include "esp_intr_alloc.h"
|
||||
#include "esp_sleep.h"
|
||||
#include "esp_pm.h"
|
||||
@@ -51,14 +50,8 @@
|
||||
#include "freertos/task.h"
|
||||
|
||||
#include "esp_private/periph_ctrl.h"
|
||||
#include "esp_private/esp_clk_tree_common.h"
|
||||
#include "esp_sleep.h"
|
||||
#include "soc/rtc.h"
|
||||
|
||||
#if CONFIG_BT_BLE_LOG_SPI_OUT_ENABLED
|
||||
#include "ble_log/ble_log_spi_out.h"
|
||||
#endif // CONFIG_BT_BLE_LOG_SPI_OUT_ENABLED
|
||||
|
||||
/* Macro definition
|
||||
************************************************************************
|
||||
*/
|
||||
@@ -66,7 +59,7 @@
|
||||
#define OSI_COEX_VERSION 0x00010006
|
||||
#define OSI_COEX_MAGIC_VALUE 0xFADEBEAD
|
||||
|
||||
#define EXT_FUNC_VERSION 0x20250415
|
||||
#define EXT_FUNC_VERSION 0x20240422
|
||||
#define EXT_FUNC_MAGIC_VALUE 0xA5A5A5A5
|
||||
|
||||
#define BT_ASSERT_PRINT ets_printf
|
||||
@@ -97,33 +90,24 @@ struct ext_funcs_t {
|
||||
int (* _ecc_gen_key_pair)(uint8_t *public, uint8_t *priv);
|
||||
int (* _ecc_gen_dh_key)(const uint8_t *remote_pub_key_x, const uint8_t *remote_pub_key_y,
|
||||
const uint8_t *local_priv_key, uint8_t *dhkey);
|
||||
void (* _esp_reset_rpa_moudle)(void);
|
||||
uint32_t magic;
|
||||
};
|
||||
|
||||
#if CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
|
||||
typedef void (*interface_func_t) (uint32_t len, const uint8_t *addr, uint32_t len_append, const uint8_t *addr_append, uint32_t flag);
|
||||
|
||||
enum {
|
||||
BLE_LOG_INTERFACE_FLAG_CONTINUE = 0,
|
||||
BLE_LOG_INTERFACE_FLAG_END,
|
||||
};
|
||||
typedef void (*interface_func_t) (uint32_t len, const uint8_t*addr, bool end);
|
||||
#endif // CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
|
||||
/* External functions or variables
|
||||
************************************************************************
|
||||
*/
|
||||
extern int ble_osi_coex_funcs_register(struct osi_coex_funcs_t *coex_funcs);
|
||||
extern int r_ble_controller_init(esp_bt_controller_config_t *cfg);
|
||||
extern void esp_ble_controller_info_capture(uint32_t cycle_times);
|
||||
#if CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
|
||||
extern int r_ble_log_init_async(interface_func_t interface, bool task_create, uint8_t buffers, uint32_t *bufs_size);
|
||||
extern int r_ble_log_init_async(interface_func_t bt_controller_log_interface, bool task_create, uint8_t buffers, uint32_t *bufs_size);
|
||||
extern int r_ble_log_deinit_async(void);
|
||||
extern int r_ble_log_init_simple(interface_func_t interface, void *handler);
|
||||
extern void r_ble_log_deinit_simple(void);
|
||||
extern void r_ble_log_async_select_dump_buffers(uint8_t buffers);
|
||||
extern void r_ble_log_async_output_dump_all(bool output);
|
||||
extern void esp_panic_handler_feed_wdts(void);
|
||||
extern int r_ble_log_ctrl_level_and_mod(uint8_t log_level, uint32_t mod_switch);
|
||||
extern int r_ble_ctrl_mod_type(uint16_t mod, uint32_t mod_type_switch);
|
||||
extern void esp_panic_handler_reconfigure_wdts(uint32_t timeout_ms);
|
||||
#endif // CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
|
||||
extern int r_ble_controller_deinit(void);
|
||||
extern int r_ble_controller_enable(uint8_t mode);
|
||||
@@ -141,10 +125,6 @@ extern void r_ble_lll_rfmgmt_set_sleep_cb(void *s_cb, void *w_cb, void *s_arg,
|
||||
extern void r_ble_rtc_wake_up_state_clr(void);
|
||||
extern int os_msys_init(void);
|
||||
extern void os_msys_deinit(void);
|
||||
#if CONFIG_BT_CTRL_RUN_IN_FLASH_ONLY
|
||||
extern void r_ble_ll_scan_start_time_init_compensation(uint32_t init_compensation);
|
||||
extern void r_priv_sdk_config_insert_proc_time_set(uint16_t insert_proc_time);
|
||||
#endif // CONFIG_BT_CTRL_RUN_IN_FLASH_ONLY
|
||||
#if CONFIG_FREERTOS_USE_TICKLESS_IDLE
|
||||
extern sleep_retention_entries_config_t *r_esp_ble_mac_retention_link_get(uint8_t *size, uint8_t extra);
|
||||
extern void r_esp_ble_set_wakeup_overhead(uint32_t overhead);
|
||||
@@ -152,9 +132,7 @@ extern void r_esp_ble_set_wakeup_overhead(uint32_t overhead);
|
||||
#if CONFIG_PM_ENABLE
|
||||
extern void r_esp_ble_stop_wakeup_timing(void);
|
||||
#endif // CONFIG_PM_ENABLE
|
||||
#if CONFIG_BT_LE_LL_PEER_SCA_SET_ENABLE
|
||||
extern void r_ble_ll_customize_peer_sca_set(uint16_t peer_sca);
|
||||
#endif // CONFIG_BT_LE_LL_PEER_SCA_SET_ENABLE
|
||||
extern void r_esp_ble_change_rtc_freq(uint32_t freq);
|
||||
extern int ble_sm_alg_gen_dhkey(const uint8_t *peer_pub_key_x,
|
||||
const uint8_t *peer_pub_key_y,
|
||||
const uint8_t *our_priv_key, uint8_t *out_dhkey);
|
||||
@@ -187,45 +165,62 @@ static int esp_intr_alloc_wrapper(int source, int flags, intr_handler_t handler,
|
||||
static int esp_intr_free_wrapper(void **ret_handle);
|
||||
static void osi_assert_wrapper(const uint32_t ln, const char *fn, uint32_t param1, uint32_t param2);
|
||||
static uint32_t osi_random_wrapper(void);
|
||||
static void esp_reset_rpa_moudle(void);
|
||||
static int esp_ecc_gen_key_pair(uint8_t *pub, uint8_t *priv);
|
||||
static int esp_ecc_gen_dh_key(const uint8_t *peer_pub_key_x, const uint8_t *peer_pub_key_y,
|
||||
const uint8_t *our_priv_key, uint8_t *out_dhkey);
|
||||
#if CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
|
||||
#if !CONFIG_BT_LE_CONTROLLER_LOG_SPI_OUT_ENABLED
|
||||
static void esp_bt_controller_log_interface(uint32_t len, const uint8_t *addr, uint32_t len_append, const uint8_t *addr_append, uint32_t flag);
|
||||
#endif // !CONFIG_BT_LE_CONTROLLER_LOG_SPI_OUT_ENABLED
|
||||
static void esp_bt_controller_log_interface(uint32_t len, const uint8_t *addr, bool end);
|
||||
#if CONFIG_BT_LE_CONTROLLER_LOG_STORAGE_ENABLE
|
||||
static void esp_bt_ctrl_log_partition_get_and_erase_first_block(void);
|
||||
#endif // CONFIG_BT_LE_CONTROLLER_LOG_STORAGE_ENABLE
|
||||
#endif // #if CONFIG_BT_LE_CONTROLLER_LOG_STORAGE_ENABLE
|
||||
#endif // CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
|
||||
/* Local variable definition
|
||||
***************************************************************************
|
||||
*/
|
||||
/* Static variable declare */
|
||||
static DRAM_ATTR esp_bt_controller_status_t ble_controller_status = ESP_BT_CONTROLLER_STATUS_IDLE;
|
||||
|
||||
#if CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
|
||||
const static uint32_t log_bufs_size[] = {CONFIG_BT_LE_LOG_CTRL_BUF1_SIZE, CONFIG_BT_LE_LOG_HCI_BUF_SIZE, CONFIG_BT_LE_LOG_CTRL_BUF2_SIZE};
|
||||
static bool log_is_inited = false;
|
||||
enum log_out_mode {
|
||||
LOG_DUMP_MEMORY,
|
||||
LOG_ASYNC_OUT,
|
||||
LOG_STORAGE_TO_FLASH,
|
||||
};
|
||||
|
||||
esp_err_t esp_bt_controller_log_init(void)
|
||||
bool log_is_inited = false;
|
||||
#if CONFIG_BT_LE_CONTROLLER_LOG_DUMP_ONLY
|
||||
uint8_t log_output_mode = LOG_DUMP_MEMORY;
|
||||
#else
|
||||
#if CONFIG_BT_LE_CONTROLLER_LOG_STORAGE_ENABLE
|
||||
uint8_t log_output_mode = LOG_STORAGE_TO_FLASH;
|
||||
#else
|
||||
uint8_t log_output_mode = LOG_ASYNC_OUT;
|
||||
#endif // CONFIG_BT_LE_CONTROLLER_LOG_STORAGE_ENABLE
|
||||
#endif // CONFIG_BT_LE_CONTROLLER_LOG_DUMP_ONLY
|
||||
|
||||
void esp_bt_log_output_mode_set(uint8_t output_mode)
|
||||
{
|
||||
if (log_is_inited) {
|
||||
return ESP_OK;
|
||||
}
|
||||
log_output_mode = output_mode;
|
||||
}
|
||||
|
||||
#if CONFIG_BT_BLE_LOG_SPI_OUT_ENABLED
|
||||
if (ble_log_spi_out_init() != 0) {
|
||||
goto spi_out_init_failed;
|
||||
}
|
||||
#endif // CONFIG_BT_BLE_LOG_SPI_OUT_ENABLED
|
||||
uint8_t esp_bt_log_output_mode_get(void)
|
||||
{
|
||||
return log_output_mode;
|
||||
}
|
||||
|
||||
#if CONFIG_BT_LE_CONTROLLER_LOG_SPI_OUT_ENABLED
|
||||
if (r_ble_log_init_simple(ble_log_spi_out_ll_write, ble_log_spi_out_ll_log_ev_proc) != 0) {
|
||||
goto log_init_failed;
|
||||
}
|
||||
#else // !CONFIG_BT_LE_CONTROLLER_LOG_SPI_OUT_ENABLED
|
||||
esp_err_t esp_bt_controller_log_init(uint8_t log_output_mode)
|
||||
{
|
||||
esp_err_t ret = ESP_OK;
|
||||
interface_func_t bt_controller_log_interface;
|
||||
bt_controller_log_interface = esp_bt_controller_log_interface;
|
||||
bool task_create;
|
||||
uint8_t buffers = 0;
|
||||
|
||||
if (log_is_inited) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
#if CONFIG_BT_LE_CONTROLLER_LOG_CTRL_ENABLED
|
||||
buffers |= ESP_BLE_LOG_BUF_CONTROLLER;
|
||||
#endif // CONFIG_BT_LE_CONTROLLER_LOG_CTRL_ENABLED
|
||||
@@ -233,50 +228,33 @@ esp_err_t esp_bt_controller_log_init(void)
|
||||
buffers |= ESP_BLE_LOG_BUF_HCI;
|
||||
#endif // CONFIG_BT_LE_CONTROLLER_LOG_HCI_ENABLED
|
||||
|
||||
bool task_create = true;
|
||||
#if CONFIG_BT_LE_CONTROLLER_LOG_DUMP_ONLY
|
||||
task_create = false;
|
||||
#elif CONFIG_BT_LE_CONTROLLER_LOG_STORAGE_ENABLE
|
||||
esp_bt_ctrl_log_partition_get_and_erase_first_block();
|
||||
#endif // CONFIG_BT_LE_CONTROLLER_LOG_SPI_OUT_ENABLED
|
||||
|
||||
if (r_ble_log_init_async(esp_bt_controller_log_interface, task_create, buffers, (uint32_t *)log_bufs_size) != 0) {
|
||||
goto log_init_failed;
|
||||
switch (log_output_mode) {
|
||||
case LOG_DUMP_MEMORY:
|
||||
task_create = false;
|
||||
break;
|
||||
case LOG_ASYNC_OUT:
|
||||
case LOG_STORAGE_TO_FLASH:
|
||||
task_create = true;
|
||||
#if CONFIG_BT_LE_CONTROLLER_LOG_STORAGE_ENABLE
|
||||
if (log_output_mode == LOG_STORAGE_TO_FLASH) {
|
||||
esp_bt_ctrl_log_partition_get_and_erase_first_block();
|
||||
}
|
||||
#endif // CONFIG_BT_LE_CONTROLLER_LOG_STORAGE_ENABLE
|
||||
break;
|
||||
default:
|
||||
assert(0);
|
||||
}
|
||||
#endif // CONFIG_BT_LE_CONTROLLER_LOG_SPI_OUT_ENABLED
|
||||
|
||||
if (r_ble_log_ctrl_level_and_mod(CONFIG_BT_LE_CONTROLLER_LOG_OUTPUT_LEVEL, CONFIG_BT_LE_CONTROLLER_LOG_MOD_OUTPUT_SWITCH) != ESP_OK) {
|
||||
goto ctrl_level_init_failed;
|
||||
ret = r_ble_log_init_async(bt_controller_log_interface, task_create, buffers, (uint32_t *)log_bufs_size);
|
||||
if (ret == ESP_OK) {
|
||||
log_is_inited = true;
|
||||
}
|
||||
log_is_inited = true;
|
||||
return ESP_OK;
|
||||
|
||||
ctrl_level_init_failed:
|
||||
#if CONFIG_BT_LE_CONTROLLER_LOG_SPI_OUT_ENABLED
|
||||
r_ble_log_deinit_simple();
|
||||
#else // !CONFIG_BT_LE_CONTROLLER_LOG_SPI_OUT_ENABLED
|
||||
r_ble_log_deinit_async();
|
||||
#endif // CONFIG_BT_LE_CONTROLLER_LOG_SPI_OUT_ENABLED
|
||||
log_init_failed:
|
||||
#if CONFIG_BT_BLE_LOG_SPI_OUT_ENABLED
|
||||
ble_log_spi_out_deinit();
|
||||
spi_out_init_failed:
|
||||
#endif // CONFIG_BT_BLE_LOG_SPI_OUT_ENABLED
|
||||
return ESP_FAIL;
|
||||
return ret;
|
||||
}
|
||||
|
||||
void esp_bt_controller_log_deinit(void)
|
||||
void esp_bt_ontroller_log_deinit(void)
|
||||
{
|
||||
#if CONFIG_BT_BLE_LOG_SPI_OUT_ENABLED
|
||||
ble_log_spi_out_deinit();
|
||||
#endif // CONFIG_BT_BLE_LOG_SPI_OUT_ENABLED
|
||||
|
||||
#if CONFIG_BT_LE_CONTROLLER_LOG_SPI_OUT_ENABLED
|
||||
r_ble_log_deinit_simple();
|
||||
#else // !CONFIG_BT_LE_CONTROLLER_LOG_SPI_OUT_ENABLED
|
||||
r_ble_log_deinit_async();
|
||||
#endif // CONFIG_BT_LE_CONTROLLER_LOG_SPI_OUT_ENABLED
|
||||
|
||||
log_is_inited = false;
|
||||
}
|
||||
|
||||
@@ -368,13 +346,13 @@ void esp_bt_read_ctrl_log_from_flash(bool output)
|
||||
|
||||
portMUX_TYPE spinlock = portMUX_INITIALIZER_UNLOCKED;
|
||||
portENTER_CRITICAL_SAFE(&spinlock);
|
||||
esp_panic_handler_feed_wdts();
|
||||
esp_panic_handler_reconfigure_wdts(5000);
|
||||
r_ble_log_async_output_dump_all(true);
|
||||
esp_bt_controller_log_deinit();
|
||||
esp_bt_ontroller_log_deinit();
|
||||
stop_write = true;
|
||||
|
||||
buffer = (const uint8_t *)mapped_ptr;
|
||||
esp_panic_handler_feed_wdts();
|
||||
esp_panic_handler_reconfigure_wdts(5000);
|
||||
if (is_filled) {
|
||||
read_index = next_erase_index;
|
||||
} else {
|
||||
@@ -386,7 +364,7 @@ void esp_bt_read_ctrl_log_from_flash(bool output)
|
||||
while (read_index != write_index) {
|
||||
esp_rom_printf("%02x ", buffer[read_index]);
|
||||
if (print_len > max_print_len) {
|
||||
esp_panic_handler_feed_wdts();
|
||||
esp_panic_handler_reconfigure_wdts(5000);
|
||||
print_len = 0;
|
||||
}
|
||||
|
||||
@@ -397,26 +375,10 @@ void esp_bt_read_ctrl_log_from_flash(bool output)
|
||||
esp_rom_printf(":DUMP_END]\r\n");
|
||||
portEXIT_CRITICAL_SAFE(&spinlock);
|
||||
esp_partition_munmap(mmap_handle);
|
||||
err = esp_bt_controller_log_init();
|
||||
err = esp_bt_controller_log_init(log_output_mode);
|
||||
assert(err == ESP_OK);
|
||||
}
|
||||
#endif // CONFIG_BT_LE_CONTROLLER_LOG_STORAGE_ENABLE
|
||||
|
||||
#if CONFIG_BT_LE_CONTROLLER_LOG_TASK_WDT_USER_HANDLER_ENABLE
|
||||
void esp_task_wdt_isr_user_handler(void)
|
||||
{
|
||||
esp_ble_controller_log_dump_all(true);
|
||||
}
|
||||
#endif // CONFIG_BT_LE_CONTROLLER_LOG_TASK_WDT_USER_HANDLER_ENABLE
|
||||
|
||||
#if CONFIG_BT_LE_CONTROLLER_LOG_WRAP_PANIC_HANDLER_ENABLE
|
||||
void __real_esp_panic_handler(void *info);
|
||||
void __wrap_esp_panic_handler (void *info)
|
||||
{
|
||||
esp_ble_controller_log_dump_all(true);
|
||||
__real_esp_panic_handler(info);
|
||||
}
|
||||
#endif // CONFIG_BT_LE_CONTROLLER_LOG_WRAP_PANIC_HANDLER_ENABLE
|
||||
#endif // CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
|
||||
|
||||
/* This variable tells if BLE is running */
|
||||
@@ -424,20 +386,7 @@ static bool s_ble_active = false;
|
||||
#ifdef CONFIG_PM_ENABLE
|
||||
static DRAM_ATTR esp_pm_lock_handle_t s_pm_lock = NULL;
|
||||
#endif // CONFIG_PM_ENABLE
|
||||
#define MAIN_XTAL_FREQ_HZ (32000000)
|
||||
static DRAM_ATTR modem_clock_lpclk_src_t s_bt_lpclk_src = MODEM_CLOCK_LPCLK_SRC_INVALID;
|
||||
static DRAM_ATTR uint32_t s_bt_lpclk_freq = 100000;
|
||||
|
||||
#define BLE_CONTROLLER_MALLOC_CAPS (MALLOC_CAP_INTERNAL|MALLOC_CAP_8BIT|MALLOC_CAP_DMA)
|
||||
void *malloc_ble_controller_mem(size_t size)
|
||||
{
|
||||
return heap_caps_malloc(size, BLE_CONTROLLER_MALLOC_CAPS);
|
||||
}
|
||||
|
||||
uint32_t get_ble_controller_free_heap_size(void)
|
||||
{
|
||||
return heap_caps_get_free_size(BLE_CONTROLLER_MALLOC_CAPS);
|
||||
}
|
||||
|
||||
#define BLE_RTC_DELAY_US_LIGHT_SLEEP (5100)
|
||||
#define BLE_RTC_DELAY_US_MODEM_SLEEP (1500)
|
||||
@@ -463,9 +412,15 @@ struct ext_funcs_t ext_funcs_ro = {
|
||||
._os_random = osi_random_wrapper,
|
||||
._ecc_gen_key_pair = esp_ecc_gen_key_pair,
|
||||
._ecc_gen_dh_key = esp_ecc_gen_dh_key,
|
||||
._esp_reset_rpa_moudle = esp_reset_rpa_moudle,
|
||||
.magic = EXT_FUNC_MAGIC_VALUE,
|
||||
};
|
||||
|
||||
static void IRAM_ATTR esp_reset_rpa_moudle(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
static void IRAM_ATTR osi_assert_wrapper(const uint32_t ln, const char *fn,
|
||||
uint32_t param1, uint32_t param2)
|
||||
{
|
||||
@@ -529,11 +484,8 @@ static int esp_ecc_gen_dh_key(const uint8_t *peer_pub_key_x, const uint8_t *peer
|
||||
static int esp_intr_alloc_wrapper(int source, int flags, intr_handler_t handler,
|
||||
void *arg, void **ret_handle_in)
|
||||
{
|
||||
#if CONFIG_BT_CTRL_RUN_IN_FLASH_ONLY
|
||||
int rc = esp_intr_alloc(source, flags, handler, arg, (intr_handle_t *)ret_handle_in);
|
||||
#else
|
||||
int rc = esp_intr_alloc(source, flags | ESP_INTR_FLAG_IRAM, handler, arg, (intr_handle_t *)ret_handle_in);
|
||||
#endif
|
||||
int rc = esp_intr_alloc(source, flags | ESP_INTR_FLAG_IRAM, handler,
|
||||
arg, (intr_handle_t *)ret_handle_in);
|
||||
return rc;
|
||||
}
|
||||
|
||||
@@ -551,10 +503,10 @@ void esp_bt_rtc_slow_clk_select(uint8_t slow_clk_src)
|
||||
switch (slow_clk_src) {
|
||||
case MODEM_CLOCK_LPCLK_SRC_MAIN_XTAL:
|
||||
ESP_LOGI(NIMBLE_PORT_LOG_TAG, "Using main XTAL as clock source");
|
||||
modem_clock_select_lp_clock_source(PERIPH_BT_MODULE, slow_clk_src, (MAIN_XTAL_FREQ_HZ/s_bt_lpclk_freq - 1));
|
||||
modem_clock_select_lp_clock_source(PERIPH_BT_MODULE, slow_clk_src, (320 - 1));
|
||||
break;
|
||||
case MODEM_CLOCK_LPCLK_SRC_RC_SLOW:
|
||||
ESP_LOGW(NIMBLE_PORT_LOG_TAG, "Using 136 kHz RC as clock source, use with caution as it may not maintain ACL or Sync process due to low clock accuracy!");
|
||||
ESP_LOGI(NIMBLE_PORT_LOG_TAG, "Using 136 kHz RC as clock source, can only run legacy ADV or SCAN due to low clock accuracy!");
|
||||
modem_clock_select_lp_clock_source(PERIPH_BT_MODULE, slow_clk_src, (5 - 1));
|
||||
break;
|
||||
case MODEM_CLOCK_LPCLK_SRC_XTAL32K:
|
||||
@@ -580,10 +532,6 @@ modem_clock_lpclk_src_t esp_bt_get_lpclk_src(void)
|
||||
|
||||
void esp_bt_set_lpclk_src(modem_clock_lpclk_src_t clk_src)
|
||||
{
|
||||
if (ble_controller_status != ESP_BT_CONTROLLER_STATUS_IDLE) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (clk_src >= MODEM_CLOCK_LPCLK_SRC_MAX) {
|
||||
return;
|
||||
}
|
||||
@@ -591,28 +539,6 @@ void esp_bt_set_lpclk_src(modem_clock_lpclk_src_t clk_src)
|
||||
s_bt_lpclk_src = clk_src;
|
||||
}
|
||||
|
||||
uint32_t esp_bt_get_lpclk_freq(void)
|
||||
{
|
||||
return s_bt_lpclk_freq;
|
||||
}
|
||||
|
||||
void esp_bt_set_lpclk_freq(uint32_t clk_freq)
|
||||
{
|
||||
if (ble_controller_status != ESP_BT_CONTROLLER_STATUS_IDLE) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!clk_freq) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (MAIN_XTAL_FREQ_HZ % clk_freq) {
|
||||
return;
|
||||
}
|
||||
|
||||
s_bt_lpclk_freq = clk_freq;
|
||||
}
|
||||
|
||||
IRAM_ATTR void controller_sleep_cb(uint32_t enable_tick, void *arg)
|
||||
{
|
||||
if (!s_ble_active) {
|
||||
@@ -634,17 +560,10 @@ IRAM_ATTR void controller_wakeup_cb(void *arg)
|
||||
return;
|
||||
}
|
||||
#ifdef CONFIG_PM_ENABLE
|
||||
esp_pm_config_t pm_config;
|
||||
esp_pm_lock_acquire(s_pm_lock);
|
||||
esp_pm_get_configuration(&pm_config);
|
||||
assert(esp_rom_get_cpu_ticks_per_us() == pm_config.max_freq_mhz);
|
||||
r_ble_rtc_wake_up_state_clr();
|
||||
#endif //CONFIG_PM_ENABLE
|
||||
esp_phy_enable(PHY_MODEM_BT);
|
||||
if (s_bt_lpclk_src == MODEM_CLOCK_LPCLK_SRC_RC_SLOW) {
|
||||
uint32_t *clk_freq = (uint32_t *)arg;
|
||||
*clk_freq = esp_clk_tree_lp_slow_get_freq_hz(ESP_CLK_TREE_SRC_FREQ_PRECISION_CACHED) / 5;
|
||||
}
|
||||
s_ble_active = true;
|
||||
}
|
||||
|
||||
@@ -666,7 +585,7 @@ static esp_err_t sleep_modem_ble_mac_modem_state_init(uint8_t extra)
|
||||
int retention_args = extra;
|
||||
sleep_retention_module_init_param_t init_param = {
|
||||
.cbs = { .create = { .handle = sleep_modem_ble_mac_retention_init, .arg = &retention_args } },
|
||||
.depends = RETENTION_MODULE_BITMAP_INIT(BT_BB)
|
||||
.depends = BIT(SLEEP_RETENTION_MODULE_BT_BB)
|
||||
};
|
||||
esp_err_t err = sleep_retention_module_init(SLEEP_RETENTION_MODULE_BLE_MAC, &init_param);
|
||||
if (err == ESP_OK) {
|
||||
@@ -865,12 +784,11 @@ static void ble_rtc_clk_init(esp_bt_controller_config_t *cfg)
|
||||
}
|
||||
|
||||
if (s_bt_lpclk_src == MODEM_CLOCK_LPCLK_SRC_MAIN_XTAL) {
|
||||
cfg->rtc_freq = s_bt_lpclk_freq;
|
||||
cfg->rtc_freq = 100000;
|
||||
} else if (s_bt_lpclk_src == MODEM_CLOCK_LPCLK_SRC_XTAL32K) {
|
||||
cfg->rtc_freq = 32768;
|
||||
} else if (s_bt_lpclk_src == MODEM_CLOCK_LPCLK_SRC_RC_SLOW) {
|
||||
cfg->rtc_freq = esp_clk_tree_lp_slow_get_freq_hz(ESP_CLK_TREE_SRC_FREQ_PRECISION_CACHED) / 5;
|
||||
cfg->ble_ll_sca = 3000;
|
||||
cfg->rtc_freq = 30000;
|
||||
} else if (s_bt_lpclk_src == MODEM_CLOCK_LPCLK_SRC_RC32K) {
|
||||
cfg->rtc_freq = 32000;
|
||||
} else if (s_bt_lpclk_src == MODEM_CLOCK_LPCLK_SRC_EXT32K) {
|
||||
@@ -948,7 +866,7 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg)
|
||||
#endif // CONFIG_SW_COEXIST_ENABLE
|
||||
|
||||
#if CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
|
||||
ret = esp_bt_controller_log_init();
|
||||
ret = esp_bt_controller_log_init(log_output_mode);
|
||||
if (ret != ESP_OK) {
|
||||
ESP_LOGW(NIMBLE_PORT_LOG_TAG, "ble_controller_log_init failed %d", ret);
|
||||
goto modem_deint;
|
||||
@@ -960,23 +878,13 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg)
|
||||
goto modem_deint;
|
||||
}
|
||||
|
||||
ESP_LOGI(NIMBLE_PORT_LOG_TAG, "ble controller commit:[%s]", ble_controller_get_compile_version());
|
||||
|
||||
ret = r_ble_controller_init(cfg);
|
||||
if (ret != ESP_OK) {
|
||||
ESP_LOGW(NIMBLE_PORT_LOG_TAG, "r_ble_controller_init failed %d", ret);
|
||||
goto modem_deint;
|
||||
}
|
||||
|
||||
#if CONFIG_BT_LE_LL_PEER_SCA_SET_ENABLE
|
||||
r_ble_ll_customize_peer_sca_set(CONFIG_BT_LE_LL_PEER_SCA);
|
||||
#endif // CONFIG_BT_LE_LL_PEER_SCA_SET_ENABLE
|
||||
|
||||
ret = ble_stack_initEnv();
|
||||
if (ret != ESP_OK) {
|
||||
ESP_LOGW(NIMBLE_PORT_LOG_TAG, "ble_stack_initEnv failed %d", ret);
|
||||
goto free_controller;
|
||||
}
|
||||
ESP_LOGI(NIMBLE_PORT_LOG_TAG, "ble controller commit:[%s]", ble_controller_get_compile_version());
|
||||
|
||||
ble_controller_scan_duplicate_config();
|
||||
|
||||
@@ -991,7 +899,6 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg)
|
||||
ESP_LOGW(NIMBLE_PORT_LOG_TAG, "controller_sleep_init failed %d", ret);
|
||||
goto free_controller;
|
||||
}
|
||||
|
||||
ESP_ERROR_CHECK(esp_read_mac((uint8_t *)mac, ESP_MAC_BT));
|
||||
ESP_LOGI(NIMBLE_PORT_LOG_TAG, "Bluetooth MAC: %02x:%02x:%02x:%02x:%02x:%02x",
|
||||
mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
|
||||
@@ -1019,12 +926,11 @@ free_controller:
|
||||
hci_transport_deinit();
|
||||
controller_sleep_deinit();
|
||||
os_msys_deinit();
|
||||
ble_stack_deinitEnv();
|
||||
r_ble_controller_deinit();
|
||||
modem_deint:
|
||||
esp_ble_unregister_bb_funcs();
|
||||
#if CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
|
||||
esp_bt_controller_log_deinit();
|
||||
esp_bt_ontroller_log_deinit();
|
||||
#endif // CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
|
||||
modem_clock_deselect_lp_clock_source(PERIPH_BT_MODULE);
|
||||
modem_clock_module_disable(PERIPH_BT_MODULE);
|
||||
@@ -1055,11 +961,10 @@ esp_err_t esp_bt_controller_deinit(void)
|
||||
modem_clock_deselect_lp_clock_source(PERIPH_BT_MODULE);
|
||||
modem_clock_module_disable(PERIPH_BT_MODULE);
|
||||
|
||||
ble_stack_deinitEnv();
|
||||
r_ble_controller_deinit();
|
||||
esp_ble_unregister_bb_funcs();
|
||||
#if CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
|
||||
esp_bt_controller_log_deinit();
|
||||
esp_bt_ontroller_log_deinit();
|
||||
#endif // CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
|
||||
|
||||
#if CONFIG_BT_NIMBLE_ENABLED
|
||||
@@ -1105,16 +1010,6 @@ esp_err_t esp_bt_controller_enable(esp_bt_mode_t mode)
|
||||
coex_enable();
|
||||
#endif // CONFIG_SW_COEXIST_ENABLE
|
||||
|
||||
#if CONFIG_BT_CTRL_RUN_IN_FLASH_ONLY
|
||||
r_ble_ll_scan_start_time_init_compensation(500);
|
||||
r_priv_sdk_config_insert_proc_time_set(500);
|
||||
#endif // CONFIG_BT_CTRL_RUN_IN_FLASH_ONLY
|
||||
|
||||
if (ble_stack_enable() != 0) {
|
||||
ret = ESP_FAIL;
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (r_ble_controller_enable(mode) != 0) {
|
||||
ret = ESP_FAIL;
|
||||
goto error;
|
||||
@@ -1123,7 +1018,6 @@ esp_err_t esp_bt_controller_enable(esp_bt_mode_t mode)
|
||||
return ESP_OK;
|
||||
|
||||
error:
|
||||
ble_stack_disable();
|
||||
#if CONFIG_SW_COEXIST_ENABLE
|
||||
coex_disable();
|
||||
#endif
|
||||
@@ -1147,7 +1041,6 @@ esp_err_t esp_bt_controller_disable(void)
|
||||
if (r_ble_controller_disable() != 0) {
|
||||
return ESP_FAIL;
|
||||
}
|
||||
ble_stack_disable();
|
||||
#if CONFIG_SW_COEXIST_ENABLE
|
||||
coex_disable();
|
||||
#endif
|
||||
@@ -1265,6 +1158,7 @@ esp_err_t esp_bt_mem_release(esp_bt_mode_t mode)
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
esp_bt_controller_status_t esp_bt_controller_get_status(void)
|
||||
{
|
||||
return ble_controller_status;
|
||||
@@ -1276,17 +1170,9 @@ esp_err_t esp_ble_tx_power_set(esp_ble_power_type_t power_type, esp_power_level_
|
||||
|
||||
switch (power_type) {
|
||||
case ESP_BLE_PWR_TYPE_DEFAULT:
|
||||
if (r_ble_txpwr_set(ESP_BLE_ENHANCED_PWR_TYPE_DEFAULT, 0, power_level) == 0) {
|
||||
stat = ESP_OK;
|
||||
}
|
||||
break;
|
||||
case ESP_BLE_PWR_TYPE_ADV:
|
||||
if (r_ble_txpwr_set(ESP_BLE_ENHANCED_PWR_TYPE_ADV, 0xFF, power_level) == 0) {
|
||||
stat = ESP_OK;
|
||||
}
|
||||
break;
|
||||
case ESP_BLE_PWR_TYPE_SCAN:
|
||||
if (r_ble_txpwr_set(ESP_BLE_ENHANCED_PWR_TYPE_SCAN, 0, power_level) == 0) {
|
||||
if (r_ble_txpwr_set(ESP_BLE_ENHANCED_PWR_TYPE_DEFAULT, 0, power_level) == 0) {
|
||||
stat = ESP_OK;
|
||||
}
|
||||
break;
|
||||
@@ -1317,13 +1203,9 @@ esp_err_t esp_ble_tx_power_set_enhanced(esp_ble_enhanced_power_type_t power_type
|
||||
esp_err_t stat = ESP_FAIL;
|
||||
switch (power_type) {
|
||||
case ESP_BLE_ENHANCED_PWR_TYPE_DEFAULT:
|
||||
if (r_ble_txpwr_set(ESP_BLE_ENHANCED_PWR_TYPE_DEFAULT, 0, power_level) == 0) {
|
||||
stat = ESP_OK;
|
||||
}
|
||||
break;
|
||||
case ESP_BLE_ENHANCED_PWR_TYPE_SCAN:
|
||||
case ESP_BLE_ENHANCED_PWR_TYPE_INIT:
|
||||
if (r_ble_txpwr_set(ESP_BLE_ENHANCED_PWR_TYPE_SCAN, 0, power_level) == 0) {
|
||||
if (r_ble_txpwr_set(ESP_BLE_ENHANCED_PWR_TYPE_DEFAULT, 0, power_level) == 0) {
|
||||
stat = ESP_OK;
|
||||
}
|
||||
break;
|
||||
@@ -1346,15 +1228,11 @@ esp_power_level_t esp_ble_tx_power_get(esp_ble_power_type_t power_type)
|
||||
int tx_level = 0;
|
||||
|
||||
switch (power_type) {
|
||||
case ESP_BLE_PWR_TYPE_ADV:
|
||||
case ESP_BLE_PWR_TYPE_SCAN:
|
||||
case ESP_BLE_PWR_TYPE_DEFAULT:
|
||||
tx_level = r_ble_txpwr_get(ESP_BLE_ENHANCED_PWR_TYPE_DEFAULT, 0);
|
||||
break;
|
||||
case ESP_BLE_PWR_TYPE_ADV:
|
||||
tx_level = r_ble_txpwr_get(ESP_BLE_ENHANCED_PWR_TYPE_ADV, 0);
|
||||
break;
|
||||
case ESP_BLE_PWR_TYPE_SCAN:
|
||||
tx_level = r_ble_txpwr_get(ESP_BLE_ENHANCED_PWR_TYPE_SCAN, 0);
|
||||
break;
|
||||
case ESP_BLE_PWR_TYPE_CONN_HDL0:
|
||||
case ESP_BLE_PWR_TYPE_CONN_HDL1:
|
||||
case ESP_BLE_PWR_TYPE_CONN_HDL2:
|
||||
@@ -1384,11 +1262,9 @@ esp_power_level_t esp_ble_tx_power_get_enhanced(esp_ble_enhanced_power_type_t po
|
||||
|
||||
switch (power_type) {
|
||||
case ESP_BLE_ENHANCED_PWR_TYPE_DEFAULT:
|
||||
tx_level = r_ble_txpwr_get(ESP_BLE_ENHANCED_PWR_TYPE_DEFAULT, 0);
|
||||
break;
|
||||
case ESP_BLE_ENHANCED_PWR_TYPE_SCAN:
|
||||
case ESP_BLE_ENHANCED_PWR_TYPE_INIT:
|
||||
tx_level = r_ble_txpwr_get(ESP_BLE_ENHANCED_PWR_TYPE_SCAN, 0);
|
||||
tx_level = r_ble_txpwr_get(ESP_BLE_ENHANCED_PWR_TYPE_DEFAULT, 0);
|
||||
break;
|
||||
case ESP_BLE_ENHANCED_PWR_TYPE_ADV:
|
||||
case ESP_BLE_ENHANCED_PWR_TYPE_CONN:
|
||||
@@ -1406,47 +1282,41 @@ esp_power_level_t esp_ble_tx_power_get_enhanced(esp_ble_enhanced_power_type_t po
|
||||
}
|
||||
|
||||
#if CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
|
||||
#if !CONFIG_BT_LE_CONTROLLER_LOG_SPI_OUT_ENABLED
|
||||
static void esp_bt_controller_log_interface(uint32_t len, const uint8_t *addr, uint32_t len_append, const uint8_t *addr_append, uint32_t flag)
|
||||
static void esp_bt_controller_log_interface(uint32_t len, const uint8_t *addr, bool end)
|
||||
{
|
||||
bool end = (flag & BIT(BLE_LOG_INTERFACE_FLAG_END));
|
||||
if (log_output_mode == LOG_STORAGE_TO_FLASH) {
|
||||
#if CONFIG_BT_LE_CONTROLLER_LOG_STORAGE_ENABLE
|
||||
esp_bt_controller_log_storage(len, addr, end);
|
||||
#else // !CONFIG_BT_LE_CONTROLLER_LOG_STORAGE_ENABLE
|
||||
portMUX_TYPE spinlock = portMUX_INITIALIZER_UNLOCKED;
|
||||
portENTER_CRITICAL_SAFE(&spinlock);
|
||||
esp_panic_handler_feed_wdts();
|
||||
esp_bt_controller_log_storage(len, addr, end);
|
||||
#endif //CONFIG_BT_LE_CONTROLLER_LOG_STORAGE_ENABLE
|
||||
} else {
|
||||
portMUX_TYPE spinlock = portMUX_INITIALIZER_UNLOCKED;
|
||||
portENTER_CRITICAL_SAFE(&spinlock);
|
||||
esp_panic_handler_reconfigure_wdts(1000);
|
||||
for (int i = 0; i < len; i++) {
|
||||
esp_rom_printf("%02x ", addr[i]);
|
||||
}
|
||||
|
||||
if (len && addr) {
|
||||
for (int i = 0; i < len; i++) { esp_rom_printf("%02x ", addr[i]); }
|
||||
if (end) {
|
||||
esp_rom_printf("\n");
|
||||
}
|
||||
portEXIT_CRITICAL_SAFE(&spinlock);
|
||||
}
|
||||
if (len_append && addr_append) {
|
||||
for (int i = 0; i < len_append; i++) { esp_rom_printf("%02x ", addr_append[i]); }
|
||||
}
|
||||
if (end) { esp_rom_printf("\n"); }
|
||||
|
||||
portEXIT_CRITICAL_SAFE(&spinlock);
|
||||
#endif // CONFIG_BT_LE_CONTROLLER_LOG_STORAGE_ENABLE
|
||||
}
|
||||
#endif // !CONFIG_BT_LE_CONTROLLER_LOG_SPI_OUT_ENABLED
|
||||
|
||||
void esp_ble_controller_log_dump_all(bool output)
|
||||
{
|
||||
#if CONFIG_BT_BLE_LOG_SPI_OUT_ENABLED
|
||||
ble_log_spi_out_dump_all();
|
||||
#endif // CONFIG_BT_BLE_LOG_SPI_OUT_ENABLED
|
||||
|
||||
#if CONFIG_BT_LE_CONTROLLER_LOG_STORAGE_ENABLE
|
||||
esp_bt_read_ctrl_log_from_flash(output);
|
||||
#elif !CONFIG_BT_LE_CONTROLLER_LOG_SPI_OUT_ENABLED
|
||||
#else
|
||||
portMUX_TYPE spinlock = portMUX_INITIALIZER_UNLOCKED;
|
||||
|
||||
portENTER_CRITICAL_SAFE(&spinlock);
|
||||
esp_panic_handler_feed_wdts();
|
||||
esp_panic_handler_reconfigure_wdts(5000);
|
||||
BT_ASSERT_PRINT("\r\n[DUMP_START:");
|
||||
r_ble_log_async_output_dump_all(output);
|
||||
BT_ASSERT_PRINT(":DUMP_END]\r\n");
|
||||
portEXIT_CRITICAL_SAFE(&spinlock);
|
||||
#endif
|
||||
#endif // CONFIG_BT_LE_CONTROLLER_LOG_STORAGE_ENABLE
|
||||
}
|
||||
#endif // CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
|
||||
|
||||
@@ -1661,35 +1531,3 @@ int ble_sm_alg_gen_key_pair(uint8_t *pub, uint8_t *priv)
|
||||
|
||||
#endif // CONFIG_BT_LE_SM_LEGACY || CONFIG_BT_LE_SM_SC
|
||||
#endif // (!CONFIG_BT_NIMBLE_ENABLED) && (CONFIG_BT_CONTROLLER_ENABLED)
|
||||
#if CONFIG_BT_LE_DEBUG_REMAIN_SCENE_ENABLED
|
||||
#include "esp_gdbstub.h"
|
||||
#endif // CONFIG_BT_LE_DEBUG_REMAIN_SCENE_ENABLED
|
||||
|
||||
int IRAM_ATTR
|
||||
ble_capture_info_user_handler(uint8_t type, uint32_t reason)
|
||||
{
|
||||
int i;
|
||||
|
||||
switch(type) {
|
||||
case 0:
|
||||
for (i = 0; i < 2; i++) {
|
||||
esp_ble_controller_info_capture(0x010101);
|
||||
}
|
||||
#if CONFIG_BT_LE_DEBUG_REMAIN_SCENE_ENABLED
|
||||
uintptr_t sp;
|
||||
__asm__ volatile ("mv %0, sp" : "=r" (sp));
|
||||
esp_gdbstub_panic_handler(&sp);
|
||||
#endif // CONFIG_BT_LE_DEBUG_REMAIN_SCENE_ENABLED
|
||||
break;
|
||||
#if CONFIG_BT_LE_ASSERT_WHEN_ABNORMAL_DISCONN_ENABLED
|
||||
case 1:
|
||||
if ((reason == 0x08) || (reason == 0x3d) || (reason == 0x28)) {
|
||||
osi_assert_wrapper(__LINE__,__func__, type, reason);
|
||||
}
|
||||
break;
|
||||
#endif // CONFIG_BT_LE_ASSERT_WHEN_ABNORMAL_DISCONN_ENABLED
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -148,74 +148,12 @@ extern "C" {
|
||||
|
||||
#define DEFAULT_BT_LE_COEX_PHY_CODED_TX_RX_TLIM_EFF CONFIG_BT_LE_COEX_PHY_CODED_TX_RX_TLIM_EFF
|
||||
|
||||
#ifdef CONFIG_BT_LE_CTRL_CHECK_CONNECT_IND_ACCESS_ADDRESS
|
||||
#define DEFAULT_BT_LE_CTRL_CHECK_CONNECT_IND_ACCESS_ADDRESS (CONFIG_BT_LE_CTRL_CHECK_CONNECT_IND_ACCESS_ADDRESS)
|
||||
#else
|
||||
#define DEFAULT_BT_LE_CTRL_CHECK_CONNECT_IND_ACCESS_ADDRESS (0)
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_BT_LE_CTRL_LLCP_CONN_UPDATE
|
||||
#define BT_CTRL_BLE_LLCP_CONN_UPDATE (1<<0)
|
||||
#else
|
||||
#define BT_CTRL_BLE_LLCP_CONN_UPDATE (0<<0)
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_BT_LE_CTRL_LLCP_CHAN_MAP_UPDATE
|
||||
#define BT_CTRL_BLE_LLCP_CHAN_MAP_UPDATE (1<<1)
|
||||
#else
|
||||
#define BT_CTRL_BLE_LLCP_CHAN_MAP_UPDATE (0<<1)
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_BT_LE_CTRL_LLCP_PHY_UPDATE
|
||||
#define BT_CTRL_BLE_LLCP_PHY_UPDATE (1<<2)
|
||||
#else
|
||||
#define BT_CTRL_BLE_LLCP_PHY_UPDATE (0<<2)
|
||||
#endif
|
||||
|
||||
#define BT_LE_CTRL_LLCP_DISC_FLAG (BT_CTRL_BLE_LLCP_CONN_UPDATE | BT_CTRL_BLE_LLCP_CHAN_MAP_UPDATE | BT_CTRL_BLE_LLCP_PHY_UPDATE)
|
||||
|
||||
#ifdef CONFIG_BT_CTRL_SCAN_BACKOFF_UPPERLIMITMAX
|
||||
#define BT_CTRL_SCAN_BACKOFF_UPPERLIMITMAX (CONFIG_BT_CTRL_SCAN_BACKOFF_UPPERLIMITMAX)
|
||||
#else
|
||||
#define BT_CTRL_SCAN_BACKOFF_UPPERLIMITMAX (256)
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_BT_LE_CTRL_CHAN_ASS_EN)
|
||||
#define DEFAULT_BT_LE_CTRL_CHAN_ASS_EN (CONFIG_BT_LE_CTRL_CHAN_ASS_EN)
|
||||
#else
|
||||
#define DEFAULT_BT_LE_CTRL_CHAN_ASS_EN (0)
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_BT_LE_CTRL_ADV_DATA_LENGTH_ZERO_AUX)
|
||||
#define DEFAULT_BT_LE_CTRL_ADV_DATA_LENGTH_ZERO_AUX (CONFIG_BT_LE_CTRL_ADV_DATA_LENGTH_ZERO_AUX)
|
||||
#else
|
||||
#define DEFAULT_BT_LE_CTRL_ADV_DATA_LENGTH_ZERO_AUX (0)
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_BT_LE_CTRL_FAST_CONN_DATA_TX_EN)
|
||||
#define DEFAULT_BT_LE_CTRL_FAST_CONN_DATA_TX_EN (CONFIG_BT_LE_CTRL_FAST_CONN_DATA_TX_EN)
|
||||
#else
|
||||
#define DEFAULT_BT_LE_CTRL_FAST_CONN_DATA_TX_EN (0)
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_BT_LE_HCI_INTERFACE_USE_UART
|
||||
#define HCI_UART_EN CONFIG_BT_LE_HCI_INTERFACE_USE_UART
|
||||
#else
|
||||
#define HCI_UART_EN 0 // hci ram mode
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_BT_LE_HCI_INTERFACE_USE_RAM
|
||||
#define DEFAULT_BT_LE_VHCI_ENABLED (CONFIG_BT_LE_HCI_INTERFACE_USE_RAM)
|
||||
#else
|
||||
#define DEFAULT_BT_LE_VHCI_ENABLED (0)
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_BT_LE_PTR_CHECK_ENABLED
|
||||
#define DEFAULT_BT_LE_PTR_CHECK_ENABLED (CONFIG_BT_LE_PTR_CHECK_ENABLED)
|
||||
#else
|
||||
#define DEFAULT_BT_LE_PTR_CHECK_ENABLED (0)
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_BT_LE_SLEEP_ENABLE
|
||||
#define NIMBLE_SLEEP_ENABLE CONFIG_BT_LE_SLEEP_ENABLE
|
||||
#else
|
||||
|
||||
Submodule components/bt/controller/lib_esp32 updated: 6d007b7167...c3f6258cfb
Submodule components/bt/controller/lib_esp32c2/esp32c2-bt-lib updated: 06c5ef1481...e5c7ef0bf7
Submodule components/bt/controller/lib_esp32c3_family updated: 72599d583c...eeb2782618
Submodule components/bt/controller/lib_esp32c5/esp32c5-bt-lib updated: 19bce59850...b4f67e85c5
Submodule components/bt/controller/lib_esp32c6/esp32c6-bt-lib updated: 841466ff3c...69f16a7a63
Submodule components/bt/controller/lib_esp32h2/esp32h2-bt-lib updated: bd09406c74...50f567fff5
@@ -15,7 +15,6 @@ if BLE_MESH
|
||||
config BLE_MESH_RANDOM_ADV_INTERVAL
|
||||
bool "Support using random adv interval for mesh packets"
|
||||
select BT_BLE_HIGH_DUTY_ADV_INTERVAL if BT_BLUEDROID_ENABLED
|
||||
select BT_NIMBLE_HIGH_DUTY_ADV_ITVL if BT_NIMBLE_ENABLED
|
||||
default n
|
||||
help
|
||||
Enable this option to allow using random advertising interval
|
||||
@@ -408,7 +407,7 @@ if BLE_MESH
|
||||
int "Maximum capacity of solicitation replay protection list"
|
||||
depends on BLE_MESH_PROXY_SOLIC_PDU_RX
|
||||
default 2
|
||||
range 1 65536
|
||||
range 1 255
|
||||
help
|
||||
This option specifies the maximum capacity of the solicitation replay
|
||||
protection list. The solicitation replay protection list is used to
|
||||
|
||||
@@ -44,7 +44,6 @@ enum bt_mesh_adv_type {
|
||||
BLE_MESH_ADV_URI,
|
||||
BLE_MESH_ADV_BLE,
|
||||
BLE_MESH_ADV_PROXY_SOLIC,
|
||||
BLE_MESH_ADV_TYPES_NUM,
|
||||
};
|
||||
|
||||
struct bt_mesh_adv {
|
||||
|
||||
@@ -35,11 +35,7 @@
|
||||
#define UNPROV_BEACON_INTERVAL K_SECONDS(5)
|
||||
#endif
|
||||
|
||||
#if CONFIG_BLE_MESH_BQB_TEST
|
||||
#define SECURE_BEACON_INTERVAL K_SECONDS(3)
|
||||
#else
|
||||
#define SECURE_BEACON_INTERVAL K_SECONDS(10)
|
||||
#endif
|
||||
|
||||
/* 3 transmissions, 20ms interval */
|
||||
#define UNPROV_XMIT BLE_MESH_TRANSMIT(2, 20)
|
||||
|
||||
@@ -1198,7 +1198,6 @@ uint16_t bt_mesh_gattc_get_service_uuid(struct bt_mesh_conn *conn)
|
||||
|
||||
int bt_mesh_gattc_conn_create(const bt_mesh_addr_t *addr, uint16_t service_uuid)
|
||||
{
|
||||
tBTA_BLE_CONN_PARAMS conn_1m_param = {0};
|
||||
uint8_t zero[6] = {0};
|
||||
int i;
|
||||
|
||||
@@ -1252,14 +1251,10 @@ int bt_mesh_gattc_conn_create(const bt_mesh_addr_t *addr, uint16_t service_uuid)
|
||||
* Slave_latency: 0x0
|
||||
* Supervision_timeout: 1s
|
||||
*/
|
||||
conn_1m_param.interval_min = 0x18;
|
||||
conn_1m_param.interval_max = 0x18;
|
||||
conn_1m_param.latency = 0;
|
||||
conn_1m_param.supervision_timeout = 0x64;
|
||||
BTA_DmSetBlePrefConnParams(bt_mesh_gattc_info[i].addr.val, 0x18, 0x18, 0x00, 0x64);
|
||||
|
||||
BTA_GATTC_Enh_Open(bt_mesh_gattc_if, bt_mesh_gattc_info[i].addr.val,
|
||||
bt_mesh_gattc_info[i].addr.type, true, BTA_GATT_TRANSPORT_LE, FALSE, BLE_ADDR_UNKNOWN_TYPE,
|
||||
BTA_BLE_PHY_1M_MASK, &conn_1m_param, NULL, NULL);
|
||||
BTA_GATTC_Open(bt_mesh_gattc_if, bt_mesh_gattc_info[i].addr.val,
|
||||
bt_mesh_gattc_info[i].addr.type, true, BTA_GATT_TRANSPORT_LE, FALSE);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1287,7 +1287,7 @@ static struct label *va_find(const uint8_t *label_uuid,
|
||||
return match;
|
||||
}
|
||||
|
||||
uint8_t va_add(uint8_t *label_uuid, uint16_t *addr)
|
||||
static uint8_t va_add(uint8_t *label_uuid, uint16_t *addr)
|
||||
{
|
||||
struct label *update = NULL, *free_slot = NULL;
|
||||
|
||||
@@ -1295,9 +1295,6 @@ uint8_t va_add(uint8_t *label_uuid, uint16_t *addr)
|
||||
if (update) {
|
||||
update->ref++;
|
||||
va_store(update);
|
||||
if (addr) {
|
||||
*addr = update->addr;
|
||||
}
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -1317,7 +1314,7 @@ uint8_t va_add(uint8_t *label_uuid, uint16_t *addr)
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
uint8_t va_del(uint8_t *label_uuid, uint16_t *addr)
|
||||
static uint8_t va_del(uint8_t *label_uuid, uint16_t *addr)
|
||||
{
|
||||
struct label *update = NULL;
|
||||
|
||||
|
||||
@@ -441,9 +441,7 @@ int bt_mesh_init(const struct bt_mesh_prov *prov,
|
||||
|
||||
if ((IS_ENABLED(CONFIG_BLE_MESH_PROVISIONER) &&
|
||||
IS_ENABLED(CONFIG_BLE_MESH_PB_GATT)) ||
|
||||
IS_ENABLED(CONFIG_BLE_MESH_GATT_PROXY_CLIENT) ||
|
||||
(IS_ENABLED(CONFIG_BLE_MESH_RPR_SRV) &&
|
||||
IS_ENABLED(CONFIG_BLE_MESH_PB_GATT))) {
|
||||
IS_ENABLED(CONFIG_BLE_MESH_GATT_PROXY_CLIENT)) {
|
||||
bt_mesh_proxy_client_init();
|
||||
}
|
||||
|
||||
@@ -593,9 +591,7 @@ int bt_mesh_deinit(struct bt_mesh_deinit_param *param)
|
||||
|
||||
if ((IS_ENABLED(CONFIG_BLE_MESH_PROVISIONER) &&
|
||||
IS_ENABLED(CONFIG_BLE_MESH_PB_GATT)) ||
|
||||
IS_ENABLED(CONFIG_BLE_MESH_GATT_PROXY_CLIENT) ||
|
||||
(IS_ENABLED(CONFIG_BLE_MESH_RPR_SRV) &&
|
||||
IS_ENABLED(CONFIG_BLE_MESH_PB_GATT))) {
|
||||
IS_ENABLED(CONFIG_BLE_MESH_GATT_PROXY_CLIENT)) {
|
||||
bt_mesh_proxy_client_deinit();
|
||||
}
|
||||
|
||||
|
||||
@@ -147,8 +147,7 @@ void bt_mesh_hci_init(void)
|
||||
|
||||
static struct ble_gap_disc_params scan_param;
|
||||
#if (CONFIG_BLE_MESH_PROVISIONER && CONFIG_BLE_MESH_PB_GATT) || \
|
||||
CONFIG_BLE_MESH_GATT_PROXY_CLIENT || \
|
||||
(CONFIG_BLE_MESH_RPR_SRV && CONFIG_BLE_MESH_PB_GATT)
|
||||
CONFIG_BLE_MESH_GATT_PROXY_CLIENT
|
||||
static struct gattc_prov_info {
|
||||
/* Service to be found depends on the type of adv pkt received */
|
||||
struct bt_mesh_conn conn;
|
||||
@@ -397,16 +396,13 @@ static int svc_disced(uint16_t conn_handle, const struct ble_gatt_error *error,
|
||||
|
||||
return rc;
|
||||
}
|
||||
#endif /* (CONFIG_BLE_MESH_PROVISIONER && CONFIG_BLE_MESH_PB_GATT) || \
|
||||
CONFIG_BLE_MESH_GATT_PROXY_CLIENT ||
|
||||
(CONFIG_BLE_MESH_RPR_SRV && CONFIG_BLE_MESH_PB_GATT) */
|
||||
#endif /* (CONFIG_BLE_MESH_PROVISIONER && CONFIG_BLE_MESH_PB_GATT) || CONFIG_BLE_MESH_GATT_PROXY_CLIENT */
|
||||
|
||||
static int disc_cb(struct ble_gap_event *event, void *arg)
|
||||
{
|
||||
struct ble_gap_disc_desc *desc;
|
||||
#if (CONFIG_BLE_MESH_PROVISIONER && CONFIG_BLE_MESH_PB_GATT) || \
|
||||
CONFIG_BLE_MESH_GATT_PROXY_CLIENT || \
|
||||
(CONFIG_BLE_MESH_RPR_SRV && CONFIG_BLE_MESH_PB_GATT)
|
||||
CONFIG_BLE_MESH_GATT_PROXY_CLIENT
|
||||
int rc, i;
|
||||
uint8_t notif_data[100];
|
||||
uint16_t notif_len;
|
||||
@@ -429,8 +425,7 @@ static int disc_cb(struct ble_gap_event *event, void *arg)
|
||||
break;
|
||||
}
|
||||
#if (CONFIG_BLE_MESH_PROVISIONER && CONFIG_BLE_MESH_PB_GATT) || \
|
||||
CONFIG_BLE_MESH_GATT_PROXY_CLIENT || \
|
||||
(CONFIG_BLE_MESH_RPR_SRV && CONFIG_BLE_MESH_PB_GATT)
|
||||
CONFIG_BLE_MESH_GATT_PROXY_CLIENT
|
||||
case BLE_GAP_EVENT_CONNECT:
|
||||
if (event->connect.status == 0) {
|
||||
/* Connection successfully established. */
|
||||
@@ -1362,8 +1357,7 @@ int bt_mesh_gatts_set_local_device_name(const char *name)
|
||||
#endif /* CONFIG_BLE_MESH_NODE */
|
||||
|
||||
#if (CONFIG_BLE_MESH_PROVISIONER && CONFIG_BLE_MESH_PB_GATT) || \
|
||||
CONFIG_BLE_MESH_GATT_PROXY_CLIENT || \
|
||||
(CONFIG_BLE_MESH_RPR_SRV && CONFIG_BLE_MESH_PB_GATT)
|
||||
CONFIG_BLE_MESH_GATT_PROXY_CLIENT
|
||||
void bt_mesh_gattc_conn_cb_register(struct bt_mesh_prov_conn_cb *cb)
|
||||
{
|
||||
bt_mesh_gattc_conn_cb = cb;
|
||||
@@ -1604,10 +1598,7 @@ void bt_mesh_gattc_disconnect(struct bt_mesh_conn *conn)
|
||||
* Mesh Proxy Data In: 0x2ADD
|
||||
* Mesh PROXY Data Out: 0x2ADE
|
||||
*/
|
||||
|
||||
#endif /* (CONFIG_BLE_MESH_PROVISIONER && CONFIG_BLE_MESH_PB_GATT) ||
|
||||
CONFIG_BLE_MESH_GATT_PROXY_CLIENT ||
|
||||
(CONFIG_BLE_MESH_RPR_SRV && CONFIG_BLE_MESH_PB_GATT)*/
|
||||
#endif /* (CONFIG_BLE_MESH_PROVISIONER && CONFIG_BLE_MESH_PB_GATT) || CONFIG_BLE_MESH_GATT_PROXY_CLIENT */
|
||||
|
||||
struct bt_mesh_conn *bt_mesh_conn_ref(struct bt_mesh_conn *conn)
|
||||
{
|
||||
@@ -1752,8 +1743,7 @@ void bt_mesh_gatt_init(void)
|
||||
#endif /* CONFIG_BLE_MESH_NODE */
|
||||
|
||||
#if (CONFIG_BLE_MESH_PROVISIONER && CONFIG_BLE_MESH_PB_GATT) || \
|
||||
CONFIG_BLE_MESH_GATT_PROXY_CLIENT || \
|
||||
(CONFIG_BLE_MESH_RPR_SRV && CONFIG_BLE_MESH_PB_GATT)
|
||||
CONFIG_BLE_MESH_GATT_PROXY_CLIENT
|
||||
for (int i = 0; i < ARRAY_SIZE(bt_mesh_gattc_info); i++) {
|
||||
bt_mesh_gattc_info[i].conn.handle = 0xFFFF;
|
||||
bt_mesh_gattc_info[i].mtu = BLE_ATT_MTU_DFLT;
|
||||
@@ -1771,8 +1761,7 @@ void bt_mesh_gatt_deinit(void)
|
||||
#endif
|
||||
|
||||
#if (CONFIG_BLE_MESH_PROVISIONER && CONFIG_BLE_MESH_PB_GATT) || \
|
||||
CONFIG_BLE_MESH_GATT_PROXY_CLIENT || \
|
||||
(CONFIG_BLE_MESH_RPR_SRV && CONFIG_BLE_MESH_PB_GATT)
|
||||
CONFIG_BLE_MESH_GATT_PROXY_CLIENT
|
||||
for (int i = 0; i < ARRAY_SIZE(bt_mesh_gattc_info); i++) {
|
||||
bt_mesh_gattc_info[i].conn.handle = 0xFFFF;
|
||||
memset(&bt_mesh_gattc_info[i].addr, 0, sizeof(bt_mesh_addr_t));
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2017 Intel Corporation
|
||||
* SPDX-FileContributor: 2018-2025 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileContributor: 2018-2023 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -135,9 +135,6 @@ bool bt_mesh_prov_pdu_check(uint8_t type, uint16_t length, uint8_t *reason)
|
||||
#define CLOSE_XMIT BLE_MESH_TRANSMIT(2, 20)
|
||||
|
||||
#define CLOSE_TIMEOUT K_MSEC(100)
|
||||
#define CLOSE_RETRANS_CNT 3
|
||||
#define CLOSE_RETRANS_WITH_REASON(cnt, rsn) (((cnt) << 4) | ((rsn) & 0x0f))
|
||||
#define CLOSE_RETRANS_GET(rsn) ((rsn) >> 4)
|
||||
|
||||
#define BUF_TIMEOUT K_MSEC(400)
|
||||
|
||||
@@ -146,7 +143,7 @@ bool bt_mesh_prov_pdu_check(uint8_t type, uint16_t length, uint8_t *reason)
|
||||
|
||||
static uint8_t bt_mesh_prov_buf_type_get(struct net_buf_simple *buf)
|
||||
{
|
||||
return buf->__buf[PROV_BUF_HEADROOM];
|
||||
return buf->data[PROV_BUF_HEADROOM];
|
||||
}
|
||||
|
||||
uint8_t node_next_xact_id(struct bt_mesh_prov_link *link)
|
||||
@@ -460,19 +457,12 @@ static void prov_retransmit(struct k_work *work)
|
||||
if (link->pb_remote_close) {
|
||||
link->pb_remote_close(link, link->reason);
|
||||
}
|
||||
return;
|
||||
} else {
|
||||
uint8_t retrans_cnt = CLOSE_RETRANS_GET(link->reason);
|
||||
if (!retrans_cnt) {
|
||||
if (link->reset_adv_link) {
|
||||
link->reset_adv_link(link, link->reason);
|
||||
}
|
||||
return;
|
||||
} else {
|
||||
retrans_cnt--;
|
||||
link->reason = CLOSE_RETRANS_WITH_REASON(retrans_cnt, link->reason);
|
||||
if (link->reset_adv_link) {
|
||||
link->reset_adv_link(link, link->reason);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
bt_mesh_mutex_lock(&link->buf_lock);
|
||||
@@ -557,14 +547,7 @@ int bt_mesh_prov_bearer_ctl_send(struct bt_mesh_prov_link *link, uint8_t op,
|
||||
if (op == LINK_CLOSE) {
|
||||
bt_mesh_atomic_clear_bit(link->flags, LINK_ACTIVE);
|
||||
bt_mesh_atomic_set_bit(link->flags, LINK_CLOSING);
|
||||
/** We can also use buf->ref and a flag to decide that
|
||||
* link close has been sent 3 times.
|
||||
* Here we use another way: use retransmit timer and need
|
||||
* to make sure the timer is not cancelled during sending
|
||||
* link close pdu, Therefore, use the higher four bits
|
||||
* of reason as a retransmit count.
|
||||
*/
|
||||
link->reason = CLOSE_RETRANS_WITH_REASON(CLOSE_RETRANS_CNT, (*((uint8_t *)data)));
|
||||
link->reason = *((uint8_t *)data);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2017 Intel Corporation
|
||||
* SPDX-FileContributor: 2018-2025 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileContributor: 2018-2021 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -82,12 +82,12 @@ static void reset_state(void)
|
||||
}
|
||||
#endif /* CONFIG_BLE_MESH_PB_GATT */
|
||||
|
||||
#if CONFIG_BLE_MESH_PB_ADV
|
||||
/* Clear everything except the retransmit and protocol timer
|
||||
* delayed work objects.
|
||||
*/
|
||||
(void)memset(&prov_link, 0, offsetof(struct bt_mesh_prov_link, tx.retransmit));
|
||||
|
||||
#if CONFIG_BLE_MESH_PB_ADV
|
||||
prov_link.pending_ack = PROV_XACT_NVAL;
|
||||
|
||||
prov_link.rx.prev_id = PROV_XACT_NVAL;
|
||||
@@ -154,7 +154,7 @@ static int prov_send_gatt(struct bt_mesh_prov_link *link, struct net_buf_simple
|
||||
/* Changed by Espressif, add provisioning timeout timer operations.
|
||||
* When sending a provisioning PDU successfully, restart the 60s timer.
|
||||
*/
|
||||
#if CONFIG_BLE_MESH_RPR_SRV
|
||||
#if CONFIG_BLE_MESH_GATT_PROXY_CLIENT && CONFIG_BLE_MESH_RPR_SRV
|
||||
if (bt_mesh_atomic_test_bit(link->flags, PB_REMOTE)) {
|
||||
err = bt_mesh_proxy_client_send(link->conn, BLE_MESH_PROXY_PROV, msg);
|
||||
|
||||
@@ -1075,19 +1075,10 @@ static void link_ack(struct prov_rx *rx, struct net_buf_simple *buf)
|
||||
bt_mesh_prov_clear_tx(&prov_link, true);
|
||||
bt_mesh_rpr_srv_recv_link_ack(prov_link.pb_remote_uuid, true);
|
||||
} else {
|
||||
BT_DBG("Link ACK for PB-Remote already received");
|
||||
return;
|
||||
BT_INFO("Link ACK for PB-Remote already received");
|
||||
}
|
||||
}
|
||||
#endif /* CONFIG_BLE_MESH_RPR_SRV */
|
||||
|
||||
if (!k_delayed_work_remaining_get(&prov_link.prot_timer)) {
|
||||
/**
|
||||
* When the link is opened, the provisioner and the unprovisioned device
|
||||
* shall start the link timer with the timeout value set to 60 seconds.
|
||||
*/
|
||||
k_delayed_work_submit(&prov_link.prot_timer, PROTOCOL_TIMEOUT);
|
||||
}
|
||||
}
|
||||
|
||||
static void link_close(struct prov_rx *rx, struct net_buf_simple *buf)
|
||||
@@ -1443,11 +1434,6 @@ int bt_mesh_pb_gatt_open(struct bt_mesh_conn *conn)
|
||||
{
|
||||
BT_DBG("conn %p", conn);
|
||||
|
||||
/**
|
||||
* It's necessary to determine if it is PB_REMOTE because when the
|
||||
* node acts as an RPR server, LINK_ACTIVE has already been set upon
|
||||
* receiving the link open from the RPR client.
|
||||
*/
|
||||
if (!bt_mesh_atomic_test_bit(prov_link.flags, PB_REMOTE) &&
|
||||
bt_mesh_atomic_test_and_set_bit(prov_link.flags, LINK_ACTIVE)) {
|
||||
BT_ERR("Link is busy");
|
||||
@@ -1465,14 +1451,6 @@ int bt_mesh_pb_gatt_open(struct bt_mesh_conn *conn)
|
||||
prov_link.expect = PROV_INVITE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Just like ADV Link, start provision timeout timer after
|
||||
* establishing the link to prevent the RPR server from
|
||||
* being unable to recover to a configurable network state
|
||||
* during remote provisioning.
|
||||
*/
|
||||
k_delayed_work_submit(&prov_link.prot_timer, PROTOCOL_TIMEOUT);
|
||||
|
||||
if (bt_mesh_prov_get()->link_open) {
|
||||
bt_mesh_prov_get()->link_open(BLE_MESH_PROV_GATT);
|
||||
}
|
||||
@@ -1518,7 +1496,7 @@ static void protocol_timeout(struct k_work *work)
|
||||
|
||||
#if CONFIG_BLE_MESH_PB_GATT
|
||||
if (prov_link.conn) {
|
||||
#if CONFIG_BLE_MESH_RPR_SRV
|
||||
#if CONFIG_BLE_MESH_GATT_PROXY_CLIENT && CONFIG_BLE_MESH_RPR_SRV
|
||||
if (bt_mesh_atomic_test_bit(prov_link.flags, PB_REMOTE)) {
|
||||
prov_link.pb_remote_reset = true;
|
||||
bt_mesh_gattc_disconnect(prov_link.conn);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2017-2025 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2017-2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -47,10 +47,6 @@ _Static_assert(BLE_MESH_MAX_CONN >= CONFIG_BLE_MESH_PBG_SAME_TIME,
|
||||
*/
|
||||
static struct bt_mesh_prov_link prov_links[BLE_MESH_PROV_SAME_TIME];
|
||||
|
||||
#if CONFIG_BLE_MESH_RPR_CLI
|
||||
extern struct bt_mesh_prov_link rpr_links[CONFIG_BLE_MESH_RPR_CLI_PROV_SAME_TIME];
|
||||
#endif
|
||||
|
||||
struct bt_mesh_prov_ctx {
|
||||
/* Primary element address of Provisioner */
|
||||
uint16_t primary_addr;
|
||||
@@ -248,7 +244,7 @@ void bt_mesh_provisioner_restore_prov_info(uint16_t primary_addr, uint16_t alloc
|
||||
}
|
||||
#endif /* CONFIG_BLE_MESH_SETTINGS */
|
||||
|
||||
bool bt_mesh_is_unprov_dev_being_prov(const uint8_t uuid[16])
|
||||
static bool is_unprov_dev_being_provision(const uint8_t uuid[16])
|
||||
{
|
||||
int i;
|
||||
|
||||
@@ -265,15 +261,6 @@ bool bt_mesh_is_unprov_dev_being_prov(const uint8_t uuid[16])
|
||||
}
|
||||
#endif /* CONFIG_BLE_MESH_FAST_PROV */
|
||||
|
||||
#if CONFIG_BLE_MESH_RPR_CLI
|
||||
for (i = 0; i < CONFIG_BLE_MESH_RPR_CLI_PROV_SAME_TIME;i++) {
|
||||
if (!memcmp(rpr_links[i].pb_remote_uuid, uuid, 16)) {
|
||||
BT_WARN("Device is being provisioning by Remote Provisioning");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
for (i = 0; i < BLE_MESH_PROV_SAME_TIME; i++) {
|
||||
if (bt_mesh_atomic_test_bit(prov_links[i].flags, LINK_ACTIVE)
|
||||
#if CONFIG_BLE_MESH_PB_GATT
|
||||
@@ -324,7 +311,7 @@ static int provisioner_check_unprov_dev_info(const uint8_t uuid[16], bt_mesh_pro
|
||||
* receive the connectable prov adv pkt from this device.
|
||||
* Here we check both PB-GATT and PB-ADV link status.
|
||||
*/
|
||||
if (bt_mesh_is_unprov_dev_being_prov(uuid)) {
|
||||
if (is_unprov_dev_being_provision(uuid)) {
|
||||
return -EALREADY;
|
||||
}
|
||||
|
||||
@@ -379,7 +366,7 @@ static int provisioner_start_prov_pb_adv(const uint8_t uuid[16], const bt_mesh_a
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
if (bt_mesh_is_unprov_dev_being_prov(uuid)) {
|
||||
if (is_unprov_dev_being_provision(uuid)) {
|
||||
bt_mesh_pb_adv_unlock();
|
||||
return 0;
|
||||
}
|
||||
@@ -441,7 +428,7 @@ static int provisioner_start_prov_pb_gatt(const uint8_t uuid[16], const bt_mesh_
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
if (bt_mesh_is_unprov_dev_being_prov(uuid)) {
|
||||
if (is_unprov_dev_being_provision(uuid)) {
|
||||
bt_mesh_pb_gatt_unlock();
|
||||
return 0;
|
||||
}
|
||||
@@ -1972,7 +1959,6 @@ static void send_prov_data(struct bt_mesh_prov_link *link)
|
||||
uint8_t session_key[16] = {0};
|
||||
uint8_t nonce[13] = {0};
|
||||
uint8_t pdu[25] = {0};
|
||||
uint8_t *dev_uuid = NULL;
|
||||
PROV_BUF(buf, 34);
|
||||
int err = 0;
|
||||
|
||||
@@ -2028,13 +2014,7 @@ static void send_prov_data(struct bt_mesh_prov_link *link)
|
||||
*/
|
||||
|
||||
/* Check if this device is a re-provisioned device */
|
||||
if (bt_mesh_atomic_test_bit(link->flags, PB_REMOTE)) {
|
||||
dev_uuid = link->pb_remote_uuid;
|
||||
} else {
|
||||
dev_uuid = link->uuid;
|
||||
}
|
||||
|
||||
node = bt_mesh_provisioner_get_node_with_uuid(dev_uuid);
|
||||
node = bt_mesh_provisioner_get_node_with_uuid(link->uuid);
|
||||
if (node) {
|
||||
if (link->element_num <= node->element_num &&
|
||||
link->pb_remote_nppi != NPPI_NODE_ADDR_REFRESH) {
|
||||
@@ -2049,7 +2029,7 @@ static void send_prov_data(struct bt_mesh_prov_link *link)
|
||||
*/
|
||||
if (!bt_mesh_atomic_test_bit(link->flags, PB_REMOTE) ||
|
||||
link->pb_remote_nppi == NPPI_UNKNOWN) {
|
||||
bt_mesh_provisioner_remove_node(dev_uuid);
|
||||
bt_mesh_provisioner_remove_node(link->uuid);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2233,7 +2213,6 @@ static void prov_complete(struct bt_mesh_prov_link *link,
|
||||
uint16_t net_idx = 0U;
|
||||
uint16_t index = 0U;
|
||||
bool nppi = false;
|
||||
uint8_t *dev_uuid = NULL;
|
||||
int err = 0;
|
||||
int i;
|
||||
|
||||
@@ -2250,16 +2229,12 @@ static void prov_complete(struct bt_mesh_prov_link *link,
|
||||
net_idx = prov_ctx.net_idx;
|
||||
}
|
||||
|
||||
if (bt_mesh_atomic_test_bit(link->flags, PB_REMOTE)) {
|
||||
if (link->pb_remote_nppi != NPPI_UNKNOWN) {
|
||||
nppi = true;
|
||||
}
|
||||
dev_uuid = link->pb_remote_uuid;
|
||||
} else {
|
||||
dev_uuid = link->uuid;
|
||||
if (bt_mesh_atomic_test_bit(link->flags, PB_REMOTE) &&
|
||||
link->pb_remote_nppi != NPPI_UNKNOWN) {
|
||||
nppi = true;
|
||||
}
|
||||
|
||||
err = bt_mesh_provisioner_provision(&link->addr, dev_uuid, link->oob_info,
|
||||
err = bt_mesh_provisioner_provision(&link->addr, link->uuid, link->oob_info,
|
||||
link->unicast_addr, link->element_num,
|
||||
net_idx, link->kri_flags, bt_mesh.iv_index,
|
||||
device_key, &index, nppi);
|
||||
@@ -2291,13 +2266,13 @@ static void prov_complete(struct bt_mesh_prov_link *link,
|
||||
#endif /* CONFIG_BLE_MESH_RPR_CLI */
|
||||
|
||||
if (bt_mesh_prov_get()->prov_complete) {
|
||||
bt_mesh_prov_get()->prov_complete(index, dev_uuid, link->unicast_addr,
|
||||
bt_mesh_prov_get()->prov_complete(index, link->uuid, link->unicast_addr,
|
||||
link->element_num, net_idx);
|
||||
}
|
||||
|
||||
/* Find if the device is in the device queue */
|
||||
for (i = 0; i < ARRAY_SIZE(unprov_dev); i++) {
|
||||
if (!memcmp(unprov_dev[i].uuid, dev_uuid, 16) &&
|
||||
if (!memcmp(unprov_dev[i].uuid, link->uuid, 16) &&
|
||||
(unprov_dev[i].flags & RM_AFTER_PROV)) {
|
||||
memset(&unprov_dev[i], 0, sizeof(struct unprov_dev_queue));
|
||||
break;
|
||||
|
||||
@@ -379,8 +379,6 @@ uint16_t bt_mesh_provisioner_get_fast_prov_net_idx(void);
|
||||
*/
|
||||
uint8_t bt_mesh_set_fast_prov_unicast_addr_range(uint16_t min, uint16_t max);
|
||||
|
||||
bool bt_mesh_is_unprov_dev_being_prov(const uint8_t uuid[16]);
|
||||
|
||||
int bt_mesh_rpr_cli_pdu_recv(struct bt_mesh_prov_link *link, uint8_t type,
|
||||
struct net_buf_simple *buf);
|
||||
|
||||
|
||||
@@ -26,8 +26,7 @@
|
||||
#endif
|
||||
|
||||
#if (CONFIG_BLE_MESH_PROVISIONER && CONFIG_BLE_MESH_PB_GATT) || \
|
||||
CONFIG_BLE_MESH_GATT_PROXY_CLIENT || \
|
||||
(CONFIG_BLE_MESH_RPR_SRV && CONFIG_BLE_MESH_PB_GATT)
|
||||
CONFIG_BLE_MESH_GATT_PROXY_CLIENT
|
||||
|
||||
static struct bt_mesh_proxy_server {
|
||||
struct bt_mesh_conn *conn;
|
||||
@@ -86,22 +85,6 @@ static void proxy_sar_timeout(struct k_work *work)
|
||||
bt_mesh_gattc_disconnect(server->conn);
|
||||
}
|
||||
|
||||
#if (CONFIG_BLE_MESH_RPR_SRV && CONFIG_BLE_MESH_PB_GATT)
|
||||
int bt_mesh_rpr_srv_set_waiting_prov_link(struct bt_mesh_prov_link *link,
|
||||
bt_mesh_addr_t *addr)
|
||||
{
|
||||
for (size_t i = 0; i < ARRAY_SIZE(waiting_conn_link);i++) {
|
||||
if (waiting_conn_link[i].link == NULL) {
|
||||
waiting_conn_link[i].link = link;
|
||||
memcpy(&waiting_conn_link[i].addr, addr, sizeof(bt_mesh_addr_t));
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
return -ENOBUFS;
|
||||
}
|
||||
#endif /* CONFIG_BLE_MESH_RPR_SRV && CONFIG_BLE_MESH_PB_GATT */
|
||||
|
||||
#if CONFIG_BLE_MESH_GATT_PROXY_CLIENT
|
||||
/**
|
||||
* The following callbacks are used to notify proper information
|
||||
@@ -132,6 +115,22 @@ void bt_mesh_proxy_client_set_filter_status_cb(proxy_client_recv_filter_status_c
|
||||
proxy_client_filter_status_recv_cb = cb;
|
||||
}
|
||||
|
||||
#if (CONFIG_BLE_MESH_RPR_SRV && CONFIG_BLE_MESH_PB_GATT)
|
||||
int bt_mesh_rpr_srv_set_waiting_prov_link(struct bt_mesh_prov_link *link,
|
||||
bt_mesh_addr_t *addr)
|
||||
{
|
||||
for (size_t i = 0; i < ARRAY_SIZE(waiting_conn_link);i++) {
|
||||
if (waiting_conn_link[i].link == NULL) {
|
||||
waiting_conn_link[i].link = link;
|
||||
memcpy(&waiting_conn_link[i].addr, addr, sizeof(bt_mesh_addr_t));
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
return -ENOBUFS;
|
||||
}
|
||||
#endif /* CONFIG_BLE_MESH_RPR_SRV && CONFIG_BLE_MESH_PB_GATT */
|
||||
|
||||
static void filter_status(struct bt_mesh_proxy_server *server,
|
||||
struct bt_mesh_net_rx *rx,
|
||||
struct net_buf_simple *buf)
|
||||
@@ -267,9 +266,7 @@ static void proxy_complete_pdu(struct bt_mesh_proxy_server *server)
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
#if CONFIG_BLE_MESH_PROVISIONER
|
||||
bt_mesh_provisioner_pb_gatt_recv(server->conn, &server->buf);
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
@@ -497,7 +494,6 @@ static void proxy_disconnected(bt_mesh_addr_t *addr, struct bt_mesh_conn *conn,
|
||||
if (bt_mesh_prov_node_get_link()->conn == conn) {
|
||||
for (size_t i = 0; i < ARRAY_SIZE(waiting_conn_link); i++) {
|
||||
if (waiting_conn_link[i].link->conn == conn) {
|
||||
waiting_conn_link[i].link = NULL;
|
||||
memset(&waiting_conn_link[i].addr, 0, sizeof(bt_mesh_addr_t));
|
||||
break;
|
||||
}
|
||||
@@ -507,9 +503,7 @@ static void proxy_disconnected(bt_mesh_addr_t *addr, struct bt_mesh_conn *conn,
|
||||
} else
|
||||
#endif /* CONFIG_BLE_MESH_RPR_SRV */
|
||||
{
|
||||
#if CONFIG_BLE_MESH_PROVISIONER
|
||||
bt_mesh_provisioner_pb_gatt_close(conn, reason);
|
||||
#endif /* CONFIG_BLE_MESH_PROVISIONER */
|
||||
}
|
||||
}
|
||||
#endif /* CONFIG_BLE_MESH_PB_GATT && (CONFIG_BLE_MESH_PROVISIONER || CONFIG_BLE_MESH_RPR_SRV) */
|
||||
@@ -556,9 +550,7 @@ static ssize_t prov_write_ccc(bt_mesh_addr_t *addr, struct bt_mesh_conn *conn)
|
||||
}
|
||||
#endif
|
||||
|
||||
#if CONFIG_BLE_MESH_PROVISIONER
|
||||
return bt_mesh_provisioner_pb_gatt_open(conn, addr->val);
|
||||
#endif
|
||||
}
|
||||
|
||||
return -ENOMEM;
|
||||
@@ -702,12 +694,10 @@ int bt_mesh_proxy_client_gatt_disable(void)
|
||||
static struct bt_mesh_prov_conn_cb conn_callbacks = {
|
||||
.connected = proxy_connected,
|
||||
.disconnected = proxy_disconnected,
|
||||
#if (CONFIG_BLE_MESH_PROVISIONER || CONFIG_BLE_MESH_RPR_SRV) && \
|
||||
CONFIG_BLE_MESH_PB_GATT
|
||||
#if CONFIG_BLE_MESH_PROVISIONER && CONFIG_BLE_MESH_PB_GATT
|
||||
.prov_write_descr = prov_write_ccc,
|
||||
.prov_notify = prov_recv_ntf,
|
||||
#endif /* (CONFIG_BLE_MESH_PROVISIONER || CONFIG_BLE_MESH_RPR_SRV) && \
|
||||
CONFIG_BLE_MESH_PB_GATT */
|
||||
#endif /* CONFIG_BLE_MESH_PROVISIONER && CONFIG_BLE_MESH_PB_GATT */
|
||||
#if CONFIG_BLE_MESH_GATT_PROXY_CLIENT
|
||||
.proxy_write_descr = proxy_write_ccc,
|
||||
.proxy_notify = proxy_recv_ntf,
|
||||
@@ -1135,5 +1125,4 @@ int bt_mesh_proxy_client_deinit(void)
|
||||
#endif /* CONFIG_BLE_MESH_DEINIT */
|
||||
|
||||
#endif /* (CONFIG_BLE_MESH_PROVISIONER && CONFIG_BLE_MESH_PB_GATT) || \
|
||||
CONFIG_BLE_MESH_GATT_PROXY_CLIENT || \
|
||||
(CONFIG_BLE_MESH_RPR_SRV && CONFIG_BLE_MESH_PB_GATT) */
|
||||
CONFIG_BLE_MESH_GATT_PROXY_CLIENT */
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2017 Intel Corporation
|
||||
* SPDX-FileContributor: 2018-2025 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileContributor: 2018-2021 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -828,12 +828,6 @@ static void proxy_connected(struct bt_mesh_conn *conn, uint8_t err)
|
||||
|
||||
BT_DBG("conn %p err 0x%02x", conn, err);
|
||||
|
||||
if (gatt_svc == MESH_GATT_PROV && conn_count == 1) {
|
||||
BT_WARN("Only one prov connection could exists");
|
||||
bt_mesh_gatts_disconnect(conn, 0x13);
|
||||
return;
|
||||
}
|
||||
|
||||
conn_count++;
|
||||
|
||||
/* Since we use ADV_OPT_ONE_TIME */
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user