Building FORTE for Wago

Introduction

Wago PFC 200 series is a PLC designed to work in Small and Medium Enterprises for small scale automations and runs on a ARM cortex A8 , 600 Mhz controller with real time Linux 3.6 (RT preemption patch). This tutorial helps to set up FORTE on the WAGO embedded platform. The essentials for following this tutorial are:

Wago Toolchain Installation on Ubuntu Host

Do NOT install the packages within the root folder! The installation may take more than an hour, therefore be patient till the whole process completes.

  1. Create a folder e.g. /home/.../Wago
  2. unzip the board support Package for WAGO PFC downloaded before into the /home/.../Wago folder. And follow the installation process found in HowTo_Install_WAGO-PFC-BSP-2014.10.3_Ubuntu-LTS.txt until you finished "6.1 Compile all packages of PFC200 Firmware".

Building FORTE for your Wago Device using "ptxdist" build tool on Ubuntu Host

FORTE is normally deployed in cross platforms using cmake. Here for the wago device all the build process is controlled by the ptxdist. For FORTE build process it is important to know about a few directories in the wago development environment. All the ptxdist packages are managed by so called rule files. The rule files are located in wago/ptxproj-2.2.20/rules directory. When you create a new package, rule files packagename.make and packagename.in are created in the rules directory. There are two kinds of source directories, wago/src for system level packages and wago/local_src for new custom packages. The build directory for the target system (wago) is located in a directory called platformwago-wago-pfc200/build-target.

  1. Create forte_wago project in PTXDist: Copy the rule files from FORTE/buildsupport/wago_pfc200/ forte_wago.in and forte_wago.make to wago/ptxproj-2.2.20/rules (creates a new package). Within the copied rule file .../ptxproj-2.2.20/forte_wago.make edit the line FORTE_WAGO_URL: file:/// to the absolute path of your FORTE main directory. To (de)activate specific modules (library parts) of FORTE edit .../ptxproj-2.2.20/wago.make line FORTE_WAGO_CONF_OPT := ...
  2. Save the package to PTXDist: To follow the standard build process of PTXDist the package has to be save to the PTXDist build environment. Select the forte_wago with space key (This will be displayed as [*]) and press exit to go out. It will ask you whether to save the package, then press Yes.
    > cd wago/ptxproj-2.2.20 > ptxdist menuconfig
    PTXDist Manager
  3. Build the Project: Go to your ptxproj-2.2.20 and perfom the build instruction as follows to build FORTE for the target device Wago PFC.
    > cd wago/ptxproj-2.2.20 > ptxdist targetinstall forte_wago
    Build Project Console Output

    The binary can be found in the directory .../ptxproj-2.2.20/platform-wago-pfc200/buid-target/forte_wago-1.6.2-build/src. The binary can be either copied to the target device /usr/bin directory or you can build your own custom linux image by performing command in your ptxproj-2.2.20 directory and boot with your own custom firmware.

  4. Rebuilding the Project: For rebuilding the project, the project has to be cleaned and perform the targetinstall again.
    > cd wago/ptxproj-2.2.20 > ptxdist clean forte_wago
    This clean instruction deletes the forte_wago build time stamps in the wago development environment. Now performing a targetinstall will rebuild the project
    > ptxdist targetinstall forte_wago
    If you made any changes in your forte root folder this changes will be reflected here and you will see a same window as you saw before.

Build and Debug FORTE remotely on Wago PFC with Eclipse

Build FORTE with Eclipse

FORTE can be debugged remotely from your Ubuntu host machine using Eclipse CDT. For more details please refer to Wago how to Utilize EclipseCDT. Using the same procedure FORTE can be debugged remotely. The recommended folder structure for building FORTE in Eclipse is:

- eclipseCDT -- workspace --- forte (contains FORTE source) --- forte-wago (contains project to access the Wago PFC)

Within the forte-wago folder create a new C Project by Menu → File → New → Project, type a project name e.g., forte-wago, deactivate default location and set the location to your FORTE source e.g., forte, choose Makefile project/Empty Makefile Project and - Other Toolchain - and press finish. Set the properties for the new projects. Within the category C/C++ Build set the Build command to ptxdist and the Build directory to your ptxdist installation location.

configure Eclipse with ptxdist

Set Build within the Behvior tab to targetinstall forte_wago and Clean to clean forte_wago.

add include folders to Eclipse

Add the required include directories within the C/C++ General / Paths and Symbols category. The required include directories are:

.../ptxproj-2.2.20/platform-wago-pfc200/sysroot-target/include .../ptxproj-2.2.20/platform-wago-pfc200/sysroot-target/usr/include .../OSELAS.Toolchain-2012.12.1/arm-cortexa8-linux-gnueabihf/ gcc-4.7.3-glibc-2.16.0-binutils-2.22-kernel-3.6-sanitized/include .../OSELAS.Toolchain-2012.12.1/arm-cortexa8-linux-gnueabihf/ gcc-4.7.3-glibc-2.16.0-binutils-2.22-kernel-3.6-sanitized/ sysroot-arm-cortexa8-linux-gnueabihf/usr/include .../OSELAS.Toolchain-2012.12.1/arm-cortexa8-linux-gnueabihf/ gcc-4.7.3-glibc-2.16.0-binutils-2.22-kernel-3.6-sanitized/ lib/gcc/arm-cortexa8-linux-gnueabihf/4.7.3/include
FORTE build for Wago in Eclipse

Within the C/C++ perspective right-click on your project and choose Build Project or Clean Project. After building your project you should get a Console output as it is shown below.

FORTE build for Wago in Eclipse

Within the Remote System Explorer perspective create a New Connection by clicking on New Connection button. Choose Linux and press Next. Enter the IP of our Wago PFC as Host name and type any Connection Name e.g. wagoPFC200 and press finish. In the Remote System view you can log to your Wago PFC by right-cklick on Ssh Terminals and entering root as user and wago as password. A Terminal view should open as well as a Remote System Details view.

FORTE build for Wago in Eclipse

copy the FORTE executable to /usr/bin on the Wago PFC. The executable can be copied to the Wago PFC by pasting it into the /usr/bin folder in the Remote System Details view. Stop the running CoDeSys instance (kill plclinux_rt) if you want to use digital inputs/outputs of the Wago PFC and start FORTE with:

> cd /usr/bin > ./forte

Debug FORTE with Eclipse

To debug FORTE on a Wago PFC click on the small triangle next to debug and choose Debug Configurations. Then select C/C++ Remote Application and set any name e.g. forte. Within the main tab set the path to the FORTE executable under C/C++ Application, set the Project to your chosen project name forte_wago, check Disable auto build, set Connection to your chosen Connection name e.g. wagoPFC200 and set the Remote Absolute File Path for C/C++ Application to your FORTE executable on the Wago /usr/bin/forte.

FORTE debug for Wago in Eclipse

Within the Debugger tab set the GDB debugger to /.../OSELAS.Toolchain-2012.12.1/arm-cortexa8-linux-gnueabihf/gcc-4.7.3-glibc-2.16.0-binutils-2.22-kernel-3.6-sanitized/bin/arm-cortexa8-linux-gnueabihf-gdb.

FORTE debug for Wago in Eclipse

Debug FORTE with Eclipse as usual.