# CMSIS-RTOS for STM32 ## Setting up and running EcMasterDemo in Keil µVision IDE 1. Prerequisites : - Keil µVision 5 IDE - STM32H747I-DISCO board - EtherCAT® devices 2. Connect the STM32H747I-DISCO development board to the PC according to user manual. 3. Connect EtherCAT® devices to the board. 4. Create ENI file for EtherCAT® configuration. : `xxd.exe` is capable of converting ENI files to a C file as array, e.g. : ```doscon C:\> xxd.exe -i eni.xml ENI.c ```
Replace the file `ENI.c` by the generated one. The file should be manually modified to look like: ```c unsigned char MasterENI_xml_data[] = { ... }; unsigned int MasterENI_xml_data_size = ???; ``` 5. Start Keil µVision IDE and set the EcMasterDemoApp project as active. 6. If needed, change debug project settings. 7. Build and run EcMasterDemoApp. #### SEE ALSO [Running EcMasterDemo](gettingstarted_running-demo.html.md#running-ecmasterdemo) ## OS Compiler settings Besides the general settings from [Compiling the EcMasterDemo](gettingstarted_compiling.html.md#compiling-the-ecmasterdemo) the following settings are necessary to build the example application for CMSIS-RTOS (STM32). Extra include paths : ```default /SDK/INC/CMSIS-RTOS /Examples/Common/CMSIS-RTOS_STM32 ``` Extra source paths : ```default /Examples/Common/CMSIS-RTOS /Sources/OsLayer/CMSIS-RTOS ``` Extra library paths to the main EtherCAT® components : ```default /SDK/LIB/CMSIS-RTOS/mdk-arm ``` Extra libraries : ```default EcMaster.lib emllCmsisEth.lib EcMasterDemo.lib ``` Preprocessor definitions : ```default EC_SOCKET_IP_SUPPORTED if IP socket support is needed, e.g. for the Remote API Server (EcMasterRasServer.lib). ```
For `EC_SOCKET_IP_SUPPORTED` see *Keil::Network&MDK:Socket:BSD* . ## Setting up and running EcMasterDemo in STM32CubeIDE for STM32H747I-DISCO 1. Prerequisites : - STM32CubeIDE V1.5.0 - EC-Master V3.1 - *CMSIS-RTOS* sources package. Use git [https://github.com/ARM-software/CMSIS_5.git](https://github.com/ARM-software/CMSIS_5.git) or download from [https://github.com/ARM-software/CMSIS_5/archive/develop.zip](https://github.com/ARM-software/CMSIS_5/archive/develop.zip). : #### NOTE Alternative *ARM CMSIS Drivers for external devices* contains *CMSIS-RTOS* sources as well. - *ARM CMSIS Drivers for external devices* from [https://www.keil.com/dd2/pack/](https://www.keil.com/dd2/pack/) (for CMSIS PHY driver sources) - *STMicroelectronics STM32H7 Series Device Support and Examples* from [https://www.keil.com/dd2/pack/](https://www.keil.com/dd2/pack/) (for CMSIS MAC driver sources) 2. Environment variables : In order to be able to build and run the demo application the following environment variables (either system or project variables) have to be defined: - **CMSIS_LOC**, has to be set to the CMSIS package location, i.e. `C:/CMSIS_5-5.7.0` - **FW_LOC**, points to the firmware folder in STM32Cube repository, i.e. `/STM32Cube_FW_H7_V1.8.0` - **PATH** variable must contain the following paths (needed for tool chain): : ```default C:/ST/STM32CubeIDE_1.5.0/STM32CubeIDE/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.7-2018-q2-update.win32_1.5.0.202011040924/tools/bin C:/ST/STM32CubeIDE_1.5.0/STM32CubeIDE/plugins/com.st.stm32cube.ide.mcu.externaltools.make.win32_1.5.0.202011040924/tools/bin ``` - **PACKS_LOC**, points to the packs location, where *ARM CMSIS Drivers for external devices* and *STMicroelectronics STM32H7 Series Device Support and Examples* were installed, i.e. `C:/Users//AppData/Local/Arm/Packs` 3. Build EcMasterDemo : - Build the EcMasterDemo project - Create EtherCAT® network configuration - Build the EcMasterDemo_STM32H747I-DISCO project for CM7 CPU 4. Run on a STM32H747I-DISCO board : - Connect the board to PC using CN2 connector. This connection will be used for powering the board and for debugging as well. - Connect EtherCAT® cable to the Ethernet interface on the board and the EtherCAT® SubDevice(s). - Power on EtherCAT® SubDevice(s). - Using your favorite terminal application (i.e. Teraterm) connect to the serial port of STM32H747I-DISCO. Usually it is called *STMicroelectronics STLink Virtual COM Port*. Ensure it has the following settings: `115200,8,N,1`. - Create a debug or run configuration, select *STM32 Cortex-M C/C++ Application* as template. For this configuration select *SWD* in *GDB Server Command Line Options*.
#### NOTE in order to let the application run with different command line parameter please change `szCommandLine` declared in `app_main.c`