forked from espressif/esp-idf
Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f8d2c0894c | ||
|
|
109afcb311 | ||
|
|
39a5604c29 | ||
|
|
d634970ed1 | ||
|
|
aa7660c9b4 |
@@ -13,7 +13,7 @@ stages:
|
||||
workflow:
|
||||
rules:
|
||||
# Disable those non-protected push triggered pipelines
|
||||
- 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"'
|
||||
- if: '$CI_COMMIT_REF_NAME != "master" && $CI_COMMIT_BRANCH !~ /^release\/v/ && $CI_COMMIT_TAG !~ /^v\d+\.\d+(\.\d+)?($|-)/ && $CI_PIPELINE_SOURCE == "push"'
|
||||
when: never
|
||||
# when running merged result pipelines, it would create a temp commit id. use $CI_MERGE_REQUEST_SOURCE_BRANCH_SHA instead of $CI_COMMIT_SHA.
|
||||
# Please use PIPELINE_COMMIT_SHA at all places that require a commit sha
|
||||
@@ -72,6 +72,9 @@ variables:
|
||||
|
||||
PRE_COMMIT_IMAGE: "$CI_DOCKER_REGISTRY/esp-idf-pre-commit:1"
|
||||
|
||||
# target test config file, used by assign test job
|
||||
CI_TARGET_TEST_CONFIG_FILE: "$CI_PROJECT_DIR/.gitlab/ci/target-test.yml"
|
||||
|
||||
# target test repo parameters
|
||||
TEST_ENV_CONFIG_REPO: "https://gitlab-ci-token:${BOT_TOKEN}@${CI_SERVER_HOST}:${CI_SERVER_PORT}/qa/ci-test-runner-configs.git"
|
||||
|
||||
@@ -128,8 +131,8 @@ cache:
|
||||
export PYTHONPATH="$IDF_PATH/tools:$IDF_PATH/tools/esp_app_trace:$IDF_PATH/components/partition_table:$IDF_PATH/tools/ci/python_packages:$PYTHONPATH"
|
||||
|
||||
.setup_tools_and_idf_python_venv: &setup_tools_and_idf_python_venv |
|
||||
# Since the version 3.21 CMake passes source files and include dirs to ninja using absolute paths.
|
||||
$IDF_PATH/tools/idf_tools.py --non-interactive install cmake
|
||||
# must use after setup_tools_except_target_test
|
||||
# otherwise the export.sh won't work properly
|
||||
|
||||
# download constraint file for dev
|
||||
if [[ -n "$CI_PYTHON_CONSTRAINT_BRANCH" ]]; then
|
||||
@@ -233,7 +236,6 @@ include:
|
||||
- '.gitlab/ci/pre_check.yml'
|
||||
- '.gitlab/ci/build.yml'
|
||||
- '.gitlab/ci/assign-test.yml'
|
||||
- '.gitlab/ci/integration_test.yml'
|
||||
- '.gitlab/ci/host-test.yml'
|
||||
- '.gitlab/ci/target-test.yml'
|
||||
- '.gitlab/ci/deploy.yml'
|
||||
|
||||
@@ -2,5 +2,214 @@
|
||||
#
|
||||
# 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
|
||||
/.github/workflows/ @esp-idf-codeowners/ci
|
||||
/.gitlab-ci.yml @esp-idf-codeowners/ci
|
||||
/.gitlab/ci/ @esp-idf-codeowners/ci
|
||||
/.gitlab/dangerjs/ @esp-idf-codeowners/ci @esp-idf-codeowners/tools
|
||||
/.pre-commit-config.yaml @esp-idf-codeowners/ci
|
||||
/.readthedocs.yml @esp-idf-codeowners/docs
|
||||
/CMakeLists.txt @esp-idf-codeowners/build-config
|
||||
/CONTRIBUTING.md @esp-idf-codeowners/docs
|
||||
/Kconfig @esp-idf-codeowners/build-config
|
||||
/README*.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/tools
|
||||
/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_coex/ @esp-idf-codeowners/wifi @esp-idf-codeowners/bluetooth @esp-idf-codeowners/ieee802154
|
||||
/components/esp_common/ @esp-idf-codeowners/system
|
||||
/components/esp_eth/ @esp-idf-codeowners/network
|
||||
/components/esp_event/ @esp-idf-codeowners/system
|
||||
/components/esp_gdbstub/ @esp-idf-codeowners/tools
|
||||
/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_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_system/ @esp-idf-codeowners/system
|
||||
/components/esp_timer/ @esp-idf-codeowners/system
|
||||
/components/esp-tls/ @esp-idf-codeowners/app-utilities
|
||||
/components/esp_wifi/ @esp-idf-codeowners/wifi
|
||||
/components/espcoredump/ @esp-idf-codeowners/tools
|
||||
/components/esptool_py/ @esp-idf-codeowners/tools
|
||||
/components/fatfs/ @esp-idf-codeowners/storage
|
||||
/components/fatfs/**/*.py @esp-idf-codeowners/tools
|
||||
/components/freertos/ @esp-idf-codeowners/system
|
||||
/components/hal/ @esp-idf-codeowners/peripherals
|
||||
/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/tools
|
||||
/components/nvs_flash/ @esp-idf-codeowners/storage
|
||||
/components/openthread/ @esp-idf-codeowners/ieee802154
|
||||
/components/partition_table/ @esp-idf-codeowners/system
|
||||
/components/perfmon/ @esp-idf-codeowners/tools
|
||||
/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/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/**/api-reference/bluetooth/ @esp-idf-codeowners/bluetooth
|
||||
/docs/**/api-reference/network/ @esp-idf-codeowners/network
|
||||
/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/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
|
||||
|
||||
/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
|
||||
/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/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/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/esp_prov/ @esp-idf-codeowners/app-utilities
|
||||
/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/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/protocols/ @esp-idf-codeowners/network @esp-idf-codeowners/app-utilities
|
||||
/tools/test_apps/security/ @esp-idf-codeowners/security
|
||||
/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/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
|
||||
|
||||
@@ -21,6 +21,11 @@
|
||||
- [Shell Script Related](#shell-script-related)
|
||||
- [Manifest File to Control the Build/Test apps](#manifest-file-to-control-the-buildtest-apps)
|
||||
- [Grammar](#grammar)
|
||||
- [Operands](#operands)
|
||||
- [Operators](#operators)
|
||||
- [Limitation:](#limitation)
|
||||
- [How does it work?](#how-does-it-work)
|
||||
- [Example](#example)
|
||||
|
||||
## General Workflow
|
||||
|
||||
@@ -51,7 +56,7 @@
|
||||
- `example_test[_esp32/esp32s2/...]`
|
||||
- `fuzzer_test`
|
||||
- `host_test`
|
||||
- `integration_test`
|
||||
- `integration_test[_wifi/ble]`
|
||||
- `iperf_stress_test`
|
||||
- `macos`
|
||||
- `macos_test`
|
||||
@@ -139,11 +144,10 @@ check if there's a suitable `.if-<if-anchor-you-need>` anchor
|
||||
1. if there is, create a rule following [`rules` Template Naming Rules](#rules-template-naming-rules).For detail information, please refer to [GitLab Documentation `rules-if`](https://docs.gitlab.com/ee/ci/yaml/README.html#rulesif). Here's an example.
|
||||
|
||||
```yaml
|
||||
.rules:patterns:python-files:
|
||||
.rules:dev:
|
||||
rules:
|
||||
- <<: *if-protected
|
||||
- <<: *if-trigger
|
||||
- <<: *if-dev-push
|
||||
changes: *patterns-python-files
|
||||
```
|
||||
|
||||
2. if there isn't
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
- assign_test
|
||||
variables:
|
||||
SUBMODULES_TO_FETCH: "none"
|
||||
CI_TARGET_TEST_CONFIG_FILE: "$CI_PROJECT_DIR/.gitlab/ci/target-test.yml"
|
||||
artifacts:
|
||||
paths:
|
||||
- ${TEST_DIR}/test_configs/
|
||||
@@ -67,3 +66,34 @@ assign_unit_test:
|
||||
variables:
|
||||
TEST_TYPE: unit_test
|
||||
TEST_DIR: components/idf_test/unit_test
|
||||
|
||||
assign_integration_test:
|
||||
extends:
|
||||
- .assign_test_template
|
||||
- .rules:test:integration_test
|
||||
- .before_script_minimal
|
||||
image: ${CI_INTEGRATION_TEST_ENV_IMAGE}
|
||||
needs:
|
||||
- build_ssc_esp32
|
||||
- build_ssc_esp32c3
|
||||
- build_ssc_esp32c2
|
||||
artifacts:
|
||||
paths:
|
||||
- $TEST_DIR/test_configs
|
||||
expire_in: 1 week
|
||||
variables:
|
||||
TEST_DIR: ${CI_PROJECT_DIR}/tools/ci/integration_test
|
||||
BUILD_DIR: ${CI_PROJECT_DIR}/SSC/ssc_bin
|
||||
INTEGRATION_TEST_CASE_PATH: "${CI_PROJECT_DIR}/auto_test_script/TestCaseFiles"
|
||||
ASSIGN_TEST_CASE_SCRIPT: "${CI_PROJECT_DIR}/auto_test_script/bin/CIAssignTestCases.py"
|
||||
PYTHONPATH: ${CI_PROJECT_DIR}/auto_test_script/packages
|
||||
GIT_LFS_SKIP_SMUDGE: 1
|
||||
script:
|
||||
- add_gitlab_ssh_keys
|
||||
# clone test script to assign tests
|
||||
- retry_failed git clone ${CI_AUTO_TEST_SCRIPT_REPO_URL} auto_test_script
|
||||
- python $CHECKOUT_REF_SCRIPT auto_test_script auto_test_script
|
||||
- cd auto_test_script
|
||||
- ./tools/ci/setup_idfci.sh
|
||||
# assign integration test cases
|
||||
- python ${ASSIGN_TEST_CASE_SCRIPT} -t ${INTEGRATION_TEST_CASE_PATH} -c $CI_TARGET_TEST_CONFIG_FILE -b ${BUILD_DIR} -o $TEST_DIR/test_configs
|
||||
|
||||
@@ -215,6 +215,14 @@ build_pytest_examples_esp32c2:
|
||||
IDF_TARGET: esp32c2
|
||||
TEST_DIR: examples
|
||||
|
||||
build_pytest_examples_esp32h4:
|
||||
extends:
|
||||
- .build_pytest_no_jtag_template
|
||||
- .rules:build:example_test-esp32h4
|
||||
variables:
|
||||
IDF_TARGET: esp32h4
|
||||
TEST_DIR: examples
|
||||
|
||||
build_pytest_examples_jtag: # for all targets
|
||||
extends:
|
||||
- .build_pytest_jtag_template
|
||||
@@ -236,7 +244,6 @@ build_pytest_examples_esp32h2:
|
||||
extends:
|
||||
- .build_pytest_template
|
||||
- .rules:build:example_test-esp32h2
|
||||
parallel: 2
|
||||
variables:
|
||||
IDF_TARGET: esp32h2
|
||||
TEST_DIR: examples
|
||||
@@ -403,7 +410,7 @@ build_only_tools_test_apps:
|
||||
extends:
|
||||
- .build_cmake_template
|
||||
- .rules:build:custom_test
|
||||
parallel: 8
|
||||
parallel: 9
|
||||
script:
|
||||
# CI specific options start from "--collect-size-info xxx". could ignore when running locally
|
||||
- run_cmd python tools/ci/ci_build_apps.py tools/test_apps -v
|
||||
@@ -451,6 +458,66 @@ fast_template_app:
|
||||
variables:
|
||||
BUILD_COMMAND_ARGS: "-p"
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
.build_ssc_template:
|
||||
extends:
|
||||
- .build_template
|
||||
- .rules:build:integration_test
|
||||
needs:
|
||||
- job: fast_template_app
|
||||
artifacts: false
|
||||
artifacts:
|
||||
paths:
|
||||
- SSC/ssc_bin
|
||||
expire_in: 1 week
|
||||
script:
|
||||
- retry_failed git clone $SSC_REPOSITORY
|
||||
- python $CHECKOUT_REF_SCRIPT SSC SSC
|
||||
- cd SSC
|
||||
- MAKEFLAGS= ./ci_build_ssc.sh $TARGET_NAME
|
||||
|
||||
build_ssc_esp32:
|
||||
extends: .build_ssc_template
|
||||
parallel: 3
|
||||
variables:
|
||||
TARGET_NAME: "ESP32"
|
||||
|
||||
build_ssc_esp32s2:
|
||||
extends: .build_ssc_template
|
||||
parallel: 2
|
||||
variables:
|
||||
TARGET_NAME: "ESP32S2"
|
||||
|
||||
build_ssc_esp32c2:
|
||||
extends: .build_ssc_template
|
||||
parallel: 2
|
||||
variables:
|
||||
TARGET_NAME: "ESP32C2"
|
||||
|
||||
build_ssc_esp32c3:
|
||||
extends: .build_ssc_template
|
||||
parallel: 3
|
||||
variables:
|
||||
TARGET_NAME: "ESP32C3"
|
||||
|
||||
build_ssc_esp32s3:
|
||||
extends: .build_ssc_template
|
||||
parallel: 3
|
||||
variables:
|
||||
TARGET_NAME: "ESP32S3"
|
||||
|
||||
build_ssc_esp32c6:
|
||||
extends: .build_ssc_template
|
||||
parallel: 3
|
||||
variables:
|
||||
TARGET_NAME: "ESP32C6"
|
||||
|
||||
build_ssc_esp32h2:
|
||||
extends: .build_ssc_template
|
||||
parallel: 2
|
||||
variables:
|
||||
TARGET_NAME: "ESP32H2"
|
||||
|
||||
.build_esp_idf_tests_cmake_template:
|
||||
extends:
|
||||
- .build_cmake_template
|
||||
@@ -577,16 +644,24 @@ build_examples_cmake_esp32c3:
|
||||
extends:
|
||||
- .build_cmake_template
|
||||
- .rules:build:example_test-esp32c3
|
||||
parallel: 8
|
||||
parallel: 6
|
||||
variables:
|
||||
IDF_TARGET: esp32c3
|
||||
TEST_DIR: examples
|
||||
|
||||
build_examples_cmake_esp32h4:
|
||||
extends:
|
||||
- .build_cmake_template
|
||||
- .rules:build:example_test-esp32h4
|
||||
variables:
|
||||
IDF_TARGET: esp32h4
|
||||
TEST_DIR: examples
|
||||
|
||||
build_examples_cmake_esp32c6:
|
||||
extends:
|
||||
- .build_cmake_template
|
||||
- .rules:build:example_test-esp32c6
|
||||
parallel: 10
|
||||
parallel: 6
|
||||
variables:
|
||||
IDF_TARGET: esp32c6
|
||||
TEST_DIR: examples
|
||||
@@ -595,7 +670,7 @@ build_examples_cmake_esp32h2:
|
||||
extends:
|
||||
- .build_cmake_template
|
||||
- .rules:build:example_test-esp32h2
|
||||
parallel: 6
|
||||
parallel: 2
|
||||
variables:
|
||||
IDF_TARGET: esp32h2
|
||||
TEST_DIR: examples
|
||||
@@ -654,6 +729,13 @@ build_clang_test_apps_esp32c6:
|
||||
variables:
|
||||
IDF_TARGET: esp32c6
|
||||
|
||||
build_clang_test_apps_esp32h4:
|
||||
extends:
|
||||
- .build_clang_test_apps_riscv
|
||||
- .rules:build:custom_test-esp32h4
|
||||
variables:
|
||||
IDF_TARGET: esp32h4
|
||||
|
||||
.test_build_system_template:
|
||||
stage: host_test
|
||||
extends:
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
- esp32s2
|
||||
- esp32s3
|
||||
- esp32c3
|
||||
- esp32h4
|
||||
- esp32c2
|
||||
- esp32c6
|
||||
- esp32h2
|
||||
@@ -75,6 +76,16 @@
|
||||
- "build:{0}"
|
||||
- build:target_test
|
||||
|
||||
build:integration_test:
|
||||
labels:
|
||||
- build
|
||||
patterns:
|
||||
- build_components
|
||||
- build_system
|
||||
included_in:
|
||||
- build:target_test
|
||||
|
||||
|
||||
####################
|
||||
# Target Test Jobs #
|
||||
####################
|
||||
@@ -122,15 +133,14 @@
|
||||
- *target_test
|
||||
- *all_targets
|
||||
- - bt # example_test_005
|
||||
- wifi # pytest*wifi*
|
||||
- ethernet # pytest*ethernet*
|
||||
- sdio # pytest*sdio*
|
||||
- wifi # example_test_002, example_test*wifi*
|
||||
- ethernet # example_test*ethernet*
|
||||
- sdio # component_ut_pytest_esp32_sdio
|
||||
- usb # USB Device & Host tests
|
||||
- adc # pytest*adc*
|
||||
- adc # component_ut_pytest_esp32x_adc
|
||||
- i154
|
||||
- flash_multi
|
||||
- ecdsa
|
||||
- ccs811 # pytest*ccs811*
|
||||
patterns:
|
||||
- "{0}-{1}-{2}"
|
||||
- "{0}-{2}"
|
||||
@@ -172,6 +182,23 @@
|
||||
- "build:example_test"
|
||||
- build:target_test
|
||||
|
||||
"test:integration_test_{0}":
|
||||
matrix:
|
||||
- - wifi
|
||||
- ble
|
||||
labels:
|
||||
- integration_test_{0}
|
||||
- integration_test
|
||||
- target_test
|
||||
patterns:
|
||||
- integration_test-{0}
|
||||
- target_test-{0}
|
||||
# - maybe others
|
||||
included_in:
|
||||
- test:integration_test
|
||||
- build:integration_test
|
||||
- build:target_test
|
||||
|
||||
"test:host_test":
|
||||
labels:
|
||||
- host_test
|
||||
@@ -187,6 +214,37 @@
|
||||
#################################
|
||||
# Triggered Only By Labels Jobs #
|
||||
#################################
|
||||
"labels:iperf_stress_test": # example_test
|
||||
labels:
|
||||
- iperf_stress_test
|
||||
included_in:
|
||||
- build:example_test
|
||||
- build:example_test-esp32
|
||||
- build:target_test
|
||||
|
||||
"labels:weekend_test": # custom test
|
||||
labels:
|
||||
- weekend_test
|
||||
included_in:
|
||||
- build:custom_test
|
||||
- build:custom_test-esp32
|
||||
- build:target_test
|
||||
|
||||
"labels:nvs_coverage": # host_test
|
||||
labels:
|
||||
- nvs_coverage
|
||||
|
||||
"labels:fuzzer_test-weekend_test": # host test
|
||||
labels:
|
||||
- fuzzer_test
|
||||
- weekend_test
|
||||
|
||||
"labels-protected:lan8720": # UT # FIXME: IDFCI-1176 temporary run this on master/release or with label
|
||||
labels:
|
||||
- lan8720
|
||||
included_in:
|
||||
- build:unit_test
|
||||
- build:unit_test-esp32
|
||||
- build:target_test
|
||||
- build:component_ut
|
||||
- build:component_ut-esp32
|
||||
|
||||
@@ -32,11 +32,50 @@ push_to_github:
|
||||
extends:
|
||||
- .deploy_job_template
|
||||
- .before_script_minimal
|
||||
- .rules:push_to_github
|
||||
needs:
|
||||
- check_submodule_sync
|
||||
- .rules:protected-no_label
|
||||
dependencies: []
|
||||
script:
|
||||
- add_github_ssh_keys
|
||||
- git remote remove github &>/dev/null || true
|
||||
- git remote add github git@github.com:espressif/esp-idf.git
|
||||
- tools/ci/push_to_github.sh
|
||||
|
||||
deploy_test_result:
|
||||
extends:
|
||||
- .deploy_job_template
|
||||
- .before_script_minimal
|
||||
- .rules:ref:master-always
|
||||
image: $CI_DOCKER_REGISTRY/bot-env:1
|
||||
dependencies: []
|
||||
tags:
|
||||
- deploy_test
|
||||
artifacts:
|
||||
when: always
|
||||
paths:
|
||||
- ${CI_PROJECT_DIR}/test-management/*.log
|
||||
expire_in: 1 week
|
||||
variables:
|
||||
BOT_ACCOUNT_CONFIG_FILE: "${CI_PROJECT_DIR}/test-management/Config/Account.local.yml"
|
||||
TEST_RESULTS_PATH: "${CI_PROJECT_DIR}/TEST_RESULTS"
|
||||
script:
|
||||
- add_gitlab_ssh_keys
|
||||
- export GIT_SHA=$(echo ${CI_COMMIT_SHA} | cut -c 1-8)
|
||||
- export REV_COUNT=$(git rev-list --count ${GIT_SHA} --)
|
||||
- export SUMMARY="IDF CI test result for $GIT_SHA (r${REV_COUNT})"
|
||||
# Download test result
|
||||
- export PYTHONPATH="$IDF_PATH/tools:$IDF_PATH/tools/ci/python_packages:$PYTHONPATH"
|
||||
- python3 ${IDF_PATH}/tools/ci/get_all_test_results.py --path ${TEST_RESULTS_PATH} --include_retried
|
||||
- if [[ -z $(find ${TEST_RESULTS_PATH} -name "*.xml") ]]; then exit 0; fi
|
||||
# Clone test-management repo
|
||||
- retry_failed git clone $TEST_MANAGEMENT_REPO
|
||||
- python3 $CHECKOUT_REF_SCRIPT test-management test-management
|
||||
- cd test-management
|
||||
- echo $BOT_JIRA_ACCOUNT > ${BOT_ACCOUNT_CONFIG_FILE}
|
||||
# Make sure all requirements are installed
|
||||
- pip3 install -r requirements.txt
|
||||
# Update test cases
|
||||
- python3 ImportTestCase.py $JIRA_TEST_MANAGEMENT_PROJECT from_xml -d ${TEST_RESULTS_PATH} -r $GIT_SHA -l IDFCI
|
||||
# update test results
|
||||
- python3 ImportTestResult.py -r "$GIT_SHA (r${REV_COUNT})" -j $JIRA_TEST_MANAGEMENT_PROJECT -s "$SUMMARY" -l IDFCI -p ${TEST_RESULTS_PATH} --pipeline_url ${CI_PIPELINE_URL}
|
||||
# May need a long time to upload all test results.
|
||||
timeout: 4 hours
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
- "docs/**/*"
|
||||
- "**/*.rst"
|
||||
- "CONTRIBUTING.rst"
|
||||
- "**/soc_caps.h"
|
||||
|
||||
.patterns-docs-partial: &patterns-docs-partial
|
||||
- "components/**/*.h"
|
||||
@@ -25,9 +24,6 @@
|
||||
.if-protected-no_label: &if-protected-no_label
|
||||
if: '($CI_COMMIT_REF_NAME == "master" || $CI_COMMIT_BRANCH =~ /^release\/v/ || $CI_COMMIT_TAG =~ /^v\d+\.\d+(\.\d+)?($|-)/) && $BOT_TRIGGER_WITH_LABEL == null'
|
||||
|
||||
.if-qa-test-tag: &if-qa-test-tag
|
||||
if: '$CI_COMMIT_TAG =~ /^qa-test/'
|
||||
|
||||
.if-label-build_docs: &if-label-build_docs
|
||||
if: '$BOT_LABEL_BUILD_DOCS || $CI_MERGE_REQUEST_LABELS =~ /^(?:[^,\n\r]+,)*build_docs(?:,[^,\n\r]+)*$/i'
|
||||
|
||||
@@ -35,12 +31,10 @@
|
||||
if: '$BOT_LABEL_DOCS_FULL || $CI_MERGE_REQUEST_LABELS =~ /^(?:[^,\n\r]+,)*docs_full(?:,[^,\n\r]+)*$/i'
|
||||
|
||||
.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: '$CI_COMMIT_REF_NAME != "master" && $CI_COMMIT_BRANCH !~ /^release\/v/ && $CI_COMMIT_TAG !~ /^v\d+\.\d+(\.\d+)?($|-)/ && ($CI_PIPELINE_SOURCE == "push" || $CI_PIPELINE_SOURCE == "merge_request_event")'
|
||||
|
||||
.doc-rules:build:docs-full:
|
||||
rules:
|
||||
- <<: *if-qa-test-tag
|
||||
when: never
|
||||
- <<: *if-protected
|
||||
- <<: *if-label-build_docs
|
||||
- <<: *if-label-docs_full
|
||||
@@ -49,11 +43,6 @@
|
||||
|
||||
.doc-rules:build:docs-partial:
|
||||
rules:
|
||||
- <<: *if-qa-test-tag
|
||||
when: never
|
||||
- <<: *if-dev-push
|
||||
changes: *patterns-docs-full
|
||||
when: never
|
||||
- <<: *if-dev-push
|
||||
changes: *patterns-docs-partial
|
||||
|
||||
|
||||
@@ -135,10 +135,10 @@ test_idf_tools:
|
||||
entrypoint: [""] # use system python3. no extra pip package installed
|
||||
script:
|
||||
# Tools must be downloaded for testing
|
||||
- python3 ${IDF_PATH}/tools/idf_tools.py download required qemu-riscv32 qemu-xtensa
|
||||
- python3 ${IDF_PATH}/tools/idf_tools.py download
|
||||
- cd ${IDF_PATH}/tools/test_idf_tools
|
||||
- python3 -m pip install jsonschema
|
||||
- python3 ./test_idf_tools.py -v
|
||||
- python3 ./test_idf_tools.py
|
||||
- python3 ./test_idf_tools_python_env.py
|
||||
|
||||
.test_efuse_table_on_host_template:
|
||||
@@ -185,6 +185,30 @@ test_efuse_table_on_host_esp32c6:
|
||||
variables:
|
||||
IDF_TARGET: esp32c6
|
||||
|
||||
test_efuse_table_on_host_esp32h4:
|
||||
extends: .test_efuse_table_on_host_template
|
||||
variables:
|
||||
IDF_TARGET: esp32h4
|
||||
|
||||
test_espcoredump:
|
||||
extends: .host_test_template
|
||||
artifacts:
|
||||
when: always
|
||||
paths:
|
||||
- components/espcoredump/test/**/.coverage
|
||||
- components/espcoredump/test/**/output
|
||||
expire_in: 1 week
|
||||
variables:
|
||||
IDF_COREDUMP_ELF_REPO: "https://gitlab-ci-token:${BOT_TOKEN}@${CI_SERVER_HOST}:${CI_SERVER_PORT}/idf/idf-coredump-elf.git"
|
||||
IDF_COREDUMP_ELF_TAG: idf-20220928
|
||||
# install CMake version specified in tools.json
|
||||
SETUP_TOOLS_LIST: "all"
|
||||
script:
|
||||
- eval $($IDF_PATH/tools/idf_tools.py export)
|
||||
- retry_failed git clone ${IDF_COREDUMP_ELF_REPO} -b $IDF_COREDUMP_ELF_TAG
|
||||
- cd ${IDF_PATH}/components/espcoredump/test/
|
||||
- ./test_espcoredump.sh ${CI_PROJECT_DIR}/idf-coredump-elf
|
||||
|
||||
test_logtrace_proc:
|
||||
extends: .host_test_template
|
||||
artifacts:
|
||||
|
||||
@@ -1,69 +0,0 @@
|
||||
# generate dynamic integration pipeline by `idf-integration-ci` project
|
||||
|
||||
.patterns-integration_test: &patterns-integration_test
|
||||
# add all possible patterns to make sure `gen_integration_pipeline` can be triggered.
|
||||
# fine-grained control will be done while generating the pipeline
|
||||
# find `patterns` in `idf-integration-ci` project
|
||||
- "components/**/*"
|
||||
- "tools/**/*"
|
||||
- ".gitlab-ci.yml"
|
||||
- ".gitlab/ci/common.yml"
|
||||
- ".gitlab/ci/integration_test.yml"
|
||||
- ".gitmodules"
|
||||
- "CMakeLists.txt"
|
||||
- "install.sh"
|
||||
- "export.sh"
|
||||
- "Kconfig"
|
||||
- "sdkconfig.rename"
|
||||
|
||||
# Simplify the rules
|
||||
.integration_test_rules:
|
||||
rules:
|
||||
- if: '$CI_PIPELINE_SOURCE != "merge_request_event"'
|
||||
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
|
||||
changes: *patterns-integration_test
|
||||
# support trigger by ci labels
|
||||
- if: '$CI_MERGE_REQUEST_LABELS =~ /^(?:[^,\n\r]+,)*target_test(?:,[^,\n\r]+)*$/i'
|
||||
- if: '$CI_MERGE_REQUEST_LABELS =~ /^(?:[^,\n\r]+,)*integration_test(?:,[^,\n\r]+)*$/i'
|
||||
- if: '$CI_MERGE_REQUEST_LABELS =~ /^(?:[^,\n\r]+,)*build(?:,[^,\n\r]+)*$/i'
|
||||
|
||||
gen_integration_pipeline:
|
||||
extends:
|
||||
- .before_script_minimal
|
||||
- .integration_test_rules
|
||||
image: ${CI_INTEGRATION_ASSIGN_ENV}
|
||||
stage: assign_test
|
||||
cache: []
|
||||
tags:
|
||||
- assign_test
|
||||
variables:
|
||||
SUBMODULES_TO_FETCH: "none"
|
||||
GIT_LFS_SKIP_SMUDGE: 1
|
||||
needs:
|
||||
- job: fast_template_app
|
||||
artifacts: false
|
||||
optional: true
|
||||
artifacts:
|
||||
paths:
|
||||
- idf-integration-ci/child_pipeline/
|
||||
expire_in: 2 weeks
|
||||
script:
|
||||
- add_gitlab_ssh_keys
|
||||
- retry_failed git clone ${CI_GEN_INTEGRATION_PIPELINE_REPO} idf-integration-ci
|
||||
- python $CHECKOUT_REF_SCRIPT idf-integration-ci idf-integration-ci
|
||||
- cd idf-integration-ci
|
||||
- python tools/generate_child_pipeline.py -o child_pipeline/
|
||||
|
||||
child_integration_test_pipeline:
|
||||
extends:
|
||||
- .integration_test_rules
|
||||
stage: assign_test
|
||||
needs:
|
||||
- gen_integration_pipeline
|
||||
trigger:
|
||||
include:
|
||||
- artifact: idf-integration-ci/child_pipeline/pipeline.yml
|
||||
job: gen_integration_pipeline
|
||||
forward:
|
||||
yaml_variables: false
|
||||
strategy: depend
|
||||
@@ -17,15 +17,13 @@ check_pre_commit_master_release:
|
||||
- .rules:protected
|
||||
script:
|
||||
- git diff-tree --no-commit-id --name-only -r $PIPELINE_COMMIT_SHA | xargs pre-commit run --files
|
||||
- pre-commit run --hook-stage post-commit validate-sbom-manifest
|
||||
|
||||
check_pre_commit_MR:
|
||||
extends:
|
||||
- .check_pre_commit_template
|
||||
- .rules:mr
|
||||
- .rules:dev
|
||||
script:
|
||||
- python ${CI_PROJECT_DIR}/tools/ci/ci_get_mr_info.py files ${CI_MERGE_REQUEST_SOURCE_BRANCH_NAME} | xargs pre-commit run --files
|
||||
- pre-commit run --hook-stage post-commit validate-sbom-manifest
|
||||
|
||||
check_MR_style_dangerjs:
|
||||
extends:
|
||||
|
||||
@@ -55,6 +55,8 @@
|
||||
- "tools/test_build_system/**/*"
|
||||
|
||||
.patterns-custom_test: &patterns-custom_test
|
||||
- "components/espcoredump/**/*"
|
||||
|
||||
- "tools/ci/python_packages/gitlab_api.py"
|
||||
- "tools/ci/python_packages/tiny_test_fw/**/*"
|
||||
- "tools/ci/python_packages/ttfw_idf/**/*"
|
||||
@@ -101,6 +103,20 @@
|
||||
- "components/wpa_supplicant/**/*"
|
||||
- "components/esp_coex/**/*"
|
||||
|
||||
.patterns-integration_test-ble: &patterns-integration_test-ble
|
||||
- "tools/ci/python_packages/gitlab_api.py"
|
||||
- "tools/ci/integration_test/**/*"
|
||||
- "components/bt/controller/lib_esp32"
|
||||
- "components/bt/controller/lib_esp32c3_family"
|
||||
- "components/bt/controller/lib_esp32h2/esp32h2-bt-lib"
|
||||
- "components/bt/host/nimble/nimble"
|
||||
- "components/esp_phy/lib"
|
||||
- "components/esp_coex/**/*"
|
||||
|
||||
.patterns-integration_test-wifi: &patterns-integration_test-wifi
|
||||
- "tools/ci/python_packages/gitlab_api.py"
|
||||
- "tools/ci/integration_test/**/*"
|
||||
|
||||
.patterns-host_test: &patterns-host_test
|
||||
- ".gitlab/ci/host-test.yml"
|
||||
|
||||
@@ -169,6 +185,7 @@
|
||||
- "components/esp_phy/lib"
|
||||
- "components/esp_wifi/lib"
|
||||
- "components/esp_coex/lib"
|
||||
- "components/ieee802154/lib"
|
||||
- "components/json/cJSON"
|
||||
- "components/lwip/lwip"
|
||||
- "components/mbedtls/mbedtls"
|
||||
@@ -229,7 +246,6 @@
|
||||
- "components/driver/include/driver/sdio*.h"
|
||||
- "components/driver/include/driver/sdmmc*.h"
|
||||
- "components/sdmmc/**/*"
|
||||
- "examples/peripherals/sdio/**/*"
|
||||
|
||||
# for jobs: component_ut_pytest_sdio related
|
||||
.patterns-component_ut-sdio: &patterns-component_ut-sdio
|
||||
@@ -243,13 +259,6 @@
|
||||
- "components/driver/include/driver/sdmmc*.h"
|
||||
- "components/sdmmc/**/*"
|
||||
|
||||
.patterns-example_test-ccs811: &patterns-example_test-ccs811
|
||||
# components
|
||||
- "examples/system/console/advanced/components/**/*"
|
||||
- "components/driver/i2c/**/*"
|
||||
# tests
|
||||
- "examples/peripherals/i2c/i2c_tools/**/*"
|
||||
|
||||
# for jobs: UT_xx_SDSPI related
|
||||
.patterns-unit_test-sdio: &patterns-unit_test-sdio
|
||||
- "components/hal/sdio*.c"
|
||||
@@ -312,19 +321,13 @@
|
||||
if: '$CI_COMMIT_TAG =~ /^v\d+\.\d+(\.\d+)?($|-)/'
|
||||
|
||||
.if-protected: &if-protected
|
||||
if: '($CI_COMMIT_REF_NAME == "master" || $CI_COMMIT_BRANCH =~ /^release\/v/ || $CI_COMMIT_TAG =~ /^v\d+\.\d+(\.\d+)?($|-)/) || $CI_COMMIT_TAG =~ /^qa-test/'
|
||||
if: '($CI_COMMIT_REF_NAME == "master" || $CI_COMMIT_BRANCH =~ /^release\/v/ || $CI_COMMIT_TAG =~ /^v\d+\.\d+(\.\d+)?($|-)/)'
|
||||
|
||||
.if-protected-no_label: &if-protected-no_label
|
||||
if: '($CI_COMMIT_REF_NAME == "master" || $CI_COMMIT_BRANCH =~ /^release\/v/ || $CI_COMMIT_TAG =~ /^v\d+\.\d+(\.\d+)?($|-)/) && $BOT_TRIGGER_WITH_LABEL == null'
|
||||
|
||||
.if-qa-test-tag: &if-qa-test-tag
|
||||
if: '$CI_COMMIT_TAG =~ /^qa-test/'
|
||||
|
||||
.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-merge_request: &if-merge_request
|
||||
if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
|
||||
if: '$CI_COMMIT_REF_NAME != "master" && $CI_COMMIT_BRANCH !~ /^release\/v/ && $CI_COMMIT_TAG !~ /^v\d+\.\d+(\.\d+)?($|-)/ && ($CI_PIPELINE_SOURCE == "push" || $CI_PIPELINE_SOURCE == "merge_request_event")'
|
||||
|
||||
.if-schedule: &if-schedule
|
||||
if: '$CI_PIPELINE_SOURCE == "schedule"'
|
||||
@@ -357,17 +360,10 @@
|
||||
rules:
|
||||
- <<: *if-protected
|
||||
|
||||
.rules:push_to_github:
|
||||
.rules:protected-no_label:
|
||||
rules:
|
||||
- <<: *if-qa-test-tag
|
||||
when: never
|
||||
- <<: *if-protected-no_label
|
||||
|
||||
.rules:mr:
|
||||
rules:
|
||||
- <<: *if-merge_request
|
||||
|
||||
### Patterns ###
|
||||
.rules:patterns:python-cache:
|
||||
rules:
|
||||
- *if-schedule
|
||||
@@ -456,6 +452,9 @@
|
||||
.if-label-component_ut_esp32h2: &if-label-component_ut_esp32h2
|
||||
if: '$BOT_LABEL_COMPONENT_UT_ESP32H2 || $CI_MERGE_REQUEST_LABELS =~ /^(?:[^,\n\r]+,)*component_ut_esp32h2(?:,[^,\n\r]+)*$/i'
|
||||
|
||||
.if-label-component_ut_esp32h4: &if-label-component_ut_esp32h4
|
||||
if: '$BOT_LABEL_COMPONENT_UT_ESP32H4 || $CI_MERGE_REQUEST_LABELS =~ /^(?:[^,\n\r]+,)*component_ut_esp32h4(?:,[^,\n\r]+)*$/i'
|
||||
|
||||
.if-label-component_ut_esp32s2: &if-label-component_ut_esp32s2
|
||||
if: '$BOT_LABEL_COMPONENT_UT_ESP32S2 || $CI_MERGE_REQUEST_LABELS =~ /^(?:[^,\n\r]+,)*component_ut_esp32s2(?:,[^,\n\r]+)*$/i'
|
||||
|
||||
@@ -480,6 +479,9 @@
|
||||
.if-label-custom_test_esp32h2: &if-label-custom_test_esp32h2
|
||||
if: '$BOT_LABEL_CUSTOM_TEST_ESP32H2 || $CI_MERGE_REQUEST_LABELS =~ /^(?:[^,\n\r]+,)*custom_test_esp32h2(?:,[^,\n\r]+)*$/i'
|
||||
|
||||
.if-label-custom_test_esp32h4: &if-label-custom_test_esp32h4
|
||||
if: '$BOT_LABEL_CUSTOM_TEST_ESP32H4 || $CI_MERGE_REQUEST_LABELS =~ /^(?:[^,\n\r]+,)*custom_test_esp32h4(?:,[^,\n\r]+)*$/i'
|
||||
|
||||
.if-label-custom_test_esp32s2: &if-label-custom_test_esp32s2
|
||||
if: '$BOT_LABEL_CUSTOM_TEST_ESP32S2 || $CI_MERGE_REQUEST_LABELS =~ /^(?:[^,\n\r]+,)*custom_test_esp32s2(?:,[^,\n\r]+)*$/i'
|
||||
|
||||
@@ -507,15 +509,36 @@
|
||||
.if-label-example_test_esp32h2: &if-label-example_test_esp32h2
|
||||
if: '$BOT_LABEL_EXAMPLE_TEST_ESP32H2 || $CI_MERGE_REQUEST_LABELS =~ /^(?:[^,\n\r]+,)*example_test_esp32h2(?:,[^,\n\r]+)*$/i'
|
||||
|
||||
.if-label-example_test_esp32h4: &if-label-example_test_esp32h4
|
||||
if: '$BOT_LABEL_EXAMPLE_TEST_ESP32H4 || $CI_MERGE_REQUEST_LABELS =~ /^(?:[^,\n\r]+,)*example_test_esp32h4(?:,[^,\n\r]+)*$/i'
|
||||
|
||||
.if-label-example_test_esp32s2: &if-label-example_test_esp32s2
|
||||
if: '$BOT_LABEL_EXAMPLE_TEST_ESP32S2 || $CI_MERGE_REQUEST_LABELS =~ /^(?:[^,\n\r]+,)*example_test_esp32s2(?:,[^,\n\r]+)*$/i'
|
||||
|
||||
.if-label-example_test_esp32s3: &if-label-example_test_esp32s3
|
||||
if: '$BOT_LABEL_EXAMPLE_TEST_ESP32S3 || $CI_MERGE_REQUEST_LABELS =~ /^(?:[^,\n\r]+,)*example_test_esp32s3(?:,[^,\n\r]+)*$/i'
|
||||
|
||||
.if-label-fuzzer_test: &if-label-fuzzer_test
|
||||
if: '$BOT_LABEL_FUZZER_TEST || $CI_MERGE_REQUEST_LABELS =~ /^(?:[^,\n\r]+,)*fuzzer_test(?:,[^,\n\r]+)*$/i'
|
||||
|
||||
.if-label-host_test: &if-label-host_test
|
||||
if: '$BOT_LABEL_HOST_TEST || $CI_MERGE_REQUEST_LABELS =~ /^(?:[^,\n\r]+,)*host_test(?:,[^,\n\r]+)*$/i'
|
||||
|
||||
.if-label-integration_test: &if-label-integration_test
|
||||
if: '$BOT_LABEL_INTEGRATION_TEST || $CI_MERGE_REQUEST_LABELS =~ /^(?:[^,\n\r]+,)*integration_test(?:,[^,\n\r]+)*$/i'
|
||||
|
||||
.if-label-integration_test_ble: &if-label-integration_test_ble
|
||||
if: '$BOT_LABEL_INTEGRATION_TEST_BLE || $CI_MERGE_REQUEST_LABELS =~ /^(?:[^,\n\r]+,)*integration_test_ble(?:,[^,\n\r]+)*$/i'
|
||||
|
||||
.if-label-integration_test_wifi: &if-label-integration_test_wifi
|
||||
if: '$BOT_LABEL_INTEGRATION_TEST_WIFI || $CI_MERGE_REQUEST_LABELS =~ /^(?:[^,\n\r]+,)*integration_test_wifi(?:,[^,\n\r]+)*$/i'
|
||||
|
||||
.if-label-iperf_stress_test: &if-label-iperf_stress_test
|
||||
if: '$BOT_LABEL_IPERF_STRESS_TEST || $CI_MERGE_REQUEST_LABELS =~ /^(?:[^,\n\r]+,)*iperf_stress_test(?:,[^,\n\r]+)*$/i'
|
||||
|
||||
.if-label-lan8720: &if-label-lan8720
|
||||
if: '$BOT_LABEL_LAN8720 || $CI_MERGE_REQUEST_LABELS =~ /^(?:[^,\n\r]+,)*lan8720(?:,[^,\n\r]+)*$/i'
|
||||
|
||||
.if-label-macos: &if-label-macos
|
||||
if: '$BOT_LABEL_MACOS || $CI_MERGE_REQUEST_LABELS =~ /^(?:[^,\n\r]+,)*macos(?:,[^,\n\r]+)*$/i'
|
||||
|
||||
@@ -549,12 +572,18 @@
|
||||
.if-label-unit_test_esp32h2: &if-label-unit_test_esp32h2
|
||||
if: '$BOT_LABEL_UNIT_TEST_ESP32H2 || $CI_MERGE_REQUEST_LABELS =~ /^(?:[^,\n\r]+,)*unit_test_esp32h2(?:,[^,\n\r]+)*$/i'
|
||||
|
||||
.if-label-unit_test_esp32h4: &if-label-unit_test_esp32h4
|
||||
if: '$BOT_LABEL_UNIT_TEST_ESP32H4 || $CI_MERGE_REQUEST_LABELS =~ /^(?:[^,\n\r]+,)*unit_test_esp32h4(?:,[^,\n\r]+)*$/i'
|
||||
|
||||
.if-label-unit_test_esp32s2: &if-label-unit_test_esp32s2
|
||||
if: '$BOT_LABEL_UNIT_TEST_ESP32S2 || $CI_MERGE_REQUEST_LABELS =~ /^(?:[^,\n\r]+,)*unit_test_esp32s2(?:,[^,\n\r]+)*$/i'
|
||||
|
||||
.if-label-unit_test_esp32s3: &if-label-unit_test_esp32s3
|
||||
if: '$BOT_LABEL_UNIT_TEST_ESP32S3 || $CI_MERGE_REQUEST_LABELS =~ /^(?:[^,\n\r]+,)*unit_test_esp32s3(?:,[^,\n\r]+)*$/i'
|
||||
|
||||
.if-label-weekend_test: &if-label-weekend_test
|
||||
if: '$BOT_LABEL_WEEKEND_TEST || $CI_MERGE_REQUEST_LABELS =~ /^(?:[^,\n\r]+,)*weekend_test(?:,[^,\n\r]+)*$/i'
|
||||
|
||||
.if-label-windows: &if-label-windows
|
||||
if: '$BOT_LABEL_WINDOWS || $CI_MERGE_REQUEST_LABELS =~ /^(?:[^,\n\r]+,)*windows(?:,[^,\n\r]+)*$/i'
|
||||
|
||||
@@ -583,8 +612,10 @@
|
||||
- <<: *if-label-component_ut_esp32c3
|
||||
- <<: *if-label-component_ut_esp32c6
|
||||
- <<: *if-label-component_ut_esp32h2
|
||||
- <<: *if-label-component_ut_esp32h4
|
||||
- <<: *if-label-component_ut_esp32s2
|
||||
- <<: *if-label-component_ut_esp32s3
|
||||
- <<: *if-label-lan8720
|
||||
- <<: *if-label-target_test
|
||||
- <<: *if-label-unit_test
|
||||
- <<: *if-label-unit_test_esp32
|
||||
@@ -592,6 +623,7 @@
|
||||
- <<: *if-label-unit_test_esp32c3
|
||||
- <<: *if-label-unit_test_esp32c6
|
||||
- <<: *if-label-unit_test_esp32h2
|
||||
- <<: *if-label-unit_test_esp32h4
|
||||
- <<: *if-label-unit_test_esp32s2
|
||||
- <<: *if-label-unit_test_esp32s3
|
||||
- <<: *if-dev-push
|
||||
@@ -625,6 +657,7 @@
|
||||
- <<: *if-label-build
|
||||
- <<: *if-label-component_ut
|
||||
- <<: *if-label-component_ut_esp32
|
||||
- <<: *if-label-lan8720
|
||||
- <<: *if-label-target_test
|
||||
- <<: *if-label-unit_test
|
||||
- <<: *if-label-unit_test_esp32
|
||||
@@ -867,9 +900,11 @@
|
||||
- <<: *if-label-custom_test_esp32c3
|
||||
- <<: *if-label-custom_test_esp32c6
|
||||
- <<: *if-label-custom_test_esp32h2
|
||||
- <<: *if-label-custom_test_esp32h4
|
||||
- <<: *if-label-custom_test_esp32s2
|
||||
- <<: *if-label-custom_test_esp32s3
|
||||
- <<: *if-label-target_test
|
||||
- <<: *if-label-weekend_test
|
||||
- <<: *if-dev-push
|
||||
changes: *patterns-build_components
|
||||
- <<: *if-dev-push
|
||||
@@ -896,6 +931,7 @@
|
||||
- <<: *if-label-custom_test
|
||||
- <<: *if-label-custom_test_esp32
|
||||
- <<: *if-label-target_test
|
||||
- <<: *if-label-weekend_test
|
||||
- <<: *if-dev-push
|
||||
changes: *patterns-build_components
|
||||
- <<: *if-dev-push
|
||||
@@ -1017,6 +1053,32 @@
|
||||
- <<: *if-dev-push
|
||||
changes: *patterns-target_test-wifi
|
||||
|
||||
.rules:build:custom_test-esp32h4:
|
||||
rules:
|
||||
- <<: *if-revert-branch
|
||||
when: never
|
||||
- <<: *if-protected
|
||||
- <<: *if-label-build
|
||||
- <<: *if-label-custom_test
|
||||
- <<: *if-label-custom_test_esp32h4
|
||||
- <<: *if-label-target_test
|
||||
- <<: *if-dev-push
|
||||
changes: *patterns-build_components
|
||||
- <<: *if-dev-push
|
||||
changes: *patterns-build_system
|
||||
- <<: *if-dev-push
|
||||
changes: *patterns-custom_test
|
||||
- <<: *if-dev-push
|
||||
changes: *patterns-downloadable-tools
|
||||
- <<: *if-dev-push
|
||||
changes: *patterns-target_test-adc
|
||||
- <<: *if-dev-push
|
||||
changes: *patterns-target_test-ecdsa
|
||||
- <<: *if-dev-push
|
||||
changes: *patterns-target_test-i154
|
||||
- <<: *if-dev-push
|
||||
changes: *patterns-target_test-wifi
|
||||
|
||||
.rules:build:custom_test-esp32s2:
|
||||
rules:
|
||||
- <<: *if-revert-branch
|
||||
@@ -1098,8 +1160,10 @@
|
||||
- <<: *if-label-example_test_esp32c3
|
||||
- <<: *if-label-example_test_esp32c6
|
||||
- <<: *if-label-example_test_esp32h2
|
||||
- <<: *if-label-example_test_esp32h4
|
||||
- <<: *if-label-example_test_esp32s2
|
||||
- <<: *if-label-example_test_esp32s3
|
||||
- <<: *if-label-iperf_stress_test
|
||||
- <<: *if-label-target_test
|
||||
- <<: *if-dev-push
|
||||
changes: *patterns-build-example_test
|
||||
@@ -1113,8 +1177,6 @@
|
||||
changes: *patterns-example_test
|
||||
- <<: *if-dev-push
|
||||
changes: *patterns-example_test-bt
|
||||
- <<: *if-dev-push
|
||||
changes: *patterns-example_test-ccs811
|
||||
- <<: *if-dev-push
|
||||
changes: *patterns-example_test-ethernet
|
||||
- <<: *if-dev-push
|
||||
@@ -1143,6 +1205,7 @@
|
||||
- <<: *if-label-build
|
||||
- <<: *if-label-example_test
|
||||
- <<: *if-label-example_test_esp32
|
||||
- <<: *if-label-iperf_stress_test
|
||||
- <<: *if-label-target_test
|
||||
- <<: *if-dev-push
|
||||
changes: *patterns-build-example_test
|
||||
@@ -1156,8 +1219,6 @@
|
||||
changes: *patterns-example_test
|
||||
- <<: *if-dev-push
|
||||
changes: *patterns-example_test-bt
|
||||
- <<: *if-dev-push
|
||||
changes: *patterns-example_test-ccs811
|
||||
- <<: *if-dev-push
|
||||
changes: *patterns-example_test-ethernet
|
||||
- <<: *if-dev-push
|
||||
@@ -1198,8 +1259,6 @@
|
||||
changes: *patterns-example_test
|
||||
- <<: *if-dev-push
|
||||
changes: *patterns-example_test-bt
|
||||
- <<: *if-dev-push
|
||||
changes: *patterns-example_test-ccs811
|
||||
- <<: *if-dev-push
|
||||
changes: *patterns-example_test-ethernet
|
||||
- <<: *if-dev-push
|
||||
@@ -1241,8 +1300,6 @@
|
||||
changes: *patterns-example_test
|
||||
- <<: *if-dev-push
|
||||
changes: *patterns-example_test-bt
|
||||
- <<: *if-dev-push
|
||||
changes: *patterns-example_test-ccs811
|
||||
- <<: *if-dev-push
|
||||
changes: *patterns-example_test-ethernet
|
||||
- <<: *if-dev-push
|
||||
@@ -1283,8 +1340,6 @@
|
||||
changes: *patterns-example_test
|
||||
- <<: *if-dev-push
|
||||
changes: *patterns-example_test-bt
|
||||
- <<: *if-dev-push
|
||||
changes: *patterns-example_test-ccs811
|
||||
- <<: *if-dev-push
|
||||
changes: *patterns-example_test-ethernet
|
||||
- <<: *if-dev-push
|
||||
@@ -1326,7 +1381,45 @@
|
||||
- <<: *if-dev-push
|
||||
changes: *patterns-example_test-bt
|
||||
- <<: *if-dev-push
|
||||
changes: *patterns-example_test-ccs811
|
||||
changes: *patterns-example_test-ethernet
|
||||
- <<: *if-dev-push
|
||||
changes: *patterns-example_test-i154
|
||||
- <<: *if-dev-push
|
||||
changes: *patterns-example_test-sdio
|
||||
- <<: *if-dev-push
|
||||
changes: *patterns-example_test-usb
|
||||
- <<: *if-dev-push
|
||||
changes: *patterns-example_test-wifi
|
||||
- <<: *if-dev-push
|
||||
changes: *patterns-target_test-adc
|
||||
- <<: *if-dev-push
|
||||
changes: *patterns-target_test-ecdsa
|
||||
- <<: *if-dev-push
|
||||
changes: *patterns-target_test-i154
|
||||
- <<: *if-dev-push
|
||||
changes: *patterns-target_test-wifi
|
||||
|
||||
.rules:build:example_test-esp32h4:
|
||||
rules:
|
||||
- <<: *if-revert-branch
|
||||
when: never
|
||||
- <<: *if-protected
|
||||
- <<: *if-label-build
|
||||
- <<: *if-label-example_test
|
||||
- <<: *if-label-example_test_esp32h4
|
||||
- <<: *if-label-target_test
|
||||
- <<: *if-dev-push
|
||||
changes: *patterns-build-example_test
|
||||
- <<: *if-dev-push
|
||||
changes: *patterns-build_components
|
||||
- <<: *if-dev-push
|
||||
changes: *patterns-build_system
|
||||
- <<: *if-dev-push
|
||||
changes: *patterns-downloadable-tools
|
||||
- <<: *if-dev-push
|
||||
changes: *patterns-example_test
|
||||
- <<: *if-dev-push
|
||||
changes: *patterns-example_test-bt
|
||||
- <<: *if-dev-push
|
||||
changes: *patterns-example_test-ethernet
|
||||
- <<: *if-dev-push
|
||||
@@ -1367,8 +1460,6 @@
|
||||
changes: *patterns-example_test
|
||||
- <<: *if-dev-push
|
||||
changes: *patterns-example_test-bt
|
||||
- <<: *if-dev-push
|
||||
changes: *patterns-example_test-ccs811
|
||||
- <<: *if-dev-push
|
||||
changes: *patterns-example_test-ethernet
|
||||
- <<: *if-dev-push
|
||||
@@ -1409,8 +1500,6 @@
|
||||
changes: *patterns-example_test
|
||||
- <<: *if-dev-push
|
||||
changes: *patterns-example_test-bt
|
||||
- <<: *if-dev-push
|
||||
changes: *patterns-example_test-ccs811
|
||||
- <<: *if-dev-push
|
||||
changes: *patterns-example_test-ethernet
|
||||
- <<: *if-dev-push
|
||||
@@ -1430,6 +1519,27 @@
|
||||
- <<: *if-dev-push
|
||||
changes: *patterns-target_test-wifi
|
||||
|
||||
.rules:build:integration_test:
|
||||
rules:
|
||||
- <<: *if-revert-branch
|
||||
when: never
|
||||
- <<: *if-protected
|
||||
- <<: *if-label-build
|
||||
- <<: *if-label-integration_test
|
||||
- <<: *if-label-integration_test_ble
|
||||
- <<: *if-label-integration_test_wifi
|
||||
- <<: *if-label-target_test
|
||||
- <<: *if-dev-push
|
||||
changes: *patterns-build_components
|
||||
- <<: *if-dev-push
|
||||
changes: *patterns-build_system
|
||||
- <<: *if-dev-push
|
||||
changes: *patterns-integration_test-ble
|
||||
- <<: *if-dev-push
|
||||
changes: *patterns-integration_test-wifi
|
||||
- <<: *if-dev-push
|
||||
changes: *patterns-target_test-wifi
|
||||
|
||||
.rules:build:macos:
|
||||
rules:
|
||||
- <<: *if-revert-branch
|
||||
@@ -1456,6 +1566,7 @@
|
||||
- <<: *if-label-component_ut_esp32c3
|
||||
- <<: *if-label-component_ut_esp32c6
|
||||
- <<: *if-label-component_ut_esp32h2
|
||||
- <<: *if-label-component_ut_esp32h4
|
||||
- <<: *if-label-component_ut_esp32s2
|
||||
- <<: *if-label-component_ut_esp32s3
|
||||
- <<: *if-label-custom_test
|
||||
@@ -1464,6 +1575,7 @@
|
||||
- <<: *if-label-custom_test_esp32c3
|
||||
- <<: *if-label-custom_test_esp32c6
|
||||
- <<: *if-label-custom_test_esp32h2
|
||||
- <<: *if-label-custom_test_esp32h4
|
||||
- <<: *if-label-custom_test_esp32s2
|
||||
- <<: *if-label-custom_test_esp32s3
|
||||
- <<: *if-label-example_test
|
||||
@@ -1472,8 +1584,14 @@
|
||||
- <<: *if-label-example_test_esp32c3
|
||||
- <<: *if-label-example_test_esp32c6
|
||||
- <<: *if-label-example_test_esp32h2
|
||||
- <<: *if-label-example_test_esp32h4
|
||||
- <<: *if-label-example_test_esp32s2
|
||||
- <<: *if-label-example_test_esp32s3
|
||||
- <<: *if-label-integration_test
|
||||
- <<: *if-label-integration_test_ble
|
||||
- <<: *if-label-integration_test_wifi
|
||||
- <<: *if-label-iperf_stress_test
|
||||
- <<: *if-label-lan8720
|
||||
- <<: *if-label-target_test
|
||||
- <<: *if-label-unit_test
|
||||
- <<: *if-label-unit_test_esp32
|
||||
@@ -1481,8 +1599,10 @@
|
||||
- <<: *if-label-unit_test_esp32c3
|
||||
- <<: *if-label-unit_test_esp32c6
|
||||
- <<: *if-label-unit_test_esp32h2
|
||||
- <<: *if-label-unit_test_esp32h4
|
||||
- <<: *if-label-unit_test_esp32s2
|
||||
- <<: *if-label-unit_test_esp32s3
|
||||
- <<: *if-label-weekend_test
|
||||
- <<: *if-dev-push
|
||||
changes: *patterns-build-example_test
|
||||
- <<: *if-dev-push
|
||||
@@ -1505,8 +1625,6 @@
|
||||
changes: *patterns-example_test
|
||||
- <<: *if-dev-push
|
||||
changes: *patterns-example_test-bt
|
||||
- <<: *if-dev-push
|
||||
changes: *patterns-example_test-ccs811
|
||||
- <<: *if-dev-push
|
||||
changes: *patterns-example_test-ethernet
|
||||
- <<: *if-dev-push
|
||||
@@ -1517,6 +1635,10 @@
|
||||
changes: *patterns-example_test-usb
|
||||
- <<: *if-dev-push
|
||||
changes: *patterns-example_test-wifi
|
||||
- <<: *if-dev-push
|
||||
changes: *patterns-integration_test-ble
|
||||
- <<: *if-dev-push
|
||||
changes: *patterns-integration_test-wifi
|
||||
- <<: *if-dev-push
|
||||
changes: *patterns-target_test-adc
|
||||
- <<: *if-dev-push
|
||||
@@ -1538,6 +1660,7 @@
|
||||
when: never
|
||||
- <<: *if-protected
|
||||
- <<: *if-label-build
|
||||
- <<: *if-label-lan8720
|
||||
- <<: *if-label-target_test
|
||||
- <<: *if-label-unit_test
|
||||
- <<: *if-label-unit_test_esp32
|
||||
@@ -1545,6 +1668,7 @@
|
||||
- <<: *if-label-unit_test_esp32c3
|
||||
- <<: *if-label-unit_test_esp32c6
|
||||
- <<: *if-label-unit_test_esp32h2
|
||||
- <<: *if-label-unit_test_esp32h4
|
||||
- <<: *if-label-unit_test_esp32s2
|
||||
- <<: *if-label-unit_test_esp32s3
|
||||
- <<: *if-dev-push
|
||||
@@ -1574,6 +1698,7 @@
|
||||
when: never
|
||||
- <<: *if-protected
|
||||
- <<: *if-label-build
|
||||
- <<: *if-label-lan8720
|
||||
- <<: *if-label-target_test
|
||||
- <<: *if-label-unit_test
|
||||
- <<: *if-label-unit_test_esp32
|
||||
@@ -1778,6 +1903,13 @@
|
||||
- <<: *if-dev-push
|
||||
changes: *patterns-unit_test-sdio
|
||||
|
||||
.rules:labels-protected:lan8720:
|
||||
rules:
|
||||
- <<: *if-revert-branch
|
||||
when: never
|
||||
- <<: *if-protected
|
||||
- <<: *if-label-lan8720
|
||||
|
||||
.rules:labels:nvs_coverage:
|
||||
rules:
|
||||
- <<: *if-revert-branch
|
||||
@@ -2294,19 +2426,6 @@
|
||||
- <<: *if-dev-push
|
||||
changes: *patterns-example_test-bt
|
||||
|
||||
.rules:test:example_test-esp32-ccs811:
|
||||
rules:
|
||||
- <<: *if-revert-branch
|
||||
when: never
|
||||
- <<: *if-protected
|
||||
- <<: *if-label-build-only
|
||||
when: never
|
||||
- <<: *if-label-example_test
|
||||
- <<: *if-label-example_test_esp32
|
||||
- <<: *if-label-target_test
|
||||
- <<: *if-dev-push
|
||||
changes: *patterns-example_test-ccs811
|
||||
|
||||
.rules:test:example_test-esp32-ethernet:
|
||||
rules:
|
||||
- <<: *if-revert-branch
|
||||
@@ -2643,6 +2762,52 @@
|
||||
- <<: *if-dev-push
|
||||
changes: *patterns-host_test
|
||||
|
||||
.rules:test:integration_test:
|
||||
rules:
|
||||
- <<: *if-revert-branch
|
||||
when: never
|
||||
- <<: *if-protected
|
||||
- <<: *if-label-build-only
|
||||
when: never
|
||||
- <<: *if-label-integration_test
|
||||
- <<: *if-label-integration_test_ble
|
||||
- <<: *if-label-integration_test_wifi
|
||||
- <<: *if-label-target_test
|
||||
- <<: *if-dev-push
|
||||
changes: *patterns-integration_test-ble
|
||||
- <<: *if-dev-push
|
||||
changes: *patterns-integration_test-wifi
|
||||
- <<: *if-dev-push
|
||||
changes: *patterns-target_test-wifi
|
||||
|
||||
.rules:test:integration_test_ble:
|
||||
rules:
|
||||
- <<: *if-revert-branch
|
||||
when: never
|
||||
- <<: *if-protected
|
||||
- <<: *if-label-build-only
|
||||
when: never
|
||||
- <<: *if-label-integration_test
|
||||
- <<: *if-label-integration_test_ble
|
||||
- <<: *if-label-target_test
|
||||
- <<: *if-dev-push
|
||||
changes: *patterns-integration_test-ble
|
||||
|
||||
.rules:test:integration_test_wifi:
|
||||
rules:
|
||||
- <<: *if-revert-branch
|
||||
when: never
|
||||
- <<: *if-protected
|
||||
- <<: *if-label-build-only
|
||||
when: never
|
||||
- <<: *if-label-integration_test
|
||||
- <<: *if-label-integration_test_wifi
|
||||
- <<: *if-label-target_test
|
||||
- <<: *if-dev-push
|
||||
changes: *patterns-integration_test-wifi
|
||||
- <<: *if-dev-push
|
||||
changes: *patterns-target_test-wifi
|
||||
|
||||
.rules:test:submodule:
|
||||
rules:
|
||||
- <<: *if-revert-branch
|
||||
|
||||
@@ -97,22 +97,6 @@ pytest_examples_esp32_jtag:
|
||||
SETUP_TOOLS: "1" # need gdb openocd
|
||||
PYTEST_EXTRA_FLAGS: "--log-cli-level DEBUG"
|
||||
|
||||
pytest_examples_esp32_ccs811:
|
||||
extends:
|
||||
- .pytest_examples_dir_template
|
||||
- .rules:test:example_test-esp32-ccs811
|
||||
needs:
|
||||
- build_pytest_examples_esp32
|
||||
tags: [ esp32, ccs811 ]
|
||||
|
||||
pytest_examples_esp32_sdio:
|
||||
extends:
|
||||
- .pytest_examples_dir_template
|
||||
- .rules:test:example_test-esp32-sdio
|
||||
needs:
|
||||
- build_pytest_examples_esp32
|
||||
tags: [ esp32, sdio_master_slave ]
|
||||
|
||||
pytest_examples_esp32s2_generic:
|
||||
extends:
|
||||
- .pytest_examples_dir_template
|
||||
@@ -265,14 +249,6 @@ pytest_examples_esp32_ethernet:
|
||||
- build_pytest_examples_esp32
|
||||
tags: [ esp32, ethernet]
|
||||
|
||||
pytest_examples_esp32_ethernet_httpbin:
|
||||
extends:
|
||||
- .pytest_examples_dir_template
|
||||
- .rules:test:example_test-esp32-ethernet
|
||||
needs:
|
||||
- build_pytest_examples_esp32
|
||||
tags: [ esp32, httpbin]
|
||||
|
||||
pytest_examples_esp32_8mb_flash:
|
||||
extends:
|
||||
- .pytest_examples_dir_template
|
||||
@@ -352,6 +328,14 @@ pytest_examples_esp32_ethernet_router:
|
||||
- build_pytest_examples_esp32
|
||||
tags: [ esp32, ethernet_router ]
|
||||
|
||||
pytest_examples_esp32_ethernet_ip101:
|
||||
extends:
|
||||
- .pytest_examples_dir_template
|
||||
- .rules:test:example_test-esp32
|
||||
needs:
|
||||
- build_pytest_examples_esp32
|
||||
tags: [ esp32, ip101 ]
|
||||
|
||||
pytest_examples_esp32_flash_encryption:
|
||||
extends:
|
||||
- .pytest_examples_dir_template
|
||||
@@ -504,14 +488,6 @@ pytest_examples_esp32h2_adc:
|
||||
- build_pytest_examples_esp32h2
|
||||
tags: [ esp32h2, adc ]
|
||||
|
||||
example_test_pytest_esp32s3_emmc:
|
||||
extends:
|
||||
- .pytest_examples_dir_template
|
||||
- .rules:test:example_test-esp32s3
|
||||
needs:
|
||||
- build_pytest_examples_esp32s3
|
||||
tags: [ esp32s3, emmc ]
|
||||
|
||||
.pytest_components_dir_template:
|
||||
extends: .pytest_template
|
||||
variables:
|
||||
@@ -558,61 +534,21 @@ pytest_components_esp32_sdio:
|
||||
- build_pytest_components_esp32
|
||||
tags: [ esp32, sdio_master_slave ]
|
||||
|
||||
pytest_components_esp32_ip101:
|
||||
extends:
|
||||
- .pytest_components_dir_template
|
||||
- .rules:test:component_ut-esp32
|
||||
needs:
|
||||
- build_pytest_components_esp32
|
||||
tags: [ esp32, ip101 ]
|
||||
|
||||
pytest_components_esp32_lan8720:
|
||||
extends:
|
||||
- .pytest_components_dir_template
|
||||
- .rules:test:component_ut-esp32
|
||||
- .rules:labels-protected:lan8720 # FIXME: IDFCI-1176
|
||||
needs:
|
||||
- build_pytest_components_esp32
|
||||
tags: [ esp32, eth_lan8720 ]
|
||||
|
||||
pytest_components_esp32_rtl8201:
|
||||
extends:
|
||||
- .pytest_components_dir_template
|
||||
- .rules:test:component_ut-esp32
|
||||
needs:
|
||||
- build_pytest_components_esp32
|
||||
tags: [ esp32, eth_rtl8201 ]
|
||||
|
||||
pytest_components_esp32_w5500:
|
||||
extends:
|
||||
- .pytest_components_dir_template
|
||||
- .rules:test:component_ut-esp32
|
||||
needs:
|
||||
- build_pytest_components_esp32
|
||||
tags: [ esp32, eth_w5500 ]
|
||||
|
||||
pytest_components_esp32_ksz8851snl:
|
||||
extends:
|
||||
- .pytest_components_dir_template
|
||||
- .rules:test:component_ut-esp32
|
||||
needs:
|
||||
- build_pytest_components_esp32
|
||||
tags: [ esp32, eth_ksz8851snl ]
|
||||
|
||||
pytest_components_esp32_dm9051:
|
||||
extends:
|
||||
- .pytest_components_dir_template
|
||||
- .rules:test:component_ut-esp32
|
||||
needs:
|
||||
- build_pytest_components_esp32
|
||||
tags: [ esp32, eth_dm9051 ]
|
||||
|
||||
pytest_components_esp32_ksz8041:
|
||||
extends:
|
||||
- .pytest_components_dir_template
|
||||
- .rules:test:component_ut-esp32
|
||||
needs:
|
||||
- build_pytest_components_esp32
|
||||
tags: [ esp32, eth_ksz8041 ]
|
||||
|
||||
pytest_components_esp32_dp83848:
|
||||
extends:
|
||||
- .pytest_components_dir_template
|
||||
- .rules:test:component_ut-esp32
|
||||
needs:
|
||||
- build_pytest_components_esp32
|
||||
tags: [ esp32, eth_dp83848 ]
|
||||
tags: [ esp32, lan8720 ]
|
||||
|
||||
pytest_components_esp32_ethernet:
|
||||
extends:
|
||||
@@ -1162,6 +1098,12 @@ example_test_001C:
|
||||
- ESP32
|
||||
- Example_GENERIC
|
||||
|
||||
.example_test_003:
|
||||
extends: .example_test_esp32_template
|
||||
tags:
|
||||
- ESP32
|
||||
- Example_SDIO
|
||||
|
||||
example_test_005:
|
||||
extends:
|
||||
- .example_test_esp32_template
|
||||
@@ -1170,6 +1112,12 @@ example_test_005:
|
||||
- ESP32
|
||||
- Example_WIFI_BT
|
||||
|
||||
example_test_007:
|
||||
extends: .example_test_esp32_template
|
||||
tags:
|
||||
- ESP32
|
||||
- Example_I2C_CCS811_SENSOR
|
||||
|
||||
example_test_C3_GENERIC:
|
||||
extends: .example_test_esp32c3_template
|
||||
tags:
|
||||
@@ -1263,12 +1211,19 @@ UT_006:
|
||||
- UT_T1_SPIMODE
|
||||
- psram
|
||||
|
||||
.UT_017:
|
||||
UT_017:
|
||||
extends: .unit_test_esp32_template
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- EMMC
|
||||
|
||||
UT_022:
|
||||
extends: .unit_test_esp32_template
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- UT_T2_I2C
|
||||
- psram
|
||||
|
||||
UT_028:
|
||||
extends: .unit_test_esp32_template
|
||||
tags:
|
||||
@@ -1341,6 +1296,12 @@ UT_C3_FLASH:
|
||||
- ESP32C3_IDF
|
||||
- UT_T1_ESP_FLASH
|
||||
|
||||
UT_C3_I2C:
|
||||
extends: .unit_test_esp32c3_template
|
||||
tags:
|
||||
- ESP32C3_IDF
|
||||
- UT_T2_I2C
|
||||
|
||||
UT_C3_SDSPI:
|
||||
extends:
|
||||
- .unit_test_esp32c3_template
|
||||
@@ -1384,3 +1345,301 @@ UT_S3_QUAD_PSRAM:
|
||||
- ESP32S3_IDF
|
||||
- UT_T1_1
|
||||
- quad_psram
|
||||
|
||||
.integration_test_template:
|
||||
extends:
|
||||
- .target_test_job_template
|
||||
- .rules:test:integration_test
|
||||
- .before_script_minimal
|
||||
image: ${CI_INTEGRATION_TEST_ENV_IMAGE}
|
||||
cache: []
|
||||
needs: # the assign already needs all the build jobs
|
||||
- assign_integration_test
|
||||
variables:
|
||||
LOCAL_ENV_CONFIG_PATH: "$CI_PROJECT_DIR/ci-test-runner-configs/$CI_RUNNER_DESCRIPTION/ESP32_IDF"
|
||||
LOG_PATH: "${CI_PROJECT_DIR}/TEST_LOGS"
|
||||
TEST_CASE_FILE_PATH: "$CI_PROJECT_DIR/auto_test_script/TestCaseFiles"
|
||||
CONFIG_FILE_PATH: "${CI_PROJECT_DIR}/tools/ci/integration_test/test_configs"
|
||||
KNOWN_ISSUE_FILE: "${CI_PROJECT_DIR}/tools/ci/integration_test/KnownIssues"
|
||||
CI_RUNNER_SCRIPT: "${CI_PROJECT_DIR}/auto_test_script/bin/CIRunner.py"
|
||||
PREPARE_TEST_BIN_SCRIPT: "${CI_PROJECT_DIR}/auto_test_script/tools/ci/idf_prepare_test_bins.py"
|
||||
PYTHONPATH: "${CI_PROJECT_DIR}/auto_test_script/packages:${CI_PROJECT_DIR}/tools/ci/python_packages:${PYTHONPATH}"
|
||||
INITIAL_CONDITION_RETRY_COUNT: "1"
|
||||
GIT_LFS_SKIP_SMUDGE: 1
|
||||
script:
|
||||
- *define_config_file_name
|
||||
# first test if config file exists, if not exist, exit 0
|
||||
- test -e $CONFIG_FILE || exit 0
|
||||
# clone local test env configs
|
||||
- add_gitlab_ssh_keys
|
||||
- retry_failed git clone $TEST_ENV_CONFIG_REPO
|
||||
- python $CHECKOUT_REF_SCRIPT ci-test-runner-configs ci-test-runner-configs
|
||||
# clone test bench
|
||||
- retry_failed git clone ${CI_AUTO_TEST_SCRIPT_REPO_URL} auto_test_script
|
||||
- python $CHECKOUT_REF_SCRIPT auto_test_script auto_test_script
|
||||
- cd auto_test_script
|
||||
- ./tools/ci/setup_idfci.sh
|
||||
# Merge known issues
|
||||
- cat ${KNOWN_ISSUE_FILE} >> ${TEST_CASE_FILE_PATH}/KnownIssues
|
||||
# run test
|
||||
- python ${PREPARE_TEST_BIN_SCRIPT} $CONFIG_FILE
|
||||
- python ${CI_RUNNER_SCRIPT} -l "$LOG_PATH/$JOB_FULL_NAME" -c $CONFIG_FILE -e $LOCAL_ENV_CONFIG_PATH -t $TEST_CASE_FILE_PATH
|
||||
|
||||
.integration_test_esp32c3_template:
|
||||
extends:
|
||||
- .integration_test_template
|
||||
variables:
|
||||
LOCAL_ENV_CONFIG_PATH: "$CI_PROJECT_DIR/ci-test-runner-configs/$CI_RUNNER_DESCRIPTION/ESP32C3_IDF"
|
||||
|
||||
.integration_test_esp32c2_template:
|
||||
extends:
|
||||
- .integration_test_template
|
||||
variables:
|
||||
LOCAL_ENV_CONFIG_PATH: "$CI_PROJECT_DIR/ci-test-runner-configs/$CI_RUNNER_DESCRIPTION/ESP32C2_IDF"
|
||||
|
||||
nvs_compatible_test:
|
||||
extends:
|
||||
- .integration_test_template
|
||||
- .rules:test:integration_test
|
||||
artifacts:
|
||||
when: always
|
||||
paths:
|
||||
- $LOG_PATH
|
||||
- nvs_wifi.bin
|
||||
expire_in: 1 mos
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- NVS_Compatible
|
||||
script:
|
||||
- *define_config_file_name
|
||||
# first test if config file exists, if not exist, exit 0
|
||||
- test -e $CONFIG_FILE || exit 0
|
||||
# clone local test env configs
|
||||
- add_gitlab_ssh_keys
|
||||
- retry_failed git clone $TEST_ENV_CONFIG_REPO
|
||||
- python $CHECKOUT_REF_SCRIPT ci-test-runner-configs ci-test-runner-configs
|
||||
# clone test bench
|
||||
- retry_failed git clone ${CI_AUTO_TEST_SCRIPT_REPO_URL} auto_test_script
|
||||
- python $CHECKOUT_REF_SCRIPT auto_test_script auto_test_script
|
||||
- cd auto_test_script
|
||||
- ./tools/ci/setup_idfci.sh
|
||||
# prepare nvs bins
|
||||
- ./tools/prepare_nvs_bin.sh
|
||||
# run test
|
||||
- python ${PREPARE_TEST_BIN_SCRIPT} $CONFIG_FILE
|
||||
- python ${CI_RUNNER_SCRIPT} -l "$LOG_PATH/$JOB_FULL_NAME" -c $CONFIG_FILE -e $LOCAL_ENV_CONFIG_PATH -t $TEST_CASE_FILE_PATH
|
||||
|
||||
IT_T1_Simple:
|
||||
extends:
|
||||
- .integration_test_template
|
||||
- .rules:test:integration_test_wifi
|
||||
parallel: 2
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- SSC_T1_Simple
|
||||
|
||||
IT_T1_WAP:
|
||||
extends:
|
||||
- .integration_test_template
|
||||
- .rules:test:integration_test_wifi
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- SSC_T1_WAP
|
||||
|
||||
IT_T2_Simple:
|
||||
extends:
|
||||
- .integration_test_template
|
||||
- .rules:test:integration_test_wifi
|
||||
parallel: 9
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- SSC_T2_Simple
|
||||
|
||||
IT_T5_BT_Simple:
|
||||
extends:
|
||||
- .integration_test_template
|
||||
- .rules:test:integration_test_ble
|
||||
parallel: 3
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- SSC_T5_BT_Simple
|
||||
|
||||
IT_T2_BT_Simple:
|
||||
extends:
|
||||
- .integration_test_template
|
||||
- .rules:test:integration_test_ble
|
||||
parallel: 6
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- SSC_T2_BT_Simple
|
||||
|
||||
IT_T1_BT_Dongle:
|
||||
extends:
|
||||
- .integration_test_template
|
||||
- .rules:test:integration_test_ble
|
||||
parallel: 2
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- SSC_T1_BT_Dongle
|
||||
|
||||
IT_T1_AP:
|
||||
extends:
|
||||
- .integration_test_template
|
||||
- .rules:test:integration_test_wifi
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- SSC_T1_AP
|
||||
|
||||
IT_T1_AP_E:
|
||||
extends:
|
||||
- .integration_test_template
|
||||
- .rules:test:integration_test_wifi
|
||||
parallel: 5
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- SSC_T1_AP_E
|
||||
|
||||
IT_T1_WNIC_AP:
|
||||
extends:
|
||||
- .integration_test_template
|
||||
- .rules:test:integration_test_wifi
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- SSC_T1_WNIC_AP
|
||||
|
||||
IT_T1_WNIC_AP_E:
|
||||
extends:
|
||||
- .integration_test_template
|
||||
- .rules:test:integration_test_wifi
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- SSC_T1_WNIC_AP_E
|
||||
|
||||
IT_T1_MESH1:
|
||||
extends:
|
||||
- .integration_test_template
|
||||
- .rules:test:integration_test_wifi
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- SSC_T1_MESH1
|
||||
|
||||
IT_T2_MESH1:
|
||||
extends:
|
||||
- .integration_test_template
|
||||
- .rules:test:integration_test_wifi
|
||||
parallel: 2
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- SSC_T2_MESH1
|
||||
|
||||
IT_T3_MESH1:
|
||||
extends:
|
||||
- .integration_test_template
|
||||
- .rules:test:integration_test_wifi
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- SSC_T3_MESH1
|
||||
|
||||
IT_T6_MESH1:
|
||||
extends:
|
||||
- .integration_test_template
|
||||
- .rules:test:integration_test_wifi
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- SSC_T6_MESH1
|
||||
|
||||
IT_T12_MESH1:
|
||||
extends:
|
||||
- .integration_test_template
|
||||
- .rules:test:integration_test_wifi
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- SSC_T12_MESH1
|
||||
|
||||
IT_T50_MESH1:
|
||||
extends:
|
||||
- .integration_test_template
|
||||
- .rules:test:integration_test_wifi
|
||||
allow_failure: true
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- SSC_T50_MESH1
|
||||
|
||||
IT_T1_MESH2:
|
||||
extends:
|
||||
- .integration_test_template
|
||||
- .rules:test:integration_test_wifi
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- SSC_T1_MESH2
|
||||
|
||||
IT_T2_WNIC:
|
||||
extends:
|
||||
- .integration_test_template
|
||||
- .rules:test:integration_test_wifi
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- SSC_T2_WNIC
|
||||
|
||||
IT_T2_AP:
|
||||
extends:
|
||||
- .integration_test_template
|
||||
- .rules:test:integration_test_wifi
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- SSC_T2_AP
|
||||
|
||||
IT_T3_Simple:
|
||||
extends:
|
||||
- .integration_test_template
|
||||
- .rules:test:integration_test_wifi
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- SSC_T3_Simple
|
||||
|
||||
IT_C3_T2_BT_Simple:
|
||||
extends:
|
||||
- .integration_test_esp32c3_template
|
||||
- .rules:test:integration_test_ble
|
||||
parallel: 11
|
||||
tags:
|
||||
- ESP32C3_IDF
|
||||
- SSC_T2_BT_Simple
|
||||
|
||||
IT_C3_T5_BT_Simple:
|
||||
extends:
|
||||
- .integration_test_esp32c3_template
|
||||
- .rules:test:integration_test_ble
|
||||
parallel: 5
|
||||
tags:
|
||||
- ESP32C3_IDF
|
||||
- SSC_T5_BT_Simple
|
||||
|
||||
IT_C3_T1_BT_Dongle:
|
||||
extends:
|
||||
- .integration_test_esp32c3_template
|
||||
- .rules:test:integration_test_ble
|
||||
image: gitlab.espressif.cn:5050/qa/dockerfiles/integration-test-env-dbg:1
|
||||
parallel: 2
|
||||
tags:
|
||||
- ESP32C3_IDF
|
||||
- SSC_T1_BT_Dongle
|
||||
|
||||
IT_C2_T2_BT_Simple:
|
||||
extends:
|
||||
- .integration_test_esp32c2_template
|
||||
- .rules:test:integration_test_ble
|
||||
parallel: 9
|
||||
tags:
|
||||
- ESP32C2_IDF
|
||||
- SSC_T2_BT_Simple
|
||||
|
||||
IT_C2_T1_BT_Dongle:
|
||||
extends:
|
||||
- .integration_test_esp32c2_template
|
||||
- .rules:test:integration_test_ble
|
||||
image: gitlab.espressif.cn:5050/qa/dockerfiles/integration-test-env-dbg:1
|
||||
parallel: 2
|
||||
tags:
|
||||
- ESP32C2_IDF
|
||||
- SSC_T1_BT_Dongle
|
||||
|
||||
57
.gitmodules
vendored
57
.gitmodules
vendored
@@ -2,26 +2,6 @@
|
||||
# All the relative URL paths are intended to be GitHub ones
|
||||
# For Espressif's public projects please use '../../espressif/proj', not a '../proj'
|
||||
#
|
||||
# Submodules SBOM information
|
||||
# ---------------------------
|
||||
# Submodules, which are used directly and not forked into espressif namespace should
|
||||
# contain SBOM information here. Other submodules should have the SBOM manifest file
|
||||
# included in the root of their project's repository.
|
||||
#
|
||||
# The sbom-hash entry records the submodule's checkout SHA as presented in git-tree
|
||||
# commit object. For example spiffs submodule
|
||||
#
|
||||
# $ git ls-tree HEAD components/spiffs/spiffs
|
||||
# 160000 commit 0dbb3f71c5f6fae3747a9d935372773762baf852 components/spiffs/spiffs
|
||||
#
|
||||
# The hash can be also obtained with git submodule command
|
||||
#
|
||||
# $ git submodule status components/spiffs/spiffs
|
||||
# 0dbb3f71c5f6fae3747a9d935372773762baf852 components/spiffs/spiffs (0.2-255-g0dbb3f71c5f6)
|
||||
#
|
||||
# The submodule SHA recorded here has to match with SHA, which is presented in git-tree.
|
||||
# This is checked by CI. Also please don't forget to update the submodule version
|
||||
# if you are changing the sbom-hash. This is important for SBOM generation.
|
||||
|
||||
[submodule "components/bt/controller/lib_esp32"]
|
||||
path = components/bt/controller/lib_esp32
|
||||
@@ -30,31 +10,14 @@
|
||||
[submodule "components/bootloader/subproject/components/micro-ecc/micro-ecc"]
|
||||
path = components/bootloader/subproject/components/micro-ecc/micro-ecc
|
||||
url = ../../kmackay/micro-ecc.git
|
||||
sbom-version = 1.1
|
||||
sbom-cpe = cpe:2.3:a:micro-ecc_project:micro-ecc:{}:*:*:*:*:*:*:*
|
||||
sbom-supplier = Person: Ken MacKay
|
||||
sbom-url = https://github.com/kmackay/micro-ecc
|
||||
sbom-description = A small and fast ECDH and ECDSA implementation for 8-bit, 32-bit, and 64-bit processors
|
||||
sbom-hash = 24c60e243580c7868f4334a1ba3123481fe1aa48
|
||||
|
||||
[submodule "components/spiffs/spiffs"]
|
||||
path = components/spiffs/spiffs
|
||||
url = ../../pellepl/spiffs.git
|
||||
sbom-version = 0.2-255-g0dbb3f71c5f6
|
||||
sbom-supplier = Person: Peter Andersson
|
||||
sbom-url = https://github.com/pellepl/spiffs
|
||||
sbom-description = Wear-leveled SPI flash file system for embedded devices
|
||||
sbom-hash = 0dbb3f71c5f6fae3747a9d935372773762baf852
|
||||
|
||||
[submodule "components/json/cJSON"]
|
||||
path = components/json/cJSON
|
||||
url = ../../DaveGamble/cJSON.git
|
||||
sbom-version = 1.7.17
|
||||
sbom-cpe = cpe:2.3:a:cjson_project:cjson:{}:*:*:*:*:*:*:*
|
||||
sbom-supplier = Person: Dave Gamble
|
||||
sbom-url = https://github.com/DaveGamble/cJSON
|
||||
sbom-description = Ultralightweight JSON parser in ANSI C
|
||||
sbom-hash = 87d8f0961a01bf09bef98ff89bae9fdec42181ee
|
||||
|
||||
[submodule "components/mbedtls/mbedtls"]
|
||||
path = components/mbedtls/mbedtls
|
||||
@@ -71,21 +34,10 @@
|
||||
[submodule "components/protobuf-c/protobuf-c"]
|
||||
path = components/protobuf-c/protobuf-c
|
||||
url = ../../protobuf-c/protobuf-c.git
|
||||
sbom-version = 1.4.1
|
||||
sbom-cpe = cpe:2.3:a:protobuf-c_project:protobuf-c:{}:*:*:*:*:*:*:*
|
||||
sbom-supplier = Organization: protobuf-c community <https://groups.google.com/g/protobuf-c>
|
||||
sbom-url = https://github.com/protobuf-c/protobuf-c
|
||||
sbom-description = Protocol Buffers implementation in C
|
||||
sbom-hash = abc67a11c6db271bedbb9f58be85d6f4e2ea8389
|
||||
|
||||
[submodule "components/unity/unity"]
|
||||
path = components/unity/unity
|
||||
url = ../../ThrowTheSwitch/Unity.git
|
||||
sbom-version = v2.4.3-51-g7d2bf62b7e6a
|
||||
sbom-supplier = Organization: ThrowTheSwitch community <http://www.throwtheswitch.org>
|
||||
sbom-url = https://github.com/ThrowTheSwitch/Unity
|
||||
sbom-description = Simple Unit Testing for C
|
||||
sbom-hash = 7d2bf62b7e6afaf38153041a9d53c21aeeca9a25
|
||||
|
||||
[submodule "components/bt/host/nimble/nimble"]
|
||||
path = components/bt/host/nimble/nimble
|
||||
@@ -98,11 +50,6 @@
|
||||
[submodule "components/cmock/CMock"]
|
||||
path = components/cmock/CMock
|
||||
url = ../../ThrowTheSwitch/CMock.git
|
||||
sbom-version = v2.5.2-2-geeecc49ce8af
|
||||
sbom-supplier = Organization: ThrowTheSwitch community <http://www.throwtheswitch.org>
|
||||
sbom-url = https://github.com/ThrowTheSwitch/CMock
|
||||
sbom-description = CMock - Mock/stub generator for C
|
||||
sbom-hash = eeecc49ce8af123cf8ad40efdb9673e37b56230f
|
||||
|
||||
[submodule "components/openthread/openthread"]
|
||||
path = components/openthread/openthread
|
||||
@@ -120,6 +67,10 @@
|
||||
path = components/openthread/lib
|
||||
url = ../../espressif/esp-thread-lib.git
|
||||
|
||||
[submodule "components/ieee802154/lib"]
|
||||
path = components/ieee802154/lib
|
||||
url = ../../espressif/esp-ieee802154-lib.git
|
||||
|
||||
[submodule "components/bt/controller/lib_esp32h2/esp32h2-bt-lib"]
|
||||
path = components/bt/controller/lib_esp32h2/esp32h2-bt-lib
|
||||
url = ../../espressif/esp32h2-bt-lib.git
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
# See https://pre-commit.com for more information
|
||||
# See https://pre-commit.com/hooks.html for more hooks
|
||||
|
||||
default_stages: [commit]
|
||||
|
||||
repos:
|
||||
- repo: https://github.com/pre-commit/pre-commit-hooks
|
||||
rev: v4.0.1
|
||||
@@ -141,8 +139,7 @@ repos:
|
||||
name: Check if all apps readme files match given .build-test-rules.yml files. Modify the supported target tables
|
||||
entry: tools/ci/check_build_test_rules.py check-readmes
|
||||
language: python
|
||||
files: 'tools/test_apps/.+|examples/.+|components/.+|tools/idf_py_actions/constants.py|tools/ci/check_build_test_rules.py'
|
||||
require_serial: true
|
||||
files: 'tools/test_apps/.+|examples/.+|components/.+'
|
||||
additional_dependencies:
|
||||
- PyYAML == 5.3.1
|
||||
- idf_build_apps
|
||||
@@ -160,12 +157,7 @@ repos:
|
||||
- id: file-contents-sorter
|
||||
files: 'tools\/ci\/(executable-list\.txt|mypy_ignore_list\.txt|check_copyright_ignore\.txt)'
|
||||
- repo: https://github.com/espressif/check-copyright/
|
||||
rev: v1.0.3
|
||||
rev: v1.0.1
|
||||
hooks:
|
||||
- id: check-copyright
|
||||
args: ['--ignore', 'tools/ci/check_copyright_ignore.txt', '--config', 'tools/ci/check_copyright_config.yaml']
|
||||
- repo: https://github.com/espressif/esp-idf-sbom.git
|
||||
rev: v0.13.0
|
||||
hooks:
|
||||
- id: validate-sbom-manifest
|
||||
stages: [post-commit]
|
||||
|
||||
24
Kconfig
24
Kconfig
@@ -66,6 +66,28 @@ mainmenu "Espressif IoT Development Framework Configuration"
|
||||
select FREERTOS_UNICORE
|
||||
select IDF_TARGET_ARCH_RISCV
|
||||
|
||||
config IDF_TARGET_ESP32H4
|
||||
bool
|
||||
default "y" if IDF_TARGET="esp32h4"
|
||||
select FREERTOS_UNICORE
|
||||
select IDF_TARGET_ARCH_RISCV
|
||||
|
||||
choice IDF_TARGET_ESP32H4_BETA_VERSION
|
||||
prompt "ESP32-H4 beta version"
|
||||
depends on IDF_TARGET_ESP32H4
|
||||
default IDF_TARGET_ESP32H4_BETA_VERSION_2
|
||||
help
|
||||
Currently ESP32-H4 has several beta versions for internal use only.
|
||||
Select the one that matches your chip model.
|
||||
|
||||
config IDF_TARGET_ESP32H4_BETA_VERSION_1
|
||||
bool
|
||||
prompt "ESP32-H4 beta1"
|
||||
config IDF_TARGET_ESP32H4_BETA_VERSION_2
|
||||
bool
|
||||
prompt "ESP32-H4 beta2"
|
||||
endchoice
|
||||
|
||||
config IDF_TARGET_ESP32C2
|
||||
bool
|
||||
default "y" if IDF_TARGET="esp32c2"
|
||||
@@ -94,8 +116,10 @@ mainmenu "Espressif IoT Development Framework Configuration"
|
||||
default 0x0002 if IDF_TARGET_ESP32S2
|
||||
default 0x0005 if IDF_TARGET_ESP32C3
|
||||
default 0x0009 if IDF_TARGET_ESP32S3
|
||||
default 0x000A if IDF_TARGET_ESP32H4_BETA_VERSION_1
|
||||
default 0x000C if IDF_TARGET_ESP32C2
|
||||
default 0x000D if IDF_TARGET_ESP32C6
|
||||
default 0x000E if IDF_TARGET_ESP32H4_BETA_VERSION_2 # ESP32-TODO: IDF-3475
|
||||
default 0x0010 if IDF_TARGET_ESP32H2
|
||||
default 0xFFFF
|
||||
|
||||
|
||||
@@ -389,11 +389,4 @@ menu "Application Level Tracing"
|
||||
help
|
||||
Enables support for GCOV data transfer to host.
|
||||
|
||||
config APPTRACE_GCOV_DUMP_TASK_STACK_SIZE
|
||||
int "Gcov dump task stack size"
|
||||
depends on APPTRACE_GCOV_ENABLE
|
||||
default 2048
|
||||
help
|
||||
Configures stack size of Gcov dump task
|
||||
|
||||
endmenu
|
||||
|
||||
@@ -76,8 +76,7 @@ gcov_exit:
|
||||
void gcov_create_task(void *arg)
|
||||
{
|
||||
ESP_EARLY_LOGV(TAG, "%s", __FUNCTION__);
|
||||
xTaskCreatePinnedToCore(&gcov_dump_task, "gcov_dump_task", CONFIG_APPTRACE_GCOV_DUMP_TASK_STACK_SIZE,
|
||||
(void *)&s_gcov_task_running, configMAX_PRIORITIES - 1, NULL, 0);
|
||||
xTaskCreatePinnedToCore(&gcov_dump_task, "gcov_dump_task", 2048, (void *)&s_gcov_task_running, configMAX_PRIORITIES - 1, NULL, 0);
|
||||
}
|
||||
|
||||
void gcov_create_task_tick_hook(void)
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
#define HEAP_TRACE_SRCFILE /* don't warn on inclusion here */
|
||||
#include "esp_heap_trace.h"
|
||||
#undef HEAP_TRACE_SRCFILE
|
||||
#include "esp_heap_caps.h"
|
||||
|
||||
#if CONFIG_APPTRACE_SV_ENABLE
|
||||
#include "esp_app_trace.h"
|
||||
#include "esp_sysview_trace.h"
|
||||
@@ -85,7 +85,7 @@ void heap_trace_dump_caps(__attribute__((unused)) const uint32_t caps)
|
||||
}
|
||||
|
||||
/* Add a new allocation to the heap trace records */
|
||||
static HEAP_IRAM_ATTR void record_allocation(const heap_trace_record_t *record)
|
||||
static IRAM_ATTR void record_allocation(const heap_trace_record_t *record)
|
||||
{
|
||||
if (!s_tracing) {
|
||||
return;
|
||||
@@ -100,7 +100,7 @@ static HEAP_IRAM_ATTR void record_allocation(const heap_trace_record_t *record)
|
||||
For HEAP_TRACE_ALL, this means filling in the freed_by pointer.
|
||||
For HEAP_TRACE_LEAKS, this means removing the record from the log.
|
||||
*/
|
||||
static HEAP_IRAM_ATTR void record_free(void *p, void **callers)
|
||||
static IRAM_ATTR void record_free(void *p, void **callers)
|
||||
{
|
||||
if (!s_tracing) {
|
||||
return;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2017-2023 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2017-2021 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -228,11 +228,8 @@ size_t esp_apptrace_fwrite(esp_apptrace_dest_t dest, const void *ptr, size_t siz
|
||||
ESP_EARLY_LOGE(TAG, "Failed to read response (%d)!", ret);
|
||||
return 0;
|
||||
}
|
||||
/* OpenOCD writes it like that:
|
||||
* fwrite(buf, size, 1, file);
|
||||
* So, if 1 was returned that means fwrite succeed
|
||||
*/
|
||||
return resp == 1 ? nmemb : 0;
|
||||
|
||||
return resp/size; // return the number of items written
|
||||
}
|
||||
|
||||
static void esp_apptrace_fread_args_prepare(uint8_t *buf, void *priv)
|
||||
@@ -278,10 +275,6 @@ size_t esp_apptrace_fread(esp_apptrace_dest_t dest, void *ptr, size_t size, size
|
||||
ESP_EARLY_LOGE(TAG, "Failed to read file data (%d)!", ret);
|
||||
return 0;
|
||||
}
|
||||
/* OpenOCD reads it like that:
|
||||
* fread(buf, 1 ,size, file);
|
||||
* So, total read bytes count returns
|
||||
*/
|
||||
return resp/size; // return the number of items read
|
||||
}
|
||||
|
||||
|
||||
@@ -37,6 +37,8 @@
|
||||
#include "esp32c3/rom/secure_boot.h"
|
||||
#elif CONFIG_IDF_TARGET_ESP32S3
|
||||
#include "esp32s3/rom/secure_boot.h"
|
||||
#elif CONFIG_IDF_TARGET_ESP32H4
|
||||
#include "esp32h4/rom/secure_boot.h"
|
||||
#elif CONFIG_IDF_TARGET_ESP32C2
|
||||
#include "esp32c2/rom/secure_boot.h"
|
||||
#elif CONFIG_IDF_TARGET_ESP32C6
|
||||
@@ -195,18 +197,13 @@ esp_err_t esp_ota_write(esp_ota_handle_t handle, const void *data, size_t size)
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
if (size == 0) {
|
||||
ESP_LOGD(TAG, "write data size is 0");
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
// find ota handle in linked list
|
||||
for (it = LIST_FIRST(&s_ota_ops_entries_head); it != NULL; it = LIST_NEXT(it, entries)) {
|
||||
if (it->handle == handle) {
|
||||
if (it->need_erase) {
|
||||
// must erase the partition before writing to it
|
||||
uint32_t first_sector = it->wrote_size / SPI_FLASH_SEC_SIZE; // first affected sector
|
||||
uint32_t last_sector = (it->wrote_size + size - 1) / SPI_FLASH_SEC_SIZE; // last affected sector
|
||||
uint32_t first_sector = it->wrote_size / SPI_FLASH_SEC_SIZE;
|
||||
uint32_t last_sector = (it->wrote_size + size) / SPI_FLASH_SEC_SIZE;
|
||||
|
||||
ret = ESP_OK;
|
||||
if ((it->wrote_size % SPI_FLASH_SEC_SIZE) == 0) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -110,7 +110,7 @@ esp_err_t esp_ota_begin(const esp_partition_t* partition, size_t image_size, esp
|
||||
* @param size Size of data buffer in bytes.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: Data was written to flash successfully, or size = 0
|
||||
* - ESP_OK: Data was written to flash successfully.
|
||||
* - ESP_ERR_INVALID_ARG: handle is invalid.
|
||||
* - ESP_ERR_OTA_VALIDATE_FAILED: First byte of image contains invalid app image magic byte.
|
||||
* - ESP_ERR_FLASH_OP_TIMEOUT or ESP_ERR_FLASH_OP_FAIL: Flash write failed.
|
||||
@@ -334,7 +334,7 @@ typedef enum {
|
||||
/**
|
||||
* @brief Revokes the old signature digest. To be called in the application after the rollback logic.
|
||||
*
|
||||
* Relevant for Secure boot v2 on ESP32-S2, ESP32-S3, ESP32-C3, ESP32-C6, ESP32-H2 where upto 3 key digests can be stored (Key \#N-1, Key \#N, Key \#N+1).
|
||||
* Relevant for Secure boot v2 on ESP32-S2, ESP32-S3, ESP32-C3, ESP32-H4 where upto 3 key digests can be stored (Key \#N-1, Key \#N, Key \#N+1).
|
||||
* When key \#N-1 used to sign an app is invalidated, an OTA update is to be sent with an app signed with key \#N-1 & Key \#N.
|
||||
* After successfully booting the OTA app should call this function to revoke Key \#N-1.
|
||||
*
|
||||
|
||||
@@ -704,12 +704,14 @@ menu "Security features"
|
||||
|
||||
config SECURE_BOOT_VERIFICATION_KEY
|
||||
string "Secure boot public signature verification key"
|
||||
depends on SECURE_SIGNED_APPS && SECURE_SIGNED_APPS_ECDSA_SCHEME && !SECURE_BOOT_BUILD_SIGNED_BINARIES
|
||||
depends on SECURE_SIGNED_APPS && !SECURE_BOOT_BUILD_SIGNED_BINARIES && !SECURE_SIGNED_APPS_RSA_SCHEME
|
||||
default "signature_verification_key.bin"
|
||||
help
|
||||
Path to a public key file used to verify signed images.
|
||||
Secure Boot V1: This ECDSA public key is compiled into the bootloader and/or
|
||||
app, to verify app images.
|
||||
Secure Boot V2: This RSA public key is compiled into the signature block at
|
||||
the end of the bootloader/app.
|
||||
|
||||
Key file is in raw binary format, and can be extracted from a
|
||||
PEM formatted private key using the espsecure.py
|
||||
|
||||
@@ -148,5 +148,5 @@ endif()
|
||||
#
|
||||
# So for now we just have the top-level build remove the final build products...
|
||||
set_property(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" APPEND PROPERTY
|
||||
ADDITIONAL_CLEAN_FILES
|
||||
ADDITIONAL_MAKE_CLEAN_FILES
|
||||
${bootloader_binary_files})
|
||||
|
||||
@@ -25,7 +25,7 @@ MEMORY
|
||||
*/
|
||||
iram_seg (RWX) : org = 0x40080400, len = 0xfc00
|
||||
/* 64k at the end of DRAM, after ROM bootloader stack */
|
||||
dram_seg (RW) : org = 0x3FFF0000, len = 0x6000
|
||||
dram_seg (RW) : org = 0x3FFF0000, len = 0x10000
|
||||
}
|
||||
|
||||
/* Default entry point: */
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
PROVIDE ( ets_update_cpu_frequency = 0x40008550 ); /* Updates g_ticks_per_us on the current CPU only; not on the other core */
|
||||
PROVIDE ( MD5Final = 0x4005db1c );
|
||||
PROVIDE ( MD5Init = 0x4005da7c );
|
||||
PROVIDE ( MD5Update = 0x4005da9c );
|
||||
|
||||
/* bootloader will use following functions from xtensa hal library */
|
||||
xthal_get_ccount = 0x4000c050;
|
||||
xthal_get_ccompare = 0x4000c078;
|
||||
xthal_set_ccompare = 0x4000c058;
|
||||
|
||||
240
components/bootloader/subproject/main/ld/esp32h4/bootloader.ld
Normal file
240
components/bootloader/subproject/main/ld/esp32h4/bootloader.ld
Normal file
@@ -0,0 +1,240 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
/** Simplified memory map for the bootloader.
|
||||
* Make sure the bootloader can load into main memory without overwriting itself.
|
||||
*
|
||||
* ESP32-H4 ROM static data usage is as follows:
|
||||
* - 0x3fccb900 - 0x3fcdd210: Shared buffers, used in UART/USB/SPI download mode only
|
||||
* - 0x3fcdd210 - 0x3fcdf210: PRO CPU stack, can be reclaimed as heap after RTOS startup
|
||||
* - 0x3fcdf210 - 0x3fce0000: ROM .bss and .data (not easily reclaimable)
|
||||
*
|
||||
* The 2nd stage bootloader can take space up to the end of ROM shared
|
||||
* buffers area (0x3fce9704). For alignment purpose we shall use value (0x3fce9700).
|
||||
*/
|
||||
|
||||
/* The offset between Dbus and Ibus. Used to convert between 0x403xxxxx and 0x3fcxxxxx addresses. */
|
||||
iram_dram_offset = 0x700000;
|
||||
|
||||
/* We consider 0x3fce9700 to be the last usable address for 2nd stage bootloader stack overhead, dram_seg,
|
||||
* and work out iram_seg and iram_loader_seg addresses from there, backwards.
|
||||
*/
|
||||
|
||||
/* These lengths can be adjusted, if necessary: */
|
||||
bootloader_usable_dram_end = 0x3fcdd120;
|
||||
bootloader_stack_overhead = 0x2000; /* For safety margin between bootloader data section and startup stacks */
|
||||
bootloader_dram_seg_len = 0x5000;
|
||||
bootloader_iram_loader_seg_len = 0x7000;
|
||||
bootloader_iram_seg_len = 0x2000;
|
||||
|
||||
/* Start of the lower region is determined by region size and the end of the higher region */
|
||||
bootloader_dram_seg_end = bootloader_usable_dram_end - bootloader_stack_overhead;
|
||||
bootloader_dram_seg_start = bootloader_dram_seg_end - bootloader_dram_seg_len;
|
||||
bootloader_iram_loader_seg_start = bootloader_dram_seg_start - bootloader_iram_loader_seg_len + iram_dram_offset;
|
||||
bootloader_iram_seg_start = bootloader_iram_loader_seg_start - bootloader_iram_seg_len;
|
||||
|
||||
MEMORY
|
||||
{
|
||||
iram_seg (RWX) : org = bootloader_iram_seg_start, len = bootloader_iram_seg_len
|
||||
iram_loader_seg (RWX) : org = bootloader_iram_loader_seg_start, len = bootloader_iram_loader_seg_len
|
||||
dram_seg (RW) : org = bootloader_dram_seg_start, len = bootloader_dram_seg_len
|
||||
}
|
||||
|
||||
/* Default entry point: */
|
||||
ENTRY(call_start_cpu0);
|
||||
|
||||
SECTIONS
|
||||
{
|
||||
|
||||
.iram_loader.text :
|
||||
{
|
||||
. = ALIGN (16);
|
||||
_loader_text_start = ABSOLUTE(.);
|
||||
*(.stub .gnu.warning .gnu.linkonce.literal.* .gnu.linkonce.t.*.literal .gnu.linkonce.t.*)
|
||||
*(.iram1 .iram1.*) /* catch stray IRAM_ATTR */
|
||||
*liblog.a:(.literal .text .literal.* .text.*)
|
||||
*libgcc.a:(.literal .text .literal.* .text.*)
|
||||
*libbootloader_support.a:bootloader_clock_loader.*(.literal .text .literal.* .text.*)
|
||||
*libbootloader_support.a:bootloader_common_loader.*(.literal .text .literal.* .text.*)
|
||||
*libbootloader_support.a:bootloader_flash.*(.literal .text .literal.* .text.*)
|
||||
*libbootloader_support.a:bootloader_random.*(.literal .text .literal.* .text.*)
|
||||
*libbootloader_support.a:bootloader_random*.*(.literal.bootloader_random_disable .text.bootloader_random_disable)
|
||||
*libbootloader_support.a:bootloader_random*.*(.literal.bootloader_random_enable .text.bootloader_random_enable)
|
||||
*libbootloader_support.a:bootloader_efuse.*(.literal .text .literal.* .text.*)
|
||||
*libbootloader_support.a:bootloader_utility.*(.literal .text .literal.* .text.*)
|
||||
*libbootloader_support.a:bootloader_sha.*(.literal .text .literal.* .text.*)
|
||||
*libbootloader_support.a:bootloader_console_loader.*(.literal .text .literal.* .text.*)
|
||||
*libbootloader_support.a:bootloader_panic.*(.literal .text .literal.* .text.*)
|
||||
*libbootloader_support.a:bootloader_soc.*(.literal .text .literal.* .text.*)
|
||||
*libbootloader_support.a:esp_image_format.*(.literal .text .literal.* .text.*)
|
||||
*libbootloader_support.a:flash_encrypt.*(.literal .text .literal.* .text.*)
|
||||
*libbootloader_support.a:flash_partitions.*(.literal .text .literal.* .text.*)
|
||||
*libbootloader_support.a:secure_boot.*(.literal .text .literal.* .text.*)
|
||||
*libbootloader_support.a:secure_boot_signatures_bootloader.*(.literal .text .literal.* .text.*)
|
||||
*libmicro-ecc.a:*.*(.literal .text .literal.* .text.*)
|
||||
*libspi_flash.a:*.*(.literal .text .literal.* .text.*)
|
||||
*libhal.a:wdt_hal_iram.*(.literal .text .literal.* .text.*)
|
||||
*libhal.a:mmu_hal.*(.literal .text .literal.* .text.*)
|
||||
*libhal.a:cache_hal.*(.literal .text .literal.* .text.*)
|
||||
*libhal.a:efuse_hal.*(.literal .text .literal.* .text.*)
|
||||
*libesp_hw_support.a:rtc_clk.*(.literal .text .literal.* .text.*)
|
||||
*libesp_hw_support.a:rtc_time.*(.literal .text .literal.* .text.*)
|
||||
*libesp_hw_support.a:regi2c_ctrl.*(.literal .text .literal.* .text.*)
|
||||
*libefuse.a:*.*(.literal .text .literal.* .text.*)
|
||||
*(.fini.literal)
|
||||
*(.fini)
|
||||
*(.gnu.version)
|
||||
_loader_text_end = ABSOLUTE(.);
|
||||
} > iram_loader_seg
|
||||
|
||||
.iram.text :
|
||||
{
|
||||
. = ALIGN (16);
|
||||
*(.entry.text)
|
||||
*(.init.literal)
|
||||
*(.init)
|
||||
} > iram_seg
|
||||
|
||||
|
||||
/* Shared RAM */
|
||||
.dram0.bss (NOLOAD) :
|
||||
{
|
||||
. = ALIGN (8);
|
||||
_dram_start = ABSOLUTE(.);
|
||||
_bss_start = ABSOLUTE(.);
|
||||
*(.dynsbss)
|
||||
*(.sbss)
|
||||
*(.sbss.*)
|
||||
*(.gnu.linkonce.sb.*)
|
||||
*(.scommon)
|
||||
*(.sbss2)
|
||||
*(.sbss2.*)
|
||||
*(.gnu.linkonce.sb2.*)
|
||||
*(.dynbss)
|
||||
*(.bss)
|
||||
*(.bss.*)
|
||||
*(.gnu.linkonce.b.*)
|
||||
*(COMMON)
|
||||
. = ALIGN (8);
|
||||
_bss_end = ABSOLUTE(.);
|
||||
} > dram_seg
|
||||
|
||||
.dram0.data :
|
||||
{
|
||||
_data_start = ABSOLUTE(.);
|
||||
*(.data)
|
||||
*(.data.*)
|
||||
*(.gnu.linkonce.d.*)
|
||||
*(.data1)
|
||||
*(.sdata)
|
||||
*(.sdata.*)
|
||||
*(.gnu.linkonce.s.*)
|
||||
*(.gnu.linkonce.s2.*)
|
||||
*(.jcr)
|
||||
_data_end = ABSOLUTE(.);
|
||||
} > dram_seg
|
||||
|
||||
.dram0.rodata :
|
||||
{
|
||||
_rodata_start = ABSOLUTE(.);
|
||||
*(.rodata)
|
||||
*(.rodata.*)
|
||||
*(.gnu.linkonce.r.*)
|
||||
*(.rodata1)
|
||||
*(.sdata2 .sdata2.* .srodata .srodata.*)
|
||||
__XT_EXCEPTION_TABLE_ = ABSOLUTE(.);
|
||||
*(.xt_except_table)
|
||||
*(.gcc_except_table)
|
||||
*(.gnu.linkonce.e.*)
|
||||
*(.gnu.version_r)
|
||||
*(.eh_frame)
|
||||
. = (. + 3) & ~ 3;
|
||||
/* C++ constructor and destructor tables, properly ordered: */
|
||||
__init_array_start = ABSOLUTE(.);
|
||||
KEEP (*crtbegin.*(.ctors))
|
||||
KEEP (*(EXCLUDE_FILE (*crtend.*) .ctors))
|
||||
KEEP (*(SORT(.ctors.*)))
|
||||
KEEP (*(.ctors))
|
||||
__init_array_end = ABSOLUTE(.);
|
||||
KEEP (*crtbegin.*(.dtors))
|
||||
KEEP (*(EXCLUDE_FILE (*crtend.*) .dtors))
|
||||
KEEP (*(SORT(.dtors.*)))
|
||||
KEEP (*(.dtors))
|
||||
/* C++ exception handlers table: */
|
||||
__XT_EXCEPTION_DESCS_ = ABSOLUTE(.);
|
||||
*(.xt_except_desc)
|
||||
*(.gnu.linkonce.h.*)
|
||||
__XT_EXCEPTION_DESCS_END__ = ABSOLUTE(.);
|
||||
*(.xt_except_desc_end)
|
||||
*(.dynamic)
|
||||
*(.gnu.version_d)
|
||||
_rodata_end = ABSOLUTE(.);
|
||||
/* Literals are also RO data. */
|
||||
_lit4_start = ABSOLUTE(.);
|
||||
*(*.lit4)
|
||||
*(.lit4.*)
|
||||
*(.gnu.linkonce.lit4.*)
|
||||
_lit4_end = ABSOLUTE(.);
|
||||
. = ALIGN(4);
|
||||
_dram_end = ABSOLUTE(.);
|
||||
} > dram_seg
|
||||
|
||||
.iram.text :
|
||||
{
|
||||
_stext = .;
|
||||
_text_start = ABSOLUTE(.);
|
||||
*(.literal .text .literal.* .text.* .stub .gnu.warning .gnu.linkonce.literal.* .gnu.linkonce.t.*.literal .gnu.linkonce.t.*)
|
||||
*(.iram .iram.*) /* catch stray IRAM_ATTR */
|
||||
*(.fini.literal)
|
||||
*(.fini)
|
||||
*(.gnu.version)
|
||||
|
||||
/** CPU will try to prefetch up to 16 bytes of
|
||||
* of instructions. This means that any configuration (e.g. MMU, PMS) must allow
|
||||
* safe access to up to 16 bytes after the last real instruction, add
|
||||
* dummy bytes to ensure this
|
||||
*/
|
||||
. += 16;
|
||||
|
||||
_text_end = ABSOLUTE(.);
|
||||
_etext = .;
|
||||
} > iram_seg
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Appendix: Memory Usage of ROM bootloader
|
||||
*
|
||||
* 0x3fccb81c ------------------> _dram0_0_start
|
||||
* | |
|
||||
* | |
|
||||
* | | 1. Large buffers that are only used in certain boot modes, see shared_buffers.h
|
||||
* | |
|
||||
* | |
|
||||
* 0x3fcdd120 ------------------> __stack_sentry
|
||||
* | |
|
||||
* | | 2. Startup pro cpu stack (freed when IDF app is running)
|
||||
* | |
|
||||
* 0x3fcdf120 ------------------> __stack (pro cpu)
|
||||
* | |
|
||||
* | |
|
||||
* | | 3. Shared memory only used in startup code or nonos/early boot*
|
||||
* | | (can be freed when IDF runs)
|
||||
* | |
|
||||
* | |
|
||||
* 0x3fcdfa6c ------------------> _dram0_rtos_reserved_start
|
||||
* | |
|
||||
* | |
|
||||
* | | 4. Shared memory used in startup code and when IDF runs
|
||||
* | |
|
||||
* | |
|
||||
* 0x3fcdfe40 ------------------> _dram0_rtos_reserved_end
|
||||
* | |
|
||||
* 0x3fcdfe4c ------------------> _data_start_interface
|
||||
* | |
|
||||
* | | 5. End of DRAM is the 'interface' data with constant addresses (ECO compatible)
|
||||
* | |
|
||||
* 0x3fce0000 ------------------> _data_end_interface
|
||||
*/
|
||||
@@ -0,0 +1,6 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
/* No definition for ESP32-H4 target */
|
||||
@@ -0,0 +1,13 @@
|
||||
/*
|
||||
* ESP32S2 ROM address table
|
||||
* Generated for ROM with MD5sum: 0a2c7ec5109c17884606d23b47045796
|
||||
*/
|
||||
PROVIDE (ets_update_cpu_frequency = 0x4000d8a4);
|
||||
|
||||
PROVIDE (MD5Final = 0x4000530c);
|
||||
PROVIDE (MD5Init = 0x4000526c);
|
||||
PROVIDE (MD5Update = 0x4000528c);
|
||||
/* bootloader will use following functions from xtensa hal library */
|
||||
xthal_get_ccount = 0x4001aa90;
|
||||
xthal_get_ccompare = 0x4001aabc;
|
||||
xthal_set_ccompare = 0x4001aa98;
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
/**
|
||||
* ESP32S3 ROM address table
|
||||
* Generated for ROM with MD5sum: d20fb231463ce337432b1fa9cba0b3c9
|
||||
*/
|
||||
|
||||
PROVIDE ( ets_update_cpu_frequency = 0x40043164 );
|
||||
|
||||
@@ -5,3 +5,7 @@ components/bootloader_support/test_apps/rtc_custom_section:
|
||||
- if: IDF_TARGET == "esp32c2"
|
||||
temporary: false
|
||||
reason: esp32c2 does not have RTC memory
|
||||
disable_test:
|
||||
- if: IDF_TARGET == "esp32h2"
|
||||
temporary: true
|
||||
reason: target esp32h2 is not supported yet
|
||||
|
||||
@@ -164,7 +164,7 @@ if(CONFIG_SECURE_SIGNED_APPS AND (CONFIG_SECURE_BOOT_V1_ENABLED OR CONFIG_SECURE
|
||||
target_add_binary_data(${COMPONENT_LIB} "${secure_boot_verification_key}" "BINARY"
|
||||
RENAME_TO signature_verification_key_bin)
|
||||
set_property(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
|
||||
APPEND PROPERTY ADDITIONAL_CLEAN_FILES
|
||||
APPEND PROPERTY ADDITIONAL_MAKE_CLEAN_FILES
|
||||
"${secure_boot_verification_key}")
|
||||
endif()
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2020-2023 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2020-2022 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -54,13 +54,6 @@ esp_err_t bootloader_flash_reset_chip(void);
|
||||
*/
|
||||
bool bootloader_flash_is_octal_mode_enabled(void);
|
||||
|
||||
/**
|
||||
* @brief Get the spi flash working mode.
|
||||
*
|
||||
* @return The mode of flash working mode, see `esp_rom_spiflash_read_mode_t`
|
||||
*/
|
||||
esp_rom_spiflash_read_mode_t bootloader_flash_get_spi_mode(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2020-2023 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2020-2022 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -109,17 +109,6 @@ extern const bootloader_qio_info_t __attribute__((weak)) bootloader_flash_qe_sup
|
||||
*/
|
||||
esp_err_t __attribute__((weak)) bootloader_flash_unlock(void);
|
||||
|
||||
#if CONFIG_SPI_FLASH_OCTAL_32BIT_ADDR_ENABLE
|
||||
/**
|
||||
* @brief Enable 32bits address flash(larger than 16MB) can map to cache.
|
||||
*
|
||||
* @param flash_mode SPI flash working mode.
|
||||
*
|
||||
* @note This can be overridden because it's attribute weak.
|
||||
*/
|
||||
void __attribute__((weak)) bootloader_flash_32bits_address_map_enable(esp_rom_spiflash_read_mode_t flash_mode);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -52,8 +52,6 @@ extern "C" {
|
||||
#define CMD_RESUME 0x7A /* Resume command to clear flash suspend bit */
|
||||
#define CMD_RESETEN 0x66
|
||||
#define CMD_RESET 0x99
|
||||
#define CMD_FASTRD_4B 0x0C
|
||||
#define CMD_SLOWRD_4B 0x13
|
||||
|
||||
|
||||
/* Provide a Flash API for bootloader_support code,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -120,13 +120,9 @@ esp_err_t bootloader_flash_erase_range(uint32_t start_addr, uint32_t size)
|
||||
#include "esp32/rom/cache.h"
|
||||
#endif
|
||||
#include "esp_rom_spiflash.h"
|
||||
#include "esp_rom_sys.h"
|
||||
#include "hal/mmu_hal.h"
|
||||
#include "hal/mmu_ll.h"
|
||||
#include "hal/cache_hal.h"
|
||||
#if CONFIG_IDF_TARGET_ESP32S3
|
||||
#include "esp32s3/rom/opi_flash.h"
|
||||
#endif
|
||||
static const char *TAG = "bootloader_flash";
|
||||
|
||||
#if CONFIG_IDF_TARGET_ESP32
|
||||
@@ -413,33 +409,6 @@ esp_err_t bootloader_flash_erase_range(uint32_t start_addr, uint32_t size)
|
||||
return spi_to_esp_err(rc);
|
||||
}
|
||||
|
||||
#if CONFIG_SPI_FLASH_OCTAL_32BIT_ADDR_ENABLE
|
||||
void bootloader_flash_32bits_address_map_enable(esp_rom_spiflash_read_mode_t flash_mode)
|
||||
{
|
||||
esp_rom_opiflash_spi0rd_t cache_rd = {};
|
||||
switch (flash_mode) {
|
||||
case ESP_ROM_SPIFLASH_FASTRD_MODE:
|
||||
cache_rd.addr_bit_len = 32;
|
||||
cache_rd.dummy_bit_len = 8;
|
||||
cache_rd.cmd = CMD_FASTRD_4B;
|
||||
cache_rd.cmd_bit_len = 8;
|
||||
break;
|
||||
case ESP_ROM_SPIFLASH_SLOWRD_MODE:
|
||||
cache_rd.addr_bit_len = 32;
|
||||
cache_rd.dummy_bit_len = 0;
|
||||
cache_rd.cmd = CMD_SLOWRD_4B;
|
||||
cache_rd.cmd_bit_len = 8;
|
||||
break;
|
||||
default:
|
||||
assert(false);
|
||||
break;
|
||||
}
|
||||
cache_hal_disable(CACHE_TYPE_ALL);
|
||||
esp_rom_opiflash_cache_mode_config(flash_mode, &cache_rd);
|
||||
cache_hal_enable(CACHE_TYPE_ALL);
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // BOOTLOADER_BUILD
|
||||
|
||||
|
||||
@@ -786,40 +755,3 @@ bool IRAM_ATTR bootloader_flash_is_octal_mode_enabled(void)
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
esp_rom_spiflash_read_mode_t bootloader_flash_get_spi_mode(void)
|
||||
{
|
||||
esp_rom_spiflash_read_mode_t spi_mode = ESP_ROM_SPIFLASH_FASTRD_MODE;
|
||||
#if CONFIG_IDF_TARGET_ESP32
|
||||
uint32_t spi_ctrl = REG_READ(SPI_CTRL_REG(0));
|
||||
if (spi_ctrl & SPI_FREAD_QIO) {
|
||||
spi_mode = ESP_ROM_SPIFLASH_QIO_MODE;
|
||||
} else if (spi_ctrl & SPI_FREAD_QUAD) {
|
||||
spi_mode = ESP_ROM_SPIFLASH_QOUT_MODE;
|
||||
} else if (spi_ctrl & SPI_FREAD_DIO) {
|
||||
spi_mode = ESP_ROM_SPIFLASH_DIO_MODE;
|
||||
} else if (spi_ctrl & SPI_FREAD_DUAL) {
|
||||
spi_mode = ESP_ROM_SPIFLASH_DOUT_MODE;
|
||||
} else if (spi_ctrl & SPI_FASTRD_MODE) {
|
||||
spi_mode = ESP_ROM_SPIFLASH_FASTRD_MODE;
|
||||
} else {
|
||||
spi_mode = ESP_ROM_SPIFLASH_SLOWRD_MODE;
|
||||
}
|
||||
#else
|
||||
uint32_t spi_ctrl = REG_READ(SPI_MEM_CTRL_REG(0));
|
||||
if (spi_ctrl & SPI_MEM_FREAD_QIO) {
|
||||
spi_mode = ESP_ROM_SPIFLASH_QIO_MODE;
|
||||
} else if (spi_ctrl & SPI_MEM_FREAD_QUAD) {
|
||||
spi_mode = ESP_ROM_SPIFLASH_QOUT_MODE;
|
||||
} else if (spi_ctrl & SPI_MEM_FREAD_DIO) {
|
||||
spi_mode = ESP_ROM_SPIFLASH_DIO_MODE;
|
||||
} else if (spi_ctrl & SPI_MEM_FREAD_DUAL) {
|
||||
spi_mode = ESP_ROM_SPIFLASH_DOUT_MODE;
|
||||
} else if (spi_ctrl & SPI_MEM_FASTRD_MODE) {
|
||||
spi_mode = ESP_ROM_SPIFLASH_FASTRD_MODE;
|
||||
} else {
|
||||
spi_mode = ESP_ROM_SPIFLASH_SLOWRD_MODE;
|
||||
}
|
||||
#endif
|
||||
return spi_mode;
|
||||
}
|
||||
|
||||
@@ -200,12 +200,6 @@ esp_err_t bootloader_init_spi_flash(void)
|
||||
bootloader_enable_qio_mode();
|
||||
#endif
|
||||
|
||||
// Since the workaround in IDF-6709, the spi_speed value in the bootloader header
|
||||
// is not the real value, overwrite it.
|
||||
#if CONFIG_ESPTOOLPY_FLASHFREQ_80M
|
||||
bootloader_image_hdr.spi_speed = ESP_IMAGE_SPI_SPEED_DIV_1;
|
||||
#endif
|
||||
|
||||
print_flash_info(&bootloader_image_hdr);
|
||||
update_flash_config(&bootloader_image_hdr);
|
||||
//ensure the flash is write-protected
|
||||
|
||||
@@ -0,0 +1,250 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2020-2022 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
#include <stdbool.h>
|
||||
#include <assert.h>
|
||||
#include "string.h"
|
||||
#include "sdkconfig.h"
|
||||
#include "esp_err.h"
|
||||
#include "esp_log.h"
|
||||
#include "esp_rom_gpio.h"
|
||||
#include "esp_rom_efuse.h"
|
||||
#include "esp32h4/rom/gpio.h"
|
||||
#include "esp32h4/rom/spi_flash.h"
|
||||
#include "esp32h4/rom/efuse.h"
|
||||
#include "soc/gpio_periph.h"
|
||||
#include "soc/efuse_reg.h"
|
||||
#include "soc/spi_reg.h"
|
||||
#include "soc/spi_mem_reg.h"
|
||||
#include "soc/soc_caps.h"
|
||||
#include "flash_qio_mode.h"
|
||||
#include "bootloader_flash_config.h"
|
||||
#include "bootloader_common.h"
|
||||
#include "bootloader_flash_priv.h"
|
||||
#include "bootloader_init.h"
|
||||
#include "hal/mmu_hal.h"
|
||||
#include "hal/cache_hal.h"
|
||||
#include "hal/mmu_ll.h"
|
||||
|
||||
#define FLASH_IO_MATRIX_DUMMY_40M 0
|
||||
#define FLASH_IO_MATRIX_DUMMY_80M 0
|
||||
|
||||
void bootloader_flash_update_id()
|
||||
{
|
||||
esp_rom_spiflash_chip_t *chip = &rom_spiflash_legacy_data->chip;
|
||||
chip->device_id = bootloader_read_flash_id();
|
||||
}
|
||||
|
||||
void IRAM_ATTR bootloader_flash_cs_timing_config()
|
||||
{
|
||||
SET_PERI_REG_MASK(SPI_MEM_USER_REG(0), SPI_MEM_CS_HOLD_M | SPI_MEM_CS_SETUP_M);
|
||||
SET_PERI_REG_BITS(SPI_MEM_CTRL2_REG(0), SPI_MEM_CS_HOLD_TIME_V, 0, SPI_MEM_CS_HOLD_TIME_S);
|
||||
SET_PERI_REG_BITS(SPI_MEM_CTRL2_REG(0), SPI_MEM_CS_SETUP_TIME_V, 0, SPI_MEM_CS_SETUP_TIME_S);
|
||||
SET_PERI_REG_MASK(SPI_MEM_USER_REG(1), SPI_MEM_CS_HOLD_M | SPI_MEM_CS_SETUP_M);
|
||||
SET_PERI_REG_BITS(SPI_MEM_CTRL2_REG(1), SPI_MEM_CS_HOLD_TIME_V, 1, SPI_MEM_CS_HOLD_TIME_S);
|
||||
SET_PERI_REG_BITS(SPI_MEM_CTRL2_REG(1), SPI_MEM_CS_SETUP_TIME_V, 0, SPI_MEM_CS_SETUP_TIME_S);
|
||||
}
|
||||
|
||||
void IRAM_ATTR bootloader_flash_clock_config(const esp_image_header_t *pfhdr)
|
||||
{
|
||||
uint32_t spi_clk_div = 0;
|
||||
switch (pfhdr->spi_speed) {
|
||||
case ESP_IMAGE_SPI_SPEED_DIV_1:
|
||||
spi_clk_div = 1;
|
||||
break;
|
||||
case ESP_IMAGE_SPI_SPEED_DIV_2:
|
||||
spi_clk_div = 2;
|
||||
break;
|
||||
case ESP_IMAGE_SPI_SPEED_DIV_3:
|
||||
spi_clk_div = 3;
|
||||
break;
|
||||
case ESP_IMAGE_SPI_SPEED_DIV_4:
|
||||
spi_clk_div = 4;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
esp_rom_spiflash_config_clk(spi_clk_div, 0);
|
||||
}
|
||||
|
||||
void IRAM_ATTR bootloader_flash_set_dummy_out(void)
|
||||
{
|
||||
REG_SET_BIT(SPI_MEM_CTRL_REG(0), SPI_MEM_FDUMMY_OUT | SPI_MEM_D_POL | SPI_MEM_Q_POL);
|
||||
REG_SET_BIT(SPI_MEM_CTRL_REG(1), SPI_MEM_FDUMMY_OUT | SPI_MEM_D_POL | SPI_MEM_Q_POL);
|
||||
}
|
||||
|
||||
void IRAM_ATTR bootloader_flash_dummy_config(const esp_image_header_t *pfhdr)
|
||||
{
|
||||
bootloader_configure_spi_pins(1);
|
||||
bootloader_flash_set_dummy_out();
|
||||
}
|
||||
|
||||
static const char *TAG = "boot.esp32h4";
|
||||
|
||||
void IRAM_ATTR bootloader_configure_spi_pins(int drv)
|
||||
{
|
||||
const uint32_t spiconfig = esp_rom_efuse_get_flash_gpio_info();
|
||||
uint8_t wp_pin = esp_rom_efuse_get_flash_wp_gpio();
|
||||
uint8_t clk_gpio_num = SPI_CLK_GPIO_NUM;
|
||||
uint8_t q_gpio_num = SPI_Q_GPIO_NUM;
|
||||
uint8_t d_gpio_num = SPI_D_GPIO_NUM;
|
||||
uint8_t cs0_gpio_num = SPI_CS0_GPIO_NUM;
|
||||
uint8_t hd_gpio_num = SPI_HD_GPIO_NUM;
|
||||
uint8_t wp_gpio_num = SPI_WP_GPIO_NUM;
|
||||
if (spiconfig == 0) {
|
||||
|
||||
} else {
|
||||
clk_gpio_num = spiconfig & 0x3f;
|
||||
q_gpio_num = (spiconfig >> 6) & 0x3f;
|
||||
d_gpio_num = (spiconfig >> 12) & 0x3f;
|
||||
cs0_gpio_num = (spiconfig >> 18) & 0x3f;
|
||||
hd_gpio_num = (spiconfig >> 24) & 0x3f;
|
||||
wp_gpio_num = wp_pin;
|
||||
}
|
||||
esp_rom_gpio_pad_set_drv(clk_gpio_num, drv);
|
||||
esp_rom_gpio_pad_set_drv(q_gpio_num, drv);
|
||||
esp_rom_gpio_pad_set_drv(d_gpio_num, drv);
|
||||
esp_rom_gpio_pad_set_drv(cs0_gpio_num, drv);
|
||||
if (hd_gpio_num <= MAX_PAD_GPIO_NUM) {
|
||||
esp_rom_gpio_pad_set_drv(hd_gpio_num, drv);
|
||||
}
|
||||
if (wp_gpio_num <= MAX_PAD_GPIO_NUM) {
|
||||
esp_rom_gpio_pad_set_drv(wp_gpio_num, drv);
|
||||
}
|
||||
}
|
||||
|
||||
static void update_flash_config(const esp_image_header_t *bootloader_hdr)
|
||||
{
|
||||
uint32_t size;
|
||||
switch (bootloader_hdr->spi_size) {
|
||||
case ESP_IMAGE_FLASH_SIZE_1MB:
|
||||
size = 1;
|
||||
break;
|
||||
case ESP_IMAGE_FLASH_SIZE_2MB:
|
||||
size = 2;
|
||||
break;
|
||||
case ESP_IMAGE_FLASH_SIZE_4MB:
|
||||
size = 4;
|
||||
break;
|
||||
case ESP_IMAGE_FLASH_SIZE_8MB:
|
||||
size = 8;
|
||||
break;
|
||||
case ESP_IMAGE_FLASH_SIZE_16MB:
|
||||
size = 16;
|
||||
break;
|
||||
default:
|
||||
size = 2;
|
||||
}
|
||||
cache_hal_disable(CACHE_TYPE_ALL);
|
||||
// Set flash chip size
|
||||
esp_rom_spiflash_config_param(rom_spiflash_legacy_data->chip.device_id, size * 0x100000, 0x10000, 0x1000, 0x100, 0xffff); // TODO: set mode
|
||||
cache_hal_enable(CACHE_TYPE_ALL);
|
||||
}
|
||||
|
||||
static void print_flash_info(const esp_image_header_t *bootloader_hdr)
|
||||
{
|
||||
ESP_EARLY_LOGD(TAG, "magic %02x", bootloader_hdr->magic);
|
||||
ESP_EARLY_LOGD(TAG, "segments %02x", bootloader_hdr->segment_count);
|
||||
ESP_EARLY_LOGD(TAG, "spi_mode %02x", bootloader_hdr->spi_mode);
|
||||
ESP_EARLY_LOGD(TAG, "spi_speed %02x", bootloader_hdr->spi_speed);
|
||||
ESP_EARLY_LOGD(TAG, "spi_size %02x", bootloader_hdr->spi_size);
|
||||
|
||||
const char *str;
|
||||
switch (bootloader_hdr->spi_speed) {
|
||||
case ESP_IMAGE_SPI_SPEED_DIV_2:
|
||||
str = "24MHz";
|
||||
break;
|
||||
case ESP_IMAGE_SPI_SPEED_DIV_3:
|
||||
str = "16MHz";
|
||||
break;
|
||||
case ESP_IMAGE_SPI_SPEED_DIV_4:
|
||||
str = "12MHz";
|
||||
break;
|
||||
case ESP_IMAGE_SPI_SPEED_DIV_1:
|
||||
str = "48MHz";
|
||||
break;
|
||||
default:
|
||||
str = "12MHz";
|
||||
break;
|
||||
}
|
||||
ESP_EARLY_LOGI(TAG, "SPI Speed : %s", str);
|
||||
|
||||
/* SPI mode could have been set to QIO during boot already,
|
||||
so test the SPI registers not the flash header */
|
||||
uint32_t spi_ctrl = REG_READ(SPI_MEM_CTRL_REG(0));
|
||||
if (spi_ctrl & SPI_MEM_FREAD_QIO) {
|
||||
str = "QIO";
|
||||
} else if (spi_ctrl & SPI_MEM_FREAD_QUAD) {
|
||||
str = "QOUT";
|
||||
} else if (spi_ctrl & SPI_MEM_FREAD_DIO) {
|
||||
str = "DIO";
|
||||
} else if (spi_ctrl & SPI_MEM_FREAD_DUAL) {
|
||||
str = "DOUT";
|
||||
} else if (spi_ctrl & SPI_MEM_FASTRD_MODE) {
|
||||
str = "FAST READ";
|
||||
} else {
|
||||
str = "SLOW READ";
|
||||
}
|
||||
ESP_EARLY_LOGI(TAG, "SPI Mode : %s", str);
|
||||
|
||||
switch (bootloader_hdr->spi_size) {
|
||||
case ESP_IMAGE_FLASH_SIZE_1MB:
|
||||
str = "1MB";
|
||||
break;
|
||||
case ESP_IMAGE_FLASH_SIZE_2MB:
|
||||
str = "2MB";
|
||||
break;
|
||||
case ESP_IMAGE_FLASH_SIZE_4MB:
|
||||
str = "4MB";
|
||||
break;
|
||||
case ESP_IMAGE_FLASH_SIZE_8MB:
|
||||
str = "8MB";
|
||||
break;
|
||||
case ESP_IMAGE_FLASH_SIZE_16MB:
|
||||
str = "16MB";
|
||||
break;
|
||||
default:
|
||||
str = "2MB";
|
||||
break;
|
||||
}
|
||||
ESP_EARLY_LOGI(TAG, "SPI Flash Size : %s", str);
|
||||
}
|
||||
|
||||
static void IRAM_ATTR bootloader_init_flash_configure(void)
|
||||
{
|
||||
bootloader_flash_dummy_config(&bootloader_image_hdr);
|
||||
bootloader_flash_cs_timing_config();
|
||||
}
|
||||
|
||||
static void bootloader_spi_flash_resume(void)
|
||||
{
|
||||
bootloader_execute_flash_command(CMD_RESUME, 0, 0, 0);
|
||||
esp_rom_spiflash_wait_idle(&g_rom_flashchip);
|
||||
}
|
||||
|
||||
esp_err_t bootloader_init_spi_flash(void)
|
||||
{
|
||||
bootloader_init_flash_configure();
|
||||
#ifndef CONFIG_SPI_FLASH_ROM_DRIVER_PATCH
|
||||
const uint32_t spiconfig = esp_rom_efuse_get_flash_gpio_info();
|
||||
if (spiconfig != ESP_ROM_EFUSE_FLASH_DEFAULT_SPI && spiconfig != ESP_ROM_EFUSE_FLASH_DEFAULT_HSPI) {
|
||||
ESP_EARLY_LOGE(TAG, "SPI flash pins are overridden. Enable CONFIG_SPI_FLASH_ROM_DRIVER_PATCH in menuconfig");
|
||||
return ESP_FAIL;
|
||||
}
|
||||
#endif
|
||||
|
||||
bootloader_spi_flash_resume();
|
||||
bootloader_flash_unlock();
|
||||
|
||||
#if CONFIG_ESPTOOLPY_FLASHMODE_QIO || CONFIG_ESPTOOLPY_FLASHMODE_QOUT
|
||||
bootloader_enable_qio_mode();
|
||||
#endif
|
||||
|
||||
print_flash_info(&bootloader_image_hdr);
|
||||
update_flash_config(&bootloader_image_hdr);
|
||||
//ensure the flash is write-protected
|
||||
bootloader_enable_wp();
|
||||
return ESP_OK;
|
||||
}
|
||||
@@ -272,9 +272,7 @@ esp_err_t bootloader_init_spi_flash(void)
|
||||
bootloader_enable_qio_mode();
|
||||
}
|
||||
#endif
|
||||
#if CONFIG_SPI_FLASH_OCTAL_32BIT_ADDR_ENABLE
|
||||
bootloader_flash_32bits_address_map_enable(bootloader_flash_get_spi_mode());
|
||||
#endif
|
||||
|
||||
print_flash_info(&bootloader_image_hdr);
|
||||
update_flash_config(&bootloader_image_hdr);
|
||||
//ensure the flash is write-protected
|
||||
|
||||
@@ -18,8 +18,12 @@ typedef enum {
|
||||
ESP_CHIP_ID_ESP32C3 = 0x0005, /*!< chip ID: ESP32-C3 */
|
||||
ESP_CHIP_ID_ESP32S3 = 0x0009, /*!< chip ID: ESP32-S3 */
|
||||
ESP_CHIP_ID_ESP32C2 = 0x000C, /*!< chip ID: ESP32-C2 */
|
||||
#if CONFIG_IDF_TARGET_ESP32H4_BETA_VERSION_2
|
||||
ESP_CHIP_ID_ESP32H4 = 0x000E, /*!< chip ID: ESP32-H4 Beta2*/ // ESP32H4-TODO: IDF-3475
|
||||
#elif CONFIG_IDF_TARGET_ESP32H4_BETA_VERSION_1
|
||||
ESP_CHIP_ID_ESP32H4 = 0x000A, /*!< chip ID: ESP32-H4 Beta1 */
|
||||
#endif
|
||||
ESP_CHIP_ID_ESP32C6 = 0x000D, /*!< chip ID: ESP32-C6 */
|
||||
ESP_CHIP_ID_ESP32H2 = 0x0010, /*!< chip ID: ESP32-H2 */
|
||||
ESP_CHIP_ID_INVALID = 0xFFFF /*!< Invalid chip ID (we defined it to make sure the esp_chip_id_t is 2 bytes size) */
|
||||
} __attribute__((packed)) esp_chip_id_t;
|
||||
|
||||
|
||||
@@ -17,6 +17,8 @@
|
||||
#include "esp32c3/rom/secure_boot.h"
|
||||
#elif CONFIG_IDF_TARGET_ESP32S3
|
||||
#include "esp32s3/rom/secure_boot.h"
|
||||
#elif CONFIG_IDF_TARGET_ESP32H4
|
||||
#include "esp32h4/rom/secure_boot.h"
|
||||
#elif CONFIG_IDF_TARGET_ESP32C2
|
||||
#include "esp32c2/rom/secure_boot.h"
|
||||
#elif CONFIG_IDF_TARGET_ESP32C6
|
||||
|
||||
@@ -45,7 +45,7 @@ int bootloader_utility_get_selected_boot_partition(const bootloader_state_t *bs)
|
||||
* @param[in] bs Bootloader state structure.
|
||||
* @param[in] start_index The index from which the search for images begins.
|
||||
*/
|
||||
__attribute__((__noreturn__)) void bootloader_utility_load_boot_image(const bootloader_state_t *bs, int start_index);
|
||||
__attribute__((noreturn)) void bootloader_utility_load_boot_image(const bootloader_state_t *bs, int start_index);
|
||||
|
||||
#ifdef CONFIG_BOOTLOADER_SKIP_VALIDATE_IN_DEEP_SLEEP
|
||||
/**
|
||||
@@ -65,7 +65,7 @@ void bootloader_utility_load_boot_image_from_deep_sleep(void);
|
||||
*
|
||||
* It is not recommended to call this function from an app (if called, the app will abort).
|
||||
*/
|
||||
__attribute__((__noreturn__)) void bootloader_reset(void);
|
||||
__attribute__((noreturn)) void bootloader_reset(void);
|
||||
|
||||
/**
|
||||
* @brief Do any cleanup before exiting the bootloader, before starting the app or resetting
|
||||
|
||||
@@ -121,6 +121,22 @@ int bootloader_common_select_otadata(const esp_ota_select_entry_t *two_otadata,
|
||||
|
||||
#if CONFIG_BOOTLOADER_RESERVE_RTC_MEM
|
||||
|
||||
#define RTC_RETAIN_MEM_ADDR (SOC_RTC_DRAM_HIGH - sizeof(rtc_retain_mem_t))
|
||||
|
||||
_Static_assert(RTC_RETAIN_MEM_ADDR >= SOC_RTC_DRAM_LOW, "rtc_retain_mem_t structure size is bigger than the RTC memory size. Consider reducing RTC reserved memory size.");
|
||||
|
||||
rtc_retain_mem_t *const rtc_retain_mem = (rtc_retain_mem_t *)RTC_RETAIN_MEM_ADDR;
|
||||
|
||||
#ifndef BOOTLOADER_BUILD
|
||||
#include "heap_memory_layout.h"
|
||||
/* The app needs to be told this memory is reserved, important if configured to use RTC memory as heap.
|
||||
|
||||
Note that keeping this macro here only works when other symbols in this file are referenced by the app, as
|
||||
this feature is otherwise 100% part of the bootloader. However this seems to happen in all apps.
|
||||
*/
|
||||
SOC_RESERVE_MEMORY_REGION(RTC_RETAIN_MEM_ADDR, RTC_RETAIN_MEM_ADDR + sizeof(rtc_retain_mem_t), rtc_retain_mem);
|
||||
#endif
|
||||
|
||||
static uint32_t rtc_retain_mem_size(void) {
|
||||
#ifdef CONFIG_BOOTLOADER_CUSTOM_RESERVE_RTC
|
||||
/* A custom memory has been reserved by the user, do not consider this memory into CRC calculation as it may change without
|
||||
@@ -128,31 +144,29 @@ static uint32_t rtc_retain_mem_size(void) {
|
||||
* minus the size of everything after (including) `custom` */
|
||||
return offsetof(rtc_retain_mem_t, custom);
|
||||
#else
|
||||
return sizeof(rtc_retain_mem_t) - sizeof(bootloader_common_get_rtc_retain_mem()->crc);
|
||||
return sizeof(rtc_retain_mem_t) - sizeof(rtc_retain_mem->crc);
|
||||
#endif
|
||||
}
|
||||
|
||||
static bool is_retain_mem_valid(void)
|
||||
{
|
||||
rtc_retain_mem_t* rtc_retain_mem = bootloader_common_get_rtc_retain_mem();
|
||||
return esp_rom_crc32_le(UINT32_MAX, (uint8_t*)rtc_retain_mem, rtc_retain_mem_size()) == rtc_retain_mem->crc && rtc_retain_mem->crc != UINT32_MAX;
|
||||
}
|
||||
|
||||
static void update_rtc_retain_mem_crc(void)
|
||||
{
|
||||
rtc_retain_mem_t* rtc_retain_mem = bootloader_common_get_rtc_retain_mem();
|
||||
rtc_retain_mem->crc = esp_rom_crc32_le(UINT32_MAX, (uint8_t*)rtc_retain_mem, rtc_retain_mem_size());
|
||||
}
|
||||
|
||||
NOINLINE_ATTR void bootloader_common_reset_rtc_retain_mem(void)
|
||||
{
|
||||
hal_memset(bootloader_common_get_rtc_retain_mem(), 0, sizeof(rtc_retain_mem_t));
|
||||
hal_memset(rtc_retain_mem, 0, sizeof(rtc_retain_mem_t));
|
||||
}
|
||||
|
||||
uint16_t bootloader_common_get_rtc_retain_mem_reboot_counter(void)
|
||||
{
|
||||
if (is_retain_mem_valid()) {
|
||||
return bootloader_common_get_rtc_retain_mem()->reboot_counter;
|
||||
return rtc_retain_mem->reboot_counter;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -162,13 +176,12 @@ void bootloader_common_set_rtc_retain_mem_factory_reset_state(void)
|
||||
if (!is_retain_mem_valid()) {
|
||||
bootloader_common_reset_rtc_retain_mem();
|
||||
}
|
||||
bootloader_common_get_rtc_retain_mem()->flags.factory_reset_state = true;
|
||||
rtc_retain_mem->flags.factory_reset_state = true;
|
||||
update_rtc_retain_mem_crc();
|
||||
}
|
||||
|
||||
bool bootloader_common_get_rtc_retain_mem_factory_reset_state(void)
|
||||
{
|
||||
rtc_retain_mem_t* rtc_retain_mem = bootloader_common_get_rtc_retain_mem();
|
||||
if (is_retain_mem_valid()) {
|
||||
bool factory_reset_state = rtc_retain_mem->flags.factory_reset_state;
|
||||
if (factory_reset_state == true) {
|
||||
@@ -183,14 +196,13 @@ bool bootloader_common_get_rtc_retain_mem_factory_reset_state(void)
|
||||
esp_partition_pos_t* bootloader_common_get_rtc_retain_mem_partition(void)
|
||||
{
|
||||
if (is_retain_mem_valid()) {
|
||||
return &bootloader_common_get_rtc_retain_mem()->partition;
|
||||
return &rtc_retain_mem->partition;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void bootloader_common_update_rtc_retain_mem(esp_partition_pos_t* partition, bool reboot_counter)
|
||||
{
|
||||
rtc_retain_mem_t* rtc_retain_mem = bootloader_common_get_rtc_retain_mem();
|
||||
if (reboot_counter) {
|
||||
if (!is_retain_mem_valid()) {
|
||||
bootloader_common_reset_rtc_retain_mem();
|
||||
@@ -212,14 +224,7 @@ void bootloader_common_update_rtc_retain_mem(esp_partition_pos_t* partition, boo
|
||||
|
||||
rtc_retain_mem_t* bootloader_common_get_rtc_retain_mem(void)
|
||||
{
|
||||
#ifdef BOOTLOADER_BUILD
|
||||
#define RTC_RETAIN_MEM_ADDR (SOC_RTC_DRAM_HIGH - sizeof(rtc_retain_mem_t))
|
||||
static rtc_retain_mem_t *const s_bootloader_retain_mem = (rtc_retain_mem_t *)RTC_RETAIN_MEM_ADDR;
|
||||
return s_bootloader_retain_mem;
|
||||
#else
|
||||
static __attribute__((section(".bootloader_data_rtc_mem"))) rtc_retain_mem_t s_bootloader_retain_mem;
|
||||
return &s_bootloader_retain_mem;
|
||||
#endif // !BOOTLOADER_BUILD
|
||||
return rtc_retain_mem;
|
||||
}
|
||||
|
||||
#endif // CONFIG_BOOTLOADER_RESERVE_RTC_MEM
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2020-2023 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2020-2022 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -18,9 +18,6 @@
|
||||
#include "esp32s2/rom/usb/cdc_acm.h"
|
||||
#include "esp32s2/rom/usb/usb_common.h"
|
||||
#endif
|
||||
#if SOC_USB_SERIAL_JTAG_SUPPORTED
|
||||
#include "hal/usb_phy_ll.h"
|
||||
#endif
|
||||
#include "esp_rom_gpio.h"
|
||||
#include "esp_rom_uart.h"
|
||||
#include "esp_rom_sys.h"
|
||||
@@ -98,12 +95,8 @@ void bootloader_console_init(void)
|
||||
#endif
|
||||
|
||||
esp_rom_uart_usb_acm_init(s_usb_cdc_buf, sizeof(s_usb_cdc_buf));
|
||||
esp_rom_uart_set_as_console(ESP_ROM_USB_OTG_NUM);
|
||||
esp_rom_uart_set_as_console(ESP_ROM_UART_USB);
|
||||
esp_rom_install_channel_putc(1, bootloader_console_write_char_usb);
|
||||
#if SOC_USB_SERIAL_JTAG_SUPPORTED
|
||||
usb_phy_ll_usb_wrap_pad_enable(&USB_WRAP, true);
|
||||
usb_phy_ll_int_otg_enable(&USB_WRAP);
|
||||
#endif
|
||||
}
|
||||
#endif //CONFIG_ESP_CONSOLE_USB_CDC
|
||||
|
||||
|
||||
@@ -27,6 +27,9 @@ int bootloader_clock_get_rated_freq_mhz(void)
|
||||
#elif CONFIG_IDF_TARGET_ESP32C3
|
||||
return 160;
|
||||
|
||||
#elif CONFIG_IDF_TARGET_ESP32H4
|
||||
return 96;
|
||||
|
||||
#elif CONFIG_IDF_TARGET_ESP32C6
|
||||
return 160;
|
||||
|
||||
|
||||
@@ -26,11 +26,9 @@ void abort(void)
|
||||
#if !CONFIG_ESP_SYSTEM_PANIC_SILENT_REBOOT
|
||||
esp_rom_printf("abort() was called at PC 0x%08x\r\n", (intptr_t)__builtin_return_address(0) - 3);
|
||||
#endif
|
||||
#if CONFIG_ESP_DEBUG_OCDAWARE
|
||||
if (esp_cpu_dbgr_is_attached()) {
|
||||
esp_cpu_dbgr_break();
|
||||
}
|
||||
#endif
|
||||
while (1) {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,10 +8,6 @@
|
||||
#include "esp_cpu.h"
|
||||
#include "soc/wdev_reg.h"
|
||||
|
||||
#if SOC_LP_TIMER_SUPPORTED
|
||||
#include "hal/lp_timer_hal.h"
|
||||
#endif
|
||||
|
||||
#ifndef BOOTLOADER_BUILD
|
||||
#include "esp_random.h"
|
||||
#include "esp_private/periph_ctrl.h"
|
||||
@@ -24,14 +20,9 @@
|
||||
#else
|
||||
|
||||
#if !defined CONFIG_IDF_TARGET_ESP32S3
|
||||
#if (defined CONFIG_IDF_TARGET_ESP32C6 || defined CONFIG_IDF_TARGET_ESP32H2)
|
||||
#define RNG_CPU_WAIT_CYCLE_NUM (80 * 16) // Keep the byte sampling frequency in the ~62KHz range which has been
|
||||
// tested.
|
||||
#else
|
||||
#define RNG_CPU_WAIT_CYCLE_NUM (80 * 32 * 2) /* extra factor of 2 is precautionary */
|
||||
#endif
|
||||
#define RNG_CPU_WAIT_CYCLE_NUM (80 * 32 * 2) /* extra factor of 2 is precautionary */
|
||||
#else
|
||||
#define RNG_CPU_WAIT_CYCLE_NUM (80 * 23) /* 45 KHz reading frequency is the maximum we have tested so far on S3 */
|
||||
#define RNG_CPU_WAIT_CYCLE_NUM (80 * 23) /* 45 KHz reading frequency is the maximum we have tested so far on S3 */
|
||||
#endif
|
||||
|
||||
__attribute__((weak)) void bootloader_fill_random(void *buffer, size_t length)
|
||||
@@ -43,21 +34,6 @@
|
||||
assert(buffer != NULL);
|
||||
|
||||
for (size_t i = 0; i < length; i++) {
|
||||
#if SOC_LP_TIMER_SUPPORTED
|
||||
random = REG_READ(WDEV_RND_REG);
|
||||
start = esp_cpu_get_cycle_count();
|
||||
do {
|
||||
random ^= REG_READ(WDEV_RND_REG);
|
||||
now = esp_cpu_get_cycle_count();
|
||||
} while (now - start < RNG_CPU_WAIT_CYCLE_NUM);
|
||||
|
||||
// XOR the RT slow clock, which is asynchronous, to add some entropy and improve
|
||||
// the distribution
|
||||
uint32_t current_rtc_timer_counter = (lp_timer_hal_get_cycle_count() & 0xFF);
|
||||
random = random ^ current_rtc_timer_counter;
|
||||
|
||||
buffer_bytes[i] = random & 0xFF;
|
||||
#else
|
||||
if (i == 0 || i % 4 == 0) { /* redundant check is for a compiler warning */
|
||||
/* in bootloader with ADC feeding HWRNG, we accumulate 1
|
||||
bit of entropy per 40 APB cycles (==80 CPU cycles.)
|
||||
@@ -74,7 +50,6 @@
|
||||
} while (now - start < RNG_CPU_WAIT_CYCLE_NUM);
|
||||
}
|
||||
buffer_bytes[i] = random >> ((i % 4) * 8);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,99 +1,22 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
#include "sdkconfig.h"
|
||||
#include "bootloader_random.h"
|
||||
#include "soc/soc.h"
|
||||
#include "soc/pcr_reg.h"
|
||||
#include "soc/apb_saradc_reg.h"
|
||||
#include "soc/pmu_reg.h"
|
||||
#include "hal/regi2c_ctrl.h"
|
||||
#include "soc/regi2c_saradc.h"
|
||||
#include "esp_log.h"
|
||||
|
||||
static const uint32_t SAR2_CHANNEL = 9;
|
||||
static const uint32_t PATTERN_BIT_WIDTH = 6;
|
||||
static const uint32_t SAR1_ATTEN = 1;
|
||||
static const uint32_t SAR2_ATTEN = 1;
|
||||
static const char *TAG = "bootloader_random";
|
||||
|
||||
void bootloader_random_enable(void)
|
||||
{
|
||||
// pull SAR ADC out of reset
|
||||
REG_SET_BIT(PCR_SARADC_CONF_REG, PCR_SARADC_RST_EN);
|
||||
REG_CLR_BIT(PCR_SARADC_CONF_REG, PCR_SARADC_RST_EN);
|
||||
|
||||
// enable SAR ADC APB clock
|
||||
REG_SET_BIT(PCR_SARADC_CONF_REG, PCR_SARADC_REG_CLK_EN);
|
||||
|
||||
// enable ADC_CTRL_CLK (SAR ADC function clock)
|
||||
REG_SET_BIT(PCR_SARADC_CLKM_CONF_REG, PCR_SARADC_CLKM_EN);
|
||||
|
||||
// select XTAL clock (40 MHz) source for ADC_CTRL_CLK
|
||||
REG_SET_FIELD(PCR_SARADC_CLKM_CONF_REG, PCR_SARADC_CLKM_SEL, 0);
|
||||
|
||||
// set the clock divider for ADC_CTRL_CLK to default value (in case it has been changed)
|
||||
REG_SET_FIELD(PCR_SARADC_CLKM_CONF_REG, PCR_SARADC_CLKM_DIV_NUM, 0);
|
||||
|
||||
// some ADC sensor registers are in power group PERIF_I2C and need to be enabled via PMU
|
||||
SET_PERI_REG_MASK(PMU_RF_PWC_REG, PMU_PERIF_I2C_RSTB);
|
||||
SET_PERI_REG_MASK(PMU_RF_PWC_REG, PMU_XPD_PERIF_I2C);
|
||||
|
||||
// Config ADC circuit (Analog part) with I2C(HOST ID 0x69) and chose internal voltage as sampling source
|
||||
REGI2C_WRITE_MASK(I2C_SAR_ADC, ADC_SARADC_DTEST_RTC_ADDR , 2);
|
||||
REGI2C_WRITE_MASK(I2C_SAR_ADC, ADC_SARADC_ENT_RTC_ADDR , 1);
|
||||
REGI2C_WRITE_MASK(I2C_SAR_ADC, ADC_SARADC1_ENCAL_REF_ADDR, 1);
|
||||
REGI2C_WRITE_MASK(I2C_SAR_ADC, ADC_SARADC2_ENCAL_REF_ADDR, 1);
|
||||
|
||||
REGI2C_WRITE_MASK(I2C_SAR_ADC, ADC_SAR2_INITIAL_CODE_HIGH_ADDR, 0x08);
|
||||
REGI2C_WRITE_MASK(I2C_SAR_ADC, ADC_SAR2_INITIAL_CODE_LOW_ADDR, 0x66);
|
||||
REGI2C_WRITE_MASK(I2C_SAR_ADC, ADC_SAR1_INITIAL_CODE_HIGH_ADDR, 0x08);
|
||||
REGI2C_WRITE_MASK(I2C_SAR_ADC, ADC_SAR1_INITIAL_CODE_LOW_ADDR, 0x66);
|
||||
|
||||
// create patterns and set them in pattern table
|
||||
uint32_t pattern_one = (SAR2_CHANNEL << 2) | SAR2_ATTEN; // we want channel 9 with max attenuation
|
||||
uint32_t pattern_two = SAR1_ATTEN; // we want channel 0 with max attenuation, channel doesn't really matter here
|
||||
uint32_t pattern_table = 0 | (pattern_two << 3 * PATTERN_BIT_WIDTH) | pattern_one << 2 * PATTERN_BIT_WIDTH;
|
||||
REG_WRITE(APB_SARADC_SAR_PATT_TAB1_REG, pattern_table);
|
||||
|
||||
// set pattern length to 2 (APB_SARADC_SAR_PATT_LEN counts from 0)
|
||||
REG_SET_FIELD(APB_SARADC_CTRL_REG, APB_SARADC_SARADC_SAR_PATT_LEN, 1);
|
||||
|
||||
// Same as in C3
|
||||
REG_SET_FIELD(APB_SARADC_CTRL_REG, APB_SARADC_SARADC_SAR_CLK_DIV, 15);
|
||||
|
||||
// set timer expiry (timer is ADC_CTRL_CLK)
|
||||
REG_SET_FIELD(APB_SARADC_CTRL2_REG, APB_SARADC_SARADC_TIMER_TARGET, 200);
|
||||
|
||||
// enable timer
|
||||
REG_SET_BIT(APB_SARADC_CTRL2_REG, APB_SARADC_SARADC_TIMER_EN);
|
||||
// TODO: IDF-5352
|
||||
ESP_EARLY_LOGW(TAG, "bootloader_random_enable() has not been implemented yet");
|
||||
}
|
||||
|
||||
void bootloader_random_disable(void)
|
||||
{
|
||||
// disable timer
|
||||
REG_CLR_BIT(APB_SARADC_CTRL2_REG, APB_SARADC_SARADC_TIMER_EN);
|
||||
|
||||
// Write reset value of this register
|
||||
REG_WRITE(APB_SARADC_SAR_PATT_TAB1_REG, 0xFFFFFF);
|
||||
|
||||
// Revert ADC I2C configuration and initial voltage source setting
|
||||
REGI2C_WRITE_MASK(I2C_SAR_ADC, ADC_SAR2_INITIAL_CODE_HIGH_ADDR, 0x60);
|
||||
REGI2C_WRITE_MASK(I2C_SAR_ADC, ADC_SAR2_INITIAL_CODE_LOW_ADDR, 0x0);
|
||||
REGI2C_WRITE_MASK(I2C_SAR_ADC, ADC_SAR1_INITIAL_CODE_HIGH_ADDR, 0x60);
|
||||
REGI2C_WRITE_MASK(I2C_SAR_ADC, ADC_SAR1_INITIAL_CODE_LOW_ADDR, 0x0);
|
||||
REGI2C_WRITE_MASK(I2C_SAR_ADC, ADC_SARADC_DTEST_RTC_ADDR, 0);
|
||||
REGI2C_WRITE_MASK(I2C_SAR_ADC, ADC_SARADC_ENT_RTC_ADDR, 0);
|
||||
REGI2C_WRITE_MASK(I2C_SAR_ADC, ADC_SARADC1_ENCAL_REF_ADDR, 0);
|
||||
REGI2C_WRITE_MASK(I2C_SAR_ADC, ADC_SARADC2_ENCAL_REF_ADDR, 0);
|
||||
|
||||
// Revert PMU_RF_PWC_REG to it's initial value
|
||||
CLEAR_PERI_REG_MASK(PMU_RF_PWC_REG, PMU_PERIF_I2C_RSTB);
|
||||
|
||||
// disable ADC_CTRL_CLK (SAR ADC function clock)
|
||||
REG_WRITE(PCR_SARADC_CLKM_CONF_REG, 0x00404000);
|
||||
|
||||
// Set PCR_SARADC_CONF_REG to initial state
|
||||
REG_WRITE(PCR_SARADC_CONF_REG, 0x5);
|
||||
// TODO: IDF-5352
|
||||
ESP_EARLY_LOGW(TAG, "bootloader_random_enable() has not been implemented yet");
|
||||
}
|
||||
|
||||
@@ -1,88 +1,21 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
#include "sdkconfig.h"
|
||||
#include "bootloader_random.h"
|
||||
#include "soc/soc.h"
|
||||
#include "soc/pcr_reg.h"
|
||||
#include "soc/apb_saradc_reg.h"
|
||||
#include "soc/pmu_reg.h"
|
||||
#include "hal/regi2c_ctrl.h"
|
||||
#include "soc/regi2c_saradc.h"
|
||||
#include "esp_log.h"
|
||||
|
||||
static const uint32_t SAR2_CHANNEL = 9;
|
||||
static const uint32_t PATTERN_BIT_WIDTH = 6;
|
||||
static const uint32_t SAR1_ATTEN = 1;
|
||||
static const uint32_t SAR2_ATTEN = 1;
|
||||
|
||||
static const char *TAG = "bootloader_random";
|
||||
void bootloader_random_enable(void)
|
||||
{
|
||||
REG_SET_BIT(PCR_SARADC_CONF_REG, PCR_SARADC_RST_EN);
|
||||
REG_CLR_BIT(PCR_SARADC_CONF_REG, PCR_SARADC_RST_EN);
|
||||
|
||||
REG_SET_BIT(PCR_SARADC_CONF_REG, PCR_SARADC_REG_CLK_EN);
|
||||
|
||||
REG_SET_BIT(PCR_SARADC_CLKM_CONF_REG, PCR_SARADC_CLKM_EN);
|
||||
|
||||
// select XTAL clock (40 MHz) source for ADC_CTRL_CLK
|
||||
REG_SET_FIELD(PCR_SARADC_CLKM_CONF_REG, PCR_SARADC_CLKM_SEL, 0);
|
||||
|
||||
REG_SET_FIELD(PCR_SARADC_CLKM_CONF_REG, PCR_SARADC_CLKM_DIV_NUM, 0);
|
||||
|
||||
// some ADC sensor registers are in power group PERIF_I2C and need to be enabled via PMU
|
||||
SET_PERI_REG_MASK(PMU_RF_PWC_REG, PMU_XPD_PERIF_I2C);
|
||||
|
||||
REGI2C_WRITE_MASK(I2C_SAR_ADC, I2C_SARADC_DTEST, 0);
|
||||
REGI2C_WRITE_MASK(I2C_SAR_ADC, I2C_SARADC_ENT_SAR, 1);
|
||||
REGI2C_WRITE_MASK(I2C_SAR_ADC, I2C_SARADC_EN_TOUT_SAR1_BUS, 1);
|
||||
|
||||
REGI2C_WRITE_MASK(I2C_SAR_ADC, I2C_SARADC_SAR2_INIT_CODE_MSB, 0X08);
|
||||
REGI2C_WRITE_MASK(I2C_SAR_ADC, I2C_SARADC_SAR2_INIT_CODE_LSB, 0X66);
|
||||
REGI2C_WRITE_MASK(I2C_SAR_ADC, I2C_SARADC_SAR1_INIT_CODE_MSB, 0X08);
|
||||
REGI2C_WRITE_MASK(I2C_SAR_ADC, I2C_SARADC_SAR1_INIT_CODE_LSB, 0X66);
|
||||
|
||||
// create patterns and set them in pattern table
|
||||
uint32_t pattern_one = (SAR2_CHANNEL << 2) | SAR2_ATTEN;
|
||||
uint32_t pattern_two = SAR1_ATTEN; // we want channel 0 with max attenuation, channel doesn't really matter here
|
||||
uint32_t pattern_table = 0 | (pattern_two << 3 * PATTERN_BIT_WIDTH) | pattern_one << 2 * PATTERN_BIT_WIDTH;
|
||||
REG_WRITE(APB_SARADC_SAR_PATT_TAB1_REG, pattern_table);
|
||||
|
||||
// set pattern length to 2 (APB_SARADC_SAR_PATT_LEN counts from 0)
|
||||
REG_SET_FIELD(APB_SARADC_CTRL_REG, APB_SARADC_SARADC_SAR_PATT_LEN, 0);
|
||||
|
||||
// Same as in C3
|
||||
REG_SET_FIELD(APB_SARADC_CTRL_REG, APB_SARADC_SARADC_SAR_CLK_DIV, 15);
|
||||
|
||||
// set timer expiry (timer is ADC_CTRL_CLK)
|
||||
REG_SET_FIELD(APB_SARADC_CTRL2_REG, APB_SARADC_SARADC_TIMER_TARGET, 200);
|
||||
|
||||
// ENABLE_TIMER
|
||||
REG_SET_BIT(APB_SARADC_CTRL2_REG, APB_SARADC_SARADC_TIMER_EN);
|
||||
// ESP32H2-TODO: IDF-6274
|
||||
ESP_EARLY_LOGW(TAG, "bootloader_random_enable() has not been implemented yet");
|
||||
}
|
||||
|
||||
void bootloader_random_disable(void)
|
||||
{
|
||||
// disable timer
|
||||
REG_CLR_BIT(APB_SARADC_CTRL2_REG, APB_SARADC_SARADC_TIMER_EN);
|
||||
|
||||
// Write reset value of this register
|
||||
REG_WRITE(APB_SARADC_SAR_PATT_TAB1_REG, 0xFFFFFF);
|
||||
|
||||
// Revert ADC I2C configuration and initial voltage source setting
|
||||
REGI2C_WRITE_MASK(I2C_SAR_ADC, I2C_SARADC_SAR2_INIT_CODE_MSB, 0x60);
|
||||
REGI2C_WRITE_MASK(I2C_SAR_ADC, I2C_SARADC_SAR2_INIT_CODE_LSB, 0x0);
|
||||
REGI2C_WRITE_MASK(I2C_SAR_ADC, I2C_SARADC_SAR1_INIT_CODE_MSB, 0x60);
|
||||
REGI2C_WRITE_MASK(I2C_SAR_ADC, I2C_SARADC_SAR1_INIT_CODE_LSB, 0x0);
|
||||
REGI2C_WRITE_MASK(I2C_SAR_ADC, I2C_SARADC_DTEST, 0);
|
||||
REGI2C_WRITE_MASK(I2C_SAR_ADC, I2C_SARADC_ENT_SAR, 0);
|
||||
REGI2C_WRITE_MASK(I2C_SAR_ADC, I2C_SARADC_EN_TOUT_SAR1_BUS, 0);
|
||||
|
||||
// disable ADC_CTRL_CLK (SAR ADC function clock)
|
||||
REG_WRITE(PCR_SARADC_CLKM_CONF_REG, 0x00404000);
|
||||
|
||||
// Set PCR_SARADC_CONF_REG to initial state
|
||||
REG_WRITE(PCR_SARADC_CONF_REG, 0x5);
|
||||
// ESP32H2-TODO: IDF-6274
|
||||
ESP_EARLY_LOGW(TAG, "bootloader_random_disable() has not been implemented yet");
|
||||
}
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2020-2021 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
#include "sdkconfig.h"
|
||||
#include "bootloader_random.h"
|
||||
#include "esp_log.h"
|
||||
#include "soc/syscon_reg.h"
|
||||
#include "soc/rtc_cntl_reg.h"
|
||||
#include "soc/apb_saradc_reg.h"
|
||||
#include "soc/system_reg.h"
|
||||
#include "esp_private/regi2c_ctrl.h"
|
||||
|
||||
// ESP32H4-TODO: IDF-3381
|
||||
void bootloader_random_enable(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void bootloader_random_disable(void)
|
||||
{
|
||||
|
||||
}
|
||||
@@ -28,6 +28,12 @@
|
||||
#include "esp32c3/rom/uart.h"
|
||||
#include "esp32c3/rom/gpio.h"
|
||||
#include "esp32c3/rom/secure_boot.h"
|
||||
#elif CONFIG_IDF_TARGET_ESP32H4
|
||||
#include "esp32h4/rom/efuse.h"
|
||||
#include "esp32h4/rom/crc.h"
|
||||
#include "esp32h4/rom/uart.h"
|
||||
#include "esp32h4/rom/gpio.h"
|
||||
#include "esp32h4/rom/secure_boot.h"
|
||||
#elif CONFIG_IDF_TARGET_ESP32C2
|
||||
#include "esp32c2/rom/efuse.h"
|
||||
#include "esp32c2/rom/crc.h"
|
||||
|
||||
@@ -3,10 +3,18 @@
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
//Not supported but common bootloader calls the function. Do nothing
|
||||
void bootloader_ana_super_wdt_reset_config(bool enable)
|
||||
{
|
||||
(void)enable;
|
||||
}
|
||||
|
||||
void bootloader_ana_bod_reset_config(bool enable)
|
||||
{
|
||||
(void)enable;
|
||||
}
|
||||
|
||||
void bootloader_ana_clock_glitch_reset_config(bool enable)
|
||||
{
|
||||
(void)enable;
|
||||
|
||||
@@ -34,7 +34,6 @@
|
||||
#include "bootloader_mem.h"
|
||||
#include "bootloader_console.h"
|
||||
#include "bootloader_flash_priv.h"
|
||||
#include "bootloader_soc.h"
|
||||
#include "esp_private/bootloader_flash_internal.h"
|
||||
#include "esp_efuse.h"
|
||||
#include "hal/mmu_hal.h"
|
||||
@@ -79,19 +78,10 @@ static void bootloader_super_wdt_auto_feed(void)
|
||||
REG_WRITE(RTC_CNTL_SWD_WPROTECT_REG, 0);
|
||||
}
|
||||
|
||||
static inline void bootloader_ana_reset_config(void)
|
||||
{
|
||||
//Enable super WDT reset.
|
||||
bootloader_ana_super_wdt_reset_config(true);
|
||||
//Enable BOD reset
|
||||
bootloader_ana_bod_reset_config(true);
|
||||
}
|
||||
|
||||
esp_err_t bootloader_init(void)
|
||||
{
|
||||
esp_err_t ret = ESP_OK;
|
||||
|
||||
bootloader_ana_reset_config();
|
||||
bootloader_super_wdt_auto_feed();
|
||||
|
||||
// In RAM_APP, memory will be initialized in `call_start_cpu0`
|
||||
|
||||
@@ -3,34 +3,19 @@
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include "soc/rtc_cntl_reg.h"
|
||||
|
||||
void bootloader_ana_super_wdt_reset_config(bool enable)
|
||||
{
|
||||
REG_CLR_BIT(RTC_CNTL_FIB_SEL_REG, RTC_CNTL_FIB_SUPER_WDT_RST);
|
||||
|
||||
if (enable) {
|
||||
REG_CLR_BIT(RTC_CNTL_SWD_CONF_REG, RTC_CNTL_SWD_BYPASS_RST);
|
||||
} else {
|
||||
REG_SET_BIT(RTC_CNTL_SWD_CONF_REG, RTC_CNTL_SWD_BYPASS_RST);
|
||||
}
|
||||
(void)enable; // ESP32-C2 has none of these features.
|
||||
}
|
||||
|
||||
void bootloader_ana_bod_reset_config(bool enable)
|
||||
{
|
||||
REG_CLR_BIT(RTC_CNTL_FIB_SEL_REG, RTC_CNTL_FIB_BOD_RST);
|
||||
|
||||
if (enable) {
|
||||
REG_SET_BIT(RTC_CNTL_BROWN_OUT_REG, RTC_CNTL_BROWN_OUT_ANA_RST_EN);
|
||||
} else {
|
||||
REG_CLR_BIT(RTC_CNTL_BROWN_OUT_REG, RTC_CNTL_BROWN_OUT_ANA_RST_EN);
|
||||
}
|
||||
(void)enable; // ESP32-C2 has none of these features.
|
||||
}
|
||||
|
||||
//Not supported but common bootloader calls the function. Do nothing
|
||||
void bootloader_ana_clock_glitch_reset_config(bool enable)
|
||||
{
|
||||
(void)enable;
|
||||
(void)enable; // ESP32-C2 has none of these features.
|
||||
}
|
||||
|
||||
@@ -96,29 +96,29 @@ static inline void bootloader_hardware_init(void)
|
||||
|
||||
static inline void bootloader_ana_reset_config(void)
|
||||
{
|
||||
//Enable super WDT reset.
|
||||
bootloader_ana_super_wdt_reset_config(true);
|
||||
|
||||
/*
|
||||
For origin chip & ECO1: brownout & clock glitch reset not available
|
||||
For ECO2: fix brownout reset bug
|
||||
For ECO3: fix clock glitch reset bug
|
||||
For origin chip & ECO1: only support swt reset;
|
||||
For ECO2: fix brownout reset bug, support swt & brownout reset;
|
||||
For ECO3: fix clock glitch reset bug, support all reset, include: swt & brownout & clock glitch reset.
|
||||
*/
|
||||
switch (efuse_hal_chip_revision()) {
|
||||
case 0:
|
||||
case 1:
|
||||
//Disable BOD and GLITCH reset
|
||||
//Enable WDT reset. Disable BOR and GLITCH reset
|
||||
bootloader_ana_super_wdt_reset_config(true);
|
||||
bootloader_ana_bod_reset_config(false);
|
||||
bootloader_ana_clock_glitch_reset_config(false);
|
||||
break;
|
||||
case 2:
|
||||
//Enable BOD reset. Disable GLITCH reset
|
||||
//Enable WDT and BOR reset. Disable GLITCH reset
|
||||
bootloader_ana_super_wdt_reset_config(true);
|
||||
bootloader_ana_bod_reset_config(true);
|
||||
bootloader_ana_clock_glitch_reset_config(false);
|
||||
break;
|
||||
case 3:
|
||||
default:
|
||||
//Enable BOD, and GLITCH reset
|
||||
//Enable WDT, BOR, and GLITCH reset
|
||||
bootloader_ana_super_wdt_reset_config(true);
|
||||
bootloader_ana_bod_reset_config(true);
|
||||
bootloader_ana_clock_glitch_reset_config(true);
|
||||
break;
|
||||
|
||||
@@ -12,15 +12,15 @@ void bootloader_ana_super_wdt_reset_config(bool enable)
|
||||
REG_CLR_BIT(RTC_CNTL_FIB_SEL_REG, RTC_CNTL_FIB_SUPER_WDT_RST);
|
||||
|
||||
if (enable) {
|
||||
REG_CLR_BIT(RTC_CNTL_SWD_CONF_REG, RTC_CNTL_SWD_BYPASS_RST);
|
||||
} else {
|
||||
REG_SET_BIT(RTC_CNTL_SWD_CONF_REG, RTC_CNTL_SWD_BYPASS_RST);
|
||||
} else {
|
||||
REG_CLR_BIT(RTC_CNTL_SWD_CONF_REG, RTC_CNTL_SWD_BYPASS_RST);
|
||||
}
|
||||
}
|
||||
|
||||
void bootloader_ana_bod_reset_config(bool enable)
|
||||
{
|
||||
REG_CLR_BIT(RTC_CNTL_FIB_SEL_REG, RTC_CNTL_FIB_BOD_RST);
|
||||
REG_CLR_BIT(RTC_CNTL_FIB_SEL_REG, RTC_CNTL_FIB_BOR_RST);
|
||||
|
||||
if (enable) {
|
||||
REG_SET_BIT(RTC_CNTL_BROWN_OUT_REG, RTC_CNTL_BROWN_OUT_ANA_RST_EN);
|
||||
|
||||
@@ -103,10 +103,33 @@ static inline void bootloader_hardware_init(void)
|
||||
|
||||
static inline void bootloader_ana_reset_config(void)
|
||||
{
|
||||
//Enable super WDT reset.
|
||||
bootloader_ana_super_wdt_reset_config(true);
|
||||
//Enable BOD reset
|
||||
bootloader_ana_bod_reset_config(true);
|
||||
// TODO: IDF-5990 copied from C3, need update
|
||||
// Have removed bootloader_ana_super_wdt_reset_config for now; can be evaluated later to see whether needs to add it back
|
||||
/*
|
||||
For origin chip & ECO1: only support swt reset;
|
||||
For ECO2: fix brownout reset bug, support swt & brownout reset;
|
||||
For ECO3: fix clock glitch reset bug, support all reset, include: swt & brownout & clock glitch reset.
|
||||
*/
|
||||
uint8_t chip_version = efuse_hal_get_minor_chip_version();
|
||||
switch (chip_version) {
|
||||
case 0:
|
||||
case 1:
|
||||
//Disable BOR and GLITCH reset
|
||||
bootloader_ana_bod_reset_config(false);
|
||||
bootloader_ana_clock_glitch_reset_config(false);
|
||||
break;
|
||||
case 2:
|
||||
//Enable BOR reset. Disable GLITCH reset
|
||||
bootloader_ana_bod_reset_config(true);
|
||||
bootloader_ana_clock_glitch_reset_config(false);
|
||||
break;
|
||||
case 3:
|
||||
default:
|
||||
//Enable BOR, and GLITCH reset
|
||||
bootloader_ana_bod_reset_config(true);
|
||||
bootloader_ana_clock_glitch_reset_config(true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
esp_err_t bootloader_init(void)
|
||||
|
||||
@@ -1,24 +1,15 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
#include <stdbool.h>
|
||||
#include <assert.h>
|
||||
#include "soc/soc.h"
|
||||
#include "soc/lp_analog_peri_reg.h"
|
||||
|
||||
void bootloader_ana_super_wdt_reset_config(bool enable)
|
||||
{
|
||||
//C6 doesn't support bypass super WDT reset
|
||||
assert(enable);
|
||||
REG_CLR_BIT(LP_ANALOG_PERI_LP_ANA_FIB_ENABLE_REG, LP_ANALOG_PERI_LP_ANA_FIB_SUPER_WDT_RST);
|
||||
}
|
||||
|
||||
void bootloader_ana_bod_reset_config(bool enable)
|
||||
{
|
||||
REG_CLR_BIT(LP_ANALOG_PERI_LP_ANA_FIB_ENABLE_REG, LP_ANALOG_PERI_LP_ANA_FIB_BOD_RST);
|
||||
|
||||
REG_CLR_BIT(LP_ANALOG_PERI_LP_ANA_FIB_ENABLE_REG, LP_ANALOG_PERI_LP_ANA_FIB_BOR_RST);
|
||||
if (enable) {
|
||||
REG_SET_BIT(LP_ANALOG_PERI_LP_ANA_BOD_MODE1_CNTL_REG, LP_ANALOG_PERI_LP_ANA_BOD_MODE1_RESET_ENA);
|
||||
} else {
|
||||
@@ -26,8 +17,12 @@ void bootloader_ana_bod_reset_config(bool enable)
|
||||
}
|
||||
}
|
||||
|
||||
//Not supported but common bootloader calls the function. Do nothing
|
||||
void bootloader_ana_clock_glitch_reset_config(bool enable)
|
||||
{
|
||||
(void)enable;
|
||||
REG_CLR_BIT(LP_ANALOG_PERI_LP_ANA_FIB_ENABLE_REG, LP_ANALOG_PERI_LP_ANA_FIB_GLITCH_RST);
|
||||
if (enable) {
|
||||
REG_SET_BIT(LP_ANALOG_PERI_LP_ANA_CK_GLITCH_CNTL_REG, LP_ANALOG_PERI_LP_ANA_CK_GLITCH_RESET_ENA);
|
||||
} else {
|
||||
REG_CLR_BIT(LP_ANALOG_PERI_LP_ANA_CK_GLITCH_CNTL_REG, LP_ANALOG_PERI_LP_ANA_CK_GLITCH_RESET_ENA);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -86,16 +86,40 @@ static void bootloader_super_wdt_auto_feed(void)
|
||||
|
||||
static inline void bootloader_hardware_init(void)
|
||||
{
|
||||
// TODO: IDF-6267
|
||||
/* Enable analog i2c master clock */
|
||||
SET_PERI_REG_MASK(MODEM_LPCON_CLK_CONF_REG, MODEM_LPCON_CLK_I2C_MST_EN);
|
||||
}
|
||||
|
||||
static inline void bootloader_ana_reset_config(void)
|
||||
{
|
||||
//Enable super WDT reset.
|
||||
bootloader_ana_super_wdt_reset_config(true);
|
||||
//Enable BOD reset
|
||||
bootloader_ana_bod_reset_config(true);
|
||||
// TODO: IDF-5990 copied from C6, need update
|
||||
// Have removed bootloader_ana_super_wdt_reset_config for now; can be evaluated later to see whether needs to add it back
|
||||
/*
|
||||
For origin chip & ECO1: only support swt reset;
|
||||
For ECO2: fix brownout reset bug, support swt & brownout reset;
|
||||
For ECO3: fix clock glitch reset bug, support all reset, include: swt & brownout & clock glitch reset.
|
||||
*/
|
||||
uint8_t chip_version = efuse_hal_get_minor_chip_version();
|
||||
switch (chip_version) {
|
||||
case 0:
|
||||
case 1:
|
||||
//Disable BOR and GLITCH reset
|
||||
bootloader_ana_bod_reset_config(false);
|
||||
bootloader_ana_clock_glitch_reset_config(false);
|
||||
break;
|
||||
case 2:
|
||||
//Enable BOR reset. Disable GLITCH reset
|
||||
bootloader_ana_bod_reset_config(true);
|
||||
bootloader_ana_clock_glitch_reset_config(false);
|
||||
break;
|
||||
case 3:
|
||||
default:
|
||||
//Enable BOR, and GLITCH reset
|
||||
bootloader_ana_bod_reset_config(true);
|
||||
bootloader_ana_clock_glitch_reset_config(true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
esp_err_t bootloader_init(void)
|
||||
|
||||
@@ -1,22 +1,20 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
#include <stdbool.h>
|
||||
#include "soc/soc.h"
|
||||
#include "soc/lp_analog_peri_reg.h"
|
||||
|
||||
void bootloader_ana_super_wdt_reset_config(bool enable)
|
||||
{
|
||||
//H2 doesn't support bypass super WDT reset
|
||||
assert(enable);
|
||||
REG_CLR_BIT(LP_ANALOG_PERI_LP_ANA_FIB_ENABLE_REG, LP_ANALOG_PERI_LP_ANA_FIB_SUPER_WDT_RST);
|
||||
// ESP32H2 has removed the super wdt
|
||||
}
|
||||
|
||||
void bootloader_ana_bod_reset_config(bool enable)
|
||||
{
|
||||
REG_CLR_BIT(LP_ANALOG_PERI_LP_ANA_FIB_ENABLE_REG, LP_ANALOG_PERI_LP_ANA_FIB_BOD_RST);
|
||||
|
||||
REG_CLR_BIT(LP_ANALOG_PERI_LP_ANA_FIB_ENABLE_REG, LP_ANALOG_PERI_LP_ANA_FIB_BOR_RST);
|
||||
if (enable) {
|
||||
REG_SET_BIT(LP_ANALOG_PERI_LP_ANA_BOD_MODE1_CNTL_REG, LP_ANALOG_PERI_LP_ANA_BOD_MODE1_RESET_ENA);
|
||||
} else {
|
||||
@@ -24,8 +22,12 @@ void bootloader_ana_bod_reset_config(bool enable)
|
||||
}
|
||||
}
|
||||
|
||||
//Not supported but common bootloader calls the function. Do nothing
|
||||
void bootloader_ana_clock_glitch_reset_config(bool enable)
|
||||
{
|
||||
(void)enable;
|
||||
REG_CLR_BIT(LP_ANALOG_PERI_LP_ANA_FIB_ENABLE_REG, LP_ANALOG_PERI_LP_ANA_FIB_GLITCH_RST);
|
||||
if (enable) {
|
||||
REG_SET_BIT(LP_ANALOG_PERI_LP_ANA_CK_GLITCH_CNTL_REG, LP_ANALOG_PERI_LP_ANA_CK_GLITCH_RESET_ENA);
|
||||
} else {
|
||||
REG_CLR_BIT(LP_ANALOG_PERI_LP_ANA_CK_GLITCH_CNTL_REG, LP_ANALOG_PERI_LP_ANA_CK_GLITCH_RESET_ENA);
|
||||
}
|
||||
}
|
||||
|
||||
155
components/bootloader_support/src/esp32h4/bootloader_esp32h4.c
Normal file
155
components/bootloader_support/src/esp32h4/bootloader_esp32h4.c
Normal file
@@ -0,0 +1,155 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2020-2022 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
#include <stdint.h>
|
||||
#include "sdkconfig.h"
|
||||
#include "esp_attr.h"
|
||||
#include "esp_log.h"
|
||||
#include "esp_image_format.h"
|
||||
#include "flash_qio_mode.h"
|
||||
#include "esp_rom_gpio.h"
|
||||
#include "esp_rom_efuse.h"
|
||||
#include "esp_rom_uart.h"
|
||||
#include "esp_rom_sys.h"
|
||||
#include "esp_rom_spiflash.h"
|
||||
#include "soc/efuse_reg.h"
|
||||
#include "soc/gpio_sig_map.h"
|
||||
#include "soc/io_mux_reg.h"
|
||||
#include "soc/assist_debug_reg.h"
|
||||
#include "esp_cpu.h"
|
||||
#include "soc/rtc.h"
|
||||
#include "soc/rtc_cntl_reg.h"
|
||||
#include "soc/spi_periph.h"
|
||||
#include "soc/extmem_reg.h"
|
||||
#include "soc/io_mux_reg.h"
|
||||
#include "soc/system_reg.h"
|
||||
#include "esp32h4/rom/efuse.h"
|
||||
#include "esp32h4/rom/ets_sys.h"
|
||||
#include "bootloader_common.h"
|
||||
#include "bootloader_init.h"
|
||||
#include "bootloader_clock.h"
|
||||
#include "bootloader_flash_config.h"
|
||||
#include "bootloader_mem.h"
|
||||
#include "bootloader_console.h"
|
||||
#include "bootloader_flash_priv.h"
|
||||
#include "bootloader_soc.h"
|
||||
#include "esp_private/bootloader_flash_internal.h"
|
||||
#include "hal/mmu_hal.h"
|
||||
#include "hal/cache_hal.h"
|
||||
|
||||
static const char *TAG = "boot.esp32h4";
|
||||
|
||||
static void wdt_reset_cpu0_info_enable(void)
|
||||
{
|
||||
REG_SET_BIT(SYSTEM_CPU_PERI_CLK_EN_REG, SYSTEM_CLK_EN_ASSIST_DEBUG);
|
||||
REG_CLR_BIT(SYSTEM_CPU_PERI_RST_EN_REG, SYSTEM_RST_EN_ASSIST_DEBUG);
|
||||
REG_WRITE(ASSIST_DEBUG_CORE_0_RCD_EN_REG, ASSIST_DEBUG_CORE_0_RCD_PDEBUGEN | ASSIST_DEBUG_CORE_0_RCD_RECORDEN);
|
||||
}
|
||||
|
||||
static void wdt_reset_info_dump(int cpu)
|
||||
{
|
||||
(void) cpu;
|
||||
// saved PC was already printed by the ROM bootloader.
|
||||
// nothing to do here.
|
||||
}
|
||||
|
||||
static void bootloader_check_wdt_reset(void)
|
||||
{
|
||||
int wdt_rst = 0;
|
||||
soc_reset_reason_t rst_reason = esp_rom_get_reset_reason(0);
|
||||
if (rst_reason == RESET_REASON_CORE_RTC_WDT || rst_reason == RESET_REASON_CORE_MWDT0 || rst_reason == RESET_REASON_CORE_MWDT1 ||
|
||||
rst_reason == RESET_REASON_CPU0_MWDT0 || rst_reason == RESET_REASON_CPU0_MWDT1 || rst_reason == RESET_REASON_CPU0_RTC_WDT) {
|
||||
ESP_LOGW(TAG, "PRO CPU has been reset by WDT.");
|
||||
wdt_rst = 1;
|
||||
}
|
||||
if (wdt_rst) {
|
||||
// if reset by WDT dump info from trace port
|
||||
wdt_reset_info_dump(0);
|
||||
}
|
||||
wdt_reset_cpu0_info_enable();
|
||||
}
|
||||
|
||||
static void bootloader_super_wdt_auto_feed(void)
|
||||
{
|
||||
REG_WRITE(RTC_CNTL_SWD_WPROTECT_REG, RTC_CNTL_SWD_WKEY_VALUE);
|
||||
REG_SET_BIT(RTC_CNTL_SWD_CONF_REG, RTC_CNTL_SWD_AUTO_FEED_EN);
|
||||
REG_WRITE(RTC_CNTL_SWD_WPROTECT_REG, 0);
|
||||
}
|
||||
|
||||
static inline void bootloader_hardware_init(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
static inline void bootloader_ana_reset_config(void)
|
||||
{
|
||||
//Enable WDT, BOR, and GLITCH reset
|
||||
bootloader_ana_super_wdt_reset_config(true);
|
||||
bootloader_ana_bod_reset_config(true);
|
||||
bootloader_ana_clock_glitch_reset_config(true);
|
||||
}
|
||||
|
||||
esp_err_t bootloader_init(void)
|
||||
{
|
||||
esp_err_t ret = ESP_OK;
|
||||
|
||||
bootloader_hardware_init();
|
||||
bootloader_ana_reset_config();
|
||||
bootloader_super_wdt_auto_feed();
|
||||
|
||||
// In RAM_APP, memory will be initialized in `call_start_cpu0`
|
||||
#if !CONFIG_APP_BUILD_TYPE_RAM
|
||||
// protect memory region
|
||||
bootloader_init_mem();
|
||||
/* check that static RAM is after the stack */
|
||||
assert(&_bss_start <= &_bss_end);
|
||||
assert(&_data_start <= &_data_end);
|
||||
// clear bss section
|
||||
bootloader_clear_bss_section();
|
||||
#endif // !CONFIG_APP_BUILD_TYPE_RAM
|
||||
|
||||
// config clock
|
||||
bootloader_clock_configure();
|
||||
// initialize console, from now on, we can use esp_log
|
||||
bootloader_console_init();
|
||||
/* print 2nd bootloader banner */
|
||||
bootloader_print_banner();
|
||||
|
||||
#if !CONFIG_APP_BUILD_TYPE_PURE_RAM_APP
|
||||
//init cache hal
|
||||
cache_hal_init(); //TODO IDF-4649
|
||||
//init mmu
|
||||
mmu_hal_init();
|
||||
// update flash ID
|
||||
bootloader_flash_update_id();
|
||||
// Check and run XMC startup flow
|
||||
if ((ret = bootloader_flash_xmc_startup()) != ESP_OK) {
|
||||
ESP_LOGE(TAG, "failed when running XMC startup flow, reboot!");
|
||||
return ret;
|
||||
}
|
||||
#if !CONFIG_APP_BUILD_TYPE_RAM
|
||||
// read bootloader header
|
||||
if ((ret = bootloader_read_bootloader_header()) != ESP_OK) {
|
||||
return ret;
|
||||
}
|
||||
// read chip revision and check if it's compatible to bootloader
|
||||
if ((ret = bootloader_check_bootloader_validity()) != ESP_OK) {
|
||||
return ret;
|
||||
}
|
||||
#endif // !CONFIG_APP_BUILD_TYPE_RAM
|
||||
// initialize spi flash
|
||||
if ((ret = bootloader_init_spi_flash()) != ESP_OK) {
|
||||
return ret;
|
||||
}
|
||||
#endif // #if !CONFIG_APP_BUILD_TYPE_PURE_RAM_APP
|
||||
|
||||
// check whether a WDT reset happend
|
||||
bootloader_check_wdt_reset();
|
||||
// config WDT
|
||||
bootloader_config_wdt();
|
||||
// enable RNG early entropy source
|
||||
bootloader_enable_random();
|
||||
return ret;
|
||||
}
|
||||
40
components/bootloader_support/src/esp32h4/bootloader_sha.c
Normal file
40
components/bootloader_support/src/esp32h4/bootloader_sha.c
Normal file
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2020-2021 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
#include "bootloader_sha.h"
|
||||
#include <stdbool.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
#include <sys/param.h>
|
||||
|
||||
#include "esp32h4/rom/sha.h"
|
||||
|
||||
static SHA_CTX ctx;
|
||||
|
||||
bootloader_sha256_handle_t bootloader_sha256_start()
|
||||
{
|
||||
// Enable SHA hardware
|
||||
ets_sha_enable();
|
||||
ets_sha_init(&ctx, SHA2_256);
|
||||
return &ctx; // Meaningless non-NULL value
|
||||
}
|
||||
|
||||
void bootloader_sha256_data(bootloader_sha256_handle_t handle, const void *data, size_t data_len)
|
||||
{
|
||||
assert(handle != NULL);
|
||||
assert(data_len % 4 == 0);
|
||||
ets_sha_update(&ctx, data, data_len, false);
|
||||
}
|
||||
|
||||
void bootloader_sha256_finish(bootloader_sha256_handle_t handle, uint8_t *digest)
|
||||
{
|
||||
assert(handle != NULL);
|
||||
|
||||
if (digest == NULL) {
|
||||
bzero(&ctx, sizeof(ctx));
|
||||
return;
|
||||
}
|
||||
ets_sha_finish(&ctx, digest);
|
||||
}
|
||||
41
components/bootloader_support/src/esp32h4/bootloader_soc.c
Normal file
41
components/bootloader_support/src/esp32h4/bootloader_soc.c
Normal file
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2019-2021 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
#include <stdbool.h>
|
||||
#include "soc/soc.h"
|
||||
#include "soc/rtc_cntl_reg.h"
|
||||
|
||||
void bootloader_ana_super_wdt_reset_config(bool enable)
|
||||
{
|
||||
REG_CLR_BIT(RTC_CNTL_FIB_SEL_REG, RTC_CNTL_FIB_SUPER_WDT_RST);
|
||||
|
||||
if (enable) {
|
||||
REG_SET_BIT(RTC_CNTL_SWD_CONF_REG, RTC_CNTL_SWD_BYPASS_RST);
|
||||
} else {
|
||||
REG_CLR_BIT(RTC_CNTL_SWD_CONF_REG, RTC_CNTL_SWD_BYPASS_RST);
|
||||
}
|
||||
}
|
||||
|
||||
void bootloader_ana_bod_reset_config(bool enable)
|
||||
{
|
||||
REG_CLR_BIT(RTC_CNTL_FIB_SEL_REG, RTC_CNTL_FIB_BOR_RST);
|
||||
|
||||
if (enable) {
|
||||
REG_SET_BIT(RTC_CNTL_BROWN_OUT_REG, RTC_CNTL_BROWN_OUT_ANA_RST_EN);
|
||||
} else {
|
||||
REG_CLR_BIT(RTC_CNTL_BROWN_OUT_REG, RTC_CNTL_BROWN_OUT_ANA_RST_EN);
|
||||
}
|
||||
}
|
||||
|
||||
void bootloader_ana_clock_glitch_reset_config(bool enable)
|
||||
{
|
||||
REG_CLR_BIT(RTC_CNTL_FIB_SEL_REG, RTC_CNTL_FIB_GLITCH_RST);
|
||||
|
||||
if (enable) {
|
||||
REG_SET_BIT(RTC_CNTL_ANA_CONF_REG, RTC_CNTL_GLITCH_RST_EN);
|
||||
} else {
|
||||
REG_CLR_BIT(RTC_CNTL_ANA_CONF_REG, RTC_CNTL_GLITCH_RST_EN);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#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 "sdkconfig.h"
|
||||
|
||||
static __attribute__((unused)) const char *TAG = "flash_encrypt";
|
||||
|
||||
esp_err_t esp_flash_encryption_enable_secure_features(void)
|
||||
{
|
||||
#ifndef CONFIG_SECURE_FLASH_UART_BOOTLOADER_ALLOW_ENC
|
||||
ESP_LOGI(TAG, "Disable UART bootloader encryption...");
|
||||
esp_efuse_write_field_bit(ESP_EFUSE_DIS_DOWNLOAD_MANUAL_ENCRYPT);
|
||||
#else
|
||||
ESP_LOGW(TAG, "Not disabling UART bootloader encryption");
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_SECURE_FLASH_UART_BOOTLOADER_ALLOW_CACHE
|
||||
ESP_LOGI(TAG, "Disable UART bootloader cache...");
|
||||
esp_efuse_write_field_bit(ESP_EFUSE_DIS_DOWNLOAD_ICACHE);
|
||||
#else
|
||||
ESP_LOGW(TAG, "Not disabling UART bootloader cache - SECURITY COMPROMISED");
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_SECURE_BOOT_ALLOW_JTAG
|
||||
ESP_LOGI(TAG, "Disable JTAG...");
|
||||
esp_efuse_write_field_bit(ESP_EFUSE_DIS_PAD_JTAG);
|
||||
esp_efuse_write_field_bit(ESP_EFUSE_DIS_USB_JTAG);
|
||||
#else
|
||||
ESP_LOGW(TAG, "Not disabling JTAG - SECURITY COMPROMISED");
|
||||
#endif
|
||||
|
||||
esp_efuse_write_field_bit(ESP_EFUSE_DIS_DIRECT_BOOT);
|
||||
|
||||
#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
|
||||
esp_efuse_write_field_bit(ESP_EFUSE_WR_DIS_RD_DIS);
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_SECURE_FLASH_SKIP_WRITE_PROTECTION_CACHE
|
||||
// Set write-protection for DIS_ICACHE to prevent bricking chip in case it will be set accidentally.
|
||||
// esp32h4 has DIS_ICACHE. Write-protection bit = 2.
|
||||
// List of eFuses with the same write protection bit:
|
||||
// DIS_ICACHE, DIS_USB_JTAG, POWERGLITCH_EN, DIS_FORCE_DOWNLOAD, SPI_DOWNLOAD_MSPI_DIS,
|
||||
// DIS_TWAI, JTAG_SEL_ENABLE, DIS_PAD_JTAG, DIS_DOWNLOAD_MANUAL_ENCRYPT
|
||||
esp_efuse_write_field_bit(ESP_EFUSE_WR_DIS_DIS_ICACHE);
|
||||
#endif
|
||||
|
||||
return ESP_OK;
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#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 "sdkconfig.h"
|
||||
|
||||
static __attribute__((unused)) const char *TAG = "secure_boot";
|
||||
|
||||
esp_err_t esp_secure_boot_enable_secure_features(void)
|
||||
{
|
||||
esp_efuse_write_field_bit(ESP_EFUSE_DIS_DIRECT_BOOT);
|
||||
|
||||
#ifdef CONFIG_SECURE_ENABLE_SECURE_ROM_DL_MODE
|
||||
ESP_LOGI(TAG, "Enabling Security download mode...");
|
||||
esp_err_t err = esp_efuse_enable_rom_secure_download_mode();
|
||||
if (err != ESP_OK) {
|
||||
ESP_LOGE(TAG, "Could not enable Security download mode...");
|
||||
return err;
|
||||
}
|
||||
#elif CONFIG_SECURE_DISABLE_ROM_DL_MODE
|
||||
ESP_LOGI(TAG, "Disable ROM Download mode...");
|
||||
esp_err_t err = esp_efuse_disable_rom_download_mode();
|
||||
if (err != ESP_OK) {
|
||||
ESP_LOGE(TAG, "Could not disable ROM Download mode...");
|
||||
return err;
|
||||
}
|
||||
#else
|
||||
ESP_LOGW(TAG, "UART ROM Download mode kept enabled - SECURITY COMPROMISED");
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_SECURE_BOOT_ALLOW_JTAG
|
||||
ESP_LOGI(TAG, "Disable hardware & software JTAG...");
|
||||
esp_efuse_write_field_bit(ESP_EFUSE_DIS_PAD_JTAG);
|
||||
esp_efuse_write_field_bit(ESP_EFUSE_DIS_USB_JTAG);
|
||||
esp_efuse_write_field_cnt(ESP_EFUSE_SOFT_DIS_JTAG, ESP_EFUSE_SOFT_DIS_JTAG[0]->bit_count);
|
||||
#else
|
||||
ESP_LOGW(TAG, "Not disabling JTAG - SECURITY COMPROMISED");
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_SECURE_BOOT_ENABLE_AGGRESSIVE_KEY_REVOKE
|
||||
esp_efuse_write_field_bit(ESP_EFUSE_SECURE_BOOT_AGGRESSIVE_REVOKE);
|
||||
#endif
|
||||
|
||||
esp_efuse_write_field_bit(ESP_EFUSE_SECURE_BOOT_EN);
|
||||
|
||||
#ifndef CONFIG_SECURE_BOOT_V2_ALLOW_EFUSE_RD_DIS
|
||||
bool rd_dis_now = true;
|
||||
#ifdef CONFIG_SECURE_FLASH_ENC_ENABLED
|
||||
/* If flash encryption is not enabled yet then don't read-disable efuses yet, do it later in the boot
|
||||
when Flash Encryption is being enabled */
|
||||
rd_dis_now = esp_flash_encryption_enabled();
|
||||
#endif
|
||||
if (rd_dis_now) {
|
||||
ESP_LOGI(TAG, "Prevent read disabling of additional efuses...");
|
||||
esp_efuse_write_field_bit(ESP_EFUSE_WR_DIS_RD_DIS);
|
||||
}
|
||||
#else
|
||||
ESP_LOGW(TAG, "Allowing read disabling of additional efuses - SECURITY COMPROMISED");
|
||||
#endif
|
||||
|
||||
return ESP_OK;
|
||||
}
|
||||
@@ -3,10 +3,18 @@
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
//Not supported but common bootloader calls the function. Do nothing
|
||||
void bootloader_ana_super_wdt_reset_config(bool enable)
|
||||
{
|
||||
(void)enable;
|
||||
}
|
||||
|
||||
void bootloader_ana_bod_reset_config(bool enable)
|
||||
{
|
||||
(void)enable;
|
||||
}
|
||||
|
||||
void bootloader_ana_clock_glitch_reset_config(bool enable)
|
||||
{
|
||||
(void)enable;
|
||||
|
||||
@@ -130,7 +130,7 @@ static void bootloader_super_wdt_auto_feed(void)
|
||||
|
||||
static inline void bootloader_ana_reset_config(void)
|
||||
{
|
||||
//Enable WDT, BOD, and GLITCH reset
|
||||
//Enable WDT, BOR, and GLITCH reset
|
||||
bootloader_ana_super_wdt_reset_config(true);
|
||||
bootloader_ana_bod_reset_config(true);
|
||||
bootloader_ana_clock_glitch_reset_config(true);
|
||||
|
||||
@@ -12,15 +12,15 @@ void bootloader_ana_super_wdt_reset_config(bool enable)
|
||||
REG_CLR_BIT(RTC_CNTL_FIB_SEL_REG, RTC_CNTL_FIB_SUPER_WDT_RST);
|
||||
|
||||
if (enable) {
|
||||
REG_CLR_BIT(RTC_CNTL_SWD_CONF_REG, RTC_CNTL_SWD_BYPASS_RST);
|
||||
} else {
|
||||
REG_SET_BIT(RTC_CNTL_SWD_CONF_REG, RTC_CNTL_SWD_BYPASS_RST);
|
||||
} else {
|
||||
REG_CLR_BIT(RTC_CNTL_SWD_CONF_REG, RTC_CNTL_SWD_BYPASS_RST);
|
||||
}
|
||||
}
|
||||
|
||||
void bootloader_ana_bod_reset_config(bool enable)
|
||||
{
|
||||
REG_CLR_BIT(RTC_CNTL_FIB_SEL_REG, RTC_CNTL_FIB_BOD_RST);
|
||||
REG_CLR_BIT(RTC_CNTL_FIB_SEL_REG, RTC_CNTL_FIB_BOR_RST);
|
||||
|
||||
if (enable) {
|
||||
REG_SET_BIT(RTC_CNTL_BROWN_OUT_REG, RTC_CNTL_BROWN_OUT_ANA_RST_EN);
|
||||
|
||||
@@ -29,6 +29,8 @@
|
||||
#include "esp32s3/rom/secure_boot.h"
|
||||
#elif CONFIG_IDF_TARGET_ESP32C3
|
||||
#include "esp32c3/rom/secure_boot.h"
|
||||
#elif CONFIG_IDF_TARGET_ESP32H4
|
||||
#include "esp32h4/rom/secure_boot.h"
|
||||
#elif CONFIG_IDF_TARGET_ESP32C2
|
||||
#include "esp32c2/rom/rtc.h"
|
||||
#include "esp32c2/rom/secure_boot.h"
|
||||
@@ -864,7 +866,7 @@ static esp_err_t verify_secure_boot_signature(bootloader_sha256_handle_t sha_han
|
||||
bootloader_munmap(simple_hash);
|
||||
}
|
||||
|
||||
#if CONFIG_SECURE_SIGNED_APPS_RSA_SCHEME || CONFIG_SECURE_SIGNED_APPS_ECDSA_V2_SCHEME
|
||||
#if CONFIG_SECURE_BOOT_V2_ENABLED
|
||||
// End of the image needs to be padded all the way to a 4KB boundary, after the simple hash
|
||||
// (for apps they are usually already padded due to --secure-pad-v2, only a problem if this option was not used.)
|
||||
uint32_t padded_end = ALIGN_UP(end, FLASH_SECTOR_SIZE);
|
||||
@@ -874,7 +876,7 @@ static esp_err_t verify_secure_boot_signature(bootloader_sha256_handle_t sha_han
|
||||
bootloader_munmap(padding);
|
||||
end = padded_end;
|
||||
}
|
||||
#endif // CONFIG_SECURE_SIGNED_APPS_RSA_SCHEME || CONFIG_SECURE_SIGNED_APPS_ECDSA_V2_SCHEME
|
||||
#endif
|
||||
|
||||
bootloader_sha256_finish(sha_handle, image_digest);
|
||||
|
||||
|
||||
@@ -144,9 +144,9 @@ static esp_err_t secure_boot_v2_check(bool *need_fix)
|
||||
#endif
|
||||
#endif // CONFIG_SECURE_BOOT
|
||||
|
||||
#if (CONFIG_SECURE_SIGNED_APPS_RSA_SCHEME || CONFIG_SECURE_SIGNED_APPS_ECDSA_V2_SCHEME) && CONFIG_SECURE_SIGNED_ON_UPDATE_NO_SECURE_BOOT
|
||||
#if CONFIG_SECURE_SIGNED_APPS_RSA_SCHEME && CONFIG_SECURE_SIGNED_ON_UPDATE_NO_SECURE_BOOT
|
||||
|
||||
static void check_signature_on_update_check(void)
|
||||
static void rsa_check_signature_on_update_check(void)
|
||||
{
|
||||
// We rely on the keys used to sign this app to verify the next app on OTA, so make sure there is at
|
||||
// least one to avoid a stuck firmware
|
||||
@@ -164,7 +164,7 @@ static void check_signature_on_update_check(void)
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif // (CONFIG_SECURE_SIGNED_APPS_RSA_SCHEME || CONFIG_SECURE_SIGNED_APPS_ECDSA_V2_SCHEME) && CONFIG_SECURE_SIGNED_ON_UPDATE_NO_SECURE_BOOT
|
||||
#endif // CONFIG_SECURE_SIGNED_APPS_RSA_SCHEME && CONFIG_SECURE_SIGNED_ON_UPDATE_NO_SECURE_BOOT
|
||||
|
||||
void esp_secure_boot_init_checks(void)
|
||||
{
|
||||
@@ -184,9 +184,9 @@ void esp_secure_boot_init_checks(void)
|
||||
#endif // CONFIG_SECURE_BOOT
|
||||
|
||||
|
||||
#if (CONFIG_SECURE_SIGNED_APPS_RSA_SCHEME || CONFIG_SECURE_SIGNED_APPS_ECDSA_V2_SCHEME) && CONFIG_SECURE_SIGNED_ON_UPDATE_NO_SECURE_BOOT
|
||||
check_signature_on_update_check();
|
||||
#endif // (CONFIG_SECURE_SIGNED_APPS_RSA_SCHEME || CONFIG_SECURE_SIGNED_APPS_ECDSA_V2_SCHEME) && CONFIG_SECURE_SIGNED_ON_UPDATE_NO_SECURE_BOOT
|
||||
#if CONFIG_SECURE_SIGNED_APPS_RSA_SCHEME && CONFIG_SECURE_SIGNED_ON_UPDATE_NO_SECURE_BOOT
|
||||
rsa_check_signature_on_update_check();
|
||||
#endif // CONFIG_SECURE_SIGNED_APPS_RSA_SCHEME && CONFIG_SECURE_SIGNED_ON_UPDATE_NO_SECURE_BOOT
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -13,6 +13,8 @@
|
||||
#include "esp32c3/rom/secure_boot.h"
|
||||
#elif CONFIG_IDF_TARGET_ESP32S3
|
||||
#include "esp32s3/rom/secure_boot.h"
|
||||
#elif CONFIG_IDF_TARGET_ESP32H4
|
||||
#include "esp32h4/rom/secure_boot.h"
|
||||
#elif CONFIG_IDF_TARGET_ESP32C2
|
||||
#include "esp32c2/rom/secure_boot.h"
|
||||
#elif CONFIG_IDF_TARGET_ESP32C6
|
||||
|
||||
@@ -4,7 +4,8 @@ cmake_minimum_required(VERSION 3.16)
|
||||
|
||||
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
||||
|
||||
list(PREPEND SDKCONFIG_DEFAULTS "$ENV{IDF_PATH}/tools/test_apps/configs/sdkconfig.debug_helpers" "sdkconfig.defaults")
|
||||
set(SDKCONFIG_DEFAULTS "$ENV{IDF_PATH}/tools/test_apps/configs/sdkconfig.debug_helpers")
|
||||
list(APPEND SDKCONFIG_DEFAULTS "sdkconfig.defaults")
|
||||
|
||||
# "Trim" the build. Include the minimal set of components, main, and anything it depends on.
|
||||
set(COMPONENTS main)
|
||||
|
||||
@@ -4,7 +4,8 @@ cmake_minimum_required(VERSION 3.16)
|
||||
|
||||
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
||||
|
||||
list(PREPEND SDKCONFIG_DEFAULTS "$ENV{IDF_PATH}/tools/test_apps/configs/sdkconfig.debug_helpers" "sdkconfig.defaults")
|
||||
set(SDKCONFIG_DEFAULTS "$ENV{IDF_PATH}/tools/test_apps/configs/sdkconfig.debug_helpers")
|
||||
list(APPEND SDKCONFIG_DEFAULTS "sdkconfig.defaults")
|
||||
|
||||
# "Trim" the build. Include the minimal set of components, main, and anything it depends on.
|
||||
set(COMPONENTS main)
|
||||
|
||||
@@ -9,7 +9,6 @@ from pytest_embedded import Dut
|
||||
@pytest.mark.esp32
|
||||
@pytest.mark.esp32c3
|
||||
@pytest.mark.esp32c6
|
||||
@pytest.mark.esp32h2
|
||||
@pytest.mark.esp32s2
|
||||
@pytest.mark.esp32s3
|
||||
def test_rtc_reserved_memory(dut: Dut) -> None:
|
||||
|
||||
@@ -2,7 +2,6 @@ if(CONFIG_BT_ENABLED)
|
||||
|
||||
set(srcs "")
|
||||
set(include_dirs "")
|
||||
set(ldfragments "linker.lf")
|
||||
|
||||
if(CONFIG_IDF_TARGET_ESP32)
|
||||
list(APPEND srcs "controller/esp32/bt.c"
|
||||
@@ -18,8 +17,11 @@ if(CONFIG_BT_ENABLED)
|
||||
list(APPEND srcs "controller/esp32c3/bt.c")
|
||||
list(APPEND include_dirs include/esp32c3/include)
|
||||
|
||||
elseif(CONFIG_IDF_TARGET_ESP32H4)
|
||||
list(APPEND srcs "controller/esp32h4/bt.c")
|
||||
list(APPEND include_dirs include/esp32h4/include)
|
||||
|
||||
elseif(CONFIG_IDF_TARGET_ESP32C2)
|
||||
set(ldfragments "linker.lf.esp32c2")
|
||||
list(APPEND srcs "controller/esp32c2/bt.c")
|
||||
list(APPEND include_dirs include/esp32c2/include)
|
||||
|
||||
@@ -530,15 +532,10 @@ if(CONFIG_BT_ENABLED)
|
||||
host/nimble/nimble/nimble/host/services/gap/include
|
||||
host/nimble/nimble/nimble/host/services/gatt/include
|
||||
host/nimble/nimble/nimble/host/services/hr/include
|
||||
host/nimble/nimble/nimble/host/services/htp/include
|
||||
host/nimble/nimble/nimble/host/services/ias/include
|
||||
host/nimble/nimble/nimble/host/services/ipss/include
|
||||
host/nimble/nimble/nimble/host/services/lls/include
|
||||
host/nimble/nimble/nimble/host/services/prox/include
|
||||
host/nimble/nimble/nimble/host/services/cts/include
|
||||
host/nimble/nimble/nimble/host/services/tps/include
|
||||
host/nimble/nimble/nimble/host/services/hid/include
|
||||
host/nimble/nimble/nimble/host/services/sps/include
|
||||
host/nimble/nimble/nimble/host/util/include
|
||||
host/nimble/nimble/nimble/host/store/ram/include
|
||||
host/nimble/nimble/nimble/host/store/config/include
|
||||
@@ -552,15 +549,10 @@ if(CONFIG_BT_ENABLED)
|
||||
"host/nimble/nimble/nimble/host/services/ipss/src/ble_svc_ipss.c"
|
||||
"host/nimble/nimble/nimble/host/services/ans/src/ble_svc_ans.c"
|
||||
"host/nimble/nimble/nimble/host/services/hr/src/ble_svc_hr.c"
|
||||
"host/nimble/nimble/nimble/host/services/htp/src/ble_svc_htp.c"
|
||||
"host/nimble/nimble/nimble/host/services/gap/src/ble_svc_gap.c"
|
||||
"host/nimble/nimble/nimble/host/services/bas/src/ble_svc_bas.c"
|
||||
"host/nimble/nimble/nimble/host/services/dis/src/ble_svc_dis.c"
|
||||
"host/nimble/nimble/nimble/host/services/lls/src/ble_svc_lls.c"
|
||||
"host/nimble/nimble/nimble/host/services/prox/src/ble_svc_prox.c"
|
||||
"host/nimble/nimble/nimble/host/services/cts/src/ble_svc_cts.c"
|
||||
"host/nimble/nimble/nimble/host/services/hid/src/ble_svc_hid.c"
|
||||
"host/nimble/nimble/nimble/host/services/sps/src/ble_svc_sps.c"
|
||||
"host/nimble/nimble/nimble/host/src/ble_hs_conn.c"
|
||||
"host/nimble/nimble/nimble/host/src/ble_store_util.c"
|
||||
"host/nimble/nimble/nimble/host/src/ble_sm.c"
|
||||
@@ -579,8 +571,6 @@ if(CONFIG_BT_ENABLED)
|
||||
"host/nimble/nimble/nimble/host/src/ble_hs_mqueue.c"
|
||||
"host/nimble/nimble/nimble/host/src/ble_hs_periodic_sync.c"
|
||||
"host/nimble/nimble/nimble/host/src/ble_att.c"
|
||||
"host/nimble/nimble/nimble/host/src/ble_ead.c"
|
||||
"host/nimble/nimble/nimble/host/src/ble_aes_ccm.c"
|
||||
"host/nimble/nimble/nimble/host/src/ble_gattc.c"
|
||||
"host/nimble/nimble/nimble/host/src/ble_store.c"
|
||||
"host/nimble/nimble/nimble/host/src/ble_sm_lgcy.c"
|
||||
@@ -703,12 +693,13 @@ if(CONFIG_BT_ENABLED)
|
||||
|
||||
endif()
|
||||
|
||||
# requirements can't depend on config
|
||||
idf_component_register(SRCS "${srcs}"
|
||||
INCLUDE_DIRS "${include_dirs}"
|
||||
PRIV_INCLUDE_DIRS "${priv_include_dirs}"
|
||||
REQUIRES esp_timer esp_wifi
|
||||
PRIV_REQUIRES nvs_flash soc esp_pm esp_phy esp_coex mbedtls driver vfs
|
||||
LDFRAGMENTS "${ldfragments}")
|
||||
INCLUDE_DIRS "${include_dirs}"
|
||||
PRIV_INCLUDE_DIRS "${priv_include_dirs}"
|
||||
REQUIRES esp_timer esp_wifi
|
||||
PRIV_REQUIRES nvs_flash soc esp_pm esp_phy esp_coex mbedtls driver vfs
|
||||
LDFRAGMENTS "linker.lf")
|
||||
|
||||
if(CONFIG_BT_ENABLED)
|
||||
target_compile_options(${COMPONENT_LIB} PRIVATE -Wno-implicit-fallthrough -Wno-unused-const-variable)
|
||||
@@ -725,6 +716,15 @@ if(CONFIG_BT_ENABLED)
|
||||
target_link_directories(${COMPONENT_LIB} INTERFACE
|
||||
"${CMAKE_CURRENT_LIST_DIR}/controller/lib_esp32c3_family/esp32s3")
|
||||
target_link_libraries(${COMPONENT_LIB} PUBLIC btdm_app)
|
||||
elseif(CONFIG_IDF_TARGET_ESP32H4)
|
||||
if(CONFIG_IDF_TARGET_ESP32H4_BETA_VERSION_1)
|
||||
# TODO: rename esp32h2 to esp32h4 [BT-2875]
|
||||
add_prebuilt_library(libble_app "controller/lib_esp32h2/esp32h2-bt-lib/beta1/libble_app.a")
|
||||
elseif(CONFIG_IDF_TARGET_ESP32H4_BETA_VERSION_2)
|
||||
# TODO: rename esp32h2 to esp32h4 [BT-2875]
|
||||
add_prebuilt_library(libble_app "controller/lib_esp32h2/esp32h2-bt-lib/beta2/libble_app.a")
|
||||
endif()
|
||||
target_link_libraries(${COMPONENT_LIB} PRIVATE libble_app)
|
||||
elseif(CONFIG_IDF_TARGET_ESP32C2)
|
||||
add_prebuilt_library(libble_app "controller/lib_esp32c2/esp32c2-bt-lib/libble_app.a")
|
||||
target_link_libraries(${COMPONENT_LIB} PRIVATE libble_app)
|
||||
|
||||
@@ -68,17 +68,6 @@ menu "Bluetooth"
|
||||
source "$IDF_PATH/components/bt/controller/$IDF_TARGET/Kconfig.in"
|
||||
endmenu
|
||||
|
||||
config BT_RELEASE_IRAM
|
||||
depends on BT_ENABLED && BT_LE_RELEASE_IRAM_SUPPORTED
|
||||
bool "Release Bluetooth text (READ DOCS FIRST)"
|
||||
default n
|
||||
help
|
||||
This option release Bluetooth text section and merge Bluetooth data, bss & text into
|
||||
a large free heap region when esp_bt_mem_release is called, total saving ~21kB or more of IRAM.
|
||||
ESP32-C2 only 3 configurable PMP entries available, rest of them are hard-coded.
|
||||
We cannot split the memory into 3 different regions (IRAM, BLE-IRAM, DRAM).
|
||||
So this option will disable the PMP (ESP_SYSTEM_PMP_IDRAM_SPLIT)
|
||||
|
||||
endmenu
|
||||
|
||||
menuconfig BLE_MESH
|
||||
|
||||
@@ -254,32 +254,6 @@ bool config_remove_section(config_t *config, const char *section)
|
||||
return list_remove(config->sections, sec);
|
||||
}
|
||||
|
||||
bool config_update_newest_section(config_t *config, const char *section)
|
||||
{
|
||||
assert(config != NULL);
|
||||
assert(section != NULL);
|
||||
|
||||
list_node_t *first_node = list_begin(config->sections);
|
||||
if (first_node == NULL) {
|
||||
return false;
|
||||
}
|
||||
section_t *first_sec = list_node(first_node);
|
||||
if (strcmp(first_sec->name, section) == 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
for (const list_node_t *node = list_begin(config->sections); node != list_end(config->sections); node = list_next(node)) {
|
||||
section_t *sec = list_node(node);
|
||||
if (strcmp(sec->name, section) == 0) {
|
||||
list_delete(config->sections, sec);
|
||||
list_prepend(config->sections, sec);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool config_remove_key(config_t *config, const char *section, const char *key)
|
||||
{
|
||||
assert(config != NULL);
|
||||
|
||||
@@ -99,11 +99,6 @@ void config_set_string(config_t *config, const char *section, const char *key, c
|
||||
// Neither |config| nor |section| may be NULL.
|
||||
bool config_remove_section(config_t *config, const char *section);
|
||||
|
||||
// Updates |section| to be the first section in |config|. Return true if |section| is in
|
||||
// |config| and updated successfully, false otherwise.
|
||||
// Neither |config| nor |section| may be NULL.
|
||||
bool config_update_newest_section(config_t *config, const char *section);
|
||||
|
||||
// Removes one specific |key| residing in |section| of the |config|. Returns true
|
||||
// if the section and key were found and the key was removed, false otherwise.
|
||||
// None of |config|, |section|, or |key| may be NULL.
|
||||
|
||||
@@ -205,11 +205,6 @@ menu "HCI UART(H4) Options"
|
||||
help
|
||||
UART Baudrate for HCI. Please use standard baudrate.
|
||||
|
||||
config BTDM_CTRL_HCI_UART_FLOW_CTRL_EN
|
||||
bool "Enable UART flow control"
|
||||
depends on BTDM_CTRL_HCI_MODE_UART_H4
|
||||
default y
|
||||
|
||||
endmenu
|
||||
|
||||
menu "MODEM SLEEP Options"
|
||||
@@ -356,7 +351,7 @@ config BTDM_SCAN_DUPL_CACHE_SIZE
|
||||
default 100
|
||||
help
|
||||
Maximum number of devices which can be recorded in scan duplicate filter.
|
||||
When the maximum amount of device in the filter is reached, the oldest device will be refreshed.
|
||||
When the maximum amount of device in the filter is reached, the cache will be refreshed.
|
||||
|
||||
config BTDM_SCAN_DUPL_CACHE_REFRESH_PERIOD
|
||||
int "Duplicate scan list refresh period (seconds)"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -35,7 +35,7 @@
|
||||
#include "soc/rtc.h"
|
||||
#include "soc/soc_memory_layout.h"
|
||||
#include "soc/dport_reg.h"
|
||||
#include "private/esp_coexist_internal.h"
|
||||
#include "esp_coexist_internal.h"
|
||||
#include "esp_timer.h"
|
||||
#if !CONFIG_FREERTOS_UNICORE
|
||||
#include "esp_ipc.h"
|
||||
@@ -111,6 +111,7 @@ typedef struct {
|
||||
|
||||
typedef struct {
|
||||
void *handle;
|
||||
void *storage;
|
||||
} btdm_queue_item_t;
|
||||
|
||||
/* OSI function */
|
||||
@@ -220,8 +221,6 @@ extern void bredr_sco_datapath_set(uint8_t data_path);
|
||||
extern void btdm_controller_scan_duplicate_list_clear(void);
|
||||
/* Shutdown */
|
||||
extern void esp_bt_controller_shutdown(void);
|
||||
extern void sdk_config_set_bt_pll_track_enable(bool enable);
|
||||
extern void sdk_config_set_uart_flow_ctrl_enable(bool enable);
|
||||
|
||||
extern char _bss_start_btdm;
|
||||
extern char _bss_end_btdm;
|
||||
@@ -556,8 +555,17 @@ static void *semphr_create_wrapper(uint32_t max, uint32_t init)
|
||||
|
||||
void *handle = NULL;
|
||||
|
||||
/* IDF FreeRTOS guarantees that all dynamic memory allocation goes to internal RAM. */
|
||||
#if !CONFIG_SPIRAM_USE_MALLOC
|
||||
handle = (void *)xSemaphoreCreateCounting(max, init);
|
||||
#else
|
||||
StaticQueue_t *queue_buffer = NULL;
|
||||
|
||||
queue_buffer = heap_caps_malloc(sizeof(StaticQueue_t), MALLOC_CAP_INTERNAL|MALLOC_CAP_8BIT);
|
||||
assert(queue_buffer);
|
||||
semphr->storage = queue_buffer;
|
||||
|
||||
handle = (void *)xSemaphoreCreateCountingStatic(max, init, queue_buffer);
|
||||
#endif
|
||||
assert(handle);
|
||||
|
||||
#if CONFIG_BTDM_CTRL_HLI
|
||||
@@ -593,6 +601,11 @@ static void semphr_delete_wrapper(void *semphr)
|
||||
if (handle) {
|
||||
vSemaphoreDelete(handle);
|
||||
}
|
||||
#ifdef CONFIG_SPIRAM_USE_MALLOC
|
||||
if (semphr_item->storage) {
|
||||
free(semphr_item->storage);
|
||||
}
|
||||
#endif
|
||||
|
||||
free(semphr);
|
||||
}
|
||||
@@ -678,9 +691,18 @@ static void *queue_create_wrapper(uint32_t queue_len, uint32_t item_size)
|
||||
queue = (btdm_queue_item_t*)heap_caps_malloc(sizeof(btdm_queue_item_t), MALLOC_CAP_INTERNAL|MALLOC_CAP_8BIT);
|
||||
assert(queue);
|
||||
|
||||
/* IDF FreeRTOS guarantees that all dynamic memory allocation goes to internal RAM. */
|
||||
#if CONFIG_SPIRAM_USE_MALLOC
|
||||
|
||||
queue->storage = heap_caps_calloc(1, sizeof(StaticQueue_t) + (queue_len*item_size), MALLOC_CAP_INTERNAL|MALLOC_CAP_8BIT);
|
||||
assert(queue->storage);
|
||||
|
||||
queue->handle = xQueueCreateStatic( queue_len, item_size, ((uint8_t*)(queue->storage)) + sizeof(StaticQueue_t), (StaticQueue_t*)(queue->storage));
|
||||
assert(queue->handle);
|
||||
|
||||
#else
|
||||
queue->handle = xQueueCreate( queue_len, item_size);
|
||||
assert(queue->handle);
|
||||
#endif
|
||||
|
||||
return queue;
|
||||
}
|
||||
@@ -692,6 +714,13 @@ static void queue_delete_wrapper(void *queue)
|
||||
if(queue_item->handle){
|
||||
vQueueDelete(queue_item->handle);
|
||||
}
|
||||
|
||||
#if CONFIG_SPIRAM_USE_MALLOC
|
||||
if (queue_item->storage) {
|
||||
free(queue_item->storage);
|
||||
}
|
||||
#endif
|
||||
|
||||
free(queue_item);
|
||||
}
|
||||
}
|
||||
@@ -866,11 +895,7 @@ static void *malloc_internal_wrapper(size_t size)
|
||||
|
||||
static int32_t IRAM_ATTR read_mac_wrapper(uint8_t mac[6])
|
||||
{
|
||||
int ret = esp_read_mac(mac, ESP_MAC_BT);
|
||||
ESP_LOGI(BTDM_LOG_TAG, "Bluetooth MAC: %02x:%02x:%02x:%02x:%02x:%02x",
|
||||
mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
|
||||
|
||||
return ret;
|
||||
return esp_read_mac(mac, ESP_MAC_BT);
|
||||
}
|
||||
|
||||
static void IRAM_ATTR srand_wrapper(unsigned int seed)
|
||||
@@ -939,7 +964,7 @@ static void btdm_sleep_enter_phase1_wrapper(uint32_t lpcycles)
|
||||
static void btdm_sleep_enter_phase2_wrapper(void)
|
||||
{
|
||||
if (btdm_controller_get_sleep_mode() == BTDM_MODEM_SLEEP_MODE_ORIG) {
|
||||
esp_phy_disable(PHY_MODEM_BT);
|
||||
esp_phy_disable();
|
||||
#ifdef CONFIG_PM_ENABLE
|
||||
if (s_pm_lock_acquired) {
|
||||
esp_pm_lock_release(s_pm_lock);
|
||||
@@ -947,7 +972,7 @@ static void btdm_sleep_enter_phase2_wrapper(void)
|
||||
}
|
||||
#endif
|
||||
} else if (btdm_controller_get_sleep_mode() == BTDM_MODEM_SLEEP_MODE_EVED) {
|
||||
esp_phy_disable(PHY_MODEM_BT);
|
||||
esp_phy_disable();
|
||||
// pause bluetooth baseband
|
||||
periph_module_disable(PERIPH_BT_BASEBAND_MODULE);
|
||||
}
|
||||
@@ -963,7 +988,7 @@ static void btdm_sleep_exit_phase3_wrapper(void)
|
||||
#endif
|
||||
|
||||
if (btdm_controller_get_sleep_mode() == BTDM_MODEM_SLEEP_MODE_ORIG) {
|
||||
esp_phy_enable(PHY_MODEM_BT);
|
||||
esp_phy_enable();
|
||||
btdm_check_and_init_bb();
|
||||
#ifdef CONFIG_PM_ENABLE
|
||||
esp_timer_stop(s_btdm_slp_tmr);
|
||||
@@ -971,7 +996,7 @@ static void btdm_sleep_exit_phase3_wrapper(void)
|
||||
} else if (btdm_controller_get_sleep_mode() == BTDM_MODEM_SLEEP_MODE_EVED) {
|
||||
// resume bluetooth baseband
|
||||
periph_module_enable(PERIPH_BT_BASEBAND_MODULE);
|
||||
esp_phy_enable(PHY_MODEM_BT);
|
||||
esp_phy_enable();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1197,12 +1222,23 @@ static int coex_register_wifi_channel_change_callback_wrapper(void *cb)
|
||||
static int coex_version_get_wrapper(unsigned int *major, unsigned int *minor, unsigned int *patch)
|
||||
{
|
||||
#if CONFIG_SW_COEXIST_ENABLE
|
||||
coex_version_t version;
|
||||
ESP_ERROR_CHECK(coex_version_get_value(&version));
|
||||
*major = (unsigned int)version.major;
|
||||
*minor = (unsigned int)version.minor;
|
||||
*patch = (unsigned int)version.patch;
|
||||
return 0;
|
||||
const char *ver_str = esp_coex_version_get();
|
||||
if (ver_str != NULL) {
|
||||
unsigned int _major = 0, _minor = 0, _patch = 0;
|
||||
if (sscanf(ver_str, "%u.%u.%u", &_major, &_minor, &_patch) != 3) {
|
||||
return -1;
|
||||
}
|
||||
if (major != NULL) {
|
||||
*major = _major;
|
||||
}
|
||||
if (minor != NULL) {
|
||||
*minor = _minor;
|
||||
}
|
||||
if (patch != NULL) {
|
||||
*patch = _patch;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
return -1;
|
||||
}
|
||||
@@ -1517,12 +1553,6 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg)
|
||||
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);
|
||||
#else
|
||||
sdk_config_set_uart_flow_ctrl_enable(false);
|
||||
#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) {
|
||||
@@ -1638,7 +1668,7 @@ static void bt_shutdown(void)
|
||||
#else
|
||||
bt_controller_shutdown(NULL);
|
||||
#endif
|
||||
esp_phy_disable(PHY_MODEM_BT);
|
||||
esp_phy_disable();
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -1664,7 +1694,7 @@ esp_err_t esp_bt_controller_enable(esp_bt_mode_t mode)
|
||||
esp_pm_lock_acquire(s_pm_lock);
|
||||
#endif
|
||||
|
||||
esp_phy_enable(PHY_MODEM_BT);
|
||||
esp_phy_enable();
|
||||
|
||||
#if CONFIG_SW_COEXIST_ENABLE
|
||||
coex_enable();
|
||||
@@ -1674,8 +1704,6 @@ esp_err_t esp_bt_controller_enable(esp_bt_mode_t mode)
|
||||
btdm_controller_enable_sleep(true);
|
||||
}
|
||||
|
||||
sdk_config_set_bt_pll_track_enable(true);
|
||||
|
||||
// inititalize bluetooth baseband
|
||||
btdm_check_and_init_bb();
|
||||
|
||||
@@ -1684,7 +1712,7 @@ esp_err_t esp_bt_controller_enable(esp_bt_mode_t mode)
|
||||
#if CONFIG_SW_COEXIST_ENABLE
|
||||
coex_disable();
|
||||
#endif
|
||||
esp_phy_disable(PHY_MODEM_BT);
|
||||
esp_phy_disable();
|
||||
#ifdef CONFIG_PM_ENABLE
|
||||
if (!s_btdm_allow_light_sleep) {
|
||||
esp_pm_lock_release(s_light_sleep_pm_lock);
|
||||
@@ -1724,7 +1752,7 @@ esp_err_t esp_bt_controller_disable(void)
|
||||
coex_disable();
|
||||
#endif
|
||||
|
||||
esp_phy_disable(PHY_MODEM_BT);
|
||||
esp_phy_disable();
|
||||
btdm_controller_status = ESP_BT_CONTROLLER_STATUS_INITED;
|
||||
esp_unregister_shutdown_handler(bt_shutdown);
|
||||
|
||||
|
||||
@@ -253,54 +253,6 @@ config BT_LE_CONTROLLER_TASK_STACK_SIZE
|
||||
help
|
||||
This configures stack size of NimBLE controller task
|
||||
|
||||
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
|
||||
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
|
||||
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
|
||||
Only operate in dump mode
|
||||
|
||||
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
|
||||
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
|
||||
Configure the size of the BLE HCI LOG buffer.
|
||||
|
||||
config BT_LE_LL_RESOLV_LIST_SIZE
|
||||
int "BLE LL Resolving list size"
|
||||
range 1 5
|
||||
@@ -393,7 +345,7 @@ config BT_LE_MAX_CONNECTIONS
|
||||
choice BT_LE_COEX_PHY_CODED_TX_RX_TLIM
|
||||
prompt "Coexistence: limit on MAX Tx/Rx time for coded-PHY connection"
|
||||
default BT_LE_COEX_PHY_CODED_TX_RX_TLIM_DIS
|
||||
depends on ESP_COEX_SW_COEXIST_ENABLE
|
||||
depends on !BT_NIMBLE_ENABLED
|
||||
help
|
||||
When using PHY-Coded in BLE connection, limitation on max tx/rx time can be applied to
|
||||
better avoid dramatic performance deterioration of Wi-Fi.
|
||||
@@ -411,7 +363,7 @@ endchoice
|
||||
|
||||
config BT_LE_COEX_PHY_CODED_TX_RX_TLIM_EFF
|
||||
int
|
||||
default 0 if !ESP_COEX_SW_COEXIST_ENABLE
|
||||
depends on !BT_NIMBLE_ENABLED
|
||||
default 1 if BT_LE_COEX_PHY_CODED_TX_RX_TLIM_EN
|
||||
default 0 if BT_LE_COEX_PHY_CODED_TX_RX_TLIM_DIS
|
||||
|
||||
@@ -421,45 +373,24 @@ config BT_LE_SLEEP_ENABLE
|
||||
help
|
||||
Enable BLE sleep
|
||||
|
||||
choice BT_LE_WAKEUP_SOURCE
|
||||
prompt "BLE light sleep wakeup source"
|
||||
depends on BT_LE_SLEEP_ENABLE
|
||||
default BT_LE_WAKEUP_SOURCE_BLE_RTC_TIMER
|
||||
config BT_LE_WAKEUP_SOURCE_CPU_RTC_TIMER
|
||||
bool "Use ESP timer to wakeup CPU"
|
||||
help
|
||||
Use esp timer to wakeup CPU
|
||||
|
||||
config BT_LE_WAKEUP_SOURCE_BLE_RTC_TIMER
|
||||
bool "Use BLE rtc timer to wakeup CPU"
|
||||
help
|
||||
Use BLE rtc timer to wakeup CPU
|
||||
endchoice
|
||||
|
||||
config BT_LE_USE_ESP_TIMER
|
||||
bool "Use Esp Timer for callout"
|
||||
depends on !BT_NIMBLE_ENABLED
|
||||
default y
|
||||
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
|
||||
help
|
||||
The function is mainly used to enable flow control for advertising reports. When it is enabled,
|
||||
advertising reports will be discarded by the controller if the number of unprocessed advertising
|
||||
reports exceeds the size of BLE adv report flow control.
|
||||
|
||||
config BT_CTRL_BLE_ADV_REPORT_FLOW_CTRL_NUM
|
||||
int "BLE adv report flow control number"
|
||||
depends on BT_CTRL_BLE_ADV_REPORT_FLOW_CTRL_SUPP
|
||||
range 50 1000
|
||||
default 100
|
||||
help
|
||||
The number of unprocessed advertising report that bluetooth host can save.If you set
|
||||
`BT_CTRL_BLE_ADV_REPORT_FLOW_CTRL_NUM` to a small value, this may cause adv packets lost.
|
||||
If you set `BT_CTRL_BLE_ADV_REPORT_FLOW_CTRL_NUM` to a large value, bluetooth host may cache a
|
||||
lot of adv packets and this may cause system memory run out. For example, if you set
|
||||
it to 50, the maximum memory consumed by host is 35 * 50 bytes. Please set
|
||||
`BT_CTRL_BLE_ADV_REPORT_FLOW_CTRL_NUM` according to your system free memory and handle adv
|
||||
packets as fast as possible, otherwise it will cause adv packets lost.
|
||||
|
||||
config BT_CTRL_BLE_ADV_REPORT_DISCARD_THRSHOLD
|
||||
int "BLE adv lost event threshold value"
|
||||
depends on BT_CTRL_BLE_ADV_REPORT_FLOW_CTRL_SUPP
|
||||
range 1 1000
|
||||
default 20
|
||||
help
|
||||
When adv report flow control is enabled, The ADV lost event will be generated when the number
|
||||
of ADV packets lost in the controller reaches this threshold. It is better to set a larger value.
|
||||
If you set `BT_CTRL_BLE_ADV_REPORT_DISCARD_THRSHOLD` to a small value or printf every adv lost event, it
|
||||
may cause adv packets lost more.
|
||||
config BT_LE_RELEASE_IRAM_SUPPORTED
|
||||
bool
|
||||
default y
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -24,7 +24,7 @@
|
||||
#endif
|
||||
|
||||
#if CONFIG_SW_COEXIST_ENABLE
|
||||
#include "private/esp_coexist_internal.h"
|
||||
#include "esp_coexist_internal.h"
|
||||
#endif
|
||||
|
||||
#include "nimble/nimble_npl_os.h"
|
||||
@@ -46,10 +46,6 @@
|
||||
#include "hci/hci_hal.h"
|
||||
#endif
|
||||
|
||||
#if CONFIG_FREERTOS_USE_TICKLESS_IDLE
|
||||
#include "esp_private/sleep_modem.h"
|
||||
#endif // CONFIG_FREERTOS_USE_TICKLESS_IDLE
|
||||
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/task.h"
|
||||
|
||||
@@ -58,8 +54,6 @@
|
||||
|
||||
#include "soc/syscon_reg.h"
|
||||
#include "soc/dport_access.h"
|
||||
|
||||
#include "hal/efuse_ll.h"
|
||||
/* Macro definition
|
||||
************************************************************************
|
||||
*/
|
||||
@@ -76,11 +70,12 @@
|
||||
#ifdef CONFIG_BT_BLUEDROID_ENABLED
|
||||
/* ACL_DATA_MBUF_LEADINGSPCAE: The leadingspace in user info header for ACL data */
|
||||
#define ACL_DATA_MBUF_LEADINGSPCAE 4
|
||||
#endif // CONFIG_BT_BLUEDROID_ENABLED
|
||||
#endif
|
||||
|
||||
/* Types definition
|
||||
************************************************************************
|
||||
*/
|
||||
|
||||
struct osi_coex_funcs_t {
|
||||
uint32_t _magic;
|
||||
uint32_t _version;
|
||||
@@ -113,21 +108,13 @@ struct ext_funcs_t {
|
||||
uint32_t magic;
|
||||
};
|
||||
|
||||
#if CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
|
||||
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 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 bt_controller_log_interface, bool task_create, uint8_t buffers, uint32_t *bufs_size);
|
||||
extern int ble_log_deinit_async(void);
|
||||
extern void ble_log_async_output_dump_all(bool output);
|
||||
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);
|
||||
extern int ble_controller_disable(void);
|
||||
@@ -143,9 +130,6 @@ extern uint32_t r_os_cputime_get32(void);
|
||||
extern uint32_t r_os_cputime_ticks_to_usecs(uint32_t ticks);
|
||||
extern void r_ble_lll_rfmgmt_set_sleep_cb(void *s_cb, void *w_cb, void *s_arg, void *w_arg, uint32_t us_to_enabled);
|
||||
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 */
|
||||
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,
|
||||
@@ -155,15 +139,14 @@ extern int ble_sm_alg_gen_key_pair(uint8_t *pub, uint8_t *priv);
|
||||
extern int ble_txpwr_set(esp_ble_enhanced_power_type_t power_type, uint16_t handle, int power_level);
|
||||
extern int ble_txpwr_get(esp_ble_enhanced_power_type_t power_type, uint16_t handle);
|
||||
extern int ble_get_npl_element_info(esp_bt_controller_config_t *cfg, ble_npl_count_info_t * npl_info);
|
||||
extern void bt_track_pll_cap(void);
|
||||
|
||||
#if CONFIG_BT_RELEASE_IRAM
|
||||
extern uint32_t _iram_bt_text_start;
|
||||
extern uint32_t _bss_bt_end;
|
||||
#else
|
||||
extern uint32_t _bt_bss_start;
|
||||
extern uint32_t _bt_bss_end;
|
||||
extern uint32_t _bt_controller_data_start;
|
||||
#endif
|
||||
extern uint32_t _nimble_bss_start;
|
||||
extern uint32_t _nimble_bss_end;
|
||||
extern uint32_t _nimble_data_start;
|
||||
extern uint32_t _nimble_data_end;
|
||||
extern uint32_t _bt_data_start;
|
||||
extern uint32_t _bt_data_end;
|
||||
|
||||
/* Local Function Declaration
|
||||
*********************************************************************
|
||||
@@ -181,37 +164,36 @@ static int hci_uart_config_wrapper(int uart_no, int32_t speed, uint8_t databits,
|
||||
static int hci_uart_close_wrapper(int uart_no);
|
||||
static void hci_uart_blocking_tx_wrapper(int port, uint8_t data);
|
||||
static int hci_uart_init_wrapper(int uart_no, void *cfg);
|
||||
#endif // CONFIG_BT_LE_HCI_INTERFACE_USE_UART
|
||||
static int esp_intr_alloc_wrapper(int source, int flags, intr_handler_t handler,
|
||||
void *arg, void **ret_handle_in);
|
||||
#endif
|
||||
static int esp_intr_alloc_wrapper(int source, int flags, intr_handler_t handler, void *arg, void **ret_handle_in);
|
||||
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
|
||||
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};
|
||||
#endif // CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
|
||||
|
||||
/* This variable tells if BLE is running */
|
||||
static bool s_ble_active = false;
|
||||
#ifdef CONFIG_PM_ENABLE
|
||||
static DRAM_ATTR esp_pm_lock_handle_t s_pm_lock = NULL;
|
||||
#define BTDM_MIN_TIMER_UNCERTAINTY_US (200)
|
||||
#endif // CONFIG_PM_ENABLE
|
||||
#endif /* #ifdef CONFIG_PM_ENABLE */
|
||||
|
||||
#ifdef CONFIG_BT_LE_WAKEUP_SOURCE_BLE_RTC_TIMER
|
||||
#define BLE_RTC_DELAY_US (1800)
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_BT_LE_WAKEUP_SOURCE_CPU_RTC_TIMER
|
||||
#define BLE_RTC_DELAY_US (0)
|
||||
static void ble_sleep_timer_callback(void *arg);
|
||||
static DRAM_ATTR esp_timer_handle_t s_ble_sleep_timer = NULL;
|
||||
#endif
|
||||
|
||||
|
||||
static const struct osi_coex_funcs_t s_osi_coex_funcs_ro = {
|
||||
@@ -241,10 +223,9 @@ struct ext_funcs_t ext_funcs_ro = {
|
||||
._task_delete = task_delete_wrapper,
|
||||
._osi_assert = osi_assert_wrapper,
|
||||
._os_random = osi_random_wrapper,
|
||||
._ecc_gen_key_pair = esp_ecc_gen_key_pair,
|
||||
._ecc_gen_dh_key = esp_ecc_gen_dh_key,
|
||||
._ecc_gen_key_pair = ble_sm_alg_gen_key_pair,
|
||||
._ecc_gen_dh_key = ble_sm_alg_gen_dhkey,
|
||||
._esp_reset_rpa_moudle = esp_reset_rpa_moudle,
|
||||
._esp_bt_track_pll_cap = NULL,
|
||||
.magic = EXT_FUNC_MAGIC_VALUE,
|
||||
};
|
||||
|
||||
@@ -254,13 +235,9 @@ static void IRAM_ATTR esp_reset_rpa_moudle(void)
|
||||
DPORT_CLEAR_PERI_REG_MASK(SYSTEM_CORE_RST_EN_REG, BLE_RPA_REST_BIT);
|
||||
}
|
||||
|
||||
static void IRAM_ATTR osi_assert_wrapper(const uint32_t ln, const char *fn,
|
||||
uint32_t param1, uint32_t param2)
|
||||
static void IRAM_ATTR osi_assert_wrapper(const uint32_t ln, const char *fn, uint32_t param1, uint32_t param2)
|
||||
{
|
||||
BT_ASSERT_PRINT("BLE assert: line %d in function %s, param: 0x%x, 0x%x", ln, fn, param1, param2);
|
||||
#if CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
|
||||
esp_ble_controller_log_dump_all(true);
|
||||
#endif // CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
|
||||
assert(0);
|
||||
}
|
||||
|
||||
@@ -273,17 +250,17 @@ static void coex_schm_status_bit_set_wrapper(uint32_t type, uint32_t status)
|
||||
{
|
||||
#if CONFIG_SW_COEXIST_ENABLE
|
||||
coex_schm_status_bit_set(type, status);
|
||||
#endif // CONFIG_SW_COEXIST_ENABLE
|
||||
#endif
|
||||
}
|
||||
|
||||
static void coex_schm_status_bit_clear_wrapper(uint32_t type, uint32_t status)
|
||||
{
|
||||
#if CONFIG_SW_COEXIST_ENABLE
|
||||
coex_schm_status_bit_clear(type, status);
|
||||
#endif // CONFIG_SW_COEXIST_ENABLE
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef CONFIG_BT_BLUEDROID_ENABLED
|
||||
|
||||
bool esp_vhci_host_check_send_available(void)
|
||||
{
|
||||
if (ble_controller_status != ESP_BT_CONTROLLER_STATUS_ENABLED) {
|
||||
@@ -336,7 +313,6 @@ void esp_vhci_host_send_packet(uint8_t *data, uint16_t len)
|
||||
if (*(data) == DATA_TYPE_COMMAND) {
|
||||
struct ble_hci_cmd *cmd = NULL;
|
||||
cmd = (struct ble_hci_cmd *) ble_hci_trans_buf_alloc(BLE_HCI_TRANS_BUF_CMD);
|
||||
assert(cmd);
|
||||
memcpy((uint8_t *)cmd, data + 1, len - 1);
|
||||
ble_hci_trans_hs_cmd_tx((uint8_t *)cmd);
|
||||
}
|
||||
@@ -347,6 +323,7 @@ void esp_vhci_host_send_packet(uint8_t *data, uint16_t len)
|
||||
assert(os_mbuf_append(om, &data[1], len - 1) == 0);
|
||||
ble_hci_trans_hs_acl_tx(om);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
esp_err_t esp_vhci_host_register_callback(const esp_vhci_host_callback_t *callback)
|
||||
@@ -359,7 +336,8 @@ esp_err_t esp_vhci_host_register_callback(const esp_vhci_host_callback_t *callba
|
||||
|
||||
return ESP_OK;
|
||||
}
|
||||
#endif // CONFIG_BT_BLUEDROID_ENABLED
|
||||
|
||||
#endif
|
||||
static int task_create_wrapper(void *task_func, const char *name, uint32_t stack_depth, void *param, uint32_t prio, void *task_handle, uint32_t core_id)
|
||||
{
|
||||
return (uint32_t)xTaskCreatePinnedToCore(task_func, name, stack_depth, param, prio, task_handle, (core_id < portNUM_PROCESSORS ? core_id : tskNO_AFFINITY));
|
||||
@@ -370,25 +348,6 @@ static void task_delete_wrapper(void *task_handle)
|
||||
vTaskDelete(task_handle);
|
||||
}
|
||||
|
||||
static int esp_ecc_gen_key_pair(uint8_t *pub, uint8_t *priv)
|
||||
{
|
||||
int rc = -1;
|
||||
#if CONFIG_BT_LE_SM_LEGACY || CONFIG_BT_LE_SM_SC
|
||||
rc = ble_sm_alg_gen_key_pair(pub, priv);
|
||||
#endif // CONFIG_BT_LE_SM_LEGACY || CONFIG_BT_LE_SM_SC
|
||||
return rc;
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
int rc = -1;
|
||||
#if CONFIG_BT_LE_SM_LEGACY || CONFIG_BT_LE_SM_SC
|
||||
rc = ble_sm_alg_gen_dhkey(peer_pub_key_x, peer_pub_key_y, our_priv_key, out_dhkey);
|
||||
#endif // CONFIG_BT_LE_SM_LEGACY || CONFIG_BT_LE_SM_SC
|
||||
return rc;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_BT_LE_HCI_INTERFACE_USE_UART
|
||||
static void hci_uart_start_tx_wrapper(int uart_no)
|
||||
{
|
||||
@@ -404,9 +363,8 @@ static int hci_uart_init_cbs_wrapper(int uart_no, hci_uart_tx_char tx_func,
|
||||
}
|
||||
|
||||
|
||||
static int hci_uart_config_wrapper(int port_num, int32_t baud_rate, uint8_t data_bits,
|
||||
uint8_t stop_bits,uart_parity_t parity,
|
||||
uart_hw_flowcontrol_t flow_ctl)
|
||||
static int hci_uart_config_wrapper(int port_num, int32_t baud_rate, uint8_t data_bits, uint8_t stop_bits,
|
||||
uart_parity_t parity, uart_hw_flowcontrol_t flow_ctl)
|
||||
{
|
||||
int rc = -1;
|
||||
rc = hci_uart_config(port_num, baud_rate, data_bits, stop_bits, parity, flow_ctl);
|
||||
@@ -453,23 +411,43 @@ 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 */
|
||||
|
||||
IRAM_ATTR void controller_sleep_cb(uint32_t enable_tick, void *arg)
|
||||
{
|
||||
if (!s_ble_active) {
|
||||
return;
|
||||
}
|
||||
#ifdef CONFIG_PM_ENABLE
|
||||
#ifdef CONFIG_BT_LE_WAKEUP_SOURCE_CPU_RTC_TIMER
|
||||
uint32_t delta_tick;
|
||||
uint32_t us_to_sleep;
|
||||
uint32_t sleep_tick;
|
||||
uint32_t tick_invalid = *(uint32_t*)(arg);
|
||||
assert(arg != NULL);
|
||||
if (!tick_invalid) {
|
||||
sleep_tick = r_os_cputime_get32();
|
||||
// start a timer to wake up and acquire the pm_lock before modem_sleep awakes
|
||||
delta_tick = enable_tick - sleep_tick;
|
||||
if (delta_tick & 0x80000000) {
|
||||
return;
|
||||
}
|
||||
us_to_sleep = r_os_cputime_ticks_to_usecs(delta_tick);
|
||||
if (us_to_sleep <= BTDM_MIN_TIMER_UNCERTAINTY_US) {
|
||||
return;
|
||||
}
|
||||
esp_err_t err = esp_timer_start_once(s_ble_sleep_timer, us_to_sleep - BTDM_MIN_TIMER_UNCERTAINTY_US);
|
||||
if (err != ESP_OK) {
|
||||
ESP_LOGW(NIMBLE_PORT_LOG_TAG, "ESP timer start failed\n");
|
||||
return;
|
||||
}
|
||||
}
|
||||
#endif // CONFIG_BT_LE_WAKEUP_SOURCE_CPU_RTC_TIMER
|
||||
|
||||
#ifdef CONFIG_BT_LE_WAKEUP_SOURCE_BLE_RTC_TIMER
|
||||
r_ble_rtc_wake_up_state_clr();
|
||||
#endif
|
||||
esp_pm_lock_release(s_pm_lock);
|
||||
#endif // CONFIG_PM_ENABLE
|
||||
esp_phy_disable(PHY_MODEM_BT);
|
||||
esp_phy_disable();
|
||||
s_ble_active = false;
|
||||
}
|
||||
|
||||
@@ -478,7 +456,7 @@ IRAM_ATTR void controller_wakeup_cb(void *arg)
|
||||
if (s_ble_active) {
|
||||
return;
|
||||
}
|
||||
esp_phy_enable(PHY_MODEM_BT);
|
||||
esp_phy_enable();
|
||||
// need to check if need to call pm lock here
|
||||
#ifdef CONFIG_PM_ENABLE
|
||||
esp_pm_lock_acquire(s_pm_lock);
|
||||
@@ -486,6 +464,16 @@ IRAM_ATTR void controller_wakeup_cb(void *arg)
|
||||
s_ble_active = true;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_PM_ENABLE
|
||||
#ifdef CONFIG_BT_LE_WAKEUP_SOURCE_CPU_RTC_TIMER
|
||||
static void ble_sleep_timer_callback(void * arg)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
#endif // CONFIG_BT_LE_WAKEUP_SOURCE_CPU_RTC_TIMER
|
||||
#endif // CONFIG_PM_ENABLE
|
||||
|
||||
esp_err_t controller_sleep_init(void)
|
||||
{
|
||||
esp_err_t rc = 0;
|
||||
@@ -505,43 +493,73 @@ esp_err_t controller_sleep_init(void)
|
||||
if (rc != ESP_OK) {
|
||||
goto error;
|
||||
}
|
||||
#if CONFIG_FREERTOS_USE_TICKLESS_IDLE
|
||||
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(sleep_modem_light_sleep_overhead_set);
|
||||
esp_pm_lock_acquire(s_pm_lock);
|
||||
#ifdef CONFIG_BT_LE_WAKEUP_SOURCE_CPU_RTC_TIMER
|
||||
esp_timer_create_args_t create_args = {
|
||||
.callback = ble_sleep_timer_callback,
|
||||
.arg = NULL,
|
||||
.name = "btSlp"
|
||||
};
|
||||
rc = esp_timer_create(&create_args, &s_ble_sleep_timer);
|
||||
if (rc != ESP_OK) {
|
||||
goto error;
|
||||
}
|
||||
#endif // CONFIG_FREERTOS_USE_TICKLESS_IDLE
|
||||
ESP_LOGW(NIMBLE_PORT_LOG_TAG, "Enable light sleep, the wake up source is ESP timer");
|
||||
#endif //CONFIG_BT_LE_WAKEUP_SOURCE_CPU_RTC_TIMER
|
||||
|
||||
#ifdef CONFIG_BT_LE_WAKEUP_SOURCE_BLE_RTC_TIMER
|
||||
esp_sleep_enable_bt_wakeup();
|
||||
ESP_LOGW(NIMBLE_PORT_LOG_TAG, "Enable light sleep, the wake up source is BLE timer");
|
||||
#endif // CONFIG_BT_LE_WAKEUP_SOURCE_BLE_RTC_TIMER
|
||||
|
||||
return rc;
|
||||
|
||||
error:
|
||||
#if CONFIG_FREERTOS_USE_TICKLESS_IDLE
|
||||
esp_sleep_disable_bt_wakeup();
|
||||
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) {
|
||||
esp_pm_lock_release(s_pm_lock);
|
||||
esp_pm_lock_delete(s_pm_lock);
|
||||
s_pm_lock = NULL;
|
||||
}
|
||||
#ifdef CONFIG_BT_LE_WAKEUP_SOURCE_CPU_RTC_TIMER
|
||||
if (s_ble_sleep_timer != NULL) {
|
||||
esp_timer_stop(s_ble_sleep_timer);
|
||||
esp_timer_delete(s_ble_sleep_timer);
|
||||
s_ble_sleep_timer = NULL;
|
||||
}
|
||||
#endif // CONFIG_BT_LE_WAKEUP_SOURCE_CPU_RTC_TIMER
|
||||
|
||||
#ifdef CONFIG_BT_LE_WAKEUP_SOURCE_BLE_RTC_TIMER
|
||||
esp_sleep_disable_bt_wakeup();
|
||||
#endif // CONFIG_BT_LE_WAKEUP_SOURCE_BLE_RTC_TIMER
|
||||
|
||||
#endif //CONFIG_PM_ENABLE
|
||||
return rc;
|
||||
}
|
||||
|
||||
void controller_sleep_deinit(void)
|
||||
{
|
||||
#ifdef CONFIG_FREERTOS_USE_TICKLESS_IDLE
|
||||
#ifdef CONFIG_PM_ENABLE
|
||||
#ifdef CONFIG_BT_LE_WAKEUP_SOURCE_BLE_RTC_TIMER
|
||||
r_ble_rtc_wake_up_state_clr();
|
||||
esp_sleep_disable_bt_wakeup();
|
||||
#endif //CONFIG_BT_LE_WAKEUP_SOURCE_BLE_RTC_TIMER
|
||||
esp_sleep_pd_config(ESP_PD_DOMAIN_XTAL, ESP_PD_OPTION_AUTO);
|
||||
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*/
|
||||
if (s_ble_active) {
|
||||
esp_pm_lock_release(s_pm_lock);
|
||||
}
|
||||
|
||||
esp_pm_lock_delete(s_pm_lock);
|
||||
s_pm_lock = NULL;
|
||||
#ifdef CONFIG_BT_LE_WAKEUP_SOURCE_CPU_RTC_TIMER
|
||||
if (s_ble_sleep_timer != NULL) {
|
||||
esp_timer_stop(s_ble_sleep_timer);
|
||||
esp_timer_delete(s_ble_sleep_timer);
|
||||
s_ble_sleep_timer = NULL;
|
||||
}
|
||||
#endif //CONFIG_BT_LE_WAKEUP_SOURCE_CPU_RTC_TIMER
|
||||
#endif //CONFIG_PM_ENABLE
|
||||
}
|
||||
|
||||
@@ -632,45 +650,29 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg)
|
||||
#endif
|
||||
esp_phy_modem_init();
|
||||
periph_module_enable(PERIPH_BT_MODULE);
|
||||
periph_module_reset(PERIPH_BT_MODULE);
|
||||
|
||||
// init phy
|
||||
esp_phy_enable();
|
||||
s_ble_active = true;
|
||||
|
||||
// init bb
|
||||
bt_bb_v2_init_cmplx(1);
|
||||
|
||||
if (ble_osi_coex_funcs_register((struct osi_coex_funcs_t *)&s_osi_coex_funcs_ro) != 0) {
|
||||
ESP_LOGW(NIMBLE_PORT_LOG_TAG, "osi coex funcs reg failed");
|
||||
ret = ESP_ERR_INVALID_ARG;
|
||||
goto modem_deint;
|
||||
goto free_controller;
|
||||
}
|
||||
|
||||
#if CONFIG_SW_COEXIST_ENABLE
|
||||
coex_init();
|
||||
#endif
|
||||
|
||||
ret = ble_controller_init(cfg);
|
||||
if (ret != ESP_OK) {
|
||||
ESP_LOGW(NIMBLE_PORT_LOG_TAG, "ble_controller_init failed %d", ret);
|
||||
goto modem_deint;
|
||||
goto free_controller;
|
||||
}
|
||||
|
||||
#if CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
|
||||
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 = ble_log_init_async(bt_controller_log_interface, false, buffers, (uint32_t *)log_bufs_size);
|
||||
#else
|
||||
ret = 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 controller_init_err;
|
||||
}
|
||||
#endif // CONFIG_BT_CONTROLLER_LOG_ENABLED
|
||||
|
||||
ret = controller_sleep_init();
|
||||
if (ret != ESP_OK) {
|
||||
ESP_LOGW(NIMBLE_PORT_LOG_TAG, "controller_sleep_init failed %d", ret);
|
||||
@@ -691,14 +693,9 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg)
|
||||
return ESP_OK;
|
||||
free_controller:
|
||||
controller_sleep_deinit();
|
||||
#if CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
|
||||
controller_init_err:
|
||||
ble_log_deinit_async();
|
||||
#endif // CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
|
||||
ble_controller_deinit();
|
||||
modem_deint:
|
||||
esp_phy_disable();
|
||||
esp_phy_modem_deinit();
|
||||
periph_module_disable(PERIPH_BT_MODULE);
|
||||
#if CONFIG_BT_NIMBLE_ENABLED
|
||||
ble_npl_eventq_deinit(nimble_port_get_dflt_eventq());
|
||||
#endif // CONFIG_BT_NIMBLE_ENABLED
|
||||
@@ -720,12 +717,12 @@ esp_err_t esp_bt_controller_deinit(void)
|
||||
|
||||
controller_sleep_deinit();
|
||||
|
||||
#if CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
|
||||
ble_log_deinit_async();
|
||||
#endif // CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
|
||||
ble_controller_deinit();
|
||||
if (s_ble_active) {
|
||||
esp_phy_disable();
|
||||
s_ble_active = false;
|
||||
}
|
||||
|
||||
periph_module_disable(PERIPH_BT_MODULE);
|
||||
ble_controller_deinit();
|
||||
|
||||
#if CONFIG_BT_NIMBLE_ENABLED
|
||||
/* De-initialize default event queue */
|
||||
@@ -761,17 +758,6 @@ esp_err_t esp_bt_controller_enable(esp_bt_mode_t mode)
|
||||
ESP_LOGW(NIMBLE_PORT_LOG_TAG, "invalid controller state");
|
||||
return ESP_FAIL;
|
||||
}
|
||||
if (!s_ble_active) {
|
||||
#if CONFIG_PM_ENABLE
|
||||
esp_pm_lock_acquire(s_pm_lock);
|
||||
#endif // CONFIG_PM_ENABLE
|
||||
// init phy
|
||||
esp_phy_enable(PHY_MODEM_BT);
|
||||
s_ble_active = true;
|
||||
}
|
||||
// init bb
|
||||
bt_bb_v2_init_cmplx(1);
|
||||
|
||||
#if CONFIG_SW_COEXIST_ENABLE
|
||||
coex_enable();
|
||||
#endif
|
||||
@@ -787,13 +773,6 @@ error:
|
||||
#if CONFIG_SW_COEXIST_ENABLE
|
||||
coex_disable();
|
||||
#endif
|
||||
if (s_ble_active) {
|
||||
esp_phy_disable(PHY_MODEM_BT);
|
||||
#if CONFIG_PM_ENABLE
|
||||
esp_pm_lock_release(s_pm_lock);
|
||||
#endif // CONFIG_PM_ENABLE
|
||||
s_ble_active = false;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -806,14 +785,6 @@ esp_err_t esp_bt_controller_disable(void)
|
||||
if (ble_controller_disable() != 0) {
|
||||
return ESP_FAIL;
|
||||
}
|
||||
|
||||
if (s_ble_active) {
|
||||
esp_phy_disable(PHY_MODEM_BT);
|
||||
#if CONFIG_PM_ENABLE
|
||||
esp_pm_lock_release(s_pm_lock);
|
||||
#endif // CONFIG_PM_ENABLE
|
||||
s_ble_active = false;
|
||||
}
|
||||
#if CONFIG_SW_COEXIST_ENABLE
|
||||
coex_disable();
|
||||
#endif
|
||||
@@ -844,30 +815,34 @@ esp_err_t esp_bt_mem_release(esp_bt_mode_t mode)
|
||||
{
|
||||
intptr_t mem_start, mem_end;
|
||||
|
||||
#if CONFIG_BT_RELEASE_IRAM && CONFIG_ESP_SYSTEM_PMP_IDRAM_SPLIT
|
||||
/* Release Bluetooth text section and merge Bluetooth data, bss & text into a large free heap
|
||||
* region when esp_bt_mem_release is called, total saving ~21kB or more of IRAM. ESP32-C2 has
|
||||
* only 3 configurable PMP entries available, rest of them are hard-coded. We cannot split the
|
||||
* memory into 3 different regions (IRAM, BLE-IRAM, DRAM). So `ESP_SYSTEM_PMP_IDRAM_SPLIT` needs
|
||||
* to be disabled.
|
||||
*/
|
||||
ESP_LOGE(NIMBLE_PORT_LOG_TAG, "`ESP_SYSTEM_PMP_IDRAM_SPLIT` should be disabled!");
|
||||
assert(0);
|
||||
#endif // CONFIG_BT_RELEASE_IRAM && CONFIG_ESP_SYSTEM_PMP_IDRAM_SPLIT
|
||||
|
||||
if (mode & ESP_BT_MODE_BLE) {
|
||||
#if CONFIG_BT_RELEASE_IRAM
|
||||
mem_start = (intptr_t)MAP_IRAM_TO_DRAM((intptr_t)&_iram_bt_text_start);
|
||||
mem_end = (intptr_t)&_bss_bt_end;
|
||||
#else
|
||||
mem_start = (intptr_t)&_bt_controller_data_start;
|
||||
if (mode == ESP_BT_MODE_BLE) {
|
||||
mem_start = (intptr_t)&_bt_bss_start;
|
||||
mem_end = (intptr_t)&_bt_bss_end;
|
||||
#endif // CONFIG_BT_RELEASE_IRAM
|
||||
if (mem_start != mem_end) {
|
||||
ESP_LOGI(NIMBLE_PORT_LOG_TAG, "Release BLE [0x%08x] - [0x%08x], len %d", mem_start,
|
||||
mem_end, mem_end - mem_start);
|
||||
ESP_LOGD(NIMBLE_PORT_LOG_TAG, "Release BT BSS [0x%08x] - [0x%08x]", mem_start, mem_end);
|
||||
ESP_ERROR_CHECK(try_heap_caps_add_region(mem_start, mem_end));
|
||||
}
|
||||
|
||||
mem_start = (intptr_t)&_bt_data_start;
|
||||
mem_end = (intptr_t)&_bt_data_end;
|
||||
if (mem_start != mem_end) {
|
||||
ESP_LOGD(NIMBLE_PORT_LOG_TAG, "Release BT Data [0x%08x] - [0x%08x]", mem_start, mem_end);
|
||||
ESP_ERROR_CHECK(try_heap_caps_add_region(mem_start, mem_end));
|
||||
}
|
||||
|
||||
mem_start = (intptr_t)&_nimble_bss_start;
|
||||
mem_end = (intptr_t)&_nimble_bss_end;
|
||||
if (mem_start != mem_end) {
|
||||
ESP_LOGD(NIMBLE_PORT_LOG_TAG, "Release NimBLE BSS [0x%08x] - [0x%08x]", mem_start, mem_end);
|
||||
ESP_ERROR_CHECK(try_heap_caps_add_region(mem_start, mem_end));
|
||||
}
|
||||
|
||||
mem_start = (intptr_t)&_nimble_data_start;
|
||||
mem_end = (intptr_t)&_nimble_data_end;
|
||||
if (mem_start != mem_end) {
|
||||
ESP_LOGD(NIMBLE_PORT_LOG_TAG, "Release NimBLE Data [0x%08x] - [0x%08x]", mem_start, mem_end);
|
||||
ESP_ERROR_CHECK(try_heap_caps_add_region(mem_start, mem_end));
|
||||
}
|
||||
}
|
||||
|
||||
return ESP_OK;
|
||||
@@ -995,40 +970,14 @@ esp_power_level_t esp_ble_tx_power_get_enhanced(esp_ble_enhanced_power_type_t po
|
||||
return (esp_power_level_t)tx_level;
|
||||
}
|
||||
|
||||
uint8_t esp_ble_get_chip_rev_version(void)
|
||||
{
|
||||
return efuse_ll_get_chip_wafer_version_minor();
|
||||
}
|
||||
|
||||
#if CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
|
||||
static void esp_bt_controller_log_interface(uint32_t len, const uint8_t *addr, bool end)
|
||||
{
|
||||
for (int i = 0; i < len; i++) {
|
||||
esp_rom_printf("%02x ", addr[i]);
|
||||
}
|
||||
if (end) {
|
||||
esp_rom_printf("\n");
|
||||
}
|
||||
}
|
||||
#if (!CONFIG_BT_NIMBLE_ENABLED) && (CONFIG_BT_CONTROLLER_ENABLED == true)
|
||||
|
||||
void esp_ble_controller_log_dump_all(bool output)
|
||||
{
|
||||
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);
|
||||
}
|
||||
#endif // CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
|
||||
|
||||
#if (!CONFIG_BT_NIMBLE_ENABLED) && (CONFIG_BT_CONTROLLER_ENABLED)
|
||||
#if CONFIG_BT_LE_SM_LEGACY || CONFIG_BT_LE_SM_SC
|
||||
#define BLE_SM_KEY_ERR 0x17
|
||||
|
||||
#if CONFIG_BT_LE_CRYPTO_STACK_MBEDTLS
|
||||
#include "mbedtls/aes.h"
|
||||
|
||||
#if CONFIG_BT_LE_SM_SC
|
||||
#include "mbedtls/cipher.h"
|
||||
#include "mbedtls/entropy.h"
|
||||
@@ -1036,9 +985,7 @@ void esp_ble_controller_log_dump_all(bool output)
|
||||
#include "mbedtls/cmac.h"
|
||||
#include "mbedtls/ecdh.h"
|
||||
#include "mbedtls/ecp.h"
|
||||
|
||||
static mbedtls_ecp_keypair keypair;
|
||||
#endif // CONFIG_BT_LE_SM_SC
|
||||
#endif
|
||||
|
||||
#else
|
||||
#include "tinycrypt/aes.h"
|
||||
@@ -1048,15 +995,15 @@ static mbedtls_ecp_keypair keypair;
|
||||
#if CONFIG_BT_LE_SM_SC
|
||||
#include "tinycrypt/cmac_mode.h"
|
||||
#include "tinycrypt/ecc_dh.h"
|
||||
#endif // CONFIG_BT_LE_SM_SC
|
||||
#endif // CONFIG_BT_LE_CRYPTO_STACK_MBEDTLS
|
||||
#endif
|
||||
|
||||
/* Based on Core Specification 4.2 Vol 3. Part H 2.3.5.6.1 */
|
||||
static const uint8_t ble_sm_alg_dbg_priv_key[32] = {
|
||||
0x3f, 0x49, 0xf6, 0xd4, 0xa3, 0xc5, 0x5f, 0x38, 0x74, 0xc9, 0xb3, 0xe3,
|
||||
0xd2, 0x10, 0x3f, 0x50, 0x4a, 0xff, 0x60, 0x7b, 0xeb, 0x40, 0xb7, 0x99,
|
||||
0x58, 0x99, 0xb8, 0xa6, 0xcd, 0x3c, 0x1a, 0xbd
|
||||
};
|
||||
#endif
|
||||
|
||||
#if CONFIG_BT_LE_CRYPTO_STACK_MBEDTLS
|
||||
#if CONFIG_BT_LE_SM_SC
|
||||
static mbedtls_ecp_keypair keypair;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
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)
|
||||
@@ -1103,7 +1050,8 @@ int ble_sm_alg_gen_dhkey(const uint8_t *peer_pub_key_x, const uint8_t *peer_pub_
|
||||
}
|
||||
|
||||
/* Set PRNG */
|
||||
if ((rc = mbedtls_ctr_drbg_seed(&ctr_drbg, mbedtls_entropy_func, &entropy, NULL, 0)) != 0) {
|
||||
if ((rc = mbedtls_ctr_drbg_seed(&ctr_drbg, mbedtls_entropy_func, &entropy,
|
||||
NULL, 0)) != 0) {
|
||||
goto exit;
|
||||
}
|
||||
|
||||
@@ -1147,12 +1095,19 @@ exit:
|
||||
if (rc == TC_CRYPTO_FAIL) {
|
||||
return BLE_SM_KEY_ERR;
|
||||
}
|
||||
#endif // CONFIG_BT_LE_CRYPTO_STACK_MBEDTLS
|
||||
#endif
|
||||
|
||||
swap_buf(out_dhkey, dh, 32);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* based on Core Specification 4.2 Vol 3. Part H 2.3.5.6.1 */
|
||||
static const uint8_t ble_sm_alg_dbg_priv_key[32] = {
|
||||
0x3f, 0x49, 0xf6, 0xd4, 0xa3, 0xc5, 0x5f, 0x38, 0x74, 0xc9, 0xb3, 0xe3,
|
||||
0xd2, 0x10, 0x3f, 0x50, 0x4a, 0xff, 0x60, 0x7b, 0xeb, 0x40, 0xb7, 0x99,
|
||||
0x58, 0x99, 0xb8, 0xa6, 0xcd, 0x3c, 0x1a, 0xbd
|
||||
};
|
||||
|
||||
#if CONFIG_BT_LE_CRYPTO_STACK_MBEDTLS
|
||||
static int mbedtls_gen_keypair(uint8_t *public_key, uint8_t *private_key)
|
||||
{
|
||||
@@ -1198,7 +1153,7 @@ exit:
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif // CONFIG_BT_LE_CRYPTO_STACK_MBEDTLS
|
||||
#endif
|
||||
|
||||
/**
|
||||
* pub: 64 bytes
|
||||
@@ -1214,6 +1169,7 @@ int ble_sm_alg_gen_key_pair(uint8_t *pub, uint8_t *priv)
|
||||
uint8_t pk[64];
|
||||
|
||||
do {
|
||||
|
||||
#if CONFIG_BT_LE_CRYPTO_STACK_MBEDTLS
|
||||
if (mbedtls_gen_keypair(pk, priv) != 0) {
|
||||
return BLE_SM_KEY_ERR;
|
||||
@@ -1222,16 +1178,17 @@ int ble_sm_alg_gen_key_pair(uint8_t *pub, uint8_t *priv)
|
||||
if (uECC_make_key(pk, priv, &curve_secp256r1) != TC_CRYPTO_SUCCESS) {
|
||||
return BLE_SM_KEY_ERR;
|
||||
}
|
||||
#endif // CONFIG_BT_LE_CRYPTO_STACK_MBEDTLS
|
||||
#endif
|
||||
|
||||
/* Make sure generated key isn't debug key. */
|
||||
} while (memcmp(priv, ble_sm_alg_dbg_priv_key, 32) == 0);
|
||||
|
||||
swap_buf(pub, pk, 32);
|
||||
swap_buf(&pub[32], &pk[32], 32);
|
||||
swap_in_place(priv, 32);
|
||||
#endif // CONFIG_BT_LE_SM_SC_DEBUG_KEYS
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif // CONFIG_BT_LE_SM_LEGACY || CONFIG_BT_LE_SM_SC
|
||||
#endif // (!CONFIG_BT_NIMBLE_ENABLED) && (CONFIG_BT_CONTROLLER_ENABLED)
|
||||
#endif
|
||||
|
||||
@@ -78,29 +78,15 @@ config BT_CTRL_ADV_DUP_FILT_MAX
|
||||
help
|
||||
The maxinum number of suplicate scan filter
|
||||
|
||||
choice BT_BLE_CCA_MODE
|
||||
prompt "BLE CCA mode"
|
||||
default BT_BLE_CCA_MODE_NONE
|
||||
config BT_CTRL_HW_CCA
|
||||
bool "HW CCA check enable"
|
||||
default n
|
||||
help
|
||||
Define BT BLE CCA mode
|
||||
|
||||
config BT_BLE_CCA_MODE_NONE
|
||||
bool "NONE"
|
||||
config BT_BLE_CCA_MODE_HW
|
||||
bool "Hardware"
|
||||
config BT_BLE_CCA_MODE_SW
|
||||
bool "Software"
|
||||
endchoice
|
||||
|
||||
config BT_BLE_CCA_MODE
|
||||
int
|
||||
default 0 if BT_BLE_CCA_MODE_NONE
|
||||
default 1 if BT_BLE_CCA_MODE_HW
|
||||
default 2 if BT_BLE_CCA_MODE_SW
|
||||
It enables HW CCA feature in controller
|
||||
|
||||
config BT_CTRL_HW_CCA_VAL
|
||||
int "CCA threshold value"
|
||||
range 20 100
|
||||
range 20 60
|
||||
default 20
|
||||
help
|
||||
It is the threshold value of HW CCA, if the value is 30, it means CCA threshold is -30 dBm.
|
||||
@@ -279,19 +265,20 @@ choice BT_CTRL_SCAN_DUPL_TYPE
|
||||
config BT_CTRL_SCAN_DUPL_TYPE_DEVICE
|
||||
bool "Scan Duplicate By Device Address"
|
||||
help
|
||||
Advertising packets with the same address, address type, and advertising type are reported once.
|
||||
This way is to use advertiser address filtering. The adv packet of the same address is only
|
||||
allowed to be reported once
|
||||
|
||||
config BT_CTRL_SCAN_DUPL_TYPE_DATA
|
||||
bool "Scan Duplicate By Advertising Data"
|
||||
help
|
||||
Advertising packets with identical advertising data, address type, and advertising type
|
||||
are reported only once, even if they originate from different devices.
|
||||
This way is to use advertising data filtering. All same advertising data only allow to be reported
|
||||
once even though they are from different devices.
|
||||
|
||||
config BT_CTRL_SCAN_DUPL_TYPE_DATA_DEVICE
|
||||
bool "Scan Duplicate By Device Address And Advertising Data"
|
||||
help
|
||||
Advertising packets with the same address, advertising data, address type,
|
||||
and advertising type are reported only once.
|
||||
This way is to use advertising data and device address filtering. All different adv packets with
|
||||
the same address are allowed to be reported.
|
||||
endchoice
|
||||
|
||||
config BT_CTRL_SCAN_DUPL_TYPE
|
||||
@@ -346,7 +333,7 @@ config BT_CTRL_MESH_DUPL_SCAN_CACHE_SIZE
|
||||
choice BT_CTRL_COEX_PHY_CODED_TX_RX_TLIM
|
||||
prompt "Coexistence: limit on MAX Tx/Rx time for coded-PHY connection"
|
||||
default BT_CTRL_COEX_PHY_CODED_TX_RX_TLIM_DIS
|
||||
depends on ESP_COEX_SW_COEXIST_ENABLE
|
||||
depends on ESP_WIFI_SW_COEXIST_ENABLE
|
||||
help
|
||||
When using PHY-Coded in BLE connection, limitation on max tx/rx time can be applied to
|
||||
better avoid dramatic performance deterioration of Wi-Fi.
|
||||
@@ -364,7 +351,7 @@ endchoice
|
||||
|
||||
config BT_CTRL_COEX_PHY_CODED_TX_RX_TLIM_EFF
|
||||
int
|
||||
default 0 if !ESP_COEX_SW_COEXIST_ENABLE
|
||||
default 0 if (!ESP_WIFI_SW_COEXIST_ENABLE)
|
||||
default 1 if BT_CTRL_COEX_PHY_CODED_TX_RX_TLIM_EN
|
||||
default 0 if BT_CTRL_COEX_PHY_CODED_TX_RX_TLIM_DIS
|
||||
|
||||
@@ -467,11 +454,3 @@ config BT_CTRL_SCAN_BACKOFF_UPPERLIMITMAX
|
||||
Disable active scan backoff. The bluetooth spec requires that scanners should run a backoff procedure to
|
||||
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 BT_BLE_ADV_DATA_LENGTH_ZERO_AUX
|
||||
bool "Enable aux packet when ext adv data length is zero"
|
||||
default n
|
||||
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.
|
||||
|
||||
@@ -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
|
||||
*/
|
||||
@@ -34,7 +34,7 @@
|
||||
#include "soc/rtc.h"
|
||||
#include "soc/rtc_cntl_reg.h"
|
||||
#include "soc/soc_memory_layout.h"
|
||||
#include "private/esp_coexist_internal.h"
|
||||
#include "esp_coexist_internal.h"
|
||||
#include "esp_timer.h"
|
||||
#include "esp_sleep.h"
|
||||
#include "esp_rom_sys.h"
|
||||
@@ -112,7 +112,7 @@ do{\
|
||||
} while(0)
|
||||
|
||||
#define OSI_FUNCS_TIME_BLOCKING 0xffffffff
|
||||
#define OSI_VERSION 0x00010007
|
||||
#define OSI_VERSION 0x00010006
|
||||
#define OSI_MAGIC_VALUE 0xFADEBEAD
|
||||
|
||||
/* Types definition
|
||||
@@ -135,6 +135,7 @@ typedef struct vhci_host_callback {
|
||||
|
||||
typedef struct {
|
||||
void *handle;
|
||||
void *storage;
|
||||
} btdm_queue_item_t;
|
||||
|
||||
typedef void (* osi_intr_handler)(void);
|
||||
@@ -193,8 +194,6 @@ struct osi_funcs_t {
|
||||
void (* _esp_hw_power_down)(void);
|
||||
void (* _esp_hw_power_up)(void);
|
||||
void (* _ets_backup_dma_copy)(uint32_t reg, uint32_t mem_addr, uint32_t num, bool to_rem);
|
||||
void (* _ets_delay_us)(uint32_t us);
|
||||
void (* _btdm_rom_table_ready)(void);
|
||||
};
|
||||
|
||||
|
||||
@@ -246,7 +245,6 @@ extern bool btdm_deep_sleep_mem_init(void);
|
||||
extern void btdm_deep_sleep_mem_deinit(void);
|
||||
extern void btdm_ble_power_down_dma_copy(bool copy);
|
||||
extern uint8_t btdm_sleep_clock_sync(void);
|
||||
extern void sdk_config_extend_set_pll_track(bool enable);
|
||||
|
||||
#if CONFIG_MAC_BB_PD
|
||||
extern void esp_mac_bb_power_down(void);
|
||||
@@ -254,8 +252,6 @@ extern void esp_mac_bb_power_up(void);
|
||||
extern void ets_backup_dma_copy(uint32_t reg, uint32_t mem_addr, uint32_t num, bool to_mem);
|
||||
#endif
|
||||
|
||||
extern void btdm_cca_feature_enable(void);
|
||||
|
||||
extern uint32_t _bt_bss_start;
|
||||
extern uint32_t _bt_bss_end;
|
||||
extern uint32_t _btdm_bss_start;
|
||||
@@ -315,7 +311,6 @@ static void interrupt_off_wrapper(int intr_num);
|
||||
static void btdm_hw_mac_power_up_wrapper(void);
|
||||
static void btdm_hw_mac_power_down_wrapper(void);
|
||||
static void btdm_backup_dma_copy_wrapper(uint32_t reg, uint32_t mem_addr, uint32_t num, bool to_mem);
|
||||
static void btdm_funcs_table_ready_wrapper(void);
|
||||
|
||||
static void btdm_slp_tmr_callback(void *arg);
|
||||
|
||||
@@ -380,8 +375,6 @@ static const struct osi_funcs_t osi_funcs_ro = {
|
||||
._esp_hw_power_down = btdm_hw_mac_power_down_wrapper,
|
||||
._esp_hw_power_up = btdm_hw_mac_power_up_wrapper,
|
||||
._ets_backup_dma_copy = btdm_backup_dma_copy_wrapper,
|
||||
._ets_delay_us = esp_rom_delay_us,
|
||||
._btdm_rom_table_ready = btdm_funcs_table_ready_wrapper,
|
||||
};
|
||||
|
||||
static DRAM_ATTR struct osi_funcs_t *osi_funcs_p;
|
||||
@@ -518,10 +511,16 @@ static void *semphr_create_wrapper(uint32_t max, uint32_t init)
|
||||
btdm_queue_item_t *semphr = heap_caps_calloc(1, sizeof(btdm_queue_item_t), MALLOC_CAP_8BIT|MALLOC_CAP_INTERNAL);
|
||||
assert(semphr);
|
||||
|
||||
/* IDF FreeRTOS guarantees that all dynamic memory allocation goes to internal RAM. */
|
||||
#if !CONFIG_SPIRAM_USE_MALLOC
|
||||
semphr->handle = (void *)xSemaphoreCreateCounting(max, init);
|
||||
assert(semphr->handle);
|
||||
#else
|
||||
|
||||
semphr->storage = heap_caps_malloc(sizeof(StaticQueue_t), MALLOC_CAP_INTERNAL|MALLOC_CAP_8BIT);
|
||||
assert(semphr->storage);
|
||||
|
||||
semphr->handle = (void *)xSemaphoreCreateCountingStatic(max, init, semphr->storage);
|
||||
#endif
|
||||
assert(semphr->handle);
|
||||
return semphr;
|
||||
}
|
||||
|
||||
@@ -536,6 +535,11 @@ static void semphr_delete_wrapper(void *semphr)
|
||||
if (semphr_item->handle) {
|
||||
vSemaphoreDelete(semphr_item->handle);
|
||||
}
|
||||
#ifdef CONFIG_SPIRAM_USE_MALLOC
|
||||
if (semphr_item->storage) {
|
||||
free(semphr_item->storage);
|
||||
}
|
||||
#endif
|
||||
|
||||
free(semphr);
|
||||
}
|
||||
@@ -591,9 +595,18 @@ static void *queue_create_wrapper(uint32_t queue_len, uint32_t item_size)
|
||||
queue = (btdm_queue_item_t*)heap_caps_malloc(sizeof(btdm_queue_item_t), MALLOC_CAP_INTERNAL|MALLOC_CAP_8BIT);
|
||||
assert(queue);
|
||||
|
||||
/* IDF FreeRTOS guarantees that all dynamic memory allocation goes to internal RAM. */
|
||||
#if CONFIG_SPIRAM_USE_MALLOC
|
||||
|
||||
queue->storage = heap_caps_calloc(1, sizeof(StaticQueue_t) + (queue_len*item_size), MALLOC_CAP_INTERNAL|MALLOC_CAP_8BIT);
|
||||
assert(queue->storage);
|
||||
|
||||
queue->handle = xQueueCreateStatic( queue_len, item_size, ((uint8_t*)(queue->storage)) + sizeof(StaticQueue_t), (StaticQueue_t*)(queue->storage));
|
||||
assert(queue->handle);
|
||||
|
||||
#else
|
||||
queue->handle = xQueueCreate( queue_len, item_size);
|
||||
assert(queue->handle);
|
||||
#endif
|
||||
|
||||
return queue;
|
||||
}
|
||||
@@ -605,6 +618,13 @@ static void queue_delete_wrapper(void *queue)
|
||||
if(queue_item->handle){
|
||||
vQueueDelete(queue_item->handle);
|
||||
}
|
||||
|
||||
#if CONFIG_SPIRAM_USE_MALLOC
|
||||
if (queue_item->storage) {
|
||||
free(queue_item->storage);
|
||||
}
|
||||
#endif
|
||||
|
||||
free(queue_item);
|
||||
}
|
||||
}
|
||||
@@ -654,7 +674,7 @@ static bool IRAM_ATTR is_in_isr_wrapper(void)
|
||||
|
||||
static void *malloc_internal_wrapper(size_t size)
|
||||
{
|
||||
void *p = heap_caps_malloc(size, MALLOC_CAP_INTERNAL|MALLOC_CAP_DMA);
|
||||
void *p = heap_caps_malloc(size, MALLOC_CAP_DEFAULT|MALLOC_CAP_INTERNAL|MALLOC_CAP_DMA);
|
||||
if(p == NULL) {
|
||||
ESP_LOGE(BT_LOG_TAG, "Malloc failed");
|
||||
}
|
||||
@@ -748,7 +768,7 @@ static void btdm_sleep_enter_phase2_wrapper(void)
|
||||
{
|
||||
if (btdm_controller_get_sleep_mode() == ESP_BT_SLEEP_MODE_1) {
|
||||
if (s_lp_stat.phy_enabled) {
|
||||
esp_phy_disable(PHY_MODEM_BT);
|
||||
esp_phy_disable();
|
||||
s_lp_stat.phy_enabled = 0;
|
||||
} else {
|
||||
assert(0);
|
||||
@@ -777,7 +797,7 @@ static void btdm_sleep_exit_phase3_wrapper(void)
|
||||
|
||||
if (btdm_controller_get_sleep_mode() == ESP_BT_SLEEP_MODE_1) {
|
||||
if (s_lp_stat.phy_enabled == 0) {
|
||||
esp_phy_enable(PHY_MODEM_BT);
|
||||
esp_phy_enable();
|
||||
s_lp_stat.phy_enabled = 1;
|
||||
}
|
||||
}
|
||||
@@ -879,13 +899,6 @@ static void async_wakeup_request_end(int event)
|
||||
return;
|
||||
}
|
||||
|
||||
static void btdm_funcs_table_ready_wrapper(void)
|
||||
{
|
||||
#if BT_BLE_CCA_MODE == 2
|
||||
btdm_cca_feature_enable();
|
||||
#endif
|
||||
}
|
||||
|
||||
static void coex_schm_status_bit_set_wrapper(uint32_t type, uint32_t status)
|
||||
{
|
||||
#if CONFIG_SW_COEXIST_ENABLE
|
||||
@@ -1155,6 +1168,18 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg)
|
||||
|
||||
btdm_controller_mem_init();
|
||||
|
||||
#if CONFIG_MAC_BB_PD
|
||||
if (esp_register_mac_bb_pd_callback(btdm_mac_bb_power_down_cb) != 0) {
|
||||
err = ESP_ERR_INVALID_ARG;
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (esp_register_mac_bb_pu_callback(btdm_mac_bb_power_up_cb) != 0) {
|
||||
err = ESP_ERR_INVALID_ARG;
|
||||
goto error;
|
||||
}
|
||||
#endif
|
||||
|
||||
osi_funcs_p = (struct osi_funcs_t *)malloc_internal_wrapper(sizeof(struct osi_funcs_t));
|
||||
if (osi_funcs_p == NULL) {
|
||||
return ESP_ERR_NO_MEM;
|
||||
@@ -1302,10 +1327,14 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg)
|
||||
periph_module_enable(PERIPH_BT_MODULE);
|
||||
periph_module_reset(PERIPH_BT_MODULE);
|
||||
|
||||
esp_phy_enable();
|
||||
s_lp_stat.phy_enabled = 1;
|
||||
|
||||
if (btdm_controller_init(cfg) != 0) {
|
||||
err = ESP_ERR_NO_MEM;
|
||||
goto error;
|
||||
}
|
||||
coex_pti_v2();
|
||||
|
||||
btdm_controller_status = ESP_BT_CONTROLLER_STATUS_INITED;
|
||||
|
||||
@@ -1335,6 +1364,11 @@ static void bt_controller_deinit_internal(void)
|
||||
{
|
||||
periph_module_disable(PERIPH_BT_MODULE);
|
||||
|
||||
if (s_lp_stat.phy_enabled) {
|
||||
esp_phy_disable();
|
||||
s_lp_stat.phy_enabled = 0;
|
||||
}
|
||||
|
||||
// deinit low power control resources
|
||||
do {
|
||||
|
||||
@@ -1395,6 +1429,11 @@ static void bt_controller_deinit_internal(void)
|
||||
btdm_lpcycle_us = 0;
|
||||
} while (0);
|
||||
|
||||
#if CONFIG_MAC_BB_PD
|
||||
esp_unregister_mac_bb_pd_callback(btdm_mac_bb_power_down_cb);
|
||||
esp_unregister_mac_bb_pu_callback(btdm_mac_bb_power_up_cb);
|
||||
#endif
|
||||
|
||||
esp_bt_power_domain_off();
|
||||
#if CONFIG_MAC_BB_PD
|
||||
esp_mac_bb_pd_mem_deinit();
|
||||
@@ -1423,12 +1462,6 @@ esp_err_t esp_bt_controller_enable(esp_bt_mode_t mode)
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
/* Enable PHY when enabling controller to reduce power dissipation after controller init
|
||||
* Notice the init order: esp_phy_enable() -> bt_bb_v2_init_cmplx() -> coex_pti_v2()
|
||||
*/
|
||||
esp_phy_enable(PHY_MODEM_BT);
|
||||
s_lp_stat.phy_enabled = 1;
|
||||
|
||||
#if CONFIG_SW_COEXIST_ENABLE
|
||||
coex_enable();
|
||||
#endif
|
||||
@@ -1443,33 +1476,16 @@ esp_err_t esp_bt_controller_enable(esp_bt_mode_t mode)
|
||||
s_lp_stat.pm_lock_released = 0;
|
||||
#endif
|
||||
|
||||
#if CONFIG_MAC_BB_PD
|
||||
if (esp_register_mac_bb_pd_callback(btdm_mac_bb_power_down_cb) != 0) {
|
||||
ret = ESP_ERR_INVALID_ARG;
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (esp_register_mac_bb_pu_callback(btdm_mac_bb_power_up_cb) != 0) {
|
||||
ret = ESP_ERR_INVALID_ARG;
|
||||
goto error;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (s_lp_cntl.enable) {
|
||||
btdm_controller_enable_sleep(true);
|
||||
}
|
||||
} while (0);
|
||||
|
||||
// Disable pll track by default in BLE controller on ESP32-C3 and ESP32-S3
|
||||
sdk_config_extend_set_pll_track(false);
|
||||
|
||||
if (btdm_controller_enable(mode) != 0) {
|
||||
ret = ESP_ERR_INVALID_STATE;
|
||||
goto error;
|
||||
}
|
||||
|
||||
coex_pti_v2();
|
||||
|
||||
btdm_controller_status = ESP_BT_CONTROLLER_STATUS_ENABLED;
|
||||
|
||||
return ret;
|
||||
@@ -1477,11 +1493,6 @@ esp_err_t esp_bt_controller_enable(esp_bt_mode_t mode)
|
||||
error:
|
||||
// disable low power mode
|
||||
do {
|
||||
#if CONFIG_MAC_BB_PD
|
||||
esp_unregister_mac_bb_pd_callback(btdm_mac_bb_power_down_cb);
|
||||
esp_unregister_mac_bb_pu_callback(btdm_mac_bb_power_up_cb);
|
||||
#endif
|
||||
|
||||
btdm_controller_enable_sleep(false);
|
||||
#ifdef CONFIG_PM_ENABLE
|
||||
if (s_lp_cntl.no_light_sleep) {
|
||||
@@ -1497,10 +1508,6 @@ error:
|
||||
#if CONFIG_SW_COEXIST_ENABLE
|
||||
coex_disable();
|
||||
#endif
|
||||
if (s_lp_stat.phy_enabled) {
|
||||
esp_phy_disable(PHY_MODEM_BT);
|
||||
s_lp_stat.phy_enabled = 0;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -1519,20 +1526,11 @@ esp_err_t esp_bt_controller_disable(void)
|
||||
#if CONFIG_SW_COEXIST_ENABLE
|
||||
coex_disable();
|
||||
#endif
|
||||
if (s_lp_stat.phy_enabled) {
|
||||
esp_phy_disable(PHY_MODEM_BT);
|
||||
s_lp_stat.phy_enabled = 0;
|
||||
}
|
||||
|
||||
btdm_controller_status = ESP_BT_CONTROLLER_STATUS_INITED;
|
||||
|
||||
// disable low power mode
|
||||
do {
|
||||
#if CONFIG_MAC_BB_PD
|
||||
esp_unregister_mac_bb_pd_callback(btdm_mac_bb_power_down_cb);
|
||||
esp_unregister_mac_bb_pu_callback(btdm_mac_bb_power_up_cb);
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_PM_ENABLE
|
||||
if (s_lp_cntl.no_light_sleep) {
|
||||
esp_pm_lock_release(s_light_sleep_pm_lock);
|
||||
|
||||
@@ -212,15 +212,6 @@ menu "Memory Settings"
|
||||
help
|
||||
Dynamic memory size of block 2
|
||||
|
||||
config BT_LE_MSYS_BUF_FROM_HEAP
|
||||
bool "Get Msys Mbuf from heap"
|
||||
default y
|
||||
depends on BT_LE_MSYS_INIT_IN_CONTROLLER
|
||||
help
|
||||
This option sets the source of the shared msys mbuf memory between
|
||||
the Host and the Controller. Allocate the memory from the heap if
|
||||
this option is sets, from the mempool otherwise.
|
||||
|
||||
config BT_LE_ACL_BUF_COUNT
|
||||
int "ACL Buffer count"
|
||||
default 10
|
||||
@@ -269,54 +260,6 @@ config BT_LE_CONTROLLER_TASK_STACK_SIZE
|
||||
help
|
||||
This configures stack size of NimBLE controller task
|
||||
|
||||
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
|
||||
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
|
||||
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
|
||||
Only operate in dump mode
|
||||
|
||||
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
|
||||
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
|
||||
Configure the size of the BLE HCI LOG buffer.
|
||||
|
||||
config BT_LE_LL_RESOLV_LIST_SIZE
|
||||
int "BLE LL Resolving list size"
|
||||
range 1 5
|
||||
@@ -382,7 +325,7 @@ config BT_LE_WHITELIST_SIZE
|
||||
|
||||
config BT_LE_LL_DUP_SCAN_LIST_COUNT
|
||||
int "BLE duplicate scan list count"
|
||||
range 5 100
|
||||
range 1 100
|
||||
default 20
|
||||
help
|
||||
config the max count of duplicate scan list
|
||||
@@ -397,7 +340,7 @@ config BT_LE_LL_SCA
|
||||
config BT_LE_MAX_CONNECTIONS
|
||||
int "Maximum number of concurrent connections"
|
||||
depends on !BT_NIMBLE_ENABLED
|
||||
range 1 70
|
||||
range 1 9
|
||||
default 3
|
||||
help
|
||||
Defines maximum number of concurrent BLE connections. For ESP32, user
|
||||
@@ -409,7 +352,7 @@ config BT_LE_MAX_CONNECTIONS
|
||||
choice BT_LE_COEX_PHY_CODED_TX_RX_TLIM
|
||||
prompt "Coexistence: limit on MAX Tx/Rx time for coded-PHY connection"
|
||||
default BT_LE_COEX_PHY_CODED_TX_RX_TLIM_DIS
|
||||
depends on ESP_COEX_SW_COEXIST_ENABLE
|
||||
depends on !BT_NIMBLE_ENABLED
|
||||
help
|
||||
When using PHY-Coded in BLE connection, limitation on max tx/rx time can be applied to
|
||||
better avoid dramatic performance deterioration of Wi-Fi.
|
||||
@@ -427,7 +370,7 @@ endchoice
|
||||
|
||||
config BT_LE_COEX_PHY_CODED_TX_RX_TLIM_EFF
|
||||
int
|
||||
default 0 if !ESP_COEX_SW_COEXIST_ENABLE
|
||||
depends on !BT_NIMBLE_ENABLED
|
||||
default 1 if BT_LE_COEX_PHY_CODED_TX_RX_TLIM_EN
|
||||
default 0 if BT_LE_COEX_PHY_CODED_TX_RX_TLIM_DIS
|
||||
|
||||
@@ -437,24 +380,19 @@ config BT_LE_SLEEP_ENABLE
|
||||
help
|
||||
Enable BLE sleep
|
||||
|
||||
choice BT_LE_LP_CLK_SRC
|
||||
prompt "BLE low power clock source"
|
||||
default BT_LE_LP_CLK_SRC_MAIN_XTAL
|
||||
config BT_LE_LP_CLK_SRC_MAIN_XTAL
|
||||
bool "Use main XTAL as RTC clock source"
|
||||
choice BT_LE_WAKEUP_SOURCE
|
||||
prompt "BLE light sleep wakeup source"
|
||||
depends on BT_LE_SLEEP_ENABLE
|
||||
default BT_LE_WAKEUP_SOURCE_BLE_RTC_TIMER
|
||||
config BT_LE_WAKEUP_SOURCE_CPU_RTC_TIMER
|
||||
bool "Use ESP timer to wakeup CPU"
|
||||
help
|
||||
User main XTAL as RTC clock source.
|
||||
This option is recommended if external 32.768k XTAL is not available.
|
||||
Using the external 32.768 kHz XTAL will have lower current consumption
|
||||
in light sleep compared to using the main XTAL.
|
||||
Use esp timer to wakeup CPU
|
||||
|
||||
config BT_LE_LP_CLK_SRC_DEFAULT
|
||||
bool "Use system RTC slow clock source"
|
||||
config BT_LE_WAKEUP_SOURCE_BLE_RTC_TIMER
|
||||
bool "Use BLE rtc timer to wakeup CPU"
|
||||
help
|
||||
Use the same slow clock source as system RTC
|
||||
Using any clock source other than external 32.768 kHz XTAL supports only
|
||||
legacy ADV and SCAN due to low clock accuracy.
|
||||
|
||||
Use BLE rtc timer to wakeup CPU
|
||||
endchoice
|
||||
|
||||
config BT_LE_USE_ESP_TIMER
|
||||
@@ -464,101 +402,3 @@ 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
|
||||
help
|
||||
The function is mainly used to enable flow control for advertising reports. When it is enabled,
|
||||
advertising reports will be discarded by the controller if the number of unprocessed advertising
|
||||
reports exceeds the size of BLE adv report flow control.
|
||||
|
||||
config BT_CTRL_BLE_ADV_REPORT_FLOW_CTRL_NUM
|
||||
int "BLE adv report flow control number"
|
||||
depends on BT_CTRL_BLE_ADV_REPORT_FLOW_CTRL_SUPP
|
||||
range 50 1000
|
||||
default 100
|
||||
help
|
||||
The number of unprocessed advertising report that bluetooth host can save.If you set
|
||||
`BT_CTRL_BLE_ADV_REPORT_FLOW_CTRL_NUM` to a small value, this may cause adv packets lost.
|
||||
If you set `BT_CTRL_BLE_ADV_REPORT_FLOW_CTRL_NUM` to a large value, bluetooth host may cache a
|
||||
lot of adv packets and this may cause system memory run out. For example, if you set
|
||||
it to 50, the maximum memory consumed by host is 35 * 50 bytes. Please set
|
||||
`BT_CTRL_BLE_ADV_REPORT_FLOW_CTRL_NUM` according to your system free memory and handle adv
|
||||
packets as fast as possible, otherwise it will cause adv packets lost.
|
||||
|
||||
config BT_CTRL_BLE_ADV_REPORT_DISCARD_THRSHOLD
|
||||
int "BLE adv lost event threshold value"
|
||||
depends on BT_CTRL_BLE_ADV_REPORT_FLOW_CTRL_SUPP
|
||||
range 1 1000
|
||||
default 20
|
||||
help
|
||||
When adv report flow control is enabled, The ADV lost event will be generated when the number
|
||||
of ADV packets lost in the controller reaches this threshold. It is better to set a larger value.
|
||||
If you set `BT_CTRL_BLE_ADV_REPORT_DISCARD_THRSHOLD` to a small value or printf every adv lost event, it
|
||||
may cause adv packets lost more.
|
||||
|
||||
config BT_LE_SCAN_DUPL
|
||||
bool "BLE Scan Duplicate Options"
|
||||
default y
|
||||
help
|
||||
This select enables parameters setting of BLE scan duplicate.
|
||||
|
||||
choice BT_LE_SCAN_DUPL_TYPE
|
||||
prompt "Scan Duplicate Type"
|
||||
default BT_LE_SCAN_DUPL_TYPE_DEVICE
|
||||
depends on BT_LE_SCAN_DUPL
|
||||
help
|
||||
Scan duplicate have three ways. one is "Scan Duplicate By Device Address", This way is to use
|
||||
advertiser address filtering. The adv packet of the same address is only allowed to be reported once.
|
||||
Another way is "Scan Duplicate By Device Address And Advertising Data". This way is to use advertising
|
||||
data and device address filtering. All different adv packets with the same address are allowed to be
|
||||
reported. The last way is "Scan Duplicate By Advertising Data". This way is to use advertising data
|
||||
filtering. All same advertising data only allow to be reported once even though they are from
|
||||
different devices.
|
||||
|
||||
config BT_LE_SCAN_DUPL_TYPE_DEVICE
|
||||
bool "Scan Duplicate By Device Address"
|
||||
help
|
||||
This way is to use advertiser address filtering. The adv packet of the same address is only
|
||||
allowed to be reported once
|
||||
|
||||
config BT_LE_SCAN_DUPL_TYPE_DATA
|
||||
bool "Scan Duplicate By Advertising Data"
|
||||
help
|
||||
This way is to use advertising data filtering. All same advertising data only allow to be reported
|
||||
once even though they are from different devices.
|
||||
|
||||
config BT_LE_SCAN_DUPL_TYPE_DATA_DEVICE
|
||||
bool "Scan Duplicate By Device Address And Advertising Data"
|
||||
help
|
||||
This way is to use advertising data and device address filtering. All different adv packets with
|
||||
the same address are allowed to be reported.
|
||||
endchoice
|
||||
|
||||
config BT_LE_SCAN_DUPL_TYPE
|
||||
int
|
||||
depends on BT_LE_SCAN_DUPL
|
||||
default 0 if BT_LE_SCAN_DUPL_TYPE_DEVICE
|
||||
default 1 if BT_LE_SCAN_DUPL_TYPE_DATA
|
||||
default 2 if BT_LE_SCAN_DUPL_TYPE_DATA_DEVICE
|
||||
default 0
|
||||
|
||||
config BT_LE_SCAN_DUPL_CACHE_REFRESH_PERIOD
|
||||
int "Duplicate scan list refresh period (seconds)"
|
||||
depends on BT_LE_SCAN_DUPL
|
||||
range 0 1000
|
||||
default 0
|
||||
help
|
||||
If the period value is non-zero, the controller will periodically clear the device information
|
||||
stored in the scan duuplicate filter. If it is 0, the scan duuplicate filter will not be cleared
|
||||
until the scanning is disabled. Duplicate advertisements for this period should not be sent to the
|
||||
Host in advertising report events.
|
||||
There are two scenarios where the ADV packet will be repeatedly reported:
|
||||
1. The duplicate scan cache is full, the controller will delete the oldest device information and
|
||||
add new device information.
|
||||
2. When the refresh period is up, the controller will clear all device information and start filtering
|
||||
again.
|
||||
|
||||
config BT_LE_MSYS_INIT_IN_CONTROLLER
|
||||
bool "Msys Mbuf Init in Controller"
|
||||
default y
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -24,7 +24,7 @@
|
||||
#endif // ESP_PLATFORM
|
||||
|
||||
#if CONFIG_SW_COEXIST_ENABLE
|
||||
#include "private/esp_coexist_internal.h"
|
||||
#include "esp_coexist_internal.h"
|
||||
#endif // CONFIG_SW_COEXIST_ENABLE
|
||||
|
||||
#include "nimble/nimble_npl_os.h"
|
||||
@@ -40,14 +40,6 @@
|
||||
#include "hci_uart.h"
|
||||
#include "bt_osi_mem.h"
|
||||
|
||||
#if SOC_PM_RETENTION_HAS_CLOCK_BUG
|
||||
#include "esp_private/sleep_retention.h"
|
||||
#endif // SOC_PM_RETENTION_HAS_CLOCK_BUG
|
||||
|
||||
#if CONFIG_FREERTOS_USE_TICKLESS_IDLE
|
||||
#include "esp_private/sleep_modem.h"
|
||||
#endif // CONFIG_FREERTOS_USE_TICKLESS_IDLE
|
||||
|
||||
#ifdef CONFIG_BT_BLUEDROID_ENABLED
|
||||
#include "hci/hci_hal.h"
|
||||
#endif // CONFIG_BT_BLUEDROID_ENABLED
|
||||
@@ -58,8 +50,6 @@
|
||||
#include "esp_private/periph_ctrl.h"
|
||||
#include "esp_sleep.h"
|
||||
|
||||
#include "hal/efuse_hal.h"
|
||||
#include "soc/rtc.h"
|
||||
/* Macro definition
|
||||
************************************************************************
|
||||
*/
|
||||
@@ -77,6 +67,7 @@
|
||||
#define ACL_DATA_MBUF_LEADINGSPCAE 4
|
||||
#endif // CONFIG_BT_BLUEDROID_ENABLED
|
||||
|
||||
|
||||
/* Types definition
|
||||
************************************************************************
|
||||
*/
|
||||
@@ -113,22 +104,12 @@ struct ext_funcs_t {
|
||||
uint32_t magic;
|
||||
};
|
||||
|
||||
#if CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
|
||||
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 ble_controller_init(esp_bt_controller_config_t *cfg);
|
||||
#if CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
|
||||
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_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);
|
||||
extern int ble_controller_disable(void);
|
||||
@@ -138,18 +119,14 @@ extern int esp_ble_ll_set_public_addr(const uint8_t *addr);
|
||||
extern int esp_register_npl_funcs (struct npl_funcs_t *p_npl_func);
|
||||
extern void esp_unregister_npl_funcs (void);
|
||||
extern void npl_freertos_mempool_deinit(void);
|
||||
extern int os_msys_buf_alloc(void);
|
||||
extern uint32_t r_os_cputime_get32(void);
|
||||
extern uint32_t r_os_cputime_ticks_to_usecs(uint32_t ticks);
|
||||
extern void r_ble_lll_rfmgmt_set_sleep_cb(void *s_cb, void *w_cb, void *s_arg,
|
||||
void *w_arg, uint32_t us_to_enabled);
|
||||
extern void r_ble_rtc_wake_up_state_clr(void);
|
||||
extern void ble_lll_rfmgmt_set_sleep_cb(void *s_cb, void *w_cb, void *s_arg,
|
||||
void *w_arg, uint32_t us_to_enabled);
|
||||
extern void ble_rtc_wake_up_state_clr(void);
|
||||
extern int os_msys_init(void);
|
||||
extern void os_msys_deinit(void);
|
||||
#if CONFIG_FREERTOS_USE_TICKLESS_IDLE
|
||||
extern const sleep_retention_entries_config_t *esp_ble_mac_retention_link_get(uint8_t *size, uint8_t extra);
|
||||
extern void esp_ble_set_wakeup_overhead(uint32_t overhead);
|
||||
#endif /* CONFIG_FREERTOS_USE_TICKLESS_IDLE */
|
||||
extern void esp_ble_change_rtc_freq(uint32_t freq);
|
||||
extern void os_msys_buf_free(void);
|
||||
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);
|
||||
@@ -157,7 +134,6 @@ extern int ble_sm_alg_gen_key_pair(uint8_t *pub, uint8_t *priv);
|
||||
extern int ble_txpwr_set(esp_ble_enhanced_power_type_t power_type, uint16_t handle, int power_level);
|
||||
extern int ble_txpwr_get(esp_ble_enhanced_power_type_t power_type, uint16_t handle);
|
||||
extern int ble_get_npl_element_info(esp_bt_controller_config_t *cfg, ble_npl_count_info_t * npl_info);
|
||||
extern char *ble_controller_get_compile_version(void);
|
||||
extern uint32_t _bt_bss_start;
|
||||
extern uint32_t _bt_bss_end;
|
||||
extern uint32_t _bt_controller_bss_start;
|
||||
@@ -191,22 +167,13 @@ 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
|
||||
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};
|
||||
#endif // CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
|
||||
|
||||
/* This variable tells if BLE is running */
|
||||
static bool s_ble_active = false;
|
||||
#ifdef CONFIG_PM_ENABLE
|
||||
@@ -214,8 +181,15 @@ static DRAM_ATTR esp_pm_lock_handle_t s_pm_lock = NULL;
|
||||
#define BTDM_MIN_TIMER_UNCERTAINTY_US (200)
|
||||
#endif // CONFIG_PM_ENABLE
|
||||
|
||||
#define BLE_RTC_DELAY_US_LIGHT_SLEEP (2500)
|
||||
#define BLE_RTC_DELAY_US_MODEM_SLEEP (500)
|
||||
#ifdef CONFIG_BT_LE_WAKEUP_SOURCE_BLE_RTC_TIMER
|
||||
#define BLE_RTC_DELAY_US (1100)
|
||||
#endif // CONFIG_BT_LE_WAKEUP_SOURCE_BLE_RTC_TIMER
|
||||
|
||||
#ifdef CONFIG_BT_LE_WAKEUP_SOURCE_CPU_RTC_TIMER
|
||||
#define BLE_RTC_DELAY_US (0)
|
||||
static void ble_sleep_timer_callback(void *arg);
|
||||
static DRAM_ATTR esp_timer_handle_t s_ble_sleep_timer = NULL;
|
||||
#endif // CONFIG_BT_LE_WAKEUP_SOURCE_CPU_RTC_TIMER
|
||||
|
||||
static const struct osi_coex_funcs_t s_osi_coex_funcs_ro = {
|
||||
._magic = OSI_COEX_MAGIC_VALUE,
|
||||
@@ -244,8 +218,8 @@ struct ext_funcs_t ext_funcs_ro = {
|
||||
._task_delete = task_delete_wrapper,
|
||||
._osi_assert = osi_assert_wrapper,
|
||||
._os_random = osi_random_wrapper,
|
||||
._ecc_gen_key_pair = esp_ecc_gen_key_pair,
|
||||
._ecc_gen_dh_key = esp_ecc_gen_dh_key,
|
||||
._ecc_gen_key_pair = ble_sm_alg_gen_key_pair,
|
||||
._ecc_gen_dh_key = ble_sm_alg_gen_dhkey,
|
||||
._esp_reset_rpa_moudle = esp_reset_rpa_moudle,
|
||||
.magic = EXT_FUNC_MAGIC_VALUE,
|
||||
};
|
||||
@@ -259,9 +233,6 @@ static void IRAM_ATTR osi_assert_wrapper(const uint32_t ln, const char *fn,
|
||||
uint32_t param1, uint32_t param2)
|
||||
{
|
||||
BT_ASSERT_PRINT("BLE assert: line %d in function %s, param: 0x%x, 0x%x", ln, fn, param1, param2);
|
||||
#if CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
|
||||
esp_ble_controller_log_dump_all(true);
|
||||
#endif // CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
|
||||
assert(0);
|
||||
}
|
||||
|
||||
@@ -328,7 +299,6 @@ void esp_vhci_host_send_packet(uint8_t *data, uint16_t len)
|
||||
if (*(data) == DATA_TYPE_COMMAND) {
|
||||
struct ble_hci_cmd *cmd = NULL;
|
||||
cmd = (struct ble_hci_cmd *) ble_hci_trans_buf_alloc(BLE_HCI_TRANS_BUF_CMD);
|
||||
assert(cmd);
|
||||
memcpy((uint8_t *)cmd, data + 1, len - 1);
|
||||
ble_hci_trans_hs_cmd_tx((uint8_t *)cmd);
|
||||
}
|
||||
@@ -365,25 +335,6 @@ static void task_delete_wrapper(void *task_handle)
|
||||
vTaskDelete(task_handle);
|
||||
}
|
||||
|
||||
static int esp_ecc_gen_key_pair(uint8_t *pub, uint8_t *priv)
|
||||
{
|
||||
int rc = -1;
|
||||
#if CONFIG_BT_LE_SM_LEGACY || CONFIG_BT_LE_SM_SC
|
||||
rc = ble_sm_alg_gen_key_pair(pub, priv);
|
||||
#endif // CONFIG_BT_LE_SM_LEGACY || CONFIG_BT_LE_SM_SC
|
||||
return rc;
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
int rc = -1;
|
||||
#if CONFIG_BT_LE_SM_LEGACY || CONFIG_BT_LE_SM_SC
|
||||
rc = ble_sm_alg_gen_dhkey(peer_pub_key_x, peer_pub_key_y, our_priv_key, out_dhkey);
|
||||
#endif // CONFIG_BT_LE_SM_LEGACY || CONFIG_BT_LE_SM_SC
|
||||
return rc;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_BT_LE_HCI_INTERFACE_USE_UART
|
||||
static void hci_uart_start_tx_wrapper(int uart_no)
|
||||
{
|
||||
@@ -450,51 +401,47 @@ static int esp_intr_free_wrapper(void **ret_handle)
|
||||
return rc;
|
||||
}
|
||||
|
||||
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:
|
||||
ESP_LOGI(NIMBLE_PORT_LOG_TAG, "Using main XTAL as clock source");
|
||||
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_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:
|
||||
ESP_LOGI(NIMBLE_PORT_LOG_TAG, "Using external 32.768 kHz XTAL as clock source");
|
||||
modem_clock_select_lp_clock_source(PERIPH_BT_MODULE, slow_clk_src, (1 - 1));
|
||||
break;
|
||||
case MODEM_CLOCK_LPCLK_SRC_RC32K:
|
||||
ESP_LOGI(NIMBLE_PORT_LOG_TAG, "Using 32 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, (1 - 1));
|
||||
break;
|
||||
case MODEM_CLOCK_LPCLK_SRC_EXT32K:
|
||||
ESP_LOGI(NIMBLE_PORT_LOG_TAG, "Using 32 kHz oscillator 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, (1 - 1));
|
||||
break;
|
||||
default:
|
||||
}
|
||||
}
|
||||
|
||||
IRAM_ATTR void controller_sleep_cb(uint32_t enable_tick, void *arg)
|
||||
{
|
||||
if (!s_ble_active) {
|
||||
return;
|
||||
}
|
||||
#if CONFIG_FREERTOS_USE_TICKLESS_IDLE
|
||||
r_ble_rtc_wake_up_state_clr();
|
||||
#endif /* CONFIG_FREERTOS_USE_TICKLESS_IDLE */
|
||||
esp_phy_disable(PHY_MODEM_BT);
|
||||
|
||||
#ifdef CONFIG_PM_ENABLE
|
||||
#ifdef CONFIG_BT_LE_WAKEUP_SOURCE_CPU_RTC_TIMER
|
||||
uint32_t delta_tick;
|
||||
uint32_t us_to_sleep;
|
||||
uint32_t sleep_tick;
|
||||
uint32_t tick_invalid = *(uint32_t*)(arg);
|
||||
assert(arg != NULL);
|
||||
if (!tick_invalid) {
|
||||
sleep_tick = r_os_cputime_get32();
|
||||
/* start a timer to wake up and acquire the pm_lock before modem_sleep awakes */
|
||||
delta_tick = enable_tick - sleep_tick;
|
||||
if (delta_tick & 0x80000000) {
|
||||
return;
|
||||
}
|
||||
us_to_sleep = r_os_cputime_ticks_to_usecs(delta_tick);
|
||||
if (us_to_sleep <= BTDM_MIN_TIMER_UNCERTAINTY_US) {
|
||||
return;
|
||||
}
|
||||
esp_err_t err = esp_timer_start_once(s_ble_sleep_timer,
|
||||
us_to_sleep - BTDM_MIN_TIMER_UNCERTAINTY_US);
|
||||
if (err != ESP_OK) {
|
||||
ESP_LOGW(NIMBLE_PORT_LOG_TAG, "ESP timer start failed\n");
|
||||
return;
|
||||
}
|
||||
}
|
||||
#endif // CONFIG_BT_LE_WAKEUP_SOURCE_CPU_RTC_TIMER
|
||||
|
||||
#ifdef CONFIG_BT_LE_WAKEUP_SOURCE_BLE_RTC_TIMER
|
||||
r_ble_rtc_wake_up_state_clr();
|
||||
#endif // CONFIG_BT_LE_WAKEUP_SOURCE_BLE_RTC_TIMER
|
||||
|
||||
esp_pm_lock_release(s_pm_lock);
|
||||
#endif // CONFIG_PM_ENABLE
|
||||
|
||||
esp_phy_disable();
|
||||
s_ble_active = false;
|
||||
}
|
||||
|
||||
@@ -503,51 +450,37 @@ IRAM_ATTR void controller_wakeup_cb(void *arg)
|
||||
if (s_ble_active) {
|
||||
return;
|
||||
}
|
||||
esp_phy_enable();
|
||||
|
||||
#ifdef CONFIG_PM_ENABLE
|
||||
esp_pm_lock_acquire(s_pm_lock);
|
||||
r_ble_rtc_wake_up_state_clr();
|
||||
#endif //CONFIG_PM_ENABLE
|
||||
esp_phy_enable(PHY_MODEM_BT);
|
||||
|
||||
s_ble_active = true;
|
||||
}
|
||||
|
||||
#if CONFIG_FREERTOS_USE_TICKLESS_IDLE
|
||||
static esp_err_t sleep_modem_ble_mac_modem_state_init(uint8_t extra)
|
||||
#ifdef CONFIG_PM_ENABLE
|
||||
#ifdef CONFIG_BT_LE_WAKEUP_SOURCE_CPU_RTC_TIMER
|
||||
static void ble_sleep_timer_callback(void * arg)
|
||||
{
|
||||
uint8_t size;
|
||||
const sleep_retention_entries_config_t *ble_mac_modem_config = esp_ble_mac_retention_link_get(&size, extra);
|
||||
esp_err_t err = sleep_retention_entries_create(ble_mac_modem_config, size, REGDMA_LINK_PRI_5, SLEEP_RETENTION_MODULE_BLE_MAC);
|
||||
if (err == ESP_OK) {
|
||||
ESP_LOGI(NIMBLE_PORT_LOG_TAG, "Modem BLE MAC retention initialization");
|
||||
}
|
||||
return err;
|
||||
|
||||
}
|
||||
|
||||
static void sleep_modem_ble_mac_modem_state_deinit(void)
|
||||
{
|
||||
sleep_retention_entries_destroy(SLEEP_RETENTION_MODULE_BLE_MAC);
|
||||
}
|
||||
|
||||
void sleep_modem_light_sleep_overhead_set(uint32_t overhead)
|
||||
{
|
||||
esp_ble_set_wakeup_overhead(overhead);
|
||||
}
|
||||
#endif /* CONFIG_FREERTOS_USE_TICKLESS_IDLE */
|
||||
|
||||
#endif // CONFIG_BT_LE_WAKEUP_SOURCE_CPU_RTC_TIMER
|
||||
#endif // CONFIG_PM_ENABLE
|
||||
|
||||
esp_err_t controller_sleep_init(void)
|
||||
{
|
||||
esp_err_t rc = 0;
|
||||
|
||||
#ifdef CONFIG_BT_LE_SLEEP_ENABLE
|
||||
ESP_LOGW(NIMBLE_PORT_LOG_TAG, "BLE modem sleep is enabled");
|
||||
#if CONFIG_FREERTOS_USE_TICKLESS_IDLE
|
||||
r_ble_lll_rfmgmt_set_sleep_cb(controller_sleep_cb, controller_wakeup_cb, 0, 0,
|
||||
BLE_RTC_DELAY_US_LIGHT_SLEEP);
|
||||
#else
|
||||
r_ble_lll_rfmgmt_set_sleep_cb(controller_sleep_cb, controller_wakeup_cb, 0, 0,
|
||||
BLE_RTC_DELAY_US_MODEM_SLEEP);
|
||||
#endif /* FREERTOS_USE_TICKLESS_IDLE */
|
||||
ESP_LOGW(NIMBLE_PORT_LOG_TAG, "BLE modem sleep is enabled\n");
|
||||
ble_lll_rfmgmt_set_sleep_cb(controller_sleep_cb, controller_wakeup_cb, 0, 0,
|
||||
500 + BLE_RTC_DELAY_US);
|
||||
|
||||
#ifdef CONFIG_PM_ENABLE
|
||||
esp_sleep_pd_config(ESP_PD_DOMAIN_XTAL, ESP_PD_OPTION_ON);
|
||||
#endif // CONFIG_PM_ENABLE
|
||||
#endif // CONFIG_BT_LE_SLEEP_ENABLE
|
||||
|
||||
#ifdef CONFIG_PM_ENABLE
|
||||
@@ -555,133 +488,78 @@ esp_err_t controller_sleep_init(void)
|
||||
if (rc != ESP_OK) {
|
||||
goto error;
|
||||
}
|
||||
#if CONFIG_FREERTOS_USE_TICKLESS_IDLE
|
||||
/* Create a new regdma link for BLE related register restoration */
|
||||
rc = sleep_modem_ble_mac_modem_state_init(1);
|
||||
assert(rc == 0);
|
||||
esp_sleep_enable_bt_wakeup();
|
||||
ESP_LOGW(NIMBLE_PORT_LOG_TAG, "Enable light sleep, the wake up source is BLE timer");
|
||||
esp_pm_lock_acquire(s_pm_lock);
|
||||
|
||||
rc = esp_pm_register_inform_out_light_sleep_overhead_callback(sleep_modem_light_sleep_overhead_set);
|
||||
#ifdef CONFIG_BT_LE_WAKEUP_SOURCE_CPU_RTC_TIMER
|
||||
esp_timer_create_args_t create_args = {
|
||||
.callback = ble_sleep_timer_callback,
|
||||
.arg = NULL,
|
||||
.name = "btSlp"
|
||||
};
|
||||
rc = esp_timer_create(&create_args, &s_ble_sleep_timer);
|
||||
if (rc != ESP_OK) {
|
||||
goto error;
|
||||
}
|
||||
ESP_LOGW(NIMBLE_PORT_LOG_TAG, "Enable light sleep, the wake up source is ESP timer");
|
||||
#endif //CONFIG_BT_LE_WAKEUP_SOURCE_CPU_RTC_TIMER
|
||||
|
||||
#ifdef CONFIG_BT_LE_WAKEUP_SOURCE_BLE_RTC_TIMER
|
||||
esp_sleep_enable_bt_wakeup();
|
||||
ESP_LOGW(NIMBLE_PORT_LOG_TAG, "Enable light sleep, the wake up source is BLE timer");
|
||||
#endif // CONFIG_BT_LE_WAKEUP_SOURCE_BLE_RTC_TIMER
|
||||
|
||||
#if SOC_PM_RETENTION_HAS_CLOCK_BUG && CONFIG_MAC_BB_PD
|
||||
sleep_modem_register_mac_bb_module_prepare_callback(sleep_modem_mac_bb_power_down_prepare,
|
||||
sleep_modem_mac_bb_power_up_prepare);
|
||||
#endif // SOC_PM_RETENTION_HAS_CLOCK_BUG && CONFIG_MAC_BB_PD
|
||||
#endif /* CONFIG_FREERTOS_USE_TICKLESS_IDLE */
|
||||
return rc;
|
||||
|
||||
error:
|
||||
|
||||
#if CONFIG_FREERTOS_USE_TICKLESS_IDLE
|
||||
#if SOC_PM_RETENTION_HAS_CLOCK_BUG && CONFIG_MAC_BB_PD
|
||||
sleep_modem_unregister_mac_bb_module_prepare_callback(sleep_modem_mac_bb_power_down_prepare,
|
||||
sleep_modem_mac_bb_power_up_prepare);
|
||||
#endif // SOC_PM_RETENTION_HAS_CLOCK_BUG && CONFIG_MAC_BB_PD
|
||||
esp_sleep_disable_bt_wakeup();
|
||||
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) {
|
||||
esp_pm_lock_release(s_pm_lock);
|
||||
esp_pm_lock_delete(s_pm_lock);
|
||||
s_pm_lock = NULL;
|
||||
}
|
||||
#endif // CONFIG_PM_ENABLE
|
||||
#ifdef CONFIG_BT_LE_WAKEUP_SOURCE_CPU_RTC_TIMER
|
||||
if (s_ble_sleep_timer != NULL) {
|
||||
esp_timer_stop(s_ble_sleep_timer);
|
||||
esp_timer_delete(s_ble_sleep_timer);
|
||||
s_ble_sleep_timer = NULL;
|
||||
}
|
||||
#endif // CONFIG_BT_LE_WAKEUP_SOURCE_CPU_RTC_TIMER
|
||||
|
||||
#ifdef CONFIG_BT_LE_WAKEUP_SOURCE_BLE_RTC_TIMER
|
||||
esp_sleep_disable_bt_wakeup();
|
||||
#endif // CONFIG_BT_LE_WAKEUP_SOURCE_BLE_RTC_TIMER
|
||||
|
||||
#endif //CONFIG_PM_ENABLE
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
void controller_sleep_deinit(void)
|
||||
{
|
||||
#if CONFIG_FREERTOS_USE_TICKLESS_IDLE
|
||||
#if SOC_PM_RETENTION_HAS_CLOCK_BUG && CONFIG_MAC_BB_PD
|
||||
sleep_modem_unregister_mac_bb_module_prepare_callback(sleep_modem_mac_bb_power_down_prepare,
|
||||
sleep_modem_mac_bb_power_up_prepare);
|
||||
#endif // SOC_PM_RETENTION_HAS_CLOCK_BUG && CONFIG_MAC_BB_PD
|
||||
#ifdef CONFIG_PM_ENABLE
|
||||
#ifdef CONFIG_BT_LE_WAKEUP_SOURCE_BLE_RTC_TIMER
|
||||
r_ble_rtc_wake_up_state_clr();
|
||||
esp_sleep_disable_bt_wakeup();
|
||||
sleep_modem_ble_mac_modem_state_deinit();
|
||||
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
|
||||
#endif //CONFIG_BT_LE_WAKEUP_SOURCE_BLE_RTC_TIMER
|
||||
|
||||
esp_sleep_pd_config(ESP_PD_DOMAIN_XTAL, ESP_PD_OPTION_AUTO);
|
||||
|
||||
/* lock should be released first */
|
||||
if (s_ble_active) {
|
||||
esp_pm_lock_release(s_pm_lock);
|
||||
}
|
||||
|
||||
esp_pm_lock_delete(s_pm_lock);
|
||||
s_pm_lock = NULL;
|
||||
#endif //CONFIG_PM_ENABLE
|
||||
}
|
||||
|
||||
typedef enum {
|
||||
FILTER_DUPLICATE_PDUTYPE = BIT(0),
|
||||
FILTER_DUPLICATE_LENGTH = BIT(1),
|
||||
FILTER_DUPLICATE_ADDRESS = BIT(2),
|
||||
FILTER_DUPLICATE_ADVDATA = BIT(3),
|
||||
FILTER_DUPLICATE_DEFAULT = FILTER_DUPLICATE_PDUTYPE | FILTER_DUPLICATE_ADDRESS,
|
||||
FILTER_DUPLICATE_PDU_ALL = 0xF,
|
||||
FILTER_DUPLICATE_EXCEPTION_FOR_MESH = BIT(4),
|
||||
FILTER_DUPLICATE_AD_TYPE = BIT(5),
|
||||
}disc_duplicate_mode_t;
|
||||
|
||||
|
||||
extern void r_filter_duplicate_mode_enable(disc_duplicate_mode_t mode);
|
||||
extern void r_filter_duplicate_mode_disable(disc_duplicate_mode_t mode);
|
||||
extern void r_filter_duplicate_set_ring_list_max_num(uint32_t max_num);
|
||||
extern void r_scan_duplicate_cache_refresh_set_time(uint32_t period_time);
|
||||
|
||||
int
|
||||
ble_vhci_disc_duplicate_mode_enable(int mode)
|
||||
{
|
||||
// TODO: use vendor hci to update
|
||||
r_filter_duplicate_mode_enable(mode);
|
||||
return true;
|
||||
}
|
||||
|
||||
int
|
||||
ble_vhci_disc_duplicate_mode_disable(int mode)
|
||||
{
|
||||
// TODO: use vendor hci to update
|
||||
r_filter_duplicate_mode_disable(mode);
|
||||
return true;
|
||||
}
|
||||
|
||||
int ble_vhci_disc_duplicate_set_max_cache_size(int max_cache_size){
|
||||
// TODO: use vendor hci to update
|
||||
r_filter_duplicate_set_ring_list_max_num(max_cache_size);
|
||||
return true;
|
||||
}
|
||||
|
||||
int ble_vhci_disc_duplicate_set_period_refresh_time(int refresh_period_time){
|
||||
// TODO: use vendor hci to update
|
||||
r_scan_duplicate_cache_refresh_set_time(refresh_period_time);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Config scan duplicate option mode from menuconfig (Adapt to the old configuration method.)
|
||||
*/
|
||||
void ble_controller_scan_duplicate_config(void)
|
||||
{
|
||||
uint32_t duplicate_mode = FILTER_DUPLICATE_DEFAULT;
|
||||
uint32_t cache_size = 100;
|
||||
#if CONFIG_BT_LE_SCAN_DUPL == true
|
||||
cache_size = CONFIG_BT_LE_LL_DUP_SCAN_LIST_COUNT;
|
||||
if (CONFIG_BT_LE_SCAN_DUPL_TYPE == 0) {
|
||||
duplicate_mode = FILTER_DUPLICATE_ADDRESS | FILTER_DUPLICATE_PDUTYPE;
|
||||
} else if (CONFIG_BT_LE_SCAN_DUPL_TYPE == 1) {
|
||||
duplicate_mode = FILTER_DUPLICATE_ADVDATA;
|
||||
} else if (CONFIG_BT_LE_SCAN_DUPL_TYPE == 2) {
|
||||
duplicate_mode = FILTER_DUPLICATE_ADDRESS | FILTER_DUPLICATE_ADVDATA;
|
||||
#ifdef CONFIG_BT_LE_WAKEUP_SOURCE_CPU_RTC_TIMER
|
||||
if (s_ble_sleep_timer != NULL) {
|
||||
esp_timer_stop(s_ble_sleep_timer);
|
||||
esp_timer_delete(s_ble_sleep_timer);
|
||||
s_ble_sleep_timer = NULL;
|
||||
}
|
||||
duplicate_mode |= FILTER_DUPLICATE_EXCEPTION_FOR_MESH;
|
||||
|
||||
ble_vhci_disc_duplicate_set_period_refresh_time(CONFIG_BT_LE_SCAN_DUPL_CACHE_REFRESH_PERIOD);
|
||||
#endif
|
||||
|
||||
ble_vhci_disc_duplicate_mode_disable(0xFFFFFFFF);
|
||||
ble_vhci_disc_duplicate_mode_enable(duplicate_mode);
|
||||
ble_vhci_disc_duplicate_set_max_cache_size(cache_size);
|
||||
#endif //CONFIG_BT_LE_WAKEUP_SOURCE_CPU_RTC_TIMER
|
||||
#endif //CONFIG_PM_ENABLE
|
||||
}
|
||||
|
||||
esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg)
|
||||
@@ -689,7 +567,6 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg)
|
||||
uint8_t mac[6];
|
||||
esp_err_t ret = ESP_OK;
|
||||
ble_npl_count_info_t npl_info;
|
||||
uint32_t slow_clk_freq = 0;
|
||||
|
||||
memset(&npl_info, 0, sizeof(ble_npl_count_info_t));
|
||||
|
||||
@@ -731,49 +608,34 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg)
|
||||
goto free_mem;
|
||||
}
|
||||
|
||||
/* Initialize the global memory pool */
|
||||
ret = os_msys_buf_alloc();
|
||||
if (ret != ESP_OK) {
|
||||
ESP_LOGW(NIMBLE_PORT_LOG_TAG, "os msys alloc failed");
|
||||
goto free_mem;
|
||||
}
|
||||
|
||||
os_msys_init();
|
||||
|
||||
#if CONFIG_BT_NIMBLE_ENABLED
|
||||
/* ble_npl_eventq_init() needs to use npl functions in rom and
|
||||
* must be called after esp_bt_controller_init().
|
||||
*/
|
||||
ble_npl_eventq_init(nimble_port_get_dflt_eventq());
|
||||
#endif // CONFIG_BT_NIMBLE_ENABLED
|
||||
|
||||
/* Enable BT-related clocks */
|
||||
modem_clock_module_enable(PERIPH_BT_MODULE);
|
||||
modem_clock_module_mac_reset(PERIPH_BT_MODULE);
|
||||
/* Select slow clock source for BT momdule */
|
||||
#if CONFIG_BT_LE_LP_CLK_SRC_MAIN_XTAL
|
||||
esp_bt_rtc_slow_clk_select(MODEM_CLOCK_LPCLK_SRC_MAIN_XTAL);
|
||||
slow_clk_freq = 100000;
|
||||
#else
|
||||
#if CONFIG_RTC_CLK_SRC_INT_RC
|
||||
esp_bt_rtc_slow_clk_select(MODEM_CLOCK_LPCLK_SRC_RC_SLOW);
|
||||
slow_clk_freq = 30000;
|
||||
#elif CONFIG_RTC_CLK_SRC_EXT_CRYS
|
||||
if (rtc_clk_slow_src_get() == SOC_RTC_SLOW_CLK_SRC_XTAL32K) {
|
||||
esp_bt_rtc_slow_clk_select(MODEM_CLOCK_LPCLK_SRC_XTAL32K);
|
||||
slow_clk_freq = 32768;
|
||||
} else {
|
||||
ESP_LOGW(NIMBLE_PORT_LOG_TAG, "32.768kHz XTAL not detected, fall back to main XTAL as Bluetooth sleep clock");
|
||||
esp_bt_rtc_slow_clk_select(MODEM_CLOCK_LPCLK_SRC_MAIN_XTAL);
|
||||
slow_clk_freq = 100000;
|
||||
}
|
||||
#elif CONFIG_RTC_CLK_SRC_INT_RC32K
|
||||
esp_bt_rtc_slow_clk_select(MODEM_CLOCK_LPCLK_SRC_RC32K);
|
||||
slow_clk_freq = 32000;
|
||||
#elif CONFIG_RTC_CLK_SRC_EXT_OSC
|
||||
esp_bt_rtc_slow_clk_select(MODEM_CLOCK_LPCLK_SRC_EXT32K);
|
||||
slow_clk_freq = 32000;
|
||||
#else
|
||||
ESP_LOGE(NIMBLE_PORT_LOG_TAG, "Unsupported clock source");
|
||||
assert(0);
|
||||
#endif
|
||||
#endif /* CONFIG_BT_LE_LP_CLK_SRC_MAIN_XTAL */
|
||||
modem_clock_select_lp_clock_source(PERIPH_BT_MODULE, MODEM_CLOCK_LPCLK_SRC_MAIN_XTAL, 249);
|
||||
esp_phy_modem_init();
|
||||
esp_phy_enable();
|
||||
esp_btbb_enable();
|
||||
s_ble_active = true;
|
||||
|
||||
if (ble_osi_coex_funcs_register((struct osi_coex_funcs_t *)&s_osi_coex_funcs_ro) != 0) {
|
||||
ESP_LOGW(NIMBLE_PORT_LOG_TAG, "osi coex funcs reg failed");
|
||||
ret = ESP_ERR_INVALID_ARG;
|
||||
goto modem_deint;
|
||||
goto free_controller;
|
||||
}
|
||||
|
||||
#if CONFIG_SW_COEXIST_ENABLE
|
||||
@@ -783,38 +645,6 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg)
|
||||
ret = ble_controller_init(cfg);
|
||||
if (ret != ESP_OK) {
|
||||
ESP_LOGW(NIMBLE_PORT_LOG_TAG, "ble_controller_init failed %d", ret);
|
||||
goto modem_deint;
|
||||
}
|
||||
|
||||
ESP_LOGI(NIMBLE_PORT_LOG_TAG, "ble controller commit:[%s]", ble_controller_get_compile_version());
|
||||
#if CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
|
||||
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 controller_init_err;
|
||||
}
|
||||
#endif // CONFIG_BT_CONTROLLER_LOG_ENABLED
|
||||
|
||||
esp_ble_change_rtc_freq(slow_clk_freq);
|
||||
|
||||
ble_controller_scan_duplicate_config();
|
||||
|
||||
ret = os_msys_init();
|
||||
if (ret != ESP_OK) {
|
||||
ESP_LOGW(NIMBLE_PORT_LOG_TAG, "msys_init failed %d", ret);
|
||||
goto free_controller;
|
||||
}
|
||||
|
||||
@@ -823,6 +653,7 @@ 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));
|
||||
swap_in_place(mac, 6);
|
||||
esp_ble_ll_set_public_addr(mac);
|
||||
@@ -835,13 +666,9 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg)
|
||||
|
||||
free_controller:
|
||||
controller_sleep_deinit();
|
||||
#if CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
|
||||
controller_init_err:
|
||||
r_ble_log_deinit_async();
|
||||
#endif // CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
|
||||
os_msys_deinit();
|
||||
ble_controller_deinit();
|
||||
modem_deint:
|
||||
esp_btbb_disable();
|
||||
esp_phy_disable();
|
||||
esp_phy_modem_deinit();
|
||||
modem_clock_deselect_lp_clock_source(PERIPH_BT_MODULE);
|
||||
modem_clock_module_disable(PERIPH_BT_MODULE);
|
||||
@@ -849,6 +676,7 @@ modem_deint:
|
||||
ble_npl_eventq_deinit(nimble_port_get_dflt_eventq());
|
||||
#endif // CONFIG_BT_NIMBLE_ENABLED
|
||||
free_mem:
|
||||
os_msys_buf_free();
|
||||
npl_freertos_mempool_deinit();
|
||||
esp_unregister_npl_funcs();
|
||||
npl_freertos_funcs_deinit();
|
||||
@@ -866,15 +694,16 @@ esp_err_t esp_bt_controller_deinit(void)
|
||||
|
||||
controller_sleep_deinit();
|
||||
|
||||
os_msys_deinit();
|
||||
esp_btbb_disable();
|
||||
|
||||
if (s_ble_active) {
|
||||
esp_phy_disable();
|
||||
s_ble_active = false;
|
||||
}
|
||||
esp_phy_modem_deinit();
|
||||
modem_clock_deselect_lp_clock_source(PERIPH_BT_MODULE);
|
||||
modem_clock_module_disable(PERIPH_BT_MODULE);
|
||||
|
||||
#if CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
|
||||
r_ble_log_deinit_async();
|
||||
#endif // CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
|
||||
ble_controller_deinit();
|
||||
|
||||
#if CONFIG_BT_NIMBLE_ENABLED
|
||||
@@ -882,6 +711,8 @@ esp_err_t esp_bt_controller_deinit(void)
|
||||
ble_npl_eventq_deinit(nimble_port_get_dflt_eventq());
|
||||
#endif // CONFIG_BT_NIMBLE_ENABLED
|
||||
|
||||
os_msys_buf_free();
|
||||
|
||||
esp_unregister_npl_funcs();
|
||||
|
||||
esp_unregister_ext_funcs();
|
||||
@@ -908,14 +739,7 @@ esp_err_t esp_bt_controller_enable(esp_bt_mode_t mode)
|
||||
ESP_LOGW(NIMBLE_PORT_LOG_TAG, "invalid controller state");
|
||||
return ESP_FAIL;
|
||||
}
|
||||
if (!s_ble_active) {
|
||||
#if CONFIG_PM_ENABLE
|
||||
esp_pm_lock_acquire(s_pm_lock);
|
||||
#endif // CONFIG_PM_ENABLE
|
||||
esp_phy_enable(PHY_MODEM_BT);
|
||||
s_ble_active = true;
|
||||
}
|
||||
esp_btbb_enable();
|
||||
|
||||
#if CONFIG_SW_COEXIST_ENABLE
|
||||
coex_enable();
|
||||
#endif // CONFIG_SW_COEXIST_ENABLE
|
||||
@@ -931,14 +755,6 @@ error:
|
||||
#if CONFIG_SW_COEXIST_ENABLE
|
||||
coex_disable();
|
||||
#endif
|
||||
esp_btbb_disable();
|
||||
if (s_ble_active) {
|
||||
esp_phy_disable(PHY_MODEM_BT);
|
||||
#if CONFIG_PM_ENABLE
|
||||
esp_pm_lock_release(s_pm_lock);
|
||||
#endif // CONFIG_PM_ENABLE
|
||||
s_ble_active = false;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -954,14 +770,6 @@ esp_err_t esp_bt_controller_disable(void)
|
||||
#if CONFIG_SW_COEXIST_ENABLE
|
||||
coex_disable();
|
||||
#endif
|
||||
esp_btbb_disable();
|
||||
if (s_ble_active) {
|
||||
esp_phy_disable(PHY_MODEM_BT);
|
||||
#if CONFIG_PM_ENABLE
|
||||
esp_pm_lock_release(s_pm_lock);
|
||||
#endif // CONFIG_PM_ENABLE
|
||||
s_ble_active = false;
|
||||
}
|
||||
ble_controller_status = ESP_BT_CONTROLLER_STATUS_INITED;
|
||||
return ESP_OK;
|
||||
}
|
||||
@@ -1175,33 +983,10 @@ esp_power_level_t esp_ble_tx_power_get_enhanced(esp_ble_enhanced_power_type_t po
|
||||
return (esp_power_level_t)tx_level;
|
||||
}
|
||||
|
||||
#if CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
|
||||
static void esp_bt_controller_log_interface(uint32_t len, const uint8_t *addr, bool end)
|
||||
{
|
||||
for (int i = 0; i < len; i++) {
|
||||
esp_rom_printf("%02x ", addr[i]);
|
||||
}
|
||||
if (end) {
|
||||
esp_rom_printf("\n");
|
||||
}
|
||||
}
|
||||
|
||||
void esp_ble_controller_log_dump_all(bool output)
|
||||
{
|
||||
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
|
||||
|
||||
#if (!CONFIG_BT_NIMBLE_ENABLED) && (CONFIG_BT_CONTROLLER_ENABLED)
|
||||
#if CONFIG_BT_LE_SM_LEGACY || CONFIG_BT_LE_SM_SC
|
||||
#if (!CONFIG_BT_NIMBLE_ENABLED) && (CONFIG_BT_CONTROLLER_ENABLED == true)
|
||||
#define BLE_SM_KEY_ERR 0x17
|
||||
|
||||
#if CONFIG_BT_LE_CRYPTO_STACK_MBEDTLS
|
||||
#include "mbedtls/aes.h"
|
||||
#if CONFIG_BT_LE_SM_SC
|
||||
@@ -1211,27 +996,22 @@ void esp_ble_controller_log_dump_all(bool output)
|
||||
#include "mbedtls/cmac.h"
|
||||
#include "mbedtls/ecdh.h"
|
||||
#include "mbedtls/ecp.h"
|
||||
|
||||
static mbedtls_ecp_keypair keypair;
|
||||
#endif // CONFIG_BT_LE_SM_SC
|
||||
|
||||
#else
|
||||
#include "tinycrypt/aes.h"
|
||||
#include "tinycrypt/constants.h"
|
||||
#include "tinycrypt/utils.h"
|
||||
|
||||
#if CONFIG_BT_LE_SM_SC
|
||||
#include "tinycrypt/cmac_mode.h"
|
||||
#include "tinycrypt/ecc_dh.h"
|
||||
#endif // CONFIG_BT_LE_SM_SC
|
||||
#endif // CONFIG_BT_LE_CRYPTO_STACK_MBEDTLS
|
||||
|
||||
/* Based on Core Specification 4.2 Vol 3. Part H 2.3.5.6.1 */
|
||||
static const uint8_t ble_sm_alg_dbg_priv_key[32] = {
|
||||
0x3f, 0x49, 0xf6, 0xd4, 0xa3, 0xc5, 0x5f, 0x38, 0x74, 0xc9, 0xb3, 0xe3,
|
||||
0xd2, 0x10, 0x3f, 0x50, 0x4a, 0xff, 0x60, 0x7b, 0xeb, 0x40, 0xb7, 0x99,
|
||||
0x58, 0x99, 0xb8, 0xa6, 0xcd, 0x3c, 0x1a, 0xbd
|
||||
};
|
||||
#if CONFIG_BT_LE_CRYPTO_STACK_MBEDTLS
|
||||
#if CONFIG_BT_LE_SM_SC
|
||||
static mbedtls_ecp_keypair keypair;
|
||||
#endif // CONFIG_BT_LE_SM_SC
|
||||
#endif// CONFIG_BT_LE_CRYPTO_STACK_MBEDTLS
|
||||
|
||||
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)
|
||||
@@ -1278,7 +1058,8 @@ int ble_sm_alg_gen_dhkey(const uint8_t *peer_pub_key_x, const uint8_t *peer_pub_
|
||||
}
|
||||
|
||||
/* Set PRNG */
|
||||
if ((rc = mbedtls_ctr_drbg_seed(&ctr_drbg, mbedtls_entropy_func, &entropy, NULL, 0)) != 0) {
|
||||
if ((rc = mbedtls_ctr_drbg_seed(&ctr_drbg, mbedtls_entropy_func, &entropy,
|
||||
NULL, 0)) != 0) {
|
||||
goto exit;
|
||||
}
|
||||
|
||||
@@ -1328,10 +1109,19 @@ exit:
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* based on Core Specification 4.2 Vol 3. Part H 2.3.5.6.1 */
|
||||
static const uint8_t ble_sm_alg_dbg_priv_key[32] = {
|
||||
0x3f, 0x49, 0xf6, 0xd4, 0xa3, 0xc5, 0x5f, 0x38, 0x74, 0xc9, 0xb3, 0xe3,
|
||||
0xd2, 0x10, 0x3f, 0x50, 0x4a, 0xff, 0x60, 0x7b, 0xeb, 0x40, 0xb7, 0x99,
|
||||
0x58, 0x99, 0xb8, 0xa6, 0xcd, 0x3c, 0x1a, 0xbd
|
||||
};
|
||||
|
||||
#if CONFIG_BT_LE_CRYPTO_STACK_MBEDTLS
|
||||
static int mbedtls_gen_keypair(uint8_t *public_key, uint8_t *private_key)
|
||||
{
|
||||
int rc = BLE_SM_KEY_ERR;
|
||||
size_t olen = 0;
|
||||
uint8_t pub[65] = {0};
|
||||
mbedtls_entropy_context entropy = {0};
|
||||
mbedtls_ctr_drbg_context ctr_drbg = {0};
|
||||
|
||||
@@ -1353,11 +1143,11 @@ static int mbedtls_gen_keypair(uint8_t *public_key, uint8_t *private_key)
|
||||
goto exit;
|
||||
}
|
||||
|
||||
size_t olen = 0;
|
||||
uint8_t pub[65] = {0};
|
||||
|
||||
if ((rc = mbedtls_ecp_point_write_binary(&keypair.MBEDTLS_PRIVATE(grp), &keypair.MBEDTLS_PRIVATE(Q), MBEDTLS_ECP_PF_UNCOMPRESSED,
|
||||
&olen, pub, 65)) != 0) {
|
||||
if ((rc = mbedtls_ecp_point_write_binary(&keypair.MBEDTLS_PRIVATE(grp),
|
||||
&keypair.MBEDTLS_PRIVATE(Q),
|
||||
MBEDTLS_ECP_PF_UNCOMPRESSED,
|
||||
&olen, pub, 65)) != 0) {
|
||||
goto exit;
|
||||
}
|
||||
|
||||
@@ -1373,7 +1163,7 @@ exit:
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif // CONFIG_BT_LE_CRYPTO_STACK_MBEDTLS
|
||||
#endif // CONFIG_BT_LE_CRYPTO_STACK_MBEDTLS
|
||||
|
||||
/**
|
||||
* pub: 64 bytes
|
||||
@@ -1397,7 +1187,7 @@ int ble_sm_alg_gen_key_pair(uint8_t *pub, uint8_t *priv)
|
||||
if (uECC_make_key(pk, priv, &curve_secp256r1) != TC_CRYPTO_SUCCESS) {
|
||||
return BLE_SM_KEY_ERR;
|
||||
}
|
||||
#endif // CONFIG_BT_LE_CRYPTO_STACK_MBEDTLS
|
||||
#endif // CONFIG_BT_LE_CRYPTO_STACK_MBEDTLS
|
||||
/* Make sure generated key isn't debug key. */
|
||||
} while (memcmp(priv, ble_sm_alg_dbg_priv_key, 32) == 0);
|
||||
|
||||
@@ -1405,8 +1195,7 @@ int ble_sm_alg_gen_key_pair(uint8_t *pub, uint8_t *priv)
|
||||
swap_buf(&pub[32], &pk[32], 32);
|
||||
swap_in_place(priv, 32);
|
||||
#endif // CONFIG_BT_LE_SM_SC_DEBUG_KEYS
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif // CONFIG_BT_LE_SM_LEGACY || CONFIG_BT_LE_SM_SC
|
||||
#endif // (!CONFIG_BT_NIMBLE_ENABLED) && (CONFIG_BT_CONTROLLER_ENABLED)
|
||||
#endif // (!CONFIG_BT_NIMBLE_ENABLED) && (CONFIG_BT_CONTROLLER_ENABLED == true)
|
||||
|
||||
@@ -260,54 +260,6 @@ config BT_LE_CONTROLLER_TASK_STACK_SIZE
|
||||
help
|
||||
This configures stack size of NimBLE controller task
|
||||
|
||||
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
|
||||
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
|
||||
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
|
||||
Only operate in dump mode
|
||||
|
||||
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
|
||||
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
|
||||
Configure the size of the BLE HCI LOG buffer.
|
||||
|
||||
config BT_LE_LL_RESOLV_LIST_SIZE
|
||||
int "BLE LL Resolving list size"
|
||||
range 1 5
|
||||
@@ -373,7 +325,7 @@ config BT_LE_WHITELIST_SIZE
|
||||
|
||||
config BT_LE_LL_DUP_SCAN_LIST_COUNT
|
||||
int "BLE duplicate scan list count"
|
||||
range 5 100
|
||||
range 1 100
|
||||
default 20
|
||||
help
|
||||
config the max count of duplicate scan list
|
||||
@@ -388,7 +340,7 @@ config BT_LE_LL_SCA
|
||||
config BT_LE_MAX_CONNECTIONS
|
||||
int "Maximum number of concurrent connections"
|
||||
depends on !BT_NIMBLE_ENABLED
|
||||
range 1 35
|
||||
range 1 9
|
||||
default 3
|
||||
help
|
||||
Defines maximum number of concurrent BLE connections. For ESP32, user
|
||||
@@ -400,7 +352,7 @@ config BT_LE_MAX_CONNECTIONS
|
||||
choice BT_LE_COEX_PHY_CODED_TX_RX_TLIM
|
||||
prompt "Coexistence: limit on MAX Tx/Rx time for coded-PHY connection"
|
||||
default BT_LE_COEX_PHY_CODED_TX_RX_TLIM_DIS
|
||||
depends on ESP_COEX_SW_COEXIST_ENABLE
|
||||
depends on !BT_NIMBLE_ENABLED
|
||||
help
|
||||
When using PHY-Coded in BLE connection, limitation on max tx/rx time can be applied to
|
||||
better avoid dramatic performance deterioration of Wi-Fi.
|
||||
@@ -418,7 +370,7 @@ endchoice
|
||||
|
||||
config BT_LE_COEX_PHY_CODED_TX_RX_TLIM_EFF
|
||||
int
|
||||
default 0 if !ESP_COEX_SW_COEXIST_ENABLE
|
||||
depends on !BT_NIMBLE_ENABLED
|
||||
default 1 if BT_LE_COEX_PHY_CODED_TX_RX_TLIM_EN
|
||||
default 0 if BT_LE_COEX_PHY_CODED_TX_RX_TLIM_DIS
|
||||
|
||||
@@ -428,24 +380,19 @@ config BT_LE_SLEEP_ENABLE
|
||||
help
|
||||
Enable BLE sleep
|
||||
|
||||
choice BT_LE_LP_CLK_SRC
|
||||
prompt "BLE low power clock source"
|
||||
default BT_LE_LP_CLK_SRC_MAIN_XTAL
|
||||
config BT_LE_LP_CLK_SRC_MAIN_XTAL
|
||||
bool "Use main XTAL as RTC clock source"
|
||||
choice BT_LE_WAKEUP_SOURCE
|
||||
prompt "BLE light sleep wakeup source"
|
||||
depends on BT_LE_SLEEP_ENABLE
|
||||
default BT_LE_WAKEUP_SOURCE_BLE_RTC_TIMER
|
||||
config BT_LE_WAKEUP_SOURCE_CPU_RTC_TIMER
|
||||
bool "Use ESP timer to wakeup CPU"
|
||||
help
|
||||
User main XTAL as RTC clock source.
|
||||
This option is recommended if external 32.768k XTAL is not available.
|
||||
Using the external 32.768 kHz XTAL will have lower current consumption
|
||||
in light sleep compared to using the main XTAL.
|
||||
Use esp timer to wakeup CPU
|
||||
|
||||
config BT_LE_LP_CLK_SRC_DEFAULT
|
||||
bool "Use system RTC slow clock source"
|
||||
config BT_LE_WAKEUP_SOURCE_BLE_RTC_TIMER
|
||||
bool "Use BLE rtc timer to wakeup CPU"
|
||||
help
|
||||
Use the same slow clock source as system RTC
|
||||
Using any clock source other than external 32.768 kHz XTAL supports only
|
||||
legacy ADV and SCAN due to low clock accuracy.
|
||||
|
||||
Use BLE rtc timer to wakeup CPU
|
||||
endchoice
|
||||
|
||||
config BT_LE_USE_ESP_TIMER
|
||||
@@ -455,102 +402,3 @@ 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
|
||||
help
|
||||
The function is mainly used to enable flow control for advertising reports. When it is enabled,
|
||||
advertising reports will be discarded by the controller if the number of unprocessed advertising
|
||||
reports exceeds the size of BLE adv report flow control.
|
||||
|
||||
config BT_CTRL_BLE_ADV_REPORT_FLOW_CTRL_NUM
|
||||
int "BLE adv report flow control number"
|
||||
depends on BT_CTRL_BLE_ADV_REPORT_FLOW_CTRL_SUPP
|
||||
range 50 1000
|
||||
default 100
|
||||
help
|
||||
The number of unprocessed advertising report that bluetooth host can save.If you set
|
||||
`BT_CTRL_BLE_ADV_REPORT_FLOW_CTRL_NUM` to a small value, this may cause adv packets lost.
|
||||
If you set `BT_CTRL_BLE_ADV_REPORT_FLOW_CTRL_NUM` to a large value, bluetooth host may cache a
|
||||
lot of adv packets and this may cause system memory run out. For example, if you set
|
||||
it to 50, the maximum memory consumed by host is 35 * 50 bytes. Please set
|
||||
`BT_CTRL_BLE_ADV_REPORT_FLOW_CTRL_NUM` according to your system free memory and handle adv
|
||||
packets as fast as possible, otherwise it will cause adv packets lost.
|
||||
|
||||
config BT_CTRL_BLE_ADV_REPORT_DISCARD_THRSHOLD
|
||||
int "BLE adv lost event threshold value"
|
||||
depends on BT_CTRL_BLE_ADV_REPORT_FLOW_CTRL_SUPP
|
||||
range 1 1000
|
||||
default 20
|
||||
help
|
||||
When adv report flow control is enabled, The ADV lost event will be generated when the number
|
||||
of ADV packets lost in the controller reaches this threshold. It is better to set a larger value.
|
||||
If you set `BT_CTRL_BLE_ADV_REPORT_DISCARD_THRSHOLD` to a small value or printf every adv lost event, it
|
||||
may cause adv packets lost more.
|
||||
|
||||
config BT_LE_SCAN_DUPL
|
||||
bool "BLE Scan Duplicate Options"
|
||||
default y
|
||||
help
|
||||
This select enables parameters setting of BLE scan duplicate.
|
||||
|
||||
choice BT_LE_SCAN_DUPL_TYPE
|
||||
prompt "Scan Duplicate Type"
|
||||
default BT_LE_SCAN_DUPL_TYPE_DEVICE
|
||||
depends on BT_LE_SCAN_DUPL
|
||||
help
|
||||
Scan duplicate have three ways. one is "Scan Duplicate By Device Address", This way is to use
|
||||
advertiser address filtering. The adv packet of the same address is only allowed to be reported once.
|
||||
Another way is "Scan Duplicate By Device Address And Advertising Data". This way is to use advertising
|
||||
data and device address filtering. All different adv packets with the same address are allowed to be
|
||||
reported. The last way is "Scan Duplicate By Advertising Data". This way is to use advertising data
|
||||
filtering. All same advertising data only allow to be reported once even though they are from
|
||||
different devices.
|
||||
|
||||
config BT_LE_SCAN_DUPL_TYPE_DEVICE
|
||||
bool "Scan Duplicate By Device Address"
|
||||
help
|
||||
This way is to use advertiser address filtering. The adv packet of the same address is only
|
||||
allowed to be reported once
|
||||
|
||||
config BT_LE_SCAN_DUPL_TYPE_DATA
|
||||
bool "Scan Duplicate By Advertising Data"
|
||||
help
|
||||
This way is to use advertising data filtering. All same advertising data only allow to be reported
|
||||
once even though they are from different devices.
|
||||
|
||||
config BT_LE_SCAN_DUPL_TYPE_DATA_DEVICE
|
||||
bool "Scan Duplicate By Device Address And Advertising Data"
|
||||
help
|
||||
This way is to use advertising data and device address filtering. All different adv packets with
|
||||
the same address are allowed to be reported.
|
||||
endchoice
|
||||
|
||||
config BT_LE_SCAN_DUPL_TYPE
|
||||
int
|
||||
depends on BT_LE_SCAN_DUPL
|
||||
default 0 if BT_LE_SCAN_DUPL_TYPE_DEVICE
|
||||
default 1 if BT_LE_SCAN_DUPL_TYPE_DATA
|
||||
default 2 if BT_LE_SCAN_DUPL_TYPE_DATA_DEVICE
|
||||
default 0
|
||||
|
||||
config BT_LE_SCAN_DUPL_CACHE_REFRESH_PERIOD
|
||||
int "Duplicate scan list refresh period (seconds)"
|
||||
depends on BT_LE_SCAN_DUPL
|
||||
range 0 1000
|
||||
default 0
|
||||
help
|
||||
If the period value is non-zero, the controller will periodically clear the device information
|
||||
stored in the scan duuplicate filter. If it is 0, the scan duuplicate filter will not be cleared
|
||||
until the scanning is disabled. Duplicate advertisements for this period should not be sent to the
|
||||
Host in advertising report events.
|
||||
There are two scenarios where the ADV packet will be repeatedly reported:
|
||||
1. The duplicate scan cache is full, the controller will delete the oldest device information and
|
||||
add new device information.
|
||||
2. When the refresh period is up, the controller will clear all device information and start filtering
|
||||
again.
|
||||
|
||||
config BT_LE_MSYS_INIT_IN_CONTROLLER
|
||||
bool
|
||||
default y
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
#endif // ESP_PLATFORM
|
||||
|
||||
#if CONFIG_SW_COEXIST_ENABLE
|
||||
#include "private/esp_coexist_internal.h"
|
||||
#include "esp_coexist_internal.h"
|
||||
#endif // CONFIG_SW_COEXIST_ENABLE
|
||||
|
||||
#include "nimble/nimble_npl_os.h"
|
||||
@@ -40,11 +40,6 @@
|
||||
#include "hci_uart.h"
|
||||
#include "bt_osi_mem.h"
|
||||
|
||||
#if CONFIG_FREERTOS_USE_TICKLESS_IDLE
|
||||
#include "esp_private/sleep_modem.h"
|
||||
#include "esp_private/sleep_retention.h"
|
||||
#endif // CONFIG_FREERTOS_USE_TICKLESS_IDLE
|
||||
|
||||
#ifdef CONFIG_BT_BLUEDROID_ENABLED
|
||||
#include "hci/hci_hal.h"
|
||||
#endif // CONFIG_BT_BLUEDROID_ENABLED
|
||||
@@ -54,7 +49,7 @@
|
||||
|
||||
#include "esp_private/periph_ctrl.h"
|
||||
#include "esp_sleep.h"
|
||||
#include "soc/rtc.h"
|
||||
|
||||
/* Macro definition
|
||||
************************************************************************
|
||||
*/
|
||||
@@ -72,6 +67,7 @@
|
||||
#define ACL_DATA_MBUF_LEADINGSPCAE 4
|
||||
#endif // CONFIG_BT_BLUEDROID_ENABLED
|
||||
|
||||
|
||||
/* Types definition
|
||||
************************************************************************
|
||||
*/
|
||||
@@ -108,21 +104,12 @@ struct ext_funcs_t {
|
||||
uint32_t magic;
|
||||
};
|
||||
|
||||
#if CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
|
||||
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 ble_controller_init(esp_bt_controller_config_t *cfg);
|
||||
#if CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
|
||||
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_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);
|
||||
extern int ble_controller_disable(void);
|
||||
@@ -132,18 +119,14 @@ extern int esp_ble_ll_set_public_addr(const uint8_t *addr);
|
||||
extern int esp_register_npl_funcs (struct npl_funcs_t *p_npl_func);
|
||||
extern void esp_unregister_npl_funcs (void);
|
||||
extern void npl_freertos_mempool_deinit(void);
|
||||
extern int os_msys_buf_alloc(void);
|
||||
extern uint32_t r_os_cputime_get32(void);
|
||||
extern uint32_t r_os_cputime_ticks_to_usecs(uint32_t ticks);
|
||||
#if CONFIG_FREERTOS_USE_TICKLESS_IDLE
|
||||
extern const sleep_retention_entries_config_t *esp_ble_mac_retention_link_get(uint8_t *size, uint8_t extra);
|
||||
extern void esp_ble_set_wakeup_overhead(uint32_t overhead);
|
||||
#endif /* CONFIG_FREERTOS_USE_TICKLESS_IDLE */
|
||||
extern void esp_ble_change_rtc_freq(uint32_t freq);
|
||||
extern void r_ble_lll_rfmgmt_set_sleep_cb(void *s_cb, void *w_cb, void *s_arg,
|
||||
void *w_arg, uint32_t us_to_enabled);
|
||||
extern void r_ble_rtc_wake_up_state_clr(void);
|
||||
extern void ble_lll_rfmgmt_set_sleep_cb(void *s_cb, void *w_cb, void *s_arg,
|
||||
void *w_arg, uint32_t us_to_enabled);
|
||||
extern void ble_rtc_wake_up_state_clr(void);
|
||||
extern int os_msys_init(void);
|
||||
extern void os_msys_deinit(void);
|
||||
extern void os_msys_buf_free(void);
|
||||
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);
|
||||
@@ -151,7 +134,6 @@ extern int ble_sm_alg_gen_key_pair(uint8_t *pub, uint8_t *priv);
|
||||
extern int ble_txpwr_set(esp_ble_enhanced_power_type_t power_type, uint16_t handle, int power_level);
|
||||
extern int ble_txpwr_get(esp_ble_enhanced_power_type_t power_type, uint16_t handle);
|
||||
extern int ble_get_npl_element_info(esp_bt_controller_config_t *cfg, ble_npl_count_info_t * npl_info);
|
||||
extern char *ble_controller_get_compile_version(void);
|
||||
extern uint32_t _bt_bss_start;
|
||||
extern uint32_t _bt_bss_end;
|
||||
extern uint32_t _bt_controller_bss_start;
|
||||
@@ -185,22 +167,13 @@ 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
|
||||
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};
|
||||
#endif // CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
|
||||
|
||||
/* This variable tells if BLE is running */
|
||||
static bool s_ble_active = false;
|
||||
#ifdef CONFIG_PM_ENABLE
|
||||
@@ -208,8 +181,15 @@ static DRAM_ATTR esp_pm_lock_handle_t s_pm_lock = NULL;
|
||||
#define BTDM_MIN_TIMER_UNCERTAINTY_US (200)
|
||||
#endif // CONFIG_PM_ENABLE
|
||||
|
||||
#define BLE_RTC_DELAY_US_LIGHT_SLEEP (5100)
|
||||
#define BLE_RTC_DELAY_US_MODEM_SLEEP (1500)
|
||||
#ifdef CONFIG_BT_LE_WAKEUP_SOURCE_BLE_RTC_TIMER
|
||||
#define BLE_RTC_DELAY_US (1100)
|
||||
#endif // CONFIG_BT_LE_WAKEUP_SOURCE_BLE_RTC_TIMER
|
||||
|
||||
#ifdef CONFIG_BT_LE_WAKEUP_SOURCE_CPU_RTC_TIMER
|
||||
#define BLE_RTC_DELAY_US (0)
|
||||
static void ble_sleep_timer_callback(void *arg);
|
||||
static DRAM_ATTR esp_timer_handle_t s_ble_sleep_timer = NULL;
|
||||
#endif // CONFIG_BT_LE_WAKEUP_SOURCE_CPU_RTC_TIMER
|
||||
|
||||
static const struct osi_coex_funcs_t s_osi_coex_funcs_ro = {
|
||||
._magic = OSI_COEX_MAGIC_VALUE,
|
||||
@@ -238,8 +218,8 @@ struct ext_funcs_t ext_funcs_ro = {
|
||||
._task_delete = task_delete_wrapper,
|
||||
._osi_assert = osi_assert_wrapper,
|
||||
._os_random = osi_random_wrapper,
|
||||
._ecc_gen_key_pair = esp_ecc_gen_key_pair,
|
||||
._ecc_gen_dh_key = esp_ecc_gen_dh_key,
|
||||
._ecc_gen_key_pair = ble_sm_alg_gen_key_pair,
|
||||
._ecc_gen_dh_key = ble_sm_alg_gen_dhkey,
|
||||
._esp_reset_rpa_moudle = esp_reset_rpa_moudle,
|
||||
.magic = EXT_FUNC_MAGIC_VALUE,
|
||||
};
|
||||
@@ -253,9 +233,6 @@ static void IRAM_ATTR osi_assert_wrapper(const uint32_t ln, const char *fn,
|
||||
uint32_t param1, uint32_t param2)
|
||||
{
|
||||
BT_ASSERT_PRINT("BLE assert: line %d in function %s, param: 0x%x, 0x%x", ln, fn, param1, param2);
|
||||
#if CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
|
||||
esp_ble_controller_log_dump_all(true);
|
||||
#endif // CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
|
||||
assert(0);
|
||||
}
|
||||
|
||||
@@ -322,7 +299,6 @@ void esp_vhci_host_send_packet(uint8_t *data, uint16_t len)
|
||||
if (*(data) == DATA_TYPE_COMMAND) {
|
||||
struct ble_hci_cmd *cmd = NULL;
|
||||
cmd = (struct ble_hci_cmd *) ble_hci_trans_buf_alloc(BLE_HCI_TRANS_BUF_CMD);
|
||||
assert(cmd);
|
||||
memcpy((uint8_t *)cmd, data + 1, len - 1);
|
||||
ble_hci_trans_hs_cmd_tx((uint8_t *)cmd);
|
||||
}
|
||||
@@ -359,25 +335,6 @@ static void task_delete_wrapper(void *task_handle)
|
||||
vTaskDelete(task_handle);
|
||||
}
|
||||
|
||||
static int esp_ecc_gen_key_pair(uint8_t *pub, uint8_t *priv)
|
||||
{
|
||||
int rc = -1;
|
||||
#if CONFIG_BT_LE_SM_LEGACY || CONFIG_BT_LE_SM_SC
|
||||
rc = ble_sm_alg_gen_key_pair(pub, priv);
|
||||
#endif // CONFIG_BT_LE_SM_LEGACY || CONFIG_BT_LE_SM_SC
|
||||
return rc;
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
int rc = -1;
|
||||
#if CONFIG_BT_LE_SM_LEGACY || CONFIG_BT_LE_SM_SC
|
||||
rc = ble_sm_alg_gen_dhkey(peer_pub_key_x, peer_pub_key_y, our_priv_key, out_dhkey);
|
||||
#endif // CONFIG_BT_LE_SM_LEGACY || CONFIG_BT_LE_SM_SC
|
||||
return rc;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_BT_LE_HCI_INTERFACE_USE_UART
|
||||
static void hci_uart_start_tx_wrapper(int uart_no)
|
||||
{
|
||||
@@ -444,46 +401,47 @@ static int esp_intr_free_wrapper(void **ret_handle)
|
||||
return rc;
|
||||
}
|
||||
|
||||
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:
|
||||
ESP_LOGI(NIMBLE_PORT_LOG_TAG, "Using main XTAL as clock source");
|
||||
modem_clock_select_lp_clock_source(PERIPH_BT_MODULE, slow_clk_src, (320 - 1));
|
||||
break;
|
||||
case MODEM_CLOCK_LPCLK_SRC_RC_SLOW:
|
||||
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:
|
||||
ESP_LOGI(NIMBLE_PORT_LOG_TAG, "Using external 32.768 kHz XTAL as clock source");
|
||||
modem_clock_select_lp_clock_source(PERIPH_BT_MODULE, slow_clk_src, (1 - 1));
|
||||
break;
|
||||
case MODEM_CLOCK_LPCLK_SRC_RC32K:
|
||||
ESP_LOGI(NIMBLE_PORT_LOG_TAG, "Using 32 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, (1 - 1));
|
||||
break;
|
||||
case MODEM_CLOCK_LPCLK_SRC_EXT32K:
|
||||
ESP_LOGI(NIMBLE_PORT_LOG_TAG, "Using 32 kHz oscillator 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, (1 - 1));
|
||||
break;
|
||||
default:
|
||||
}
|
||||
}
|
||||
|
||||
IRAM_ATTR void controller_sleep_cb(uint32_t enable_tick, void *arg)
|
||||
{
|
||||
if (!s_ble_active) {
|
||||
return;
|
||||
}
|
||||
#if CONFIG_FREERTOS_USE_TICKLESS_IDLE
|
||||
r_ble_rtc_wake_up_state_clr();
|
||||
#endif /* CONFIG_FREERTOS_USE_TICKLESS_IDLE */
|
||||
esp_phy_disable(PHY_MODEM_BT);
|
||||
|
||||
#ifdef CONFIG_PM_ENABLE
|
||||
#ifdef CONFIG_BT_LE_WAKEUP_SOURCE_CPU_RTC_TIMER
|
||||
uint32_t delta_tick;
|
||||
uint32_t us_to_sleep;
|
||||
uint32_t sleep_tick;
|
||||
uint32_t tick_invalid = *(uint32_t*)(arg);
|
||||
assert(arg != NULL);
|
||||
if (!tick_invalid) {
|
||||
sleep_tick = r_os_cputime_get32();
|
||||
/* start a timer to wake up and acquire the pm_lock before modem_sleep awakes */
|
||||
delta_tick = enable_tick - sleep_tick;
|
||||
if (delta_tick & 0x80000000) {
|
||||
return;
|
||||
}
|
||||
us_to_sleep = r_os_cputime_ticks_to_usecs(delta_tick);
|
||||
if (us_to_sleep <= BTDM_MIN_TIMER_UNCERTAINTY_US) {
|
||||
return;
|
||||
}
|
||||
esp_err_t err = esp_timer_start_once(s_ble_sleep_timer,
|
||||
us_to_sleep - BTDM_MIN_TIMER_UNCERTAINTY_US);
|
||||
if (err != ESP_OK) {
|
||||
ESP_LOGW(NIMBLE_PORT_LOG_TAG, "ESP timer start failed\n");
|
||||
return;
|
||||
}
|
||||
}
|
||||
#endif // CONFIG_BT_LE_WAKEUP_SOURCE_CPU_RTC_TIMER
|
||||
|
||||
#ifdef CONFIG_BT_LE_WAKEUP_SOURCE_BLE_RTC_TIMER
|
||||
r_ble_rtc_wake_up_state_clr();
|
||||
#endif // CONFIG_BT_LE_WAKEUP_SOURCE_BLE_RTC_TIMER
|
||||
|
||||
esp_pm_lock_release(s_pm_lock);
|
||||
#endif // CONFIG_PM_ENABLE
|
||||
|
||||
esp_phy_disable();
|
||||
s_ble_active = false;
|
||||
}
|
||||
|
||||
@@ -492,50 +450,37 @@ IRAM_ATTR void controller_wakeup_cb(void *arg)
|
||||
if (s_ble_active) {
|
||||
return;
|
||||
}
|
||||
esp_phy_enable();
|
||||
|
||||
#ifdef CONFIG_PM_ENABLE
|
||||
esp_pm_lock_acquire(s_pm_lock);
|
||||
r_ble_rtc_wake_up_state_clr();
|
||||
#endif //CONFIG_PM_ENABLE
|
||||
esp_phy_enable(PHY_MODEM_BT);
|
||||
|
||||
s_ble_active = true;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_FREERTOS_USE_TICKLESS_IDLE
|
||||
static esp_err_t sleep_modem_ble_mac_modem_state_init(uint8_t extra)
|
||||
#ifdef CONFIG_PM_ENABLE
|
||||
#ifdef CONFIG_BT_LE_WAKEUP_SOURCE_CPU_RTC_TIMER
|
||||
static void ble_sleep_timer_callback(void * arg)
|
||||
{
|
||||
uint8_t size;
|
||||
const sleep_retention_entries_config_t *ble_mac_modem_config = esp_ble_mac_retention_link_get(&size, extra);
|
||||
esp_err_t err = sleep_retention_entries_create(ble_mac_modem_config, size, REGDMA_LINK_PRI_5, SLEEP_RETENTION_MODULE_BLE_MAC);
|
||||
if (err == ESP_OK) {
|
||||
ESP_LOGI(NIMBLE_PORT_LOG_TAG, "Modem BLE MAC retention initialization");
|
||||
}
|
||||
return err;
|
||||
|
||||
}
|
||||
|
||||
static void sleep_modem_ble_mac_modem_state_deinit(void)
|
||||
{
|
||||
sleep_retention_entries_destroy(SLEEP_RETENTION_MODULE_BLE_MAC);
|
||||
}
|
||||
|
||||
void sleep_modem_light_sleep_overhead_set(uint32_t overhead)
|
||||
{
|
||||
esp_ble_set_wakeup_overhead(overhead);
|
||||
}
|
||||
#endif // CONFIG_FREERTOS_USE_TICKLESS_IDLE
|
||||
#endif // CONFIG_BT_LE_WAKEUP_SOURCE_CPU_RTC_TIMER
|
||||
#endif // CONFIG_PM_ENABLE
|
||||
|
||||
esp_err_t controller_sleep_init(void)
|
||||
{
|
||||
esp_err_t rc = 0;
|
||||
|
||||
#ifdef CONFIG_BT_LE_SLEEP_ENABLE
|
||||
ESP_LOGW(NIMBLE_PORT_LOG_TAG, "BLE modem sleep is enabled");
|
||||
#if CONFIG_FREERTOS_USE_TICKLESS_IDLE
|
||||
r_ble_lll_rfmgmt_set_sleep_cb(controller_sleep_cb, controller_wakeup_cb, 0, 0,
|
||||
BLE_RTC_DELAY_US_LIGHT_SLEEP);
|
||||
#else
|
||||
r_ble_lll_rfmgmt_set_sleep_cb(controller_sleep_cb, controller_wakeup_cb, 0, 0,
|
||||
BLE_RTC_DELAY_US_MODEM_SLEEP);
|
||||
#endif /* FREERTOS_USE_TICKLESS_IDLE */
|
||||
ESP_LOGW(NIMBLE_PORT_LOG_TAG, "BLE modem sleep is enabled\n");
|
||||
ble_lll_rfmgmt_set_sleep_cb(controller_sleep_cb, controller_wakeup_cb, 0, 0,
|
||||
500 + BLE_RTC_DELAY_US);
|
||||
|
||||
#ifdef CONFIG_PM_ENABLE
|
||||
esp_sleep_pd_config(ESP_PD_DOMAIN_XTAL, ESP_PD_OPTION_ON);
|
||||
#endif // CONFIG_PM_ENABLE
|
||||
#endif // CONFIG_BT_LE_SLEEP_ENABLE
|
||||
|
||||
#ifdef CONFIG_PM_ENABLE
|
||||
@@ -543,120 +488,104 @@ esp_err_t controller_sleep_init(void)
|
||||
if (rc != ESP_OK) {
|
||||
goto error;
|
||||
}
|
||||
#if CONFIG_FREERTOS_USE_TICKLESS_IDLE
|
||||
/* Create a new regdma link for BLE related register restoration */
|
||||
rc = sleep_modem_ble_mac_modem_state_init(0);
|
||||
assert(rc == 0);
|
||||
esp_sleep_enable_bt_wakeup();
|
||||
ESP_LOGW(NIMBLE_PORT_LOG_TAG, "Enable light sleep, the wake up source is BLE timer");
|
||||
esp_pm_lock_acquire(s_pm_lock);
|
||||
|
||||
rc = esp_pm_register_inform_out_light_sleep_overhead_callback(sleep_modem_light_sleep_overhead_set);
|
||||
#ifdef CONFIG_BT_LE_WAKEUP_SOURCE_CPU_RTC_TIMER
|
||||
esp_timer_create_args_t create_args = {
|
||||
.callback = ble_sleep_timer_callback,
|
||||
.arg = NULL,
|
||||
.name = "btSlp"
|
||||
};
|
||||
rc = esp_timer_create(&create_args, &s_ble_sleep_timer);
|
||||
if (rc != ESP_OK) {
|
||||
goto error;
|
||||
}
|
||||
#endif /* CONFIG_FREERTOS_USE_TICKLESS_IDLE */
|
||||
ESP_LOGW(NIMBLE_PORT_LOG_TAG, "Enable light sleep, the wake up source is ESP timer");
|
||||
#endif //CONFIG_BT_LE_WAKEUP_SOURCE_CPU_RTC_TIMER
|
||||
|
||||
#ifdef CONFIG_BT_LE_WAKEUP_SOURCE_BLE_RTC_TIMER
|
||||
esp_sleep_enable_bt_wakeup();
|
||||
ESP_LOGW(NIMBLE_PORT_LOG_TAG, "Enable light sleep, the wake up source is BLE timer");
|
||||
#endif // CONFIG_BT_LE_WAKEUP_SOURCE_BLE_RTC_TIMER
|
||||
|
||||
return rc;
|
||||
|
||||
error:
|
||||
|
||||
#if CONFIG_FREERTOS_USE_TICKLESS_IDLE
|
||||
esp_sleep_disable_bt_wakeup();
|
||||
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) {
|
||||
esp_pm_lock_release(s_pm_lock);
|
||||
esp_pm_lock_delete(s_pm_lock);
|
||||
s_pm_lock = NULL;
|
||||
}
|
||||
#endif // CONFIG_PM_ENABLE
|
||||
#ifdef CONFIG_BT_LE_WAKEUP_SOURCE_CPU_RTC_TIMER
|
||||
if (s_ble_sleep_timer != NULL) {
|
||||
esp_timer_stop(s_ble_sleep_timer);
|
||||
esp_timer_delete(s_ble_sleep_timer);
|
||||
s_ble_sleep_timer = NULL;
|
||||
}
|
||||
#endif // CONFIG_BT_LE_WAKEUP_SOURCE_CPU_RTC_TIMER
|
||||
|
||||
#ifdef CONFIG_BT_LE_WAKEUP_SOURCE_BLE_RTC_TIMER
|
||||
esp_sleep_disable_bt_wakeup();
|
||||
#endif // CONFIG_BT_LE_WAKEUP_SOURCE_BLE_RTC_TIMER
|
||||
|
||||
#endif //CONFIG_PM_ENABLE
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
void controller_sleep_deinit(void)
|
||||
{
|
||||
#if CONFIG_FREERTOS_USE_TICKLESS_IDLE
|
||||
#ifdef CONFIG_PM_ENABLE
|
||||
#ifdef CONFIG_BT_LE_WAKEUP_SOURCE_BLE_RTC_TIMER
|
||||
r_ble_rtc_wake_up_state_clr();
|
||||
esp_sleep_disable_bt_wakeup();
|
||||
sleep_modem_ble_mac_modem_state_deinit();
|
||||
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
|
||||
#endif //CONFIG_BT_LE_WAKEUP_SOURCE_BLE_RTC_TIMER
|
||||
|
||||
esp_sleep_pd_config(ESP_PD_DOMAIN_XTAL, ESP_PD_OPTION_AUTO);
|
||||
|
||||
/* lock should be released first */
|
||||
if (s_ble_active) {
|
||||
esp_pm_lock_release(s_pm_lock);
|
||||
}
|
||||
|
||||
esp_pm_lock_delete(s_pm_lock);
|
||||
s_pm_lock = NULL;
|
||||
|
||||
#ifdef CONFIG_BT_LE_WAKEUP_SOURCE_CPU_RTC_TIMER
|
||||
if (s_ble_sleep_timer != NULL) {
|
||||
esp_timer_stop(s_ble_sleep_timer);
|
||||
esp_timer_delete(s_ble_sleep_timer);
|
||||
s_ble_sleep_timer = NULL;
|
||||
}
|
||||
#endif //CONFIG_BT_LE_WAKEUP_SOURCE_CPU_RTC_TIMER
|
||||
#endif //CONFIG_PM_ENABLE
|
||||
}
|
||||
|
||||
typedef enum {
|
||||
FILTER_DUPLICATE_PDUTYPE = BIT(0),
|
||||
FILTER_DUPLICATE_LENGTH = BIT(1),
|
||||
FILTER_DUPLICATE_ADDRESS = BIT(2),
|
||||
FILTER_DUPLICATE_ADVDATA = BIT(3),
|
||||
FILTER_DUPLICATE_DEFAULT = FILTER_DUPLICATE_PDUTYPE | FILTER_DUPLICATE_ADDRESS,
|
||||
FILTER_DUPLICATE_PDU_ALL = 0xF,
|
||||
FILTER_DUPLICATE_EXCEPTION_FOR_MESH = BIT(4),
|
||||
FILTER_DUPLICATE_AD_TYPE = BIT(5),
|
||||
}disc_duplicate_mode_t;
|
||||
#define REG_MODEM_SYSCON_BASE 0x600A5400
|
||||
#define REG_MODEM_LPCON_BASE 0x600AD000
|
||||
#define DR_REG_MODEM_SYSCON_BASE REG_MODEM_SYSCON_BASE
|
||||
|
||||
#define MODEM_SYSCON_CLK_CONF_REG (DR_REG_MODEM_SYSCON_BASE + 0x4)
|
||||
#define MODEM_SYSCON_CLK_CONF1_REG (DR_REG_MODEM_SYSCON_BASE + 0x10)
|
||||
|
||||
extern void r_filter_duplicate_mode_enable(disc_duplicate_mode_t mode);
|
||||
extern void r_filter_duplicate_mode_disable(disc_duplicate_mode_t mode);
|
||||
extern void r_filter_duplicate_set_ring_list_max_num(uint32_t max_num);
|
||||
extern void r_scan_duplicate_cache_refresh_set_time(uint32_t period_time);
|
||||
#define MODEM_LPCON_CLK_CONF_REG (REG_MODEM_LPCON_BASE + 0x0008)
|
||||
#define MODEM_LPCON_CLK_CONF_FORCE_ON_REG (REG_MODEM_LPCON_BASE + 0x000C)
|
||||
#include "hal/clk_tree_ll.h"
|
||||
|
||||
int
|
||||
ble_vhci_disc_duplicate_mode_enable(int mode)
|
||||
static void enable_chip_clk(void)
|
||||
{
|
||||
// TODO: use vendor hci to update
|
||||
r_filter_duplicate_mode_enable(mode);
|
||||
return true;
|
||||
}
|
||||
WRITE_PERI_REG(MODEM_SYSCON_CLK_CONF_REG,0xFFFFFFFF);
|
||||
WRITE_PERI_REG(MODEM_SYSCON_CLK_CONF1_REG,0xFFFFFFFF);
|
||||
WRITE_PERI_REG(MODEM_LPCON_CLK_CONF_REG ,0xFFFFFFFF);
|
||||
// SET BIT for BLE RTC clk
|
||||
SET_PERI_REG_MASK(PMU_HP_SLEEP_LP_CK_POWER_REG,PMU_HP_SLEEP_XPD_XTAL32K);
|
||||
// REG_SET_FIELD(LP_CLKRST_LPPERI_REG,LP_CLKRST_LP_SEL_XTAL32K,1);
|
||||
// REG_SET_FIELD(LP_CLKRST_LPPERI_REG,LP_CLKRST_LP_BLETIMER_DIV_NUM,0);
|
||||
|
||||
int
|
||||
ble_vhci_disc_duplicate_mode_disable(int mode)
|
||||
{
|
||||
// TODO: use vendor hci to update
|
||||
r_filter_duplicate_mode_disable(mode);
|
||||
return true;
|
||||
}
|
||||
|
||||
int ble_vhci_disc_duplicate_set_max_cache_size(int max_cache_size){
|
||||
// TODO: use vendor hci to update
|
||||
r_filter_duplicate_set_ring_list_max_num(max_cache_size);
|
||||
return true;
|
||||
}
|
||||
|
||||
int ble_vhci_disc_duplicate_set_period_refresh_time(int refresh_period_time){
|
||||
// TODO: use vendor hci to update
|
||||
r_scan_duplicate_cache_refresh_set_time(refresh_period_time);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Config scan duplicate option mode from menuconfig (Adapt to the old configuration method.)
|
||||
*/
|
||||
void ble_controller_scan_duplicate_config(void)
|
||||
{
|
||||
uint32_t duplicate_mode = FILTER_DUPLICATE_DEFAULT;
|
||||
uint32_t cache_size = 100;
|
||||
#if CONFIG_BT_LE_SCAN_DUPL == true
|
||||
cache_size = CONFIG_BT_LE_LL_DUP_SCAN_LIST_COUNT;
|
||||
if (CONFIG_BT_LE_SCAN_DUPL_TYPE == 0) {
|
||||
duplicate_mode = FILTER_DUPLICATE_ADDRESS | FILTER_DUPLICATE_PDUTYPE;
|
||||
} else if (CONFIG_BT_LE_SCAN_DUPL_TYPE == 1) {
|
||||
duplicate_mode = FILTER_DUPLICATE_ADVDATA;
|
||||
} else if (CONFIG_BT_LE_SCAN_DUPL_TYPE == 2) {
|
||||
duplicate_mode = FILTER_DUPLICATE_ADDRESS | FILTER_DUPLICATE_ADVDATA;
|
||||
}
|
||||
duplicate_mode |= FILTER_DUPLICATE_EXCEPTION_FOR_MESH;
|
||||
|
||||
ble_vhci_disc_duplicate_set_period_refresh_time(CONFIG_BT_LE_SCAN_DUPL_CACHE_REFRESH_PERIOD);
|
||||
#endif
|
||||
|
||||
ble_vhci_disc_duplicate_mode_disable(0xFFFFFFFF);
|
||||
ble_vhci_disc_duplicate_mode_enable(duplicate_mode);
|
||||
ble_vhci_disc_duplicate_set_max_cache_size(cache_size);
|
||||
/* For chip */
|
||||
WRITE_PERI_REG(MODEM_LPCON_CLK_CONF_REG ,0xFFFFFFFF);
|
||||
WRITE_PERI_REG(MODEM_LPCON_CLK_CONF_FORCE_ON_REG ,0xFFFFFFFF);
|
||||
}
|
||||
|
||||
esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg)
|
||||
@@ -664,9 +593,9 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg)
|
||||
uint8_t mac[6];
|
||||
esp_err_t ret = ESP_OK;
|
||||
ble_npl_count_info_t npl_info;
|
||||
uint32_t slow_clk_freq = 0;
|
||||
|
||||
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;
|
||||
@@ -683,6 +612,8 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg)
|
||||
return ret;
|
||||
}
|
||||
|
||||
enable_chip_clk();
|
||||
|
||||
/* Initialize the function pointers for OS porting */
|
||||
npl_freertos_funcs_init();
|
||||
struct npl_funcs_t *p_npl_funcs = npl_freertos_funcs_get();
|
||||
@@ -705,6 +636,15 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg)
|
||||
goto free_mem;
|
||||
}
|
||||
|
||||
/* Initialize the global memory pool */
|
||||
ret = os_msys_buf_alloc();
|
||||
if (ret != ESP_OK) {
|
||||
ESP_LOGW(NIMBLE_PORT_LOG_TAG, "os msys alloc failed");
|
||||
goto free_mem;
|
||||
}
|
||||
|
||||
os_msys_init();
|
||||
|
||||
#if CONFIG_BT_NIMBLE_ENABLED
|
||||
/* ble_npl_eventq_init() needs to use npl functions in rom and
|
||||
* must be called after esp_bt_controller_init().
|
||||
@@ -713,40 +653,17 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg)
|
||||
#endif // CONFIG_BT_NIMBLE_ENABLED
|
||||
|
||||
/* Enable BT-related clocks */
|
||||
modem_clock_module_enable(PERIPH_BT_MODULE);
|
||||
modem_clock_module_mac_reset(PERIPH_BT_MODULE);
|
||||
#if CONFIG_BT_LE_LP_CLK_SRC_MAIN_XTAL
|
||||
esp_bt_rtc_slow_clk_select(MODEM_CLOCK_LPCLK_SRC_MAIN_XTAL);
|
||||
slow_clk_freq = 100000;
|
||||
#else
|
||||
#if CONFIG_RTC_CLK_SRC_INT_RC
|
||||
esp_bt_rtc_slow_clk_select(MODEM_CLOCK_LPCLK_SRC_RC_SLOW);
|
||||
slow_clk_freq = 30000;
|
||||
#elif CONFIG_RTC_CLK_SRC_EXT_CRYS
|
||||
if (rtc_clk_slow_src_get() == SOC_RTC_SLOW_CLK_SRC_XTAL32K) {
|
||||
esp_bt_rtc_slow_clk_select(MODEM_CLOCK_LPCLK_SRC_XTAL32K);
|
||||
slow_clk_freq = 32768;
|
||||
} else {
|
||||
ESP_LOGW(NIMBLE_PORT_LOG_TAG, "32.768kHz XTAL not detected, fall back to main XTAL as Bluetooth sleep clock");
|
||||
esp_bt_rtc_slow_clk_select(MODEM_CLOCK_LPCLK_SRC_MAIN_XTAL);
|
||||
slow_clk_freq = 100000;
|
||||
}
|
||||
#elif CONFIG_RTC_CLK_SRC_INT_RC32K
|
||||
esp_bt_rtc_slow_clk_select(MODEM_CLOCK_LPCLK_SRC_RC32K);
|
||||
slow_clk_freq = 32000;
|
||||
#elif CONFIG_RTC_CLK_SRC_EXT_OSC
|
||||
esp_bt_rtc_slow_clk_select(MODEM_CLOCK_LPCLK_SRC_EXT32K);
|
||||
slow_clk_freq = 32000;
|
||||
#else
|
||||
ESP_LOGE(NIMBLE_PORT_LOG_TAG, "Unsupported clock source");
|
||||
assert(0);
|
||||
#endif
|
||||
#endif /* CONFIG_BT_LE_LP_CLK_SRC_MAIN_XTAL */
|
||||
// modem_clock_module_enable(PERIPH_BT_MODULE);
|
||||
// modem_clock_select_lp_clock_source(PERIPH_BT_MODULE, MODEM_CLOCK_LPCLK_SRC_MAIN_XTAL, 249);
|
||||
// esp_phy_modem_init();
|
||||
esp_phy_enable();
|
||||
esp_btbb_enable();
|
||||
s_ble_active = true;
|
||||
|
||||
if (ble_osi_coex_funcs_register((struct osi_coex_funcs_t *)&s_osi_coex_funcs_ro) != 0) {
|
||||
ESP_LOGW(NIMBLE_PORT_LOG_TAG, "osi coex funcs reg failed");
|
||||
ret = ESP_ERR_INVALID_ARG;
|
||||
goto modem_deint;
|
||||
goto free_controller;
|
||||
}
|
||||
|
||||
#if CONFIG_SW_COEXIST_ENABLE
|
||||
@@ -756,38 +673,6 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg)
|
||||
ret = ble_controller_init(cfg);
|
||||
if (ret != ESP_OK) {
|
||||
ESP_LOGW(NIMBLE_PORT_LOG_TAG, "ble_controller_init failed %d", ret);
|
||||
goto modem_deint;
|
||||
}
|
||||
|
||||
ESP_LOGI(NIMBLE_PORT_LOG_TAG, "ble controller commit:[%s]", ble_controller_get_compile_version());
|
||||
#if CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
|
||||
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 controller_init_err;
|
||||
}
|
||||
#endif // CONFIG_BT_CONTROLLER_LOG_ENABLED
|
||||
|
||||
esp_ble_change_rtc_freq(slow_clk_freq);
|
||||
|
||||
ble_controller_scan_duplicate_config();
|
||||
|
||||
ret = os_msys_init();
|
||||
if (ret != ESP_OK) {
|
||||
ESP_LOGW(NIMBLE_PORT_LOG_TAG, "msys_init failed %d", ret);
|
||||
goto free_controller;
|
||||
}
|
||||
|
||||
@@ -809,19 +694,17 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg)
|
||||
|
||||
free_controller:
|
||||
controller_sleep_deinit();
|
||||
#if CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
|
||||
controller_init_err:
|
||||
r_ble_log_deinit_async();
|
||||
#endif // CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
|
||||
os_msys_deinit();
|
||||
ble_controller_deinit();
|
||||
modem_deint:
|
||||
modem_clock_deselect_lp_clock_source(PERIPH_BT_MODULE);
|
||||
modem_clock_module_disable(PERIPH_BT_MODULE);
|
||||
esp_btbb_disable();
|
||||
esp_phy_disable();
|
||||
// esp_phy_modem_deinit();
|
||||
// modem_clock_deselect_lp_clock_source(PERIPH_BT_MODULE);
|
||||
// modem_clock_module_disable(PERIPH_BT_MODULE);
|
||||
#if CONFIG_BT_NIMBLE_ENABLED
|
||||
ble_npl_eventq_deinit(nimble_port_get_dflt_eventq());
|
||||
#endif // CONFIG_BT_NIMBLE_ENABLED
|
||||
free_mem:
|
||||
os_msys_buf_free();
|
||||
npl_freertos_mempool_deinit();
|
||||
esp_unregister_npl_funcs();
|
||||
npl_freertos_funcs_deinit();
|
||||
@@ -839,14 +722,16 @@ esp_err_t esp_bt_controller_deinit(void)
|
||||
|
||||
controller_sleep_deinit();
|
||||
|
||||
os_msys_deinit();
|
||||
esp_btbb_disable();
|
||||
|
||||
modem_clock_deselect_lp_clock_source(PERIPH_BT_MODULE);
|
||||
modem_clock_module_disable(PERIPH_BT_MODULE);
|
||||
if (s_ble_active) {
|
||||
esp_phy_disable();
|
||||
s_ble_active = false;
|
||||
}
|
||||
// esp_phy_modem_deinit();
|
||||
// modem_clock_deselect_lp_clock_source(PERIPH_BT_MODULE);
|
||||
// modem_clock_module_disable(PERIPH_BT_MODULE);
|
||||
|
||||
#if CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
|
||||
r_ble_log_deinit_async();
|
||||
#endif // CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
|
||||
ble_controller_deinit();
|
||||
|
||||
#if CONFIG_BT_NIMBLE_ENABLED
|
||||
@@ -854,6 +739,8 @@ esp_err_t esp_bt_controller_deinit(void)
|
||||
ble_npl_eventq_deinit(nimble_port_get_dflt_eventq());
|
||||
#endif // CONFIG_BT_NIMBLE_ENABLED
|
||||
|
||||
os_msys_buf_free();
|
||||
|
||||
esp_unregister_npl_funcs();
|
||||
|
||||
esp_unregister_ext_funcs();
|
||||
@@ -880,14 +767,7 @@ esp_err_t esp_bt_controller_enable(esp_bt_mode_t mode)
|
||||
ESP_LOGW(NIMBLE_PORT_LOG_TAG, "invalid controller state");
|
||||
return ESP_FAIL;
|
||||
}
|
||||
if (!s_ble_active) {
|
||||
#if CONFIG_PM_ENABLE
|
||||
esp_pm_lock_acquire(s_pm_lock);
|
||||
#endif // CONFIG_PM_ENABLE
|
||||
esp_phy_enable(PHY_MODEM_BT);
|
||||
s_ble_active = true;
|
||||
}
|
||||
esp_btbb_enable();
|
||||
|
||||
#if CONFIG_SW_COEXIST_ENABLE
|
||||
coex_enable();
|
||||
#endif // CONFIG_SW_COEXIST_ENABLE
|
||||
@@ -903,14 +783,6 @@ error:
|
||||
#if CONFIG_SW_COEXIST_ENABLE
|
||||
coex_disable();
|
||||
#endif
|
||||
esp_btbb_disable();
|
||||
if (s_ble_active) {
|
||||
esp_phy_disable(PHY_MODEM_BT);
|
||||
#if CONFIG_PM_ENABLE
|
||||
esp_pm_lock_release(s_pm_lock);
|
||||
#endif // CONFIG_PM_ENABLE
|
||||
s_ble_active = false;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -926,14 +798,6 @@ esp_err_t esp_bt_controller_disable(void)
|
||||
#if CONFIG_SW_COEXIST_ENABLE
|
||||
coex_disable();
|
||||
#endif
|
||||
esp_btbb_disable();
|
||||
if (s_ble_active) {
|
||||
esp_phy_disable(PHY_MODEM_BT);
|
||||
#if CONFIG_PM_ENABLE
|
||||
esp_pm_lock_release(s_pm_lock);
|
||||
#endif // CONFIG_PM_ENABLE
|
||||
s_ble_active = false;
|
||||
}
|
||||
ble_controller_status = ESP_BT_CONTROLLER_STATUS_INITED;
|
||||
return ESP_OK;
|
||||
}
|
||||
@@ -1147,33 +1011,10 @@ esp_power_level_t esp_ble_tx_power_get_enhanced(esp_ble_enhanced_power_type_t po
|
||||
return (esp_power_level_t)tx_level;
|
||||
}
|
||||
|
||||
#if CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
|
||||
static void esp_bt_controller_log_interface(uint32_t len, const uint8_t *addr, bool end)
|
||||
{
|
||||
for (int i = 0; i < len; i++) {
|
||||
esp_rom_printf("%02x ", addr[i]);
|
||||
}
|
||||
if (end) {
|
||||
esp_rom_printf("\n");
|
||||
}
|
||||
}
|
||||
|
||||
void esp_ble_controller_log_dump_all(bool output)
|
||||
{
|
||||
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
|
||||
|
||||
#if (!CONFIG_BT_NIMBLE_ENABLED) && (CONFIG_BT_CONTROLLER_ENABLED)
|
||||
#if CONFIG_BT_LE_SM_LEGACY || CONFIG_BT_LE_SM_SC
|
||||
#if (!CONFIG_BT_NIMBLE_ENABLED) && (CONFIG_BT_CONTROLLER_ENABLED == true)
|
||||
#define BLE_SM_KEY_ERR 0x17
|
||||
|
||||
#if CONFIG_BT_LE_CRYPTO_STACK_MBEDTLS
|
||||
#include "mbedtls/aes.h"
|
||||
#if CONFIG_BT_LE_SM_SC
|
||||
@@ -1183,27 +1024,22 @@ void esp_ble_controller_log_dump_all(bool output)
|
||||
#include "mbedtls/cmac.h"
|
||||
#include "mbedtls/ecdh.h"
|
||||
#include "mbedtls/ecp.h"
|
||||
|
||||
static mbedtls_ecp_keypair keypair;
|
||||
#endif // CONFIG_BT_LE_SM_SC
|
||||
|
||||
#else
|
||||
#include "tinycrypt/aes.h"
|
||||
#include "tinycrypt/constants.h"
|
||||
#include "tinycrypt/utils.h"
|
||||
|
||||
#if CONFIG_BT_LE_SM_SC
|
||||
#include "tinycrypt/cmac_mode.h"
|
||||
#include "tinycrypt/ecc_dh.h"
|
||||
#endif // CONFIG_BT_LE_SM_SC
|
||||
#endif // CONFIG_BT_LE_CRYPTO_STACK_MBEDTLS
|
||||
|
||||
/* Based on Core Specification 4.2 Vol 3. Part H 2.3.5.6.1 */
|
||||
static const uint8_t ble_sm_alg_dbg_priv_key[32] = {
|
||||
0x3f, 0x49, 0xf6, 0xd4, 0xa3, 0xc5, 0x5f, 0x38, 0x74, 0xc9, 0xb3, 0xe3,
|
||||
0xd2, 0x10, 0x3f, 0x50, 0x4a, 0xff, 0x60, 0x7b, 0xeb, 0x40, 0xb7, 0x99,
|
||||
0x58, 0x99, 0xb8, 0xa6, 0xcd, 0x3c, 0x1a, 0xbd
|
||||
};
|
||||
#if CONFIG_BT_LE_CRYPTO_STACK_MBEDTLS
|
||||
#if CONFIG_BT_LE_SM_SC
|
||||
static mbedtls_ecp_keypair keypair;
|
||||
#endif // CONFIG_BT_LE_SM_SC
|
||||
#endif// CONFIG_BT_LE_CRYPTO_STACK_MBEDTLS
|
||||
|
||||
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)
|
||||
@@ -1250,7 +1086,8 @@ int ble_sm_alg_gen_dhkey(const uint8_t *peer_pub_key_x, const uint8_t *peer_pub_
|
||||
}
|
||||
|
||||
/* Set PRNG */
|
||||
if ((rc = mbedtls_ctr_drbg_seed(&ctr_drbg, mbedtls_entropy_func, &entropy, NULL, 0)) != 0) {
|
||||
if ((rc = mbedtls_ctr_drbg_seed(&ctr_drbg, mbedtls_entropy_func, &entropy,
|
||||
NULL, 0)) != 0) {
|
||||
goto exit;
|
||||
}
|
||||
|
||||
@@ -1300,10 +1137,19 @@ exit:
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* based on Core Specification 4.2 Vol 3. Part H 2.3.5.6.1 */
|
||||
static const uint8_t ble_sm_alg_dbg_priv_key[32] = {
|
||||
0x3f, 0x49, 0xf6, 0xd4, 0xa3, 0xc5, 0x5f, 0x38, 0x74, 0xc9, 0xb3, 0xe3,
|
||||
0xd2, 0x10, 0x3f, 0x50, 0x4a, 0xff, 0x60, 0x7b, 0xeb, 0x40, 0xb7, 0x99,
|
||||
0x58, 0x99, 0xb8, 0xa6, 0xcd, 0x3c, 0x1a, 0xbd
|
||||
};
|
||||
|
||||
#if CONFIG_BT_LE_CRYPTO_STACK_MBEDTLS
|
||||
static int mbedtls_gen_keypair(uint8_t *public_key, uint8_t *private_key)
|
||||
{
|
||||
int rc = BLE_SM_KEY_ERR;
|
||||
size_t olen = 0;
|
||||
uint8_t pub[65] = {0};
|
||||
mbedtls_entropy_context entropy = {0};
|
||||
mbedtls_ctr_drbg_context ctr_drbg = {0};
|
||||
|
||||
@@ -1325,11 +1171,11 @@ static int mbedtls_gen_keypair(uint8_t *public_key, uint8_t *private_key)
|
||||
goto exit;
|
||||
}
|
||||
|
||||
size_t olen = 0;
|
||||
uint8_t pub[65] = {0};
|
||||
|
||||
if ((rc = mbedtls_ecp_point_write_binary(&keypair.MBEDTLS_PRIVATE(grp), &keypair.MBEDTLS_PRIVATE(Q), MBEDTLS_ECP_PF_UNCOMPRESSED,
|
||||
&olen, pub, 65)) != 0) {
|
||||
if ((rc = mbedtls_ecp_point_write_binary(&keypair.MBEDTLS_PRIVATE(grp),
|
||||
&keypair.MBEDTLS_PRIVATE(Q),
|
||||
MBEDTLS_ECP_PF_UNCOMPRESSED,
|
||||
&olen, pub, 65)) != 0) {
|
||||
goto exit;
|
||||
}
|
||||
|
||||
@@ -1345,7 +1191,7 @@ exit:
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif // CONFIG_BT_LE_CRYPTO_STACK_MBEDTLS
|
||||
#endif // CONFIG_BT_LE_CRYPTO_STACK_MBEDTLS
|
||||
|
||||
/**
|
||||
* pub: 64 bytes
|
||||
@@ -1369,7 +1215,7 @@ int ble_sm_alg_gen_key_pair(uint8_t *pub, uint8_t *priv)
|
||||
if (uECC_make_key(pk, priv, &curve_secp256r1) != TC_CRYPTO_SUCCESS) {
|
||||
return BLE_SM_KEY_ERR;
|
||||
}
|
||||
#endif // CONFIG_BT_LE_CRYPTO_STACK_MBEDTLS
|
||||
#endif // CONFIG_BT_LE_CRYPTO_STACK_MBEDTLS
|
||||
/* Make sure generated key isn't debug key. */
|
||||
} while (memcmp(priv, ble_sm_alg_dbg_priv_key, 32) == 0);
|
||||
|
||||
@@ -1377,8 +1223,7 @@ int ble_sm_alg_gen_key_pair(uint8_t *pub, uint8_t *priv)
|
||||
swap_buf(&pub[32], &pk[32], 32);
|
||||
swap_in_place(priv, 32);
|
||||
#endif // CONFIG_BT_LE_SM_SC_DEBUG_KEYS
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif // CONFIG_BT_LE_SM_LEGACY || CONFIG_BT_LE_SM_SC
|
||||
#endif // (!CONFIG_BT_NIMBLE_ENABLED) && (CONFIG_BT_CONTROLLER_ENABLED)
|
||||
#endif // (!CONFIG_BT_NIMBLE_ENABLED) && (CONFIG_BT_CONTROLLER_ENABLED == true)
|
||||
|
||||
392
components/bt/controller/esp32h4/Kconfig.in
Normal file
392
components/bt/controller/esp32h4/Kconfig.in
Normal file
@@ -0,0 +1,392 @@
|
||||
|
||||
menu "HCI Config"
|
||||
|
||||
choice BT_LE_HCI_INTERFACE
|
||||
prompt "Select HCI interface"
|
||||
default BT_LE_HCI_INTERFACE_USE_RAM
|
||||
|
||||
config BT_LE_HCI_INTERFACE_USE_RAM
|
||||
bool "ram"
|
||||
help
|
||||
Use RAM as HCI interface
|
||||
config BT_LE_HCI_INTERFACE_USE_UART
|
||||
bool "uart"
|
||||
help
|
||||
Use UART as HCI interface
|
||||
endchoice
|
||||
|
||||
config BT_LE_HCI_UART_PORT
|
||||
int "HCI UART port"
|
||||
depends on BT_LE_HCI_INTERFACE_USE_UART
|
||||
default 1
|
||||
help
|
||||
Set the port number of HCI UART
|
||||
|
||||
config BT_LE_HCI_UART_FLOWCTRL
|
||||
bool "HCI uart Hardware Flow ctrl"
|
||||
depends on BT_LE_HCI_INTERFACE_USE_UART
|
||||
default n
|
||||
|
||||
config BT_LE_HCI_UART_TX_PIN
|
||||
int "HCI uart Tx gpio"
|
||||
depends on BT_LE_HCI_INTERFACE_USE_UART
|
||||
default 19
|
||||
|
||||
config BT_LE_HCI_UART_RX_PIN
|
||||
int "HCI uart Rx gpio"
|
||||
depends on BT_LE_HCI_INTERFACE_USE_UART
|
||||
default 10
|
||||
|
||||
config BT_LE_HCI_UART_RTS_PIN
|
||||
int "HCI uart RTS gpio"
|
||||
depends on BT_LE_HCI_UART_FLOWCTRL
|
||||
default 4
|
||||
|
||||
config BT_LE_HCI_UART_CTS_PIN
|
||||
int "HCI uart CTS gpio"
|
||||
depends on BT_LE_HCI_UART_FLOWCTRL
|
||||
default 5
|
||||
|
||||
config BT_LE_HCI_UART_BAUD
|
||||
int "HCI uart baudrate"
|
||||
depends on BT_LE_HCI_INTERFACE_USE_UART
|
||||
default 921600
|
||||
help
|
||||
HCI uart baud rate 115200 ~ 1000000
|
||||
|
||||
choice BT_LE_HCI_UART_PARITY
|
||||
prompt "select uart parity"
|
||||
depends on BT_LE_HCI_INTERFACE_USE_UART
|
||||
default BT_LE_HCI_UART_UART_PARITY_DISABLE
|
||||
|
||||
config BT_LE_HCI_UART_UART_PARITY_DISABLE
|
||||
bool "PARITY_DISABLE"
|
||||
help
|
||||
UART_PARITY_DISABLE
|
||||
config BT_LE_HCI_UART_UART_PARITY_EVEN
|
||||
bool "PARITY_EVEN"
|
||||
help
|
||||
UART_PARITY_EVEN
|
||||
config BT_LE_HCI_UART_UART_PARITY_ODD
|
||||
bool "PARITY_ODD"
|
||||
help
|
||||
UART_PARITY_ODD
|
||||
endchoice
|
||||
|
||||
config BT_LE_HCI_UART_TASK_STACK_SIZE
|
||||
int "HCI uart task stack size"
|
||||
depends on BT_LE_HCI_INTERFACE_USE_UART
|
||||
default 1000
|
||||
help
|
||||
Set the size of uart task stack
|
||||
endmenu
|
||||
|
||||
config BT_LE_CONTROLLER_NPL_OS_PORTING_SUPPORT
|
||||
bool
|
||||
default y
|
||||
help
|
||||
Enable NPL porting for controller.
|
||||
|
||||
|
||||
menuconfig BT_LE_50_FEATURE_SUPPORT
|
||||
bool "Enable BLE 5 feature"
|
||||
depends on !BT_NIMBLE_ENABLED
|
||||
default y
|
||||
help
|
||||
Enable BLE 5 feature
|
||||
|
||||
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 Transer 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_MAX_PERIODIC_SYNCS
|
||||
int "Maximum number of periodic advertising syncs"
|
||||
depends on BT_LE_50_FEATURE_SUPPORT && !BT_NIMBLE_ENABLED
|
||||
|
||||
range 0 8
|
||||
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
|
||||
|
||||
config BT_LE_MSYS_1_BLOCK_COUNT
|
||||
int "MSYS_1 Block Count"
|
||||
default 12
|
||||
help
|
||||
MSYS is a system level mbuf registry. For prepare write & prepare
|
||||
responses MBUFs are allocated out of msys_1 pool. For NIMBLE_MESH
|
||||
enabled cases, this block count is increased by 8 than user defined
|
||||
count.
|
||||
|
||||
config BT_LE_MSYS_1_BLOCK_SIZE
|
||||
int "MSYS_1 Block Size"
|
||||
default 256
|
||||
help
|
||||
Dynamic memory size of block 1
|
||||
|
||||
config BT_LE_MSYS_2_BLOCK_COUNT
|
||||
int "MSYS_2 Block Count"
|
||||
default 24
|
||||
help
|
||||
Dynamic memory count
|
||||
|
||||
config BT_LE_MSYS_2_BLOCK_SIZE
|
||||
int "MSYS_2 Block Size"
|
||||
default 320
|
||||
help
|
||||
Dynamic memory size of block 2
|
||||
|
||||
config BT_LE_ACL_BUF_COUNT
|
||||
int "ACL Buffer count"
|
||||
default 10
|
||||
help
|
||||
The number of ACL data buffers.
|
||||
|
||||
config BT_LE_ACL_BUF_SIZE
|
||||
int "ACL Buffer size"
|
||||
default 517
|
||||
help
|
||||
This is the maximum size of the data portion of HCI ACL data packets.
|
||||
It does not include the HCI data header (of 4 bytes)
|
||||
|
||||
config BT_LE_HCI_EVT_BUF_SIZE
|
||||
int "HCI Event Buffer size"
|
||||
default 257 if BT_LE_EXT_ADV
|
||||
default 70
|
||||
help
|
||||
This is the size of each HCI event buffer in bytes. In case of
|
||||
extended advertising, packets can be fragmented. 257 bytes is the
|
||||
maximum size of a packet.
|
||||
|
||||
config BT_LE_HCI_EVT_HI_BUF_COUNT
|
||||
int "High Priority HCI Event Buffer count"
|
||||
default 30
|
||||
help
|
||||
This is the high priority HCI events' buffer size. High-priority
|
||||
event buffers are for everything except advertising reports. If there
|
||||
are no free high-priority event buffers then host will try to allocate a
|
||||
low-priority buffer instead
|
||||
|
||||
config BT_LE_HCI_EVT_LO_BUF_COUNT
|
||||
int "Low Priority HCI Event Buffer count"
|
||||
default 8
|
||||
help
|
||||
This is the low priority HCI events' buffer size. Low-priority event
|
||||
buffers are only used for advertising reports. If there are no free
|
||||
low-priority event buffers, then an incoming advertising report will
|
||||
get dropped
|
||||
endmenu
|
||||
|
||||
config BT_LE_CONTROLLER_TASK_STACK_SIZE
|
||||
int "Controller task stack size"
|
||||
default 5120 if BLE_MESH
|
||||
default 4096
|
||||
help
|
||||
This configures stack size of NimBLE controller task
|
||||
|
||||
config BT_LE_LL_RESOLV_LIST_SIZE
|
||||
int "BLE LL Resolving list size"
|
||||
range 1 5
|
||||
default 4
|
||||
help
|
||||
Configure the size of resolving list used in link layer.
|
||||
|
||||
menuconfig BT_LE_SECURITY_ENABLE
|
||||
bool "Enable BLE SM feature"
|
||||
depends on !BT_NIMBLE_ENABLED
|
||||
default y
|
||||
help
|
||||
Enable BLE sm feature
|
||||
|
||||
config BT_LE_SM_LEGACY
|
||||
bool "Security manager legacy pairing"
|
||||
depends on BT_LE_SECURITY_ENABLE
|
||||
default y
|
||||
help
|
||||
Enable security manager legacy pairing
|
||||
|
||||
config BT_LE_SM_SC
|
||||
bool "Security manager secure connections (4.2)"
|
||||
depends on BT_LE_SECURITY_ENABLE
|
||||
default y
|
||||
help
|
||||
Enable security manager secure connections
|
||||
|
||||
config BT_LE_SM_SC_DEBUG_KEYS
|
||||
bool "Use predefined public-private key pair"
|
||||
default n
|
||||
depends on BT_LE_SECURITY_ENABLE && BT_LE_SM_SC
|
||||
help
|
||||
If this option is enabled, SM uses predefined DH key pair as described
|
||||
in Core Specification, Vol. 3, Part H, 2.3.5.6.1. This allows to
|
||||
decrypt air traffic easily and thus should only be used for debugging.
|
||||
|
||||
config BT_LE_LL_CFG_FEAT_LE_ENCRYPTION
|
||||
bool "Enable LE encryption"
|
||||
depends on BT_LE_SECURITY_ENABLE
|
||||
default y
|
||||
help
|
||||
Enable encryption connection
|
||||
|
||||
config BT_LE_CRYPTO_STACK_MBEDTLS
|
||||
bool "Override TinyCrypt with mbedTLS for crypto computations"
|
||||
default y
|
||||
depends on !BT_NIMBLE_ENABLED
|
||||
select MBEDTLS_ECP_RESTARTABLE
|
||||
select MBEDTLS_CMAC_C
|
||||
help
|
||||
Enable this option to choose mbedTLS instead of TinyCrypt for crypto
|
||||
computations.
|
||||
|
||||
config BT_LE_WHITELIST_SIZE
|
||||
int "BLE white list size"
|
||||
range 1 15
|
||||
default 12
|
||||
depends on !BT_NIMBLE_ENABLED
|
||||
|
||||
help
|
||||
BLE list size
|
||||
|
||||
config BT_LE_LL_DUP_SCAN_LIST_COUNT
|
||||
int "BLE duplicate scan list count"
|
||||
range 1 100
|
||||
default 20
|
||||
help
|
||||
config the max count of duplicate scan list
|
||||
|
||||
config BT_LE_LL_SCA
|
||||
int "BLE Sleep clock accuracy"
|
||||
range 0 500
|
||||
default 60
|
||||
help
|
||||
Sleep clock accuracy of our device (in ppm)
|
||||
|
||||
config BT_LE_MAX_CONNECTIONS
|
||||
int "Maximum number of concurrent connections"
|
||||
depends on !BT_NIMBLE_ENABLED
|
||||
range 1 9
|
||||
default 3
|
||||
help
|
||||
Defines maximum number of concurrent BLE connections. For ESP32, user
|
||||
is expected to configure BTDM_CTRL_BLE_MAX_CONN from controller menu
|
||||
along with this option. Similarly for ESP32-C3 or ESP32-S3, user is expected to
|
||||
configure BT_CTRL_BLE_MAX_ACT from controller menu.
|
||||
Each connection will take about 1k DRAM.
|
||||
|
||||
choice BT_LE_COEX_PHY_CODED_TX_RX_TLIM
|
||||
prompt "Coexistence: limit on MAX Tx/Rx time for coded-PHY connection"
|
||||
default BT_LE_COEX_PHY_CODED_TX_RX_TLIM_DIS
|
||||
depends on !BT_NIMBLE_ENABLED
|
||||
help
|
||||
When using PHY-Coded in BLE connection, limitation on max tx/rx time can be applied to
|
||||
better avoid dramatic performance deterioration of Wi-Fi.
|
||||
|
||||
config BT_LE_COEX_PHY_CODED_TX_RX_TLIM_EN
|
||||
bool "Force Enable"
|
||||
help
|
||||
Always enable the limitation on max tx/rx time for Coded-PHY connection
|
||||
|
||||
config BT_LE_COEX_PHY_CODED_TX_RX_TLIM_DIS
|
||||
bool "Force Disable"
|
||||
help
|
||||
Disable the limitation on max tx/rx time for Coded-PHY connection
|
||||
endchoice
|
||||
|
||||
config BT_LE_COEX_PHY_CODED_TX_RX_TLIM_EFF
|
||||
int
|
||||
depends on !BT_NIMBLE_ENABLED
|
||||
default 1 if BT_LE_COEX_PHY_CODED_TX_RX_TLIM_EN
|
||||
default 0 if BT_LE_COEX_PHY_CODED_TX_RX_TLIM_DIS
|
||||
|
||||
config BT_LE_SLEEP_ENABLE
|
||||
bool "Enable BLE sleep"
|
||||
default n
|
||||
help
|
||||
Enable BLE sleep
|
||||
|
||||
choice BT_LE_WAKEUP_SOURCE
|
||||
prompt "BLE light sleep wakeup source"
|
||||
depends on BT_LE_SLEEP_ENABLE
|
||||
default BT_LE_WAKEUP_SOURCE_CPU_RTC_TIMER
|
||||
config BT_LE_WAKEUP_SOURCE_CPU_RTC_TIMER
|
||||
bool "Use ESP timer to wakeup CPU"
|
||||
help
|
||||
Use esp timer to wakeup CPU
|
||||
endchoice
|
||||
|
||||
config BT_LE_USE_ESP_TIMER
|
||||
bool "Use Esp Timer for callout"
|
||||
depends on !BT_NIMBLE_ENABLED
|
||||
default y
|
||||
help
|
||||
Set this option to use Esp Timer which has higher priority timer
|
||||
instead of FreeRTOS timer
|
||||
1169
components/bt/controller/esp32h4/bt.c
Normal file
1169
components/bt/controller/esp32h4/bt.c
Normal file
File diff suppressed because it is too large
Load Diff
Submodule components/bt/controller/lib_esp32 updated: b0f132f17e...c97f994fb8
Submodule components/bt/controller/lib_esp32c2/esp32c2-bt-lib updated: 7f3eb5f556...da5d7642db
Submodule components/bt/controller/lib_esp32c3_family updated: 9d40b3bc0a...d83f7d618a
Submodule components/bt/controller/lib_esp32c6/esp32c6-bt-lib updated: 19eb534d33...91cd5b598d
Submodule components/bt/controller/lib_esp32h2/esp32h2-bt-lib updated: c97e0d84f0...c08159814b
@@ -6,23 +6,13 @@ if BLE_MESH
|
||||
help
|
||||
It is a temporary solution and needs further modifications.
|
||||
|
||||
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
|
||||
default n
|
||||
help
|
||||
Enable this option to allow using random advertising interval
|
||||
for mesh packets. And this could help avoid collision of
|
||||
advertising packets.
|
||||
|
||||
config BLE_MESH_USE_DUPLICATE_SCAN
|
||||
bool "Support Duplicate Scan in BLE Mesh"
|
||||
depends on BT_BLUEDROID_ENABLED
|
||||
select BTDM_BLE_SCAN_DUPL if IDF_TARGET_ESP32
|
||||
select BTDM_BLE_MESH_SCAN_DUPL_EN if IDF_TARGET_ESP32
|
||||
select BT_CTRL_BLE_SCAN_DUPL if IDF_TARGET_ESP32C3 || IDF_TARGET_ESP32S3
|
||||
select BT_CTRL_BLE_MESH_SCAN_DUPL_EN if IDF_TARGET_ESP32C3 || IDF_TARGET_ESP32S3
|
||||
select BT_LE_SCAN_DUPL if IDF_TARGET_ESP32C6 || IDF_TARGET_ESP32H2
|
||||
select BT_NIMBLE_VS_SUPPORT if BT_NIMBLE_ENABLED
|
||||
select BT_CTRL_BLE_SCAN_DUPL if IDF_TARGET_ESP32C3
|
||||
select BT_CTRL_BLE_MESH_SCAN_DUPL_EN if IDF_TARGET_ESP32C3
|
||||
default y
|
||||
help
|
||||
Enable this option to allow using specific duplicate scan filter
|
||||
@@ -546,20 +536,6 @@ if BLE_MESH
|
||||
Provisioner can provision up to 20 nodes and each node contains two elements,
|
||||
then the replay protection list size of Provisioner should be at least 40.
|
||||
|
||||
config BLE_MESH_NOT_RELAY_REPLAY_MSG
|
||||
bool "Not relay replayed messages in a mesh network"
|
||||
depends on BLE_MESH_EXPERIMENTAL
|
||||
default n
|
||||
help
|
||||
There may be many expired messages in a complex mesh network that would be
|
||||
considered replayed messages.
|
||||
Enable this option will refuse to relay such messages, which could help to
|
||||
reduce invalid packets in the mesh network.
|
||||
However, it should be noted that enabling this option may result in packet
|
||||
loss in certain environments.
|
||||
Therefore, users need to decide whether to enable this option according to
|
||||
the actual usage situation.
|
||||
|
||||
config BLE_MESH_MSG_CACHE_SIZE
|
||||
int "Network message cache size"
|
||||
default 10
|
||||
@@ -1263,12 +1239,4 @@ if BLE_MESH
|
||||
|
||||
endmenu
|
||||
|
||||
config BLE_MESH_EXPERIMENTAL
|
||||
bool "Make BLE Mesh experimental features visible"
|
||||
default n
|
||||
help
|
||||
Make BLE Mesh Experimental features visible.
|
||||
Experimental features list:
|
||||
- CONFIG_BLE_MESH_NOT_RELAY_REPLAY_MSG
|
||||
|
||||
endif # BLE_MESH
|
||||
|
||||
@@ -79,7 +79,7 @@ void btc_ble_mesh_time_scene_client_arg_deep_free(btc_msg_t *msg)
|
||||
{
|
||||
btc_ble_mesh_time_scene_client_args_t *arg = NULL;
|
||||
|
||||
if (!msg) {
|
||||
if (!msg || !msg->arg) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
@@ -166,7 +166,7 @@ static void btc_ble_mesh_time_scene_client_free_req_data(btc_msg_t *msg)
|
||||
{
|
||||
esp_ble_mesh_time_scene_client_cb_param_t *arg = NULL;
|
||||
|
||||
if (!msg) {
|
||||
if (!msg || !msg->arg) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
@@ -293,7 +293,7 @@ void btc_ble_mesh_time_scene_client_call_handler(btc_msg_t *msg)
|
||||
esp_ble_mesh_time_scene_client_cb_param_t cb = {0};
|
||||
bt_mesh_client_common_param_t common = {0};
|
||||
|
||||
if (!msg) {
|
||||
if (!msg || !msg->arg) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
@@ -353,7 +353,7 @@ void btc_ble_mesh_time_scene_client_cb_handler(btc_msg_t *msg)
|
||||
{
|
||||
esp_ble_mesh_time_scene_client_cb_param_t *param = NULL;
|
||||
|
||||
if (!msg) {
|
||||
if (!msg || !msg->arg) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -45,8 +45,6 @@ void btc_ble_mesh_time_scene_client_cb_handler(btc_msg_t *msg);
|
||||
|
||||
void btc_ble_mesh_time_scene_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src);
|
||||
|
||||
void btc_ble_mesh_time_scene_client_arg_deep_free(btc_msg_t *msg);
|
||||
|
||||
void btc_ble_mesh_time_scene_client_publish_callback(uint32_t opcode, struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
struct net_buf_simple *buf);
|
||||
|
||||
@@ -67,8 +67,6 @@ uint8_t bt_mesh_get_device_role(struct bt_mesh_model *model, bool srv_send);
|
||||
|
||||
int bt_mesh_rand(void *buf, size_t len);
|
||||
|
||||
uint32_t bt_mesh_get_rand(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user