Skip to content

Commit f09e76a

Browse files
authored
Merge branch 'master' into mcapdeville
2 parents c0c6921 + 0f0068f commit f09e76a

File tree

1,302 files changed

+40583
-12825
lines changed

Some content is hidden

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

1,302 files changed

+40583
-12825
lines changed

.gitlab/CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,7 @@
206206

207207
/tools/ @esp-idf-codeowners/tools
208208
/tools/ble/ @esp-idf-codeowners/app-utilities
209+
/tools/bt/ @esp-idf-codeowners/bluetooth
209210
/tools/catch/ @esp-idf-codeowners/ci
210211
/tools/ci/ @esp-idf-codeowners/ci
211212
/tools/cmake/ @esp-idf-codeowners/build-config

.gitlab/ci/default-build-test-rules.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ extra_default_build_targets:
1111
- esp32c61
1212

1313
bypass_check_test_targets:
14+
- esp32h21
1415

1516
#
1617
# These lines would

.gitlab/ci/host-test.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ check_public_headers:
3333
- IDF_TARGET=esp32h2 python tools/ci/check_public_headers.py --jobs 4 --prefix riscv32-esp-elf-
3434
- IDF_TARGET=esp32p4 python tools/ci/check_public_headers.py --jobs 4 --prefix riscv32-esp-elf-
3535
- IDF_TARGET=esp32c61 python tools/ci/check_public_headers.py --jobs 4 --prefix riscv32-esp-elf-
36+
- IDF_TARGET=esp32h21 python tools/ci/check_public_headers.py --jobs 4 --prefix riscv32-esp-elf-
3637

3738
test_nvs_coverage:
3839
extends:
@@ -204,10 +205,14 @@ test_tools:
204205
- pytest --noconftest test_idf_py.py --junitxml=${IDF_PATH}/XUNIT_IDF_PY.xml || stat=1
205206
- pytest --noconftest test_hints.py --junitxml=${IDF_PATH}/XUNIT_HINTS.xml || stat=1
206207
- pytest --noconftest test_idf_qemu.py --junitxml=${IDF_PATH}/XUNIT_IDF_PY_QEMU.xml || stat=1
208+
- cd ${IDF_PATH}/tools/test_bsasm
209+
- pytest --noconftest test_bsasm.py --junitxml=${IDF_PATH}/XUNIT_BSASM.xml || stat=1
207210
- cd ${IDF_PATH}/tools/test_mkdfu
208211
- pytest --noconftest test_mkdfu.py --junitxml=${IDF_PATH}/XUNIT_MKDFU.xml || stat=1
209212
- cd ${IDF_PATH}/tools/test_idf_size
210213
- pytest --noconftest test_idf_size.py --junitxml=${IDF_PATH}/XUNIT_IDF_SIZE.xml || stat=1
214+
- cd ${IDF_PATH}/tools/test_idf_diag
215+
- pytest --noconftest test_idf_diag.py --junitxml=${IDF_PATH}/XUNIT_IDF_DIAG.xml || stat=1
211216
- cd ${IDF_PATH}
212217
- shellcheck -s sh tools/detect_python.sh || stat=1
213218
- shellcheck -s bash tools/detect_python.sh || stat=1

.gitlab/ci/rules.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,8 @@
9292
- "tools/idf_size.py"
9393
- "tools/test_idf_size/**/*"
9494

95+
- "tools/test_idf_diag/**/*"
96+
9597
- "tools/tools.json"
9698
- "tools/tools_schema.json"
9799
- "tools/idf_tools.py"
@@ -124,6 +126,9 @@
124126

125127
- "tools/check_python_dependencies.py"
126128

129+
- "tools/bsasm.py"
130+
- "tools/test_bsasm/**/*"
131+
127132
.patterns-docker: &patterns-docker
128133
- "tools/docker/**/*"
129134

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ repos:
200200
- id: file-contents-sorter
201201
files: 'tools\/ci\/(executable-list\.txt|mypy_ignore_list\.txt|check_copyright_ignore\.txt)'
202202
- repo: https://github.com/espressif/check-copyright/
203-
rev: v1.0.3
203+
rev: v1.1.0
204204
hooks:
205205
- id: check-copyright
206206
args: ['--ignore', 'tools/ci/check_copyright_ignore.txt', '--config', 'tools/ci/check_copyright_config.yaml']

