Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Papyrus for Real Time » Generating code for specific hardware
Generating code for specific hardware [message #1798813] Mon, 26 November 2018 07:50 Go to next message
Twan Dieltjes is currently offline Twan DieltjesFriend
Messages: 22
Registered: September 2018
Junior Member
Till now, I only used Papyrus RT to generate code which used log.log to write to the console. Suppose I want to generate code for a Raspberry Pi, Arduino or other microcontrollers like a stm32.

Is there a best-practice guide available about how to generate code for this kind of hardware and control buttons, motors etc?
Where and how should I insert the code to control the hardware?

Re: Generating code for specific hardware [message #1798903 is a reply to message #1798813] Tue, 27 November 2018 09:12 Go to previous messageGo to next message
Nicolas Hili is currently offline Nicolas HiliFriend
Messages: 40
Registered: March 2017
Member
Hi,

I worked a bit on using Papyrus-RT for generating code for single-board computers. First of all, keep in mind that Papyrus-RT allows you to generate code for Linux systems. So, it will work out-of-the-box on your Raspberry PI. You just have to compile the Papyrus-RT RunTime Service (RTS) library first on your RPI.

About using the GPIOs of the RPI, you can use WiringPI. All you have to do is to include the corresponding header files and to modify the global configuration of your Papyrus-RT Makefile. More info here:

The first link also includes models I've created and presented.

As for non-Linux microcontrollers (e.g., Arduino), unless I am mistaken, there is for now no support for them since the RTS of Payrus-RT was designed for being executed on Linux, or under Cygwin, and Vagrant. Two options:

  • Your Arduino plays the role of "slave" in a "master-slave" communication where the master is a Linux-powered board (e.g., Raspberry PI). In that case, you can use Papyrus-RT to generate code on the master, and write Arduino code for your Arduino. Include WiringPI or other libraries in your model in order to communicate through I2C, SPI or other protocols;
  • You want to generate code for your Arduino directly. In that case, you have to build a minimalist RTS for your Arduino, and to generate code from Papyrus-RT using your preferred M2T technology. I used not long ago Acceleo to generate code on bare metal, I can give you pointers to do it if necessary.

Cheers,

Nicolas Hili
Re: Generating code for specific hardware [message #1798992 is a reply to message #1798903] Wed, 28 November 2018 12:05 Go to previous messageGo to next message
Twan Dieltjes is currently offline Twan DieltjesFriend
Messages: 22
Registered: September 2018
Junior Member
Thanks for your detailed answer.
I will checkout the links and just start with the Raspberry.
Re: Generating code for specific hardware [message #1799149 is a reply to message #1798992] Fri, 30 November 2018 14:09 Go to previous messageGo to next message
Twan Dieltjes is currently offline Twan DieltjesFriend
Messages: 22
Registered: September 2018
Junior Member
Great article and slides. Thanks again for the information!

What could be the workflow to develop for the RPi?
I now run Papyrus RT on a unbuntu virtual machine. Could I just copy the generated code files to the RPi, build it on the RPi and run it?

or is there a more conventient way? For example, for some of the course assigments, I was able to remote develop on the ubuntu machine via visual studio.

Great help!

Re: Generating code for specific hardware [message #1799341 is a reply to message #1799149] Wed, 05 December 2018 09:16 Go to previous messageGo to next message
Nicolas Hili is currently offline Nicolas HiliFriend
Messages: 40
Registered: March 2017
Member
Hi,

Sorry for my late answer.
I guess it depends on you. You can choose to generate source code on your VM, copy the sources using scp and build your code on the Rpi.

You can also choose to cross-compile from your Eclipse installation to the Rpi directly. I never tried, but there is a tutorial from Gael's blog that mentions it: https://github.com/gaelblondelle/PSysRoverInitialContrib/blob/master/documentation/c_getting_started/org.polarsys.rover.c.getting_started/setup_tool_chain.asciidoc

On my end, I used to scp my generated code on the Rpi. I do not test on the VM because of the use of the WiringPI library that requires to have access to the GPIOs.

Nicolas
Re: Generating code for specific hardware [message #1799343 is a reply to message #1799341] Wed, 05 December 2018 10:38 Go to previous messageGo to next message
Twan Dieltjes is currently offline Twan DieltjesFriend
Messages: 22
Registered: September 2018
Junior Member
No problem about the late reply.

I think I first go for the scp option.
Do you manually then add the wiring.h to the capsule after each regenerate of code?
Re: Generating code for specific hardware [message #1799351 is a reply to message #1799343] Wed, 05 December 2018 13:17 Go to previous messageGo to next message
Nicolas Hili is currently offline Nicolas HiliFriend
Messages: 40
Registered: March 2017
Member
No, you can add it using the CapsuleProperties stereotype from the Cpp profile in Papyrus-RT. After adding the stereotype, you can include WiringPI in the "implementation preface" field.

About the Makefile, you would have to add -lwiringPi each time you recompile your application. A better idea (since your Papyrus-RT RTS installation on the Rpi will most likely be used for executing UML-RT systems that access the GPIOs most exclusively) is to add this flag in: $UMLRTS_ROOT/build/buildtools/x86-gcc-4.6.3/buildtools.mk so you would not have to change your generated Makefile every time you recompile.

Nicolas

[Updated on: Wed, 05 December 2018 13:18]

Report message to a moderator

Re: Generating code for specific hardware [message #1799670 is a reply to message #1799351] Wed, 12 December 2018 08:10 Go to previous messageGo to next message
Twan Dieltjes is currently offline Twan DieltjesFriend
Messages: 22
Registered: September 2018
Junior Member
In your previous post, you wrote that you send the generated code via SCP to the pi and if I understand it correctly build it on the py. I expect the teacher wants us to cross compile but he said compiling the code on the py is very time consuming and kills the SD card due to the large amount of write actions. Is that your experience too?

[Updated on: Thu, 13 December 2018 07:26]

Report message to a moderator

Re: Generating code for specific hardware [message #1799915 is a reply to message #1799670] Mon, 17 December 2018 12:16 Go to previous message
Nicolas Hili is currently offline Nicolas HiliFriend
Messages: 40
Registered: March 2017
Member
Hi Twan,

Never experienced something like that. It's not like compiling UML-RT applications is so time consuming that it will destroy your SD card instantaneously :) Otherwise, we should not even use an OS since it will perform many more read and write operations on the SD card than compiling UML-RT applications.. Nonetheless, cross-compiling should be a better and faster approach since you will be able to compile on a more powerful computer and then just deploy your binary file.
Previous Topic:Invoke code generator command line
Next Topic:Customizing code generator
Goto Forum:
  


Current Time: Sat Oct 12 19:22:20 GMT 2024

Powered by FUDForum. Page generated in 0.05722 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top