Skip to content

Commit 37e616e

Browse files
authored
Merge branch 'espressif:release/v5.5' into release/v5.5
2 parents 197c483 + 07e9bf4 commit 37e616e

File tree

621 files changed

+394575
-2384
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

621 files changed

+394575
-2384
lines changed

.gitmodules

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
url = ../../DaveGamble/cJSON.git
5252
sbom-version = 1.7.19
5353
sbom-cpe = cpe:2.3:a:cjson_project:cjson:{}:*:*:*:*:*:*:*
54+
sbom-cpe = cpe:2.3:a:davegamble:cjson:{}:*:*:*:*:*:*:*
5455
sbom-supplier = Person: Dave Gamble
5556
sbom-url = https://github.com/DaveGamble/cJSON
5657
sbom-description = Ultralightweight JSON parser in ANSI C

components/bootloader/Kconfig.projbuild

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1051,7 +1051,7 @@ menu "Security features"
10511051
endmenu # Potentially Insecure
10521052

10531053
config SECURE_FLASH_ENCRYPT_ONLY_IMAGE_LEN_IN_APP_PART
1054-
bool "Encrypt only the app image that is present in the partition of type app"
1054+
bool "Encrypt contents upto app image length in app partition"
10551055
depends on SECURE_FLASH_ENC_ENABLED && !SECURE_FLASH_REQUIRE_ALREADY_ENABLED
10561056
default y
10571057
help

components/bootloader_support/include/esp_secure_boot.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,23 @@ typedef struct {
225225
uint8_t signature[64];
226226
} esp_secure_boot_sig_block_t;
227227

