fix(lp_core): updated lp rom newlib API addresses

This commit is contained in:
Marius Vikhammer
2024-10-24 09:50:29 +08:00
parent e05fce3c9c
commit 8406735635
5 changed files with 189 additions and 60 deletions

View File

@@ -1,7 +1,8 @@
set(app_sources "test_app_main.c" "test_lp_core.c")
set(lp_core_sources "lp_core/test_hello_main.c")
set(lp_core_sources_panic "lp_core/test_panic_main.c")
set(lp_core_sources_shared_mem "lp_core/test_shared_mem_main.c")
set(lp_core_sources_shared_mem "lp_core/test_shared_mem_main.c")
set(lp_core_sources_lp_rom "lp_core/test_lp_rom_main.c")
idf_component_register(SRCS ${app_sources}
INCLUDE_DIRS "lp_core"
@@ -13,3 +14,7 @@ set(lp_core_exp_dep_srcs ${app_sources})
ulp_embed_binary(lp_core_test_app "${lp_core_sources}" "${lp_core_exp_dep_srcs}")
ulp_embed_binary(lp_core_test_app_panic "${lp_core_sources_panic}" "${lp_core_exp_dep_srcs}")
ulp_embed_binary(lp_core_test_app_shared_mem "${lp_core_sources_shared_mem}" "${lp_core_exp_dep_srcs}")
if(CONFIG_ESP_ROM_HAS_LP_ROM)
ulp_embed_binary(lp_core_test_app_lp_rom "${lp_core_sources_lp_rom}" "${lp_core_exp_dep_srcs}")
endif()

View File

@@ -0,0 +1,85 @@
/*
* SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <stdint.h>
#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
#include "soc/soc.h"
#include "ulp_lp_core_print.h"
#include <ctype.h>
void assert_function_in_rom(void *func)
{
if ((intptr_t)func < SOC_LP_ROM_LOW || (intptr_t)func > SOC_LP_ROM_HIGH) {
abort();
}
}
static void test_memset(void)
{
#define TEST_MEMSET_VAL 0xAB
assert_function_in_rom(memset);
lp_core_printf("Testing memset\n");
uint8_t test_buf[100];
memset(test_buf, TEST_MEMSET_VAL, sizeof(test_buf));
for (int i = 0; i < sizeof(test_buf); i++) {
if (test_buf[i] != TEST_MEMSET_VAL) {
lp_core_printf("test_buf[%d]: 0x%X != 0x%X\n", i, test_buf[i], TEST_MEMSET_VAL);
abort();
}
}
}
static void test_memcpy(void)
{
#define TEST_MEMCPY_VAL 0xAC
#define TEST_SIZE 100
assert_function_in_rom(memcpy);
lp_core_printf("Testing memcpy\n");
uint8_t test_buf_a[TEST_SIZE];
memset(test_buf_a, TEST_MEMCPY_VAL, TEST_SIZE);
uint8_t test_buf_b[TEST_SIZE];
memcpy(test_buf_b, test_buf_a, TEST_SIZE);
for (int i = 0; i < TEST_SIZE; i++) {
if (test_buf_b[i] != TEST_MEMCPY_VAL) {
lp_core_printf("test_buf_b[%d]: 0x%X != 0x%X\n", i, test_buf_b[i], TEST_MEMCPY_VAL);
abort();
}
}
}
static void test_abs(void)
{
assert_function_in_rom(abs);
lp_core_printf("Testing abs\n");
if (abs(-123) != 123) {
lp_core_printf("Failed abs() test\n");
abort();
}
}
volatile bool lp_rom_test_finished;
int main(void)
{
// Test a misc of ROM functions to catch any regression with LD file updates
test_memset();
test_memcpy();
test_abs();
lp_core_printf("ULP: all tests passed\n");
lp_rom_test_finished = true;
return 0;
}

View File

@@ -19,6 +19,10 @@
#include "ulp_lp_core_memory_shared.h"
#include "test_shared.h"
#if ESP_ROM_HAS_LP_ROM
#include "lp_core_test_app_lp_rom.h"
#endif
extern const uint8_t lp_core_main_bin_start[] asm("_binary_lp_core_test_app_bin_start");
extern const uint8_t lp_core_main_bin_end[] asm("_binary_lp_core_test_app_bin_end");
@@ -28,6 +32,11 @@ extern const uint8_t lp_core_panic_bin_end[] asm("_binary_lp_core_test_app_pan
extern const uint8_t lp_core_shared_mem_bin_start[] asm("_binary_lp_core_test_app_shared_mem_bin_start");
extern const uint8_t lp_core_shared_mem_bin_end[] asm("_binary_lp_core_test_app_shared_mem_bin_end");
#if ESP_ROM_HAS_LP_ROM
extern const uint8_t lp_core_lp_rom_bin_start[] asm("_binary_lp_core_test_app_lp_rom_bin_start");
extern const uint8_t lp_core_lp_rom_bin_end[] asm("_binary_lp_core_test_app_lp_rom_bin_end");
#endif
static void load_and_start_lp_core_firmware(ulp_lp_core_cfg_t* cfg, const uint8_t* firmware_start, const uint8_t* firmware_end)
{
TEST_ASSERT(ulp_lp_core_load_binary(firmware_start,
@@ -93,3 +102,24 @@ TEST_CASE("LP-Core Shared-mem", "[lp_core]")
printf("HP shared memory test passed\n");
}
#if ESP_ROM_HAS_LP_ROM
TEST_CASE("LP-Core LP-ROM", "[lp_core]")
{
/* Load ULP firmware and start the coprocessor */
ulp_lp_core_cfg_t cfg = {
.wakeup_source = ULP_LP_CORE_WAKEUP_SOURCE_HP_CPU,
};
TEST_ASSERT(ulp_lp_core_load_binary(lp_core_lp_rom_bin_start, (lp_core_lp_rom_bin_end - lp_core_lp_rom_bin_start)) == ESP_OK);
TEST_ASSERT(ulp_lp_core_run(&cfg) == ESP_OK);
// Actual test output on UART is checked by pytest, not unity test-case
// We simply wait to allow the lp-core to run once
while (!ulp_lp_rom_test_finished) {
vTaskDelay(100 / portTICK_PERIOD_MS);
}
printf("LP ROM test passed\n");
}
#endif

View File

@@ -47,3 +47,12 @@ def test_lp_core_shared_mem(dut: Dut) -> None:
dut.expect_exact('ULP shared memory test passed')
dut.expect_exact('HP shared memory test passed')
@pytest.mark.esp32p4
@pytest.mark.generic
def test_lp_core_lp_rom(dut: Dut) -> None:
dut.expect_exact('Press ENTER to see the list of tests')
dut.write('"LP-Core LP-ROM"')
dut.expect_exact('ULP: all tests passed')
dut.expect_exact('LP ROM test passed')