OPC UA Stack porting to PIC32
Porting of the Matrikon FLEX OPC UA SDK to PIC32MZ with and without FreeRTOS
The customer wanted to run the Matrikon FLEX OPC UA server on a PIC32MZ microcontroller with FreeRTOS. However, the Matrikon FLEX OPC UA SDK does not support FreeRTOS natively and does not have any version available for the PIC32MZ microcontroller. The goal of this project was to get the Matrikon FLEX OPC UA SDK based OPC UA server running on the PIC32MZ custom hardware. Another complication which required to be handled was to fit the Matrikon FLEX OPC UA Server along with the customer application with the limited Flash and RAM resources on the device. This required to also optimize the Matrikon SDK further so that it can fit with the application.
The Matrikon FLEX OPC UA SDK is implemented using standard C++ and only requires C++ 11 support along with some platform specific networking, file system and timer APIs. As the stack is divided into platform specific and portable parts already, the changes to be done was easily identified. To port the Matrikon FLEX we first prepared a bare metal prototype to run the Matrikon FLEX OPC UA server on the PIC32MZ, without any security. This prototype was used to measure both footprint and performance of the OPC UA server. Initially the footprint of the OPC UA server was too large and required additional optimization to reduce it further. We identified additional configuration changes and other code optimization techniques which included using smaller nodeset and using the compiler optimization flags specific to the PIC32MZ. We also used the Linux kernel ksize utility (https://github.com/intel/luv-yocto/blob/master/scripts/tiny/ksize.py) in a modified form to analyze the generated objects and identify the areas which produced large code. Such code sections were then analyzed further to identify sections which we could optimize further.
The Matrikon FLEX OPC UA Stack was ported to PIC32 platform for NoOS and we were able to achieve the working OPC UA server with the FLASH and RAM size which was acceptable for the application within the time and effort estimated.