diff --git a/components/esp8266/source/startup.c b/components/esp8266/source/startup.c index 0f7c6358..95f16265 100644 --- a/components/esp8266/source/startup.c +++ b/components/esp8266/source/startup.c @@ -34,7 +34,7 @@ #include "FreeRTOS.h" #include "task.h" -#if defined(CONFIG_NEWLIB_LIBRARY_LEVEL_NORMAL) || defined(CONFIG_NEWLIB_LIBRARY_LEVEL_NANO) +#ifndef CONFIG_NEWLIB_LIBRARY_CUSTOMER #include "esp_newlib.h" #endif @@ -163,7 +163,7 @@ void call_start_cpu(size_t start_addr) assert(__esp_os_init() == 0); #endif -#if defined(CONFIG_NEWLIB_LIBRARY_LEVEL_NORMAL) || defined(CONFIG_NEWLIB_LIBRARY_LEVEL_NANO) +#ifndef CONFIG_NEWLIB_LIBRARY_CUSTOMER esp_newlib_init(); #endif diff --git a/components/freertos/port/esp8266/include/freertos/portmacro.h b/components/freertos/port/esp8266/include/freertos/portmacro.h index 673c16b2..4abc6267 100644 --- a/components/freertos/port/esp8266/include/freertos/portmacro.h +++ b/components/freertos/port/esp8266/include/freertos/portmacro.h @@ -42,7 +42,7 @@ extern "C" { #include "xtensa_rtos.h" #if defined(configUSE_NEWLIB_REENTRANT) && configUSE_NEWLIB_REENTRANT == 1 -#if defined(CONFIG_NEWLIB_LIBRARY_LEVEL_NORMAL) || defined(CONFIG_NEWLIB_LIBRARY_LEVEL_NANO) +#ifndef CONFIG_NEWLIB_LIBRARY_CUSTOMER #include "esp_newlib.h" #define _impure_ptr _global_impure_ptr diff --git a/components/newlib/CMakeLists.txt b/components/newlib/CMakeLists.txt index 9a002cba..ec17652a 100644 --- a/components/newlib/CMakeLists.txt +++ b/components/newlib/CMakeLists.txt @@ -1,5 +1,5 @@ set(COMPONENT_SRCDIRS newlib/port) -set(COMPONENT_ADD_INCLUDEDIRS newlib/include newlib/port/include) +set(COMPONENT_ADD_INCLUDEDIRS newlib/port/include newlib/include) if(CONFIG_NEWLIB_LIBRARY_LEVEL_NANO) diff --git a/components/newlib/Kconfig b/components/newlib/Kconfig index 14d11fc5..64329ff8 100644 --- a/components/newlib/Kconfig +++ b/components/newlib/Kconfig @@ -1,18 +1,8 @@ menu "Newlib" -config NEWLIB_ENABLE - bool "Enable newlib" - default y - help - If you need use you own C library, make this option disable. The libraries and - header files at this component will not be used. - - Note: ABI of the C library of your own must be same as SDK. - choice NEWLIB_LIBRARY_LEVEL prompt "newlib level" default NEWLIB_LIBRARY_LEVEL_FLOAT_NANO - depends on NEWLIB_ENABLE help Choose newlib library level. @@ -50,6 +40,14 @@ config NEWLIB_LIBRARY_LEVEL_FLOAT_NANO If you do not need 64-bit integer formatting support and C99 features, but need float formats, select this option. +config NEWLIB_LIBRARY_CUSTOMER + bool "customer" + help + If you need use you own C library, select this option. The libraries and + header files at this component will not be used. + + Note: ABI of the C library of your own must be same as SDK. + endchoice endmenu diff --git a/components/newlib/Makefile.projbuild b/components/newlib/Makefile.projbuild index bdb60c01..4b16af7f 100644 --- a/components/newlib/Makefile.projbuild +++ b/components/newlib/Makefile.projbuild @@ -1,2 +1,9 @@ -CFLAGS += -D_CLOCKS_PER_SEC_=CONFIG_FREERTOS_HZ -D_POSIX_THREADS=1 -D_UNIX98_THREAD_MUTEX_ATTRIBUTES=1 -CPPFLAGS += -D_CLOCKS_PER_SEC_=CONFIG_FREERTOS_HZ -D_POSIX_THREADS=1 -D_UNIX98_THREAD_MUTEX_ATTRIBUTES=1 +ifndef CONFIG_NEWLIB_LIBRARY_CUSTOMER + +NEWLIB_FLAGS := -D_CLOCKS_PER_SEC_=CONFIG_FREERTOS_HZ \ + -D_POSIX_THREADS=1 \ + -D_UNIX98_THREAD_MUTEX_ATTRIBUTES=1 + +CFLAGS += $(NEWLIB_FLAGS) +CPPFLAGS += $(NEWLIB_FLAGS) +endif diff --git a/components/newlib/component.mk b/components/newlib/component.mk index 9a3a4851..b432f4dd 100644 --- a/components/newlib/component.mk +++ b/components/newlib/component.mk @@ -1,38 +1,23 @@ # # Component Makefile # -COMPONENT_SRCDIRS := . - -ifdef CONFIG_NEWLIB_ENABLE - -ADD_NEW_NEWLIB := 0 +ifndef CONFIG_NEWLIB_LIBRARY_CUSTOMER ifdef CONFIG_NEWLIB_LIBRARY_LEVEL_NORMAL -LIBC_PATH := $(COMPONENT_PATH)/newlib/lib/libc.a -LIBM_PATH := $(COMPONENT_PATH)/newlib/lib/libm.a -ADD_NEW_NEWLIB := 1 -else -ifdef CONFIG_NEWLIB_LIBRARY_LEVEL_NANO -LIBC_PATH := $(COMPONENT_PATH)/newlib/lib/libc_nano.a -LIBM_PATH := $(COMPONENT_PATH)/newlib/lib/libm.a -ADD_NEW_NEWLIB := 1 -else -ifdef CONFIG_NEWLIB_LIBRARY_LEVEL_FLOAT_NANO -LIBC_PATH := $(COMPONENT_PATH)/newlib/lib/libc_fnano.a -LIBM_PATH := $(COMPONENT_PATH)/newlib/lib/libm.a -ADD_NEW_NEWLIB := 1 -endif -endif +LIB_PATH := $(COMPONENT_PATH)/newlib/lib/libc.a $(COMPONENT_PATH)/newlib/lib/libm.a +else ifdef CONFIG_NEWLIB_LIBRARY_LEVEL_NANO +LIB_PATH := $(COMPONENT_PATH)/newlib/lib/libc_nano.a $(COMPONENT_PATH)/newlib/lib/libm.a +else ifdef CONFIG_NEWLIB_LIBRARY_LEVEL_FLOAT_NANO +LIB_PATH := $(COMPONENT_PATH)/newlib/lib/libc_fnano.a $(COMPONENT_PATH)/newlib/lib/libm.a endif -ifeq ($(ADD_NEW_NEWLIB),1) -COMPONENT_ADD_INCLUDEDIRS += newlib/include newlib/port/include +COMPONENT_ADD_INCLUDEDIRS += newlib/port/include newlib/include COMPONENT_SRCDIRS += newlib/port -COMPONENT_ADD_LDFLAGS := $(LIBC_PATH) $(LIBM_PATH) -lnewlib +COMPONENT_ADD_LDFLAGS := $(LIB_PATH) -lnewlib +COMPONENT_ADD_LINKER_DEPS := $(LIB_PATH) + ifdef CONFIG_NEWLIB_LIBRARY_LEVEL_FLOAT_NANO COMPONENT_ADD_LDFLAGS := $(COMPONENT_ADD_LDFLAGS) -u _printf_float -u _scanf_float endif -COMPONENT_ADD_LINKER_DEPS := $(LIBC_PATH) $(LIBM_PATH) -endif -endif \ No newline at end of file +endif # CONFIG_NEWLIB_LIBRARY_CUSTOMER \ No newline at end of file