esp_bootloader_format: Adds bootloader description structure to read bootloader version from app

Closes https://github.com/espressif/esp-idf/issues/8800
Closes https://github.com/espressif/esp-idf/issues/9132
This commit is contained in:
KonstantinKondrashov
2022-12-14 01:16:56 +08:00
parent 87dd7bb51a
commit 69838403f9
38 changed files with 421 additions and 51 deletions

View File

@@ -0,0 +1,8 @@
# This is the project CMakeLists.txt file for the test subproject
cmake_minimum_required(VERSION 3.16)
# "Trim" the build. Include the minimal set of components, main, and anything it depends on.
set(COMPONENTS main)
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
project(esp_bootloader_format_test)

View File

@@ -0,0 +1,2 @@
| Supported Targets | ESP32 |
| ----------------- | ----- |

View File

@@ -0,0 +1,3 @@
idf_component_register(SRCS "test_bootloader_desc.c"
PRIV_INCLUDE_DIRS .
PRIV_REQUIRES esp_bootloader_format app_update unity)

View File

@@ -0,0 +1,45 @@
/*
* SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <stdio.h>
#include <string.h>
#include "esp_ota_ops.h"
#include "esp_bootloader_desc.h"
#include "unity.h"
#include "unity_fixture.h"
#include "unity_internals.h"
TEST_GROUP(esp_bootloader_format);
TEST_SETUP(esp_bootloader_format)
{
}
TEST_TEAR_DOWN(esp_bootloader_format)
{
}
TEST(esp_bootloader_format, esp_ota_get_bootloader_description)
{
esp_bootloader_desc_t desc;
printf("\n");
TEST_ESP_OK(esp_ota_get_bootloader_description(NULL, &desc));
TEST_ASSERT_EQUAL(desc.magic_byte, ESP_BOOTLOADER_DESC_MAGIC_BYTE);
TEST_ASSERT_EQUAL(desc.version, CONFIG_BOOTLOADER_PROJECT_VER);
printf("\tESP-IDF version from 2nd stage bootloader: %s\n", desc.idf_ver);
printf("\tESP-IDF version from app: %s\n", IDF_VER);
TEST_ASSERT_EQUAL(0, memcmp(desc.idf_ver, IDF_VER, sizeof(IDF_VER)));
}
TEST_GROUP_RUNNER(esp_bootloader_format)
{
RUN_TEST_CASE(esp_bootloader_format, esp_ota_get_bootloader_description)
}
void app_main(void)
{
UNITY_MAIN(esp_bootloader_format);
}

View File

@@ -0,0 +1,11 @@
# SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD
# SPDX-License-Identifier: CC0-1.0
import pytest
from pytest_embedded import Dut
@pytest.mark.esp32
@pytest.mark.generic
def test_esp_bootloader_format(dut: Dut) -> None:
dut.expect_unity_test_output()

View File

@@ -0,0 +1,10 @@
# General options for additional checks
CONFIG_HEAP_POISONING_COMPREHENSIVE=y
CONFIG_COMPILER_WARN_WRITE_STRINGS=y
CONFIG_FREERTOS_WATCHPOINT_END_OF_STACK=y
CONFIG_COMPILER_STACK_CHECK_MODE_STRONG=y
CONFIG_COMPILER_STACK_CHECK=y
# Enable Unity fixture support
CONFIG_UNITY_ENABLE_FIXTURE=y
CONFIG_UNITY_ENABLE_IDF_TEST_RUNNER=n