Skip to content

Commit

Permalink
Merge branch 'bugfix/p4_ld_newlib_api_v5.3' into 'release/v5.3'
Browse files Browse the repository at this point in the history
fix(lp_core): updated lp rom newlib API addresses (v5.3)

See merge request espressif/esp-idf!34480
  • Loading branch information
Jiang Jiang Jian committed Nov 14, 2024
2 parents 004e1b5 + f3557bc commit d819f0c
Show file tree
Hide file tree
Showing 5 changed files with 189 additions and 60 deletions.
118 changes: 59 additions & 59 deletions components/esp_rom/esp32p4/ld/esp32p4lp.rom.newlib.ld
Original file line number Diff line number Diff line change
@@ -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
*/
/* 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.
*
Expand All @@ -18,60 +18,60 @@
***************************************/

/* Functions */
memset = 0x501000f0;
memcpy = 0x501000f4;
memmove = 0x501000f8;
memcmp = 0x501000fc;
strcpy = 0x50100100;
strncpy = 0x50100104;
strcmp = 0x50100108;
strncmp = 0x5010010c;
strlen = 0x50100110;
strstr = 0x50100114;
bzero = 0x50100118;
isalnum = 0x5010011c;
isalpha = 0x50100120;
isascii = 0x50100124;
isblank = 0x50100128;
iscntrl = 0x5010012c;
isdigit = 0x50100130;
islower = 0x50100134;
isgraph = 0x50100138;
isprint = 0x5010013c;
ispunct = 0x50100140;
isspace = 0x50100144;
isupper = 0x50100148;
toupper = 0x5010014c;
tolower = 0x50100150;
toascii = 0x50100154;
memccpy = 0x50100158;
memchr = 0x5010015c;
memrchr = 0x50100160;
strcasecmp = 0x50100164;
strcasestr = 0x50100168;
strcat = 0x5010016c;
strchr = 0x50100170;
strcspn = 0x50100174;
strcoll = 0x50100178;
strlcat = 0x5010017c;
strlcpy = 0x50100180;
strlwr = 0x50100184;
strncasecmp = 0x50100188;
strncat = 0x5010018c;
strnlen = 0x50100190;
strrchr = 0x50100194;
strsep = 0x50100198;
strspn = 0x5010019c;
strtok_r = 0x501001a0;
strupr = 0x501001a4;
longjmp = 0x501001a8;
setjmp = 0x501001ac;
abs = 0x501001b0;
div = 0x501001b4;
labs = 0x501001b8;
ldiv = 0x501001bc;
qsort = 0x501001c0;
atoi = 0x501001c4;
atol = 0x501001c8;
itoa = 0x501001cc;
utoa = 0x501001d0;
memset = 0x50100134;
memcpy = 0x50100138;
memmove = 0x5010013c;
memcmp = 0x50100140;
strcpy = 0x50100144;
strncpy = 0x50100148;
strcmp = 0x5010014c;
strncmp = 0x50100150;
strlen = 0x50100154;
strstr = 0x50100158;
bzero = 0x5010015c;
isalnum = 0x50100160;
isalpha = 0x50100164;
isascii = 0x50100168;
isblank = 0x5010016c;
iscntrl = 0x50100170;
isdigit = 0x50100174;
islower = 0x50100178;
isgraph = 0x5010017c;
isprint = 0x50100180;
ispunct = 0x50100184;
isspace = 0x50100188;
isupper = 0x5010018c;
toupper = 0x50100190;
tolower = 0x50100194;
toascii = 0x50100198;
memccpy = 0x5010019c;
memchr = 0x501001a0;
memrchr = 0x501001a4;
strcasecmp = 0x501001a8;
strcasestr = 0x501001ac;
strcat = 0x501001b0;
strchr = 0x501001b4;
strcspn = 0x501001b8;
strcoll = 0x501001bc;
strlcat = 0x501001c0;
strlcpy = 0x501001c4;
strlwr = 0x501001c8;
strncasecmp = 0x501001cc;
strncat = 0x501001d0;
strnlen = 0x501001d4;
strrchr = 0x501001d8;
strsep = 0x501001dc;
strspn = 0x501001e0;
strtok_r = 0x501001e4;
strupr = 0x501001e8;
longjmp = 0x501001ec;
setjmp = 0x501001f0;
abs = 0x501001f4;
div = 0x501001f8;
labs = 0x501001fc;
ldiv = 0x50100200;
qsort = 0x50100204;
atoi = 0x50100208;
atol = 0x5010020c;
itoa = 0x50100210;
utoa = 0x50100214;
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
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_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"
Expand All @@ -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_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()
Original file line number Diff line number Diff line change
@@ -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;
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,21 @@
#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");

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,
Expand Down Expand Up @@ -76,3 +85,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
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,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')

0 comments on commit d819f0c

Please sign in to comment.