Skip to content

Instantly share code, notes, and snippets.

@arkival
Last active March 21, 2018 00:31
Show Gist options
  • Select an option

  • Save arkival/f11088a0ded82484a47e to your computer and use it in GitHub Desktop.

Select an option

Save arkival/f11088a0ded82484a47e to your computer and use it in GitHub Desktop.

Revisions

  1. arkival renamed this gist Apr 4, 2015. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  2. arkival revised this gist Apr 4, 2015. 1 changed file with 2 additions and 4 deletions.
    6 changes: 2 additions & 4 deletions inteledison-cmdline.md
    Original file line number Diff line number Diff line change
    @@ -101,8 +101,6 @@ That's it really, the output of this command, `blink`, is an Edison executable.

    If you're compiling C++, the command is very similar, just use `i586-poky-linux-g++` instead of `i586-poky-linux-gcc`.




    ## Feedback ##


    If any of this is not clear, or you have further questions, please use the comments below.
  3. arkival revised this gist Apr 4, 2015. 1 changed file with 2 additions and 3 deletions.
    5 changes: 2 additions & 3 deletions inteledison-cmdline.md
    Original file line number Diff line number Diff line change
    @@ -27,10 +27,9 @@ Or, if you want to use C++:
    You can use the full names of the compilers if you prefer. For `gcc` use `i586-poky-linux-gcc` and for `g++` use `i586-poky-linux-g++`.



    ## OS X ##

    OS X is almost identical to linux except that at the current revision, there is not install file. So, after downloading the [cross compile tools (SDK)](http://www.intel.com/support/edison/sb/CS-035180.htm) for OS X and using `bunzip2` to extract the contents you will have a single tar file `poky-edison-eglibc-i386-edison-image-core2-32-toolchain-1.6.1.tar`. By default, the installation is expected to go in the same location as linux but since there is on script, we have to create the directories manually and extract the tar file into the directory.
    OS X is almost identical to linux except that at the current revision, there is no install file included in the distribution. So, after downloading the [cross compile tools (SDK)](http://www.intel.com/support/edison/sb/CS-035180.htm) for OS X and using `bunzip2` to extract the contents you will have a single tar file `poky-edison-eglibc-i386-edison-image-core2-32-toolchain-1.6.1.tar`. By default, the installation is expected to go in the same location as linux but since there is on script, we have to create the directories manually and extract the tar file into the directory. You will need admin privileges, so use sudo as shown.

    sudo mkdir -p /opt/poky-edison/1.6.1/
    sudo tar -vf poky-edison-eglibc-i386-edison-image-core2-32-toolchain-1.6.1.tar -C /opt/poky-edison/1.6.1/
    @@ -100,7 +99,7 @@ The command `i586-poky-linux-gcc` executes the gcc cross compiler referenced abo

    That's it really, the output of this command, `blink`, is an Edison executable. Copy it to your edison and run.

    If you're compiling C++, the command is very similar, just use `i586-poky-linux-g++` instead of `i586-poky-linux-gcc` .
    If you're compiling C++, the command is very similar, just use `i586-poky-linux-g++` instead of `i586-poky-linux-gcc`.



  4. arkival revised this gist Apr 4, 2015. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion inteledison-cmdline.md
    Original file line number Diff line number Diff line change
    @@ -100,7 +100,7 @@ The command `i586-poky-linux-gcc` executes the gcc cross compiler referenced abo

    That's it really, the output of this command, `blink`, is an Edison executable. Copy it to your edison and run.

    If you're compiling C++, the command is very similar, just use `i586-poky-linux-g++` instead.
    If you're compiling C++, the command is very similar, just use `i586-poky-linux-g++` instead of `i586-poky-linux-gcc` .



  5. arkival revised this gist Apr 4, 2015. 2 changed files with 109 additions and 1 deletion.
    1 change: 0 additions & 1 deletion inteledison-cmdline
    Original file line number Diff line number Diff line change
    @@ -1 +0,0 @@
    C/C++ cross compilation from the command line for the Intel Edison
    109 changes: 109 additions & 0 deletions inteledison-cmdline.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,109 @@
    # C/C++ cross compilation from the command line for the Intel Edison #

    It is not necessary to use the Eclipse environment in order to compile code for the Intel Edison. Command line compilation is possible on all platforms and is relatively straightforward. For linux and OS/X the simplest method is to download the SDK for the respective platform and setup as described below. Although Intel lists SDKs for both 32 and 64 bit Windows, I find it simpler to setup command line compilation from the integrated IOT platform installation.

    All three platforms use the GNU compiler tools (gcc, g++, and friends) and the main differences really come down to differences in the command shell usage. Consequently, the procedures have the following common elements.

    1. Install the cross compilation tool chain and library file-system.
    2. Setup the path so that the operating system can find the compilers and other utilities.
    3. Setup environment variables to simplify the command line and tell the compilers where to find libraries and include files.

    ## Linux ##

    For linux download the [cross compile tools (SDK)](http://www.intel.com/support/edison/sb/CS-035180.htm) for your platform, 32 or 64 bit. Unzip the archive in any directory and it will contain a `zip` file of the actual sdk, e.g., `edison-sdk-linux64-ww05-15.zip` and an installation shell file, e.g., `poky-edison-eglibc-x86_64-edison-image-core2-32-toolchain-1.6.1.sh`. When you run the `.sh` file it will prompt you for an install location, by default, `/opt/poky-edison/<version-number>`. Unless you have good reason to do otherwise, I suggest the default. At the time of writing, the current version was `1.6.1`. Once installed, you will find the system roots as well as a command to setup the environment variables in the base of the install directory.

    To setup the environment with the necessary variables and path modifications, execute the following command:

    `source /opt/poky-edison/1.6.1/environment-setup-core2-32-poky-linux`

    The standard environment variables, e.g., $CC are now setup and you can use these directly, for example, to compile `blink.c`.

    `$CC -lmraa blink.c -o blink`

    Or, if you want to use C++:

    `$CXX -lmraa Blink-IO.cpp -o blink`

    You can use the full names of the compilers if you prefer. For `gcc` use `i586-poky-linux-gcc` and for `g++` use `i586-poky-linux-g++`.



    ## OS X ##

    OS X is almost identical to linux except that at the current revision, there is not install file. So, after downloading the [cross compile tools (SDK)](http://www.intel.com/support/edison/sb/CS-035180.htm) for OS X and using `bunzip2` to extract the contents you will have a single tar file `poky-edison-eglibc-i386-edison-image-core2-32-toolchain-1.6.1.tar`. By default, the installation is expected to go in the same location as linux but since there is on script, we have to create the directories manually and extract the tar file into the directory.

    sudo mkdir -p /opt/poky-edison/1.6.1/
    sudo tar -vf poky-edison-eglibc-i386-edison-image-core2-32-toolchain-1.6.1.tar -C /opt/poky-edison/1.6.1/

    At this point the usage is identical to linux, repeated here for completeness:

    To setup the environment with the necessary variables and path modifications, execute the following command:

    `source /opt/poky-edison/1.6.1/environment-setup-core2-32-poky-linux`

    The standard environment variables, e.g., $CC are now setup and you can use these directly, for example, to compile `blink.c`.

    `$CC -lmraa blink.c -o blink`

    Or, if you want to use C++:

    `$CXX -lmraa Blink-IO.cpp -o blink`

    You can use the full names of the compilers if you prefer. For `gcc` use `i586-poky-linux-gcc` and for `g++` use `i586-poky-linux-g++`.



    ## Windows 32/64 ##

    For windows you do not want to download the SDKs. Scroll down until you see the [Windows 64 Integrated Installer](http://www.intel.com/support/edison/sb/CS-035180.htm) and download and start the installer.

    **This executable will run on a 32 bit system.** It will complain about needing 64 bit java, but we don't care because we are not going to use Eclipse to cross compile Edison code. Just click next after you see the warning message about 64 bit Java.

    When you get to the prompt asking you which packages to install, other than the the drivers, which you need in order to talk to the Edison, you only need to install the Eclipse IDE in order to cross compile C and C++. It doesn't hurt to install the XDK or Arduino, however, if you so choose.

    After the installation finishes you will want to bring up a `CMD` prompt and navigate your way to the dev kit installation. If you installed in the default location `C:\Intel`, then the batch file discussed below can be used as is. If you install in any other location, you will have to modify one line in the batch file as described.

    Navigate to the dev kit directory:

    CD C:\Intel\iotdk-ide-win

    You should be in the directory that contains `devkit_launcher.bat`. Open an editor, notepad is fine, and create the following batch file. I named it `xcompile.bat`.


    @ECHO OFF

    REM Batch file to setup cross compliation on windows

    # Modify the following line to point to your install location if you do not use the default.
    #
    set DEVKIT_HOME=C:\Intel\iotdk-ide-win

    set PATH=%DEVKIT_HOME%\devkit-x86\sysroots\x86_64-pokysdk-mingw32\usr\bin\i586-poky-linux;%DEVKIT_HOME%\iot-devkit\devkit-debugger;%PATH%
    set POKY_HOME=%DEVKIT_HOME%\devkit-x86\sysroots\i586-poky-linux

    This file takes care of steps (2) and (3) listed above. The `PATH` environment variable will be modified so that the system can find the compiler and we setup the `POKY_HOME` variable to simplify the compiler command line.

    After you have created the file, run it by typing xcompile at the command prompt:

    C:\Intel\iotdk-ide-win>xcompile
    C:\Intel\iotdk-ide-win>

    Your environment is now setup to compile from the command line. You only need to run this batch file once when you open a command window. You can also setup a shortcut to both open a command window and run the batch file.

    Navigate to wherever your source code ls located and run the following command to cross compile. This code is identical for 32 or 64 bit windows.

    To compile `blink.c` use the following command:

    `i586-poky-linux-gcc --sysroot=%POKY_LINUX% -lmraa blink.c -o blink`

    The command `i586-poky-linux-gcc` executes the gcc cross compiler referenced above. The `--sysroot` option tells the compiler to use the environment variable setup in the batch file as the base directory for include and library files, and the `-lmraa` option tells `gcc` to include the `mraa` library.

    That's it really, the output of this command, `blink`, is an Edison executable. Copy it to your edison and run.

    If you're compiling C++, the command is very similar, just use `i586-poky-linux-g++` instead.






  6. arkival revised this gist Apr 4, 2015. 1 changed file with 1 addition and 109 deletions.
    110 changes: 1 addition & 109 deletions inteledison-cmdline
    Original file line number Diff line number Diff line change
    @@ -1,109 +1 @@
    # C/C++ cross compilation from the command line for the Intel Edison #

    It is not necessary to use the Eclipse environment in order to compile code for the Intel Edison. Command line compilation is possible on all platforms and is relatively straightforward. For linux and OS/X the simplest method is to download the SDK for the respective platform and setup as described below. Although Intel lists SDKs for both 32 and 64 bit Windows, I find it simpler to setup command line compilation from the integrated IOT platform installation.

    All three platforms use the GNU compiler tools (gcc, g++, and friends) and the main differences really come down to differences in the command shell usage. Consequently, the procedures have the following common elements.

    1. Install the cross compilation tool chain and library file-system.
    2. Setup the path so that the operating system can find the compilers and other utilities.
    3. Setup environment variables to simplify the command line and tell the compilers where to find libraries and include files.

    ## Linux ##

    For linux download the [cross compile tools (SDK)](http://www.intel.com/support/edison/sb/CS-035180.htm) for your platform, 32 or 64 bit. Unzip the archive in any directory and it will contain a `zip` file of the actual sdk, e.g., `edison-sdk-linux64-ww05-15.zip` and an installation shell file, e.g., `poky-edison-eglibc-x86_64-edison-image-core2-32-toolchain-1.6.1.sh`. When you run the `.sh` file it will prompt you for an install location, by default, `/opt/poky-edison/<version-number>`. Unless you have good reason to do otherwise, I suggest the default. At the time of writing, the current version was `1.6.1`. Once installed, you will find the system roots as well as a command to setup the environment variables in the base of the install directory.

    To setup the environment with the necessary variables and path modifications, execute the following command:

    `source /opt/poky-edison/1.6.1/environment-setup-core2-32-poky-linux`

    The standard environment variables, e.g., $CC are now setup and you can use these directly, for example, to compile `blink.c`.

    `$CC -lmraa blink.c -o blink`

    Or, if you want to use C++:

    `$CXX -lmraa Blink-IO.cpp -o blink`

    You can use the full names of the compilers if you prefer. For `gcc` use `i586-poky-linux-gcc` and for `g++` use `i586-poky-linux-g++`.



    ## OS X ##

    OS X is almost identical to linux except that at the current revision, there is not install file. So, after downloading the [cross compile tools (SDK)](http://www.intel.com/support/edison/sb/CS-035180.htm) for OS X and using `bunzip2` to extract the contents you will have a single tar file `poky-edison-eglibc-i386-edison-image-core2-32-toolchain-1.6.1.tar`. By default, the installation is expected to go in the same location as linux but since there is on script, we have to create the directories manually and extract the tar file into the directory.

    sudo mkdir -p /opt/poky-edison/1.6.1/
    sudo tar -vf poky-edison-eglibc-i386-edison-image-core2-32-toolchain-1.6.1.tar -C /opt/poky-edison/1.6.1/

    At this point the usage is identical to linux, repeated here for completeness:

    To setup the environment with the necessary variables and path modifications, execute the following command:

    `source /opt/poky-edison/1.6.1/environment-setup-core2-32-poky-linux`

    The standard environment variables, e.g., $CC are now setup and you can use these directly, for example, to compile `blink.c`.

    `$CC -lmraa blink.c -o blink`

    Or, if you want to use C++:

    `$CXX -lmraa Blink-IO.cpp -o blink`

    You can use the full names of the compilers if you prefer. For `gcc` use `i586-poky-linux-gcc` and for `g++` use `i586-poky-linux-g++`.



    ## Windows 32/64 ##

    For windows you do not want to download the SDKs. Scroll down until you see the [Windows 64 Integrated Installer](http://www.intel.com/support/edison/sb/CS-035180.htm) and download and start the installer.

    **This executable will run on a 32 bit system.** It will complain about needing 64 bit java, but we don't care because we are not going to use Eclipse to cross compile Edison code. Just click next after you see the warning message about 64 bit Java.

    When you get to the prompt asking you which packages to install, other than the the drivers, which you need in order to talk to the Edison, you only need to install the Eclipse IDE in order to cross compile C and C++. It doesn't hurt to install the XDK or Arduino, however, if you so choose.

    After the installation finishes you will want to bring up a `CMD` prompt and navigate your way to the dev kit installation. If you installed in the default location `C:\Intel`, then the batch file discussed below can be used as is. If you install in any other location, you will have to modify one line in the batch file as described.

    Navigate to the dev kit directory:

    CD C:\Intel\iotdk-ide-win

    You should be in the directory that contains `devkit_launcher.bat`. Open an editor, notepad is fine, and create the following batch file. I named it `xcompile.bat`.


    @ECHO OFF

    REM Batch file to setup cross compliation on windows

    # Modify the following line to point to your install location if you do not use the default.
    #
    set DEVKIT_HOME=C:\Intel\iotdk-ide-win

    set PATH=%DEVKIT_HOME%\devkit-x86\sysroots\x86_64-pokysdk-mingw32\usr\bin\i586-poky-linux;%DEVKIT_HOME%\iot-devkit\devkit-debugger;%PATH%
    set POKY_HOME=%DEVKIT_HOME%\devkit-x86\sysroots\i586-poky-linux

    This file takes care of steps (2) and (3) listed above. The `PATH` environment variable will be modified so that the system can find the compiler and we setup the `POKY_HOME` variable to simplify the compiler command line.

    After you have created the file, run it by typing xcompile at the command prompt:

    C:\Intel\iotdk-ide-win>xcompile
    C:\Intel\iotdk-ide-win>

    Your environment is now setup to compile from the command line. You only need to run this batch file once when you open a command window. You can also setup a shortcut to both open a command window and run the batch file.

    Navigate to wherever your source code ls located and run the following command to cross compile. This code is identical for 32 or 64 bit windows.

    To compile `blink.c` use the following command:

    `i586-poky-linux-gcc --sysroot=%POKY_LINUX% -lmraa blink.c -o blink`

    The command `i586-poky-linux-gcc` executes the gcc cross compiler referenced above. The `--sysroot` option tells the compiler to use the environment variable setup in the batch file as the base directory for include and library files, and the `-lmraa` option tells `gcc` to include the `mraa` library.

    That's it really, the output of this command, `blink`, is an Edison executable. Copy it to your edison and run.

    If you're compiling C++, the command is very similar, just use `i586-poky-linux-g++` instead.






    C/C++ cross compilation from the command line for the Intel Edison
  7. arkival created this gist Apr 4, 2015.
    109 changes: 109 additions & 0 deletions inteledison-cmdline
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,109 @@
    # C/C++ cross compilation from the command line for the Intel Edison #

    It is not necessary to use the Eclipse environment in order to compile code for the Intel Edison. Command line compilation is possible on all platforms and is relatively straightforward. For linux and OS/X the simplest method is to download the SDK for the respective platform and setup as described below. Although Intel lists SDKs for both 32 and 64 bit Windows, I find it simpler to setup command line compilation from the integrated IOT platform installation.

    All three platforms use the GNU compiler tools (gcc, g++, and friends) and the main differences really come down to differences in the command shell usage. Consequently, the procedures have the following common elements.

    1. Install the cross compilation tool chain and library file-system.
    2. Setup the path so that the operating system can find the compilers and other utilities.
    3. Setup environment variables to simplify the command line and tell the compilers where to find libraries and include files.

    ## Linux ##

    For linux download the [cross compile tools (SDK)](http://www.intel.com/support/edison/sb/CS-035180.htm) for your platform, 32 or 64 bit. Unzip the archive in any directory and it will contain a `zip` file of the actual sdk, e.g., `edison-sdk-linux64-ww05-15.zip` and an installation shell file, e.g., `poky-edison-eglibc-x86_64-edison-image-core2-32-toolchain-1.6.1.sh`. When you run the `.sh` file it will prompt you for an install location, by default, `/opt/poky-edison/<version-number>`. Unless you have good reason to do otherwise, I suggest the default. At the time of writing, the current version was `1.6.1`. Once installed, you will find the system roots as well as a command to setup the environment variables in the base of the install directory.

    To setup the environment with the necessary variables and path modifications, execute the following command:

    `source /opt/poky-edison/1.6.1/environment-setup-core2-32-poky-linux`

    The standard environment variables, e.g., $CC are now setup and you can use these directly, for example, to compile `blink.c`.

    `$CC -lmraa blink.c -o blink`

    Or, if you want to use C++:

    `$CXX -lmraa Blink-IO.cpp -o blink`

    You can use the full names of the compilers if you prefer. For `gcc` use `i586-poky-linux-gcc` and for `g++` use `i586-poky-linux-g++`.



    ## OS X ##

    OS X is almost identical to linux except that at the current revision, there is not install file. So, after downloading the [cross compile tools (SDK)](http://www.intel.com/support/edison/sb/CS-035180.htm) for OS X and using `bunzip2` to extract the contents you will have a single tar file `poky-edison-eglibc-i386-edison-image-core2-32-toolchain-1.6.1.tar`. By default, the installation is expected to go in the same location as linux but since there is on script, we have to create the directories manually and extract the tar file into the directory.

    sudo mkdir -p /opt/poky-edison/1.6.1/
    sudo tar -vf poky-edison-eglibc-i386-edison-image-core2-32-toolchain-1.6.1.tar -C /opt/poky-edison/1.6.1/

    At this point the usage is identical to linux, repeated here for completeness:

    To setup the environment with the necessary variables and path modifications, execute the following command:

    `source /opt/poky-edison/1.6.1/environment-setup-core2-32-poky-linux`

    The standard environment variables, e.g., $CC are now setup and you can use these directly, for example, to compile `blink.c`.

    `$CC -lmraa blink.c -o blink`

    Or, if you want to use C++:

    `$CXX -lmraa Blink-IO.cpp -o blink`

    You can use the full names of the compilers if you prefer. For `gcc` use `i586-poky-linux-gcc` and for `g++` use `i586-poky-linux-g++`.



    ## Windows 32/64 ##

    For windows you do not want to download the SDKs. Scroll down until you see the [Windows 64 Integrated Installer](http://www.intel.com/support/edison/sb/CS-035180.htm) and download and start the installer.

    **This executable will run on a 32 bit system.** It will complain about needing 64 bit java, but we don't care because we are not going to use Eclipse to cross compile Edison code. Just click next after you see the warning message about 64 bit Java.

    When you get to the prompt asking you which packages to install, other than the the drivers, which you need in order to talk to the Edison, you only need to install the Eclipse IDE in order to cross compile C and C++. It doesn't hurt to install the XDK or Arduino, however, if you so choose.

    After the installation finishes you will want to bring up a `CMD` prompt and navigate your way to the dev kit installation. If you installed in the default location `C:\Intel`, then the batch file discussed below can be used as is. If you install in any other location, you will have to modify one line in the batch file as described.

    Navigate to the dev kit directory:

    CD C:\Intel\iotdk-ide-win

    You should be in the directory that contains `devkit_launcher.bat`. Open an editor, notepad is fine, and create the following batch file. I named it `xcompile.bat`.


    @ECHO OFF

    REM Batch file to setup cross compliation on windows

    # Modify the following line to point to your install location if you do not use the default.
    #
    set DEVKIT_HOME=C:\Intel\iotdk-ide-win

    set PATH=%DEVKIT_HOME%\devkit-x86\sysroots\x86_64-pokysdk-mingw32\usr\bin\i586-poky-linux;%DEVKIT_HOME%\iot-devkit\devkit-debugger;%PATH%
    set POKY_HOME=%DEVKIT_HOME%\devkit-x86\sysroots\i586-poky-linux

    This file takes care of steps (2) and (3) listed above. The `PATH` environment variable will be modified so that the system can find the compiler and we setup the `POKY_HOME` variable to simplify the compiler command line.

    After you have created the file, run it by typing xcompile at the command prompt:

    C:\Intel\iotdk-ide-win>xcompile
    C:\Intel\iotdk-ide-win>

    Your environment is now setup to compile from the command line. You only need to run this batch file once when you open a command window. You can also setup a shortcut to both open a command window and run the batch file.

    Navigate to wherever your source code ls located and run the following command to cross compile. This code is identical for 32 or 64 bit windows.

    To compile `blink.c` use the following command:

    `i586-poky-linux-gcc --sysroot=%POKY_LINUX% -lmraa blink.c -o blink`

    The command `i586-poky-linux-gcc` executes the gcc cross compiler referenced above. The `--sysroot` option tells the compiler to use the environment variable setup in the batch file as the base directory for include and library files, and the `-lmraa` option tells `gcc` to include the `mraa` library.

    That's it really, the output of this command, `blink`, is an Edison executable. Copy it to your edison and run.

    If you're compiling C++, the command is very similar, just use `i586-poky-linux-g++` instead.