GOAL supports the selection of an Industrial Ethernet Protocol during startup time. This means the application can choose to start a protocol that is part of the binary. With the current version of GOAL, it is not possible to run multiple protocols at the same time. Changing the protocol requires a reboot of the system.
This application note explains how to create such a project and application.
Creating a Build project
A good starting point is to examine the standard example projects for our protocols that come with each GOAL release. If you are using our GCC/make environment, you can navigate to a project folder (e.g. projects/goal_ecat/01_simple_io/gcc) and execute the command make files. This will show you all settings for this project, including source files, include path, compile switches and other compiler options. If you are using an IDE you have to examine the appropriate project file.
Create a new project based on the example projects of each protocol
include the sources, compile switches and include paths you got as described above
if you are using GOAL’s gcc/make environment, you can simply merge the CONFIG_MAKE_FEAT_* statements in the Makefile to include the required sources and compile switches
Add the compile switch GOAL_CONFIG_MEDIA_MI_ETH=1. This disables the automatic initialization of the Ethernet driver during startup. (in GOAL’s gcc/make environment add DEFINES_COMMON += GOAL_CONFIG_MEDIA_MI_ETH=1)
Add the source files and include paths of the new application
Creating an Application
The same strategy that was used for creating a project can be used for creating an application: Base your application that supports multiple protocols on the sample applications of each individual protocol.
Each protocol allocates its variables on the GOAL Heap. Therefore, all unused protocols do not occupy the RAM. However, allocation is only possible during the initialization phase of GOAL. For the application, this happens within the function appl_setup(). So special care must be taken for this function.
merge the files goal_config.h
merge the file goal_appl.c:
merge the function appl_init(), appl_loop() (if present)
copy each instance of the function appl_setup() into your new application and rename it to appl_<PROTOCOL>setup()
create a new instance of the function appl_setup() in your application and:
determine with protocol to start
initialize the Ethernet MI/MA and the appropriate Ethernet driver (see section below)
initialize the protocol by calling the appropriate appl_<PROTOCOL>setup() function
initialize application specific resources
add additional files from each individual application and your own application files (make sure all these files a part of the newly created build project)
The compile switch GOAL_CONFIG_MEDIA_MI_ETH=1 disables the automatic initialization of the Ethernet driver during the appropriate startup Stage. Therefore, the application must initialize the appropriate Ethernet driver, once it has decided which protocol to start.
The application must invoke the function goal_miEthOpen() to enable the appropriate Ethernet driver in step 2.c.ii.
If the selected protocol is EtherCAT, the application does not need to load the Ethernet driver. It is only required if the Feature EoE is enabled. In this case, the protocol automatically loads the appropriate driver during initialization.
All other protocols use the standard Ethernet driver of the platform and expect it to be already available. Thus, the application must call goal_miEthOpen(GOAL_MI_ID, GOAL_MA_ID_ETH) and goal_miNetOpen() before any of the appl_<PROTOCOL>setup() functions.
Some drivers might need small adjustments if they were created under the assumption that only one protocol can be part of the binary. In that case, usually only a compile switch needs to be adjusted.