CMakeLists.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,13 @@ if(CONFIG_ESP_SYSTEM_USE_EH_FRAME)
207207
list(APPEND link_options "-Wl,--eh-frame-hdr")
208208
endif()
209209

210+
if(CONFIG_ESP_SYSTEM_USE_FRAME_POINTER)
211+
list(APPEND compile_options "-fno-omit-frame-pointer")
212+
if(CMAKE_C_COMPILER_ID MATCHES "GNU")
213+
list(APPEND compile_options "-mno-omit-leaf-frame-pointer")
214+
endif()
215+
endif()
216+
210217
list(APPEND link_options "-fno-lto")
211218

212219
if(CONFIG_IDF_TARGET_LINUX AND CMAKE_HOST_SYSTEM_NAME STREQUAL "Darwin")

components/app_trace/CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,9 @@ endif()
6060

6161
if(CONFIG_HEAP_TRACING_TOHOST)
6262
list(APPEND srcs "heap_trace_tohost.c")
63-
set_source_files_properties(heap_trace_tohost.c
64-
PROPERTIES COMPILE_FLAGS
65-
-Wno-frame-address)
63+
if(CONFIG_IDF_TARGET_ARCH_XTENSA)
64+
set_source_files_properties(heap_trace_tohost.c PROPERTIES COMPILE_FLAGS -Wno-frame-address)
65+
endif()
6666
endif()
6767

6868
idf_component_register(SRCS "${srcs}"

components/app_trace/heap_trace_tohost.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
/*
2-
* SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD
2+
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*/
6-
#include <sdkconfig.h>
6+
#include "sdkconfig.h"
77

8-
#define HEAP_TRACE_SRCFILE /* don't warn on inclusion here */
98
#include "esp_heap_trace.h"
10-
#undef HEAP_TRACE_SRCFILE
119
#include "esp_heap_caps.h"
1210
#if CONFIG_APPTRACE_SV_ENABLE
1311
#include "esp_app_trace.h"
@@ -16,7 +14,7 @@
1614

1715
#define STACK_DEPTH CONFIG_HEAP_TRACING_STACK_DEPTH
1816

19-
#ifdef CONFIG_HEAP_TRACING_TOHOST
17+
#if CONFIG_HEAP_TRACING_TOHOST
2018

2119
#if !CONFIG_APPTRACE_SV_ENABLE
2220
#error None of the heap tracing backends is enabled! You must enable SystemView compatible tracing to use this feature.

components/app_update/esp_ota_ops.c

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -182,8 +182,18 @@ esp_err_t esp_ota_begin(const esp_partition_t *partition, size_t image_size, esp
182182
} else {
183183
erase_size = ALIGN_UP(image_size, partition->erase_size);
184184
}
185-
return esp_partition_erase_range(partition, 0, erase_size);
185+
esp_err_t err = esp_partition_erase_range(partition, 0, erase_size);
186+
if (err != ESP_OK) {
187+
return err;
188+
}
189+
}
190+
191+
#ifdef CONFIG_BOOTLOADER_APP_ROLLBACK_ENABLE
192+
if (is_ota_partition(partition)) {
193+
esp_ota_invalidate_inactive_ota_data_slot();
186194
}
195+
#endif
196+
187197
return ESP_OK;
188198
}
189199

@@ -955,7 +965,7 @@ esp_err_t esp_ota_get_state_partition(const esp_partition_t *partition, esp_ota_
955965
return ESP_OK;
956966
}
957967

958-
esp_err_t esp_ota_erase_last_boot_app_partition(void)
968+
static esp_err_t erase_last_boot_app_partition(bool skip_app_part_erase)
959969
{
960970
esp_ota_select_entry_t otadata[2];
961971
const esp_partition_t* ota_data_partition = read_otadata(otadata);
@@ -987,20 +997,32 @@ esp_err_t esp_ota_erase_last_boot_app_partition(void)
987997
return ESP_FAIL;
988998
}
989999