228+
/** @brief Get the size of the secure boot signature block
229+
*
230+
* This is the size of the signature block appended to a signed image.
231+
*
232+
* @return Size of the secure boot signature block in bytes
233+
*/
234+
static inline uint32_t esp_secure_boot_sig_block_size(void)
235+
{
236+
#if CONFIG_SECURE_SIGNED_APPS_RSA_SCHEME || CONFIG_SECURE_SIGNED_APPS_ECDSA_V2_SCHEME
237+
return sizeof(ets_secure_boot_signature_t);
238+
#elif defined(CONFIG_SECURE_SIGNED_APPS_ECDSA_SCHEME)
239+
return sizeof(esp_secure_boot_sig_block_t);
240+
#else
241+
return 0;
242+
#endif
243+
}
244+
228245
/** @brief Verify the ECDSA secure boot signature block for Secure Boot V1.
229246
*
230247
* Calculates Deterministic ECDSA w/ SHA256 based on the SHA256 hash of the image. ECDSA signature

components/bootloader_support/src/flash_encryption/flash_encrypt.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -428,6 +428,10 @@ static esp_err_t encrypt_partition(int index, const esp_partition_info_t *partit
428428
if (partition->type == PART_TYPE_APP && should_encrypt) {
429429
// Encrypt only the app image instead of encrypting the whole partition
430430
size = image_data.image_len;
431+
#if CONFIG_SECURE_SIGNED_ON_UPDATE_NO_SECURE_BOOT
432+
// If secure update without secure boot, also encrypt the signature block
433+
size += esp_secure_boot_sig_block_size();
434+
#endif
431435
}
432436
#endif
433437
} else if (partition->type == PART_TYPE_PARTITION_TABLE) {

components/bt/CMakeLists.txt

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -954,13 +954,35 @@ set(bt_priv_requires
954954
esp_gdbstub
955955
)
956956

957+
if(CONFIG_BLE_COMPRESSED_LOG_ENABLE)
958+
set(BT_ROOT_PATH "${CMAKE_CURRENT_SOURCE_DIR}")
959+
# When log compression is enabled, selected logs are replaced
960+
# by auto-generated macros that emit pre-encoded data.
961+
# This eliminates the original format strings, reducing firmware size and
962+
# removing runtime formatting overhead, so logs are produced faster and
963+
# with less system impact.
964+
add_subdirectory(common/ble_log/extension/log_compression)
965+
if(LOG_COMPRESSION_TARGET)
966+
set(srcs ${LOG_COMPRESS_SRCS})
967+
set(include_dirs ${LOG_COMPRESS_INCLUDE_DIRS})
968+
else()
969+
list(APPEND include_dirs ${LOG_COMPRESS_INCLUDE_DIRS})
970+
endif()
971+
endif()
972+
957973
idf_component_register(SRCS "${srcs}"
958974
INCLUDE_DIRS "${include_dirs}"
959975
PRIV_INCLUDE_DIRS "${priv_include_dirs}"
960976
REQUIRES esp_timer esp_wifi
961977
PRIV_REQUIRES "${bt_priv_requires}"
962978
LDFRAGMENTS "${ldscripts}")
963979

980+
if(CONFIG_BLE_COMPRESSED_LOG_ENABLE)
981+
if(LOG_COMPRESSION_TARGET)
982+
add_dependencies(${COMPONENT_LIB} ${LOG_COMPRESSION_TARGET})
983+
endif()
984+
endif()
985+
964986
if(CONFIG_BT_ENABLED)
965987
target_compile_options(${COMPONENT_LIB} PRIVATE -Wno-implicit-fallthrough -Wno-unused-const-variable)
966988
if(CONFIG_IDF_TARGET_ESP32)

components/bt/common/ble_log/Kconfig.in

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,32 @@ if BLE_LOG_ENABLED
3333
try to use the LBM with spin lock protection. So the more LBMs with atomic
3434
lock protection are created, the more ISRs can nest.
3535

36-
config BLE_LOG_LL_ENABLED
37-
bool "Enable BLE Log for Link Layer"
36+
config BLE_LOG_IS_ESP_CONTROLLER
37+
bool "Current BLE Controller is ESP BLE Controller"
3838
depends on BT_CONTROLLER_ENABLED
39+
depends on SOC_ESP_NIMBLE_CONTROLLER
3940
default y
4041
select BT_LE_CONTROLLER_LOG_ENABLED
41-
select BT_LE_CONTROLLER_LOG_MODE_BLE_LOG
42+
select BT_LE_CONTROLLER_LOG_MODE_BLE_LOG_V2
43+
select BLE_LOG_LL_ENABLED
44+
help
45+
Current BLE Controller is ESP BLE Controller
46+
47+
config BLE_LOG_IS_ESP_LEGACY_CONTROLLER
48+
bool "Current BLE Controller is ESP BLE Legacy Controller"
49+
depends on BT_CONTROLLER_ENABLED
50+
depends on !SOC_ESP_NIMBLE_CONTROLLER
51+
depends on BT_CTRL_RUN_IN_FLASH_ONLY
52+
default y
53+
select BT_CTRL_LE_LOG_EN
54+
select BLE_LOG_LL_ENABLED
55+
help
56+
Current BLE Controller is ESP BLE Legacy Controller
57+
58+
config BLE_LOG_LL_ENABLED
59+
bool "Enable BLE Log for Link Layer"
60+
depends on BT_CONTROLLER_ENABLED
61+
default n
4262
help
4363
Enable BLE Log for Link Layer
4464

@@ -96,11 +116,13 @@ if BLE_LOG_ENABLED
96116

97117
config BLE_LOG_PRPH_SPI_MASTER_DMA
98118
bool "Utilize SPI master DMA driver as transport"
119+
depends on SOC_GPSPI_SUPPORTED
99120
help
100121
Utilize SPI master DMA driver as transport
101122

102123
config BLE_LOG_PRPH_UART_DMA
103124
bool "Utilize UART DMA driver as transport"
125+
depends on SOC_UHCI_SUPPORTED
104126
help
105127
Utilize UART DMA driver as transport
106128
endchoice
@@ -144,4 +166,8 @@ if BLE_LOG_ENABLED
144166
help
145167
GPIO number for UART TX
146168
endif
169+
170+
menu "Settings of BLE Log Compression"
171+
source "$IDF_PATH/components/bt/common/ble_log/extension/log_compression/Kconfig.in"
172+
endmenu
147173
endif
Lines changed: 202 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,202 @@
1+
2+
set(LOG_COMPRESSED_MODULE "")
3+
set(LOG_COMPRESSED_MODULE_CODE_PATH "")
4+
set(LOG_COMPRESSED_SRCS_DIR "${CMAKE_BINARY_DIR}/ble_log/.compressed_srcs")
5+
6+
# default config value for ble mesh module
7+
set(BLE_MESH_CODE_PATH "")
8+
set(BLE_MESH_LOG_INDEX_HEADER "\"\"")
9+
set(BLE_MESH_TAGS "")
10+
set(BLE_MESH_TAGS_PRESERVE "")
11+
12+
# default config value for host module
13+
set(HOST_CODE_PATH "")
14+
set(HOST_LOG_INDEX_HEADER "\"\"")
15+
set(BLE_HOST_TAGS "")
16+
set(BLE_HOST_TAGS_PRESERVE "")
17+
18+
if(CONFIG_BLE_MESH_COMPRESSED_LOG_ENABLE)
19+
list(APPEND LOG_COMPRESSED_MODULE "BLE_MESH")
20+
if(NOT EXISTS "${CMAKE_BINARY_DIR}/ble_log/include/mesh_log_index.h")
21+
file(WRITE "${CMAKE_BINARY_DIR}/ble_log/include/mesh_log_index.h" "")
22+
endif()
23+
list(APPEND LOG_COMPRESSED_MODULE_CODE_PATH "esp_ble_mesh")
24+
25+
# update config file
26+
set(BLE_MESH_CODE_PATH "esp_ble_mesh")
27+
set(BLE_MESH_LOG_INDEX_HEADER "mesh_log_index.h")
28+
# update BLE_MESH_TAGS and BLE_MESH_TAGS_PRESERVE
29+
include(${CMAKE_CURRENT_LIST_DIR}/cmake/ble_mesh_log_tags.cmake)
30+
31+
endif()
32+
if(CONFIG_BLE_HOST_COMPRESSED_LOG_ENABLE AND CONFIG_BT_BLUEDROID_ENABLED)
33+
list(APPEND LOG_COMPRESSED_MODULE "BLE_HOST")
34+
list(APPEND LOG_COMPRESSED_MODULE_CODE_PATH "host/bluedroid/stack")
35+
if(NOT EXISTS "${CMAKE_BINARY_DIR}/ble_log/include/host_log_index.h")
36+
file(WRITE "${CMAKE_BINARY_DIR}/ble_log/include/host_log_index.h" "")
37+
endif()
38+
39+
set(HOST_CODE_PATH "host/bluedroid/stack")
40+
set(HOST_LOG_INDEX_HEADER "host_log_index.h")
41+
include(${CMAKE_CURRENT_LIST_DIR}/cmake/ble_host_bluedroid_tags.cmake)
42+
endif()
43+
if(LOG_COMPRESSED_MODULE)
44+
list(APPEND srcs "common/ble_log/extension/log_compression/ble_log_compression.c")
45+
list(APPEND include_dirs "${CMAKE_BINARY_DIR}/ble_log/include")
46+
if(NOT CMAKE_VERSION VERSION_LESS 3.15.0)
47+
set(Python3_FIND_STRATEGY LOCATION)
48+
find_package(Python3 COMPONENTS Interpreter)
49+
if(Python3_Interpreter_FOUND)
50+
set(BLE_PYTHON_EXECUTABLE ${Python3_EXECUTABLE})
51+
endif()
52+
else()
53+
find_package(PythonInterp 3)
54+
if(PYTHONINTERP_FOUND)
55+
set(BLE_PYTHON_EXECUTABLE ${PYTHON_EXECUTABLE})
56+
endif()
57+
endif()
58+
59+
if(BLE_PYTHON_EXECUTABLE)
60+
set(PYTHON_SCRIPT ${BT_ROOT_PATH}/common/ble_log/extension/log_compression/scripts/ble_log_compress.py)
61+
62+
set(compressed_srcs "")
63+
set(uncompressed_srcs "")
64+
set(compressed_srcs_with_abs_path "")
65+
66+
execute_process(COMMAND ${BLE_PYTHON_EXECUTABLE}
67+
${BT_ROOT_PATH}/common/ble_log/extension/log_compression/scripts/env_check.py
68+
RESULT_VARIABLE result
69+
OUTPUT_VARIABLE out
70+
ERROR_VARIABLE err
71+
)
72+
73+
if(NOT ${result} EQUAL 0)
74+
message(WARNING "${err}")
75+
message(WARNING "Exit this log compression due to failure of environment check")
76+
set(LOG_COMPRESS_INCLUDE_DIRS ${include_dirs} PARENT_SCOPE)
77+
set(LOG_COMPRESSION_TARGET "" PARENT_SCOPE)
78+
return()
79+
endif()
80+
81+
set(CONFIG_FILE_PATH "${CMAKE_BINARY_DIR}/ble_log/module_info.yml")
82+
if(NOT EXISTS "${CONFIG_FILE_PATH}")
83+
file(WRITE "${CMAKE_BINARY_DIR}/ble_log/module_info.yml")
84+
endif()
85+
set(YML_IN "${BT_ROOT_PATH}/common/ble_log/extension/log_compression/scripts/configs/module_info.yml.in")
86+
configure_file(${YML_IN} ${CONFIG_FILE_PATH} @ONLY)
87+
88+
string(REPLACE ";" "|" MODULE_CODE_PATH "${LOG_COMPRESSED_MODULE_CODE_PATH}")
89+
set(MATCH_PATTERN "(${MODULE_CODE_PATH}).+\\.c")
90+
foreach(src ${srcs})
91+
if(src MATCHES ${MATCH_PATTERN})
92+
set(dest "${LOG_COMPRESSED_SRCS_DIR}/${src}")
93+
file(WRITE "${dest}" "")
94+
list(APPEND compressed_srcs ${src})
95+
list(APPEND compressed_srcs_with_abs_path "${dest}")
96+
else()
97+
list(APPEND uncompressed_srcs ${src})
98+
endif()
99+
endforeach()
100+
string(REPLACE "|" ";" LOG_COMPRESSED_MODULE_CODE_PATH "${MODULE_CODE_PATH}")
101+
102+
# Some header files of NIMBLE are not added to include_dirs,
103+
# but rely on relative path searches. This will cause the header
104+
# files to be found due to the change in the source code location
105+
# after using the log compression scheme.
106+
# Therefore, these paths are added to include_dirs here to avoid
107+
# unfinished compilation errors.
108+
if(CONFIG_BT_NIMBLE_ENABLED)
109+
list(APPEND include_dirs
110+
"host/nimble/nimble/nimble/host/src"
111+
"host/nimble/nimble/nimble/host/store/config/src")
112+
endif()
113+
114+
add_custom_target(ble_log_compression ALL
115+
COMMAND ${BLE_PYTHON_EXECUTABLE} ${PYTHON_SCRIPT}
116+
compress
117+
--compressed_srcs_path "${LOG_COMPRESSED_SRCS_DIR}"
118+
--build_path "${CMAKE_BINARY_DIR}"
119+
--module "'${LOG_COMPRESSED_MODULE}'"
120+
--bt_path "${BT_ROOT_PATH}"
121+
--srcs "'${compressed_srcs}'"
122+
DEPENDS ${compressed_srcs_with_abs_path} ${PYTHON_SCRIPT}
123+
COMMENT "Log compression is being performed, please wait..."
124+
WORKING_DIRECTORY ${BT_ROOT_PATH}
125+
USES_TERMINAL
126+
)
127+
128+
function(add_flags_if_in_list file file_list compile_flags)
129+
set(PROCESSED OFF PARENT_SCOPE)
130+
foreach(item IN LISTS file_list)
131+
if(item STREQUAL file)
132+
set_source_files_properties("${LOG_COMPRESSED_SRCS_DIR}/${file}"
133+
PROPERTIES
134+
GENERATED TRUE
135+
COMPILE_FLAGS "${compile_flags}"
136+
OBJECT_DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/ble_log_compression"
137+
)
138+
set(PROCESSED ON PARENT_SCOPE)
139+
break()
140+
endif()
141+
endforeach()
142+
endfunction()
143+
144+
foreach(src ${compressed_srcs})
145+
set(PROCESSED OFF)
146+
if(CONFIG_BT_BLUEDROID_ENABLED)
147+
set(files_with_compile_flags
148+
"host/bluedroid/bta/gatt/bta_gattc_act.c"
149+
"host/bluedroid/bta/gatt/bta_gattc_cache.c"
150+
"host/bluedroid/btc/profile/std/gatt/btc_gatt_util.c"
151+
"host/bluedroid/btc/profile/std/gatt/btc_gatts.c")
152+
add_flags_if_in_list("${src}"
153+
"${files_with_compile_flags}"
154+
"-Wno-address-of-packed-member")
155+
156+
if(NOT CMAKE_BUILD_EARLY_EXPANSION)
157+
set(jump_table_opts "-fjump-tables")
158+
if(NOT (CMAKE_C_COMPILER_ID MATCHES "Clang") )
159+
set(jump_table_opts "${jump_table_opts} -ftree-switch-conversion")
160+
endif()
161+
set(files_with_compile_flags
162+
"host/bluedroid/bta/hf_ag/bta_ag_cmd.c"
163+
"host/bluedroid/btc/profile/std/gap/btc_gap_ble.c"
164+
)
165+
add_flags_if_in_list("${src}"
166+
"${files_with_compile_flags}"
167+
"${jump_table_opts}")
168+
endif()
169+
170+
if(CMAKE_C_COMPILER_ID MATCHES "GNU" AND CMAKE_C_COMPILER_VERSION VERSION_GREATER 15.0)
171+
set(files_with_compile_flags "host/bluedroid/device/controller.c")
172+
add_flags_if_in_list("${src}"
173+
"${files_with_compile_flags}"
174+
"-Wno-unterminated-string-initialization")
175+
endif()
176+
endif()
177+
if(CONFIG_BT_NIMBLE_ENABLED)
178+
if(CONFIG_BT_NIMBLE_MESH)
179+
message(ERROR "The current log compression scheme does not support NIMBLE MESH")
180+
endif()
181+
endif()
182+
if(NOT PROCESSED)
183+
set_source_files_properties("${LOG_COMPRESSED_SRCS_DIR}/${src}"
184+
PROPERTIES GENERATED TRUE
185+
OBJECT_DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/ble_log_compression
186+
)
187+
endif()
188+
endforeach()
189+
190+
set(LOG_COMPRESSION_TARGET ble_log_compression PARENT_SCOPE)
191+
# set(LOG_COMPRESSION_TARGET "" PARENT_SCOPE)
192+
set(LOG_COMPRESS_SRCS "${compressed_srcs_with_abs_path};${uncompressed_srcs}" PARENT_SCOPE)
193+
list(APPEND include_dirs "common/ble_log/extension/log_compression/include")
194+
set(LOG_COMPRESS_INCLUDE_DIRS ${include_dirs} PARENT_SCOPE)
195+
else()
196+
set(LOG_COMPRESSION_TARGET "" PARENT_SCOPE)
197+
message("Python 3 used for log compressing not found")
198+
endif()
199+
else()
200+
set(LOG_COMPRESSION_TARGET "" PARENT_SCOPE)
201+
message(STATUS "No module enabled for log compress")
202+
endif()

0 commit comments

Comments
 (0)