2 Replies Latest reply on Nov 2, 2015 8:52 AM by prashast.srivastava

    Changing assembly level code of Blink example

    prashast.srivastava

      Hi. I have a galileo gen2 board with a fully featured micro SD card on board. So I have this project where I need to make certain changes to the assembly code which is generated for the source code which is gonna be run on the galileo board. Right now I am using a normal Blink example.

       

      I have the eclipse IDE but I wasn't able to find any particular plugin which could help me in making assembly level changes to the blink code and upload that to the board. I have a cross compiler toolchain setup on my workstation as well. So my question is  is it possible to run blink code on my galileo board if I cross compile the blink code using the cross compile toolchain and then transfer the binary to the galileo board over to the linux image through ssh and execute it over there? I tried cross compiling the source code given below but my toolchain wasn't able to find "mraa.h".

       

       

      #include "mraa.h"

      #include <stdio.h>

      #include <unistd.h>

      int main()

      {

          // select onboard LED pin based on the platform type

          // create a GPIO object from MRAA using it

          mraa_platform_t platform = mraa_get_platform_type();

          mraa_gpio_context d_pin = NULL;

          switch (platform) {

              case MRAA_INTEL_GALILEO_GEN1:

                  d_pin = mraa_gpio_init_raw(3);

                  break;

              case MRAA_INTEL_GALILEO_GEN2:

                  d_pin = mraa_gpio_init(13);

                  break ;

              case MRAA_INTEL_EDISON_FAB_C:

                  d_pin = mraa_gpio_init(13);

                  break;

              default:

                  fprintf(stderr, "Unsupported platform, exiting");

                  return MRAA_ERROR_INVALID_PLATFORM;

          }

          if (d_pin == NULL) {

              fprintf(stderr, "MRAA couldn't initialize GPIO, exiting");

              return MRAA_ERROR_UNSPECIFIED;

          }

       

          // set the pin as output

          if (mraa_gpio_dir(d_pin, MRAA_GPIO_OUT) != MRAA_SUCCESS) {

              fprintf(stderr, "Can't set digital pin as output, exiting");

              return MRAA_ERROR_UNSPECIFIED;

          };

       

          // loop forever toggling the on board LED every second

          for (;;) {

              mraa_gpio_write(d_pin, 0);

              sleep(1);

              mraa_gpio_write(d_pin, 1);

              sleep(1);

          }

       

          return MRAA_SUCCESS;

      }