mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
Merge branch 'feature/esp_app_desc_linux' into 'master'
feat(linux): esp_app_format now works on Linux See merge request espressif/esp-idf!30781
This commit is contained in:
commit
6d5d4f8fc1
@ -1,9 +1,5 @@
|
||||
idf_build_get_property(target IDF_TARGET)
|
||||
|
||||
if(${target} STREQUAL "linux")
|
||||
return() # This component is not supported by the POSIX/Linux simulator
|
||||
endif()
|
||||
|
||||
if(NOT BOOTLOADER_BUILD)
|
||||
set(src "esp_app_desc.c")
|
||||
else()
|
||||
|
@ -11,9 +11,13 @@
|
||||
#include "sdkconfig.h"
|
||||
|
||||
#include "esp_log.h"
|
||||
|
||||
// startup_internal.h is necessary for startup function definition, which does not exist on Linux (TODO: IDF-9950)
|
||||
#if !CONFIG_IDF_TARGET_LINUX
|
||||
#include "esp_private/startup_internal.h"
|
||||
|
||||
static const char *TAG = "app_init";
|
||||
#endif
|
||||
|
||||
// Application version info
|
||||
const __attribute__((weak)) __attribute__((section(".rodata_desc"))) esp_app_desc_t esp_app_desc = {
|
||||
@ -31,6 +35,11 @@ const __attribute__((weak)) __attribute__((section(".rodata_desc"))) esp_app_de
|
||||
#endif
|
||||
.idf_ver = IDF_VER,
|
||||
|
||||
// On Linux we just initialize the hash to some known value for testing
|
||||
#if CONFIG_IDF_TARGET_LINUX
|
||||
.app_elf_sha256 = { 0xDE, 0xAD, 0xBE, 0xEF, 0x47, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B},
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_BOOTLOADER_APP_SECURE_VERSION
|
||||
.secure_version = CONFIG_BOOTLOADER_APP_SECURE_VERSION,
|
||||
#else
|
||||
@ -100,6 +109,9 @@ int esp_app_get_elf_sha256(char* dst, size_t size)
|
||||
return n;
|
||||
}
|
||||
|
||||
// startup function definition and execution does not exist on the Linux target
|
||||
// (TODO: IDF-9950)
|
||||
#if !CONFIG_IDF_TARGET_LINUX
|
||||
ESP_SYSTEM_INIT_FN(init_show_app_info, CORE, BIT(0), 20)
|
||||
{
|
||||
// Load the current ELF SHA256
|
||||
@ -127,3 +139,4 @@ ESP_SYSTEM_INIT_FN(init_show_app_info, CORE, BIT(0), 20)
|
||||
}
|
||||
return ESP_OK;
|
||||
}
|
||||
#endif
|
||||
|
@ -0,0 +1,6 @@
|
||||
# Documentation: .gitlab/ci/README.md#manifest-file-to-control-the-buildtest-apps
|
||||
|
||||
components/esp_app_format/test_apps:
|
||||
enable:
|
||||
- if: IDF_TARGET in ["esp32", "esp32s2", "esp32c3", "linux"]
|
||||
reason: covers all major arch types, xtensa vs riscv, single vs dual-core
|
@ -1,2 +1,2 @@
|
||||
| Supported Targets | ESP32 | ESP32-C2 | ESP32-C3 | ESP32-C5 | ESP32-C6 | ESP32-H2 | ESP32-P4 | ESP32-S2 | ESP32-S3 |
|
||||
| ----------------- | ----- | -------- | -------- | -------- | -------- | -------- | -------- | -------- | -------- |
|
||||
| Supported Targets | ESP32 | ESP32-C3 | ESP32-S2 | Linux |
|
||||
| ----------------- | ----- | -------- | -------- | ----- |
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include "esp_app_desc.h"
|
||||
#include "unity.h"
|
||||
#include "unity_fixture.h"
|
||||
#include "inttypes_ext.h"
|
||||
|
||||
TEST_GROUP(esp_app_format);
|
||||
|
||||
@ -40,7 +41,7 @@ TEST(esp_app_format, esp_app_get_elf_sha256_test)
|
||||
memset(dst, fill, sizeof(dst));
|
||||
len = sizeof(dst);
|
||||
res = esp_app_get_elf_sha256(dst, len);
|
||||
printf("%d: %s (%d)\n", len, dst, res);
|
||||
printf("%" PRIuSIZE ": %s (%d)\n", len, dst, res);
|
||||
TEST_ASSERT_EQUAL(sha256_hex_len + 1, res);
|
||||
TEST_ASSERT_EQUAL(0, memcmp(dst, ref_sha256, res - 1));
|
||||
TEST_ASSERT_EQUAL_HEX(0, dst[sha256_hex_len]);
|
||||
@ -49,7 +50,7 @@ TEST(esp_app_format, esp_app_get_elf_sha256_test)
|
||||
memset(dst, fill, sizeof(dst));
|
||||
len = 9;
|
||||
res = esp_app_get_elf_sha256(dst, len);
|
||||
printf("%d: %s (%d)\n", len, dst, res);
|
||||
printf("%" PRIuSIZE ": %s (%d)\n", len, dst, res);
|
||||
TEST_ASSERT_EQUAL(9, res);
|
||||
TEST_ASSERT_EQUAL(0, memcmp(dst, ref_sha256, res - 1));
|
||||
TEST_ASSERT_EQUAL_HEX(0, dst[8]);
|
||||
@ -59,7 +60,7 @@ TEST(esp_app_format, esp_app_get_elf_sha256_test)
|
||||
strncpy(ref_sha256, esp_app_get_elf_sha256_str(), sizeof(ref_sha256));
|
||||
len = strlen(ref_sha256);
|
||||
TEST_ASSERT_EQUAL(CONFIG_APP_RETRIEVE_LEN_ELF_SHA, len);
|
||||
printf("\n_Ref: %s (len=%d with null)\n", ref_sha256, len);
|
||||
printf("\n_Ref: %s (len=%" PRIuSIZE " with null)\n", ref_sha256, len);
|
||||
|
||||
TEST_ASSERT_EQUAL(0, esp_app_get_elf_sha256(dst, 0));
|
||||
TEST_ASSERT_EQUAL(0, esp_app_get_elf_sha256(dst, 1));
|
||||
@ -69,7 +70,7 @@ TEST(esp_app_format, esp_app_get_elf_sha256_test)
|
||||
memset(dst, 0xCC, sizeof(dst));
|
||||
TEST_ASSERT_EQUAL(req_len, esp_app_get_elf_sha256(dst, req_len));
|
||||
len = strlen(dst) + 1; // + 1 for the null terminator
|
||||
printf("_%02d_: %-15s (len=%d with null)\n", req_len, dst, len);
|
||||
printf("_%02" PRIuSIZE "_: %-15s (len=%" PRIuSIZE " with null)\n", req_len, dst, len);
|
||||
TEST_ASSERT_EQUAL(req_len, len);
|
||||
TEST_ASSERT_EQUAL_STRING_LEN(ref_sha256, dst, len - 1); // -1 without null terminator
|
||||
}
|
||||
@ -78,7 +79,7 @@ TEST(esp_app_format, esp_app_get_elf_sha256_test)
|
||||
size_t max_len = CONFIG_APP_RETRIEVE_LEN_ELF_SHA + 1; // + 1 for the null terminator
|
||||
TEST_ASSERT_EQUAL(max_len, esp_app_get_elf_sha256(dst, 99));
|
||||
len = strlen(dst) + 1; // + 1 for the null terminator
|
||||
printf("_99_: %-15s (len=%d with null)\n", dst, len);
|
||||
printf("_99_: %-15s (len=%" PRIuSIZE " with null)\n", dst, len);
|
||||
TEST_ASSERT_EQUAL(max_len, len);
|
||||
TEST_ASSERT_EQUAL_STRING_LEN(ref_sha256, dst, len - 1); // -1 without null terminator
|
||||
}
|
||||
|
@ -1,11 +1,18 @@
|
||||
# SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
|
||||
# SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD
|
||||
# SPDX-License-Identifier: CC0-1.0
|
||||
|
||||
import pytest
|
||||
from pytest_embedded import Dut
|
||||
|
||||
|
||||
@pytest.mark.supported_targets
|
||||
@pytest.mark.esp32
|
||||
@pytest.mark.esp32s2
|
||||
@pytest.mark.esp32c3
|
||||
@pytest.mark.generic
|
||||
def test_esp_app_format(dut: Dut) -> None:
|
||||
dut.expect_unity_test_output()
|
||||
|
||||
|
||||
@pytest.mark.linux
|
||||
@pytest.mark.host_test
|
||||
def test_esp_app_format_linux(dut: Dut) -> None:
|
||||
dut.expect_unity_test_output()
|
||||
|
@ -1,7 +1,7 @@
|
||||
# General options for additional checks
|
||||
CONFIG_HEAP_POISONING_COMPREHENSIVE=y
|
||||
CONFIG_COMPILER_WARN_WRITE_STRINGS=y
|
||||
CONFIG_BOOTLOADER_LOG_LEVEL_WARN=y
|
||||
#CONFIG_BOOTLOADER_LOG_LEVEL_WARN=y TODO IDF-9967
|
||||
CONFIG_FREERTOS_WATCHPOINT_END_OF_STACK=y
|
||||
CONFIG_COMPILER_STACK_CHECK_MODE_STRONG=y
|
||||
CONFIG_COMPILER_STACK_CHECK=y
|
||||
|
@ -142,6 +142,9 @@ Note that any "Yes" here does not necessarily mean a full implementation or mock
|
||||
* - driver
|
||||
- Yes
|
||||
- No
|
||||
* - esp_app_format
|
||||
- No
|
||||
- Yes
|
||||
* - esp_common
|
||||
- No
|
||||
- Yes
|
||||
|
@ -88,6 +88,9 @@ ESP-IDF 已支持使用 `FreeRTOS POSIX/Linux 模拟器 <https://www.freertos.or
|
||||
* - driver
|
||||
- 是
|
||||
- 否
|
||||
* - esp_app_format
|
||||
- 否
|
||||
- 是
|
||||
* - esp_common
|
||||
- 否
|
||||
- 是
|
||||
|
Loading…
Reference in New Issue
Block a user