Programming your SOMANET

There are two different ways of executing a binary application on your SOMANET Node, by running the software for development/debug purposes via the JTAG adapter or permanently flashing it into the on-board flash memory for production purposes.

At this point you should have already set up your XMOS development environment and have your application built and powered up.

Running an application from xTIMEcomposer

  1. When running an application on a SOMANET device, you need to connect it to your computer USB through an XTAG.

See also

See the specific documentation of your Core board to see how to connect it to an XTAG.

  1. After that we will have a look at the current configuration for running XCore applications. Go to Run > Run Configurations...

    ../../_images/Runconfig.png
  2. A pop-up window will show the different kind of applications to configure. Double click on XCore Application.

    ../../_images/Xcoreapplication.png
  3. A new dialog will open up with a new XCore application configuration. At this Main tab you have to select the application to run (Project box), and the binary (C/C++ Application box).

../../_images/Xcoreapplication1.png

Note

If the list of binaries is empty, it means that the application you selected is not built yet.

  1. What is really important at this point is to make sure that the xTIMEcomposer recognises properly the XTAG plugged to USB and the attached tiles* to it. In this case, the L1[0..3] represent the tiles on board of the Core C22. If the Target box does not show the right information about your hardware, check your connections and push Refresh list.

* a tile refers to a real processor kernel in the XMOS processor, whereas the cores are virtual. Each tile can have up to 8 cores.

../../_images/Xcoreapplication2.png
  1. In case you want to enable XScope, you must go to the XScope tab and select the Real-Time Mode.

    ../../_images/enable_xscope.png

Important

If you are using XScope in your application, and you are using a SOMANET Core C22, make sure that XScope is enabled in your Core to Debug Adaptor.

  1. Once the configuration is setted, just click on Apply and then on Run.

    ../../_images/Xcoreapplication3.png

Note

In most cases, it is convenient to set the Target I/O options over xSCOPE (via xCONNECT/UART) instead of JTAG in order to make console prints way faster.

  1. The application should run on your node and the application output messages must appear at the Console. In order to get your program stopped press the button Terminate.

    ../../_images/Xcoreapplication4.png

Running an application from the Command-Line Tools

It is also possible, once you have built an application, to just flash it over a SOMANET node without the xTIMEcomposer. When running an application on a SOMANET node from the terminal, it is required to include a Core to XTAG debug adaptor since your system will reach the node through the XTAG interface.

  1. First of all we will connect the Core to XTAG debug adapter within your node to your XTAG. The XTAG must be plugged to an USB port in your computer.

  2. Navigate to the folder containing your binary file and flash your application.

    cd path/to/your/executable
    xrun your_executable_file.xe
    

Flashing a node from the xTIMEcomposer

When flashing an application on a SOMANET node using the xTIMEcomposer, it is required to include a Core to XTAG debug adaptor since your xTIMEcomposer will reach the node through the XTAG interface.

  1. First of all we will connect the Core to XTAG debug adapter within your node to your XTAG. The XTAG must be plugged to an USB port in your computer.

  2. After that we will have a look at the current configuration for flashing XCore applications. Go to Run > Flash configurations...

    ../../_images/Flashconfig4.png
  3. A pop up window will show the different kind of applications to configure. Double click on XCore Application.

    ../../_images/Flash_xcoreapplication1.png
  4. A new dialog will open up the current configuration for running XCore applications. At this Main tab you can select the software component where your application is located (Project box) and the application to run (C/C++ Application box).

    ../../_images/Flashconfig11.png
  5. What is really important at this point is to make sure that the xTIMEcomposer recognises properly the XTAG plugged to USB and the attached tiles to it. In this case, the L1[0..3] represent the tiles on board the Core C22. If the Target box does not show the right information about your hardware, check your connections and push Refresh list.

    ../../_images/Xcoreapplication2.png
  6. Once the configuration is setted, just click on Apply and then on Flash.

    ../../_images/Flash_xcoreapplication31.png
  7. The Console must provide information about the flashing and notify any possible error. If everything goes well, a message will say output succeeded.

    ../../_images/Flash_xcoreapplication4.png

Flashing a node from the Command-Line Tools

It is also possible, once you have built an application, to just flash it over a SOMANET node without the xTIMEcomposer. When flashing an application on a SOMANET node from the terminal, it is required to include a Core to XTAG debug adaptor since your system will reach the node through the XTAG interface.

  1. First of all we will connect the Core to XTAG debug adapter within your node to your XTAG. The XTAG must be plugged to an USB port in your computer.

  2. Navigate to the folder containing your binary file and flash your application.

    xflash your_executable_file.xe
    

    Note

    If you are using Linux, you might first need to set the XMOS environment variables.

  3. A message should notify the flash was successful.

    xflash succeeded
    

Flashing a node using EtherCAT

Somanet-base software component provides an application called app_linux_fwupdate which enables the users to flash over EtherCAT. For this, once you have your binary file ready, you should have your node flashed with an application able to handle firmware updates through EtherCAT. This application is called app_fwupdate and it is located within somanet-base.

  1. Having your node ready to handle firmware updates over EtherCAT and connected to your host, we will work on the host side. We have to make sure that your EtherCAT Master Software is stopped, if we have installed it.

    sudo /etc/init.d/ethercat stop
    
  2. In your terminal we will navigate to the app_linux_fwupdate folder located at your sc_somanet-base project. That’s where we will compile the application.

    make
    
  3. Two executable files will be generated slaveinfo and fw_update. The first executable will provide information about the slave devices detected. We will normally look up at the eth0 or eth1 interface depending on your host machine configuration.

    sudo ./slaveinfo eth0
    
  4. The output should contain a large amount of information about your slave SOMANET module. Now that we know your node is ready, we can run fw_update. In case we want to flash all the connected slaves with the same binary file, we will run:

    sudo ./fw_update eth0 -all path/to/your/binary
    

    Important

    It is really important not to stop the flashing process, otherwise the Core module might not be flashable anymore.

  5. We could specify the node we want to flash by using the options -s, or -seq. For more information about how to use this application take a look at the documentation.

  6. If everything went well the terminal must say something like the message below. Restart your node to complete the flashing.

    Firmware Update succeeded for SOMANET slave XY
    Slave reached init state