Looking for help with my C++ thread class

ChibiOS public support forum for all topics not covered by a specific support forum.

Moderators: RoccoMarco, lbednarz, utzig, tfAteba, barthess

User avatar
Giovanni
Site Admin
Posts: 14444
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1074 times
Been thanked: 921 times
Contact:

Re: Looking for help with my C++ thread class

Postby Giovanni » Mon Apr 18, 2011 7:49 am

There is a new C++ demo under ./demos/ARMCM3-STM32F103-G++, you may start from there.

There are changes to the ch.ld file, to the Makefile, to the C++ kernel wrapper and a new unified startup file that supports several new features.

Giovanni

JetForMe
Posts: 99
Joined: Mon Jan 31, 2011 8:12 am

Re: Looking for help with my C++ thread class

Postby JetForMe » Sat Sep 17, 2011 9:54 am

It looks like the new C++ support still isn't available for GCC/ARM AT91SAM7. How hard would it be for you to update that port to include it? I can try myself, but I fear it will be very hard to get it working (without JTAG tools).

Thanks,
Rick

User avatar
Giovanni
Site Admin
Posts: 14444
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1074 times
Been thanked: 921 times
Contact:

Re: Looking for help with my C++ thread class

Postby Giovanni » Sat Sep 17, 2011 10:24 am

Hi Rick,

The existing C++ wrapper should work perfectly for the AT91SAM7 too, it is not platform dependent and there is a LPC2148 demo proving it works on ARM7. You just have to modify a AT91 demo by changing the makefile like in the LPC demo.

Lack of a JTAG probe makes everything harder. Anyway, give it a try, If you are unable to make it work I'll give it some bandwidth during next week.

Giovanni

JetForMe
Posts: 99
Joined: Mon Jan 31, 2011 8:12 am

Re: Looking for help with my C++ thread class

Postby JetForMe » Sat Sep 17, 2011 10:32 am

Thanks, Giovanni, I'll give it a shot this weekend.

One thing I ran into was a link problem with delete and pure virtual:


src/ColorAnimator.o: In function `~ColorAnimatorDelegate':
/Users/rmann/Projects/ISSLamp/repo/trunk/Firmware/src/ColorAnimator.cpp:77: undefined reference to `operator delete(void*)'
src/ColorAnimator.o:(.rodata._ZTV21ColorAnimatorDelegate[vtable for ColorAnimatorDelegate]+0x10): undefined reference to `__cxa_pure_virtual'
src/Flower.o: In function `~Flower':
/Users/rmann/Projects/ISSLamp/repo/trunk/Firmware/src/Flower.h:33: undefined reference to `operator delete(void*)'
collect2: ld returned 1 exit status


Does your new stuff fix that?

Thanks!

User avatar
Giovanni
Site Admin
Posts: 14444
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1074 times
Been thanked: 921 times
Contact:

Re: Looking for help with my C++ thread class

Postby Giovanni » Sat Sep 17, 2011 10:35 am

There is no support for destructors because the C++ support is limited, there is no allocation currently. Probably this is the cause of that error.

RTTI and exceptions are not supported too.

Giovanni

JetForMe
Posts: 99
Joined: Mon Jan 31, 2011 8:12 am

Re: Looking for help with my C++ thread class

Postby JetForMe » Sat Sep 17, 2011 10:41 am

RTTI and exceptions are a lot easier to live without, but destructors are very important.

User avatar
Giovanni
Site Admin
Posts: 14444
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1074 times
Been thanked: 921 times
Contact:

Re: Looking for help with my C++ thread class

Postby Giovanni » Tue Sep 20, 2011 3:12 pm

It is something that could be added when that C++ wrapper will be improved, it is quite old now, unfortunately the bandwidth is limited and there are more urgent pending developments right now.

Giovanni

mabl
Posts: 417
Joined: Tue Dec 21, 2010 10:19 am
Location: Karlsruhe, Germany
Been thanked: 1 time
Contact:

Re: Looking for help with my C++ thread class

Postby mabl » Tue Sep 20, 2011 4:21 pm

That really is unfortunate. I also run into the C++ limitations quite often. For now I'm fine with the wrapper class, but improved C++ language support would really be great. Is there any documentation on the internet on what is missing and how to do it?

EDIT: I know it is an awful hack, but in the meantime, would linking to stdc++ help? (Assuming I have enough of ROM)

User avatar
Giovanni
Site Admin
Posts: 14444
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1074 times
Been thanked: 921 times
Contact:

Re: Looking for help with my C++ thread class

Postby Giovanni » Tue Sep 20, 2011 5:54 pm

The wrapper is just plan and simple C++, there are no hacks so supporting the whole stdc++ would allow exceptions, destructors and everything else. The problem is making stdc++ work with the RTOS but this is an integration effort not a development effort.

I imagine that stdc++ requires at least allocation services for the "new" operator, linker scripts may require changes.

Giovanni

mabl
Posts: 417
Joined: Tue Dec 21, 2010 10:19 am
Location: Karlsruhe, Germany
Been thanked: 1 time
Contact:

Re: Looking for help with my C++ thread class

Postby mabl » Tue Sep 20, 2011 6:45 pm

Hi Giovanni,

I just made some test with libstdc++. It uses standard malloc for allocation and has some os layer support for newlib (mainly ctype). In my tests I can create objects with new, and the constructor is called as well. Though I'm pretty sure malloc will collide with the ChibiOs allocator, right?

So basically I'll have to figure out how to map malloc to the ChibiOs.


Return to “General Support”

Who is online

Users browsing this forum: No registered users and 12 guests