990-
esp_err_t err = esp_partition_erase_range(last_boot_app_partition_from_otadata, 0, last_boot_app_partition_from_otadata->size);
991-
if (err != ESP_OK) {
992-
return err;
1000+
if (!skip_app_part_erase) {
1001+
esp_err_t err = esp_partition_erase_range(last_boot_app_partition_from_otadata, 0, last_boot_app_partition_from_otadata->size);
1002+
if (err != ESP_OK) {
1003+
return err;
1004+
}
9931005
}
9941006

9951007
int sec_id = inactive_otadata;
996-
err = esp_partition_erase_range(ota_data_partition, sec_id * ota_data_partition->erase_size, ota_data_partition->erase_size);
1008+
esp_err_t err = esp_partition_erase_range(ota_data_partition, sec_id * ota_data_partition->erase_size, ota_data_partition->erase_size);
9971009
if (err != ESP_OK) {
9981010
return err;
9991011
}
10001012

10011013
return ESP_OK;
10021014
}
10031015

1016+
esp_err_t esp_ota_erase_last_boot_app_partition(void)
1017+
{
1018+
return erase_last_boot_app_partition(false);
1019+
}
1020+
1021+
esp_err_t esp_ota_invalidate_inactive_ota_data_slot(void)
1022+
{
1023+
return erase_last_boot_app_partition(true);
1024+
}
1025+
10041026
#if SOC_SUPPORT_SECURE_BOOT_REVOKE_KEY && CONFIG_SECURE_BOOT_V2_ENABLED
10051027

10061028
// Validates the image at "app_pos" with the secure boot digests other than "revoked_key_index"

