mirror of
https://github.com/pine64/bl_iot_sdk.git
synced 2025-02-21 18:40:03 +00:00
Add basic C++ support
This commit is contained in:
parent
e231762bbb
commit
25fb041d1c
@ -80,6 +80,23 @@ SECTIONS
|
||||
_rom_framework_audio_device_end = .;
|
||||
} > flash
|
||||
|
||||
.preinit_array :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
__preinit_array_start = .;
|
||||
KEEP (*(.preinit_array))
|
||||
__preinit_array_end = .;
|
||||
} > flash
|
||||
|
||||
.init_array :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
__init_array_start = .;
|
||||
KEEP (*(SORT_BY_INIT_PRIORITY(.init_array.*)))
|
||||
KEEP (*(.init_array))
|
||||
__init_array_end = .;
|
||||
} > flash
|
||||
|
||||
/*put wifibss in the first place*/
|
||||
.wifibss (NOLOAD) :
|
||||
{
|
||||
|
@ -119,6 +119,27 @@ bl602_start:
|
||||
sd ra, 8(sp)
|
||||
#endif
|
||||
|
||||
// call global obj constructors
|
||||
la s1, __preinit_array_start
|
||||
la s2, __preinit_array_end
|
||||
li s3, 4
|
||||
1:
|
||||
bgeu s1, s2, 2f
|
||||
lw a3, (s1)
|
||||
jalr a3
|
||||
add s1, s1, s3
|
||||
j 1b
|
||||
2:
|
||||
la s1, __init_array_start
|
||||
la s2, __init_array_end
|
||||
li s3, 4
|
||||
1:
|
||||
bgeu s1, s2, 2f
|
||||
lw a3, (s1)
|
||||
jalr a3
|
||||
add s1, s1, s3
|
||||
j 1b
|
||||
2:
|
||||
/* argc = argv = 0 */
|
||||
li a0, 0
|
||||
li a1, 0
|
||||
|
@ -1,7 +1,7 @@
|
||||
# Component Makefile
|
||||
#
|
||||
## These include paths would be exported to project level
|
||||
COMPONENT_ADD_INCLUDEDIRS += bl602_hal
|
||||
COMPONENT_ADD_INCLUDEDIRS += bl602_hal platform_hal
|
||||
|
||||
## not be exported to project level
|
||||
COMPONENT_PRIV_INCLUDEDIRS :=
|
||||
@ -50,8 +50,10 @@ COMPONENT_SRCS := bl602_hal/bl_uart.c \
|
||||
bl602_hal/hal_spi.c \
|
||||
bl602_hal/hal_adc.c \
|
||||
bl602_hal/hal_wifi.c \
|
||||
platform_hal/platform_hal_device.cpp \
|
||||
|
||||
COMPONENT_SRCDIRS := bl602_hal
|
||||
|
||||
COMPONENT_SRCDIRS := bl602_hal platform_hal
|
||||
|
||||
COMPONENT_OBJS := $(patsubst %.c,%.o, $(COMPONENT_SRCS))
|
||||
COMPONENT_OBJS := $(patsubst %.cpp,%.o, $(COMPONENT_OBJS))
|
||||
|
@ -32,23 +32,23 @@
|
||||
|
||||
extern "C" void* operator new(size_t size)
|
||||
{
|
||||
printf("[C++] new %d\r\n", size);
|
||||
/* printf("[C++] new %d\r\n", size); */
|
||||
return pvPortMalloc(size);
|
||||
}
|
||||
|
||||
extern "C" void* operator new[](size_t size)
|
||||
{
|
||||
printf("[C++] new[] %d\r\n", size);
|
||||
/* printf("[C++] new[] %d\r\n", size); */
|
||||
return pvPortMalloc(size);
|
||||
}
|
||||
|
||||
extern "C" void operator delete(void* ptr) {
|
||||
printf("[C++] delete %p\r\n", ptr);
|
||||
/* printf("[C++] delete %p\r\n", ptr); */
|
||||
vPortFree(ptr);
|
||||
}
|
||||
|
||||
extern "C" void operator delete[](void* ptr) {
|
||||
printf("[C++] delete[] %p\r\n", ptr);
|
||||
/* printf("[C++] delete[] %p\r\n", ptr); */
|
||||
vPortFree(ptr);
|
||||
}
|
||||
|
||||
@ -242,6 +242,7 @@ extern "C" int platform_hal_device_init(void)
|
||||
class BLAesRequest *aes_request = new BLAesRequest[6];
|
||||
aes_engine = new BLAesEngine();
|
||||
|
||||
(void)aes_request;
|
||||
#if 0
|
||||
aes_engine->encryption(aes_request[0]);
|
||||
#endif
|
||||
|
@ -281,7 +281,7 @@ $(2)/%.o: $$(COMPONENT_PATH)/$(1)/%.c $(COMMON_MAKEFILES) $(COMPONENT_MAKEFILE)
|
||||
|
||||
$(2)/%.o: $$(COMPONENT_PATH)/$(1)/%.cpp $(COMMON_MAKEFILES) $(COMPONENT_MAKEFILE) | $(COMPONENT_OBJDIRS)
|
||||
$$(summary) CXX $$(patsubst $$(PWD)/%,%,$$(CURDIR))/$$@
|
||||
$$(CXX) $$(CFLAGS) $$(CXXFLAGS) -D __FILENAME__=\"$$(notdir $$<)\" -D __FILENAME_WO_SUFFIX__=\"$$(subst .c,,$$(notdir $$<))\" -D __FILENAME_WO_SUFFIX_DEQUOTED__=$$(subst .c,,$$(notdir $$<)) -D __COMPONENT_NAME__=\"$$(COMPONENT_NAME)\" -D __COMPONENT_NAME_DEQUOTED__=$$(COMPONENT_NAME) -D __COMPONENT_FILE_NAME__=\"$$(COMPONENT_NAME)$$(subst .c,,$$(notdir $$<))\" -D__COMPONENT_FILE_NAMED__=$$(COMPONENT_NAME).$$(subst .c,,$$(notdir $$<)) -D__COMPONENT_FILE_NAME_DEQUOTED__=$$(COMPONENT_NAME)$$(subst .c,,$$(notdir $$<)) $$(CPPFLAGS) $$(addprefix -I ,$$(COMPONENT_INCLUDES)) $$(addprefix -I ,$$(COMPONENT_EXTRA_INCLUDES)) -I $(1) -c $$(abspath $$<) -o $$@
|
||||
$$(CXX) $$(CXXFLAGS) $$(CPPFLAGS) -D __FILENAME__=\"$$(notdir $$<)\" -D __FILENAME_WO_SUFFIX__=\"$$(subst .c,,$$(notdir $$<))\" -D __FILENAME_WO_SUFFIX_DEQUOTED__=$$(subst .c,,$$(notdir $$<)) -D __COMPONENT_NAME__=\"$$(COMPONENT_NAME)\" -D __COMPONENT_NAME_DEQUOTED__=$$(COMPONENT_NAME) -D __COMPONENT_FILE_NAME__=\"$$(COMPONENT_NAME)$$(subst .c,,$$(notdir $$<))\" -D__COMPONENT_FILE_NAMED__=$$(COMPONENT_NAME).$$(subst .c,,$$(notdir $$<)) -D__COMPONENT_FILE_NAME_DEQUOTED__=$$(COMPONENT_NAME)$$(subst .c,,$$(notdir $$<)) $$(CPPFLAGS) $$(addprefix -I ,$$(COMPONENT_INCLUDES)) $$(addprefix -I ,$$(COMPONENT_EXTRA_INCLUDES)) -I $(1) -c $$(abspath $$<) -o $$@
|
||||
$(call AppendSourceToDependencies,$$<,$$@)
|
||||
|
||||
$(2)/%.o: $$(COMPONENT_PATH)/$(1)/%.cc $(COMMON_MAKEFILES) $(COMPONENT_MAKEFILE) | $(COMPONENT_OBJDIRS)
|
||||
|
@ -341,8 +341,11 @@ CFLAGS := $(strip \
|
||||
-save-temps=obj
|
||||
|
||||
CXXFLAGS := $(strip \
|
||||
$(CPPFLAGS) \
|
||||
$(OPTIMIZATION_FLAGS) \
|
||||
-std=c++11 \
|
||||
$(OPTIMIZATION_FLAGS) $(DEBUG_FLAGS) \
|
||||
$(COMMON_FLAGS) \
|
||||
$(COMMON_WARNING_FLAGS) \
|
||||
$(CXXFLAGS) \
|
||||
$(E21_CPU_CFLAGS) \
|
||||
-nostdlib \
|
||||
-g3 \
|
||||
@ -357,7 +360,9 @@ CXXFLAGS := $(strip \
|
||||
-Wswitch-default \
|
||||
-Wunused \
|
||||
-Wundef \
|
||||
-fno-rtti -fno-exceptions)
|
||||
-fno-rtti -fno-exceptions \
|
||||
-save-temps=obj \
|
||||
)
|
||||
|
||||
export CFLAGS CPPFLAGS CXXFLAGS ASMFLAGS
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user