RIOT icon indicating copy to clipboard operation
RIOT copied to clipboard

C++ on the boards

Open BytesGalore opened this issue 12 years ago • 38 comments

RIOT now provides a seamless c and c++ handling in the RIOT build system for user applications. But using c++ on specific boards requires adjustments, e.g. (un)set specific compiler and linker flags, provide/change system calls or even provide a custom tweaked compiler.

Here we can track the progression of board support and discuss related issues.

  • - [x] Family: native
    • - [x] native
  • - [x] Family: ARM
    • - [x] Airfy Beacon
    • - [x] Arduino Due
    • - [x] cc2538dk
    • - [x] f4vi1
    • - [x] IoT LAB_M3
    • - [x] mbed_lpc1768
    • - [x] MSB-IoT
    • - [x] MSBA2
    • - [x] Mulle
    • - [x] OpenMote
    • - [x] PCA1000x
    • - [x] Phytec phyWAVE KW22
    • - [x] Samr21 xpro
    • - [x] Spark Core
    • - [x] STM32F0discovery
    • - [x] STM32F3discovery
    • - [x] STM32F4discovery
    • - [x] UDOO
    • - [x] yunjia-nrf51822
  • - [ ] Family: ATmega
    • - [ ] Arduino Mega2560
    • - [ ] Arduino Uno
    • - [ ] Arduino Duemilanove
  • - [ ] Family: MSP430
    • - [ ] eZ430-Chronos
    • - [ ] MSB-430H
    • - [ ] TelosB
    • - [ ] WSN430
    • - [ ] Zolertia Z1
  • - [ ] Family: x86
    • - [ ] Intel Galileo

BytesGalore avatar Jun 15 '14 07:06 BytesGalore

Family: ARM compile tests

  • pttu w/ MCU lpc2387 (compiles)
  • avsextrem w/ MCU lpc2387 (compiles)
  • redbee-econotag w/ MCU mc1322x (Does NOT compile, errors)
./RIOT/cpu/mc1322x/include/mc1322x.h:26:10: error: 'struct CRM_struct::<anonymous union>::CRM_SYS_CNTL' invalid; an anonymous union can only have non-static data members [-fpermissive]
...
./RIOT/cpu/mc1322x/include/mc1322x.h:200:66: error: invalid conversion from 'void*' to 'volatile CRM_struct*' [-fpermissive]
./RIOT/cpu/mc1322x/include/mc1322x.h:223:10: error: 'struct TMR_struct::<anonymous union>::TMR_CTRL' invalid; an anonymous union can only have non-static data members [-fpermissive]
...
./RIOT/cpu/mc1322x/include/mc1322x.h:292:69: error: invalid conversion from 'void*' to 'volatile TMR_struct*' [-fpermissive]
...
./RIOT/cpu/mc1322x/include/mc1322x.h:332:24: error: 'struct ITC_struct::<anonymous union>::ITC_INTCNTL' invalid; an anonymous union can only have non-static data members [-fpermissive]
...
./RIOT/cpu/mc1322x/include/mc1322x.h:342:9: note: in expansion of macro '__INTERRUPT_union'
...
/RIOT/cpu/mc1322x/include/mc1322x.h:354:66: error: invalid conversion from 'void*' to 'volatile ITC_struct*' [-fpermissive]

BytesGalore avatar Jun 18 '14 06:06 BytesGalore

ping @BytesGalore : do we have any progress on this ? ;-)

dangnhat avatar Oct 30 '14 03:10 dangnhat

no, I haven't tested the implementation for some time if something changed :blush: I will extend the list for with the new boards tomorrow and update it with current results.

BytesGalore avatar Oct 30 '14 06:10 BytesGalore

For AVR I think I can say that there seems is currently no real C++ support on the side of avr-libc. Especially libstdc++ is missing. So while it is possible to use language constructs like classes (I'm not sure if a C++ compiler is included in the default toolchain, Gentoo's crossdev builds one), C++ experience on AVR won't be seamless (without extensive work or switching to another libc, which implies extensive work again ;-) ).

N8Fear avatar Oct 30 '14 09:10 N8Fear

Arch Linux comes with avr-g++.

LudwigKnuepfer avatar Oct 30 '14 12:10 LudwigKnuepfer

@N8Fear It is not really viable to expect a full libstdc++ or similar on a microcontroller platform because of flash and RAM considerations, but there are lighter alternatives for a C++ template library if just the C++ support is there, e.g. http://msharov.github.io/ustl/ (I haven't tried that one yet, but I have been meaning to do it for some time)