components/app_update/include/esp_ota_ops.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ int esp_ota_get_app_elf_sha256(char* dst, size_t size) __attribute__((deprecated
8383
* use esp_ota_mark_app_valid_cancel_rollback() function for it (this should be done as early as possible when you first download a new application).
8484
*
8585
* Note: Rollback is applicable only for app type partitions.
86+
* Note: For Rollback - The OTA data slot corresponding to the last boot application partition will be invalidated.
8687
*
8788
* @param partition Pointer to info for partition which will receive the OTA update. Required.
8889
* This is considered as the staging partition (where OTA is downloaded), be default this also considered as the final partition which supposed to be updated.
@@ -302,6 +303,20 @@ esp_err_t esp_ota_get_partition_description(const esp_partition_t *partition, es
302303
*/
303304
esp_err_t esp_ota_get_bootloader_description(const esp_partition_t *bootloader_partition, esp_bootloader_desc_t *desc);
304305

306+
/**
307+
* @brief Invalidate the OTA data slot associated with the last boot application partition.
308+
*
309+
* This function erases the OTA data slot corresponding to the last boot application partition,
310+
* making the partition invalid for booting in future. The application partition itself
311+
* is not erased, preserving its contents.
312+
*
313+
* @return
314+
* - ESP_OK: Successfully invalidated the OTA data slot.
315+
* - ESP_FAIL: Failed to invalidate the OTA data slot (e.g., invalid parameters, no OTA data partition, or other errors).
316+
* - Other error codes from `esp_partition_erase_range`.
317+
*/
318+
esp_err_t esp_ota_invalidate_inactive_ota_data_slot(void);
319+
305320
/**
306321
* @brief Returns number of ota partitions provided in partition table.
307322
*

components/app_update/test_apps/test_app_update/.build-test-rules.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
components/app_update/test_apps:
44
enable:
55
- if: CONFIG_NAME == "defaults" and IDF_TARGET in ["esp32", "esp32c2", "esp32c3", "esp32c5", "esp32c6", "esp32c61", "esp32h2", "esp32p4", "esp32s2", "esp32s3"]
6+
- if: CONFIG_NAME == "rollback" and IDF_TARGET in ["esp32", "esp32c3", "esp32s3", "esp32p4"]
67
- if: CONFIG_NAME == "xip_psram" and IDF_TARGET in ["esp32s2", "esp32s3", "esp32p4"]
78
# S2 doesn't have ROM for flash
89
- if: CONFIG_NAME == "xip_psram_with_rom_impl" and IDF_TARGET in ["esp32s3", "esp32p4"]

components/app_update/test_apps/test_app_update/main/test_switch_ota.c

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -849,3 +849,84 @@ TEST_CASE("Test bootloader_common_get_sha256_of_partition returns ESP_ERR_IMAGE_
849849
TEST_ESP_ERR(ESP_ERR_IMAGE_INVALID, bootloader_common_get_sha256_of_partition(other_app->address, other_app->size, other_app->type, sha_256_other_app));
850850
TEST_ASSERT_EQUAL_MEMORY_MESSAGE(sha_256_cur_app, sha_256_other_app, sizeof(sha_256_cur_app), "must be the same");
851851
}
852+
853+
static void test_rollback3(void)
854+
{
855+
uint8_t boot_count = get_boot_count_from_nvs();
856+
boot_count++;
857+
set_boot_count_in_nvs(boot_count);
858+
ESP_LOGI(TAG, "boot count %d", boot_count);
859+
const esp_partition_t *cur_app = get_running_firmware();
860+
const esp_partition_t* update_partition = NULL;
861+
switch (boot_count) {
862+
case 2:
863+
ESP_LOGI(TAG, "Factory");
864+
TEST_ASSERT_EQUAL(ESP_PARTITION_SUBTYPE_APP_FACTORY, cur_app->subtype);
865+
update_partition = app_update();
866+
reboot_as_deep_sleep();
867+
break;
868+
case 3:
869+
ESP_LOGI(TAG, "OTA0");
870+
TEST_ASSERT_EQUAL(ESP_PARTITION_SUBTYPE_APP_OTA_0, cur_app->subtype);
871+
TEST_ESP_OK(esp_ota_mark_app_valid_cancel_rollback());
872+
TEST_ASSERT_NULL(esp_ota_get_last_invalid_partition());
873+
update_partition = app_update();
874+
reboot_as_deep_sleep();
875+
break;
876+
case 4:
877+
ESP_LOGI(TAG, "OTA1");
878+
TEST_ASSERT_EQUAL(ESP_PARTITION_SUBTYPE_APP_OTA_1, cur_app->subtype);
879+
TEST_ESP_OK(esp_ota_mark_app_valid_cancel_rollback());
880+
881+
update_partition = esp_ota_get_next_update_partition(NULL);
882+
#ifdef CONFIG_BOOTLOADER_APP_ROLLBACK_ENABLE
883+
// two partitions are valid
884+
TEST_ASSERT_NULL(esp_ota_get_last_invalid_partition());
885+
esp_ota_img_states_t ota_state;
886+
TEST_ESP_OK(esp_ota_get_state_partition(update_partition, &ota_state));
887+
TEST_ASSERT_EQUAL(ESP_OTA_IMG_VALID, ota_state);
888+
#endif
889+
890+
esp_ota_handle_t update_handle = 0;
891+
TEST_ESP_OK(esp_ota_begin(update_partition, OTA_SIZE_UNKNOWN, &update_handle));
892+
893+
#ifdef CONFIG_BOOTLOADER_APP_ROLLBACK_ENABLE
894+
// After esp_ota_begin, the only one partition is valid
895+
// ota data slots do not have an entry about the update_partition.
896+
TEST_ESP_ERR(ESP_ERR_NOT_FOUND, esp_ota_get_state_partition(update_partition, &ota_state));
897+
#endif
898+
copy_app_partition(update_handle, get_running_firmware());
899+
TEST_ESP_OK(esp_ota_end(update_handle));
900+
// esp_ota_set_boot_partition is not called, so the running app will not be changed after reboot
901+
reboot_as_deep_sleep();
902+
break;
903+
default:
904+
erase_ota_data();
905+
TEST_FAIL_MESSAGE("Unexpected stage");
906+
break;
907+
}
908+
}
909+
910+
static void test_rollback3_1(void)
911+
{
912+
set_boot_count_in_nvs(5);
913+
uint8_t boot_count = get_boot_count_from_nvs();
914+
esp_ota_img_states_t ota_state = 0x5555AAAA;
915+
ESP_LOGI(TAG, "boot count %d", boot_count);
916+
const esp_partition_t *cur_app = get_running_firmware();
917+
ESP_LOGI(TAG, "OTA1");
918+
TEST_ASSERT_EQUAL(ESP_PARTITION_SUBTYPE_APP_OTA_1, cur_app->subtype);
919+
TEST_ESP_OK(esp_ota_get_state_partition(cur_app, &ota_state));
920+
TEST_ASSERT_EQUAL(ESP_OTA_IMG_VALID, ota_state);
921+
922+
TEST_ASSERT_NULL(esp_ota_get_last_invalid_partition());
923+
const esp_partition_t* next_update_partition = esp_ota_get_next_update_partition(NULL);
924+
TEST_ASSERT_NOT_NULL(next_update_partition);
925+
#ifdef CONFIG_BOOTLOADER_APP_ROLLBACK_ENABLE
926+
// ota data slots do not have an entry about the next_update_partition.
927+
TEST_ESP_ERR(ESP_ERR_NOT_FOUND, esp_ota_get_state_partition(next_update_partition, &ota_state));
928+
#endif
929+
erase_ota_data();
930+
}
931+
932+
TEST_CASE_MULTIPLE_STAGES("Test rollback. Updated partition invalidated after esp_ota_begin", "[app_update][timeout=90][reset=DEEPSLEEP_RESET, DEEPSLEEP_RESET, DEEPSLEEP_RESET, SW_CPU_RESET]", start_test, test_rollback3, test_rollback3, test_rollback3, test_rollback3_1);

components/app_update/test_apps/test_app_update/pytest_app_update_ut.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,19 @@ def test_app_update_xip_psram(dut: Dut) -> None:
5050
)
5151
def test_app_update_xip_psram_rom_impl(dut: Dut) -> None:
5252
dut.run_all_single_board_cases(timeout=90)
53+
54+
55+
@pytest.mark.esp32
56+
@pytest.mark.esp32c3
57+
@pytest.mark.esp32s3
58+
@pytest.mark.esp32p4
59+
@pytest.mark.generic
60+
@pytest.mark.parametrize(
61+
'config',
62+
[
63+
'rollback',
64+
],
65+
indirect=True,
66+
)
67+
def test_app_update_with_rollback(dut: Dut) -> None:
68+
dut.run_all_single_board_cases(timeout=90)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
CONFIG_BOOTLOADER_APP_ROLLBACK_ENABLE=y

components/bootloader/Kconfig.log

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,26 @@
11
menu "Log"
22

3+
choice BOOTLOADER_LOG_VERSION
4+
prompt "Log version"
5+
help
6+
Select the log version to be used by the ESP log component.
7+
The app log version (CONFIG_LOG_VERSION) controls the version used in the bootloader,
8+
preventing the selection of different versions.
9+
For description of V1 and V2 see CONFIG_LOG_VERSION.
10+
11+
config BOOTLOADER_LOG_VERSION_1
12+
bool "V1" if LOG_VERSION_1
13+
config BOOTLOADER_LOG_VERSION_2
14+
bool "V2" if LOG_VERSION_2
15+
endchoice
16+
17+
config BOOTLOADER_LOG_VERSION
18+
int
19+
default 1 if BOOTLOADER_LOG_VERSION_1
20+
default 2 if BOOTLOADER_LOG_VERSION_2
21+
help
22+
This configuration sets the log version number based on the chosen log version.
23+
324
choice BOOTLOADER_LOG_LEVEL
425
bool "Bootloader log verbosity"
526
default BOOTLOADER_LOG_LEVEL_INFO

0 commit comments

Comments
 (0)