mirror of
https://github.com/espressif/esp-idf
synced 2025-03-09 17:19:09 -04:00
newlib: ROM library is build with time_t 64bit on esp32c2
This commit is contained in:
parent
44909aff93
commit
6eb450fa87
@ -194,10 +194,16 @@ else() # Regular app build
|
|||||||
rom_linker_script("version")
|
rom_linker_script("version")
|
||||||
rom_linker_script("mbedtls")
|
rom_linker_script("mbedtls")
|
||||||
|
|
||||||
if(CONFIG_NEWLIB_NANO_FORMAT AND time_t_size EQUAL 4)
|
if(time_t_size EQUAL 8)
|
||||||
# nano formatting functions in ROM are built for 32-bit time_t,
|
# The ROM functions listed in this linker script depend on sizeof(time_t).
|
||||||
# only link them if the toolchain is also using 32-bit time_t and nano formatting was requested.
|
# Since ROM for ESP32-C2 was compiled for 64-bit time_t, only link these functions
|
||||||
rom_linker_script("newlib-nano")
|
# if the toolchain is also using 64-bit time_t.
|
||||||
|
rom_linker_script("newlib-time")
|
||||||
|
|
||||||
|
if(CONFIG_NEWLIB_NANO_FORMAT)
|
||||||
|
# nano formatting functions in ROM are also built for 64-bit time_t.
|
||||||
|
rom_linker_script("newlib-nano")
|
||||||
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(CONFIG_HEAP_TLSF_USE_ROM_IMPL)
|
if(CONFIG_HEAP_TLSF_USE_ROM_IMPL)
|
||||||
|
16
components/esp_rom/esp32c2/ld/esp32c2.rom.newlib-time.ld
Normal file
16
components/esp_rom/esp32c2/ld/esp32c2.rom.newlib-time.ld
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
/*
|
||||||
|
* SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
|
*/
|
||||||
|
/* These are the newlib functions and the .bss/.data symbols which are related to 'time_t'
|
||||||
|
or other structures which include 'time_t' (like 'struct stat').
|
||||||
|
These ROM functions were compiled with sizeof(time_t) == 8.
|
||||||
|
When compiling with sizeof(time_t) == 4, these functions should be excluded from the build.
|
||||||
|
*/
|
||||||
|
asctime = 0x40000638;
|
||||||
|
asctime_r = 0x4000063c;
|
||||||
|
_isatty_r = 0x400004b4;
|
||||||
|
PROVIDE( __smakebuf_r = 0x400005a0 );
|
||||||
|
PROVIDE( __swhatbuf_r = 0x400005a4 );
|
||||||
|
PROVIDE( __swsetup_r = 0x400005b0 );
|
@ -30,7 +30,6 @@ strncmp = 0x400004a4;
|
|||||||
strlen = 0x400004a8;
|
strlen = 0x400004a8;
|
||||||
strstr = 0x400004ac;
|
strstr = 0x400004ac;
|
||||||
bzero = 0x400004b0;
|
bzero = 0x400004b0;
|
||||||
_isatty_r = 0x400004b4;
|
|
||||||
sbrk = 0x400004b8;
|
sbrk = 0x400004b8;
|
||||||
isalnum = 0x400004bc;
|
isalnum = 0x400004bc;
|
||||||
isalpha = 0x400004c0;
|
isalpha = 0x400004c0;
|
||||||
@ -89,11 +88,8 @@ fflush = 0x40000590;
|
|||||||
_fflush_r = 0x40000594;
|
_fflush_r = 0x40000594;
|
||||||
_fwalk = 0x40000598;
|
_fwalk = 0x40000598;
|
||||||
_fwalk_reent = 0x4000059c;
|
_fwalk_reent = 0x4000059c;
|
||||||
__smakebuf_r = 0x400005a0;
|
|
||||||
__swhatbuf_r = 0x400005a4;
|
|
||||||
__swbuf_r = 0x400005a8;
|
__swbuf_r = 0x400005a8;
|
||||||
__swbuf = 0x400005ac;
|
__swbuf = 0x400005ac;
|
||||||
__swsetup_r = 0x400005b0;
|
|
||||||
_strtod_l = 0x400005b4;
|
_strtod_l = 0x400005b4;
|
||||||
_strtod_r = 0x400005b8;
|
_strtod_r = 0x400005b8;
|
||||||
strtod_l = 0x400005bc;
|
strtod_l = 0x400005bc;
|
||||||
@ -127,8 +123,6 @@ __ratio = 0x40000628;
|
|||||||
_mprec_log10 = 0x4000062c;
|
_mprec_log10 = 0x4000062c;
|
||||||
__copybits = 0x40000630;
|
__copybits = 0x40000630;
|
||||||
__any_on = 0x40000634;
|
__any_on = 0x40000634;
|
||||||
asctime = 0x40000638;
|
|
||||||
asctime_r = 0x4000063c;
|
|
||||||
atof = 0x40000640;
|
atof = 0x40000640;
|
||||||
atoff = 0x40000644;
|
atoff = 0x40000644;
|
||||||
_dtoa_r = 0x40000648;
|
_dtoa_r = 0x40000648;
|
||||||
|
@ -126,17 +126,17 @@ static bool fn_in_rom(void *fn)
|
|||||||
|
|
||||||
TEST_CASE("check if ROM or Flash is used for functions", "[newlib]")
|
TEST_CASE("check if ROM or Flash is used for functions", "[newlib]")
|
||||||
{
|
{
|
||||||
#if CONFIG_NEWLIB_NANO_FORMAT && (CONFIG_IDF_TARGET_ESP32 || CONFIG_IDF_TARGET_ESP32C2)
|
#if CONFIG_NEWLIB_NANO_FORMAT
|
||||||
TEST_ASSERT(fn_in_rom(vfprintf));
|
TEST_ASSERT(fn_in_rom(vfprintf));
|
||||||
#else
|
#else
|
||||||
TEST_ASSERT_FALSE(fn_in_rom(vfprintf));
|
TEST_ASSERT_FALSE(fn_in_rom(vfprintf));
|
||||||
#endif // CONFIG_NEWLIB_NANO_FORMAT && CONFIG_IDF_TARGETx
|
#endif // CONFIG_NEWLIB_NANO_FORMAT
|
||||||
|
|
||||||
#if defined(CONFIG_NEWLIB_NANO_FORMAT)
|
#if CONFIG_NEWLIB_NANO_FORMAT && (CONFIG_IDF_TARGET_ESP32 || CONFIG_IDF_TARGET_ESP32C2 || CONFIG_IDF_TARGET_ESP32H2)
|
||||||
TEST_ASSERT(fn_in_rom(sscanf));
|
TEST_ASSERT(fn_in_rom(sscanf));
|
||||||
#else
|
#else
|
||||||
TEST_ASSERT_FALSE(fn_in_rom(sscanf));
|
TEST_ASSERT_FALSE(fn_in_rom(sscanf));
|
||||||
#endif // CONFIG_NEWLIB_NANO_FORMAT
|
#endif // CONFIG_NEWLIB_NANO_FORMAT && CONFIG_IDF_TARGET_x
|
||||||
|
|
||||||
#if defined(CONFIG_IDF_TARGET_ESP32) && !defined(CONFIG_SPIRAM)
|
#if defined(CONFIG_IDF_TARGET_ESP32) && !defined(CONFIG_SPIRAM)
|
||||||
TEST_ASSERT(fn_in_rom(atoi));
|
TEST_ASSERT(fn_in_rom(atoi));
|
||||||
|
@ -450,7 +450,9 @@ static struct timeval get_time(const char *desc, char *buffer)
|
|||||||
gettimeofday(×tamp, NULL);
|
gettimeofday(×tamp, NULL);
|
||||||
struct tm* tm_info = localtime(×tamp.tv_sec);
|
struct tm* tm_info = localtime(×tamp.tv_sec);
|
||||||
strftime(buffer, 32, "%c", tm_info);
|
strftime(buffer, 32, "%c", tm_info);
|
||||||
|
#if !CONFIG_NEWLIB_NANO_FORMAT
|
||||||
ESP_LOGI("TAG", "%s: %016llX (%s)", desc, timestamp.tv_sec, buffer);
|
ESP_LOGI("TAG", "%s: %016llX (%s)", desc, timestamp.tv_sec, buffer);
|
||||||
|
#endif
|
||||||
return timestamp;
|
return timestamp;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -462,7 +464,9 @@ TEST_CASE("test time_t wide 64 bits", "[newlib]")
|
|||||||
|
|
||||||
struct tm tm = {4, 14, 3, 19, 0, 138, 0, 0, 0};
|
struct tm tm = {4, 14, 3, 19, 0, 138, 0, 0, 0};
|
||||||
struct timeval timestamp = { mktime(&tm), 0 };
|
struct timeval timestamp = { mktime(&tm), 0 };
|
||||||
|
#if !CONFIG_NEWLIB_NANO_FORMAT
|
||||||
ESP_LOGI("TAG", "timestamp: %016llX", timestamp.tv_sec);
|
ESP_LOGI("TAG", "timestamp: %016llX", timestamp.tv_sec);
|
||||||
|
#endif
|
||||||
settimeofday(×tamp, NULL);
|
settimeofday(×tamp, NULL);
|
||||||
get_time("Set time", buffer);
|
get_time("Set time", buffer);
|
||||||
|
|
||||||
@ -494,7 +498,9 @@ TEST_CASE("test time functions wide 64 bits", "[newlib]")
|
|||||||
localtime_r(&now, &timeinfo);
|
localtime_r(&now, &timeinfo);
|
||||||
|
|
||||||
time_t t = mktime(&timeinfo);
|
time_t t = mktime(&timeinfo);
|
||||||
|
#if !CONFIG_NEWLIB_NANO_FORMAT
|
||||||
ESP_LOGI("TAG", "Test mktime(). Time: %016llX", t);
|
ESP_LOGI("TAG", "Test mktime(). Time: %016llX", t);
|
||||||
|
#endif
|
||||||
TEST_ASSERT_EQUAL(timestamp.tv_sec, t);
|
TEST_ASSERT_EQUAL(timestamp.tv_sec, t);
|
||||||
// mktime() has error in newlib-3.0.0. It fixed in newlib-3.0.0.20180720
|
// mktime() has error in newlib-3.0.0. It fixed in newlib-3.0.0.20180720
|
||||||
TEST_ASSERT_EQUAL((timestamp.tv_sec >> 32), (t >> 32));
|
TEST_ASSERT_EQUAL((timestamp.tv_sec >> 32), (t >> 32));
|
||||||
|
@ -59,6 +59,7 @@ GDB_REGS_INFO_RISCV_ILP32 = [
|
|||||||
|
|
||||||
GDB_REGS_INFO = {
|
GDB_REGS_INFO = {
|
||||||
'esp32c3': GDB_REGS_INFO_RISCV_ILP32,
|
'esp32c3': GDB_REGS_INFO_RISCV_ILP32,
|
||||||
|
'esp32c2': GDB_REGS_INFO_RISCV_ILP32,
|
||||||
'esp32h2': GDB_REGS_INFO_RISCV_ILP32
|
'esp32h2': GDB_REGS_INFO_RISCV_ILP32
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -152,6 +153,7 @@ def parse_idf_riscv_panic_output(panic_text): # type: (str) -> PanicInfo
|
|||||||
|
|
||||||
PANIC_OUTPUT_PARSERS = {
|
PANIC_OUTPUT_PARSERS = {
|
||||||
'esp32c3': parse_idf_riscv_panic_output,
|
'esp32c3': parse_idf_riscv_panic_output,
|
||||||
|
'esp32c2': parse_idf_riscv_panic_output,
|
||||||
'esp32h2': parse_idf_riscv_panic_output
|
'esp32h2': parse_idf_riscv_panic_output
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user