AURIX Development Studio Tutorial¶
This section serves as a comprehensive guide to assist in creating and understanding the key points of a basic Safe DDS application using the AURIX Development Studio tool.
This project has been tested on the AURIX TC397 TriCore Application Kit with AURIX Development Studio 1.10.10, running bare metal and with LwIP v2.1.2. Check Supported platforms for more information.
Note
This guide might require adaptations to work with a different hardware, RTOS, network stack or AURIX Development Studio version.
In order to get support please contact support@eProsima.com.
Note
It is recommended to first read the Getting Started section to gain a better understanding of the basic concepts and terminology used in this section.
Project Configuration¶
This section describes how to configure an AURIX Development Studio project that uses the Safe DDS library.
Start by downloading the Ethernet_1_KIT_TC397_TFT example from the AURIX code examples repository to obtain a fully configured project with the LwIP network stack. The project can be renamed if desired by right-clicking it in the Project Explorer and selecting Rename.
Then, follow the steps below in the order presented to ensure the project is set up correctly.
1. Initial Project Setup¶
Set the project as the active one by right-clicking on it and selecting Set Active Project.
Also set the build configuration by right-clicking on the project, selecting Build Configurations > Set Active, and then choosing Tricore Debug/Release (GCC).
To convert the project to a C++ project, right-click on the project and select New > Other > C/C++ > Convert to a C/C++ Project (Adds C/C++ Nature).
2. Configure LwIP for Safe DDS¶
By default, Safe DDS will use UDP multicast operation, so LWIP_IGMP shall be enabled in the Configurations/lwipopts.h LwIP configuration file.
3. Add a New Source Folder for Safe DDS¶
To add the Safe DDS library to the project follow these steps:
In the Project Explorer, right-click on the project and select New > Source Folder. Name the folder, i.e.: Safe-DDS.
Navigate to the AURIX Development Studio support package folder and run the create_package.sh script followed by the path to the Safe DDS source release folder. This script generates the required files for a bare metal + LwIP application on an AURIX Development Studio environment.
Copy the Safe DDS src and include generated folders to the folder previously created in the AURIX Development Studio project.
Move to the project properties and navigate to C/C++ Build > Settings > Tool Settings > AURIX G++ Compiler > Includes.
Add to the include files (-include) the path to the lwip/udp.h file included in the Safe DDS include folder.
Also, under C/C++ Build > Settings > Tool Settings > AURIX G++ Compiler > Miscellaneous, add the -fno-exceptions flag.
Safe DDS application¶
After the project has been set up, the next step is to create a Safe DDS application:
1. Add the application files to the project¶
Navigate to the tutorial_aurix_development_studio folder.
Add the provided SafeDDSApp.cpp, SafeDDSApp.hpp and HelloWorldTypeSupport.hpp files to the project.
2. Configure the first core main application¶
Once all necessary files are in place, add the Safe DDS application entry point to the main application of the first core.
An example of a Safe DDS entry point could be:
void safedds_app_init(const uint32_t, const uint32_t);
void safedds_app_spin();
void core0_main (void)
{
// Keep the existing initializations
// ...
Ifx_Lwip_init(ethAddr); /* Initialize LwIP with the MAC address */
uint8_t safedds_app_enabled = 0;
while (1)
{
// Spin SafeDDS application if initialized
if (safedds_app_enabled)
{
safedds_app_spin();
}
// Check if an IP address is assigned and initialize SafeDDS application
else if (!ip4_addr_isany_val(*netif_ip4_addr(&g_Lwip.netif)))
{
const uint32_t ip_address = ip4_addr_get_u32(netif_ip4_addr(&g_Lwip.netif));
const uint32_t port = 8000;
safedds_app_enabled = 1;
safedds_app_init(ip_address, port);
}
Ifx_Lwip_pollTimerFlags(); /* Poll LwIP timers and trigger protocols execution if required */
Ifx_Lwip_pollReceiveFlags(); /* Receive data package through ETH */
}
}
In addition, take advantage of the fact that LwIP updates the millisecond counter to update the Safe DDS counter.
void safedds_ms_tick();
/* ISR to update LwIP stack */
void updateLwIPStackISR(void)
{
// ...
g_TickCount_1ms++; /* Increase LwIP system time */
safedds_ms_tick(); /* Increase SafeDDS time */
// ...
}
Running the application¶
Build the application and flash it to the device.
Note
If a build error occurs related to .gcc_except_table or the .eh_frame section, comment out the corresponding section in the linker script.
Since C++ exceptions are disabled in this project, these sections are not required. However, some of the compiler’s default runtime libraries may still reference them, which can trigger linker errors.
Run the Getting Started example in a local machine on the same network as the device. The console output should show messages similar to the following:
[DW: 0] Message: HelloWorld with index: 4
[DW: 16777217] Message: Hello World from TC397! with index: 1
[DW: 16777217] Message: Hello World from TC397! with index: 2
[DW: 0] Message: HelloWorld with index: 5
[DW: 16777217] Message: Hello World from TC397! with index: 3
[DW: 16777217] Message: Hello World from TC397! with index: 4
[DW: 0] Message: HelloWorld with index: 6
[DW: 16777217] Message: Hello World from TC397! with index: 5
[DW: 16777217] Message: Hello World from TC397! with index: 6
[DW: 0] Message: HelloWorld with index: 7
[DW: 16777217] Message: Hello World from TC397! with index: 7
[DW: 16777217] Message: Hello World from TC397! with index: 8