Andes Workshop

It is currently Thu Jan 18, 2018 2:52 pm

All times are UTC + 8 hours [ DST ]




Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: C++ code add on FreeRTOS
PostPosted: Tue Dec 26, 2017 7:20 pm 
Offline

Joined: Thu Apr 14, 2011 11:27 am
Posts: 14
Attachment:
crtend.c [1.04 KiB]
Downloaded 4 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 :

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


add suffixes rules in Makefile:

Code:
%.o: %.cpp
$(TRACE_C++)
$(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:
Code:
! System reset handler
   bal   reset
   bal _crt_init
   ! Infinite loop, if returned accidently
1:
   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:
Code:
#include "nds32_intrinsic.h"
#include "nds32_defs.h"

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

void* __dso_handle = (void*) &__dso_handle;

#ifndef VECTOR_BASE
#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 https://gcc.gnu.org/onlinedocs/gccint/I ... ation.html to know reason.


Attachments:
crtbegin.c [531 Bytes]
Downloaded 3 times
Top
 Profile Send private message E-mail  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC + 8 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group