Merge branch 'bugfix/p4_ld_newlib_api_v5.3' into 'release/v5.3'

fix(lp_core): updated lp rom newlib API addresses (v5.3)

See merge request espressif/esp-idf!34480
This commit is contained in:
Jiang Jiang Jian
2024-11-14 18:56:14 +08:00
5 changed files with 189 additions and 60 deletions

View File

@@ -1,12 +1,12 @@
/* /*
* SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD * SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
*/ */
/* ROM function interface esp32p4lp.rom.newlib.ld for esp32p4lp /* ROM function interface esp32p4lp.rom.newlib.ld for esp32p4lp
* *
* *
* Generated from ./target/esp32p4lp/interface-esp32p4lp.yml md5sum 0751c805e21bd23f11b74dcc1f7e8007 * Generated from ./target/esp32p4lp/interface-esp32p4lp.yml md5sum f827caf806e9f4faec384ffbde44b380
* *
* Compatible with ROM where ECO version equal or greater to 0. * Compatible with ROM where ECO version equal or greater to 0.
* *
@@ -18,60 +18,60 @@
***************************************/ ***************************************/
/* Functions */ /* Functions */
memset = 0x501000f0; memset = 0x50100134;
memcpy = 0x501000f4; memcpy = 0x50100138;
memmove = 0x501000f8; memmove = 0x5010013c;
memcmp = 0x501000fc; memcmp = 0x50100140;
strcpy = 0x50100100; strcpy = 0x50100144;
strncpy = 0x50100104; strncpy = 0x50100148;
strcmp = 0x50100108; strcmp = 0x5010014c;
strncmp = 0x5010010c; strncmp = 0x50100150;
strlen = 0x50100110; strlen = 0x50100154;
strstr = 0x50100114; strstr = 0x50100158;
bzero = 0x50100118; bzero = 0x5010015c;
isalnum = 0x5010011c; isalnum = 0x50100160;
isalpha = 0x50100120; isalpha = 0x50100164;
isascii = 0x50100124; isascii = 0x50100168;
isblank = 0x50100128; isblank = 0x5010016c;
iscntrl = 0x5010012c; iscntrl = 0x50100170;
isdigit = 0x50100130; isdigit = 0x50100174;
islower = 0x50100134; islower = 0x50100178;
isgraph = 0x50100138; isgraph = 0x5010017c;
isprint = 0x5010013c; isprint = 0x50100180;
ispunct = 0x50100140; ispunct = 0x50100184;
isspace = 0x50100144; isspace = 0x50100188;
isupper = 0x50100148; isupper = 0x5010018c;
toupper = 0x5010014c; toupper = 0x50100190;
tolower = 0x50100150; tolower = 0x50100194;
toascii = 0x50100154; toascii = 0x50100198;
memccpy = 0x50100158; memccpy = 0x5010019c;
memchr = 0x5010015c; memchr = 0x501001a0;
memrchr = 0x50100160; memrchr = 0x501001a4;
strcasecmp = 0x50100164; strcasecmp = 0x501001a8;
strcasestr = 0x50100168; strcasestr = 0x501001ac;
strcat = 0x5010016c; strcat = 0x501001b0;
strchr = 0x50100170; strchr = 0x501001b4;
strcspn = 0x50100174; strcspn = 0x501001b8;
strcoll = 0x50100178; strcoll = 0x501001bc;
strlcat = 0x5010017c; strlcat = 0x501001c0;
strlcpy = 0x50100180; strlcpy = 0x501001c4;
strlwr = 0x50100184; strlwr = 0x501001c8;
strncasecmp = 0x50100188; strncasecmp = 0x501001cc;
strncat = 0x5010018c; strncat = 0x501001d0;
strnlen = 0x50100190; strnlen = 0x501001d4;
strrchr = 0x50100194; strrchr = 0x501001d8;
strsep = 0x50100198; strsep = 0x501001dc;
strspn = 0x5010019c; strspn = 0x501001e0;
strtok_r = 0x501001a0; strtok_r = 0x501001e4;
strupr = 0x501001a4; strupr = 0x501001e8;
longjmp = 0x501001a8; longjmp = 0x501001ec;
setjmp = 0x501001ac; setjmp = 0x501001f0;
abs = 0x501001b0; abs = 0x501001f4;
div = 0x501001b4; div = 0x501001f8;
labs = 0x501001b8; labs = 0x501001fc;
ldiv = 0x501001bc; ldiv = 0x50100200;
qsort = 0x501001c0; qsort = 0x50100204;
atoi = 0x501001c4; atoi = 0x50100208;
atol = 0x501001c8; atol = 0x5010020c;
itoa = 0x501001cc; itoa = 0x50100210;
utoa = 0x501001d0; utoa = 0x50100214;

View File

@@ -1,6 +1,7 @@
set(app_sources "test_app_main.c" "test_lp_core.c") 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 "lp_core/test_hello_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} idf_component_register(SRCS ${app_sources}
INCLUDE_DIRS "lp_core" INCLUDE_DIRS "lp_core"
@@ -11,3 +12,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 "${lp_core_sources}" "${lp_core_exp_dep_srcs}")
ulp_embed_binary(lp_core_test_app_shared_mem "${lp_core_sources_shared_mem}" "${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,12 +19,21 @@
#include "ulp_lp_core_memory_shared.h" #include "ulp_lp_core_memory_shared.h"
#include "test_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_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"); extern const uint8_t lp_core_main_bin_end[] asm("_binary_lp_core_test_app_bin_end");
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_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"); 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) 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, TEST_ASSERT(ulp_lp_core_load_binary(firmware_start,
@@ -76,3 +85,24 @@ TEST_CASE("LP-Core Shared-mem", "[lp_core]")
printf("HP shared memory test passed\n"); 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

@@ -30,3 +30,12 @@ def test_lp_core_shared_mem(dut: Dut) -> None:
dut.expect_exact('ULP shared memory test passed') dut.expect_exact('ULP shared memory test passed')
dut.expect_exact('HP 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')