jnohlgard avatar Oct 30 '14 14:10 jnohlgard

Ok - in this case: If C++ support means "there is a compiler" AVR should be fine.. ;-)

N8Fear avatar Oct 30 '14 15:10 N8Fear

@N8Fear : at least we want some basic object-oriented programming can be done, after that we can consider the support for other stuffs like STL (after evaluate the resource needed and real-time capacity on uCs ). ;-)

For AVR I think I can say that there seems is currently no real C++ support on the side of avr-libc.

IMHO, I think it's the problem with C++ support on that platform in general not specific RIOT. I guess our main goal should be providing the build system to build C++ easily and making sure our source code don't do anything to violate C/C++ compatibility. In other words, it's something like "if some people can use C++ on a platform then they can use C++ with RIOT like normal because our build system can mix their code with RIOT and we don't mess anything up with C/C++ compatibility" ;-)

C++ experience on AVR won't be seamless (without extensive work or switching to another libc, which implies extensive work again ;-) )

Therefore, if the "normal situation on a specific platform" has some difficulties with C++ then provide the better C++ support for that platform should be nice to have for RIOT but not mandatory. :-)

BTW, arduino can do some C++ programming on avr, right?

dangnhat avatar Oct 31 '14 02:10 dangnhat

BTW, arduino can do some C++ programming on avr, right?

Honestly I don't know, but since the AVR arduinos use avr-libc themselves I guess that if it is possible, it's limited the same way as for us (no stdlib).

N8Fear avatar Oct 31 '14 02:10 N8Fear

@gebart :

http://msharov.github.io/ustl/

I also haven't tried this one but it looks really nice. I have a C++ project on RIOT with stm32 so I'll try it out. ;-) Thanks.

dangnhat avatar Oct 31 '14 02:10 dangnhat

it's limited the same way as for us (no stdlib).

yeah, I have looked into some forums, it seems to be quite limited. I guess when we have time, we should get one and find out by ourselves. :D

dangnhat avatar Oct 31 '14 02:10 dangnhat

Because the deadline of my thesis is closing in, I will postponed the C++ support for msp430 and avr for several weeks, and the C++ support for these platforms probably can't make it into next release. I'll come back with this topic in 2, 3 weeks. Cheers,

dangnhat avatar Dec 11 '14 15:12 dangnhat

Just successfully tested for the mbed_lpc1768.

haukepetersen avatar Dec 11 '14 15:12 haukepetersen

@dangnhat good luck for your thesis! I will take a look on eZ430-Chronos, as we have this HW here. The TI toolchain for msp in >=4.9 seems to be very complete with c++ support (I had just a quick look) and maybe we can manage to build RIOT with it for the board.

BytesGalore avatar Dec 11 '14 16:12 BytesGalore

@haukepetersen : good new! :D @BytesGalore : thanks! Did you mention about proprietary TI compiler, or Red hat & TI's MSP430-gcc or community's MSPGCC? ;-) (Just out of curiousity )

dangnhat avatar Dec 12 '14 06:12 dangnhat

@dangnhat The Red hat one.

BytesGalore avatar Dec 12 '14 06:12 BytesGalore

hi i am a new comer , can you help me on how to get started with this issue ? few links or what am i looking to resolve ? thanks in advance

kausthub avatar Mar 09 '15 19:03 kausthub

@BytesGalore, @josephnoir, since @dangnhat has become quite silent recently, maybe you can help here.

OlegHahm avatar Mar 10 '15 15:03 OlegHahm

Sorry for the long silence after I finished my thesis (I think I have enjoyed Lunar New Year holiday too much :D )

@kausthub : There may be two directions to go from here: First, we can continue providing the basic C++ programming for the remaining boards. (I'm working on Intel Galileo now, and @BytesGalore might be working on msp430 board, so if you choose this direction then avr might be the good way to go :-) ). The basic idea is to compile C++ project as easy as possible. To do that we might want to change RIOT's build system so understanding the makefiles is needed. You might want take a quick look at (https://github.com/RIOT-OS/RIOT/pull/981). It introduce the main idea and some new Make variables. Some Googling is also needed.

Second, we can try and test some other features on the boards which can compile C++ such as STL; evaluate the resource needed and its real time capacity. I don't have much experiences about this so Google might be your good friend. ;-)

Other comments are welcome if I missed something.

dangnhat avatar Mar 10 '15 16:03 dangnhat

@dangnhat, no need to apologize! I'm really happy to see that you're still aboard! :)

OlegHahm avatar Mar 10 '15 16:03 OlegHahm