behi88
Hi,
first of all let me say the this OPENPLC project is one of the best open source project that I could find on web.
right now i'm working with a Linux 3.2.0 based platform with AM335X ARM Cortex-A7 CPU and with no Linux distributor so I have to cross compile every library and program from source. I use linaro 4.7 tools as cross compiler.
I have so many question that I like to ask:
1- Is it possible to cross compile OPENPLC for my platform?
2- If so, which library do i need to cross compile for my platform?
3- How is it possible to add my own IO or UART driver to the software output?

Quote 0 0
thiagoralves
behi88 wrote:
Hi,
first of all let me say the this OPENPLC project is one of the best open source project that I could find on web.

Thanks! [smile]

behi88 wrote:
1- Is it possible to cross compile OPENPLC for my platform?

I never tried to cross compile it, but I believe it will be a little tricky. The entire OpenPLC application needs to be recompiled every time a new PLC program is uploaded. Currently it is done on the target by some scripts. You will have to port these scripts to run on the host and send only the compiled binary to the target board. Why not install GCC on the board and have all the fun happening embedded?

behi88 wrote:
2- If so, witch library do i need to cross compile for my platform?

Currently you only need GCC and libmodbus, but I'm writing my own Modbus implementation, so in a few days you won't need libmodbus anymore.

behi88 wrote:
3- How is it possible to add my own IO or UART driver to the software output?

Certainly. OpenPLC was built with expandability in mind. Take a look at the hardware layers in OpenPLC_v2/core/hardware_layers to create your own customized IO layer. Basically, there are two functions that you will need to provide: one to initialize your hardware and other to update the OpenPLC buffers with your inputs and outputs
Quote 0 0
behi88
thank you so much for your reply. your project inspire me to so much [smile].
I tried to add GCC to my board but I failed before but now I will again and port OpenPLC to my board.
I keep you posted.
Quote 0 0
thiagoralves
If you want to cross compile, you will need to setup your environment to use GCC to cross-compile for you board (I don't know how to do that, google is your friend). Once you have the environment ready, you will need to modify OpenPLC scripts to cross-compile the code locally and then send the compiled binary to your board.

Basically the OpenPLC has a webserver that works like a launcher for the OpenPLC application. You will need to run this webserver on the host machine. The code for the webserver is on the file server.js (or server_win.js for the windows platform). You might create a copy and rename it to server_yourboard.js to target your board. You will then modify your server_yourboard.js to, instead of just compile the new uploaded code, to call your cross-compiler and generate the binary file for your board. Just follow the same structure I used to compile the code locally and you probably will be fine.

To help you understand the rule for the webserver, here is the compilation step by step:
When a new code generated from the PLCopen Editor is uploaded to the webserver, it calls the iec2c compiler to generate C code based on the ST file that was uploaded. Then, this code is moved into the /core folder. The glue_generator is then called to generate the glueVars.cpp file based on the located vars in your program. After this step, you will have all the files you need inside the /core folder. Now it just compiles everything into a openplc executable application. Beware of the compilation order. The generated .c files must be compiled first into object files. If you don't do that, you might end up with lots of compilation errors.

Once the compilation is finished, you will need to manage a way to transfer the binary file to your board (scp maybe?).


Let me know if you need more information
Quote 0 0
behi88
Thank you thiago
as a matter of fact I have so much experience with cross compiling (because of my board) First I will try to install Linaro tool-chain. It is a relyable and very stable GCC compiler. but fist of all I do not understand, lets say I try to do the whole cross-compiling on windows and i install the openplc windows version, is iec2c program a windows independent exe file or a Linux bin file with Linux library that run with cygwin help?

 
Quote 0 0
thiagoralves
Compiling the iec2c on Cygwin was a mess, so I generated the iec2c executable for Windows using MinGW cross compiler on Linux. It doesn't need cygwin to run, but it requires two dlls that are copied to the main folder once the building process finishes.
Quote 1 0
mendesgeo
Thats sounds really nice. I use VisualGDB addin for visual studio, so i can cross compile everthing very easily.
Quote 0 0
ghl.bhrt
Hello All.
I am new here.
OPENPLC looks promising to me.
I am doing same thing and try to port openPLC to my custom TI AM335x board which run our custom Linux.
Any success using above procedure?
Quote 0 0
behi88
Hi
I have finished my project while ago
I worked for me and i will be glad to help
Quote 0 0