mirror of
https://github.com/espressif/esp-idf
synced 2025-03-10 09:39:10 -04:00
newlib: Add ESP_ROM_HAS_RETARGETABLE_LOCKING capability for C3 and S3 chips
This commit is contained in:
parent
5a982ffe7a
commit
b46b50eaa6
@ -9,7 +9,7 @@ if(CONFIG_IDF_TARGET_ARCH_XTENSA)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
idf_component_register(SRCS ${sources}
|
idf_component_register(SRCS ${sources}
|
||||||
INCLUDE_DIRS include "${target}"
|
INCLUDE_DIRS include "${target}" "include/${target}"
|
||||||
PRIV_REQUIRES soc hal)
|
PRIV_REQUIRES soc hal)
|
||||||
|
|
||||||
# Append a target linker script at the target-specific path,
|
# Append a target linker script at the target-specific path,
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
COMPONENT_ADD_INCLUDEDIRS := include esp32
|
COMPONENT_ADD_INCLUDEDIRS := include esp32 include/esp32
|
||||||
COMPONENT_SRCDIRS := patches .
|
COMPONENT_SRCDIRS := patches .
|
||||||
|
|
||||||
#Linker scripts used to link the final application.
|
#Linker scripts used to link the final application.
|
||||||
|
@ -19,3 +19,4 @@
|
|||||||
#define ESP_ROM_HAS_JPEG_DECODE (1) // ROM has JPEG decode library
|
#define ESP_ROM_HAS_JPEG_DECODE (1) // ROM has JPEG decode library
|
||||||
#define ESP_ROM_UART_CLK_IS_XTAL (1) // UART clock source is selected to XTAL in ROM
|
#define ESP_ROM_UART_CLK_IS_XTAL (1) // UART clock source is selected to XTAL in ROM
|
||||||
#define ESP_ROM_USB_SERIAL_DEVICE_NUM (3) // UART uses USB_SERIAL_JTAG port in ROM.
|
#define ESP_ROM_USB_SERIAL_DEVICE_NUM (3) // UART uses USB_SERIAL_JTAG port in ROM.
|
||||||
|
#define ESP_ROM_HAS_RETARGETABLE_LOCKING (1) // ROM was built with retargetable locking
|
||||||
|
@ -19,3 +19,4 @@
|
|||||||
#define ESP_ROM_HAS_JPEG_DECODE (1) // ROM has JPEG decode library
|
#define ESP_ROM_HAS_JPEG_DECODE (1) // ROM has JPEG decode library
|
||||||
#define ESP_ROM_SUPPORT_MULTIPLE_UART (1) // ROM has multiple UARTs available for logging
|
#define ESP_ROM_SUPPORT_MULTIPLE_UART (1) // ROM has multiple UARTs available for logging
|
||||||
#define ESP_ROM_UART_CLK_IS_XTAL (1) // UART clock source is selected to XTAL in ROM
|
#define ESP_ROM_UART_CLK_IS_XTAL (1) // UART clock source is selected to XTAL in ROM
|
||||||
|
#define ESP_ROM_HAS_RETARGETABLE_LOCKING (1) // ROM was built with retargetable locking
|
||||||
|
@ -27,7 +27,7 @@ extern "C" {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
ESP32 ROM code contains implementations of some of C library functions.
|
ESP32-C3 ROM code contains implementations of some of C library functions.
|
||||||
Whenever a function in ROM needs to use a syscall, it calls a pointer to the corresponding syscall
|
Whenever a function in ROM needs to use a syscall, it calls a pointer to the corresponding syscall
|
||||||
implementation defined in the following struct.
|
implementation defined in the following struct.
|
||||||
|
|
||||||
@ -65,7 +65,6 @@ struct syscall_stub_table
|
|||||||
int (*_write_r)(struct _reent *r, int, const void *, int);
|
int (*_write_r)(struct _reent *r, int, const void *, int);
|
||||||
int (*_lseek_r)(struct _reent *r, int, int, int);
|
int (*_lseek_r)(struct _reent *r, int, int, int);
|
||||||
int (*_read_r)(struct _reent *r, int, void *, int);
|
int (*_read_r)(struct _reent *r, int, void *, int);
|
||||||
#ifdef _RETARGETABLE_LOCKING
|
|
||||||
void (*_retarget_lock_init)(_LOCK_T *lock);
|
void (*_retarget_lock_init)(_LOCK_T *lock);
|
||||||
void (*_retarget_lock_init_recursive)(_LOCK_T *lock);
|
void (*_retarget_lock_init_recursive)(_LOCK_T *lock);
|
||||||
void (*_retarget_lock_close)(_LOCK_T lock);
|
void (*_retarget_lock_close)(_LOCK_T lock);
|
||||||
@ -76,18 +75,6 @@ struct syscall_stub_table
|
|||||||
int (*_retarget_lock_try_acquire_recursive)(_LOCK_T lock);
|
int (*_retarget_lock_try_acquire_recursive)(_LOCK_T lock);
|
||||||
void (*_retarget_lock_release)(_LOCK_T lock);
|
void (*_retarget_lock_release)(_LOCK_T lock);
|
||||||
void (*_retarget_lock_release_recursive)(_LOCK_T lock);
|
void (*_retarget_lock_release_recursive)(_LOCK_T lock);
|
||||||
#else
|
|
||||||
void (*_lock_init)(_lock_t *lock);
|
|
||||||
void (*_lock_init_recursive)(_lock_t *lock);
|
|
||||||
void (*_lock_close)(_lock_t *lock);
|
|
||||||
void (*_lock_close_recursive)(_lock_t *lock);
|
|
||||||
void (*_lock_acquire)(_lock_t *lock);
|
|
||||||
void (*_lock_acquire_recursive)(_lock_t *lock);
|
|
||||||
int (*_lock_try_acquire)(_lock_t *lock);
|
|
||||||
int (*_lock_try_acquire_recursive)(_lock_t *lock);
|
|
||||||
void (*_lock_release)(_lock_t *lock);
|
|
||||||
void (*_lock_release_recursive)(_lock_t *lock);
|
|
||||||
#endif
|
|
||||||
int (*_printf_float)(struct _reent *data, void *pdata, FILE * fp, int (*pfunc) (struct _reent *, FILE *, const char *, size_t len), va_list * ap);
|
int (*_printf_float)(struct _reent *data, void *pdata, FILE * fp, int (*pfunc) (struct _reent *, FILE *, const char *, size_t len), va_list * ap);
|
||||||
int (*_scanf_float) (struct _reent *rptr, void *pdata, FILE *fp, va_list *ap);
|
int (*_scanf_float) (struct _reent *rptr, void *pdata, FILE *fp, va_list *ap);
|
||||||
void (*__assert_func) (const char *file, int line, const char * func, const char *failedexpr) __attribute__((noreturn));
|
void (*__assert_func) (const char *file, int line, const char * func, const char *failedexpr) __attribute__((noreturn));
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <sys/lock.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@ -65,7 +66,6 @@ struct syscall_stub_table
|
|||||||
int (*_write_r)(struct _reent *r, int, const void *, int);
|
int (*_write_r)(struct _reent *r, int, const void *, int);
|
||||||
int (*_lseek_r)(struct _reent *r, int, int, int);
|
int (*_lseek_r)(struct _reent *r, int, int, int);
|
||||||
int (*_read_r)(struct _reent *r, int, void *, int);
|
int (*_read_r)(struct _reent *r, int, void *, int);
|
||||||
#ifdef _RETARGETABLE_LOCKING
|
|
||||||
void (*_retarget_lock_init)(_LOCK_T *lock);
|
void (*_retarget_lock_init)(_LOCK_T *lock);
|
||||||
void (*_retarget_lock_init_recursive)(_LOCK_T *lock);
|
void (*_retarget_lock_init_recursive)(_LOCK_T *lock);
|
||||||
void (*_retarget_lock_close)(_LOCK_T lock);
|
void (*_retarget_lock_close)(_LOCK_T lock);
|
||||||
@ -76,18 +76,6 @@ struct syscall_stub_table
|
|||||||
int (*_retarget_lock_try_acquire_recursive)(_LOCK_T lock);
|
int (*_retarget_lock_try_acquire_recursive)(_LOCK_T lock);
|
||||||
void (*_retarget_lock_release)(_LOCK_T lock);
|
void (*_retarget_lock_release)(_LOCK_T lock);
|
||||||
void (*_retarget_lock_release_recursive)(_LOCK_T lock);
|
void (*_retarget_lock_release_recursive)(_LOCK_T lock);
|
||||||
#else
|
|
||||||
void (*_lock_init)(_lock_t *lock);
|
|
||||||
void (*_lock_init_recursive)(_lock_t *lock);
|
|
||||||
void (*_lock_close)(_lock_t *lock);
|
|
||||||
void (*_lock_close_recursive)(_lock_t *lock);
|
|
||||||
void (*_lock_acquire)(_lock_t *lock);
|
|
||||||
void (*_lock_acquire_recursive)(_lock_t *lock);
|
|
||||||
int (*_lock_try_acquire)(_lock_t *lock);
|
|
||||||
int (*_lock_try_acquire_recursive)(_lock_t *lock);
|
|
||||||
void (*_lock_release)(_lock_t *lock);
|
|
||||||
void (*_lock_release_recursive)(_lock_t *lock);
|
|
||||||
#endif
|
|
||||||
int (*_printf_float)(struct _reent *data, void *pdata, FILE * fp, int (*pfunc) (struct _reent *, FILE *, const char *, size_t len), va_list * ap);
|
int (*_printf_float)(struct _reent *data, void *pdata, FILE * fp, int (*pfunc) (struct _reent *, FILE *, const char *, size_t len), va_list * ap);
|
||||||
int (*_scanf_float) (struct _reent *rptr, void *pdata, FILE *fp, va_list *ap);
|
int (*_scanf_float) (struct _reent *rptr, void *pdata, FILE *fp, va_list *ap);
|
||||||
void (*__assert_func) (const char *file, int line, const char * func, const char *failedexpr) __attribute__((noreturn));
|
void (*__assert_func) (const char *file, int line, const char * func, const char *failedexpr) __attribute__((noreturn));
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
#include "freertos/semphr.h"
|
#include "freertos/semphr.h"
|
||||||
#include "freertos/task.h"
|
#include "freertos/task.h"
|
||||||
#include "freertos/portable.h"
|
#include "freertos/portable.h"
|
||||||
|
#include "esp_rom_caps.h"
|
||||||
|
|
||||||
/* Notes on our newlib lock implementation:
|
/* Notes on our newlib lock implementation:
|
||||||
*
|
*
|
||||||
@ -210,7 +211,6 @@ void IRAM_ATTR _lock_release_recursive(_lock_t *lock) {
|
|||||||
lock_release_generic(lock, queueQUEUE_TYPE_RECURSIVE_MUTEX);
|
lock_release_generic(lock, queueQUEUE_TYPE_RECURSIVE_MUTEX);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef _RETARGETABLE_LOCKING
|
|
||||||
/* To ease the transition to newlib 3.3.0, this part is kept under an ifdef.
|
/* To ease the transition to newlib 3.3.0, this part is kept under an ifdef.
|
||||||
* After the toolchain with newlib 3.3.0 is released and merged, the ifdefs
|
* After the toolchain with newlib 3.3.0 is released and merged, the ifdefs
|
||||||
* can be removed.
|
* can be removed.
|
||||||
@ -252,8 +252,8 @@ static StaticSemaphore_t s_common_mutex;
|
|||||||
static StaticSemaphore_t s_common_recursive_mutex;
|
static StaticSemaphore_t s_common_recursive_mutex;
|
||||||
|
|
||||||
|
|
||||||
#ifdef CONFIG_IDF_TARGET_ESP32C3
|
#if defined(CONFIG_IDF_TARGET_ESP32C3) || defined(CONFIG_IDF_TARGET_ESP32S3)
|
||||||
/* C3 ROM is built without Newlib static lock symbols exported, and
|
/* C3 and S3 ROMs are built without Newlib static lock symbols exported, and
|
||||||
* with an extra level of _LOCK_T indirection in mind.
|
* with an extra level of _LOCK_T indirection in mind.
|
||||||
* The following is a workaround for this:
|
* The following is a workaround for this:
|
||||||
* - on startup, we call esp_rom_newlib_init_common_mutexes to set
|
* - on startup, we call esp_rom_newlib_init_common_mutexes to set
|
||||||
@ -267,7 +267,7 @@ static StaticSemaphore_t s_common_recursive_mutex;
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#define ROM_NEEDS_MUTEX_OVERRIDE
|
#define ROM_NEEDS_MUTEX_OVERRIDE
|
||||||
#endif // CONFIG_IDF_TARGET_ESP32C3
|
#endif // defined(CONFIG_IDF_TARGET_ESP32C3) || defined(CONFIG_IDF_TARGET_ESP32S3)
|
||||||
|
|
||||||
#ifdef ROM_NEEDS_MUTEX_OVERRIDE
|
#ifdef ROM_NEEDS_MUTEX_OVERRIDE
|
||||||
#define ROM_MUTEX_MAGIC 0xbb10c433
|
#define ROM_MUTEX_MAGIC 0xbb10c433
|
||||||
@ -407,11 +407,3 @@ void esp_newlib_locks_init(void)
|
|||||||
#error Unsupported target
|
#error Unsupported target
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#else // _RETARGETABLE_LOCKING
|
|
||||||
|
|
||||||
void esp_newlib_locks_init(void)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // _RETARGETABLE_LOCKING
|
|
||||||
|
@ -27,6 +27,7 @@
|
|||||||
#include "esp_attr.h"
|
#include "esp_attr.h"
|
||||||
#include "sdkconfig.h"
|
#include "sdkconfig.h"
|
||||||
#include "soc/soc_caps.h"
|
#include "soc/soc_caps.h"
|
||||||
|
#include "esp_rom_caps.h"
|
||||||
|
|
||||||
#if CONFIG_IDF_TARGET_ESP32
|
#if CONFIG_IDF_TARGET_ESP32
|
||||||
#include "esp32/rom/libc_stubs.h"
|
#include "esp32/rom/libc_stubs.h"
|
||||||
@ -82,7 +83,7 @@ static struct syscall_stub_table s_stub_table = {
|
|||||||
._write_r = (int (*)(struct _reent *r, int, const void *, int)) &_write_r,
|
._write_r = (int (*)(struct _reent *r, int, const void *, int)) &_write_r,
|
||||||
._lseek_r = (int (*)(struct _reent *r, int, int, int)) &_lseek_r,
|
._lseek_r = (int (*)(struct _reent *r, int, int, int)) &_lseek_r,
|
||||||
._read_r = (int (*)(struct _reent *r, int, void *, int)) &_read_r,
|
._read_r = (int (*)(struct _reent *r, int, void *, int)) &_read_r,
|
||||||
#if _RETARGETABLE_LOCKING /* TODO: only if RETARGETABLE LOCKING IS IN ROM */
|
#if ESP_ROM_HAS_RETARGETABLE_LOCKING
|
||||||
._retarget_lock_init = &__retarget_lock_init,
|
._retarget_lock_init = &__retarget_lock_init,
|
||||||
._retarget_lock_init_recursive = &__retarget_lock_init_recursive,
|
._retarget_lock_init_recursive = &__retarget_lock_init_recursive,
|
||||||
._retarget_lock_close = &__retarget_lock_close,
|
._retarget_lock_close = &__retarget_lock_close,
|
||||||
|
@ -141,7 +141,7 @@ TEST_CASE("check if ROM or Flash is used for functions", "[newlib]")
|
|||||||
#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));
|
||||||
TEST_ASSERT(fn_in_rom(strtol));
|
TEST_ASSERT(fn_in_rom(strtol));
|
||||||
#elif defined(CONFIG_IDF_TARGET_ESP32C3) || defined(CONFIG_IDF_TARGET_ESP32C3)
|
#elif defined(CONFIG_IDF_TARGET_ESP32C3) || defined(CONFIG_IDF_TARGET_ESP32S3)
|
||||||
/* S3 and C3 always use these from ROM */
|
/* S3 and C3 always use these from ROM */
|
||||||
TEST_ASSERT(fn_in_rom(atoi));
|
TEST_ASSERT(fn_in_rom(atoi));
|
||||||
TEST_ASSERT(fn_in_rom(strtol));
|
TEST_ASSERT(fn_in_rom(strtol));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user