-
Notifications
You must be signed in to change notification settings - Fork 7.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'bugfix/rtc_retain_mem_always_erased' into 'master'
Bootloader: retained memory can now be kept after reboot when custom data enabled See merge request espressif/esp-idf!19809
- Loading branch information
Showing
10 changed files
with
86 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# Documentation: .gitlab/ci/README.md#manifest-file-to-control-the-buildtest-apps | ||
|
||
components/bootloader_support/test_apps/rtc_custom_section: | ||
disable: | ||
- if: IDF_TARGET == "esp32c2" | ||
temporary: false | ||
reason: esp32c2 does not have RTC memory |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
components/bootloader_support/test_apps/rtc_custom_section/CMakeLists.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# The following lines of boilerplate have to be in your project's | ||
# CMakeLists in this exact order for cmake to work correctly | ||
cmake_minimum_required(VERSION 3.16) | ||
|
||
include($ENV{IDF_PATH}/tools/cmake/project.cmake) | ||
project(test_rtc_custom_section) |
2 changes: 2 additions & 0 deletions
2
components/bootloader_support/test_apps/rtc_custom_section/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
| Supported Targets | ESP32 | ESP32-C3 | ESP32-S2 | ESP32-S3 | | ||
| ----------------- | ----- | -------- | -------- | -------- | |
2 changes: 2 additions & 0 deletions
2
components/bootloader_support/test_apps/rtc_custom_section/main/CMakeLists.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
idf_component_register(SRCS "test_main.c" | ||
INCLUDE_DIRS ".") |
31 changes: 31 additions & 0 deletions
31
components/bootloader_support/test_apps/rtc_custom_section/main/test_main.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* | ||
* SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
#include "bootloader_common.h" | ||
#include <stdio.h> | ||
#include "sdkconfig.h" | ||
#include "freertos/FreeRTOS.h" | ||
#include "freertos/task.h" | ||
|
||
#define TEST_MAGIC_VALUE 0x42987561 | ||
|
||
extern rtc_retain_mem_t* bootloader_common_get_rtc_retain_mem(void); | ||
|
||
void app_main(void) { | ||
rtc_retain_mem_t* mem = bootloader_common_get_rtc_retain_mem(); | ||
uint32_t* _rtc_vars = (uint32_t*) mem->custom; | ||
|
||
if (_rtc_vars[0] != TEST_MAGIC_VALUE) { | ||
/* On the first boot, set the data inside the array */ | ||
_rtc_vars[0] = TEST_MAGIC_VALUE; | ||
} else { | ||
/* Second boot, the data was saved saved, success */ | ||
printf("SUCCESS: data were saved across reboot\n"); | ||
vTaskDelay(10000 / portTICK_PERIOD_MS); | ||
} | ||
|
||
esp_restart(); | ||
} |
14 changes: 14 additions & 0 deletions
14
components/bootloader_support/test_apps/rtc_custom_section/pytest_rtc_mem.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD | ||
# SPDX-License-Identifier: CC0-1.0 | ||
|
||
import pytest | ||
from pytest_embedded import Dut | ||
|
||
|
||
@pytest.mark.generic | ||
@pytest.mark.esp32 | ||
@pytest.mark.esp32c3 | ||
@pytest.mark.esp32s2 | ||
@pytest.mark.esp32s3 | ||
def test_rtc_reserved_memory(dut: Dut) -> None: | ||
dut.expect_exact('SUCCESS: data were saved across reboot', timeout=10) |
3 changes: 3 additions & 0 deletions
3
components/bootloader_support/test_apps/rtc_custom_section/sdkconfig.defaults
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
CONFIG_BOOTLOADER_RESERVE_RTC_SIZE=0x10 | ||
CONFIG_BOOTLOADER_CUSTOM_RESERVE_RTC=y | ||
CONFIG_BOOTLOADER_CUSTOM_RESERVE_RTC_SIZE=0x200 |