Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 3986202

Browse files
donghengdongheng
authored andcommitted
fix(newlib): fix some initialization function is not done when using float-nano newlib and VFS
Using option "NEWLIB_LIBRARY_CUSTOMER" instead of "NEWLIB_ENABLE".
1 parent 0193d06 commit 3986202

File tree

6 files changed

+32
-42
lines changed

6 files changed

+32
-42
lines changed

components/esp8266/source/startup.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
#include "FreeRTOS.h"
3535
#include "task.h"
3636

37-
#if defined(CONFIG_NEWLIB_LIBRARY_LEVEL_NORMAL) || defined(CONFIG_NEWLIB_LIBRARY_LEVEL_NANO)
37+
#ifndef CONFIG_NEWLIB_LIBRARY_CUSTOMER
3838
#include "esp_newlib.h"
3939
#endif
4040

@@ -163,7 +163,7 @@ void call_start_cpu(size_t start_addr)
163163
assert(__esp_os_init() == 0);
164164
#endif
165165

166-
#if defined(CONFIG_NEWLIB_LIBRARY_LEVEL_NORMAL) || defined(CONFIG_NEWLIB_LIBRARY_LEVEL_NANO)
166+
#ifndef CONFIG_NEWLIB_LIBRARY_CUSTOMER
167167
esp_newlib_init();
168168
#endif
169169

