Andes Workshop

C++ code add on FreeRTOS
Page 1 of 1

Author:  jimmy [ Tue Dec 26, 2017 7:20 pm ]
Post subject:  C++ code add on FreeRTOS

crtend.c [1.04 KiB]
Downloaded 1496 times
FreeRTOS programmed by C language. If C++ code wants to add in FreeRTOS, you should update steps as following. C++ code can merge into Andes FreeRTOS.

1. Makefile :
add define in Makefile :

C++   := $(CROSS_COMPILE)g++

add suffixes rules in Makefile:

%.o: %.cpp
$(Q)$(C++) -c -MMD $(CFLAGS) -o $@ $<

2. add crtbegin.c/crtend.c files (attached files) into folder RTOSDemo_bsp and both file will be compiled into project.

3. call function "_crt_init"in Start.S:
! System reset handler
   bal   reset
   bal _crt_init
   ! Infinite loop, if returned accidently
   b       1b

4. add code "void __cxa_atexit(void (*arg1)(void*), void* arg2, void* arg3)

void* __dso_handle = (void*) &__dso_handle;
" in startup-nds32.c:
#include "nds32_intrinsic.h"
#include "nds32_defs.h"

void __cxa_atexit(void (*arg1)(void*), void* arg2, void* arg3)

void* __dso_handle = (void*) &__dso_handle;

#define VECTOR_BASE   0x00000000

Please pay attention to following:
C++ program can call C function but C program can't call C++

If you are curious above updates, you can check web site ... ation.html to know reason.

crtbegin.c [531 Bytes]
Downloaded 1502 times

Page 1 of 1 All times are UTC + 8 hours [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group