components/freertos/port/esp8266/include/freertos/portmacro.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ extern "C" {
4242
#include "xtensa_rtos.h"
4343

4444
#if defined(configUSE_NEWLIB_REENTRANT) && configUSE_NEWLIB_REENTRANT == 1
45-
#if defined(CONFIG_NEWLIB_LIBRARY_LEVEL_NORMAL) || defined(CONFIG_NEWLIB_LIBRARY_LEVEL_NANO)
45+
#ifndef CONFIG_NEWLIB_LIBRARY_CUSTOMER
4646
#include "esp_newlib.h"
4747

4848
#define _impure_ptr _global_impure_ptr

components/newlib/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
set(COMPONENT_SRCDIRS newlib/port)
2-
set(COMPONENT_ADD_INCLUDEDIRS newlib/include newlib/port/include)
2+
set(COMPONENT_ADD_INCLUDEDIRS newlib/port/include newlib/include)
33

44

55
if(CONFIG_NEWLIB_LIBRARY_LEVEL_NANO)

components/newlib/Kconfig

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,8 @@
11
menu "Newlib"
22

3-
config NEWLIB_ENABLE
4-
bool "Enable newlib"
5-
default y
6-
help
7-
If you need use you own C library, make this option disable. The libraries and
8-
header files at this component will not be used.
9-
10-
Note: ABI of the C library of your own must be same as SDK.
11-
123
choice NEWLIB_LIBRARY_LEVEL
134
prompt "newlib level"
145
default NEWLIB_LIBRARY_LEVEL_FLOAT_NANO
15-
depends on NEWLIB_ENABLE
166
help
177
Choose newlib library level.
188

@@ -50,6 +40,14 @@ config NEWLIB_LIBRARY_LEVEL_FLOAT_NANO
5040
If you do not need 64-bit integer formatting support and C99 features, but need float formats,
5141
select this option.
5242

43+
config NEWLIB_LIBRARY_CUSTOMER
44+
bool "customer"
45+
help
46+
If you need use you own C library, select this option. The libraries and
47+
header files at this component will not be used.
48+
49+
Note: ABI of the C library of your own must be same as SDK.
50+
5351
endchoice
5452

5553
endmenu
Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,9 @@
1-
CFLAGS += -D_CLOCKS_PER_SEC_=CONFIG_FREERTOS_HZ -D_POSIX_THREADS=1 -D_UNIX98_THREAD_MUTEX_ATTRIBUTES=1
2-
CPPFLAGS += -D_CLOCKS_PER_SEC_=CONFIG_FREERTOS_HZ -D_POSIX_THREADS=1 -D_UNIX98_THREAD_MUTEX_ATTRIBUTES=1
1+
ifndef CONFIG_NEWLIB_LIBRARY_CUSTOMER
2+
3+
NEWLIB_FLAGS := -D_CLOCKS_PER_SEC_=CONFIG_FREERTOS_HZ \
4+
-D_POSIX_THREADS=1 \
5+
-D_UNIX98_THREAD_MUTEX_ATTRIBUTES=1
6+
7+
CFLAGS += $(NEWLIB_FLAGS)
8+
CPPFLAGS += $(NEWLIB_FLAGS)
9+
endif

components/newlib/component.mk

Lines changed: 11 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,23 @@
11
#
22
# Component Makefile
33
#
4-
COMPONENT_SRCDIRS := .
5-
6-
ifdef CONFIG_NEWLIB_ENABLE
7-
8-
ADD_NEW_NEWLIB := 0
4+
ifndef CONFIG_NEWLIB_LIBRARY_CUSTOMER
95

106
ifdef CONFIG_NEWLIB_LIBRARY_LEVEL_NORMAL
11-
LIBC_PATH := $(COMPONENT_PATH)/newlib/lib/libc.a
12-
LIBM_PATH := $(COMPONENT_PATH)/newlib/lib/libm.a
13-
ADD_NEW_NEWLIB := 1
14-
else
15-
ifdef CONFIG_NEWLIB_LIBRARY_LEVEL_NANO
16-
LIBC_PATH := $(COMPONENT_PATH)/newlib/lib/libc_nano.a
17-
LIBM_PATH := $(COMPONENT_PATH)/newlib/lib/libm.a
18-
ADD_NEW_NEWLIB := 1
19-
else
20-
ifdef CONFIG_NEWLIB_LIBRARY_LEVEL_FLOAT_NANO
21-
LIBC_PATH := $(COMPONENT_PATH)/newlib/lib/libc_fnano.a
22-
LIBM_PATH := $(COMPONENT_PATH)/newlib/lib/libm.a
23-
ADD_NEW_NEWLIB := 1
24-
endif
25-
endif
7+
LIB_PATH := $(COMPONENT_PATH)/newlib/lib/libc.a $(COMPONENT_PATH)/newlib/lib/libm.a
8+
else ifdef CONFIG_NEWLIB_LIBRARY_LEVEL_NANO
9+
LIB_PATH := $(COMPONENT_PATH)/newlib/lib/libc_nano.a $(COMPONENT_PATH)/newlib/lib/libm.a
10+
else ifdef CONFIG_NEWLIB_LIBRARY_LEVEL_FLOAT_NANO
11+
LIB_PATH := $(COMPONENT_PATH)/newlib/lib/libc_fnano.a $(COMPONENT_PATH)/newlib/lib/libm.a
2612
endif
2713

28-
ifeq ($(ADD_NEW_NEWLIB),1)
29-
COMPONENT_ADD_INCLUDEDIRS += newlib/include newlib/port/include
14+
COMPONENT_ADD_INCLUDEDIRS += newlib/port/include newlib/include
3015
COMPONENT_SRCDIRS += newlib/port
31-
COMPONENT_ADD_LDFLAGS := $(LIBC_PATH) $(LIBM_PATH) -lnewlib
16+
COMPONENT_ADD_LDFLAGS := $(LIB_PATH) -lnewlib
17+
COMPONENT_ADD_LINKER_DEPS := $(LIB_PATH)
18+
3219
ifdef CONFIG_NEWLIB_LIBRARY_LEVEL_FLOAT_NANO
3320
COMPONENT_ADD_LDFLAGS := $(COMPONENT_ADD_LDFLAGS) -u _printf_float -u _scanf_float
3421
endif
35-
COMPONENT_ADD_LINKER_DEPS := $(LIBC_PATH) $(LIBM_PATH)
36-
endif
3722

38-
endif
23+
endif # CONFIG_NEWLIB_LIBRARY_CUSTOMER

0 commit comments

Comments
 (0)