https://wiki.emacinc.com/api.php?action=feedcontributions&user=Bserrano&feedformat=atomwiki.emacinc.com - User contributions [en]2024-03-28T18:49:44ZUser contributionsMediaWiki 1.31.6https://wiki.emacinc.com/index.php?title=Getting_Started_with_the_EMAC_OE_SDK&diff=4615Getting Started with the EMAC OE SDK2015-07-22T15:57:16Z<p>Bserrano: </p>
<hr />
<div>{{todo| Complete (03.31.2015-13:42->BS+);(04.08.2015-15:00->BS+);(04.09.15-14:00->MD+);(04.21.2015-10:15->BS+);(04.24.2015-20:00->MD-);(04.28.2015-12:20->MD+);(04.29.2015-16:00->BS+);(04.29.2015-17:30->MD+);(04.30.2015-15:30->KY+); (07.22.2015-11:00->BS+)|Brian Serrano| project=OE 5.0,BS,MD,Complete,KY}}<br />
{{#seo:<br />
|title=Getting Started with the EMAC OE SDK<br />
|titlemode=append<br />
|keywords=EMAC SDK,Cross compiling, ARM Target Compiling, CMake Build System, CMake Cross Compiling, CMake, CMake Arm<br />
|description=A basic tutorial for using the EMAC OE SDK.<br />
}}<br />
<br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /**************************************** Page Description Text ****************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
<br />
<span style="background:#00FF00;color:#FF0000;font-size:300%"></span><br />
The EMAC OE SDK is distributed with a set of example projects intended to demonstrate how to use the EMAC OE toolchain and libraries. This page demonstrates the process of compiling an example project and running it on the target machine. Also, it provides a straightforward guide to the essential steps you need to follow to get started with cross compiling a simple program with gcc and running the program on your embedded machine.<br />
<br />
__TOC__<br />
<br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /***************************************** General Information *****************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
{{:Templateimpl:geninfo | initials=BS | title=Getting Started with the EMAC OE SDK | desc=Basic tutorial for using the EMAC OE SDK. | project=OE 5.0 }}<br />
<br />
The EMAC OE SDK is primarily distributed via our apt repository as a deb package for Ubuntu. Using EMAC's apt repository makes installing and updating the EMAC SDK and tools as easy as installing and updating any standard Ubuntu package. This tutorial will show you how to configure your system to use the EMAC apt repository so that you can use the same package management tools you're familiar with in Ubuntu to install and update the EMAC provided SDK and tools.<br />
<br />
EMAC also provides a tarball you can extract and install manually in case you're using a distribution other than Ubuntu (or a derivative), but EMAC strongly recommends using an Ubuntu LTS release. The recent Ubuntu LTS releases have been thoroughly tested with the EMAC SDK and tools and are fully supported by EMAC. Given the large number of alternate Linux distributions available, EMAC is only able to provide limited support (in the form of a manually installed tarball) for other Linux distributions. <br />
<br />
Each SDK includes the C/C++ header files and libraries compatible with the target hardware. It also includes the C/C++ cross-compiler toolchain components necessary to compile and debug custom application code. The links below will help you get started building and running the example projects on the target hardware.<br />
<br />
More information on using Qt Creator with the EMAC SDK is available on the [[Getting_Started_With_Qt_Creator |Getting Started With Qt Creator]] page.<br />
<br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /***************************************** Using/Working With ******************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
{{:Templateimpl:using | initials=BS | title=Getting Started with the EMAC OE SDK | desc=Basic tutorial for using the EMAC OE SDK. | project=OE 5.0 }}<br />
<br />
=== Installing EMAC SDK ===<br />
<br />
This is the EMAC Apt Repository, which hosts installation files for EMAC provided tools built for 64 bit Ubuntu 12.04 LTS and 14.04 LTS. To use this repository, a source for it must be added to your apt sources, and the key for the repository must be added to your machine. The steps below outline how to do this. <br />
<br />
# Add the EMAC Repository as an Apt source:<br />
#:<br />
#:'''For Ubuntu 12.04 LTS:'''<br />
#:<br />
#:{{cli | username=developer | hostname=ldc | echo "deb http://apt.emacinc.com/ubuntu precise non-free" > /etc/apt/sources.list.d/emac.list }}<br />
#:<br />
#:'''For Ubuntu 14.04 LTS:'''<br />
#:<br />
#:{{cli | username=developer | hostname=ldc | echo "deb http://apt.emacinc.com/ubuntu trusty non-free" > /etc/apt/sources.list.d/emac.list }}<br />
#:<br />
# Add the EMAC Apt Key:<br />
#:<br />
#:{{cli | username=developer | hostname=ldc | sudo sh -c 'wget -O - http://apt.emacinc.com/packages.emac.key | apt-key add -' }}<br />
#:<br />
#:'''Note that the 'O' above is a capital letter 'o', not a zero.'''<br />
#:<br />
# Update your apt cache:<br />
#:<br />
#:{{cli | username=developer | hostname=ldc | sudo apt-get update }}<br />
#:<br />
# Search for and install desired EMAC packages:<br />
#:<br />
#:{{cli | username=developer | hostname=ldc | sudo apt-cache search emac- $ apt-get install emac-sdk }}<br />
<br />
=== Connecting to a Target Board ===<br />
<br />
A machine running EMAC OE Linux can be connected to through a serial port or through a network cable. EMAC OE Linux allows users to log in via getty, and SSH (Secure Shell). A getty can be accessed via a serial connection (through a console) while SSH utilizes a network connection. More information on establishing a physical connection to a board is available on the [[Serial_Connections |Serial Connections]] and [[Network_Connections |Network Connections]] page.<br />
<br />
The next step after establishing a physical connection to the board is logging in. For more information visit the [[System_Log_In | System Log In]] page.<br />
<br />
=== Setting the Filesystem to Read-Write ===<br />
The root filesystem on a machine running EMAC OE Linux is mounted read-only by default. In order to put files on the board, you may need to make the filesystem read-write. The [[Linux_Filesystem_Organization|Linux Filesystem Organization page]] has more information regarding which parts of the filesystem are mounted read-only by default versus which parts are always writeable. Note that EMAC recommends installing your program into a read-only portion of the filesystem (according to the guide) to safeguard it from filesystem corruption (such as may be caused by removing power from the board without shutting down the operating system first, which is normal in embedded systems).<br />
<br />
To remount the root filesytem in read-write mode, enter the following into the terminal: <br />
{{cli | oemntrw | hostname=ipac9x25}}<br />
<br />
{{note|This will only change the root filesystem to read-write for the current boot. When the system is rebooted, the root filesystem will once again be mounted read-only.}}<br />
<br />
=== Transferring Files ===<br />
The command line syntax for transferring a file using the SSH protocol is <code>scp file user@host:/directory</code>. SCP, or Secure Copy, is a way of securely transferring files between a local and remote host. For example, to send the file ''example.text'' to the <code>/home</code> directory of a system with the IP address 10.0.6.221, enter the following command:<br />
{{cli | username=developer | hostname=ldc | scp example.text root@10.0.6.221:/home/ }}<br />
<br />
Alternatively, you can leave off the path after the colon if you want the file to go directly into the home directory.<br />
<br />
{{cli | username=developer | hostname=ldc | scp example.text root@10.0.6.221: }}<br />
<br />
{{note|This copy operation will fail if the filesystem on the remote machine is mounted read-only, which is the default on most EMAC systems. If you experience this failure, remount the root filesystem read-write (see above) and try again.}}<br />
<br />
=== Remote Execution ===<br />
SSH can also be used to execute programs on remote systems without logging in. The syntax for SSH remote execution is <code>ssh user@host "my_command -args file"</code>. The following is an example of a command to run a program on a board with the IP address ''10.0.6.221''.<br />
<br />
{{cli | username=developer | hostname=ldc | ssh root@10.0.6.221 "/path/to/executable -args" }}<br />
<br />
<br />
=== Basic Compiling ===<br />
The two subsections below show the two common options for how to compile source code. The first subsection demonstrates how to use the EMAC [[ #CMake_Compiling| CMake ]] tool, while the second subsection demonstrates how to compile c code [[ #Manual_Compiling | manually ]].<br />
<br />
==== CMake Compiling ====<br />
===== Host Machine Compiling =====<br />
<br />
This section demonstrates how to use the EMAC CMake tool to generate CMake files automatically for a project. When using the EMAC SDK there are currently two options for cross compiling:<br />
* arm<br />
* x86<br />
For the purposes of this guide, the <tt>arm</tt> option will be used for the listed examples.<br />
<br />
Navigate to the directory where the project will be located. Then run the CMake new project script.<br />
{{clo}}<br />
{{clio | username=developer | hostname=ldc | pwd=~/projects | oe_init_project -n hello.c }}<br />
If desired, please enter a name for this project, otherwise press Enter to use the default: hello_emac <br /><br />
<br />
-- Creating new project directory... <br /><br />
-- Creating new source file... <br /><br />
-- Building custom CMakeLists.txt file... <br /><br />
-- Done. <br /><br />
<br />
Do you want to create a build directory for this project? (y/n) y <br /><br />
<br />
-- Creating build directory... <br /><br />
<br />
Do you want to run cmake for this project? (y/n) y <br /><br />
<br />
-- Using system compiler <br /><br />
-- The C compiler identification is GNU 4.8.2 <br /><br />
-- The CXX compiler identification is GNU 4.8.2 <br /><br />
-- Check for working C compiler: /usr/bin/cc <br /><br />
-- Check for working C compiler: /usr/bin/cc -- works <br /><br />
-- Detecting C compiler ABI info <br /><br />
-- Detecting C compiler ABI info - done <br /><br />
-- Check for working CXX compiler: /usr/bin/c++ <br /><br />
-- Check for working CXX compiler: /usr/bin/c++ -- works <br /><br />
-- Detecting CXX compiler ABI info <br /><br />
-- Detecting CXX compiler ABI info - done <br /><br />
-- Configuring done <br /><br />
-- Generating done <br /><br />
-- Build files have been written to: /home/developer/projects/hello_emac/hello_emac-build <br /><br />
<br />
Do you want to compile this project? (y/n) y<br />
<br />
Scanning dependencies of target hello_emac <br /><br />
[100%] Building C object CMakeFiles/hello_emac.dir/hello.c.o <br /><br />
Linking C executable hello_emac <br /><br />
[100%] Built target hello_emac <br /><br />
{{clos}}<br />
<br />
The executable, in this case, is now inside the <code> hello_emac/hello_emac-build </code> directory.<br />
<br />
===== Target Machine Compiling =====<br />
<br />
The CMake project script has now made a project directory that contains the following:<br />
* CMakeLists.txt<br />
* Source code file (''hello.c'' in this case)<br />
* ''README'' file<br />
* Desktop Build Directory (''hello_emac-build'' in this case)<br />
<br />
The ''CMakeLists.txt'' contains the required information to automatically create a ''Makefile'' for a given architecture. This was created by the EMAC <tt>oe_init_project</tt> script, and will need to be modified over time as a project grows. The comments in the file generated by the EMAC tool will provide a good starting point for how to add additional source files and how to perform other common tasks related to maintaining your CMake build system as your project grows. The CMake project provides extensive documentation on how to work with these files.<br />
<br />
The source code file generated by the script (''hello.c'') contains a basic Hello World style program.<br />
<br />
The ''README'' file contains more information on using ''CMake'' with the EMAC 5.0 SDK.<br />
<br />
The Desktop Build Directory (''hello_emac-build'') contains the executable ''hello_emac'', the ''Makefile'', and various cache files. These were automatically created by CMake and by the build system, and can be recreated at any time.<br />
<br />
It is useful to have a Desktop Build Directory because it is easier (in the beginning) to use the desktop to verify all code changes before cross-compiling for a target board. This will be useful until the application under development depends upon resources which are only available on the target hardware, such as certain devices drivers or the touchscreen (if so equipped).<br />
<br />
Use the following steps to cross-compile the project and send it to a target board.<br />
<br /><br />
<br /><br />
<cl><br />
1. In a terminal, navigate to the base directory of the project.<br />
{{note | If the target board being used is <tt>x86</tt>, then change all occurrences of <tt>arm</tt> in the following sections below to <tt>x86</tt>.}}<br />
* Create a build directory for cross compiling. <br />
{{cli | username=developer | hostname=ldc | pwd=~/projects/hello_emac | mkdir hello_emac-build-arm }} <br />
* Change directories into the newly created directory.<br />
{{cli | username=developer | hostname=ldc | pwd=~/projects/hello_emac | cd hello_emac-build-arm }} <br />
* Run cmake using the target architecture.<br />
{{cli | username=developer | hostname=ldc | pwd=~/projects/hello_emac/hello_emac-build-arm | 1 = cmake .. -DARCH:STRING=arm }} <br />
* Compile the code using make.<br />
{{cli | username=developer | hostname=ldc | pwd=~/projects/hello_emac/hello_emac-build-arm | make }} <br />
<br />
The <code> make </code> command creates the target executable in the <code> hello_emac-build-arm </code> directory.<br />
* Now copy the executable to the target board. For information on copying the executable file, see the [[ #Transferring_Files | Transferring Files ]] section.<br />
</cl><br />
<br /><br />
<br />
For other ways to generate the CMake files, visit the [[CMake | CMake ]] page.<br />
<br /><br />
<br /><br />
<br />
==== Manual Compiling ====<br />
===== Host Machine Compiling =====<br />
{{note|In these examples we are using the Ipac-9x25 board. Your board's processor's architecture will determine which file needs to be sourced. These files come from the EMAC SDK toolchain.}}<br />
<br />
Create a file called hello.c using a text editor such as vi, vim, nano, or gedit. Then copy and paste the source code from the [[ #Hello_World_System_Log_Example | Hello World System Log Example ]] section in the text editor of your choice.<br />
<br />
Once you've created and saved the file with the source code, use the following syntax to compile the program called hello.c:<br />
{{cli | username=developer | hostname=ldc | gcc -o hello hello.c }}<br />
<br />
If there is no error in your code then the compiler will successfully create an executable file called hello in the current directory.<br />
<br />
To verify this, enter the following command:<br />
{{clo}}<br />
{{clio | username=developer | hostname=ldc | ls -l hello* }}<br />
-rwxrwxr-x 1 bserrano bserrano 9583 Apr 6 12:45 hello <br /><br />
-rwxr-xr-x 1 bserrano bserrano 129 Apr 6 12:28 hello.c <br />
{{clos}}<br />
<br />
To run the program, enter the following command:<br />
{{clo}}<br />
{{clio | username=developer | hostname=ldc | ./hello }}<br />
Hello EMAC OE!<br />
{{clos}}<br />
<br />
OR<br />
{{clo}}<br />
{{clio | username=developer | hostname=ldc | /path/to/hello }}<br />
Hello EMAC OE!<br />
{{clos}}<br />
<br /><br />
<br /><br />
<br />
===== Target Board Compiling =====<br />
<br />
To compile for the target board, you must <code>source</code> the <code>environment-setup-armv5te-emac-linux-gnueabi</code> file.<br />
{{cli | username=developer | hostname=ldc | source /opt/emac/5.0/environment-setup-armv5te-emac-linux-gnueabi }}<br />
<br />
Once you are in the directory with the source file, enter the following command:<br />
{{cli | username=developer | hostname=ldc | $CC -o hello hello.c }}<br />
<br />
{{note|Once you source the file in your current terminal, you can only use it to cross-compile your program for the target board. You can no longer compile it for your host machine. To compile it to your host machine, simply open a new terminal.}}<br />
<br />
After sourcing the file, copy the program over to the target board using <code>scp</code>. Enter the following command:<br />
{{clo}}<br />
{{clio | username=developer | hostname=ldc | scp hello root@10.0.6.221: }}<br />
root@10.0.6.221's password: <br />
<br />
hello 100% 9583 9.4KB/s 00:00 <br />
{{clos}}<br />
<br />
After copying the program, you can now execute the program on the target board. Enter the following command:<br />
{{clo}}<br />
{{clio | username=developer | hostname=ldc | ssh root@10.0.6.221 ./hello}}<br />
root@10.0.6.221's password: <br /> <br />
Hello EMAC OE!<br />
{{clos}}<br />
<br /><br />
<br /><br />
<br />
=== Linux Filesystem Organization ===<br />
In order to prevent confusion and promote portability, a standard was created for the organization of the Linux filesystem. To ensure future portability of software created today, promote maintainability of software, and ensure proper utilization of available storage on an embedded machine, this standard should be followed as much as possible. This document covers parts of the standard and gives information about the customizations made to it by EMAC OE to accommodate embedded hardware. A link is provided to the standards document which covers the organization of the Linux filesystem at the end of this document. For more information visit the [[Linux_Filesystem_Organization | Linux Filesystem Organization]] page.<br />
<br />
EMAC recommends <tt>/usr/local/bin</tt> as the location for software you deploy.<br />
<br />
{{clo}}<br />
/usr/local/bin/<br />
{{clos}}<br />
<br />
{{note|It is important to pay attention to the filesystem structure in order to ensure that your application will work as expected when the filesystem is in production. Reasons for this include:<br />
<cl><br />
1. Only certain directories, such as <tt>/var/</tt> and <tt>/tmp/</tt>, are writeable when the filesystem is read-only.<br />
* Only certain directories should contain executables, such as <tt>/bin/</tt>, <tt>/usr/bin/</tt>, and <tt>/usr/local/bin/</tt>.<br />
* Following this directory structure properly will make it easier to port your software to a newer release of EMAC OE later on.<br />
</cl>}}<br />
<br />
=== Remote Debugging ===<br />
<br />
When working with embedded systems the binary is usually compiled on a development machine with a different CPU architecture than what is on the target machine. This can be a problem when, as is typically the case, the target machine lacks the system resources to run a debugger. In these cases, it is possible to use the GNU debugger (<tt>gdb</tt>) on the development machine to remotely debug the target machine provided it has a flavor-matched version of a program named <tt>gdbserver</tt>. All EMAC OE builds are packaged with a flavor-matched <tt>gdbserver</tt> to simplify the setup process for developers.<br />
<br />
{{note | A flavor-matched <tt>gdbserver</tt> is one which is built against the same source code revision as the <tt>gdb</tt> client for your desktop, because <tt>gdb</tt> does not have a stable interface for attaching to the <tt>gdbserver</tt>. In fact, the interface changes slightly with almost every release, so if you find yourself having difficulty getting <tt>gdb</tt> and <tt>gdbserver</tt> to communicate with each other, make sure they're the exact same version before trying any other debugging steps.}}<br />
<br />
For more information visit the [[Remote_Debugging_EMAC_OE_SDK_Projects_with_gdbserver | Remote Debugging EMAC OE SDK Projects with gdbserver]] page.<br />
<br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /***************************************** Examples *****************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
{{:Templateimpl:examples | initials=BS | title=Getting Started with the EMAC OE SDK | desc=Basic tutorial for using the EMAC OE SDK. | project=OE 5.0 }}<br />
<br />
=== Hello World System Log Example ===<br />
This example will print <code>Hello EMAC OE!</code> to the syslog facility as well as the console. This will allow you to log, debug, and send status messages to the system logger.<br />
<br />
To compile and run this program, see the sections above.<br />
<br />
<syntaxhighlight lang="c"><br />
#include <stdio.h><br />
#include <stdlib.h><br />
#include <unistd.h><br />
#include <syslog.h><br />
<br />
int main(int argc, char** argv)<br />
{ <br />
char message[] = "Hello EMAC OE!";<br />
<br />
openlog("slog", LOG_PID|LOG_CONS, LOG_USER);<br />
syslog(LOG_INFO, "%s", message);<br />
closelog(); <br />
<br />
printf("%s\n", message);<br />
<br />
return 0;<br />
}<br />
</syntaxhighlight><br />
<br />
This is extremely useful because it allows you to save a record of the output that you might not see first hand.<br />
<br />
To verify the output of the program went into syslog, enter the following command:<br />
{{clo}}<br />
{{clio | username=developer | hostname=ldc | tail /var/log/syslog}}<br />
Apr 7 14:10:06 ENG-26-LX dhclient: DHCPACK of 10.0.6.237 from 10.0.2.1<br /><br />
Apr 7 14:10:06 ENG-26-LX dhclient: bound to 10.0.6.237 -- renewal in 3306 seconds.<br /><br />
Apr 7 14:17:01 ENG-26-LX CRON[21193]: (root) CMD ( cd / && run-parts --report /etc/cron.hourly)<br /><br />
Apr 7 14:54:41 ENG-26-LX hpcups[21266]: prnt/hpcups/HPCupsFilter.cpp 689: First raster data plane..<br /><br />
Apr 7 14:55:31 hpcups[21266]: last message repeated 3 times<br /><br />
Apr 7 15:05:12 ENG-26-LX dhclient: DHCPREQUEST of 10.0.6.237 on eth0 to 10.0.2.1 port 67<br /><br />
Apr 7 15:05:12 ENG-26-LX dhclient: DHCPACK of 10.0.6.237 from 10.0.2.1<br /><br />
Apr 7 15:05:12 ENG-26-LX dhclient: bound to 10.0.6.237 -- renewal in 3559 seconds.<br /><br />
Apr 7 15:17:01 ENG-26-LX CRON[21302]: (root) CMD ( cd / && run-parts --report /etc/cron.hourly)<br /><br />
Apr 7 15:27:08 ENG-26-LX slog[21375]: Hello EMAC OE!<br />
{{clos}}<br />
<br />
As you can see on the bottom line, your program output has been recorded and date stamped in syslog.<br />
<br />
For more information on system logging visit the [[System_Logging| System Logging ]] page.<br />
<br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /****************************************** More Information *****************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
{{:Templateimpl:moreinfo | initials=BS | title=Getting Started with the EMAC OE SDK | desc=Basic tutorial for using the EMAC OE SDK. | project=OE 5.0 }}<br />
* [[Getting_Started_With_Qt_Creator |Getting Started With Qt Creator]]<br />
<br />
{{:Templateimpl:whatnext | initials=BS | title=Getting Started with the EMAC OE SDK | desc=Basic tutorial for using the EMAC OE SDK. | project=OE 5.0 }}<br />
* [[System_Log_In | System Log In]]<br />
* [[Serial_Connections | Serial Connections ]]<br />
* [[Network_Connections | Network_Connections ]]<br />
* [[System_Log_In | System Log In ]]<br />
* [[Remote_Debugging_EMAC_OE_SDK_Projects_with_gdbserver | Remote Debugging EMAC OE SDK Projects with gdbserver ]]<br />
* [[Linux_Filesystem_Organization | Linux Filesystem Organization]]<br />
* [[CMake | CMake ]]<br />
* [[Remote_Debugging_EMAC_OE_SDK_with_gdbserver | Remote Debugging EMAC OE SDK Projects with gdbserver]]<br />
* [[System_Logging | System Logging ]]</div>Bserranohttps://wiki.emacinc.com/index.php?title=Getting_Started_with_the_EMAC_OE_SDK&diff=4462Getting Started with the EMAC OE SDK2015-07-15T18:27:25Z<p>Bserrano: </p>
<hr />
<div>{{todo| Complete (03.31.2015-13:42->BS+);(04.08.2015-15:00->BS+);(04.09.15-14:00->MD+);(04.21.2015-10:15->BS+);(04.24.2015-20:00->MD-);(04.28.2015-12:20->MD+);(04.29.2015-16:00->BS+);(04.29.2015-17:30->MD+);(04.30.2015-15:30->KY+) |Brian Serrano| project=OE 5.0,BS,MD,Complete,KY}}<br />
{{#seo:<br />
|title=Getting Started with the EMAC OE SDK<br />
|titlemode=append<br />
|keywords=EMAC SDK,Cross compiling, ARM Target Compiling, CMake Build System, CMake Cross Compiling, CMake, CMake Arm<br />
|description=A basic tutorial for using the EMAC OE SDK.<br />
}}<br />
<br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /**************************************** Page Description Text ****************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
<br />
<span style="background:#00FF00;color:#FF0000;font-size:300%"></span><br />
The EMAC OE SDK is distributed with a set of example projects intended to demonstrate how to use the EMAC OE toolchain and libraries. This page demonstrates the process of compiling an example project and running it on the target machine. Also, it provides a straightforward guide to the essential steps you need to follow to get started with cross compiling a simple program with gcc and running the program on your embedded machine.<br />
<br />
__TOC__<br />
<br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /***************************************** General Information *****************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
{{:Templateimpl:geninfo | initials=BS | title=Getting Started with the EMAC OE SDK | desc=Basic tutorial for using the EMAC OE SDK. | project=OE 5.0 }}<br />
<br />
The EMAC OE SDK is primarily distributed via our apt repository as a deb package for Ubuntu. Using EMAC's apt repository makes installing and updating the EMAC SDK and tools as easy as installing and updating any standard Ubuntu package. This tutorial will show you how to configure your system to use the EMAC apt repository so that you can use the same package management tools you're familiar with in Ubuntu to install and update the EMAC provided SDK and tools.<br />
<br />
EMAC also provides a tarball you can extract and install manually in case you're using a distribution other than Ubuntu (or a derivative), but EMAC strongly recommends using an Ubuntu LTS release. The recent Ubuntu LTS releases have been thoroughly tested with the EMAC SDK and tools and are fully supported by EMAC. Given the large number of alternate Linux distributions available, EMAC is only able to provide limited support (in the form of a manually installed tarball) for other Linux distributions. <br />
<br />
Each SDK includes the C/C++ header files and libraries compatible with the target hardware. It also includes the C/C++ cross-compiler toolchain components necessary to compile and debug custom application code. The links below will help you get started building and running the example projects on the target hardware.<br />
<br />
More information on using Qt Creator with the EMAC SDK is available on the [[Getting_Started_With_Qt_Creator |Getting Started With Qt Creator]] page.<br />
<br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /***************************************** Using/Working With ******************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
{{:Templateimpl:using | initials=BS | title=Getting Started with the EMAC OE SDK | desc=Basic tutorial for using the EMAC OE SDK. | project=OE 5.0 }} <br />
=== Connecting to a Target Board ===<br />
<br />
A machine running EMAC OE Linux can be connected to through a serial port or through a network cable. EMAC OE Linux allows users to log in via getty, and SSH (Secure Shell). A getty can be accessed via a serial connection (through a console) while SSH utilizes a network connection. More information on establishing a physical connection to a board is available on the [[Serial_Connections |Serial Connections]] and [[Network_Connections |Network Connections]] page.<br />
<br />
The next step after establishing a physical connection to the board is logging in. For more information visit the [[System_Log_In | System Log In]] page.<br />
<br />
=== Setting the Filesystem to Read-Write ===<br />
The root filesystem on a machine running EMAC OE Linux is mounted read-only by default. In order to put files on the board, you may need to make the filesystem read-write. The [[Linux_Filesystem_Organization|Linux Filesystem Organization page]] has more information regarding which parts of the filesystem are mounted read-only by default versus which parts are always writeable. Note that EMAC recommends installing your program into a read-only portion of the filesystem (according to the guide) to safeguard it from filesystem corruption (such as may be caused by removing power from the board without shutting down the operating system first, which is normal in embedded systems).<br />
<br />
To remount the root filesytem in read-write mode, enter the following into the terminal: <br />
{{cli | oemntrw | hostname=ipac9x25}}<br />
<br />
{{note|This will only change the root filesystem to read-write for the current boot. When the system is rebooted, the root filesystem will once again be mounted read-only.}}<br />
<br />
=== Transferring Files ===<br />
The command line syntax for transferring a file using the SSH protocol is <code>scp file user@host:/directory</code>. SCP, or Secure Copy, is a way of securely transferring files between a local and remote host. For example, to send the file ''example.text'' to the <code>/home</code> directory of a system with the IP address 10.0.6.221, enter the following command:<br />
{{cli | username=developer | hostname=ldc | scp example.text root@10.0.6.221:/home/ }}<br />
<br />
Alternatively, you can leave off the path after the colon if you want the file to go directly into the home directory.<br />
<br />
{{cli | username=developer | hostname=ldc | scp example.text root@10.0.6.221: }}<br />
<br />
{{note|This copy operation will fail if the filesystem on the remote machine is mounted read-only, which is the default on most EMAC systems. If you experience this failure, remount the root filesystem read-write (see above) and try again.}}<br />
<br />
=== Remote Execution ===<br />
SSH can also be used to execute programs on remote systems without logging in. The syntax for SSH remote execution is <code>ssh user@host "my_command -args file"</code>. The following is an example of a command to run a program on a board with the IP address ''10.0.6.221''.<br />
<br />
{{cli | username=developer | hostname=ldc | ssh root@10.0.6.221 "/path/to/executable -args" }}<br />
<br />
<br />
=== Basic Compiling ===<br />
The two subsections below show the two common options for how to compile source code. The first subsection demonstrates how to use the EMAC [[ #CMake_Compiling| CMake ]] tool, while the second subsection demonstrates how to compile c code [[ #Manual_Compiling | manually ]].<br />
<br />
==== CMake Compiling ====<br />
===== Host Machine Compiling =====<br />
<br />
This section demonstrates how to use the EMAC CMake tool to generate CMake files automatically for a project. When using the EMAC SDK there are currently two options for cross compiling:<br />
* arm<br />
* x86<br />
For the purposes of this guide, the <tt>arm</tt> option will be used for the listed examples.<br />
<br />
Navigate to the directory where the project will be located. Then run the CMake new project script.<br />
{{clo}}<br />
{{clio | username=developer | hostname=ldc | pwd=~/projects | oe_init_project -n hello.c }}<br />
If desired, please enter a name for this project, otherwise press Enter to use the default: hello_emac <br /><br />
<br />
-- Creating new project directory... <br /><br />
-- Creating new source file... <br /><br />
-- Building custom CMakeLists.txt file... <br /><br />
-- Done. <br /><br />
<br />
Do you want to create a build directory for this project? (y/n) y <br /><br />
<br />
-- Creating build directory... <br /><br />
<br />
Do you want to run cmake for this project? (y/n) y <br /><br />
<br />
-- Using system compiler <br /><br />
-- The C compiler identification is GNU 4.8.2 <br /><br />
-- The CXX compiler identification is GNU 4.8.2 <br /><br />
-- Check for working C compiler: /usr/bin/cc <br /><br />
-- Check for working C compiler: /usr/bin/cc -- works <br /><br />
-- Detecting C compiler ABI info <br /><br />
-- Detecting C compiler ABI info - done <br /><br />
-- Check for working CXX compiler: /usr/bin/c++ <br /><br />
-- Check for working CXX compiler: /usr/bin/c++ -- works <br /><br />
-- Detecting CXX compiler ABI info <br /><br />
-- Detecting CXX compiler ABI info - done <br /><br />
-- Configuring done <br /><br />
-- Generating done <br /><br />
-- Build files have been written to: /home/developer/projects/hello_emac/hello_emac-build <br /><br />
<br />
Do you want to compile this project? (y/n) y<br />
<br />
Scanning dependencies of target hello_emac <br /><br />
[100%] Building C object CMakeFiles/hello_emac.dir/hello.c.o <br /><br />
Linking C executable hello_emac <br /><br />
[100%] Built target hello_emac <br /><br />
{{clos}}<br />
<br />
The executable, in this case, is now inside the <code> hello_emac/hello_emac-build </code> directory.<br />
<br />
===== Target Machine Compiling =====<br />
<br />
The CMake project script has now made a project directory that contains the following:<br />
* CMakeLists.txt<br />
* Source code file (''hello.c'' in this case)<br />
* ''README'' file<br />
* Desktop Build Directory (''hello_emac-build'' in this case)<br />
<br />
The ''CMakeLists.txt'' contains the required information to automatically create a ''Makefile'' for a given architecture. This was created by the EMAC <tt>oe_init_project</tt> script, and will need to be modified over time as a project grows. The comments in the file generated by the EMAC tool will provide a good starting point for how to add additional source files and how to perform other common tasks related to maintaining your CMake build system as your project grows. The CMake project provides extensive documentation on how to work with these files.<br />
<br />
The source code file generated by the script (''hello.c'') contains a basic Hello World style program.<br />
<br />
The ''README'' file contains more information on using ''CMake'' with the EMAC 5.0 SDK.<br />
<br />
The Desktop Build Directory (''hello_emac-build'') contains the executable ''hello_emac'', the ''Makefile'', and various cache files. These were automatically created by CMake and by the build system, and can be recreated at any time.<br />
<br />
It is useful to have a Desktop Build Directory because it is easier (in the beginning) to use the desktop to verify all code changes before cross-compiling for a target board. This will be useful until the application under development depends upon resources which are only available on the target hardware, such as certain devices drivers or the touchscreen (if so equipped).<br />
<br />
Use the following steps to cross-compile the project and send it to a target board.<br />
<br /><br />
<br /><br />
<cl><br />
1. In a terminal, navigate to the base directory of the project.<br />
{{note | If the target board being used is <tt>x86</tt>, then change all occurrences of <tt>arm</tt> in the following sections below to <tt>x86</tt>.}}<br />
* Create a build directory for cross compiling. <br />
{{cli | username=developer | hostname=ldc | pwd=~/projects/hello_emac | mkdir hello_emac-build-arm }} <br />
* Change directories into the newly created directory.<br />
{{cli | username=developer | hostname=ldc | pwd=~/projects/hello_emac | cd hello_emac-build-arm }} <br />
* Run cmake using the target architecture.<br />
{{cli | username=developer | hostname=ldc | pwd=~/projects/hello_emac/hello_emac-build-arm | 1 = cmake .. -DARCH:STRING=arm }} <br />
* Compile the code using make.<br />
{{cli | username=developer | hostname=ldc | pwd=~/projects/hello_emac/hello_emac-build-arm | make }} <br />
<br />
The <code> make </code> command creates the target executable in the <code> hello_emac-build-arm </code> directory.<br />
* Now copy the executable to the target board. For information on copying the executable file, see the [[ #Transferring_Files | Transferring Files ]] section.<br />
</cl><br />
<br /><br />
<br />
For other ways to generate the CMake files, visit the [[CMake | CMake ]] page.<br />
<br /><br />
<br /><br />
<br />
==== Manual Compiling ====<br />
===== Host Machine Compiling =====<br />
{{note|In these examples we are using the Ipac-9x25 board. Your board's processor's architecture will determine which file needs to be sourced. These files come from the EMAC SDK toolchain.}}<br />
<br />
Create a file called hello.c using a text editor such as vi, vim, nano, or gedit. Then copy and paste the source code from the [[ #Hello_World_System_Log_Example | Hello World System Log Example ]] section in the text editor of your choice.<br />
<br />
Once you've created and saved the file with the source code, use the following syntax to compile the program called hello.c:<br />
{{cli | username=developer | hostname=ldc | gcc -o hello hello.c }}<br />
<br />
If there is no error in your code then the compiler will successfully create an executable file called hello in the current directory.<br />
<br />
To verify this, enter the following command:<br />
{{clo}}<br />
{{clio | username=developer | hostname=ldc | ls -l hello* }}<br />
-rwxrwxr-x 1 bserrano bserrano 9583 Apr 6 12:45 hello <br /><br />
-rwxr-xr-x 1 bserrano bserrano 129 Apr 6 12:28 hello.c <br />
{{clos}}<br />
<br />
To run the program, enter the following command:<br />
{{clo}}<br />
{{clio | username=developer | hostname=ldc | ./hello }}<br />
Hello EMAC OE!<br />
{{clos}}<br />
<br />
OR<br />
{{clo}}<br />
{{clio | username=developer | hostname=ldc | /path/to/hello }}<br />
Hello EMAC OE!<br />
{{clos}}<br />
<br /><br />
<br /><br />
<br />
===== Target Board Compiling =====<br />
<br />
To compile for the target board, you must <code>source</code> the <code>environment-setup-armv5te-emac-linux-gnueabi</code> file.<br />
{{cli | username=developer | hostname=ldc | source /opt/emac/5.0/environment-setup-armv5te-emac-linux-gnueabi }}<br />
<br />
Once you are in the directory with the source file, enter the following command:<br />
{{cli | username=developer | hostname=ldc | $CC -o hello hello.c }}<br />
<br />
{{note|Once you source the file in your current terminal, you can only use it to cross-compile your program for the target board. You can no longer compile it for your host machine. To compile it to your host machine, simply open a new terminal.}}<br />
<br />
After sourcing the file, copy the program over to the target board using <code>scp</code>. Enter the following command:<br />
{{clo}}<br />
{{clio | username=developer | hostname=ldc | scp hello root@10.0.6.221: }}<br />
root@10.0.6.221's password: <br />
<br />
hello 100% 9583 9.4KB/s 00:00 <br />
{{clos}}<br />
<br />
After copying the program, you can now execute the program on the target board. Enter the following command:<br />
{{clo}}<br />
{{clio | username=developer | hostname=ldc | ssh root@10.0.6.221 ./hello}}<br />
root@10.0.6.221's password: <br /> <br />
Hello EMAC OE!<br />
{{clos}}<br />
<br /><br />
<br /><br />
<br />
=== Linux Filesystem Organization ===<br />
In order to prevent confusion and promote portability, a standard was created for the organization of the Linux filesystem. To ensure future portability of software created today, promote maintainability of software, and ensure proper utilization of available storage on an embedded machine, this standard should be followed as much as possible. This document covers parts of the standard and gives information about the customizations made to it by EMAC OE to accommodate embedded hardware. A link is provided to the standards document which covers the organization of the Linux filesystem at the end of this document. For more information visit the [[Linux_Filesystem_Organization | Linux Filesystem Organization]] page.<br />
<br />
EMAC recommends <tt>/usr/local/bin</tt> as the location for software you deploy.<br />
<br />
{{clo}}<br />
/usr/local/bin/<br />
{{clos}}<br />
<br />
{{note|It is important to pay attention to the filesystem structure in order to ensure that your application will work as expected when the filesystem is in production. Reasons for this include:<br />
<cl><br />
1. Only certain directories, such as <tt>/var/</tt> and <tt>/tmp/</tt>, are writeable when the filesystem is read-only.<br />
* Only certain directories should contain executables, such as <tt>/bin/</tt>, <tt>/usr/bin/</tt>, and <tt>/usr/local/bin/</tt>.<br />
* Following this directory structure properly will make it easier to port your software to a newer release of EMAC OE later on.<br />
</cl>}}<br />
<br />
=== Remote Debugging ===<br />
<br />
When working with embedded systems the binary is usually compiled on a development machine with a different CPU architecture than what is on the target machine. This can be a problem when, as is typically the case, the target machine lacks the system resources to run a debugger. In these cases, it is possible to use the GNU debugger (<tt>gdb</tt>) on the development machine to remotely debug the target machine provided it has a flavor-matched version of a program named <tt>gdbserver</tt>. All EMAC OE builds are packaged with a flavor-matched <tt>gdbserver</tt> to simplify the setup process for developers.<br />
<br />
{{note | A flavor-matched <tt>gdbserver</tt> is one which is built against the same source code revision as the <tt>gdb</tt> client for your desktop, because <tt>gdb</tt> does not have a stable interface for attaching to the <tt>gdbserver</tt>. In fact, the interface changes slightly with almost every release, so if you find yourself having difficulty getting <tt>gdb</tt> and <tt>gdbserver</tt> to communicate with each other, make sure they're the exact same version before trying any other debugging steps.}}<br />
<br />
For more information visit the [[Remote_Debugging_EMAC_OE_SDK_Projects_with_gdbserver | Remote Debugging EMAC OE SDK Projects with gdbserver]] page.<br />
<br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /***************************************** Examples *****************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
{{:Templateimpl:examples | initials=BS | title=Getting Started with the EMAC OE SDK | desc=Basic tutorial for using the EMAC OE SDK. | project=OE 5.0 }}<br />
<br />
=== Hello World System Log Example ===<br />
This example will print <code>Hello EMAC OE!</code> to the syslog facility as well as the console. This will allow you to log, debug, and send status messages to the system logger.<br />
<br />
To compile and run this program, see the sections above.<br />
<br />
<syntaxhighlight lang="c"><br />
#include <stdio.h><br />
#include <stdlib.h><br />
#include <unistd.h><br />
#include <syslog.h><br />
<br />
int main(int argc, char** argv)<br />
{ <br />
char message[] = "Hello EMAC OE!";<br />
<br />
openlog("slog", LOG_PID|LOG_CONS, LOG_USER);<br />
syslog(LOG_INFO, "%s", message);<br />
closelog(); <br />
<br />
printf("%s\n", message);<br />
<br />
return 0;<br />
}<br />
</syntaxhighlight><br />
<br />
This is extremely useful because it allows you to save a record of the output that you might not see first hand.<br />
<br />
To verify the output of the program went into syslog, enter the following command:<br />
{{clo}}<br />
{{clio | username=developer | hostname=ldc | tail /var/log/syslog}}<br />
Apr 7 14:10:06 ENG-26-LX dhclient: DHCPACK of 10.0.6.237 from 10.0.2.1<br /><br />
Apr 7 14:10:06 ENG-26-LX dhclient: bound to 10.0.6.237 -- renewal in 3306 seconds.<br /><br />
Apr 7 14:17:01 ENG-26-LX CRON[21193]: (root) CMD ( cd / && run-parts --report /etc/cron.hourly)<br /><br />
Apr 7 14:54:41 ENG-26-LX hpcups[21266]: prnt/hpcups/HPCupsFilter.cpp 689: First raster data plane..<br /><br />
Apr 7 14:55:31 hpcups[21266]: last message repeated 3 times<br /><br />
Apr 7 15:05:12 ENG-26-LX dhclient: DHCPREQUEST of 10.0.6.237 on eth0 to 10.0.2.1 port 67<br /><br />
Apr 7 15:05:12 ENG-26-LX dhclient: DHCPACK of 10.0.6.237 from 10.0.2.1<br /><br />
Apr 7 15:05:12 ENG-26-LX dhclient: bound to 10.0.6.237 -- renewal in 3559 seconds.<br /><br />
Apr 7 15:17:01 ENG-26-LX CRON[21302]: (root) CMD ( cd / && run-parts --report /etc/cron.hourly)<br /><br />
Apr 7 15:27:08 ENG-26-LX slog[21375]: Hello EMAC OE!<br />
{{clos}}<br />
<br />
As you can see on the bottom line, your program output has been recorded and date stamped in syslog.<br />
<br />
For more information on system logging visit the [[System_Logging| System Logging ]] page.<br />
<br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /****************************************** More Information *****************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
{{:Templateimpl:moreinfo | initials=BS | title=Getting Started with the EMAC OE SDK | desc=Basic tutorial for using the EMAC OE SDK. | project=OE 5.0 }}<br />
* [[Getting_Started_With_Qt_Creator |Getting Started With Qt Creator]]<br />
<br />
{{:Templateimpl:whatnext | initials=BS | title=Getting Started with the EMAC OE SDK | desc=Basic tutorial for using the EMAC OE SDK. | project=OE 5.0 }}<br />
* [[System_Log_In | System Log In]]<br />
* [[Serial_Connections | Serial Connections ]]<br />
* [[Network_Connections | Network_Connections ]]<br />
* [[System_Log_In | System Log In ]]<br />
* [[Remote_Debugging_EMAC_OE_SDK_Projects_with_gdbserver | Remote Debugging EMAC OE SDK Projects with gdbserver ]]<br />
* [[Linux_Filesystem_Organization | Linux Filesystem Organization]]<br />
* [[CMake | CMake ]]<br />
* [[Remote_Debugging_EMAC_OE_SDK_with_gdbserver | Remote Debugging EMAC OE SDK Projects with gdbserver]]<br />
* [[System_Logging | System Logging ]]</div>Bserranohttps://wiki.emacinc.com/index.php?title=OE_5_Software_Overview&diff=4321OE 5 Software Overview2015-06-22T20:16:57Z<p>Bserrano: </p>
<hr />
<div>{{todo| FinalDraft (05.20.2015-12:35->BS+);(05.21.2015-15:35->BS+);(05.21.2015-16:48->KY+)|Brian Serrano| project=OE 5.0,BS,KY,MD}}<br />
{{#seo:<br />
|title=Software Overview<br />
|titlemode=append<br />
|keywords=Qt Creator, Open Embedded, Linux U-boot, Xenomai<br />
|description=EMAC products offer a wide variety of software support from both open source and proprietary sources.<br />
}}<br />
<br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /**************************************** Page Description Text ****************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
<span style="background:#00FF00;color:#FF0000;font-size:300%"></span><br />
EMAC Products offer a wide variety of software support from both open source and proprietary sources. The hardware core was designed to be software compatible with the given processor reference design, which is supported by Linux.<br />
<br />
__TOC__<br />
<br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /***************************************** General Information *****************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
{{:Templateimpl:geninfo | initials=BS | title=Software Overview | desc=EMAC products offer a wide variety of software support from both open source and proprietary sources. | project=OE 5.0 }}<br />
=== Qt Creator ===<br />
Qt Creator is a cross-platform IDE (Integrated Development Environment) tailored to the needs of Qt developers but works well for headless applications as well. EMAC provides sample code for EMAC Products as projects that can be imported into Qt Creator. Qt Creator supports remote deployment and source debugging. <br />
<br />
For more information visit https://qt-project.org/wiki/Category:Tools::QtCreator page.<br />
<br />
EMAC provides a custom version of Qt Creator based on the 3.x or later release. This custom version includes examples and documentation relevant to EMAC customers. EMAC also provides a getting started guide for Qt Creator as a separate document.<br />
<br />
More information on using Qt Creator with the EMAC SDK is available on the [[Getting_Started_With_Qt_Creator |Getting Started With Qt Creator]] page.<br />
<br />
=== Das U-Boot ===<br />
EMAC Products are distributed with Das U-Boot installed. U-Boot is an open source/cross-architecture platform independent bootloader. It supports reading and writing to the flash, auto-booting, environmental variables, and TFTP. Das U-boot can be used to upload and run and/or reflash the OS on EMAC Products or to run stand-alone programs without an OS. EMAC Products modules are shipped with a valid MAC address installed in flash in the protected U-boot environmental variable “ethaddr”. At boot time U-Boot automatically stores this address in a register within the MAC, which effectively provides it to any OS loaded after that point.<br />
<br />
For more information visit [[U-Boot_Overview | U-Boot Overview]] page.<br />
<br />
=== Embedded Linux ===<br />
EMAC Open Embedded Linux is an open source Linux distribution for use in embedded systems. EMAC Products build uses a Linux 3.x or later kernel that has been has been patched to support EMAC Products.<br />
<br />
The distribution contains everything a user could expect from a standard Linux kernel: powerful networking features, advanced file system support, security, debugging utilities, and countless other features.<br />
<br />
EMAC Products will work out of the box with EMAC’s Embedded Linux distribution, and EMAC provides the most up to date distribution via FTP. EMAC Products comes preinstalled with a 3.x or later Linux kernel.<br />
<br />
=== Linux with Xenomai Real Time Extensions ===<br />
Xenomai provides real time extensions to the kernel and can be used to schedule tasks with hard deadlines and μs latencies. The Xenomai build is an additional module that can be added to the standard Linux kernel and is available for one-time inexpensive support/installation fee.<br />
<br />
For more information visit http://www.xenomai.org/ page.<br />
<br />
=== Linux Software Packages ===<br />
EMAC provides support for many Linux modules such as: Lighttpd Web Server, PHP, SQLite, Perl, SNMP, DHCP Server, etc. As with the Xenomai module, other modules can be added to the standard Linux file system and are available for a one-time inexpensive support/installation fee.<br />
<br />
For more information visit [[EMAC_OE_50_Add-on_Packages |EMAC OE 5.X Add-on Packages]] page.<br />
<br />
=== Linux Patches ===<br />
In addition to standard Embedded Linux support, EMAC has released a number of patches and device drivers from the open source community and from internal EMAC engineering into its standard distribution. Along with kernel patches, EMAC provides the binaries for the kernel and root file system.<br />
<br />
=== Yocto Project ===<br />
The Linux build for EMAC Products is based on Yocto Project (https://www.yoctoproject.org/) Linux build system. Yocto Project is a superior Linux distribution for embedded systems. Custom Linux builds are also available on request.<br />
<br />
The basic root file system includes:<br />
<br />
* Busybox<br />
* Hotplugging support<br />
* APM utilities for power management<br />
* Openssh SSH server<br />
* lighttpd HTTP server<br />
* EXT4 file system with utilities<br />
<br />
=== ARM EABI Cross Compiler ===<br />
The popular open source gcc compiler has a stable build for the ARM family. EMAC uses the 4.9.1 version of the ARM EABI compiler. The Embedded Linux kernel and EMAC Qt Creator projects use this compiler for building ARM stand alone, and OS specific binaries. The EMAC Qt Creator provides source level debugging over Ethernet or serial using gdbserver. The Linux binaries for the ARM EABI cross compiler are available online along with the SDK for EMAC Products at the following location: <br />
<br />
ftp://ftp.emacinc.com/Controllers/SoM/<br />
<br />
=== Disclaimer ===<br />
<br />
The OE 5.0 release is currently in Beta. All data related to the OE 5.0 release is subject to change. For more information on the current stable EMAC OE visit [[Main_Page | EMAC OE 4.0 Wiki]] page.</div>Bserranohttps://wiki.emacinc.com/index.php?title=Installing_QtCreator&diff=4318Installing QtCreator2015-06-19T19:29:55Z<p>Bserrano: </p>
<hr />
<div>{{todo| Review|Brian Serrano|project=oe 5,bs,ky}}<br />
<br />
==Install Qt Creator==<br />
<cl><br />
1. Download Qt Creator from the Qt project web page:<br />
* [http://download.qt.io/official_releases/qtcreator/3.3/3.3.0/qt-creator-opensource-linux-x86-3.3.0.run Qt Creator x86 32-bit]<br />
* [http://download.qt.io/official_releases/qtcreator/3.3/3.3.0/qt-creator-opensource-linux-x86_64-3.3.0.run Qt Creator x86 64-bit]<br />
<br />
* Change to the directory where Qt Creator was downloaded from the command line:<br />
<syntaxhighlight lang="bash"><br />
developer@ldc:~$ cd /download/directory<br />
</syntaxhighlight><br />
<br />
* Make Qt Creator installer executable and run installer script:<br />
<br />
<syntaxhighlight lang="bash"><br />
developer@ldc:~$ chmod +x qt-creator-opensource-linux-x86-3.1.0.run<br />
developer@ldc:~$ ./qt-creator-opensource-linux-x86-3.1.0.run<br />
</syntaxhighlight><br />
<br />
The installation wizard will start. <br />
<br />
[[File:Qt_Creator_Install_1.png|400px|thumb|left|Figure 1: Qt Creator Installation Wizard]]<br />
<br />
<br clear=all><br />
<br />
* Press '''next''' to proceed.<br />
<br />
[[File:Qt_Creator_Install_2.png|400px|thumb|left|Figure 2: Qt Creator Installation Wizard]]<br />
<br />
<br clear=all><br />
<br />
* Choose an installation directory then press '''next'''<br />
<br />
[[File:Qt_Creator_Install_3.png|400px|thumb|left|Figure 3: Qt Creator Installation Wizard]]<br />
<br />
<br clear=all><br />
* Accept the license agreement then press '''next'''<br />
<br />
[[File:Qt_Creator_Install_4.png|400px|thumb|left|Figure 4: Qt Creator Installation Wizard]]<br />
<br />
<br clear=all><br />
<br />
* Press '''install''' to begin the installation<br />
<br />
[[File:Qt_Creator_Install_5.png|400px|thumb|left|Figure 5: Qt Creator Installation Wizard]]<br />
<br />
<br clear=all><br />
<br />
* A status bar will appear. Press '''finish''' to exit the installation wizard<br />
</cl><br />
<br />
== Next Steps ==<br />
<br />
Once Qt Creator is installed, the next step is to [[Getting_Started_With_Qt_Creator|configure Qt Creator.]]</div>Bserranohttps://wiki.emacinc.com/index.php?title=OE_5_Software_Overview&diff=4316OE 5 Software Overview2015-06-19T19:28:12Z<p>Bserrano: Bserrano moved page Software Overview to OE 5 Software Overview</p>
<hr />
<div>{{todo| FinalDraft (05.20.2015-12:35->BS+);(05.21.2015-15:35->BS+);(05.21.2015-16:48->KY+)|Brian Serrano| project=OE 5.0,BS,KY,MD}}<br />
{{#seo:<br />
|title=Software Overview<br />
|titlemode=append<br />
|keywords=Qt Creator, Open Embedded, Linux U-boot, Xenomai<br />
|description=EMAC products offer a wide variety of software support from both open source and proprietary sources.<br />
}}<br />
<br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /**************************************** Page Description Text ****************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
<span style="background:#00FF00;color:#FF0000;font-size:300%"></span><br />
EMAC Products offer a wide variety of software support from both open source and proprietary sources. The hardware core was designed to be software compatible with the given processor reference design, which is supported by Linux.<br />
<br />
__TOC__<br />
<br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /***************************************** General Information *****************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
{{:Templateimpl:geninfo | initials=BS | title=Software Overview | desc=EMAC products offer a wide variety of software support from both open source and proprietary sources. | project=OE 5.0 }}<br />
=== Qt Creator ===<br />
Qt Creator is a cross-platform IDE (Integrated Development Environment) tailored to the needs of Qt developers but works well for headless applications as well. EMAC provides sample code for EMAC Products as projects that can be imported into Qt Creator. Qt Creator supports remote deployment and source debugging. <br />
<br />
For more information visit https://qt-project.org/wiki/Category:Tools::QtCreator page.<br />
<br />
EMAC provides a custom version of Qt Creator based on the 3.x or later release. This custom version includes examples and documentation relevant to EMAC customers. EMAC also provides a getting started guide for Qt Creator as a separate document.<br />
<br />
More information on using Qt Creator with the EMAC SDK is available on the [[Getting_Started_With_Qt_Creator |Getting Started With Qt Creator]] page.<br />
<br />
=== Das U-Boot ===<br />
EMAC Products are distributed with Das U-Boot installed. U-Boot is an open source/cross-architecture platform independent bootloader. It supports reading and writing to the flash, auto-booting, environmental variables, and TFTP. Das U-boot can be used to upload and run and/or reflash the OS on EMAC Products or to run stand-alone programs without an OS. EMAC Products modules are shipped with a valid MAC address installed in flash in the protected U-boot environmental variable “ethaddr”. At boot time U-Boot automatically stores this address in a register within the MAC, which effectively provides it to any OS loaded after that point.<br />
<br />
=== Embedded Linux ===<br />
EMAC Open Embedded Linux is an open source Linux distribution for use in embedded systems. EMAC Products build uses a Linux 3.x or later kernel that has been has been patched to support EMAC Products.<br />
<br />
The distribution contains everything a user could expect from a standard Linux kernel: powerful networking features, advanced file system support, security, debugging utilities, and countless other features.<br />
<br />
EMAC Products will work out of the box with EMAC’s Embedded Linux distribution, and EMAC provides the most up to date distribution via FTP. EMAC Products comes preinstalled with a 3.x or later Linux kernel.<br />
<br />
=== Linux with Xenomai Real Time Extensions ===<br />
Xenomai provides real time extensions to the kernel and can be used to schedule tasks with hard deadlines and μs latencies. The Xenomai build is an additional module that can be added to the standard Linux kernel and is available for one-time inexpensive support/installation fee.<br />
<br />
For more information visit http://www.xenomai.org/ page.<br />
<br />
=== Linux Modules ===<br />
EMAC provides support for many Linux modules such as: Lighttpd Web Server, PHP, SQLite, Perl, SNMP, DHCP Server, etc. As with the Xenomai module, other modules can be added to the standard Linux file system and are available for a one-time inexpensive support/installation fee.<br />
<br />
=== Linux Patches ===<br />
In addition to standard Embedded Linux support, EMAC has released a number of patches and device drivers from the open source community and from internal EMAC engineering into its standard distribution. Along with kernel patches, EMAC provides the binaries for the kernel and root file system.<br />
<br />
=== Open Embedded ===<br />
The Linux build for EMAC Products is based on the Open Embedded (www.openembedded.org) Linux build system. Open Embedded is a superior Linux distribution for embedded systems. Custom Linux builds are also available on request.<br />
<br />
The basic root file system includes:<br />
<br />
* Busybox<br />
* Hotplugging support<br />
* APM utilities for power management<br />
* Openssh SSH server<br />
* lighttpd HTTP server<br />
* EXT4 file system with utilities<br />
<br />
=== ARM EABI Cross Compiler ===<br />
The popular open source gcc compiler has a stable build for the ARM family. EMAC uses the 4.9.1 version of the ARM EABI compiler. The Embedded Linux kernel and EMAC Qt Creator projects use this compiler for building ARM stand alone, and OS specific binaries. The EMAC Qt Creator provides source level debugging over Ethernet or serial using gdbserver. The Linux binaries for the ARM EABI cross compiler are available online along with the SDK for EMAC Products at the following location: <br />
<br />
ftp://ftp.emacinc.com/Controllers/SoM/</div>Bserranohttps://wiki.emacinc.com/index.php?title=Software_Overview&diff=4317Software Overview2015-06-19T19:28:12Z<p>Bserrano: Bserrano moved page Software Overview to OE 5 Software Overview</p>
<hr />
<div>#REDIRECT [[OE 5 Software Overview]]</div>Bserranohttps://wiki.emacinc.com/index.php?title=Getting_Started_With_Qt_Creator&diff=4315Getting Started With Qt Creator2015-06-19T19:27:41Z<p>Bserrano: </p>
<hr />
<div>{{todo| Review (02.03.2015-10:42->BS+);(06.18.2015-14:25->BS+)|Brian Serrano| project=OE 5.0,BS,KY}}<br />
{{#seo:<br />
|title=Getting Started with Qt Creator<br />
|titlemode=append<br />
|keywords=Qt Creator, Tutorial, Qt Creator Examples<br />
|description=The following page can be used to get familiarized with EMAC Qt Creator.<br />
}}<br />
<br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /**************************************** Page Description Text ****************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
<span style="background:#00FF00;color:#FF0000;font-size:300%"></span><br />
The following page demonstrates the process of getting familiar with EMAC Qt Creator and running it on the target machine.<br />
__TOC__<br />
<br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /***************************************** Background Information ****************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
{{:Templateimpl:bg | initials=BS | title=Getting Started with Qt Creator | desc=The following page can be used to get familiarized with EMAC Qt Creator. | project=OE 5.0 }}<br />
Qt Creator is a cross-platform Open Source Integrated Development Environment (IDE) that can be used to develop software for many different languages. It includes a visual debugger and an integrated GUI layout and forms designer. <br />
<br />
For more information visit the Qt Project site http://qt-project.org/wiki/Category:Tools::QtCreator.<br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /***************************************** General Information *****************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
{{:Templateimpl:geninfo | initials=BS | title=Getting Started with Qt Creator | desc=The following page can be used to get familiarized with EMAC Qt Creator. | project=OE 5.0 }}<br />
=== Tools Required ===<br />
* EMAC OE SDK 5.0<br />
* EMAC Qt Creator<br />
* GNU ''make''<br />
* ''cmake''<br />
=== Setup === <br />
# Make sure the system is [[Getting_Started_with_the_EMAC_OE_SDK | configured ]] for the correct target machine and that the IP and user/password are set.<br />
# Launch EMAC Qt Creator.<br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /***************************************** Using/Working With ******************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
{{:Templateimpl:using | initials=BS | title=Getting Started with Qt Creator | desc=The following page can be used to get familiarized with EMAC Qt Creator. | project=OE 5.0 }}<br />
<br />
After installing EMAC SDK, launch the EMAC Qt Creator desktop icon.<br />
<br />
1. Press the Start key or Alt + F2 and search for Qt Creator EMAC<br />
<br />
2. Put the Qt Creator EMAC icon on the Launcher for easy access.<br />
<br />
[[File:EMAC_Qt_Creator_Icon.png|600px|left|thumb|Figure 1: Qt Creator Launcher Icon]]<br />
<br clear=all><br />
<br />
3. To generate a new project from Qt Creator, select '''New Project''' on the opening splash window. The examples being used are all written in <code> C programming </code> language.<br />
<br />
[[File:Qtcreator_gui.png|600px|left|thumb|Figure 2: Qt Creator GUI]]<br />
<br clear=all><br />
<br />
4. After selecting '''New Project''' a new window will pop up. To run a <code> C programming </code> example using EMAC hardware, select '''EMAC Project''' under the Projects tab. Then select '''EMAC C Project (CMake Build)'''. Click the '''Choose''' button on the bottom right of window to continue to the next page as shown in Figure 3.<br />
<br />
[[File:EMAC_C_Project.png|600px|left|thumb|Figure 3: Qt Creator EMAC Project]]<br />
<br clear=all><br />
<br />
5. The next page will be '''Introduction and Project Location'''. Select a name for the <code> C </code> project. Once the project name is given, choose a directory to store the project. Note: It is highly recommended to store your project other than the default location. For this example, we used ''/home/developer/Projects''.<br />
<br />
[[File:Project_location1.png|600px|left|thumb|Figure 4: Qt Creator Project Location]]<br />
<br clear=all><br />
<br />
6. The next page summarizes the '''EMAC C Project'''. Click '''Finish''' to continue.<br />
<br />
[[File:Project_summary1.png|600px|left|thumb|Figure 5: Qt Creator Project Summary]]<br />
<br clear=all><br />
<br />
7. Next, it will prompt you to the '''CMake Wizard Build Location'''. Click '''Next''' to continue. Note: It is highly recommended to use the default build directory as stated below in Figure 6. <br />
<br />
[[File:Build_location.png|600px|left|thumb|Figure 6: Qt Creator Build Location]] <br />
<br clear=all><br />
<br />
8. '''CMake Wizard''' will then prompt you to '''Run CMake'''. For setting up the Desktop Kit, click '''Run CMake''' and the output should be similar to Figure 7 below. Click '''Finish''' to start new project.<br />
<br />
[[File:Run_cmake1.png|600px|left|thumb|Figure 7: Qt Creator Run CMake]]<br />
<br clear=all><br />
<br />
9. The next step is to setup your device which you'll be using for the Qt Creator examples. Click Tools -> Options<br />
{{note|The board being used will be the iPac-9x25. The iPac-9x25 is a 32-bit ARM architecture. Make sure to connect power, Ethernet, and serial to the board.}}<br />
<br />
10. Select '''Devices''' from the left pane.<br />
<br />
[[File:Options_devices.png|600px|left|thumb|Figure 8: Qt Creator Device Option]] <br />
<br clear=all><br />
<br />
11. Click the '''Add''' button <br />
<br />
12. Select Generic Linux Device, then click '''Start Wizard'''.<br />
<br />
[[File:Generic_linux.png|600px|left|thumb|Figure 9: Qt Creator Wizard Selection]]<br />
<br clear=all><br />
<br />
13. Type in a name, the IP address, user name and password for the device. Use the credentials below to sign in.<br />
<br />
{| class="wikitable"<br />
!colspan="2"|Table 4: Default Login Credentials <br />
|-<br />
! Username !! Password<br />
|-<br />
| root || emac_inc<br />
|}<br />
<br />
[[File:Device_connection.png|600px|left|thumb|Figure 10: Qt Creator Configuration Setup]]<br />
<br clear=all><br />
<br />
14. Click '''Next'''.<br />
<br />
15. Click '''Finish'''.<br />
<br />
16. A connection will be established with the target device.<br />
<br />
[[File:Device_test.png|600px|left|thumb|Figure 11: Qt Creator Device Test]]<br />
<br clear=all><br />
<br />
17. Click '''Close'''.<br />
<br />
18. Click '''Apply'''.<br />
<br />
19. Navigate to '''Add Kit''' in the '''Projects''' tab. Under '''Add Kit''' select the architecture for the board being used. Click '''EMAC OE 5.0 arm'''. <br />
<br />
<br />
[[File:Add_kit_arm.jpg|600px|left|thumb|Figure 12: Qt Creator Add Kit]]<br />
<br clear=all><br />
<br />
20. As previously stated in step 7 it will prompt you to the '''CMake Wizard Build Location'''. Click '''Next''' to continue. Note: It is highly recommended to use the default build directory as stated below in Figure 13.<br />
<br />
[[File:Add_arm.png|600px|left|thumb|Figure 13: Qt Creator Add Kit Build Location]]<br />
<br clear=all><br />
<br />
21. '''CMake Wizard''' will then prompt you to '''Run CMake'''. For setting up the iPac-9x25 arm kit, click the box next to '''Arguments'''. Copy and paste the string below: <br />
''-DARCH:STRING=arm''<br />
<br />
[[File:Arm_argument_string.png|600px|left|thumb|Figure 14: Qt Creator Argument String]] <br />
<br clear=all><br />
<br />
EMAC SDK provides another architectural kit for x86 hardware. If using an x86 architecture, copy and paste the argument string below in the '''Arguments''' box. <br />
''-DARCH:STRING=x86'' <br />
<br />
22. Once the arguments string is pasted in the box, click '''Run CMake''' and the output should be similar to Figure 15 below. Click '''Finish''' to add the arm kit to the current project.<br />
<br />
[[File:Run_arm_cmake.png|600px|left|thumb|Figure 15: Qt Creator Run CMake]] <br />
<br clear=all><br />
<br />
23. To confirm if the kits installed correctly, click on the '''Kit Selector''' tab (Monitor symbol) on the left hand side of the Qt Creator window as shown in Figure 16. Both '''Desktop''' and '''OE 5.0 arm''' kit will be present.<br />
<br />
[[File:Arm_kit.jpg|600px|left|thumb|Figure 16: Qt Creator Kits Installed]] <br />
<br clear=all><br />
<br />
24. To run the example projects on the target board remotely, you'll need to add it to the '''Run Configuration'''. Click on '''Projects'''.<br />
<br />
25. Select '''Run''' under the '''OE 5.0 arm''' tab.<br />
<br />
26. To '''Run Configuration''', click on '''Add''' and select your project name (on Remote Generic Linux Host). In this case, our project name is Prime_Numbers (on Remote Generic Linux Host).<br />
<br />
[[File:Run_config.jpg|600px|left|thumb|Figure 17: Qt Creator Run Configuration]]<br />
<br clear=all><br />
<br />
You are now all set up to run the examples below on Qt Creator.<br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /***************************************** Examples *****************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
{{:Templateimpl:examples | initials=BS | title=Getting Started with Qt Creator | desc=The following page can be used to get familiarized with EMAC Qt Creator. | project=OE 5.0 }}<br />
This section will show how to run <code> C programming </code> examples through the Qt Creator IDE. The example board will be the iPac-9x25. <br />
<br />
The first example is a basic <code> hello c </code> example project. <br />
<br />
1. After creating a new project and installing the necessary kits for the target board, navigate to the '''Edit''' tab on Qt Creator. Qt Creator will automatically have the <code> hello c </code> example uploaded as shown in Figure 18.<br />
<br />
<syntaxhighlight lang="c"><br />
#include <stdio.h><br />
#include <stdlib.h><br />
<br />
int main(int argc, char * argv[])<br />
{<br />
printf("Hello EMAC OE!\n");<br />
<br />
exit(EXIT_SUCCESS);<br />
}<br />
</syntaxhighlight><br />
<br />
[[File:Edit_window.png|600px|left|thumb|Figure 18: Qt Creator Edit Window]] <br />
<br clear=all><br />
<br />
2. Before executing the example, you must build the program first. Click on the build icon (hammer symbol) on the bottom left of Qt Creator. If the build was successful, a green bar will fill on the bottom right of the window.<br />
<br />
3. Once the program successfully builds, you can now run the program. Click on the run icon (green arrow symbol) on the left hand side of Qt Creator. The program prints <code> Hello EMAC OE! </code> in the '''Application Output''' terminal. <br />
<br />
[[File:Final_output.png|600px|left|thumb|Figure 19: Qt Creator Edit Window]]<br />
<br clear=all><br />
<br />
The second example will show how to run a <code> c programming </code> project on a target board. This example will show all prime numbers from 1 - 100 and output it on Qt Creator remote terminal.<br />
<br />
1. Create a new project and install the necessary kits for the target board just as shown before. Call this project <code> Prime_Numbers </code>. Then Navigate to the '''Edit''' tab on Qt Creator. Copy and paste the following code below to the Qt Creator terminal. <br />
<br />
<syntaxhighlight lang="c"><br />
#include <stdio.h><br />
#include <stdlib.h><br />
<br />
int main(int argc, char * argv[])<br />
{ <br />
int i;<br />
int j;<br />
<br />
for (i = 2; i <= 100; i++)<br />
{<br />
for (j = 2; j <= i; j++)<br />
{<br />
if (i%j==0)<br />
{<br />
break;<br />
}<br />
}<br />
if (i == j)<br />
{<br />
printf ("%d is a prime number. \n", i);<br />
}<br />
}<br />
return 0;<br />
}<br />
</syntaxhighlight><br />
<br />
[[File:Prime_Numbers_edit.png|600px|left|thumb|Figure 210: Qt Creator Edit Window]] <br />
<br clear=all><br />
<br />
2. Click on the build icon (hammer symbol) on the bottom left of the Qt Creator. If the build was successful, a green bar will fill on the bottom right of Qt Creator.<br />
<br />
3. Click on the run icon (green arrow symbol) on the left hand side of Qt Creator. The program prints all prime numbers from 1 - 100 in the '''Application Output''' terminal. <br />
<br />
[[File:Final_Prime_Numbers.png|600px|left|thumb|Figure 21: Qt Creator Edit Window]] <br />
<br clear=all><br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /****************************************** Conclusion ******************************************/ --> <br />
<!-- /*********************************************************************************************************/ --><br />
{{:Templateimpl:conclusion | initials=BS | title=Getting Started with Qt Creator | desc=The following page can be used to get familiarized with EMAC Qt Creator. | project=OE 5.0 }}<br />
This page is a quick getting started tutorial on how to use EMAC Qt Creator for the first time. It shows you how to create an EMAC C Project, set up the necessary kits for your target board, setup your target board, and how to build and run example projects.<br />
<br />
<br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /****************************************** More Information *****************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
<!--{{:Templateimpl:moreinfo | initials=BS | title=Getting Started with the EMAC OE SDK | desc=Basic tutorial for using the EMAC OE SDK. | project=OE 5.0 }}<br />
* <br />
<br />
{{:Templateimpl:whatnext | initials=BS | title=Getting Started with the EMAC OE SDK | desc=Basic tutorial for using the EMAC OE SDK. | project=OE 5.0 }}<br />
* [[Getting_Started_with_the_EMAC_OE_SDK | Getting Started with the EMAC OE SDK ]]<br />
<br />
--></div>Bserranohttps://wiki.emacinc.com/index.php?title=File:EMAC_Qt_Creator_Icon.png&diff=4314File:EMAC Qt Creator Icon.png2015-06-19T15:36:35Z<p>Bserrano: </p>
<hr />
<div></div>Bserranohttps://wiki.emacinc.com/index.php?title=OE_5_Software_Overview&diff=4311OE 5 Software Overview2015-05-21T20:37:44Z<p>Bserrano: </p>
<hr />
<div>{{todo| Review (05.20.2015-12:35->BS+);(05.21.2015-15:35->BS+)|Brian Serrano| project=OE 5.0,BS,KY}}<br />
{{#seo:<br />
|title=Software Overview<br />
|titlemode=append<br />
|keywords=Qt Creator, Open Embedded, Linux U-boot, Xenomai<br />
|description=EMAC products offer a wide variety of software support from both open source and proprietary sources.<br />
}}<br />
<br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /**************************************** Page Description Text ****************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
<span style="background:#00FF00;color:#FF0000;font-size:300%"></span><br />
EMAC Products offer a wide variety of software support from both open source and proprietary sources. The hardware core was designed to be software compatible with the given processor reference design, which is supported by Linux.<br />
<br />
__TOC__<br />
<br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /***************************************** General Information *****************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
{{:Templateimpl:geninfo | initials=BS | title=Software Overview | desc=EMAC products offer a wide variety of software support from both open source and proprietary sources. | project=OE 5.0 }}<br />
=== Qt Creator ===<br />
Qt Creator is a cross-platform IDE (Integrated Development Environment) tailored to the needs of Qt developers but works well for Headless applications as well. EMAC provides sample code for EMAC Products as projects that can be imported into Qt Creator. Qt Creator supports remote deployment and source debugging. <br />
<br />
For more information visit https://qt-project.org/wiki/Category:Tools::QtCreator page.<br />
<br />
EMAC provides a custom version of Qt Creator based on the 3.x or later release. This custom version includes examples and documentation relevant to EMAC customers. EMAC also provides a getting started guide for Qt Creator as a separate document.<br />
<br />
More information on using Qt Creator with the EMAC SDK is available on the [[Getting_Started_With_Qt_Creator |Getting Started With Qt Creator]] page.<br />
<br />
=== Das U-Boot ===<br />
EMAC Products are distributed with Das U-Boot installed. U-Boot is an open source/cross-architecture platform independent bootloader. It supports reading and writing to the flash, auto-booting, environmental variables, and TFTP. Das U-boot can be used to upload and run and/or reflash the OS on EMAC Products or to run stand-alone programs without an OS. EMAC Products modules are shipped with a valid MAC address installed in flash in the protected U-boot environmental variable “ethaddr”. At boot time U-Boot automatically stores this address in a register within the MAC, which effectively provides it to any OS loaded after that point.<br />
<br />
=== Embedded Linux ===<br />
EMAC Open Embedded Linux is an open source Linux distribution for use in embedded systems. EMAC Products build uses a Linux 3.x or later kernel that has been has been patched to support EMAC Products.<br />
<br />
The distribution contains everything a user could expect from a standard Linux kernel: powerful networking features, advanced file system support, security, debugging utilities, and countless other features.<br />
<br />
EMAC Products will work out of the box with EMAC’s Embedded Linux distribution, and EMAC provides the most up to date distribution via FTP. EMAC Products comes preinstalled with a 3.x or later Linux kernel.<br />
<br />
=== Linux with Xenomai Real Time Extensions ===<br />
Xenomai provides real time extensions to the kernel and can be used to schedule tasks with hard deadlines and μs latencies. The Xenomai build is an additional module that can be added to the standard Linux kernel and is available for one-time inexpensive support/installation fee.<br />
<br />
For more information visit http://www.xenomai.org/ page.<br />
<br />
=== Linux Modules ===<br />
EMAC provides support for many Linux modules such as: Lighttpd Web Server, PHP, SQLite, Perl, SNMP, DHCP Server, etc. As with the Xenomai module, other modules can be added to the standard Linux file system and are available for a one-time inexpensive support/installation fee.<br />
<br />
=== Linux Patches ===<br />
In addition to standard Embedded Linux support, EMAC has released a number of patches and device drivers from the open source community and from internal EMAC engineering into its standard distribution. Along with kernel patches, EMAC provides the binaries for the kernel and root file system.<br />
<br />
=== Open Embedded ===<br />
The Linux build for EMAC Products is based on the Open Embedded (www.openembedded.org) Linux build system. Open Embedded is a superior Linux distribution for embedded systems. Custom Linux builds are also available on request.<br />
<br />
The basic root file system includes:<br />
<br />
* Busybox<br />
* Hotplugging support<br />
* APM utilities for power management<br />
* Openssh SSH server<br />
* lighttpd HTTP server<br />
* EXT4 file system with utilities<br />
<br />
=== ARM EABI Cross Compiler ===<br />
The popular open source gcc compiler has a stable build for the ARM family. EMAC uses the 4.9.1 version of the ARM EABI compiler. The Embedded Linux kernel and EMAC Qt Creator projects use this compiler for building ARM stand alone, and OS specific binaries. The EMAC Qt Creator provides source level debugging over Ethernet or serial using gdbserver. The Linux binaries for the ARM EABI cross compiler are available online along with the SDK for EMAC Products at the following location: <br />
<br />
ftp://ftp.emacinc.com/Controllers/SoM/</div>Bserranohttps://wiki.emacinc.com/index.php?title=OE_5_Software_Overview&diff=4310OE 5 Software Overview2015-05-21T20:33:06Z<p>Bserrano: </p>
<hr />
<div>{{todo| InProgress (05.20.2015-12:33->BS+)|Brian Serrano| project=OE 5.0,BS }}<br />
{{#seo:<br />
|title=Software Overview<br />
|titlemode=append<br />
|keywords=<br />
|description=EMAC products offer a wide variety of software support from both open source and proprietary sources.<br />
}}<br />
<br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /**************************************** Page Description Text ****************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
<span style="background:#00FF00;color:#FF0000;font-size:300%"></span><br />
EMAC Products offer a wide variety of software support from both open source and proprietary sources. The hardware core was designed to be software compatible with the given processor reference design, which is supported by Linux.<br />
<br />
__TOC__<br />
<br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /***************************************** General Information *****************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
{{:Templateimpl:geninfo | initials=BS | title=Software Overview | desc=EMAC products offer a wide variety of software support from both open source and proprietary sources. | project=OE 5.0 }}<br />
=== Qt Creator ===<br />
Qt Creator is a cross-platform IDE (Integrated Development Environment) tailored to the needs of Qt developers but works well for Headless applications as well. EMAC provides sample code for EMAC Products as projects that can be imported into Qt Creator. Qt Creator supports remote deployment and source debugging. <br />
<br />
For more information visit https://qt-project.org/wiki/Category:Tools::QtCreator page.<br />
<br />
EMAC provides a custom version of Qt Creator based on the 3.x or later release. This custom version includes examples and documentation relevant to EMAC customers. EMAC also provides a getting started guide for Qt Creator as a separate document.<br />
<br />
More information on using Qt Creator with the EMAC SDK is available on the [[Getting_Started_With_Qt_Creator |Getting Started With Qt Creator]] page.<br />
<br />
=== Das U-Boot ===<br />
EMAC Products are distributed with Das U-Boot installed. U-Boot is an open source/cross-architecture platform independent bootloader. It supports reading and writing to the flash, auto-booting, environmental variables, and TFTP. Das U-boot can be used to upload and run and/or reflash the OS on EMAC Products or to run stand-alone programs without an OS. EMAC Products modules are shipped with a valid MAC address installed in flash in the protected U-boot environmental variable “ethaddr”. At boot time U-Boot automatically stores this address in a register within the MAC, which effectively provides it to any OS loaded after that point.<br />
<br />
=== Embedded Linux ===<br />
EMAC Open Embedded Linux is an open source Linux distribution for use in embedded systems. EMAC Products build uses a Linux 3.x or later kernel that has been has been patched to support EMAC Products.<br />
<br />
The distribution contains everything a user could expect from a standard Linux kernel: powerful networking features, advanced file system support, security, debugging utilities, and countless other features.<br />
<br />
EMAC Products will work out of the box with EMAC’s Embedded Linux distribution, and EMAC provides the most up to date distribution via FTP. EMAC Products comes preinstalled with a 3.x or later Linux kernel.<br />
<br />
=== Linux with Xenomai Real Time Extensions ===<br />
Xenomai provides real time extensions to the kernel and can be used to schedule tasks with hard deadlines and μs latencies. The Xenomai build is an additional module that can be added to the standard Linux kernel and is available for one-time inexpensive support/installation fee.<br />
<br />
For more information visit http://www.xenomai.org/ page.<br />
<br />
=== Linux Modules ===<br />
EMAC provides support for many Linux modules such as: Lighttpd Web Server, PHP, SQLite, Perl, SNMP, DHCP Server, etc. As with the Xenomai module, other modules can be added to the standard Linux file system and are available for a one-time inexpensive support/installation fee.<br />
<br />
=== Linux Patches ===<br />
In addition to standard Embedded Linux support, EMAC has released a number of patches and device drivers from the open source community and from internal EMAC engineering into its standard distribution. Along with kernel patches, EMAC provides the binaries for the kernel and root file system.<br />
<br />
=== Open Embedded ===<br />
The Linux build for EMAC Products is based on the Open Embedded (www.openembedded.org) Linux build system. Open Embedded is a superior Linux distribution for embedded systems. Custom Linux builds are also available on request.<br />
<br />
The basic root file system includes:<br />
<br />
* Busybox<br />
* Hotplugging support<br />
* APM utilities for power management<br />
* Openssh SSH server<br />
* lighttpd HTTP server<br />
* EXT4 file system with utilities<br />
<br />
=== ARM EABI Cross Compiler ===<br />
The popular open source gcc compiler has a stable build for the ARM family. EMAC uses the 4.9.1 version of the ARM EABI compiler. The Embedded Linux kernel and EMAC Qt Creator projects use this compiler for building ARM stand alone, and OS specific binaries. The EMAC Qt Creator provides source level debugging over Ethernet or serial using gdbserver. The Linux binaries for the ARM EABI cross compiler are available online along with the SDK for EMAC Products at the following location: <br />
<br />
ftp://ftp.emacinc.com/Controllers/SoM/</div>Bserranohttps://wiki.emacinc.com/index.php?title=OE_5_Software_Overview&diff=4309OE 5 Software Overview2015-05-21T20:25:46Z<p>Bserrano: </p>
<hr />
<div>{{todo| InProgress (05.20.2015-12:33->BS+)|Brian Serrano| project=OE 5.0,BS }}<br />
{{#seo:<br />
|title=Software Overview<br />
|titlemode=append<br />
|keywords=<br />
|description=EMAC products offer a wide variety of software support from both open source and proprietary sources.<br />
}}<br />
<br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /**************************************** Page Description Text ****************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
<span style="background:#00FF00;color:#FF0000;font-size:300%"></span><br />
EMAC Products offer a wide variety of software support from both open source and proprietary sources. The hardware core was designed to be software compatible with the given processor reference design, which is supported by Linux.<br />
<br />
__TOC__<br />
<br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /***************************************** General Information *****************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
{{:Templateimpl:geninfo | initials=BS | title=Software Overview | desc=EMAC products offer a wide variety of software support from both open source and proprietary sources. | project=OE 5.0 }}<br />
== Qt Creator ==<br />
Qt Creator is a cross-platform IDE (Integrated Development Environment) tailored to the needs of Qt developers but works well for Headless applications as well. EMAC provides sample code for EMAC Products as projects that can be imported into Qt Creator. Qt Creator supports remote deployment and source debugging. <br />
<br />
For more information visit https://qt-project.org/wiki/Category:Tools::QtCreator page.<br />
<br />
EMAC provides a custom version of Qt Creator based on the 3.x or later release. This custom version includes examples and documentation relevant to EMAC customers. EMAC also provides a getting started guide for Qt Creator as a separate document.<br />
<br />
More information on using Qt Creator with the EMAC SDK is available on the [[Getting_Started_With_Qt_Creator |Getting Started With Qt Creator]] page.<br />
<br />
== Das U-Boot ==<br />
EMAC Products are distributed with Das U-Boot installed. U-Boot is an open source/cross-architecture platform independent bootloader. It supports reading and writing to the flash, auto-booting, environmental variables, and TFTP. Das U-boot can be used to upload and run and/or reflash the OS on EMAC Products or to run stand-alone programs without an OS. EMAC Products modules are shipped with a valid MAC address installed in flash in the protected U-boot environmental variable “ethaddr”. At boot time U-Boot automatically stores this address in a register within the MAC, which effectively provides it to any OS loaded after that point.<br />
<br />
== Embedded Linux ==<br />
EMAC Open Embedded Linux is an open source Linux distribution for use in embedded systems. EMAC Products build uses a Linux 3.x or later kernel that has been has been patched to support EMAC Products.<br />
<br />
The distribution contains everything a user could expect from a standard Linux kernel: powerful networking features, advanced file system support, security, debugging utilities, and countless other features.<br />
<br />
EMAC Products will work out of the box with EMAC’s Embedded Linux distribution, and EMAC provides the most up to date distribution via FTP. EMAC Products comes preinstalled with a 3.x or later Linux kernel.<br />
<br />
== Linux with Xenomai Real Time Extensions ==<br />
Xenomai provides real time extensions to the kernel and can be used to schedule tasks with hard deadlines and μs latencies. The Xenomai build is an additional module that can be added to the standard Linux kernel and is available for one-time inexpensive support/installation fee.<br />
<br />
For more information visit http://www.xenomai.org/ page.<br />
<br />
== Linux Modules ==<br />
EMAC provides support for many Linux modules such as: Lighttpd Web Server, PHP, SQLite, Perl, SNMP, DHCP Server, etc. As with the Xenomai module, other modules can be added to the standard Linux file system and are available for a one-time inexpensive support/installation fee.<br />
<br />
== Linux Patches ==<br />
In addition to standard Embedded Linux support, EMAC has released a number of patches and device drivers from the open source community and from internal EMAC engineering into its standard distribution. Along with kernel patches, EMAC provides the binaries for the kernel and root file system.<br />
<br />
== Open Embedded ==<br />
The Linux build for EMAC Products is based on the Open Embedded (www.openembedded.org) Linux build system. Open Embedded is a superior Linux distribution for embedded systems. Custom Linux builds are also available on request.<br />
<br />
The basic root file system includes:<br />
<br />
* Busybox<br />
* Hotplugging support<br />
* APM utilities for power management<br />
* Openssh SSH server<br />
* lighttpd HTTP server<br />
* EXT4 file system with utilities<br />
<br />
== ARM EABI Cross Compiler ==<br />
The popular open source gcc compiler has a stable build for the ARM family. EMAC uses the 4.9.1 version of the ARM EABI compiler. The Embedded Linux kernel and EMAC Qt Creator projects use this compiler for building ARM stand alone, and OS specific binaries. The EMAC Qt Creator provides source level debugging over Ethernet or serial using gdbserver. The Linux binaries for the ARM EABI cross compiler are available online along with the SDK for EMAC Products at the following location: <br />
<br />
ftp://ftp.emacinc.com/Controllers/SoM/</div>Bserranohttps://wiki.emacinc.com/index.php?title=OE_5_Software_Overview&diff=4308OE 5 Software Overview2015-05-20T17:35:49Z<p>Bserrano: </p>
<hr />
<div>{{todo| InProgress (05.20.2015-12:33->BS+)|Brian Serrano| project=OE 5.0,BS }}<br />
{{#seo:<br />
|title=Software Overview<br />
|titlemode=append<br />
|keywords=<br />
|description=EMAC products offer a wide variety of software support from both open source and proprietary sources.<br />
}}<br />
<br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /**************************************** Page Description Text ****************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
<span style="background:#00FF00;color:#FF0000;font-size:300%">'''''Put the page description text here.'''''</span><br />
<br />
__TOC__<br />
<br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /***************************************** Background Information ****************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
{{:Templateimpl:bg | initials=BS | title=Software Overview | desc=EMAC products offer a wide variety of software support from both open source and proprietary sources. | project=OE 5.0 }}<br />
<br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /***************************************** General Information *****************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
{{:Templateimpl:geninfo | initials=BS | title=Software Overview | desc=EMAC products offer a wide variety of software support from both open source and proprietary sources. | project=OE 5.0 }}<br />
<br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /***************************************** Using/Working With ******************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
{{:Templateimpl:using | initials=BS | title=Software Overview | desc=EMAC products offer a wide variety of software support from both open source and proprietary sources. | project=OE 5.0 }}<br />
<br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /***************************************** Examples *****************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
{{:Templateimpl:examples | initials=BS | title=Software Overview | desc=EMAC products offer a wide variety of software support from both open source and proprietary sources. | project=OE 5.0 }}<br />
<br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /****************************************** Conclusion ******************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
{{:Templateimpl:conclusion | initials=BS | title=Software Overview | desc=EMAC products offer a wide variety of software support from both open source and proprietary sources. | project=OE 5.0 }}<br />
<br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /****************************************** More Information *****************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
{{:Templateimpl:moreinfo | initials=BS | title=Software Overview | desc=EMAC products offer a wide variety of software support from both open source and proprietary sources. | project=OE 5.0 }}<br />
* <br />
<br />
{{:Templateimpl:whatnext | initials=BS | title=Software Overview | desc=EMAC products offer a wide variety of software support from both open source and proprietary sources. | project=OE 5.0 }}<br />
*</div>Bserranohttps://wiki.emacinc.com/index.php?title=OE_5_Software_Overview&diff=4307OE 5 Software Overview2015-05-20T17:33:50Z<p>Bserrano: Created page with "{{ subst:Pgtempl | initials={{subst::Templateimpl:getinitials}} | project=OE 5.0 | title=Software Overview | desc=EMAC products offer a wide variety of software support from b..."</p>
<hr />
<div>{{todo| NotStarted (05.20.2015-12:33->BS+)| Bserrano | project=OE 5.0,BS }}<br />
{{#seo:<br />
|title=Software Overview<br />
|titlemode=append<br />
|keywords=<br />
|description=EMAC products offer a wide variety of software support from both open source and proprietary sources.<br />
}}<br />
<br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /**************************************** Page Description Text ****************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
<span style="background:#00FF00;color:#FF0000;font-size:300%">'''''Put the page description text here.'''''</span><br />
<br />
__TOC__<br />
<br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /***************************************** Background Information ****************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
{{:Templateimpl:bg | initials=BS | title=Software Overview | desc=EMAC products offer a wide variety of software support from both open source and proprietary sources. | project=OE 5.0 }}<br />
<br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /***************************************** General Information *****************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
{{:Templateimpl:geninfo | initials=BS | title=Software Overview | desc=EMAC products offer a wide variety of software support from both open source and proprietary sources. | project=OE 5.0 }}<br />
<br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /***************************************** Using/Working With ******************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
{{:Templateimpl:using | initials=BS | title=Software Overview | desc=EMAC products offer a wide variety of software support from both open source and proprietary sources. | project=OE 5.0 }}<br />
<br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /***************************************** Examples *****************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
{{:Templateimpl:examples | initials=BS | title=Software Overview | desc=EMAC products offer a wide variety of software support from both open source and proprietary sources. | project=OE 5.0 }}<br />
<br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /****************************************** Conclusion ******************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
{{:Templateimpl:conclusion | initials=BS | title=Software Overview | desc=EMAC products offer a wide variety of software support from both open source and proprietary sources. | project=OE 5.0 }}<br />
<br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /****************************************** More Information *****************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
{{:Templateimpl:moreinfo | initials=BS | title=Software Overview | desc=EMAC products offer a wide variety of software support from both open source and proprietary sources. | project=OE 5.0 }}<br />
* <br />
<br />
{{:Templateimpl:whatnext | initials=BS | title=Software Overview | desc=EMAC products offer a wide variety of software support from both open source and proprietary sources. | project=OE 5.0 }}<br />
*</div>Bserranohttps://wiki.emacinc.com/index.php?title=Getting_Started_with_the_EMAC_OE_SDK&diff=4299Getting Started with the EMAC OE SDK2015-04-29T21:23:03Z<p>Bserrano: </p>
<hr />
<div>{{todo| (03.31.2015-13:42->BS+);(04.08.2015-15:00->BS+);(04.09.15-14:00->MD+);(04.21.2015-10:15->BS+);(04.24.2015-20:00->MD-);(04.28.2015-12:20->MD+);(04.29.2015-16:00->BS+) |Brian Serrano| project=OE 5.0,BS,MD,Review}}<br />
{{#seo:<br />
|title=Getting Started with the EMAC OE SDK<br />
|titlemode=append<br />
|keywords=EMAC SDK,Cross compiling, ARM Target Compiling, CMake Build System, CMake Cross Compiling<br />
|description=A basic tutorial for using the EMAC OE SDK.<br />
}}<br />
<br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /**************************************** Page Description Text ****************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
<br />
<span style="background:#00FF00;color:#FF0000;font-size:300%"></span><br />
The EMAC OE SDK is distributed with a set of example projects intended to demonstrate how to use the EMAC OE toolchain and libraries. This page demonstrates the process of compiling an example project and running it on the target machine. Also, it provides a straightforward guide to the essential steps you need to follow to get started with cross compiling a simple program with gcc and running the program on your embedded machine.<br />
<br />
__TOC__<br />
<br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /***************************************** General Information *****************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
{{:Templateimpl:geninfo | initials=BS | title=Getting Started with the EMAC OE SDK | desc=Basic tutorial for using the EMAC OE SDK. | project=OE 5.0 }}<br />
<br />
The EMAC OE SDK is primarily distributed via our apt repository as a deb package for Ubuntu. Using EMAC's apt repository makes installing and updating the EMAC SDK and tools as easy as installing and updating any standard Ubuntu package. This tutorial will show you how to configure your system to use the EMAC apt repository so that you can use the same package management tools you're familiar with in Ubuntu to install and update the EMAC provided SDK and tools.<br />
<br />
EMAC also provides a tarball you can extract and install manually in case you're using a distribution other than Ubuntu (or a derivative), but EMAC strongly recommends using an Ubuntu LTS release. The recent Ubuntu LTS releases have been thoroughly tested with the EMAC SDK and tools and are fully supported by EMAC. Given the large number of alternate Linux distributions available, EMAC is only able to provide limited support (in the form of a manually installed tarball) for other Linux distributions. <br />
<br />
Each SDK includes the C/C++ header files and libraries compatible with the target hardware. It also includes the C/C++ cross-compiler toolchain components necessary to compile and debug custom application code. The links below will help you get started building and running the example projects on the target hardware.<br />
<br />
More information on using Qt Creator with the EMAC SDK is available on the [[Getting_Started_With_Qt_Creator |Getting Started With Qt Creator]] page.<br />
<br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /***************************************** Using/Working With ******************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
{{:Templateimpl:using | initials=BS | title=Getting Started with the EMAC OE SDK | desc=Basic tutorial for using the EMAC OE SDK. | project=OE 5.0 }} <br />
=== Connecting to a Target Board ===<br />
The next step after establishing a physical connection to the board is logging in. More information on establishing a physical connection to a board is available on the [[Serrial_Connections |Serial Connections]] and [[Network_Connections |Network Connections]] page. <br />
<br />
A machine running EMAC OE Linux can be connected to through a serial port or through a network cable. EMAC OE Linux allows users to log in via getty, and SSH (Secure Shell). A getty can be accessed via a serial connection (through a console) while SSH utilizes a network connection. For more information visit the [[System_Log_In | System Log In]] page.<br />
<br />
=== Setting the Filesystem to Read-Write ===<br />
The root filesystem on a machine running EMAC OE Linux is mounted read-only by default. In order to put files on the board, you may need to make the filesystem read-write. The [[Linux_Filesystem_Organization|Linux Filesystem Organization page]] has more information regarding which parts of the filesystem are mounted read-only by default versus which parts are always writeable. Note that EMAC recommends installing your program into a read-only portion of the filesystem (according to the guide) to safeguard it from filesystem corruption (such as may be caused by removing power from the board without shutting down the operating system first, which is normal in embedded systems).<br />
<br />
To remount the root filesytem in read-write mode, enter the following into the terminal: <br />
{{cli | oemntrw | hostname=ipac9x25}}<br />
<br />
{{note|This will only change the root filesystem to read-write for the current boot. When the system is rebooted, the root filesystem will once again be mounted read-only.}}<br />
<br />
=== Transferring Files ===<br />
The command line syntax for transferring a file using the SSH protocol is <code>scp file user@host:/directory</code>. SCP or Secure Copy is a way of securely transferring files between a local and remote host. For example, to send the file ''example.text'' to the <code>/home</code> directory of a system with the IP address 10.0.6.221, enter the following command:<br />
{{cli | username=developer | hostname=ldc | scp example.text root@10.0.6.221:/home/ }}<br />
<br />
Alternatively, you can leave off the path after the colon if you want the file to go directly into the home directory.<br />
<br />
{{cli | username=developer | hostname=ldc | scp example.text root@10.0.6.221: }}<br />
<br />
{{note|This copy operation will fail if the filesystem on the remote machine is mounted read-only, which is the default on most EMAC systems. If you experience this failure, remount the root filesystem read-write (see above) and try again.}}<br />
<br />
=== Remote Execution ===<br />
SSH can also be used to execute programs on remote systems without logging in. The syntax for SSH remote execution is <code>ssh user@host "my_command -args file"</code>. The following is an example of a command to run a program on a board with the IP address of ''10.0.6.221''.<br />
<br />
{{cli | username=developer | hostname=ldc | ssh root@10.0.6.221 "/path/to/executable -args" }}<br />
<br />
{{warning | The description doesn't match the example}}<br />
<br />
=== Basic Compiling ===<br />
In the two subsections below, it will show two options on how to compile the example source code. The first subsection will demonstrate on how to use the EMAC [[ #CMake_Compiling| CMake ]] tool and the second subsection demonstrates how to compile codec [[ #Manual_Compiling | manually ]].<br />
<br />
==== CMake Compiling ====<br />
===== Host Machine Compiling =====<br />
{{warning|This note belongs in the following section (manual), not here. There should also be a description in the parent section (Compiling) which describes the two subsections, so that the reader will know what's coming and can decide to skip to one or the other, if he/she only wants to learn about one method.}}<br />
<br />
This section demonstrates how to use the EMAC CMake tool to generate CMake files automatically for a project. When using the EMAC SDK there are currently two options for cross compiling:<br />
* arm<br />
* x86<br />
For the purposes of this guide, the arm option will be used for the listed examples.<br />
<br />
Navigate to the directory where the project will be located. Then run the CMake new project script.<br />
{{clo|indent=2}}<br />
{{clio | username=developer | hostname=ldc | pwd=~/projects | oe_init_project -n hello.c }}<br />
If desired, please enter a name for this project, otherwise press Enter to use the default: hello_emac <br /><br />
<br />
-- Creating new project directory... <br /><br />
-- Creating new source file... <br /><br />
-- Building custom CMakeLists.txt file... <br /><br />
-- Done. <br /><br />
<br />
Do you want to create a build directory for this project? (y/n) y <br /><br />
<br />
-- Creating build directory... <br /><br />
<br />
Do you want to run cmake for this project? (y/n) y <br /><br />
<br />
-- Using system compiler <br /><br />
-- The C compiler identification is GNU 4.8.2 <br /><br />
-- The CXX compiler identification is GNU 4.8.2 <br /><br />
-- Check for working C compiler: /usr/bin/cc <br /><br />
-- Check for working C compiler: /usr/bin/cc -- works <br /><br />
-- Detecting C compiler ABI info <br /><br />
-- Detecting C compiler ABI info - done <br /><br />
-- Check for working CXX compiler: /usr/bin/c++ <br /><br />
-- Check for working CXX compiler: /usr/bin/c++ -- works <br /><br />
-- Detecting CXX compiler ABI info <br /><br />
-- Detecting CXX compiler ABI info - done <br /><br />
-- Configuring done <br /><br />
-- Generating done <br /><br />
-- Build files have been written to: /home/developer/projects/hello_emac/hello_emac-build <br /><br />
<br />
Do you want to compile this project? (y/n) y<br />
<br />
Scanning dependencies of target hello_emac <br /><br />
[100%] Building C object CMakeFiles/hello_emac.dir/hello.c.o <br /><br />
Linking C executable hello_emac <br /><br />
[100%] Built target hello_emac <br /><br />
{{clos}}<br />
<br />
The executable in this case, is now inside the <code> hello_emac/hello_emac-build </code> directory.<br />
<br />
===== Target Machine Compiling =====<br />
{{note | There needs to be lead in text here describing what they got from the last section. It's jarring to see that you have to create a directory to cross-compile the project into immediately after you've finished a step which supposedly created an executable for you; it'll make the reader wonder if this is supposed to be steps for them to perform if they didn't perform the one above. So, describe the CMake files that were produced above, what they contain, why they're important, and why they now should create a subdirectory for doing the cross compile. Documentation is supposed to take the mystery out of the process, but if you leave these details out, you're leaving part of it as a mystery.<br />Also, are you sure 'arm' is the only target you should list? What if the reader is on x86? They won't know if they should pass 'Intel', 'i386', 'x86', etc. Tell them by giving them a complete list of options. ;) }}<br />
<br />
The CMake project script has now made a project directory that contains the following:<br />
* CMakeLists.txt<br />
* Source code file (''hello.c'' in this case)<br />
* ''README'' file<br />
* Desktop Build Directory (''hello_emac-build'' in this case)<br />
<br />
The ''CMakeLists.txt'' contains the required information to automatically create a ''Makefile'' for a given architecture.<br />
<br />
The source code file generated by the script (''hello.c'') contains a basic Hello World style program.<br />
<br />
The ''README'' file contains more information on using ''CMake'' with the EMAC 5.0 SDK.<br />
<br />
The Desktop Build Directory (''hello_emac-build'') contains the executable ''hello_emac'', the ''Makefile'', and various cache files.<br />
<br />
It is important to have a Desktop Build Directory because it is good practice to use the desktop to verify all code changes before cross-compiling to a target board. This saves time on transferring files between the target board. <br />
<br />
Use the following steps to cross-compile the project and send it to a target board. In a terminal, navigate to the base directory of the project (where this document is located).<br />
<br />
If the target board being used is ''x86'', then change all occurrences of ''arm'' in the following sections below to ''x86''.<br />
<br />
Create a build directory for cross compiling. <br />
{{clio | username=developer | hostname=ldc | pwd=~/projects/hello_emac | mkdir hello_emac-build-arm }} <br />
<br />
Change directories into the newly created directory.<br />
{{clio | username=developer | hostname=ldc | pwd=~/projects/hello_emac | cd hello_emac-build-arm }} <br />
<br />
Run cmake using the target architecture.<br />
{{clio | username=developer | hostname=ldc | pwd=~/projects/hello_emac/hello_emac-build-arm | 1 = cmake .. -DARCH:STRING=arm }} <br />
<br />
Compile the code using make.<br />
{{clio | username=developer | hostname=ldc | pwd=~/projects/hello_emac/hello_emac-build-arm | make }} <br />
<br />
After running the <code> make </code> command, the target executable is now in the <code> hello_emac-build-arm </code> directory. Then copy the executable to the target board. For information on copying the executable file, see the [[ #Transferring_Files | Transferring Files ]] section.<br />
<br />
For other ways to generate the CMake files, visit the [[CMake | CMake ]] page.<br />
<br />
==== Manual Compiling ====<br />
===== Host Machine Compiling =====<br />
{{note|In these examples we are using the Ipac-9x25 board. Your board's processor's architecture will determine which file needs to be sourced. These files come from the EMAC SDK toolchain.}}<br />
<br />
Create a file called hello.c using a text editor such as vi, vim, nano, or gedit. Then copy and paste the source code from the [[ #Hello_World_System_Log_Example | Hello World System Log Example ]] section in the text editor of your choice.<br />
<br />
{{warning | Why not just create the file with touch? Why do I need an empty file? What's the point? Oh... it's supposed to have some code in it that you're not telling me about, eh? Uh...}}<br />
<br />
Once you created and saved the file with the source code, use the following syntax to compile the program called hello.c:<br />
{{cli | username=developer | hostname=ldc | gcc -o hello hello.c }}<br />
<br />
If there is no error in your code then the compiler will successfully create an executable file called hello in the current directory.<br />
<br />
To verify this, enter the following command:<br />
{{clo|indent=2}}<br />
{{clio | username=developer | hostname=ldc | ls -l hello* }}<br />
-rwxrwxr-x 1 bserrano bserrano 9583 Apr 6 12:45 hello <br /><br />
-rwxr-xr-x 1 bserrano bserrano 129 Apr 6 12:28 hello.c <br />
{{clos}}<br />
<br />
To run the program, enter the following command:<br />
{{clo|indent=2}}<br />
{{clio | username=developer | hostname=ldc | ./hello }}<br />
Hello EMAC OE!<br />
{{clos}}<br />
<br />
OR<br />
{{clo|indent=2}}<br />
{{clio | username=developer | hostname=ldc | /path/to/hello }}<br />
Hello EMAC OE!<br />
{{clos}}<br />
<br />
===== Target Board Compiling =====<br />
<br />
To compile for the target board, you must <code>source</code> the <code>environment-setup-armv5te-emac-linux-gnueabi</code> file.<br />
{{cli | username=developer | hostname=ldc | source /opt/emac/5.0/environment-setup-armv5te-emac-linux-gnueabi }}<br />
<br />
Once you are in the directory with the source file, enter the following command:<br />
{{cli | username=developer | hostname=ldc | $CC -o hello hello.c }}<br />
<br />
{{note|Once you source the file in your current terminal, you can only use it to cross-compile your program for the target board. You can no longer compile it for your host machine. To compile it to your host machine, simply open a new terminal.}}<br />
<br />
After sourcing the file, copy the program over to the target board using <code>scp</code>. Enter the following command:<br />
{{clo|indent=2}}<br />
{{clio | username=developer | hostname=ldc | scp hello root@10.0.6.221: }}<br />
root@10.0.6.221's password: <br />
hello 100% 9583 9.4KB/s 00:00 <br />
{{clos}}<br />
<br />
After copying the program, you can now execute the program on the target board. Enter the following command:<br />
{{clo|indent=2}}<br />
{{clio | username=developer | hostname=ldc | ssh root@10.0.6.221 ./hello}}<br />
root@10.0.6.221's password: <br /> <br />
Hello EMAC OE!<br />
{{clos}}<br />
<br />
=== Linux Filesystem Organization ===<br />
In order to prevent confusion and promote portability, a standard was created for the organization of the Linux filesystem. To ensure future portability of software created today, promote maintainability of software, and ensure proper utilization of available storage on an embedded machine, this standard should be followed as much as possible. This document covers parts of the standard and gives information about the customizations made to it by EMAC OE to accommodate embedded hardware. A link is provided to the standards document which covers the organization of the Linux filesystem at the end of this document. For more information visit the [[Linux_Filesystem_Organization | Linux Filesystem Organization]] page.<br />
<br />
EMAC recommends ''/usr/local/bin'' as the location for software you deploy.<br />
<br />
/usr/local/bin<br />
<br />
{{note|It is important to pay attention to the filesystem structure in order to ensure that your application will work as expected when the filesystem is in production. Reasons for this include:<br />
<cl><br />
1. Only certain directories, such as ''/var/'' and ''/tmp/'', are writeable when the filesystem is read-only.<br />
* Only certain directories should contain executables, such as ''/bin/'', ''/usr/bin/'', and ''/usr/local/bin/''.<br />
* Following this directory structure properly will make it easier to port your software to a newer release of EMAC OE later on.<br />
</cl>}}<br />
<br />
=== Remote Debugging ===<br />
Sometimes a program has no technical errors that cause the compile to fail, but fails to meet the developer's expectations when run. This is typically due to algorithm or data structure design errors which can be difficult to find with just visual inspection of the code. Because of this, it can be beneficial to run a debugger targeting the executable process. Debugging is the process of watching what is going on inside of another program while it is running. When a program is compiled with debug symbols included in the binary, it is possible to observe the source code and corresponding assembly code while running the debugger.<br />
<br />
{{ warning | The above paragraph comes across as sounding like the article is targeted towards a beginner programmer. The reader may be a beginner to cross compiling and to embedded, but is very unlikely to be a beginner programmer. Rather than describing what a debugger is, it would be better to tell them about their ability to remotely debug their software over Ethernet using gdb, because that's something that could be new (and cool) to them. Also, they're going to want to know that there are both commandline and GUI versions of the debugger available (most of them will only care about the GUI version, but not all) and that the EMAC provided Qt Creator is all set up for remote debugging (once it knows what IP address to point to).}}<br />
<br />
When working with embedded systems the binary is usually compiled on a development machine with a different CPU architecture than what is on the target machine. This can be a problem when, as is typically the case, the target machine lacks the system resources to run a debugger. In these cases, it is possible to use the GNU debugger, or GDB, on the development machine to remotely debug the target machine provided it has a program called gdbserver. All EMAC OE builds are packaged with gdbserver to simplify the setup process for developers.<br />
<br />
For more information visit the [[Remote_Debugging_EMAC_OE_SDK_Projects_with_gdbserver | Remote Debugging EMAC OE SDK Projects with gdbserver]] page.<br />
<br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /***************************************** Examples *****************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
{{:Templateimpl:examples | initials=BS | title=Getting Started with the EMAC OE SDK | desc=Basic tutorial for using the EMAC OE SDK. | project=OE 5.0 }}<br />
<br />
=== Hello World System Log Example ===<br />
This example will print <code>Hello EMAC OE!</code> to the syslog facility as well as the console. This will allow you to log, debug, and send status messages to the system logger.<br />
<br />
To compile and run this program, see the sections above.<br />
<br />
<syntaxhighlight lang="c"><br />
#include <stdio.h><br />
#include <stdlib.h><br />
#include <unistd.h><br />
#include <syslog.h><br />
<br />
int main(int argc, char** argv)<br />
{ <br />
char message[] = "Hello EMAC OE!";<br />
<br />
openlog("slog", LOG_PID|LOG_CONS, LOG_USER);<br />
syslog(LOG_INFO, "%s", message);<br />
closelog(); <br />
<br />
printf("%s\n", message);<br />
<br />
return 0;<br />
}<br />
</syntaxhighlight><br />
<br />
This is extremely useful because it allows you to save a record of the output that you might not see first hand.<br />
<br />
To verify the output of the program went into syslog, enter the following command:<br />
{{clo|indent=2}}<br />
{{clio | username=developer | hostname=ldc | tail /var/log/syslog}}<br />
Apr 7 14:10:06 ENG-26-LX dhclient: DHCPACK of 10.0.6.237 from 10.0.2.1<br /><br />
Apr 7 14:10:06 ENG-26-LX dhclient: bound to 10.0.6.237 -- renewal in 3306 seconds.<br /><br />
Apr 7 14:17:01 ENG-26-LX CRON[21193]: (root) CMD ( cd / && run-parts --report /etc/cron.hourly)<br /><br />
Apr 7 14:54:41 ENG-26-LX hpcups[21266]: prnt/hpcups/HPCupsFilter.cpp 689: First raster data plane..<br /><br />
Apr 7 14:55:31 hpcups[21266]: last message repeated 3 times<br /><br />
Apr 7 15:05:12 ENG-26-LX dhclient: DHCPREQUEST of 10.0.6.237 on eth0 to 10.0.2.1 port 67<br /><br />
Apr 7 15:05:12 ENG-26-LX dhclient: DHCPACK of 10.0.6.237 from 10.0.2.1<br /><br />
Apr 7 15:05:12 ENG-26-LX dhclient: bound to 10.0.6.237 -- renewal in 3559 seconds.<br /><br />
Apr 7 15:17:01 ENG-26-LX CRON[21302]: (root) CMD ( cd / && run-parts --report /etc/cron.hourly)<br /><br />
Apr 7 15:27:08 ENG-26-LX slog[21375]: Hello EMAC OE!<br />
{{clos}}<br />
<br />
As you can see on the bottom line, your program output has been recorded and date stamped in syslog.<br />
<br />
For more information on system logging visit the [[System_Logging| System Logging ]] page.<br />
<br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /****************************************** More Information *****************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
{{:Templateimpl:moreinfo | initials=BS | title=Getting Started with the EMAC OE SDK | desc=Basic tutorial for using the EMAC OE SDK. | project=OE 5.0 }}<br />
* [[Getting_Started_With_Qt_Creator |Getting Started With Qt Creator]]<br />
<br />
{{:Templateimpl:whatnext | initials=BS | title=Getting Started with the EMAC OE SDK | desc=Basic tutorial for using the EMAC OE SDK. | project=OE 5.0 }}<br />
* [[System_Log_In | System Log In]]<br />
* [[Serial_Connections | Serial Connections ]]<br />
* [[Network_Connections | Network_Connections ]]<br />
* [[System_Log_In | System Log In ]]<br />
* [[Remote_Debugging_EMAC_OE_SDK_Projects_with_gdbserver | Remote Debugging EMAC OE SDK Projects with gdbserver ]]<br />
* [[Linux_Filesystem_Organization | Linux Filesystem Organization]]<br />
* [[CMake | CMake ]]<br />
* [[Remote_Debugging_EMAC_OE_SDK_with_gdbserver | Remote Debugging EMAC OE SDK Projects with gdbserver]]<br />
* [[System_Logging | System Logging ]]</div>Bserranohttps://wiki.emacinc.com/index.php?title=Getting_Started_with_the_EMAC_OE_SDK&diff=4298Getting Started with the EMAC OE SDK2015-04-29T21:22:44Z<p>Bserrano: </p>
<hr />
<div>{{todo| Review (03.31.2015-13:42->BS+);(04.08.2015-15:00->BS+);(04.09.15-14:00->MD+);(04.21.2015-10:15->BS+);(04.24.2015-20:00->MD-);(04.28.2015-12:20->MD+);(04.29.2015-16:00->BS+) |Brian Serrano| project=OE 5.0,BS,MD,Review}}<br />
{{#seo:<br />
|title=Getting Started with the EMAC OE SDK<br />
|titlemode=append<br />
|keywords=EMAC SDK,Cross compiling, ARM Target Compiling, CMake Build System, CMake Cross Compiling<br />
|description=A basic tutorial for using the EMAC OE SDK.<br />
}}<br />
<br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /**************************************** Page Description Text ****************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
<br />
<span style="background:#00FF00;color:#FF0000;font-size:300%"></span><br />
The EMAC OE SDK is distributed with a set of example projects intended to demonstrate how to use the EMAC OE toolchain and libraries. This page demonstrates the process of compiling an example project and running it on the target machine. Also, it provides a straightforward guide to the essential steps you need to follow to get started with cross compiling a simple program with gcc and running the program on your embedded machine.<br />
<br />
__TOC__<br />
<br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /***************************************** General Information *****************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
{{:Templateimpl:geninfo | initials=BS | title=Getting Started with the EMAC OE SDK | desc=Basic tutorial for using the EMAC OE SDK. | project=OE 5.0 }}<br />
<br />
The EMAC OE SDK is primarily distributed via our apt repository as a deb package for Ubuntu. Using EMAC's apt repository makes installing and updating the EMAC SDK and tools as easy as installing and updating any standard Ubuntu package. This tutorial will show you how to configure your system to use the EMAC apt repository so that you can use the same package management tools you're familiar with in Ubuntu to install and update the EMAC provided SDK and tools.<br />
<br />
EMAC also provides a tarball you can extract and install manually in case you're using a distribution other than Ubuntu (or a derivative), but EMAC strongly recommends using an Ubuntu LTS release. The recent Ubuntu LTS releases have been thoroughly tested with the EMAC SDK and tools and are fully supported by EMAC. Given the large number of alternate Linux distributions available, EMAC is only able to provide limited support (in the form of a manually installed tarball) for other Linux distributions. <br />
<br />
Each SDK includes the C/C++ header files and libraries compatible with the target hardware. It also includes the C/C++ cross-compiler toolchain components necessary to compile and debug custom application code. The links below will help you get started building and running the example projects on the target hardware.<br />
<br />
More information on using Qt Creator with the EMAC SDK is available on the [[Getting_Started_With_Qt_Creator |Getting Started With Qt Creator]] page.<br />
<br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /***************************************** Using/Working With ******************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
{{:Templateimpl:using | initials=BS | title=Getting Started with the EMAC OE SDK | desc=Basic tutorial for using the EMAC OE SDK. | project=OE 5.0 }} <br />
=== Connecting to a Target Board ===<br />
The next step after establishing a physical connection to the board is logging in. More information on establishing a physical connection to a board is available on the [[Serrial_Connections |Serial Connections]] and [[Network_Connections |Network Connections]] page. <br />
<br />
A machine running EMAC OE Linux can be connected to through a serial port or through a network cable. EMAC OE Linux allows users to log in via getty, and SSH (Secure Shell). A getty can be accessed via a serial connection (through a console) while SSH utilizes a network connection. For more information visit the [[System_Log_In | System Log In]] page.<br />
<br />
=== Setting the Filesystem to Read-Write ===<br />
The root filesystem on a machine running EMAC OE Linux is mounted read-only by default. In order to put files on the board, you may need to make the filesystem read-write. The [[Linux_Filesystem_Organization|Linux Filesystem Organization page]] has more information regarding which parts of the filesystem are mounted read-only by default versus which parts are always writeable. Note that EMAC recommends installing your program into a read-only portion of the filesystem (according to the guide) to safeguard it from filesystem corruption (such as may be caused by removing power from the board without shutting down the operating system first, which is normal in embedded systems).<br />
<br />
To remount the root filesytem in read-write mode, enter the following into the terminal: <br />
{{cli | oemntrw | hostname=ipac9x25}}<br />
<br />
{{note|This will only change the root filesystem to read-write for the current boot. When the system is rebooted, the root filesystem will once again be mounted read-only.}}<br />
<br />
=== Transferring Files ===<br />
The command line syntax for transferring a file using the SSH protocol is <code>scp file user@host:/directory</code>. SCP or Secure Copy is a way of securely transferring files between a local and remote host. For example, to send the file ''example.text'' to the <code>/home</code> directory of a system with the IP address 10.0.6.221, enter the following command:<br />
{{cli | username=developer | hostname=ldc | scp example.text root@10.0.6.221:/home/ }}<br />
<br />
Alternatively, you can leave off the path after the colon if you want the file to go directly into the home directory.<br />
<br />
{{cli | username=developer | hostname=ldc | scp example.text root@10.0.6.221: }}<br />
<br />
{{note|This copy operation will fail if the filesystem on the remote machine is mounted read-only, which is the default on most EMAC systems. If you experience this failure, remount the root filesystem read-write (see above) and try again.}}<br />
<br />
=== Remote Execution ===<br />
SSH can also be used to execute programs on remote systems without logging in. The syntax for SSH remote execution is <code>ssh user@host "my_command -args file"</code>. The following is an example of a command to run a program on a board with the IP address of ''10.0.6.221''.<br />
<br />
{{cli | username=developer | hostname=ldc | ssh root@10.0.6.221 "/path/to/executable -args" }}<br />
<br />
{{warning | The description doesn't match the example}}<br />
<br />
=== Basic Compiling ===<br />
In the two subsections below, it will show two options on how to compile the example source code. The first subsection will demonstrate on how to use the EMAC [[ #CMake_Compiling| CMake ]] tool and the second subsection demonstrates how to compile codec [[ #Manual_Compiling | manually ]].<br />
<br />
==== CMake Compiling ====<br />
===== Host Machine Compiling =====<br />
{{warning|This note belongs in the following section (manual), not here. There should also be a description in the parent section (Compiling) which describes the two subsections, so that the reader will know what's coming and can decide to skip to one or the other, if he/she only wants to learn about one method.}}<br />
<br />
This section demonstrates how to use the EMAC CMake tool to generate CMake files automatically for a project. When using the EMAC SDK there are currently two options for cross compiling:<br />
* arm<br />
* x86<br />
For the purposes of this guide, the arm option will be used for the listed examples.<br />
<br />
Navigate to the directory where the project will be located. Then run the CMake new project script.<br />
{{clo|indent=2}}<br />
{{clio | username=developer | hostname=ldc | pwd=~/projects | oe_init_project -n hello.c }}<br />
If desired, please enter a name for this project, otherwise press Enter to use the default: hello_emac <br /><br />
<br />
-- Creating new project directory... <br /><br />
-- Creating new source file... <br /><br />
-- Building custom CMakeLists.txt file... <br /><br />
-- Done. <br /><br />
<br />
Do you want to create a build directory for this project? (y/n) y <br /><br />
<br />
-- Creating build directory... <br /><br />
<br />
Do you want to run cmake for this project? (y/n) y <br /><br />
<br />
-- Using system compiler <br /><br />
-- The C compiler identification is GNU 4.8.2 <br /><br />
-- The CXX compiler identification is GNU 4.8.2 <br /><br />
-- Check for working C compiler: /usr/bin/cc <br /><br />
-- Check for working C compiler: /usr/bin/cc -- works <br /><br />
-- Detecting C compiler ABI info <br /><br />
-- Detecting C compiler ABI info - done <br /><br />
-- Check for working CXX compiler: /usr/bin/c++ <br /><br />
-- Check for working CXX compiler: /usr/bin/c++ -- works <br /><br />
-- Detecting CXX compiler ABI info <br /><br />
-- Detecting CXX compiler ABI info - done <br /><br />
-- Configuring done <br /><br />
-- Generating done <br /><br />
-- Build files have been written to: /home/developer/projects/hello_emac/hello_emac-build <br /><br />
<br />
Do you want to compile this project? (y/n) y<br />
<br />
Scanning dependencies of target hello_emac <br /><br />
[100%] Building C object CMakeFiles/hello_emac.dir/hello.c.o <br /><br />
Linking C executable hello_emac <br /><br />
[100%] Built target hello_emac <br /><br />
{{clos}}<br />
<br />
The executable in this case, is now inside the <code> hello_emac/hello_emac-build </code> directory.<br />
<br />
===== Target Machine Compiling =====<br />
{{note | There needs to be lead in text here describing what they got from the last section. It's jarring to see that you have to create a directory to cross-compile the project into immediately after you've finished a step which supposedly created an executable for you; it'll make the reader wonder if this is supposed to be steps for them to perform if they didn't perform the one above. So, describe the CMake files that were produced above, what they contain, why they're important, and why they now should create a subdirectory for doing the cross compile. Documentation is supposed to take the mystery out of the process, but if you leave these details out, you're leaving part of it as a mystery.<br />Also, are you sure 'arm' is the only target you should list? What if the reader is on x86? They won't know if they should pass 'Intel', 'i386', 'x86', etc. Tell them by giving them a complete list of options. ;) }}<br />
<br />
The CMake project script has now made a project directory that contains the following:<br />
* CMakeLists.txt<br />
* Source code file (''hello.c'' in this case)<br />
* ''README'' file<br />
* Desktop Build Directory (''hello_emac-build'' in this case)<br />
<br />
The ''CMakeLists.txt'' contains the required information to automatically create a ''Makefile'' for a given architecture.<br />
<br />
The source code file generated by the script (''hello.c'') contains a basic Hello World style program.<br />
<br />
The ''README'' file contains more information on using ''CMake'' with the EMAC 5.0 SDK.<br />
<br />
The Desktop Build Directory (''hello_emac-build'') contains the executable ''hello_emac'', the ''Makefile'', and various cache files.<br />
<br />
It is important to have a Desktop Build Directory because it is good practice to use the desktop to verify all code changes before cross-compiling to a target board. This saves time on transferring files between the target board. <br />
<br />
Use the following steps to cross-compile the project and send it to a target board. In a terminal, navigate to the base directory of the project (where this document is located).<br />
<br />
If the target board being used is ''x86'', then change all occurrences of ''arm'' in the following sections below to ''x86''.<br />
<br />
Create a build directory for cross compiling. <br />
{{clio | username=developer | hostname=ldc | pwd=~/projects/hello_emac | mkdir hello_emac-build-arm }} <br />
<br />
Change directories into the newly created directory.<br />
{{clio | username=developer | hostname=ldc | pwd=~/projects/hello_emac | cd hello_emac-build-arm }} <br />
<br />
Run cmake using the target architecture.<br />
{{clio | username=developer | hostname=ldc | pwd=~/projects/hello_emac/hello_emac-build-arm | 1 = cmake .. -DARCH:STRING=arm }} <br />
<br />
Compile the code using make.<br />
{{clio | username=developer | hostname=ldc | pwd=~/projects/hello_emac/hello_emac-build-arm | make }} <br />
<br />
After running the <code> make </code> command, the target executable is now in the <code> hello_emac-build-arm </code> directory. Then copy the executable to the target board. For information on copying the executable file, see the [[ #Transferring_Files | Transferring Files ]] section.<br />
<br />
For other ways to generate the CMake files, visit the [[CMake | CMake ]] page.<br />
<br />
==== Manual Compiling ====<br />
===== Host Machine Compiling =====<br />
{{note|In these examples we are using the Ipac-9x25 board. Your board's processor's architecture will determine which file needs to be sourced. These files come from the EMAC SDK toolchain.}}<br />
<br />
Create a file called hello.c using a text editor such as vi, vim, nano, or gedit. Then copy and paste the source code from the [[ #Hello_World_System_Log_Example | Hello World System Log Example ]] section in the text editor of your choice.<br />
<br />
{{warning | Why not just create the file with touch? Why do I need an empty file? What's the point? Oh... it's supposed to have some code in it that you're not telling me about, eh? Uh...}}<br />
<br />
Once you created and saved the file with the source code, use the following syntax to compile the program called hello.c:<br />
{{cli | username=developer | hostname=ldc | gcc -o hello hello.c }}<br />
<br />
If there is no error in your code then the compiler will successfully create an executable file called hello in the current directory.<br />
<br />
To verify this, enter the following command:<br />
{{clo|indent=2}}<br />
{{clio | username=developer | hostname=ldc | ls -l hello* }}<br />
-rwxrwxr-x 1 bserrano bserrano 9583 Apr 6 12:45 hello <br /><br />
-rwxr-xr-x 1 bserrano bserrano 129 Apr 6 12:28 hello.c <br />
{{clos}}<br />
<br />
To run the program, enter the following command:<br />
{{clo|indent=2}}<br />
{{clio | username=developer | hostname=ldc | ./hello }}<br />
Hello EMAC OE!<br />
{{clos}}<br />
<br />
OR<br />
{{clo|indent=2}}<br />
{{clio | username=developer | hostname=ldc | /path/to/hello }}<br />
Hello EMAC OE!<br />
{{clos}}<br />
<br />
===== Target Board Compiling =====<br />
<br />
To compile for the target board, you must <code>source</code> the <code>environment-setup-armv5te-emac-linux-gnueabi</code> file.<br />
{{cli | username=developer | hostname=ldc | source /opt/emac/5.0/environment-setup-armv5te-emac-linux-gnueabi }}<br />
<br />
Once you are in the directory with the source file, enter the following command:<br />
{{cli | username=developer | hostname=ldc | $CC -o hello hello.c }}<br />
<br />
{{note|Once you source the file in your current terminal, you can only use it to cross-compile your program for the target board. You can no longer compile it for your host machine. To compile it to your host machine, simply open a new terminal.}}<br />
<br />
After sourcing the file, copy the program over to the target board using <code>scp</code>. Enter the following command:<br />
{{clo|indent=2}}<br />
{{clio | username=developer | hostname=ldc | scp hello root@10.0.6.221: }}<br />
root@10.0.6.221's password: <br />
hello 100% 9583 9.4KB/s 00:00 <br />
{{clos}}<br />
<br />
After copying the program, you can now execute the program on the target board. Enter the following command:<br />
{{clo|indent=2}}<br />
{{clio | username=developer | hostname=ldc | ssh root@10.0.6.221 ./hello}}<br />
root@10.0.6.221's password: <br /> <br />
Hello EMAC OE!<br />
{{clos}}<br />
<br />
=== Linux Filesystem Organization ===<br />
In order to prevent confusion and promote portability, a standard was created for the organization of the Linux filesystem. To ensure future portability of software created today, promote maintainability of software, and ensure proper utilization of available storage on an embedded machine, this standard should be followed as much as possible. This document covers parts of the standard and gives information about the customizations made to it by EMAC OE to accommodate embedded hardware. A link is provided to the standards document which covers the organization of the Linux filesystem at the end of this document. For more information visit the [[Linux_Filesystem_Organization | Linux Filesystem Organization]] page.<br />
<br />
EMAC recommends ''/usr/local/bin'' as the location for software you deploy.<br />
<br />
/usr/local/bin<br />
<br />
{{note|It is important to pay attention to the filesystem structure in order to ensure that your application will work as expected when the filesystem is in production. Reasons for this include:<br />
<cl><br />
1. Only certain directories, such as ''/var/'' and ''/tmp/'', are writeable when the filesystem is read-only.<br />
* Only certain directories should contain executables, such as ''/bin/'', ''/usr/bin/'', and ''/usr/local/bin/''.<br />
* Following this directory structure properly will make it easier to port your software to a newer release of EMAC OE later on.<br />
</cl>}}<br />
<br />
=== Remote Debugging ===<br />
Sometimes a program has no technical errors that cause the compile to fail, but fails to meet the developer's expectations when run. This is typically due to algorithm or data structure design errors which can be difficult to find with just visual inspection of the code. Because of this, it can be beneficial to run a debugger targeting the executable process. Debugging is the process of watching what is going on inside of another program while it is running. When a program is compiled with debug symbols included in the binary, it is possible to observe the source code and corresponding assembly code while running the debugger.<br />
<br />
{{ warning | The above paragraph comes across as sounding like the article is targeted towards a beginner programmer. The reader may be a beginner to cross compiling and to embedded, but is very unlikely to be a beginner programmer. Rather than describing what a debugger is, it would be better to tell them about their ability to remotely debug their software over Ethernet using gdb, because that's something that could be new (and cool) to them. Also, they're going to want to know that there are both commandline and GUI versions of the debugger available (most of them will only care about the GUI version, but not all) and that the EMAC provided Qt Creator is all set up for remote debugging (once it knows what IP address to point to).}}<br />
<br />
When working with embedded systems the binary is usually compiled on a development machine with a different CPU architecture than what is on the target machine. This can be a problem when, as is typically the case, the target machine lacks the system resources to run a debugger. In these cases, it is possible to use the GNU debugger, or GDB, on the development machine to remotely debug the target machine provided it has a program called gdbserver. All EMAC OE builds are packaged with gdbserver to simplify the setup process for developers.<br />
<br />
For more information visit the [[Remote_Debugging_EMAC_OE_SDK_Projects_with_gdbserver | Remote Debugging EMAC OE SDK Projects with gdbserver]] page.<br />
<br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /***************************************** Examples *****************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
{{:Templateimpl:examples | initials=BS | title=Getting Started with the EMAC OE SDK | desc=Basic tutorial for using the EMAC OE SDK. | project=OE 5.0 }}<br />
<br />
=== Hello World System Log Example ===<br />
This example will print <code>Hello EMAC OE!</code> to the syslog facility as well as the console. This will allow you to log, debug, and send status messages to the system logger.<br />
<br />
To compile and run this program, see the sections above.<br />
<br />
<syntaxhighlight lang="c"><br />
#include <stdio.h><br />
#include <stdlib.h><br />
#include <unistd.h><br />
#include <syslog.h><br />
<br />
int main(int argc, char** argv)<br />
{ <br />
char message[] = "Hello EMAC OE!";<br />
<br />
openlog("slog", LOG_PID|LOG_CONS, LOG_USER);<br />
syslog(LOG_INFO, "%s", message);<br />
closelog(); <br />
<br />
printf("%s\n", message);<br />
<br />
return 0;<br />
}<br />
</syntaxhighlight><br />
<br />
This is extremely useful because it allows you to save a record of the output that you might not see first hand.<br />
<br />
To verify the output of the program went into syslog, enter the following command:<br />
{{clo|indent=2}}<br />
{{clio | username=developer | hostname=ldc | tail /var/log/syslog}}<br />
Apr 7 14:10:06 ENG-26-LX dhclient: DHCPACK of 10.0.6.237 from 10.0.2.1<br /><br />
Apr 7 14:10:06 ENG-26-LX dhclient: bound to 10.0.6.237 -- renewal in 3306 seconds.<br /><br />
Apr 7 14:17:01 ENG-26-LX CRON[21193]: (root) CMD ( cd / && run-parts --report /etc/cron.hourly)<br /><br />
Apr 7 14:54:41 ENG-26-LX hpcups[21266]: prnt/hpcups/HPCupsFilter.cpp 689: First raster data plane..<br /><br />
Apr 7 14:55:31 hpcups[21266]: last message repeated 3 times<br /><br />
Apr 7 15:05:12 ENG-26-LX dhclient: DHCPREQUEST of 10.0.6.237 on eth0 to 10.0.2.1 port 67<br /><br />
Apr 7 15:05:12 ENG-26-LX dhclient: DHCPACK of 10.0.6.237 from 10.0.2.1<br /><br />
Apr 7 15:05:12 ENG-26-LX dhclient: bound to 10.0.6.237 -- renewal in 3559 seconds.<br /><br />
Apr 7 15:17:01 ENG-26-LX CRON[21302]: (root) CMD ( cd / && run-parts --report /etc/cron.hourly)<br /><br />
Apr 7 15:27:08 ENG-26-LX slog[21375]: Hello EMAC OE!<br />
{{clos}}<br />
<br />
As you can see on the bottom line, your program output has been recorded and date stamped in syslog.<br />
<br />
For more information on system logging visit the [[System_Logging| System Logging ]] page.<br />
<br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /****************************************** More Information *****************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
{{:Templateimpl:moreinfo | initials=BS | title=Getting Started with the EMAC OE SDK | desc=Basic tutorial for using the EMAC OE SDK. | project=OE 5.0 }}<br />
* [[Getting_Started_With_Qt_Creator |Getting Started With Qt Creator]]<br />
<br />
{{:Templateimpl:whatnext | initials=BS | title=Getting Started with the EMAC OE SDK | desc=Basic tutorial for using the EMAC OE SDK. | project=OE 5.0 }}<br />
* [[System_Log_In | System Log In]]<br />
* [[Serial_Connections | Serial Connections ]]<br />
* [[Network_Connections | Network_Connections ]]<br />
* [[System_Log_In | System Log In ]]<br />
* [[Remote_Debugging_EMAC_OE_SDK_Projects_with_gdbserver | Remote Debugging EMAC OE SDK Projects with gdbserver ]]<br />
* [[Linux_Filesystem_Organization | Linux Filesystem Organization]]<br />
* [[CMake | CMake ]]<br />
* [[Remote_Debugging_EMAC_OE_SDK_with_gdbserver | Remote Debugging EMAC OE SDK Projects with gdbserver]]<br />
* [[System_Logging | System Logging ]]</div>Bserranohttps://wiki.emacinc.com/index.php?title=Getting_Started_with_the_EMAC_OE_SDK&diff=4297Getting Started with the EMAC OE SDK2015-04-29T21:02:18Z<p>Bserrano: </p>
<hr />
<div>{{todo| Review (03.31.2015-13:42->BS+);(04.08.2015-15:00->BS+);(04.09.15-14:00->MD+);(04.21.2015-10:15->BS+);(04.24.2015-20:00->MD-);(04.28.2015-12:20->MD+);(04.29.2015-16:00->BS+) |Brian Serrano| project=OE 5.0,BS,MD,Buggy}}<br />
{{#seo:<br />
|title=Getting Started with the EMAC OE SDK<br />
|titlemode=append<br />
|keywords=EMAC SDK,Cross compiling, ARM Target Compiling, CMake Build System, CMake Cross Compiling<br />
|description=A basic tutorial for using the EMAC OE SDK.<br />
}}<br />
<br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /**************************************** Page Description Text ****************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
<br />
<span style="background:#00FF00;color:#FF0000;font-size:300%"></span><br />
The EMAC OE SDK is distributed with a set of example projects intended to demonstrate how to use the EMAC OE toolchain and libraries. This page demonstrates the process of compiling an example project and running it on the target machine. Also, it provides a straightforward guide to the essential steps you need to follow to get started with cross compiling a simple program with gcc and running the program on your embedded machine.<br />
<br />
__TOC__<br />
<br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /***************************************** General Information *****************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
{{:Templateimpl:geninfo | initials=BS | title=Getting Started with the EMAC OE SDK | desc=Basic tutorial for using the EMAC OE SDK. | project=OE 5.0 }}<br />
<br />
The EMAC OE SDK is primarily distributed via our apt repository as a deb package for Ubuntu. Using EMAC's apt repository makes installing and updating the EMAC SDK and tools as easy as installing and updating any standard Ubuntu package. This tutorial will show you how to configure your system to use the EMAC apt repository so that you can use the same package management tools you're familiar with in Ubuntu to install and update the EMAC provided SDK and tools.<br />
<br />
EMAC also provides a tarball you can extract and install manually in case you're using a distribution other than Ubuntu (or a derivative), but EMAC strongly recommends using an Ubuntu LTS release. The recent Ubuntu LTS releases have been thoroughly tested with the EMAC SDK and tools and are fully supported by EMAC. Given the large number of alternate Linux distributions available, EMAC is only able to provide limited support (in the form of a manually installed tarball) for other Linux distributions. <br />
<br />
Each SDK includes the C/C++ header files and libraries compatible with the target hardware. It also includes the C/C++ cross-compiler toolchain components necessary to compile and debug custom application code. The links below will help you get started building and running the example projects on the target hardware.<br />
<br />
More information on using Qt Creator with the EMAC SDK is available on the [[Getting_Started_With_Qt_Creator |Getting Started With Qt Creator]] page.<br />
<br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /***************************************** Using/Working With ******************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
{{:Templateimpl:using | initials=BS | title=Getting Started with the EMAC OE SDK | desc=Basic tutorial for using the EMAC OE SDK. | project=OE 5.0 }} <br />
=== Connecting to a Target Board ===<br />
The next step after establishing a physical connection to the board is logging in. More information on establishing a physical connection to a board is available on the [[Serrial_Connections |Serial Connections]] and [[Network_Connections |Network Connections]] page. <br />
<br />
A machine running EMAC OE Linux can be connected to through a serial port or through a network cable. EMAC OE Linux allows users to log in via getty, and SSH (Secure Shell). A getty can be accessed via a serial connection (through a console) while SSH utilizes a network connection. For more information visit the [[System_Log_In | System Log In]] page.<br />
<br />
=== Setting the Filesystem to Read-Write ===<br />
The root filesystem on a machine running EMAC OE Linux is mounted read-only by default. In order to put files on the board, you may need to make the filesystem read-write. The [[Linux_Filesystem_Organization|Linux Filesystem Organization page]] has more information regarding which parts of the filesystem are mounted read-only by default versus which parts are always writeable. Note that EMAC recommends installing your program into a read-only portion of the filesystem (according to the guide) to safeguard it from filesystem corruption (such as may be caused by removing power from the board without shutting down the operating system first, which is normal in embedded systems).<br />
<br />
To remount the root filesytem in read-write mode, enter the following into the terminal: <br />
{{cli | oemntrw | hostname=ipac9x25}}<br />
<br />
{{note|This will only change the root filesystem to read-write for the current boot. When the system is rebooted, the root filesystem will once again be mounted read-only.}}<br />
<br />
=== Transferring Files ===<br />
The command line syntax for transferring a file using the SSH protocol is <code>scp file user@host:/directory</code>. SCP or Secure Copy is a way of securely transferring files between a local and remote host. For example, to send the file ''example.text'' to the <code>/home</code> directory of a system with the IP address 10.0.6.221, enter the following command:<br />
{{cli | username=developer | hostname=ldc | scp example.text root@10.0.6.221:/home/ }}<br />
<br />
Alternatively, you can leave off the path after the colon if you want the file to go directly into the home directory.<br />
<br />
{{cli | username=developer | hostname=ldc | scp example.text root@10.0.6.221: }}<br />
<br />
{{note|This copy operation will fail if the filesystem on the remote machine is mounted read-only, which is the default on most EMAC systems. If you experience this failure, remount the root filesystem read-write (see above) and try again.}}<br />
<br />
=== Remote Execution ===<br />
SSH can also be used to execute programs on remote systems without logging in. The syntax for SSH remote execution is <code>ssh user@host "my_command -args file"</code>. The following is an example of a command to run a program on a board with the IP address of ''10.0.6.221''.<br />
<br />
{{cli | username=developer | hostname=ldc | ssh root@10.0.6.221 "/path/to/executable -args" }}<br />
<br />
{{warning | The description doesn't match the example}}<br />
<br />
=== Basic Compiling ===<br />
In the two subsections below, it will show two options on how to compile the example source code. The first subsection will demonstrate on how to use the EMAC [[ #CMake_Compiling| CMake ]] tool and the second subsection demonstrates how to compile codec [[ #Manual_Compiling | manually ]].<br />
<br />
==== CMake Compiling ====<br />
===== Host Machine Compiling =====<br />
{{warning|This note belongs in the following section (manual), not here. There should also be a description in the parent section (Compiling) which describes the two subsections, so that the reader will know what's coming and can decide to skip to one or the other, if he/she only wants to learn about one method.}}<br />
<br />
This section demonstrates how to use the EMAC CMake tool to generate CMake files automatically for a project. When using the EMAC SDK there are currently two options for cross compiling:<br />
* arm<br />
* x86<br />
For the purposes of this guide, the arm option will be used for the listed examples.<br />
<br />
Navigate to the directory where the project will be located. Then run the CMake new project script.<br />
{{clo|indent=2}}<br />
{{clio | username=developer | hostname=ldc | pwd=~/projects | oe_init_project -n hello.c }}<br />
If desired, please enter a name for this project, otherwise press Enter to use the default: hello_emac <br /><br />
<br />
-- Creating new project directory... <br /><br />
-- Creating new source file... <br /><br />
-- Building custom CMakeLists.txt file... <br /><br />
-- Done. <br /><br />
<br />
Do you want to create a build directory for this project? (y/n) y <br /><br />
<br />
-- Creating build directory... <br /><br />
<br />
Do you want to run cmake for this project? (y/n) y <br /><br />
<br />
-- Using system compiler <br /><br />
-- The C compiler identification is GNU 4.8.2 <br /><br />
-- The CXX compiler identification is GNU 4.8.2 <br /><br />
-- Check for working C compiler: /usr/bin/cc <br /><br />
-- Check for working C compiler: /usr/bin/cc -- works <br /><br />
-- Detecting C compiler ABI info <br /><br />
-- Detecting C compiler ABI info - done <br /><br />
-- Check for working CXX compiler: /usr/bin/c++ <br /><br />
-- Check for working CXX compiler: /usr/bin/c++ -- works <br /><br />
-- Detecting CXX compiler ABI info <br /><br />
-- Detecting CXX compiler ABI info - done <br /><br />
-- Configuring done <br /><br />
-- Generating done <br /><br />
-- Build files have been written to: /home/developer/projects/hello_emac/hello_emac-build <br /><br />
<br />
Do you want to compile this project? (y/n) y<br />
<br />
Scanning dependencies of target hello_emac <br /><br />
[100%] Building C object CMakeFiles/hello_emac.dir/hello.c.o <br /><br />
Linking C executable hello_emac <br /><br />
[100%] Built target hello_emac <br /><br />
{{clos}}<br />
<br />
The executable in this case, is now inside the <code> hello_emac/hello_emac-build </code> directory.<br />
<br />
===== Target Machine Compiling =====<br />
{{note | There needs to be lead in text here describing what they got from the last section. It's jarring to see that you have to create a directory to cross-compile the project into immediately after you've finished a step which supposedly created an executable for you; it'll make the reader wonder if this is supposed to be steps for them to perform if they didn't perform the one above. So, describe the CMake files that were produced above, what they contain, why they're important, and why they now should create a subdirectory for doing the cross compile. Documentation is supposed to take the mystery out of the process, but if you leave these details out, you're leaving part of it as a mystery.<br />Also, are you sure 'arm' is the only target you should list? What if the reader is on x86? They won't know if they should pass 'Intel', 'i386', 'x86', etc. Tell them by giving them a complete list of options. ;) }}<br />
<br />
The CMake project script has now made a project directory that contains the following:<br />
* CMakeLists.txt<br />
* Source code file (''hello.c'' in this case)<br />
* ''README'' file<br />
* Desktop Build Directory (''hello_emac-build'' in this case)<br />
<br />
The ''CMakeLists.txt'' contains the required information to automatically create a ''Makefile'' for a given architecture.<br />
<br />
The source code file generated by the script (''hello.c'') contains a basic Hello World style program.<br />
<br />
The ''README'' file contains more information on using ''CMake'' with the EMAC 5.0 SDK.<br />
<br />
The Desktop Build Directory (''hello_emac-build'') contains the executable ''hello_emac'', the ''Makefile'', and various cache files.<br />
<br />
It is important to have a Desktop Build Directory because it is good practice to use the desktop to verify all code changes before cross-compiling to a target board. This saves time on transferring files between the target board. <br />
<br />
Use the following steps to cross-compile the project and send it to a target board. In a terminal, navigate to the base directory of the project (where this document is located).<br />
<br />
If the target board being used is ''x86'', then change all occurrences of ''arm'' in the following sections below to ''x86''.<br />
<br />
Create a build directory for cross compiling. <br />
{{clio | username=developer | hostname=ldc | pwd=~/projects/hello_emac | mkdir hello_emac-build-arm }} <br />
<br />
Change directories into the newly created directory.<br />
{{clio | username=developer | hostname=ldc | pwd=~/projects/hello_emac | cd hello_emac-build-arm }} <br />
<br />
Run cmake using the target architecture.<br />
{{clio | username=developer | hostname=ldc | pwd=~/projects/hello_emac/hello_emac-build-arm | 1 = cmake .. -DARCH:STRING=arm }} <br />
<br />
Compile the code using make.<br />
{{clio | username=developer | hostname=ldc | pwd=~/projects/hello_emac/hello_emac-build-arm | make }} <br />
<br />
After running the <code> make </code> command, the target executable is now in the <code> hello_emac-build-arm </code> directory. Then copy the executable to the target board. For information on copying the executable file, see the [[ #Transferring_Files | Transferring Files ]] section.<br />
<br />
For other ways to generate the CMake files, visit the [[CMake | CMake ]] page.<br />
<br />
==== Manual Compiling ====<br />
===== Host Machine Compiling =====<br />
{{note|In these examples we are using the Ipac-9x25 board. Your board's processor's architecture will determine which file needs to be sourced. These files come from the EMAC SDK toolchain.}}<br />
<br />
Create a file called hello.c using a text editor such as vi, vim, nano, or gedit. Then copy and paste the source code from the [[ #Hello_World_System_Log_Example | Hello World System Log Example ]] section in the text editor of your choice.<br />
<br />
{{warning | Why not just create the file with touch? Why do I need an empty file? What's the point? Oh... it's supposed to have some code in it that you're not telling me about, eh? Uh...}}<br />
<br />
Once you created and saved the file with the source code, use the following syntax to compile the program called hello.c:<br />
{{cli | username=developer | hostname=ldc | gcc -o hello hello.c }}<br />
<br />
If there is no error in your code then the compiler will successfully create an executable file called hello in the current directory.<br />
<br />
To verify this, enter the following command:<br />
{{clo|indent=2}}<br />
{{clio | username=developer | hostname=ldc | ls -l hello* }}<br />
-rwxrwxr-x 1 bserrano bserrano 9583 Apr 6 12:45 hello <br /><br />
-rwxr-xr-x 1 bserrano bserrano 129 Apr 6 12:28 hello.c <br />
{{clos}}<br />
<br />
To run the program, enter the following command:<br />
{{clo|indent=2}}<br />
{{clio | username=developer | hostname=ldc | ./hello }}<br />
Hello EMAC OE!<br />
{{clos}}<br />
<br />
OR<br />
{{clo|indent=2}}<br />
{{clio | username=developer | hostname=ldc | /path/to/hello }}<br />
Hello EMAC OE!<br />
{{clos}}<br />
<br />
===== Target Board Compiling =====<br />
<br />
To compile for the target board, you must <code>source</code> the <code>environment-setup-armv5te-emac-linux-gnueabi</code> file.<br />
{{cli | username=developer | hostname=ldc | source /opt/emac/5.0/environment-setup-armv5te-emac-linux-gnueabi }}<br />
<br />
Once you are in the directory with the source file, enter the following command:<br />
{{cli | username=developer | hostname=ldc | $CC -o hello hello.c }}<br />
<br />
{{note|Once you source the file in your current terminal, you can only use it to cross-compile your program for the target board. You can no longer compile it for your host machine. To compile it to your host machine, simply open a new terminal.}}<br />
<br />
After sourcing the file, copy the program over to the target board using <code>scp</code>. Enter the following command:<br />
{{clo|indent=2}}<br />
{{clio | username=developer | hostname=ldc | scp hello root@10.0.6.221: }}<br />
root@10.0.6.221's password: <br />
hello 100% 9583 9.4KB/s 00:00 <br />
{{clos}}<br />
<br />
After copying the program, you can now execute the program on the target board. Enter the following command:<br />
{{clo|indent=2}}<br />
{{clio | username=developer | hostname=ldc | ssh root@10.0.6.221 ./hello}}<br />
root@10.0.6.221's password: <br /> <br />
Hello EMAC OE!<br />
{{clos}}<br />
<br />
=== Linux Filesystem Organization ===<br />
In order to prevent confusion and promote portability, a standard was created for the organization of the Linux filesystem. To ensure future portability of software created today, promote maintainability of software, and ensure proper utilization of available storage on an embedded machine, this standard should be followed as much as possible. This document covers parts of the standard and gives information about the customizations made to it by EMAC OE to accommodate embedded hardware. A link is provided to the standards document which covers the organization of the Linux filesystem at the end of this document. For more information visit the [[Linux_Filesystem_Organization | Linux Filesystem Organization]] page.<br />
<br />
EMAC recommends ''/usr/local/bin'' as the location for software you deploy.<br />
<br />
/usr/local/bin<br />
<br />
{{note|It is important to pay attention to the filesystem structure in order to ensure that your application will work as expected when the filesystem is in production. Reasons for this include:<br />
<cl><br />
1. Only certain directories, such as ''/var/'' and ''/tmp/'', are writeable when the filesystem is read-only.<br />
* Only certain directories should contain executables, such as ''/bin/'', ''/usr/bin/'', and ''/usr/local/bin/''.<br />
* Following this directory structure properly will make it easier to port your software to a newer release of EMAC OE later on.<br />
</cl>}}<br />
<br />
=== Remote Debugging ===<br />
Sometimes a program has no technical errors that cause the compile to fail, but fails to meet the developer's expectations when run. This is typically due to algorithm or data structure design errors which can be difficult to find with just visual inspection of the code. Because of this, it can be beneficial to run a debugger targeting the executable process. Debugging is the process of watching what is going on inside of another program while it is running. When a program is compiled with debug symbols included in the binary, it is possible to observe the source code and corresponding assembly code while running the debugger.<br />
<br />
{{ warning | The above paragraph comes across as sounding like the article is targeted towards a beginner programmer. The reader may be a beginner to cross compiling and to embedded, but is very unlikely to be a beginner programmer. Rather than describing what a debugger is, it would be better to tell them about their ability to remotely debug their software over Ethernet using gdb, because that's something that could be new (and cool) to them. Also, they're going to want to know that there are both commandline and GUI versions of the debugger available (most of them will only care about the GUI version, but not all) and that the EMAC provided Qt Creator is all set up for remote debugging (once it knows what IP address to point to).}}<br />
<br />
When working with embedded systems the binary is usually compiled on a development machine with a different CPU architecture than what is on the target machine. This can be a problem when, as is typically the case, the target machine lacks the system resources to run a debugger. In these cases, it is possible to use the GNU debugger, or GDB, on the development machine to remotely debug the target machine provided it has a program called gdbserver. All EMAC OE builds are packaged with gdbserver to simplify the setup process for developers.<br />
<br />
For more information visit the [[Remote_Debugging_EMAC_OE_SDK_Projects_with_gdbserver | Remote Debugging EMAC OE SDK Projects with gdbserver]] page.<br />
<br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /***************************************** Examples *****************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
{{:Templateimpl:examples | initials=BS | title=Getting Started with the EMAC OE SDK | desc=Basic tutorial for using the EMAC OE SDK. | project=OE 5.0 }}<br />
<br />
=== Hello World System Log Example ===<br />
This example will print <code>Hello EMAC OE!</code> to the syslog facility as well as the console. This will allow you to log, debug, and send status messages to the system logger.<br />
<br />
To compile and run this program, see the sections above.<br />
<br />
<syntaxhighlight lang="c"><br />
#include <stdio.h><br />
#include <stdlib.h><br />
#include <unistd.h><br />
#include <syslog.h><br />
<br />
int main(int argc, char** argv)<br />
{ <br />
char message[] = "Hello EMAC OE!";<br />
<br />
openlog("slog", LOG_PID|LOG_CONS, LOG_USER);<br />
syslog(LOG_INFO, "%s", message);<br />
closelog(); <br />
<br />
printf("%s\n", message);<br />
<br />
return 0;<br />
}<br />
</syntaxhighlight><br />
<br />
This is extremely useful because it allows you to save a record of the output that you might not see first hand.<br />
<br />
To verify the output of the program went into syslog, enter the following command:<br />
{{clo|indent=2}}<br />
{{clio | username=developer | hostname=ldc | tail /var/log/syslog}}<br />
Apr 7 14:10:06 ENG-26-LX dhclient: DHCPACK of 10.0.6.237 from 10.0.2.1<br /><br />
Apr 7 14:10:06 ENG-26-LX dhclient: bound to 10.0.6.237 -- renewal in 3306 seconds.<br /><br />
Apr 7 14:17:01 ENG-26-LX CRON[21193]: (root) CMD ( cd / && run-parts --report /etc/cron.hourly)<br /><br />
Apr 7 14:54:41 ENG-26-LX hpcups[21266]: prnt/hpcups/HPCupsFilter.cpp 689: First raster data plane..<br /><br />
Apr 7 14:55:31 hpcups[21266]: last message repeated 3 times<br /><br />
Apr 7 15:05:12 ENG-26-LX dhclient: DHCPREQUEST of 10.0.6.237 on eth0 to 10.0.2.1 port 67<br /><br />
Apr 7 15:05:12 ENG-26-LX dhclient: DHCPACK of 10.0.6.237 from 10.0.2.1<br /><br />
Apr 7 15:05:12 ENG-26-LX dhclient: bound to 10.0.6.237 -- renewal in 3559 seconds.<br /><br />
Apr 7 15:17:01 ENG-26-LX CRON[21302]: (root) CMD ( cd / && run-parts --report /etc/cron.hourly)<br /><br />
Apr 7 15:27:08 ENG-26-LX slog[21375]: Hello EMAC OE!<br />
{{clos}}<br />
<br />
As you can see on the bottom line, your program output has been recorded and date stamped in syslog.<br />
<br />
For more information on system logging visit the [[System_Logging| System Logging ]] page.<br />
<br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /****************************************** More Information *****************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
{{:Templateimpl:moreinfo | initials=BS | title=Getting Started with the EMAC OE SDK | desc=Basic tutorial for using the EMAC OE SDK. | project=OE 5.0 }}<br />
* [[Getting_Started_With_Qt_Creator |Getting Started With Qt Creator]]<br />
<br />
{{:Templateimpl:whatnext | initials=BS | title=Getting Started with the EMAC OE SDK | desc=Basic tutorial for using the EMAC OE SDK. | project=OE 5.0 }}<br />
* [[System_Log_In | System Log In]]<br />
* [[Serial_Connections | Serial Connections ]]<br />
* [[Network_Connections | Network_Connections ]]<br />
* [[System_Log_In | System Log In ]]<br />
* [[Remote_Debugging_EMAC_OE_SDK_Projects_with_gdbserver | Remote Debugging EMAC OE SDK Projects with gdbserver ]]<br />
* [[Linux_Filesystem_Organization | Linux Filesystem Organization]]<br />
* [[CMake | CMake ]]<br />
* [[Remote_Debugging_EMAC_OE_SDK_with_gdbserver | Remote Debugging EMAC OE SDK Projects with gdbserver]]<br />
* [[System_Logging | System Logging ]]</div>Bserranohttps://wiki.emacinc.com/index.php?title=Getting_Started_with_the_EMAC_OE_SDK&diff=4280Getting Started with the EMAC OE SDK2015-04-21T16:14:55Z<p>Bserrano: </p>
<hr />
<div>{{todo| Review (03.31.2015-13:42->BS+);(04.08.2015-15:00->BS+);(04.09.15-14:00->MD+);(04.21.2015-10:15->BS+) |Brian Serrano| project=OE 5.0,BS,MD}}<br />
{{#seo:<br />
|title=Getting Started with the EMAC OE SDK<br />
|titlemode=append<br />
|keywords=EMAC SDK,Hello World Example,Target Compiling, Host Compiling<br />
|description=A basic tutorial for using the EMAC OE SDK.<br />
}}<br />
{{warning|Now is a good time to come up with keywords for the SEO tag.}}<br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /**************************************** Page Description Text ****************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
<span style="background:#00FF00;color:#FF0000;font-size:300%"></span><br />
<br />
The EMAC OE SDK is distributed with a set of example projects intended to demonstrate how to use the EMAC OE toolchain and libraries. This page demonstrates the process of compiling an example project and running it on the target machine. Also, it provides a straightforward guide to the essential steps you need to follow to get started with cross compiling a simple program with gcc and running the program on your embedded machine.<br />
{{warning|The following sentence isn't very compelling. I'd probably click back and look for a different page after reading that sentence. Maybe something like, "This page provides a straightforward guide to the essential steps you need to follow to get started with cross compiling a simple program with gcc and running the program on your embedded machine." }}<br />
__TOC__<br />
<br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /***************************************** General Information *****************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
{{:Templateimpl:geninfo | initials=BS | title=Getting Started with the EMAC OE SDK | desc=Basic tutorial for using the EMAC OE SDK. | project=OE 5.0 }}<br />
{{warning|We primarily distribute the SDK with our apt repository as a deb file for Ubuntu. We also provide a tarball they can extract, but we recommend the deb because that's the only version we officially support. I would reword this sentence to reflect that.}}<br />
The EMAC Open Embedded SDK is primarily distributed with our apt repository as a deb file for Ubuntu. EMAC also provides a tarbell you can extract, but recommends the deb file because it's the only version EMAC officially supports.<br />
<br />
Each SDK includes the C/C++ header files and libraries compatible with the target hardware. It also includes the C/C++ cross-compiler toolchain components necessary to compile and debug custom application code. The links below will help you get started building and running the example projects on the target hardware.<br />
<br />
More information on using Qt Creator with the EMAC SDK is available on the [[Getting_Started_With_Qt_Creator |Getting Started With Qt Creator]] page.<br />
{{warning|Using commanding language ("Follow the links to do this") sounds a bit unfriendly when talking to customers (as opposeMike dean d to internal documentation). We've tried to steer away from that in our documentation as much as possible. Instead, we try to phrase sentences in a friendly, informative way. I reworded two sentences above to show what I mean.}}<br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /***************************************** Using/Working With ******************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
{{:Templateimpl:using | initials=BS | title=Getting Started with the EMAC OE SDK | desc=Basic tutorial for using the EMAC OE SDK. | project=OE 5.0 }} <br />
=== Connecting to a Target Board ===<br />
The next step after establishing a physical connection to the board is logging in. More information on establishing a physical connection to a board is available on the [[Serrial_Connections |Serial Connections]] and [[Network_Connections |Network Connections]] page. <br />
<br />
EMAC OE Linux allows login from getty, and SSH (Secure Shell). A getty uses the serial connection or console while SSH utilizes a network connection. For more information visit the [[System_Log_In | System Log In]] page.<br />
{{warning|This is too abrupt. It feels like a paragraph or more is missing. You're assuming the reader already knows how to establish a physical connection. You need to either document how to do so here, or provide a link for information on how to do this. Remember, pages which are found via google need to stand on their own, since it may be the only page on our site that a potential customer will ever see. If they like it, they may come back and become a customer. If it leaves them hanging, they probably won't. It may be annoying to have to cater to that idea with every document we write, but it really is very important.}}<br />
<br />
=== Setting up the Filesystem Read-Write ===<br />
The filesystems on the remote machines are mounted read-only by default. In order to put your program on the board, you need to make the filesystem read-write. <br />
<br />
To set up the root filesytem read-write, enter the following into the terminal: <br />
{{cli | oemntrw | hostname=ipac9x25}}<br />
<br />
{{warning|Why would they want to do this? Because our filesystems are mounted read-only by default, which means they're not going to be able to put their program on the board unless they make it read-write first? There's a good chance they don't know that. Let them know. ;)}}<br />
=== Transferring Files ===<br />
The command line syntax for transferring a file using the SSH protocol is <code>scp file user@host:/directory</code>. SCP or Secure Copy is a way of securely transferring files between a local and remote host. For example, to send the file ''example.text'' to the <code>/home</code> directory of a system with the IP address 10.0.6.221, enter the following command:<br />
{{cli | username=developer | hostname=ldc | scp example.text root@10.0.6.221:/home }}<br />
<br /><br />
Alternatively, you can leave off the path after the colon if you want the file to go directly into the home directory.<br />
{{cli | username=developer | hostname=ldc | scp example.text root@10.0.6.221: }}<br />
<br /><br />
Be aware that this copy operation will fail if the filesystem on the remote machine is mounted read-only, which is the default on most EMAC systems.<br />
<br />
{{warning|(I'm only using the warning box so it stands out, and so you can remove it easily). It would be nice to let the reader know that they can leave off the path after the : if they want the file to go directly into their home directory. I like that trick a lot because it saves me a lot of typing. They'll probably like it too.<br />
<br />
Also, be careful where you put comments/notes. I moved the line above this box from below, because it was attached to the remote execution command before.}}<br />
=== Remote Execution ===<br />
SSH can also be used to execute programs on remote systems without logging in. The syntax for SSH remote execution is <code>ssh user@host "my_command -args file"</code>. For example, to run the program ''hello'' with the ''-hi'' flags on a system with the IP address of 10.0.6.221, enter the following command:<br />
{{cli | username=developer | hostname=ldc | ssh root@10.0.6.221 "/path/to/executable -args" }} <br />
<br />
=== Basic Compiling ===<br />
==== CMake Compiling ====<br />
===== Host Machine Compiling =====<br />
{{note|In these examples we are using the Ipac-9x25 board. Your board's processor's architecture will determine which file needs to be sourced. These files come from the EMAC SDK toolchain.}}<br />
{{warning|This is the manual way to do it, and only works well for ultra simple programs which only have one source file. Our customers are professional programmers, which means they will almost never have only one source file. We put a lot of work into CMake to make the cross compiling process much easier, and Klint created a tool to generate the CMake files automatically for a project. This is an important selling point for EMAC (everyone hates doing this by hand the manual way), so this is the method that should be documented first. Here's the script in our version control system: http://gitlab.emacinc.com/oe/cmake-new-project We will have a deb package in apt for this when we get a chance to make it, or we may incorporate it into one of our existing packages (like the tools package). You can leave a stub for how to install it before describing it.}}<br />
<br />
This section demonstrates how to use the EMAC CMake tool to generate CMake files automatically for a project. When using the EMAC SDK there are currently two options for cross compiling:<br />
* arm<br />
* x86<br />
For the purposes of this guide, the arm option will be used for the listed examples.<br />
<br />
Navigate to the directory where the project will be located. Then run the CMake new project script.<br />
{{clo|indent=2}}<br />
{{clio | username=developer | hostname=ldc | pwd=~/projects | oe_init_project -n hello.c }}<br />
If desired, please enter a name for this project, otherwise press Enter to use the default: hello_emac <br /><br />
<br />
-- Creating new project directory... <br /><br />
-- Creating new source file... <br /><br />
-- Building custom CMakeLists.txt file... <br /><br />
-- Done. <br /><br />
<br />
Do you want to create a build directory for this project? (y/n) y <br /><br />
<br />
-- Creating build directory... <br /><br />
<br />
Do you want to run cmake for this project? (y/n) y <br /><br />
<br />
-- Using system compiler <br /><br />
-- The C compiler identification is GNU 4.8.2 <br /><br />
-- The CXX compiler identification is GNU 4.8.2 <br /><br />
-- Check for working C compiler: /usr/bin/cc <br /><br />
-- Check for working C compiler: /usr/bin/cc -- works <br /><br />
-- Detecting C compiler ABI info <br /><br />
-- Detecting C compiler ABI info - done <br /><br />
-- Check for working CXX compiler: /usr/bin/c++ <br /><br />
-- Check for working CXX compiler: /usr/bin/c++ -- works <br /><br />
-- Detecting CXX compiler ABI info <br /><br />
-- Detecting CXX compiler ABI info - done <br /><br />
-- Configuring done <br /><br />
-- Generating done <br /><br />
-- Build files have been written to: /home/developer/projects/hello_emac/hello_emac-build <br /><br />
<br />
Do you want to compile this project? (y/n) y<br />
<br />
Scanning dependencies of target hello_emac <br /><br />
[100%] Building C object CMakeFiles/hello_emac.dir/hello.c.o <br /><br />
Linking C executable hello_emac <br /><br />
[100%] Built target hello_emac <br /><br />
{{clos}}<br />
The executable in this case, is now inside the <code> hello_emac/hello_emac-build </code> directory.<br />
===== Target Machine Compiling =====<br />
Use the following steps to cross-compile the project and send it to a target board. In a terminal, navigate to the base directory of the project (where this document is located).<br />
<br />
Create a build directory for cross compiling. <br />
{{clio | username=developer | hostname=ldc | pwd=~/projects/hello_emac | mkdir hello_emac-build-arm }} <br />
<br />
Change directories into the newly created directory.<br />
{{clio | username=developer | hostname=ldc | pwd=~/projects/hello_emac | cd hello_emac-build-arm }} <br />
<br />
Run cmake using the target architecture.<br />
{{clio | username=developer | hostname=ldc | pwd=~/projects/hello_emac/hello_emac-build-arm | 1 = cmake .. -DARCH:STRING=arm }} <br />
<br />
Compile the code using make.<br />
{{clio | username=developer | hostname=ldc | pwd=~/projects/hello_emac/hello_emac-build-arm | make }} <br />
<br />
After running the <code> make </code> command, the target executable is now in the <code> hello_emac-build-arm </code> directory. Then copy the executable to the target board. For information on copying the executable file, see the [[ #Transferring_Files | Transferring Files ]] section.<br />
<br />
For other ways to generate the CMake files, visit the [[CMake | CMake ]] page.<br />
<br />
==== Manual Compiling ====<br />
===== Host Machine Compiling =====<br />
Create a file called hello.c using a text editor such as vi, vim, nano, or gedit.<br />
<br />
Use the following syntax to compile the program called hello.c:<br />
{{cli | username=developer | hostname=ldc | gcc -o hello hello.c }}<br />
<br />
If there is no error in your code then the compiler will successfully create an executable file called hello in the current directory. <br />
<br />
To verify this, enter the following command:<br />
{{clo|indent=2}}<br />
{{clio | username=developer | hostname=ldc | ls -l hello* }}<br />
-rwxrwxr-x 1 bserrano bserrano 9583 Apr 6 12:45 hello <br /><br />
-rwxr-xr-x 1 bserrano bserrano 129 Apr 6 12:28 hello.c <br />
{{clos}}<br />
<br />
To run the program, enter the following command:<br />
{{clo|indent=2}}<br />
{{clio | username=developer | hostname=ldc | ./hello }}<br />
Hello EMAC OE!<br />
{{clos}}<br />
<br />
OR<br />
{{clo|indent=2}}<br />
{{clio | username=developer | hostname=ldc | /path/to/hello }}<br />
Hello EMAC OE!<br />
{{clos}}<br />
<br />
<br />
===== Target Board Compiling =====<br />
<br />
To compile on the target board, you must <code>source</code> the <code>environment-setup-armv5te-emac-linux-gnueabi</code> file.<br />
{{cli | username=developer | hostname=ldc | source /opt/emac/5.0/environment-setup-armv5te-emac-linux-gnueabi }}<br />
<br />
Once you are in the directory with the source file, enter the following command:<br />
{{cli | username=developer | hostname=ldc | $CC -o hello hello.c }}<br />
<br />
{{note|Once you source the file in your current terminal, you can only use it to cross-compile your program for the target board. You can no longer compile it for your host machine. To compile it to your host machine, simply open a new terminal.}}<br />
<br />
After sourcing the file, copy the program over to the target board using <code>scp</code>. Enter the following command:<br />
{{clo|indent=2}}<br />
{{clio | username=developer | hostname=ldc | scp hello root@10.0.6.221: }}<br />
root@10.0.6.221's password: <br />
hello 100% 9583 9.4KB/s 00:00 <br />
{{clos}}<br />
<br />
After copying the program, you can now execute the program on the target board. Enter the following command:<br />
{{clo|indent=2}}<br />
{{clio | username=developer | hostname=ldc | ssh root@10.0.6.221 ./hello}}<br />
root@10.0.6.221's password: <br /> <br />
Hello EMAC OE!<br />
{{clos}}<br />
<br />
=== Linux Filesystem Organization ===<br />
In order to prevent confusion and promote portability, a standard was created for the organization of the Linux filesystem. To ensure future portability of software created today, promote maintainability of software, and ensure proper utilization of available storage on an embedded machine, this standard should be followed as much as possible. This document covers parts of the standard and gives information about the customizations made to it by EMAC OE to accommodate embedded hardware. A link is provided to the standards document which covers the organization of the Linux filesystem at the end of this document. For more information visit the [[Linux_Filesystem_Organization | Linux Filesystem Organization]] page.<br />
<br />
EMAC recommends ''/usr/local/bin'' as the location for software you deploy.<br />
<br />
/usr/local/bin<br />
<br />
{{note|It is important to pay attention to the filesystem structure in order to ensure that your application will work as expected when the filesystem is in production. Reasons for this include:<br />
<cl><br />
1. Only certain directories, such as ''/var/'' and ''/tmp/'', are writeable when the filesystem is read-only.<br />
* Only certain directories should contain executables, such as ''/bin/'', ''/usr/bin/'', and ''/usr/local/bin/''.<br />
* Following this directory structure properly will make it easier to port your software to a newer release of EMAC OE later on.<br />
</cl>}}<br />
<br />
=== Remote Debugging ===<br />
Sometimes a program has no technical errors that cause the compile to fail, but fails to meet the developer's expectations when run. This is typically due to algorithm or data structure design errors which can be difficult to find with just visual inspection of the code. Because of this, it can be beneficial to run a debugger targeting the executable process. Debugging is the process of watching what is going on inside of another program while it is running. When a program is compiled with debug symbols included in the binary, it is possible to observe the source code and corresponding assembly code while running the debugger.<br />
<br />
When working with embedded systems the binary is usually compiled on a development machine with a different CPU architecture than what is on the target machine. This can be a problem when, as is typically the case, the target machine lacks the system resources to run a debugger. In these cases, it is possible to use the GNU debugger, or GDB, on the development machine to remotely debug the target machine provided it has a program called gdbserver. All EMAC OE builds are packaged with gdbserver to simplify the setup process for developers.<br />
<br />
For more information visit the [[Remote_Debugging_EMAC_OE_SDK_with_gdbserver | Remote Debugging EMAC OE SDK Projects with gdbserver]] page.<br />
<br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /***************************************** Examples *****************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
{{:Templateimpl:examples | initials=BS | title=Getting Started with the EMAC OE SDK | desc=Basic tutorial for using the EMAC OE SDK. | project=OE 5.0 }}<br />
=== Hello World System Log Example ===<br />
This example will print <code>Hello EMAC OE!</code> to the syslog facility as well as the console. This will allow you to log, debug, and send status messages to the system logger.<br />
<br />
To compile and run this program, see the sections above.<br />
<br />
{{warning|I removed the GPL copyright because this code should be unlicensed and free for the customers to use any way they want. Virtually no customer is going to want to release their source code to the public, so pushing the GPL on them can give the wrong impression.}}<br />
<syntaxhighlight lang="c"><br />
#include <stdio.h><br />
#include <stdlib.h><br />
#include <unistd.h><br />
#include <syslog.h><br />
<br />
int main(int argc, char** argv)<br />
{ <br />
char message[] = "Hello EMAC OE!";<br />
<br />
openlog("slog", LOG_PID|LOG_CONS, LOG_USER);<br />
syslog(LOG_INFO, "%s", message);<br />
closelog(); <br />
<br />
printf("%s\n", message);<br />
<br />
return 0;<br />
}<br />
</syntaxhighlight><br />
<br />
This is extremely useful because it allows you to save a record of the output that you might not see first hand.<br />
<br />
To verify the program went into the syslog, enter the following command:<br />
{{clo|indent=2}}<br />
{{clio | username=developer | hostname=ldc | tail /var/log/syslog}}<br />
Apr 7 14:10:06 ENG-26-LX dhclient: DHCPACK of 10.0.6.237 from 10.0.2.1<br /><br />
Apr 7 14:10:06 ENG-26-LX dhclient: bound to 10.0.6.237 -- renewal in 3306 seconds.<br /><br />
Apr 7 14:17:01 ENG-26-LX CRON[21193]: (root) CMD ( cd / && run-parts --report /etc/cron.hourly)<br /><br />
Apr 7 14:54:41 ENG-26-LX hpcups[21266]: prnt/hpcups/HPCupsFilter.cpp 689: First raster data plane..<br /><br />
Apr 7 14:55:31 hpcups[21266]: last message repeated 3 times<br /><br />
Apr 7 15:05:12 ENG-26-LX dhclient: DHCPREQUEST of 10.0.6.237 on eth0 to 10.0.2.1 port 67<br /><br />
Apr 7 15:05:12 ENG-26-LX dhclient: DHCPACK of 10.0.6.237 from 10.0.2.1<br /><br />
Apr 7 15:05:12 ENG-26-LX dhclient: bound to 10.0.6.237 -- renewal in 3559 seconds.<br /><br />
Apr 7 15:17:01 ENG-26-LX CRON[21302]: (root) CMD ( cd / && run-parts --report /etc/cron.hourly)<br /><br />
Apr 7 15:27:08 ENG-26-LX slog[21375]: Hello EMAC OE!<br />
{{clos}}<br />
<br />
As you can see on the bottom line, your program output has been recorded and date stamped in the syslog.<br />
<br />
For more information on system logging visit the [[System_Logging| System Logging ]] page.<br />
{{warning|I think we have a page which talks more about the system logging facility. If not, we do at least have it on our TODO list of pages to write. See if you can find that page, and link to it here. If we don't have it yet, please create a stub page for it and link to it here (using the template, of course).}}<br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /****************************************** More Information *****************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
{{:Templateimpl:moreinfo | initials=BS | title=Getting Started with the EMAC OE SDK | desc=Basic tutorial for using the EMAC OE SDK. | project=OE 5.0 }}<br />
* [[Getting_Started_With_Qt_Creator |Getting Started With Qt Creator]]<br />
<br />
{{:Templateimpl:whatnext | initials=BS | title=Getting Started with the EMAC OE SDK | desc=Basic tutorial for using the EMAC OE SDK. | project=OE 5.0 }}<br />
* [[System_Log_In | System Log In]]<br />
* [[Serial_Connections | Serial Connections ]]<br />
* [[Network_Connections | Network_Connections ]]<br />
* [[System_Log_In | System Log In ]]<br />
* [[Remote_Debugging_EMAC_OE_SDK_Projects_with_gdbserver | Remote Debugging EMAC OE SDK Projects with gdbserver ]]<br />
* [[Linux_Filesystem_Organization | Linux Filesystem Organization]]<br />
* [[CMake | CMake ]]<br />
* [[Remote_Debugging_EMAC_OE_SDK_with_gdbserver | Remote Debugging EMAC OE SDK Projects with gdbserver]]<br />
* [[System_Logging | System Logging ]]</div>Bserranohttps://wiki.emacinc.com/index.php?title=Getting_Started_with_the_EMAC_OE_SDK&diff=4279Getting Started with the EMAC OE SDK2015-04-21T15:20:55Z<p>Bserrano: </p>
<hr />
<div>{{todo| Review (03.31.2015-13:42->BS+);(04.08.2015-15:00->BS+);(04.09.15-14:00->MD+);(04.21.2015-10:15->BS+) |Brian Serrano| project=OE 5.0,BS,MD}}<br />
{{#seo:<br />
|title=Getting Started with the EMAC OE SDK<br />
|titlemode=append<br />
|keywords=EMAC SDK,Hello World Example,Target Compiling, Host Compiling<br />
|description=A basic tutorial for using the EMAC OE SDK.<br />
}}<br />
{{warning|Now is a good time to come up with keywords for the SEO tag.}}<br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /**************************************** Page Description Text ****************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
<span style="background:#00FF00;color:#FF0000;font-size:300%"></span><br />
<br />
The EMAC OE SDK is distributed with a set of example projects intended to demonstrate how to use the EMAC OE toolchain and libraries. This page demonstrates the process of compiling an example project and running it on the target machine. Also, it provides a straightforward guide to the essential steps you need to follow to get started with cross compiling a simple program with gcc and running the program on your embedded machine.<br />
{{warning|The following sentence isn't very compelling. I'd probably click back and look for a different page after reading that sentence. Maybe something like, "This page provides a straightforward guide to the essential steps you need to follow to get started with cross compiling a simple program with gcc and running the program on your embedded machine." }}<br />
__TOC__<br />
<br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /***************************************** General Information *****************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
{{:Templateimpl:geninfo | initials=BS | title=Getting Started with the EMAC OE SDK | desc=Basic tutorial for using the EMAC OE SDK. | project=OE 5.0 }}<br />
{{warning|We primarily distribute the SDK with our apt repository as a deb file for Ubuntu. We also provide a tarball they can extract, but we recommend the deb because that's the only version we officially support. I would reword this sentence to reflect that.}}<br />
The EMAC Open Embedded SDK is primarily distributed with our apt repository as a deb file for Ubuntu. EMAC also provides a tarbell you can extract, but recommends the deb file because it's the only version EMAC officially supports.<br />
<br />
Each SDK includes the C/C++ header files and libraries compatible with the target hardware. It also includes the C/C++ cross-compiler toolchain components necessary to compile and debug custom application code. The links below will help you get started building and running the example projects on the target hardware.<br />
<br />
More information on using Qt Creator with the EMAC SDK is available on the [[Getting_Started_With_Qt_Creator |Getting Started With Qt Creator]] page.<br />
{{warning|Using commanding language ("Follow the links to do this") sounds a bit unfriendly when talking to customers (as opposeMike dean d to internal documentation). We've tried to steer away from that in our documentation as much as possible. Instead, we try to phrase sentences in a friendly, informative way. I reworded two sentences above to show what I mean.}}<br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /***************************************** Using/Working With ******************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
{{:Templateimpl:using | initials=BS | title=Getting Started with the EMAC OE SDK | desc=Basic tutorial for using the EMAC OE SDK. | project=OE 5.0 }} <br />
=== Connecting to a Target Board ===<br />
The next step after establishing a physical connection to the board is logging in. More information on establishing a physical connection to a board is available on the [[Serrial_Connections |Serial Connections]] and [[Network_Connections |Network Connections]] page. <br />
<br />
EMAC OE Linux allows login from getty, and SSH (Secure Shell). A getty uses the serial connection or console while SSH utilizes a network connection. For more information visit the [[System_Log_In | System Log In]] page.<br />
{{warning|This is too abrupt. It feels like a paragraph or more is missing. You're assuming the reader already knows how to establish a physical connection. You need to either document how to do so here, or provide a link for information on how to do this. Remember, pages which are found via google need to stand on their own, since it may be the only page on our site that a potential customer will ever see. If they like it, they may come back and become a customer. If it leaves them hanging, they probably won't. It may be annoying to have to cater to that idea with every document we write, but it really is very important.}}<br />
<br />
=== Setting up the Filesystem Read-Write ===<br />
The filesystems on the remote machines are mounted read-only by default. In order to put your program on the board, you need to make the filesystem read-write. <br />
<br />
To set up the root filesytem read-write, enter the following into the terminal: <br />
{{cli | oemntrw | hostname=ipac9x25}}<br />
<br />
{{warning|Why would they want to do this? Because our filesystems are mounted read-only by default, which means they're not going to be able to put their program on the board unless they make it read-write first? There's a good chance they don't know that. Let them know. ;)}}<br />
=== Transferring Files ===<br />
The command line syntax for transferring a file using the SSH protocol is <code>scp file user@host:/directory</code>. SCP or Secure Copy is a way of securely transferring files between a local and remote host. For example, to send the file ''example.text'' to the <code>/home</code> directory of a system with the IP address 10.0.6.221, enter the following command:<br />
{{cli | username=developer | hostname=ldc | scp example.text root@10.0.6.221:/home }}<br />
<br /><br />
Alternatively, you can leave off the path after the colon if you want the file to go directly into the home directory.<br />
{{cli | username=developer | hostname=ldc | scp example.text root@10.0.6.221: }}<br />
<br /><br />
Be aware that this copy operation will fail if the filesystem on the remote machine is mounted read-only, which is the default on most EMAC systems.<br />
<br />
{{warning|(I'm only using the warning box so it stands out, and so you can remove it easily). It would be nice to let the reader know that they can leave off the path after the : if they want the file to go directly into their home directory. I like that trick a lot because it saves me a lot of typing. They'll probably like it too.<br />
<br />
Also, be careful where you put comments/notes. I moved the line above this box from below, because it was attached to the remote execution command before.}}<br />
=== Remote Execution ===<br />
SSH can also be used to execute programs on remote systems without logging in. The syntax for SSH remote execution is <code>ssh user@host "my_command -args file"</code>. For example, to run the program ''hello'' with the ''-hi'' flags on a system with the IP address of 10.0.6.221, enter the following command:<br />
{{cli | username=developer | hostname=ldc | ssh root@10.0.6.221 "/path/to/executable -args" }} <br />
<br />
=== Basic Compiling ===<br />
==== CMake Compiling ====<br />
===== Host Machine Compiling =====<br />
{{note|In these examples we are using the Ipac-9x25 board. Your board's processor's architecture will determine which file needs to be sourced. These files come from the EMAC SDK toolchain.}}<br />
{{warning|This is the manual way to do it, and only works well for ultra simple programs which only have one source file. Our customers are professional programmers, which means they will almost never have only one source file. We put a lot of work into CMake to make the cross compiling process much easier, and Klint created a tool to generate the CMake files automatically for a project. This is an important selling point for EMAC (everyone hates doing this by hand the manual way), so this is the method that should be documented first. Here's the script in our version control system: http://gitlab.emacinc.com/oe/cmake-new-project We will have a deb package in apt for this when we get a chance to make it, or we may incorporate it into one of our existing packages (like the tools package). You can leave a stub for how to install it before describing it.}}<br />
<br />
This section demonstrates how to use the EMAC CMake tool to generate CMake files automatically for a project. When using the EMAC SDK there are currently two options for cross compiling:<br />
* arm<br />
* x86<br />
For the purposes of this guide, the arm option will be used for the listed examples.<br />
<br />
Navigate to the directory where the project will be located. Then run the CMake new project script.<br />
{{clo|indent=2}}<br />
{{clio | username=developer | hostname=ldc | pwd=~/projects | oe_intit_project -n hello.c }}<br />
If desired, please enter a name for this project, otherwise press Enter to use the default: hello_emac <br /><br />
<br />
-- Creating new project directory... <br /><br />
-- Creating new source file... <br /><br />
-- Building custom CMakeLists.txt file... <br /><br />
-- Done. <br /><br />
<br />
Do you want to create a build directory for this project? (y/n) y <br /><br />
<br />
-- Creating build directory... <br /><br />
<br />
Do you want to run cmake for this project? (y/n) y <br /><br />
<br />
-- Using system compiler <br /><br />
-- The C compiler identification is GNU 4.8.2 <br /><br />
-- The CXX compiler identification is GNU 4.8.2 <br /><br />
-- Check for working C compiler: /usr/bin/cc <br /><br />
-- Check for working C compiler: /usr/bin/cc -- works <br /><br />
-- Detecting C compiler ABI info <br /><br />
-- Detecting C compiler ABI info - done <br /><br />
-- Check for working CXX compiler: /usr/bin/c++ <br /><br />
-- Check for working CXX compiler: /usr/bin/c++ -- works <br /><br />
-- Detecting CXX compiler ABI info <br /><br />
-- Detecting CXX compiler ABI info - done <br /><br />
-- Configuring done <br /><br />
-- Generating done <br /><br />
-- Build files have been written to: /home/developer/projects/hello_emac/hello_emac-build <br /><br />
<br />
Do you want to compile this project? (y/n) y<br />
<br />
Scanning dependencies of target hello_emac <br /><br />
[100%] Building C object CMakeFiles/hello_emac.dir/hello.c.o <br /><br />
Linking C executable hello_emac <br /><br />
[100%] Built target hello_emac <br /><br />
{{clos}}<br />
The executable in this case, is now inside the <code> hello_emac/hello_emac-build </code> directory.<br />
===== Target Machine Compiling =====<br />
Use the following steps to cross-compile the project and send it to a target board. In a terminal, navigate to the base directory of the project (where this document is located).<br />
<br />
Create a build directory for cross compiling. <br />
{{clio | username=developer | hostname=ldc | pwd=~/projects/hello_emac | mkdir hello_emac-build-arm }} <br />
<br />
Change directories into the newly created directory.<br />
{{clio | username=developer | hostname=ldc | pwd=~/projects/hello_emac | cd hello_emac-build-arm }} <br />
<br />
Run cmake using the target architecture.<br />
{{clio | username=developer | hostname=ldc | pwd=~/projects/hello_emac/hello_emac-build-arm | cmake .. -DARCH:STRING=arm }} <br />
Brian's Comment: cmake .. -DARCH:STRING=arm (MD this command prints out 1 on the wiki page because of the equal sign instead of the actual command. Is there a way to fix this?<br />
<br />
Compile the code using make.<br />
{{clio | username=developer | hostname=ldc | pwd=~/projects/hello_emac/hello_emac-build-arm | make }} <br />
<br />
After running the <code> make </code> command, the target executable is now in the <code> hello_emac-build-arm </code> directory. Then copy the executable to the target board. For information on copying the executable file, see the [[ #Transferring_Files | Transferring Files ]] section.<br />
<br />
For other ways to generate the CMake files, visit the [[CMake | CMake ]] page.<br />
<br />
==== Manual Compiling ====<br />
===== Host Machine Compiling =====<br />
Create a file called hello.c using a text editor such as vi, vim, nano, or gedit.<br />
<br />
Use the following syntax to compile the program called hello.c:<br />
{{cli | username=developer | hostname=ldc | gcc -o hello hello.c }}<br />
<br />
If there is no error in your code then the compiler will successfully create an executable file called hello in the current directory. <br />
<br />
To verify this, enter the following command:<br />
{{clo|indent=2}}<br />
{{clio | username=developer | hostname=ldc | ls -l hello* }}<br />
-rwxrwxr-x 1 bserrano bserrano 9583 Apr 6 12:45 hello <br /><br />
-rwxr-xr-x 1 bserrano bserrano 129 Apr 6 12:28 hello.c <br />
{{clos}}<br />
<br />
To run the program, enter the following command:<br />
{{clo|indent=2}}<br />
{{clio | username=developer | hostname=ldc | ./hello }}<br />
Hello EMAC OE!<br />
{{clos}}<br />
<br />
OR<br />
{{clo|indent=2}}<br />
{{clio | username=developer | hostname=ldc | /path/to/hello }}<br />
Hello EMAC OE!<br />
{{clos}}<br />
<br />
<br />
===== Target Board Compiling =====<br />
<br />
To compile on the target board, you must <code>source</code> the <code>environment-setup-armv5te-emac-linux-gnueabi</code> file.<br />
{{cli | username=developer | hostname=ldc | source /opt/emac/5.0/environment-setup-armv5te-emac-linux-gnueabi }}<br />
<br />
Once you are in the directory with the source file, enter the following command:<br />
{{cli | username=developer | hostname=ldc | $CC -o hello hello.c }}<br />
<br />
{{note|Once you source the file in your current terminal, you can only use it to cross-compile your program for the target board. You can no longer compile it for your host machine. To compile it to your host machine, simply open a new terminal.}}<br />
<br />
After sourcing the file, copy the program over to the target board using <code>scp</code>. Enter the following command:<br />
{{clo|indent=2}}<br />
{{clio | username=developer | hostname=ldc | scp hello root@10.0.6.221: }}<br />
root@10.0.6.221's password: <br />
hello 100% 9583 9.4KB/s 00:00 <br />
{{clos}}<br />
<br />
After copying the program, you can now execute the program on the target board. Enter the following command:<br />
{{clo|indent=2}}<br />
{{clio | username=developer | hostname=ldc | ssh root@10.0.6.221 ./hello}}<br />
root@10.0.6.221's password: <br /> <br />
Hello EMAC OE!<br />
{{clos}}<br />
<br />
=== Linux Filesystem Organization ===<br />
In order to prevent confusion and promote portability, a standard was created for the organization of the Linux filesystem. To ensure future portability of software created today, promote maintainability of software, and ensure proper utilization of available storage on an embedded machine, this standard should be followed as much as possible. This document covers parts of the standard and gives information about the customizations made to it by EMAC OE to accommodate embedded hardware. A link is provided to the standards document which covers the organization of the Linux filesystem at the end of this document. For more information visit the [[Linux_Filesystem_Organization | Linux Filesystem Organization]] page.<br />
<br />
EMAC recommends ''/usr/local/bin'' as the location for software you deploy.<br />
<br />
/usr/local/bin<br />
<br />
{{note|It is important to pay attention to the filesystem structure in order to ensure that your application will work as expected when the filesystem is in production. Reasons for this include:<br />
<cl><br />
1. Only certain directories, such as ''/var/'' and ''/tmp/'', are writeable when the filesystem is read-only.<br />
* Only certain directories should contain executables, such as ''/bin/'', ''/usr/bin/'', and ''/usr/local/bin/''.<br />
* Following this directory structure properly will make it easier to port your software to a newer release of EMAC OE later on.<br />
</cl>}}<br />
<br />
=== Remote Debugging ===<br />
Sometimes a program has no technical errors that cause the compile to fail, but fails to meet the developer's expectations when run. This is typically due to algorithm or data structure design errors which can be difficult to find with just visual inspection of the code. Because of this, it can be beneficial to run a debugger targeting the executable process. Debugging is the process of watching what is going on inside of another program while it is running. When a program is compiled with debug symbols included in the binary, it is possible to observe the source code and corresponding assembly code while running the debugger.<br />
<br />
When working with embedded systems the binary is usually compiled on a development machine with a different CPU architecture than what is on the target machine. This can be a problem when, as is typically the case, the target machine lacks the system resources to run a debugger. In these cases, it is possible to use the GNU debugger, or GDB, on the development machine to remotely debug the target machine provided it has a program called gdbserver. All EMAC OE builds are packaged with gdbserver to simplify the setup process for developers.<br />
<br />
For more information visit the [[Remote_Debugging_EMAC_OE_SDK_with_gdbserver | Remote Debugging EMAC OE SDK Projects with gdbserver]] page.<br />
<br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /***************************************** Examples *****************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
{{:Templateimpl:examples | initials=BS | title=Getting Started with the EMAC OE SDK | desc=Basic tutorial for using the EMAC OE SDK. | project=OE 5.0 }}<br />
=== Hello World System Log Example ===<br />
This example will print <code>Hello EMAC OE!</code> to the syslog facility as well as the console. This will allow you to log, debug, and send status messages to the system logger.<br />
<br />
To compile and run this program, see the sections above.<br />
<br />
{{warning|I removed the GPL copyright because this code should be unlicensed and free for the customers to use any way they want. Virtually no customer is going to want to release their source code to the public, so pushing the GPL on them can give the wrong impression.}}<br />
<syntaxhighlight lang="c"><br />
#include <stdio.h><br />
#include <stdlib.h><br />
#include <unistd.h><br />
#include <syslog.h><br />
<br />
int main(int argc, char** argv)<br />
{ <br />
char message[] = "Hello EMAC OE!";<br />
<br />
openlog("slog", LOG_PID|LOG_CONS, LOG_USER);<br />
syslog(LOG_INFO, "%s", message);<br />
closelog(); <br />
<br />
printf("%s\n", message);<br />
<br />
return 0;<br />
}<br />
</syntaxhighlight><br />
<br />
This is extremely useful because it allows you to save a record of the output that you might not see first hand.<br />
<br />
To verify the program went into the syslog, enter the following command:<br />
{{clo|indent=2}}<br />
{{clio | username=developer | hostname=ldc | tail /var/log/syslog}}<br />
Apr 7 14:10:06 ENG-26-LX dhclient: DHCPACK of 10.0.6.237 from 10.0.2.1<br /><br />
Apr 7 14:10:06 ENG-26-LX dhclient: bound to 10.0.6.237 -- renewal in 3306 seconds.<br /><br />
Apr 7 14:17:01 ENG-26-LX CRON[21193]: (root) CMD ( cd / && run-parts --report /etc/cron.hourly)<br /><br />
Apr 7 14:54:41 ENG-26-LX hpcups[21266]: prnt/hpcups/HPCupsFilter.cpp 689: First raster data plane..<br /><br />
Apr 7 14:55:31 hpcups[21266]: last message repeated 3 times<br /><br />
Apr 7 15:05:12 ENG-26-LX dhclient: DHCPREQUEST of 10.0.6.237 on eth0 to 10.0.2.1 port 67<br /><br />
Apr 7 15:05:12 ENG-26-LX dhclient: DHCPACK of 10.0.6.237 from 10.0.2.1<br /><br />
Apr 7 15:05:12 ENG-26-LX dhclient: bound to 10.0.6.237 -- renewal in 3559 seconds.<br /><br />
Apr 7 15:17:01 ENG-26-LX CRON[21302]: (root) CMD ( cd / && run-parts --report /etc/cron.hourly)<br /><br />
Apr 7 15:27:08 ENG-26-LX slog[21375]: Hello EMAC OE!<br />
{{clos}}<br />
<br />
As you can see on the bottom line, your program output has been recorded and date stamped in the syslog.<br />
<br />
For more information on system logging visit the [[System_Logging| System Logging ]] page.<br />
{{warning|I think we have a page which talks more about the system logging facility. If not, we do at least have it on our TODO list of pages to write. See if you can find that page, and link to it here. If we don't have it yet, please create a stub page for it and link to it here (using the template, of course).}}<br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /****************************************** More Information *****************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
{{:Templateimpl:moreinfo | initials=BS | title=Getting Started with the EMAC OE SDK | desc=Basic tutorial for using the EMAC OE SDK. | project=OE 5.0 }}<br />
* [[Getting_Started_With_Qt_Creator |Getting Started With Qt Creator]]<br />
<br />
{{:Templateimpl:whatnext | initials=BS | title=Getting Started with the EMAC OE SDK | desc=Basic tutorial for using the EMAC OE SDK. | project=OE 5.0 }}<br />
* [[System_Log_In | System Log In]]<br />
* [[Serial_Connections | Serial Connections ]]<br />
* [[Network_Connections | Network_Connections ]]<br />
* [[System_Log_In | System Log In ]]<br />
* [[Remote_Debugging_EMAC_OE_SDK_Projects_with_gdbserver | Remote Debugging EMAC OE SDK Projects with gdbserver ]]<br />
* [[Linux_Filesystem_Organization | Linux Filesystem Organization]]<br />
* [[CMake | CMake ]]<br />
* [[Remote_Debugging_EMAC_OE_SDK_with_gdbserver | Remote Debugging EMAC OE SDK Projects with gdbserver]]<br />
* [[System_Logging | System Logging ]]</div>Bserranohttps://wiki.emacinc.com/index.php?title=Getting_Started_with_the_EMAC_OE_SDK&diff=4278Getting Started with the EMAC OE SDK2015-04-21T15:18:53Z<p>Bserrano: </p>
<hr />
<div>{{todo| Review (03.31.2015-13:42->BS+);(04.08.2015-15:00->BS+);(04.09.15-14:00->MD+);(04.21.2015-10:15->BS+) |Brian Serrano| project=OE 5.0,BS,MD}}<br />
{{#seo:<br />
|title=Getting Started with the EMAC OE SDK<br />
|titlemode=append<br />
|keywords=EMAC SDK,Hello World Example,Target Compiling, Host Compiling<br />
|description=A basic tutorial for using the EMAC OE SDK.<br />
}}<br />
{{warning|Now is a good time to come up with keywords for the SEO tag.}}<br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /**************************************** Page Description Text ****************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
<span style="background:#00FF00;color:#FF0000;font-size:300%"></span><br />
<br />
The EMAC OE SDK is distributed with a set of example projects intended to demonstrate how to use the EMAC OE toolchain and libraries. This page demonstrates the process of compiling an example project and running it on the target machine. Also, it provides a straightforward guide to the essential steps you need to follow to get started with cross compiling a simple program with gcc and running the program on your embedded machine.<br />
{{warning|The following sentence isn't very compelling. I'd probably click back and look for a different page after reading that sentence. Maybe something like, "This page provides a straightforward guide to the essential steps you need to follow to get started with cross compiling a simple program with gcc and running the program on your embedded machine." }}<br />
__TOC__<br />
<br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /***************************************** General Information *****************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
{{:Templateimpl:geninfo | initials=BS | title=Getting Started with the EMAC OE SDK | desc=Basic tutorial for using the EMAC OE SDK. | project=OE 5.0 }}<br />
{{warning|We primarily distribute the SDK with our apt repository as a deb file for Ubuntu. We also provide a tarball they can extract, but we recommend the deb because that's the only version we officially support. I would reword this sentence to reflect that.}}<br />
The EMAC Open Embedded SDK is primarily distributed with our apt repository as a deb file for Ubuntu. EMAC also provides a tarbell you can extract, but recommends the deb file because it's the only version EMAC officially supports.<br />
<br />
Each SDK includes the C/C++ header files and libraries compatible with the target hardware. It also includes the C/C++ cross-compiler toolchain components necessary to compile and debug custom application code. The links below will help you get started building and running the example projects on the target hardware.<br />
<br />
More information on using Qt Creator with the EMAC SDK is available on the [[Getting_Started_With_Qt_Creator |Getting Started With Qt Creator]] page.<br />
{{warning|Using commanding language ("Follow the links to do this") sounds a bit unfriendly when talking to customers (as opposeMike dean d to internal documentation). We've tried to steer away from that in our documentation as much as possible. Instead, we try to phrase sentences in a friendly, informative way. I reworded two sentences above to show what I mean.}}<br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /***************************************** Using/Working With ******************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
{{:Templateimpl:using | initials=BS | title=Getting Started with the EMAC OE SDK | desc=Basic tutorial for using the EMAC OE SDK. | project=OE 5.0 }} <br />
=== Connecting to a Target Board ===<br />
The next step after establishing a physical connection to the board is logging in. More information on establishing a physical connection to a board is available on the [[Serrial_Connections |Serial Connections]] and [[Network_Connections |Network Connections]] page. <br />
<br />
EMAC OE Linux allows login from getty, and SSH (Secure Shell). A getty uses the serial connection or console while SSH utilizes a network connection. For more information visit the [[System_Log_In | System Log In]] page.<br />
{{warning|This is too abrupt. It feels like a paragraph or more is missing. You're assuming the reader already knows how to establish a physical connection. You need to either document how to do so here, or provide a link for information on how to do this. Remember, pages which are found via google need to stand on their own, since it may be the only page on our site that a potential customer will ever see. If they like it, they may come back and become a customer. If it leaves them hanging, they probably won't. It may be annoying to have to cater to that idea with every document we write, but it really is very important.}}<br />
<br />
=== Setting up the Filesystem Read-Write ===<br />
The filesystems on the remote machines are mounted read-only by default. In order to put your program on the board, you need to make the filesystem read-write. <br />
<br />
To set up the root filesytem read-write, enter the following into the terminal: <br />
{{cli | oemntrw | hostname=ipac9x25}}<br />
<br />
{{warning|Why would they want to do this? Because our filesystems are mounted read-only by default, which means they're not going to be able to put their program on the board unless they make it read-write first? There's a good chance they don't know that. Let them know. ;)}}<br />
=== Transferring Files ===<br />
The command line syntax for transferring a file using the SSH protocol is <code>scp file user@host:/directory</code>. SCP or Secure Copy is a way of securely transferring files between a local and remote host. For example, to send the file ''example.text'' to the <code>/home</code> directory of a system with the IP address 10.0.6.221, enter the following command:<br />
{{cli | username=developer | hostname=ldc | scp example.text root@10.0.6.221:/home }}<br />
<br /><br />
Alternatively, you can leave off the path after the colon if you want the file to go directly into the home directory.<br />
{{cli | username=developer | hostname=ldc | scp example.text root@10.0.6.221: }}<br />
<br /><br />
Be aware that this copy operation will fail if the filesystem on the remote machine is mounted read-only, which is the default on most EMAC systems.<br />
<br />
{{warning|(I'm only using the warning box so it stands out, and so you can remove it easily). It would be nice to let the reader know that they can leave off the path after the : if they want the file to go directly into their home directory. I like that trick a lot because it saves me a lot of typing. They'll probably like it too.<br />
<br />
Also, be careful where you put comments/notes. I moved the line above this box from below, because it was attached to the remote execution command before.}}<br />
=== Remote Execution ===<br />
SSH can also be used to execute programs on remote systems without logging in. The syntax for SSH remote execution is <code>ssh user@host "my_command -args file"</code>. For example, to run the program ''hello'' with the ''-hi'' flags on a system with the IP address of 10.0.6.221, enter the following command:<br />
{{cli | username=developer | hostname=ldc | ssh root@10.0.6.221 "/path/to/executable -args" }} <br />
<br />
<br />
=== Basic Compiling ===<br />
==== CMake Compiling ====<br />
===== Host Machine Compiling =====<br />
{{note|In these examples we are using the Ipac-9x25 board. Your board's processor's architecture will determine which file needs to be sourced. These files come from the EMAC SDK toolchain.}}<br />
{{warning|This is the manual way to do it, and only works well for ultra simple programs which only have one source file. Our customers are professional programmers, which means they will almost never have only one source file. We put a lot of work into CMake to make the cross compiling process much easier, and Klint created a tool to generate the CMake files automatically for a project. This is an important selling point for EMAC (everyone hates doing this by hand the manual way), so this is the method that should be documented first. Here's the script in our version control system: http://gitlab.emacinc.com/oe/cmake-new-project We will have a deb package in apt for this when we get a chance to make it, or we may incorporate it into one of our existing packages (like the tools package). You can leave a stub for how to install it before describing it.}}<br />
<br />
This section demonstrates how to use the EMAC CMake tool to generate CMake files automatically for a project. When using the EMAC SDK there are currently two options for cross compiling:<br />
* arm<br />
* x86<br />
For the purposes of this guide, the arm option will be used for the listed examples.<br />
<br />
Navigate to the directory where the project will be located. Then run the CMake new project script.<br />
{{clo|indent=2}}<br />
{{clio | username=developer | hostname=ldc | pwd=~/projects | oe_intit_project -n hello.c }}<br />
If desired, please enter a name for this project, otherwise press Enter to use the default: hello_emac <br /><br />
<br />
-- Creating new project directory... <br /><br />
-- Creating new source file... <br /><br />
-- Building custom CMakeLists.txt file... <br /><br />
-- Done. <br /><br />
<br />
Do you want to create a build directory for this project? (y/n) y <br /><br />
<br />
-- Creating build directory... <br /><br />
<br />
Do you want to run cmake for this project? (y/n) y <br /><br />
<br />
-- Using system compiler <br /><br />
-- The C compiler identification is GNU 4.8.2 <br /><br />
-- The CXX compiler identification is GNU 4.8.2 <br /><br />
-- Check for working C compiler: /usr/bin/cc <br /><br />
-- Check for working C compiler: /usr/bin/cc -- works <br /><br />
-- Detecting C compiler ABI info <br /><br />
-- Detecting C compiler ABI info - done <br /><br />
-- Check for working CXX compiler: /usr/bin/c++ <br /><br />
-- Check for working CXX compiler: /usr/bin/c++ -- works <br /><br />
-- Detecting CXX compiler ABI info <br /><br />
-- Detecting CXX compiler ABI info - done <br /><br />
-- Configuring done <br /><br />
-- Generating done <br /><br />
-- Build files have been written to: /home/developer/projects/hello_emac/hello_emac-build <br /><br />
<br />
Do you want to compile this project? (y/n) y<br />
<br />
Scanning dependencies of target hello_emac <br /><br />
[100%] Building C object CMakeFiles/hello_emac.dir/hello.c.o <br /><br />
Linking C executable hello_emac <br /><br />
[100%] Built target hello_emac <br /><br />
{{clos}}<br />
The executable in this case, is now inside the <code> hello_emac/hello_emac-build </code> directory.<br />
===== Target Machine Compiling =====<br />
Use the following steps to cross-compile the project and send it to a target board. In a terminal, navigate to the base directory of the project (where this document is located).<br />
<br />
Create a build directory for cross compiling. <br />
{{clio | username=developer | hostname=ldc | pwd=~/projects/hello_emac | mkdir hello_emac-build-arm }} <br />
<br />
Change directories into the newly created directory.<br />
{{clio | username=developer | hostname=ldc | pwd=~/projects/hello_emac | cd hello_emac-build-arm }} <br />
<br />
Run cmake using the target architecture.<br />
{{clio | username=developer | hostname=ldc | pwd=~/projects/hello_emac/hello_emac-build-arm | cmake .. -DARCH:STRING=arm }} <br />
{{warning| Brian's Comment: cmake .. -DARCH:STRING=arm (MD this command prints out 1 on the wiki page because of the equal sign instead of the actual command. Is there a way to fix this?)}}<br />
<br />
<br />
Compile the code using make.<br />
{{clio | username=developer | hostname=ldc | pwd=~/projects/hello_emac/hello_emac-build-arm | make }} <br />
<br />
After running the <code> make </code> command, the target executable is now in the <code> hello_emac-build-arm </code> directory. Then copy the executable to the target board. For information on copying the executable file, see the [[ #Transferring_Files | Transferring Files ]] section.<br />
<br />
For other ways to generate the CMake files, visit the [[CMake | CMake ]] page.<br />
<br />
==== Manual Compiling ====<br />
===== Host Machine Compiling =====<br />
Create a file called hello.c using a text editor such as vi, vim, nano, or gedit.<br />
<br />
Use the following syntax to compile the program called hello.c:<br />
{{cli | username=developer | hostname=ldc | gcc -o hello hello.c }}<br />
<br />
If there is no error in your code then the compiler will successfully create an executable file called hello in the current directory. <br />
<br />
To verify this, enter the following command:<br />
{{clo|indent=2}}<br />
{{clio | username=developer | hostname=ldc | ls -l hello* }}<br />
-rwxrwxr-x 1 bserrano bserrano 9583 Apr 6 12:45 hello <br /><br />
-rwxr-xr-x 1 bserrano bserrano 129 Apr 6 12:28 hello.c <br />
{{clos}}<br />
<br />
To run the program, enter the following command:<br />
{{clo|indent=2}}<br />
{{clio | username=developer | hostname=ldc | ./hello }}<br />
Hello EMAC OE!<br />
{{clos}}<br />
<br />
OR<br />
{{clo|indent=2}}<br />
{{clio | username=developer | hostname=ldc | /path/to/hello }}<br />
Hello EMAC OE!<br />
{{clos}}<br />
<br />
<br />
===== Target Board Compiling =====<br />
<br />
To compile on the target board, you must <code>source</code> the <code>environment-setup-armv5te-emac-linux-gnueabi</code> file.<br />
{{cli | username=developer | hostname=ldc | source /opt/emac/5.0/environment-setup-armv5te-emac-linux-gnueabi }}<br />
<br />
Once you are in the directory with the source file, enter the following command:<br />
{{cli | username=developer | hostname=ldc | $CC -o hello hello.c }}<br />
<br />
{{note|Once you source the file in your current terminal, you can only use it to cross-compile your program for the target board. You can no longer compile it for your host machine. To compile it to your host machine, simply open a new terminal.}}<br />
<br />
After sourcing the file, copy the program over to the target board using <code>scp</code>. Enter the following command:<br />
{{clo|indent=2}}<br />
{{clio | username=developer | hostname=ldc | scp hello root@10.0.6.221: }}<br />
root@10.0.6.221's password: <br />
hello 100% 9583 9.4KB/s 00:00 <br />
{{clos}}<br />
<br />
After copying the program, you can now execute the program on the target board. Enter the following command:<br />
{{clo|indent=2}}<br />
{{clio | username=developer | hostname=ldc | ssh root@10.0.6.221 ./hello}}<br />
root@10.0.6.221's password: <br /> <br />
Hello EMAC OE!<br />
{{clos}}<br />
<br />
=== Linux Filesystem Organization ===<br />
In order to prevent confusion and promote portability, a standard was created for the organization of the Linux filesystem. To ensure future portability of software created today, promote maintainability of software, and ensure proper utilization of available storage on an embedded machine, this standard should be followed as much as possible. This document covers parts of the standard and gives information about the customizations made to it by EMAC OE to accommodate embedded hardware. A link is provided to the standards document which covers the organization of the Linux filesystem at the end of this document. For more information visit the [[Linux_Filesystem_Organization | Linux Filesystem Organization]] page.<br />
<br />
EMAC recommends ''/usr/local/bin'' as the location for software you deploy.<br />
<br />
/usr/local/bin<br />
<br />
{{note|It is important to pay attention to the filesystem structure in order to ensure that your application will work as expected when the filesystem is in production. Reasons for this include:<br />
<cl><br />
1. Only certain directories, such as ''/var/'' and ''/tmp/'', are writeable when the filesystem is read-only.<br />
* Only certain directories should contain executables, such as ''/bin/'', ''/usr/bin/'', and ''/usr/local/bin/''.<br />
* Following this directory structure properly will make it easier to port your software to a newer release of EMAC OE later on.<br />
</cl>}}<br />
<br />
=== Remote Debugging ===<br />
Sometimes a program has no technical errors that cause the compile to fail, but fails to meet the developer's expectations when run. This is typically due to algorithm or data structure design errors which can be difficult to find with just visual inspection of the code. Because of this, it can be beneficial to run a debugger targeting the executable process. Debugging is the process of watching what is going on inside of another program while it is running. When a program is compiled with debug symbols included in the binary, it is possible to observe the source code and corresponding assembly code while running the debugger.<br />
<br />
When working with embedded systems the binary is usually compiled on a development machine with a different CPU architecture than what is on the target machine. This can be a problem when, as is typically the case, the target machine lacks the system resources to run a debugger. In these cases, it is possible to use the GNU debugger, or GDB, on the development machine to remotely debug the target machine provided it has a program called gdbserver. All EMAC OE builds are packaged with gdbserver to simplify the setup process for developers.<br />
<br />
For more information visit the [[Remote_Debugging_EMAC_OE_SDK_with_gdbserver | Remote Debugging EMAC OE SDK Projects with gdbserver]] page.<br />
<br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /***************************************** Examples *****************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
{{:Templateimpl:examples | initials=BS | title=Getting Started with the EMAC OE SDK | desc=Basic tutorial for using the EMAC OE SDK. | project=OE 5.0 }}<br />
=== Hello World System Log Example ===<br />
This example will print <code>Hello EMAC OE!</code> to the syslog facility as well as the console. This will allow you to log, debug, and send status messages to the system logger.<br />
<br />
To compile and run this program, see the sections above.<br />
<br />
{{warning|I removed the GPL copyright because this code should be unlicensed and free for the customers to use any way they want. Virtually no customer is going to want to release their source code to the public, so pushing the GPL on them can give the wrong impression.}}<br />
<syntaxhighlight lang="c"><br />
#include <stdio.h><br />
#include <stdlib.h><br />
#include <unistd.h><br />
#include <syslog.h><br />
<br />
int main(int argc, char** argv)<br />
{ <br />
char message[] = "Hello EMAC OE!";<br />
<br />
openlog("slog", LOG_PID|LOG_CONS, LOG_USER);<br />
syslog(LOG_INFO, "%s", message);<br />
closelog(); <br />
<br />
printf("%s\n", message);<br />
<br />
return 0;<br />
}<br />
</syntaxhighlight><br />
<br />
This is extremely useful because it allows you to save a record of the output that you might not see first hand.<br />
<br />
To verify the program went into the syslog, enter the following command:<br />
{{clo|indent=2}}<br />
{{clio | username=developer | hostname=ldc | tail /var/log/syslog}}<br />
Apr 7 14:10:06 ENG-26-LX dhclient: DHCPACK of 10.0.6.237 from 10.0.2.1<br /><br />
Apr 7 14:10:06 ENG-26-LX dhclient: bound to 10.0.6.237 -- renewal in 3306 seconds.<br /><br />
Apr 7 14:17:01 ENG-26-LX CRON[21193]: (root) CMD ( cd / && run-parts --report /etc/cron.hourly)<br /><br />
Apr 7 14:54:41 ENG-26-LX hpcups[21266]: prnt/hpcups/HPCupsFilter.cpp 689: First raster data plane..<br /><br />
Apr 7 14:55:31 hpcups[21266]: last message repeated 3 times<br /><br />
Apr 7 15:05:12 ENG-26-LX dhclient: DHCPREQUEST of 10.0.6.237 on eth0 to 10.0.2.1 port 67<br /><br />
Apr 7 15:05:12 ENG-26-LX dhclient: DHCPACK of 10.0.6.237 from 10.0.2.1<br /><br />
Apr 7 15:05:12 ENG-26-LX dhclient: bound to 10.0.6.237 -- renewal in 3559 seconds.<br /><br />
Apr 7 15:17:01 ENG-26-LX CRON[21302]: (root) CMD ( cd / && run-parts --report /etc/cron.hourly)<br /><br />
Apr 7 15:27:08 ENG-26-LX slog[21375]: Hello EMAC OE!<br />
{{clos}}<br />
<br />
As you can see on the bottom line, your program output has been recorded and date stamped in the syslog.<br />
<br />
For more information on system logging visit the [[System_Logging| System Logging ]] page.<br />
{{warning|I think we have a page which talks more about the system logging facility. If not, we do at least have it on our TODO list of pages to write. See if you can find that page, and link to it here. If we don't have it yet, please create a stub page for it and link to it here (using the template, of course).}}<br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /****************************************** More Information *****************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
{{:Templateimpl:moreinfo | initials=BS | title=Getting Started with the EMAC OE SDK | desc=Basic tutorial for using the EMAC OE SDK. | project=OE 5.0 }}<br />
* [[Getting_Started_With_Qt_Creator |Getting Started With Qt Creator]]<br />
<br />
{{:Templateimpl:whatnext | initials=BS | title=Getting Started with the EMAC OE SDK | desc=Basic tutorial for using the EMAC OE SDK. | project=OE 5.0 }}<br />
* [[System_Log_In | System Log In]]<br />
* [[Serial_Connections | Serial Connections ]]<br />
* [[Network_Connections | Network_Connections ]]<br />
* [[System_Log_In | System Log In ]]<br />
* [[Remote_Debugging_EMAC_OE_SDK_Projects_with_gdbserver | Remote Debugging EMAC OE SDK Projects with gdbserver ]]<br />
* [[Linux_Filesystem_Organization | Linux Filesystem Organization]]<br />
* [[CMake | CMake ]]<br />
* [[Remote_Debugging_EMAC_OE_SDK_with_gdbserver | Remote Debugging EMAC OE SDK Projects with gdbserver]]<br />
* [[System_Logging | System Logging ]]</div>Bserranohttps://wiki.emacinc.com/index.php?title=Getting_Started_with_the_EMAC_OE_SDK&diff=4277Getting Started with the EMAC OE SDK2015-04-21T15:15:34Z<p>Bserrano: </p>
<hr />
<div>{{todo| Review (03.31.2015-13:42->BS+);(04.08.2015-15:00->BS+);(04.09.15-14:00->MD+);(04.21.2015-10:15->BS+) |Brian Serrano| project=OE 5.0,BS,MD}}<br />
{{#seo:<br />
|title=Getting Started with the EMAC OE SDK<br />
|titlemode=append<br />
|keywords=EMAC SDK,Hello World Example,Target Compiling, Host Compiling<br />
|description=A basic tutorial for using the EMAC OE SDK.<br />
}}<br />
{{warning|Now is a good time to come up with keywords for the SEO tag.}}<br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /**************************************** Page Description Text ****************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
<span style="background:#00FF00;color:#FF0000;font-size:300%"></span><br />
<br />
The EMAC OE SDK is distributed with a set of example projects intended to demonstrate how to use the EMAC OE toolchain and libraries. This page demonstrates the process of compiling an example project and running it on the target machine. Also, it provides a straightforward guide to the essential steps you need to follow to get started with cross compiling a simple program with gcc and running the program on your embedded machine.<br />
{{warning|The following sentence isn't very compelling. I'd probably click back and look for a different page after reading that sentence. Maybe something like, "This page provides a straightforward guide to the essential steps you need to follow to get started with cross compiling a simple program with gcc and running the program on your embedded machine." }}<br />
__TOC__<br />
<br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /***************************************** General Information *****************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
{{:Templateimpl:geninfo | initials=BS | title=Getting Started with the EMAC OE SDK | desc=Basic tutorial for using the EMAC OE SDK. | project=OE 5.0 }}<br />
{{warning|We primarily distribute the SDK with our apt repository as a deb file for Ubuntu. We also provide a tarball they can extract, but we recommend the deb because that's the only version we officially support. I would reword this sentence to reflect that.}}<br />
The EMAC Open Embedded SDK is primarily distributed with our apt repository as a deb file for Ubuntu. EMAC also provides a tarbell you can extract, but recommends the deb file because it's the only version EMAC officially supports.<br />
<br />
Each SDK includes the C/C++ header files and libraries compatible with the target hardware. It also includes the C/C++ cross-compiler toolchain components necessary to compile and debug custom application code. The links below will help you get started building and running the example projects on the target hardware.<br />
<br />
More information on using Qt Creator with the EMAC SDK is available on the [[Getting_Started_With_Qt_Creator |Getting Started With Qt Creator]] page.<br />
{{warning|Using commanding language ("Follow the links to do this") sounds a bit unfriendly when talking to customers (as opposeMike dean d to internal documentation). We've tried to steer away from that in our documentation as much as possible. Instead, we try to phrase sentences in a friendly, informative way. I reworded two sentences above to show what I mean.}}<br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /***************************************** Using/Working With ******************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
{{:Templateimpl:using | initials=BS | title=Getting Started with the EMAC OE SDK | desc=Basic tutorial for using the EMAC OE SDK. | project=OE 5.0 }} <br />
=== Connecting to a Target Board ===<br />
The next step after establishing a physical connection to the board is logging in. More information on establishing a physical connection to a board is available on the [[Serrial_Connections |Serial Connections]] and [[Network_Connections |Network Connections]] page. <br />
<br />
EMAC OE Linux allows login from getty, and SSH (Secure Shell). A getty uses the serial connection or console while SSH utilizes a network connection. For more information visit the [[System_Log_In | System Log In]] page.<br />
{{warning|This is too abrupt. It feels like a paragraph or more is missing. You're assuming the reader already knows how to establish a physical connection. You need to either document how to do so here, or provide a link for information on how to do this. Remember, pages which are found via google need to stand on their own, since it may be the only page on our site that a potential customer will ever see. If they like it, they may come back and become a customer. If it leaves them hanging, they probably won't. It may be annoying to have to cater to that idea with every document we write, but it really is very important.}}<br />
<br />
=== Setting up the Filesystem Read-Write ===<br />
The filesystems on the remote machines are mounted read-only by default. In order to put your program on the board, you need to make the filesystem read-write. <br />
<br />
To set up the root filesytem read-write, enter the following into the terminal: <br />
{{cli | oemntrw | hostname=ipac9x25}}<br />
<br />
{{warning|Why would they want to do this? Because our filesystems are mounted read-only by default, which means they're not going to be able to put their program on the board unless they make it read-write first? There's a good chance they don't know that. Let them know. ;)}}<br />
=== Transferring Files ===<br />
The command line syntax for transferring a file using the SSH protocol is <code>scp file user@host:/directory</code>. SCP or Secure Copy is a way of securely transferring files between a local and remote host. For example, to send the file ''example.text'' to the <code>/home</code> directory of a system with the IP address 10.0.6.221, enter the following command:<br />
{{cli | username=developer | hostname=ldc | scp example.text root@10.0.6.221:/home }}<br />
<br /><br />
Alternatively, you can leave off the path after the colon if you want the file to go directly into the home directory.<br />
{{cli | username=developer | hostname=ldc | scp example.text root@10.0.6.221: }}<br />
<br /><br />
Be aware that this copy operation will fail if the filesystem on the remote machine is mounted read-only, which is the default on most EMAC systems.<br />
<br />
{{warning|(I'm only using the warning box so it stands out, and so you can remove it easily). It would be nice to let the reader know that they can leave off the path after the : if they want the file to go directly into their home directory. I like that trick a lot because it saves me a lot of typing. They'll probably like it too.<br />
<br />
Also, be careful where you put comments/notes. I moved the line above this box from below, because it was attached to the remote execution command before.}}<br />
=== Remote Execution ===<br />
SSH can also be used to execute programs on remote systems without logging in. The syntax for SSH remote execution is <code>ssh user@host "my_command -args file"</code>. For example, to run the program ''hello'' with the ''-hi'' flags on a system with the IP address of 10.0.6.221, enter the following command:<br />
{{cli | username=developer | hostname=ldc | ssh root@10.0.6.221 "/path/to/executable -args" }} <br />
<br />
<br />
=== Basic Compiling ===<br />
==== CMake Compiling ====<br />
===== Host Machine Compiling =====<br />
{{note|In these examples we are using the Ipac-9x25 board. Your board's processor's architecture will determine which file needs to be sourced. These files come from the EMAC SDK toolchain.}}<br />
{{warning|This is the manual way to do it, and only works well for ultra simple programs which only have one source file. Our customers are professional programmers, which means they will almost never have only one source file. We put a lot of work into CMake to make the cross compiling process much easier, and Klint created a tool to generate the CMake files automatically for a project. This is an important selling point for EMAC (everyone hates doing this by hand the manual way), so this is the method that should be documented first. Here's the script in our version control system: http://gitlab.emacinc.com/oe/cmake-new-project We will have a deb package in apt for this when we get a chance to make it, or we may incorporate it into one of our existing packages (like the tools package). You can leave a stub for how to install it before describing it.}}<br />
<br />
This section demonstrates how to use the EMAC CMake tool to generate CMake files automatically for a project. When using the EMAC SDK there are currently two options for cross compiling:<br />
* arm<br />
* x86<br />
For the purposes of this guide, the arm option will be used for the listed examples.<br />
<br />
Navigate to the directory where the project will be located. Then run the CMake new project script.<br />
{{clo|indent=2}}<br />
{{clio | username=developer | hostname=ldc | pwd=~/projects | oe_intit_project -n hello.c }}<br />
If desired, please enter a name for this project, otherwise press Enter to use the default: hello_emac <br /><br />
<br />
-- Creating new project directory... <br /><br />
-- Creating new source file... <br /><br />
-- Building custom CMakeLists.txt file... <br /><br />
-- Done. <br /><br />
<br />
Do you want to create a build directory for this project? (y/n) y <br /><br />
<br />
-- Creating build directory... <br /><br />
<br />
Do you want to run cmake for this project? (y/n) y <br /><br />
<br />
-- Using system compiler <br /><br />
-- The C compiler identification is GNU 4.8.2 <br /><br />
-- The CXX compiler identification is GNU 4.8.2 <br /><br />
-- Check for working C compiler: /usr/bin/cc <br /><br />
-- Check for working C compiler: /usr/bin/cc -- works <br /><br />
-- Detecting C compiler ABI info <br /><br />
-- Detecting C compiler ABI info - done <br /><br />
-- Check for working CXX compiler: /usr/bin/c++ <br /><br />
-- Check for working CXX compiler: /usr/bin/c++ -- works <br /><br />
-- Detecting CXX compiler ABI info <br /><br />
-- Detecting CXX compiler ABI info - done <br /><br />
-- Configuring done <br /><br />
-- Generating done <br /><br />
-- Build files have been written to: /home/developer/projects/hello_emac/hello_emac-build <br /><br />
<br />
Do you want to compile this project? (y/n) y<br />
<br />
Scanning dependencies of target hello_emac <br /><br />
[100%] Building C object CMakeFiles/hello_emac.dir/hello.c.o <br /><br />
Linking C executable hello_emac <br /><br />
[100%] Built target hello_emac <br /><br />
{{clos}}<br />
The executable in this case, is now inside the <code> hello_emac/hello_emac-build </code> directory.<br />
===== Target Machine Compiling =====<br />
Use the following steps to cross-compile the project and send it to a target board. In a terminal, navigate to the base directory of the project (where this document is located).<br />
<br />
Create a build directory for cross compiling. <br />
{{clio | username=developer | hostname=ldc | pwd=~/projects/hello_emac | mkdir hello_emac-build-arm }} <br />
<br />
Change directories into the newly created directory.<br />
{{clio | username=developer | hostname=ldc | pwd=~/projects/hello_emac | cd hello_emac-build-arm }} <br />
<br />
Run cmake using the target architecture.<br />
{{clio | username=developer | hostname=ldc | pwd=~/projects/hello_emac/hello_emac-build-arm | cmake .. -DARCH:STRING=arm }} <br />
cmake .. -DARCH:STRING=arm (Command prints out 1 on the wiki page because of the equal sign.)<br />
<br />
Compile the code using make.<br />
{{clio | username=developer | hostname=ldc | pwd=~/projects/hello_emac/hello_emac-build-arm | make }} <br />
<br />
After running the <code> make </code> command, the target executable is now in the <code> hello_emac-build-arm </code> directory. Then copy the executable to the target board. For information on copying the executable file, see the [[ #Transferring_Files | Transferring Files ]] section.<br />
<br />
For other ways to generate the CMake files, visit the [[CMake | CMake ]] page.<br />
<br />
==== Manual Compiling ====<br />
===== Host Machine Compiling =====<br />
Create a file called hello.c using a text editor such as vi, vim, nano, or gedit.<br />
<br />
Use the following syntax to compile the program called hello.c:<br />
{{cli | username=developer | hostname=ldc | gcc -o hello hello.c }}<br />
<br />
If there is no error in your code then the compiler will successfully create an executable file called hello in the current directory. <br />
<br />
To verify this, enter the following command:<br />
{{clo|indent=2}}<br />
{{clio | username=developer | hostname=ldc | ls -l hello* }}<br />
-rwxrwxr-x 1 bserrano bserrano 9583 Apr 6 12:45 hello <br /><br />
-rwxr-xr-x 1 bserrano bserrano 129 Apr 6 12:28 hello.c <br />
{{clos}}<br />
<br />
To run the program, enter the following command:<br />
{{clo|indent=2}}<br />
{{clio | username=developer | hostname=ldc | ./hello }}<br />
Hello EMAC OE!<br />
{{clos}}<br />
<br />
OR<br />
{{clo|indent=2}}<br />
{{clio | username=developer | hostname=ldc | /path/to/hello }}<br />
Hello EMAC OE!<br />
{{clos}}<br />
<br />
<br />
===== Target Board Compiling =====<br />
<br />
To compile on the target board, you must <code>source</code> the <code>environment-setup-armv5te-emac-linux-gnueabi</code> file.<br />
{{cli | username=developer | hostname=ldc | source /opt/emac/5.0/environment-setup-armv5te-emac-linux-gnueabi }}<br />
<br />
Once you are in the directory with the source file, enter the following command:<br />
{{cli | username=developer | hostname=ldc | $CC -o hello hello.c }}<br />
<br />
{{note|Once you source the file in your current terminal, you can only use it to cross-compile your program for the target board. You can no longer compile it for your host machine. To compile it to your host machine, simply open a new terminal.}}<br />
<br />
After sourcing the file, copy the program over to the target board using <code>scp</code>. Enter the following command:<br />
{{clo|indent=2}}<br />
{{clio | username=developer | hostname=ldc | scp hello root@10.0.6.221: }}<br />
root@10.0.6.221's password: <br />
hello 100% 9583 9.4KB/s 00:00 <br />
{{clos}}<br />
<br />
After copying the program, you can now execute the program on the target board. Enter the following command:<br />
{{clo|indent=2}}<br />
{{clio | username=developer | hostname=ldc | ssh root@10.0.6.221 ./hello}}<br />
root@10.0.6.221's password: <br /> <br />
Hello EMAC OE!<br />
{{clos}}<br />
<br />
=== Linux Filesystem Organization ===<br />
In order to prevent confusion and promote portability, a standard was created for the organization of the Linux filesystem. To ensure future portability of software created today, promote maintainability of software, and ensure proper utilization of available storage on an embedded machine, this standard should be followed as much as possible. This document covers parts of the standard and gives information about the customizations made to it by EMAC OE to accommodate embedded hardware. A link is provided to the standards document which covers the organization of the Linux filesystem at the end of this document. For more information visit the [[Linux_Filesystem_Organization | Linux Filesystem Organization]] page.<br />
<br />
EMAC recommends ''/usr/local/bin'' as the location for software you deploy.<br />
<br />
/usr/local/bin<br />
<br />
{{note|It is important to pay attention to the filesystem structure in order to ensure that your application will work as expected when the filesystem is in production. Reasons for this include:<br />
<cl><br />
1. Only certain directories, such as ''/var/'' and ''/tmp/'', are writeable when the filesystem is read-only.<br />
* Only certain directories should contain executables, such as ''/bin/'', ''/usr/bin/'', and ''/usr/local/bin/''.<br />
* Following this directory structure properly will make it easier to port your software to a newer release of EMAC OE later on.<br />
</cl>}}<br />
<br />
=== Remote Debugging ===<br />
Sometimes a program has no technical errors that cause the compile to fail, but fails to meet the developer's expectations when run. This is typically due to algorithm or data structure design errors which can be difficult to find with just visual inspection of the code. Because of this, it can be beneficial to run a debugger targeting the executable process. Debugging is the process of watching what is going on inside of another program while it is running. When a program is compiled with debug symbols included in the binary, it is possible to observe the source code and corresponding assembly code while running the debugger.<br />
<br />
When working with embedded systems the binary is usually compiled on a development machine with a different CPU architecture than what is on the target machine. This can be a problem when, as is typically the case, the target machine lacks the system resources to run a debugger. In these cases, it is possible to use the GNU debugger, or GDB, on the development machine to remotely debug the target machine provided it has a program called gdbserver. All EMAC OE builds are packaged with gdbserver to simplify the setup process for developers.<br />
<br />
For more information visit the [[Remote_Debugging_EMAC_OE_SDK_with_gdbserver | Remote Debugging EMAC OE SDK Projects with gdbserver]] page.<br />
<br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /***************************************** Examples *****************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
{{:Templateimpl:examples | initials=BS | title=Getting Started with the EMAC OE SDK | desc=Basic tutorial for using the EMAC OE SDK. | project=OE 5.0 }}<br />
=== Hello World System Log Example ===<br />
This example will print <code>Hello EMAC OE!</code> to the syslog facility as well as the console. This will allow you to log, debug, and send status messages to the system logger.<br />
<br />
To compile and run this program, see the sections above.<br />
<br />
{{warning|I removed the GPL copyright because this code should be unlicensed and free for the customers to use any way they want. Virtually no customer is going to want to release their source code to the public, so pushing the GPL on them can give the wrong impression.}}<br />
<syntaxhighlight lang="c"><br />
#include <stdio.h><br />
#include <stdlib.h><br />
#include <unistd.h><br />
#include <syslog.h><br />
<br />
int main(int argc, char** argv)<br />
{ <br />
char message[] = "Hello EMAC OE!";<br />
<br />
openlog("slog", LOG_PID|LOG_CONS, LOG_USER);<br />
syslog(LOG_INFO, "%s", message);<br />
closelog(); <br />
<br />
printf("%s\n", message);<br />
<br />
return 0;<br />
}<br />
</syntaxhighlight><br />
<br />
This is extremely useful because it allows you to save a record of the output that you might not see first hand.<br />
<br />
To verify the program went into the syslog, enter the following command:<br />
{{clo|indent=2}}<br />
{{clio | username=developer | hostname=ldc | tail /var/log/syslog}}<br />
Apr 7 14:10:06 ENG-26-LX dhclient: DHCPACK of 10.0.6.237 from 10.0.2.1<br /><br />
Apr 7 14:10:06 ENG-26-LX dhclient: bound to 10.0.6.237 -- renewal in 3306 seconds.<br /><br />
Apr 7 14:17:01 ENG-26-LX CRON[21193]: (root) CMD ( cd / && run-parts --report /etc/cron.hourly)<br /><br />
Apr 7 14:54:41 ENG-26-LX hpcups[21266]: prnt/hpcups/HPCupsFilter.cpp 689: First raster data plane..<br /><br />
Apr 7 14:55:31 hpcups[21266]: last message repeated 3 times<br /><br />
Apr 7 15:05:12 ENG-26-LX dhclient: DHCPREQUEST of 10.0.6.237 on eth0 to 10.0.2.1 port 67<br /><br />
Apr 7 15:05:12 ENG-26-LX dhclient: DHCPACK of 10.0.6.237 from 10.0.2.1<br /><br />
Apr 7 15:05:12 ENG-26-LX dhclient: bound to 10.0.6.237 -- renewal in 3559 seconds.<br /><br />
Apr 7 15:17:01 ENG-26-LX CRON[21302]: (root) CMD ( cd / && run-parts --report /etc/cron.hourly)<br /><br />
Apr 7 15:27:08 ENG-26-LX slog[21375]: Hello EMAC OE!<br />
{{clos}}<br />
<br />
As you can see on the bottom line, your program output has been recorded and date stamped in the syslog.<br />
<br />
For more information on system logging visit the [[System_Logging| System Logging ]] page.<br />
{{warning|I think we have a page which talks more about the system logging facility. If not, we do at least have it on our TODO list of pages to write. See if you can find that page, and link to it here. If we don't have it yet, please create a stub page for it and link to it here (using the template, of course).}}<br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /****************************************** More Information *****************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
{{:Templateimpl:moreinfo | initials=BS | title=Getting Started with the EMAC OE SDK | desc=Basic tutorial for using the EMAC OE SDK. | project=OE 5.0 }}<br />
* [[Getting_Started_With_Qt_Creator |Getting Started With Qt Creator]]<br />
<br />
{{:Templateimpl:whatnext | initials=BS | title=Getting Started with the EMAC OE SDK | desc=Basic tutorial for using the EMAC OE SDK. | project=OE 5.0 }}<br />
* [[System_Log_In | System Log In]]<br />
* [[Serial_Connections | Serial Connections ]]<br />
* [[Network_Connections | Network_Connections ]]<br />
* [[System_Log_In | System Log In ]]<br />
* [[Remote_Debugging_EMAC_OE_SDK_Projects_with_gdbserver | Remote Debugging EMAC OE SDK Projects with gdbserver ]]<br />
* [[Linux_Filesystem_Organization | Linux Filesystem Organization]]<br />
* [[CMake | CMake ]]<br />
* [[Remote_Debugging_EMAC_OE_SDK_with_gdbserver | Remote Debugging EMAC OE SDK Projects with gdbserver]]<br />
* [[System_Logging | System Logging ]]</div>Bserranohttps://wiki.emacinc.com/index.php?title=Getting_Started_with_the_EMAC_OE_SDK&diff=4270Getting Started with the EMAC OE SDK2015-04-14T13:58:04Z<p>Bserrano: </p>
<hr />
<div>{{todo| Buggy (03.31.2015-13:42->BS+), (04.08.2015-15:00->BS+);(04.09.15-14:00->MD+) |Brian Serrano| project=OE 5.0,BS,MD,SEOKWREV}}<br />
{{#seo:<br />
|title=Getting Started with the EMAC OE SDK<br />
|titlemode=append<br />
|keywords=EMAC SDK,Hello World Example,Target Board<br />
|description=A basic tutorial for using the EMAC OE SDK<br />
}}<br />
{{warning|Now is a good time to come up with keywords for the SEO tag.}}<br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /**************************************** Page Description Text ****************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
<span style="background:#00FF00;color:#FF0000;font-size:300%"></span><br />
<br />
The EMAC OE SDK is distributed with a set of example projects intended to demonstrate how to use the EMAC OE toolchain and libraries. This page demonstrates the process of compiling an example project and running it on the target machine. Also, it provides a straightforward guide to the essential steps you need to follow to get started with cross compiling a simple program with gcc and running the program on your embedded machine.<br />
{{warning|The following sentence isn't very compelling. I'd probably click back and look for a different page after reading that sentence. Maybe something like, "This page provides a straightforward guide to the essential steps you need to follow to get started with cross compiling a simple program with gcc and running the program on your embedded machine." }}<br />
__TOC__<br />
<br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /***************************************** General Information *****************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
{{:Templateimpl:geninfo | initials=BS | title=Getting Started with the EMAC OE SDK | desc=Basic tutorial for using the EMAC OE SDK. | project=OE 5.0 }}<br />
{{warning|We primarily distribute the SDK with our apt repository as a deb file for Ubuntu. We also provide a tarball they can extract, but we recommend the deb because that's the only version we officially support. I would reword this sentence to reflect that.}}<br />
The EMAC Open Embedded SDK is primarily distributed with our apt repository as a deb file for Ubuntu. EMAC also provides a tarbell you can extract, but recommends the deb file because it's the only version EMAC officially supports.<br />
<br />
Each SDK includes the C/C++ header files and libraries compatible with the target hardware. It also includes the C/C++ cross-compiler toolchain components necessary to compile and debug custom application code. The links below will help you get started building and running the example projects on the target hardware.<br />
<br />
More information on using Qt Creator with the EMAC SDK is available on the [[Getting_Started_With_Qt_Creator |Getting Started With Qt Creator]] page.<br />
{{warning|Using commanding language ("Follow the links to do this") sounds a bit unfriendly when talking to customers (as opposed to internal documentation). We've tried to steer away from that in our documentation as much as possible. Instead, we try to phrase sentences in a friendly, informative way. I reworded two sentences above to show what I mean.}}<br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /***************************************** Using/Working With ******************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
{{:Templateimpl:using | initials=BS | title=Getting Started with the EMAC OE SDK | desc=Basic tutorial for using the EMAC OE SDK. | project=OE 5.0 }} <br />
=== Connecting to a Target Board ===<br />
The next step after establishing a physical connection to the board is logging in. More information on establishing a physical connection to a board is available on the [[Serrial_Connections |Serial Connections]] and [[Network_Connections |Network Connections]] page. <br />
<br />
EMAC OE Linux allows login from getty, and SSH (Secure Shell). A getty uses the serial connection or console while SSH utilizes a network connection. For more information visit the [[System_Log_In | System Log In]] page.<br />
{{warning|This is too abrupt. It feels like a paragraph or more is missing. You're assuming the reader already knows how to establish a physical connection. You need to either document how to do so here, or provide a link for information on how to do this. Remember, pages which are found via google need to stand on their own, since it may be the only page on our site that a potential customer will ever see. If they like it, they may come back and become a customer. If it leaves them hanging, they probably won't. It may be annoying to have to cater to that idea with every document we write, but it really is very important.}}<br />
<br />
=== Setting up the Filesystem Read-Write ===<br />
The filesystems on the remote machines are mounted read-only by default. In order to put your program on the board, you need to make the filesystem read-write. <br />
<br />
To set up the root filesytem read-write, enter the following into the terminal: <br />
{{cli | oemntrw | hostname=ipac9x25}}<br />
<br />
{{warning|Why would they want to do this? Because our filesystems are mounted read-only by default, which means they're not going to be able to put their program on the board unless they make it read-write first? There's a good chance they don't know that. Let them know. ;)}}<br />
=== Transferring Files ===<br />
The command line syntax for transferring a file using the SSH protocol is <code>scp file user@host:/directory</code>. SCP or Secure Copy is a way of securely transferring files between a local and remote host. For example, to send the file ''example.text'' to the <code>/home</code> directory of a system with the IP address 10.0.6.221, enter the following command:<br />
{{cli | username=developer | hostname=ldc | scp example.text root@10.0.6.221:/home }}<br />
<br /><br />
Alternatively, you can leave of the path after the ':' if you want the file to go directly into the home directory.<br />
{{cli | username=developer | hostname=ldc | scp example.text root@10.0.6.221: }}<br />
<br /><br />
Be aware that this copy operation will fail if the filesystem on the remote machine is mounted read-only, which is the default on most EMAC systems.<br />
<br />
{{warning|(I'm only using the warning box so it stands out, and so you can remove it easily). It would be nice to let the reader know that they can leave off the path after the : if they want the file to go directly into their home directory. I like that trick a lot because it saves me a lot of typing. They'll probably like it too.<br />
<br />
Also, be careful where you put comments/notes. I moved the line above this box from below, because it was attached to the remote execution command before.}}<br />
=== Remote Execution ===<br />
SSH can also be used to execute programs on remote systems without logging in. The syntax for SSH remote execution is <code>ssh user@host "my_command -args file"</code>. For example, to run the program ''hello'' with the ''-hi'' flags on a system with the IP address of 10.0.6.221, enter the following command:<br />
{{cli | username=developer | hostname=ldc | ssh root@10.0.6.221 "/path/to/executable -args" }} <br />
<br />
<br />
=== Basic Compiling ===<br />
==== Host Machine Compiling ====<br />
Create a file called hello.c using a text editor such as vi, vim, nano, or gedit.<br />
<br />
Use the following syntax to compile the program called hello.c:<br />
{{cli | username=developer | hostname=ldc | gcc -o hello hello.c }}<br />
<br />
If there is no error in your code then the compiler will successfully create an executable file called hello in the current directory. <br />
<br />
To verify this, enter the following command:<br />
{{clo|indent=2}}<br />
{{clio | username=developer | hostname=ldc | ls -l hello* }}<br />
-rwxrwxr-x 1 bserrano bserrano 9583 Apr 6 12:45 hello <br /><br />
-rwxr-xr-x 1 bserrano bserrano 129 Apr 6 12:28 hello.c <br />
{{clos}}<br />
<br />
To run the program, enter the following command:<br />
{{clo|indent=2}}<br />
{{clio | username=developer | hostname=ldc | ./hello }}<br />
Hello EMAC OE!<br />
{{clos}}<br />
<br />
OR<br />
{{clo|indent=2}}<br />
{{clio | username=developer | hostname=ldc | /path/to/hello }}<br />
Hello EMAC OE!<br />
{{clos}}<br />
<br />
<br />
==== Target Board Compiling ====<br />
{{note|In these examples we are using the Ipac-9x25 board. Your board's processor's architecture will determine which file needs to be sourced. These files come from the EMAC SDK toolchain.}}<br />
{{warning|This is the manual way to do it, and only works well for ultra simple programs which only have one source file. Our customers are professional programmers, which means they will almost never have only one source file. We put a lot of work into CMake to make the cross compiling process much easier, and Klint created a tool to generate the CMake files automatically for a project. This is an important selling point for EMAC (everyone hates doing this by hand the manual way), so this is the method that should be documented first. Here's the script in our version control system: http://gitlab.emacinc.com/oe/cmake-new-project We will have a deb package in apt for this when we get a chance to make it, or we may incorporate it into one of our existing packages (like the tools package). You can leave a stub for how to install it before describing it.}}<br />
<br />
To compile on the target board, you must <code>source</code> the <code>environment-setup-armv5te-emac-linux-gnueabi</code> file.<br />
{{cli | username=developer | hostname=ldc | source /opt/emac/5.0/environment-setup-armv5te-emac-linux-gnueabi }}<br />
<br />
Once you are in the directory with the source file, enter the following command:<br />
{{cli | username=developer | hostname=ldc | $CC -o hello hello.c }}<br />
<br />
{{note|Once you source the file in your current terminal, you can only use it to cross-compile your program for the target board. You can no longer compile it for your host machine. To compile it to your host machine, simply open a new terminal.}}<br />
<br />
After sourcing the file, copy the program over to the target board using <code>scp</code>. Enter the following command:<br />
{{clo|indent=2}}<br />
{{clio | username=developer | hostname=ldc | scp hello root@10.0.6.221: }}<br />
root@10.0.6.221's password: <br />
hello 100% 9583 9.4KB/s 00:00 <br />
{{clos}}<br />
<br />
After copying the program, you can now execute the program on the target board. Enter the following command:<br />
{{clo|indent=2}}<br />
{{clio | username=developer | hostname=ldc | ssh root@10.0.6.221 ./hello}}<br />
root@10.0.6.221's password: <br /> <br />
Hello EMAC OE!<br />
{{clos}}<br />
<br />
=== Linux Filesystem Organization ===<br />
In order to prevent confusion and promote portability, a standard was created for the organization of the Linux filesystem. To ensure future portability of software created today, promote maintainability of software, and ensure proper utilization of available storage on an embedded machine, this standard should be followed as much as possible. This document covers parts of the standard and gives information about the customizations made to it by EMAC OE to accommodate embedded hardware. A link is provided to the standards document which covers the organization of the Linux filesystem at the end of this document. For more information visit the [[Linux_Filesystem_Organization | Linux Filesystem Organization]] page.<br />
<br />
EMAC recommends ''/usr/local/bin'' as the location for software you deploy.<br />
<br />
/usr/local/bin<br />
<br />
{{note|It is important to pay attention to the filesystem structure in order to ensure that your application will work as expected when the filesystem is in production. Reasons for this include:<br />
<cl><br />
1. Only certain directories, such as ''/var/'' and ''/tmp/'', are writeable when the filesystem is read-only.<br />
* Only certain directories should contain executables, such as ''/bin/'', ''/usr/bin/'', and ''/usr/local/bin/''.<br />
* Following this directory structure properly will make it easier to port your software to a newer release of EMAC OE later on.<br />
</cl>}}<br />
<br />
=== Remote Debugging ===<br />
Sometimes a program has no technical errors that cause the compile to fail, but fails to meet the developer's expectations when run. This is typically due to algorithm or data structure design errors which can be difficult to find with just visual inspection of the code. Because of this, it can be beneficial to run a debugger targeting the executable process. Debugging is the process of watching what is going on inside of another program while it is running. When a program is compiled with debug symbols included in the binary, it is possible to observe the source code and corresponding assembly code while running the debugger.<br />
<br />
When working with embedded systems the binary is usually compiled on a development machine with a different CPU architecture than what is on the target machine. This can be a problem when, as is typically the case, the target machine lacks the system resources to run a debugger. In these cases, it is possible to use the GNU debugger, or GDB, on the development machine to remotely debug the target machine provided it has a program called gdbserver. All EMAC OE builds are packaged with gdbserver to simplify the setup process for developers.<br />
<br />
For more information visit the [[Remote_Debugging_EMAC_OE_SDK_with_gdbserver | Remote Debugging EMAC OE SDK Projects with gdbserver]] page.<br />
<br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /***************************************** Examples *****************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
{{:Templateimpl:examples | initials=BS | title=Getting Started with the EMAC OE SDK | desc=Basic tutorial for using the EMAC OE SDK. | project=OE 5.0 }}<br />
=== Hello World System Log Example ===<br />
This example will print <code>Hello EMAC OE!</code> to the syslog facility as well as the console. This will allow you to log, debug, and send status messages to the system logger.<br />
<br />
To compile and run this program, see the sections above.<br />
<br />
{{warning|I removed the GPL copyright because this code should be unlicensed and free for the customers to use any way they want. Virtually no customer is going to want to release their source code to the public, so pushing the GPL on them can give the wrong impression.}}<br />
<syntaxhighlight lang="c"><br />
#include <stdio.h><br />
#include <stdlib.h><br />
#include <unistd.h><br />
#include <syslog.h><br />
<br />
int main(int argc, char** argv)<br />
{ <br />
char message[] = "Hello EMAC OE!";<br />
<br />
openlog("slog", LOG_PID|LOG_CONS, LOG_USER);<br />
syslog(LOG_INFO, "%s", message);<br />
closelog(); <br />
<br />
printf("%s\n", message);<br />
<br />
return 0;<br />
}<br />
</syntaxhighlight><br />
<br />
This is extremely useful because it allows you to save a record of the output that you might not see first hand.<br />
<br />
To verify the program went into the syslog, enter the following command:<br />
{{clo|indent=2}}<br />
{{clio | username=developer | hostname=ldc | tail /var/log/syslog}}<br />
Apr 7 14:10:06 ENG-26-LX dhclient: DHCPACK of 10.0.6.237 from 10.0.2.1<br /><br />
Apr 7 14:10:06 ENG-26-LX dhclient: bound to 10.0.6.237 -- renewal in 3306 seconds.<br /><br />
Apr 7 14:17:01 ENG-26-LX CRON[21193]: (root) CMD ( cd / && run-parts --report /etc/cron.hourly)<br /><br />
Apr 7 14:54:41 ENG-26-LX hpcups[21266]: prnt/hpcups/HPCupsFilter.cpp 689: First raster data plane..<br /><br />
Apr 7 14:55:31 hpcups[21266]: last message repeated 3 times<br /><br />
Apr 7 15:05:12 ENG-26-LX dhclient: DHCPREQUEST of 10.0.6.237 on eth0 to 10.0.2.1 port 67<br /><br />
Apr 7 15:05:12 ENG-26-LX dhclient: DHCPACK of 10.0.6.237 from 10.0.2.1<br /><br />
Apr 7 15:05:12 ENG-26-LX dhclient: bound to 10.0.6.237 -- renewal in 3559 seconds.<br /><br />
Apr 7 15:17:01 ENG-26-LX CRON[21302]: (root) CMD ( cd / && run-parts --report /etc/cron.hourly)<br /><br />
Apr 7 15:27:08 ENG-26-LX slog[21375]: Hello EMAC OE!<br />
{{clos}}<br />
<br />
As you can see on the bottom line, your program output has been recorded and date stamped in the syslog.<br />
{{warning|I think we have a page which talks more about the system logging facility. If not, we do at least have it on our TODO list of pages to write. See if you can find that page, and link to it here. If we don't have it yet, please create a stub page for it and link to it here (using the template, of course).}}<br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /****************************************** More Information *****************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
{{:Templateimpl:moreinfo | initials=BS | title=Getting Started with the EMAC OE SDK | desc=Basic tutorial for using the EMAC OE SDK. | project=OE 5.0 }}<br />
* [[Getting_Started_With_Qt_Creator |Getting Started With Qt Creator]]<br />
<br />
{{:Templateimpl:whatnext | initials=BS | title=Getting Started with the EMAC OE SDK | desc=Basic tutorial for using the EMAC OE SDK. | project=OE 5.0 }}<br />
* [[System_Log_In | System Log In]]<br />
* [[Linux_Filesystem_Organization | Linux Filesystem Organization]]<br />
* [[Remote_Debugging_EMAC_OE_SDK_with_gdbserver | Remote Debugging EMAC OE SDK Projects with gdbserver]]</div>Bserranohttps://wiki.emacinc.com/index.php?title=Getting_Started_with_the_EMAC_OE_SDK&diff=4269Getting Started with the EMAC OE SDK2015-04-13T21:41:28Z<p>Bserrano: </p>
<hr />
<div>{{todo| Buggy (03.31.2015-13:42->BS+), (04.08.2015-15:00->BS+);(04.09.15-14:00->MD+) |Brian Serrano| project=OE 5.0,BS,MD,SEOKWREV}}<br />
{{#seo:<br />
|title=Getting Started with the EMAC OE SDK<br />
|titlemode=append<br />
|keywords=EMAC SDK,Hello World Example,Target Board<br />
|description=A basic tutorial for using the EMAC OE SDK<br />
}}<br />
<!--{{warning|Now is a good time to come up with keywords for the SEO tag.}}--><br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /**************************************** Page Description Text ****************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
<span style="background:#00FF00;color:#FF0000;font-size:300%"></span><br />
<br />
The EMAC OE SDK is distributed with a set of example projects intended to demonstrate how to use the EMAC OE toolchain and libraries. This page demonstrates the process of compiling an example project and running it on the target machine. Also, it provides a straightforward guide to the essential steps you need to follow to get started with cross compiling a simple program with gcc and running the program on your embedded machine.<br />
<!--{{warning|The following sentence isn't very compelling. I'd probably click back and look for a different page after reading that sentence. Maybe something like, "This page provides a straightforward guide to the essential steps you need to follow to get started with cross compiling a simple program with gcc and running the program on your embedded machine." }}--><br />
__TOC__<br />
<br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /***************************************** General Information *****************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
{{:Templateimpl:geninfo | initials=BS | title=Getting Started with the EMAC OE SDK | desc=Basic tutorial for using the EMAC OE SDK. | project=OE 5.0 }}<br />
<!--{{warning|We primarily distribute the SDK with our apt repository as a deb file for Ubuntu. We also provide a tarball they can extract, but we recommend the deb because that's the only version we officially support. I would reword this sentence to reflect that.}}--><br />
The EMAC Open Embedded SDK is primarily distributed with our apt repository as a deb file for Ubuntu. EMAC also provides a tarbell you can extract, but recommends the deb file because it's the only version EMAC officially supports.<br />
<br />
Each SDK includes the C/C++ header files and libraries compatible with the target hardware. It also includes the C/C++ cross-compiler toolchain components necessary to compile and debug custom application code. The links below will help you get started building and running the example projects on the target hardware.<br />
<br />
More information on using Qt Creator with the EMAC SDK is available on the [[Getting_Started_With_Qt_Creator |Getting Started With Qt Creator]] page.<br />
<!--{{warning|Using commanding language ("Follow the links to do this") sounds a bit unfriendly when talking to customers (as opposed to internal documentation). We've tried to steer away from that in our documentation as much as possible. Instead, we try to phrase sentences in a friendly, informative way. I reworded two sentences above to show what I mean.}}--><br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /***************************************** Using/Working With ******************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
{{:Templateimpl:using | initials=BS | title=Getting Started with the EMAC OE SDK | desc=Basic tutorial for using the EMAC OE SDK. | project=OE 5.0 }} <br />
=== Connecting to a Target Board ===<br />
The next step after establishing a physical connection to the board is logging in. More information on establishing a physical connection to a board is available on the [[Serrial_Connections |Serial Connections]] and [[Network_Connections |Network Connections]] page. <br />
<br />
EMAC OE Linux allows login from getty, and SSH (Secure Shell). A getty uses the serial connection or console while SSH utilizes a network connection. For more information visit the [[System_Log_In | System Log In]] page.<br />
<!--{{warning|This is too abrupt. It feels like a paragraph or more is missing. You're assuming the reader already knows how to establish a physical connection. You need to either document how to do so here, or provide a link for information on how to do this. Remember, pages which are found via google need to stand on their own, since it may be the only page on our site that a potential customer will ever see. If they like it, they may come back and become a customer. If it leaves them hanging, they probably won't. It may be annoying to have to cater to that idea with every document we write, but it really is very important.}}--><br />
<br />
=== Setting up the Filesystem Read-Write ===<br />
The filesystems on the remote machines are mounted read-only by default. In order to put your program on the board, you need to make the filesystem read-write. <br />
<br />
To set up the root filesytem read-write, enter the following into the terminal: <br />
{{cli | oemntrw | hostname=ipac9x25}}<br />
<br />
<!--{{warning|Why would they want to do this? Because our filesystems are mounted read-only by default, which means they're not going to be able to put their program on the board unless they make it read-write first? There's a good chance they don't know that. Let them know. ;)}}--><br />
=== Transferring Files ===<br />
The command line syntax for transferring a file using the SSH protocol is <code>scp file user@host:/directory</code>. SCP or Secure Copy is a way of securely transferring files between a local and remote host. For example, to send the file ''example.text'' to the <code>/home</code> directory of a system with the IP address 10.0.6.221, enter the following command:<br />
{{cli | username=developer | hostname=ldc | scp example.text root@10.0.6.221:/home }}<br />
<br /><br />
Alternatively, you can leave of the path after the ':' if you want the file to go directly into the home directory.<br />
{{cli | username=developer | hostname=ldc | scp example.text root@10.0.6.221: }}<br />
<br /><br />
Be aware that this copy operation will fail if the filesystem on the remote machine is mounted read-only, which is the default on most EMAC systems.<br />
<br />
<!--{{warning|(I'm only using the warning box so it stands out, and so you can remove it easily). It would be nice to let the reader know that they can leave off the path after the : if they want the file to go directly into their home directory. I like that trick a lot because it saves me a lot of typing. They'll probably like it too.<br />
<br />
Also, be careful where you put comments/notes. I moved the line above this box from below, because it was attached to the remote execution command before.}}--><br />
=== Remote Execution ===<br />
SSH can also be used to execute programs on remote systems without logging in. The syntax for SSH remote execution is <code>ssh user@host "my_command -args file"</code>. For example, to run the program ''hello'' with the ''-hi'' flags on a system with the IP address of 10.0.6.221, enter the following command:<br />
{{cli | username=developer | hostname=ldc | ssh root@10.0.6.221 "/path/to/executable -args" }} <br />
<br />
<br />
=== Basic Compiling ===<br />
==== Host Machine Compiling ====<br />
Create a file called hello.c using a text editor such as vi, vim, nano, or gedit.<br />
<br />
Use the following syntax to compile the program called hello.c:<br />
{{cli | username=developer | hostname=ldc | gcc -o hello hello.c }}<br />
<br />
If there is no error in your code then the compiler will successfully create an executable file called hello in the current directory. <br />
<br />
To verify this, enter the following command:<br />
{{clo|indent=2}}<br />
{{clio | username=developer | hostname=ldc | ls -l hello* }}<br />
-rwxrwxr-x 1 bserrano bserrano 9583 Apr 6 12:45 hello <br /><br />
-rwxr-xr-x 1 bserrano bserrano 129 Apr 6 12:28 hello.c <br />
{{clos}}<br />
<br />
To run the program, enter the following command:<br />
{{clo|indent=2}}<br />
{{clio | username=developer | hostname=ldc | ./hello }}<br />
Hello EMAC OE!<br />
{{clos}}<br />
<br />
OR<br />
{{clo|indent=2}}<br />
{{clio | username=developer | hostname=ldc | /path/to/hello }}<br />
Hello EMAC OE!<br />
{{clos}}<br />
<br />
<br />
==== Target Board Compiling ====<br />
{{note|In these examples we are using the Ipac-9x25 board. Your board's processor's architecture will determine which file needs to be sourced. These files come from the EMAC SDK toolchain.}}<br />
<!--{{warning|This is the manual way to do it, and only works well for ultra simple programs which only have one source file. Our customers are professional programmers, which means they will almost never have only one source file. We put a lot of work into CMake to make the cross compiling process much easier, and Klint created a tool to generate the CMake files automatically for a project. This is an important selling point for EMAC (everyone hates doing this by hand the manual way), so this is the method that should be documented first. Here's the script in our version control system: http://gitlab.emacinc.com/oe/cmake-new-project We will have a deb package in apt for this when we get a chance to make it, or we may incorporate it into one of our existing packages (like the tools package). You can leave a stub for how to install it before describing it.}}--><br />
<br />
To compile on the target board, you must <code>source</code> the <code>environment-setup-armv5te-emac-linux-gnueabi</code> file.<br />
{{cli | username=developer | hostname=ldc | source /opt/emac/5.0/environment-setup-armv5te-emac-linux-gnueabi }}<br />
<br />
Once you are in the directory with the source file, enter the following command:<br />
{{cli | username=developer | hostname=ldc | $CC -o hello hello.c }}<br />
<br />
{{note|Once you source the file in your current terminal, you can only use it to cross-compile your program for the target board. You can no longer compile it for your host machine. To compile it to your host machine, simply open a new terminal.}}<br />
<br />
After sourcing the file, copy the program over to the target board using <code>scp</code>. Enter the following command:<br />
{{clo|indent=2}}<br />
{{clio | username=developer | hostname=ldc | scp hello root@10.0.6.221: }}<br />
root@10.0.6.221's password: <br />
hello 100% 9583 9.4KB/s 00:00 <br />
{{clos}}<br />
<br />
After copying the program, you can now execute the program on the target board. Enter the following command:<br />
{{clo|indent=2}}<br />
{{clio | username=developer | hostname=ldc | ssh root@10.0.6.221 ./hello}}<br />
root@10.0.6.221's password: <br /> <br />
Hello EMAC OE!<br />
{{clos}}<br />
<br />
=== Linux Filesystem Organization ===<br />
In order to prevent confusion and promote portability, a standard was created for the organization of the Linux filesystem. To ensure future portability of software created today, promote maintainability of software, and ensure proper utilization of available storage on an embedded machine, this standard should be followed as much as possible. This document covers parts of the standard and gives information about the customizations made to it by EMAC OE to accommodate embedded hardware. A link is provided to the standards document which covers the organization of the Linux filesystem at the end of this document. For more information visit the [[Linux_Filesystem_Organization | Linux Filesystem Organization]] page.<br />
<br />
EMAC recommends ''/usr/local/bin'' as the location for software you deploy.<br />
<br />
/usr/local/bin<br />
<br />
{{note|It is important to pay attention to the filesystem structure in order to ensure that your application will work as expected when the filesystem is in production. Reasons for this include:<br />
<cl><br />
1. Only certain directories, such as ''/var/'' and ''/tmp/'', are writeable when the filesystem is read-only.<br />
* Only certain directories should contain executables, such as ''/bin/'', ''/usr/bin/'', and ''/usr/local/bin/''.<br />
* Following this directory structure properly will make it easier to port your software to a newer release of EMAC OE later on.<br />
</cl>}}<br />
<br />
=== Remote Debugging ===<br />
Sometimes a program has no technical errors that cause the compile to fail, but fails to meet the developer's expectations when run. This is typically due to algorithm or data structure design errors which can be difficult to find with just visual inspection of the code. Because of this, it can be beneficial to run a debugger targeting the executable process. Debugging is the process of watching what is going on inside of another program while it is running. When a program is compiled with debug symbols included in the binary, it is possible to observe the source code and corresponding assembly code while running the debugger.<br />
<br />
When working with embedded systems the binary is usually compiled on a development machine with a different CPU architecture than what is on the target machine. This can be a problem when, as is typically the case, the target machine lacks the system resources to run a debugger. In these cases, it is possible to use the GNU debugger, or GDB, on the development machine to remotely debug the target machine provided it has a program called gdbserver. All EMAC OE builds are packaged with gdbserver to simplify the setup process for developers.<br />
<br />
For more information visit the [[Remote_Debugging_EMAC_OE_SDK_with_gdbserver | Remote Debugging EMAC OE SDK Projects with gdbserver]] page.<br />
<br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /***************************************** Examples *****************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
{{:Templateimpl:examples | initials=BS | title=Getting Started with the EMAC OE SDK | desc=Basic tutorial for using the EMAC OE SDK. | project=OE 5.0 }}<br />
=== Hello World System Log Example ===<br />
This example will print <code>Hello EMAC OE!</code> to the syslog facility as well as the console. This will allow you to log, debug, and send status messages to the system logger.<br />
<br />
To compile and run this program, see the sections above.<br />
<br />
<!--{{warning|I removed the GPL copyright because this code should be unlicensed and free for the customers to use any way they want. Virtually no customer is going to want to release their source code to the public, so pushing the GPL on them can give the wrong impression.}}--><br />
<syntaxhighlight lang="c"><br />
#include <stdio.h><br />
#include <stdlib.h><br />
#include <unistd.h><br />
#include <syslog.h><br />
<br />
int main(int argc, char** argv)<br />
{ <br />
char message[] = "Hello EMAC OE!";<br />
<br />
openlog("slog", LOG_PID|LOG_CONS, LOG_USER);<br />
syslog(LOG_INFO, "%s", message);<br />
closelog(); <br />
<br />
printf("%s\n", message);<br />
<br />
return 0;<br />
}<br />
</syntaxhighlight><br />
<br />
This is extremely useful because it allows you to save a record of the output that you might not see first hand.<br />
<br />
To verify the program went into the syslog, enter the following command:<br />
{{clo|indent=2}}<br />
{{clio | username=developer | hostname=ldc | tail /var/log/syslog}}<br />
Apr 7 14:10:06 ENG-26-LX dhclient: DHCPACK of 10.0.6.237 from 10.0.2.1<br /><br />
Apr 7 14:10:06 ENG-26-LX dhclient: bound to 10.0.6.237 -- renewal in 3306 seconds.<br /><br />
Apr 7 14:17:01 ENG-26-LX CRON[21193]: (root) CMD ( cd / && run-parts --report /etc/cron.hourly)<br /><br />
Apr 7 14:54:41 ENG-26-LX hpcups[21266]: prnt/hpcups/HPCupsFilter.cpp 689: First raster data plane..<br /><br />
Apr 7 14:55:31 hpcups[21266]: last message repeated 3 times<br /><br />
Apr 7 15:05:12 ENG-26-LX dhclient: DHCPREQUEST of 10.0.6.237 on eth0 to 10.0.2.1 port 67<br /><br />
Apr 7 15:05:12 ENG-26-LX dhclient: DHCPACK of 10.0.6.237 from 10.0.2.1<br /><br />
Apr 7 15:05:12 ENG-26-LX dhclient: bound to 10.0.6.237 -- renewal in 3559 seconds.<br /><br />
Apr 7 15:17:01 ENG-26-LX CRON[21302]: (root) CMD ( cd / && run-parts --report /etc/cron.hourly)<br /><br />
Apr 7 15:27:08 ENG-26-LX slog[21375]: Hello EMAC OE!<br />
{{clos}}<br />
<br />
As you can see on the bottom line, your program output has been recorded and date stamped in the syslog.<br />
<!--{{warning|I think we have a page which talks more about the system logging facility. If not, we do at least have it on our TODO list of pages to write. See if you can find that page, and link to it here. If we don't have it yet, please create a stub page for it and link to it here (using the template, of course).}}--><br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /****************************************** More Information *****************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
{{:Templateimpl:moreinfo | initials=BS | title=Getting Started with the EMAC OE SDK | desc=Basic tutorial for using the EMAC OE SDK. | project=OE 5.0 }}<br />
* [[Getting_Started_With_Qt_Creator |Getting Started With Qt Creator]]<br />
<br />
{{:Templateimpl:whatnext | initials=BS | title=Getting Started with the EMAC OE SDK | desc=Basic tutorial for using the EMAC OE SDK. | project=OE 5.0 }}<br />
* [[System_Log_In | System Log In]]<br />
* [[Linux_Filesystem_Organization | Linux Filesystem Organization]]<br />
* [[Remote_Debugging_EMAC_OE_SDK_with_gdbserver | Remote Debugging EMAC OE SDK Projects with gdbserver]]</div>Bserranohttps://wiki.emacinc.com/index.php?title=Getting_Started_with_the_EMAC_OE_SDK&diff=4268Getting Started with the EMAC OE SDK2015-04-13T20:02:57Z<p>Bserrano: </p>
<hr />
<div>{{todo| Buggy (03.31.2015-13:42->BS+), (04.08.2015-15:00->BS+);(04.09.15-14:00->MD+) |Brian Serrano| project=OE 5.0,BS,MD,SEOKWREV}}<br />
{{#seo:<br />
|title=Getting Started with the EMAC OE SDK<br />
|titlemode=append<br />
|keywords=EMAC SDK,Hello World Example,Target Board<br />
|description=A basic tutorial for using the EMAC OE SDK<br />
}}<br />
{{warning|Now is a good time to come up with keywords for the SEO tag.}}<br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /**************************************** Page Description Text ****************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
<span style="background:#00FF00;color:#FF0000;font-size:300%"></span><br />
<br />
The EMAC OE SDK is distributed with a set of example projects intended to demonstrate how to use the EMAC OE toolchain and libraries. This page demonstrates the process of compiling an example project and running it on the target machine.<br />
{{warning|The following sentence isn't very compelling. I'd probably click back and look for a different page after reading that sentence. Maybe something like, "This page provides a straightforward guide to the essential steps you need to follow to get started with cross compiling a simple program with gcc and running the program on your embedded machine." }}<br />
This guide consists of a simple hello.c source file.<br />
__TOC__<br />
<br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /***************************************** General Information *****************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
{{:Templateimpl:geninfo | initials=BS | title=Getting Started with the EMAC OE SDK | desc=Basic tutorial for using the EMAC OE SDK. | project=OE 5.0 }}<br />
{{warning|We primarily distribute the SDK with our apt repository as a deb file for Ubuntu. We also provide a tarball they can extract, but we recommend the deb because that's the only version we officially support. I would reword this sentence to reflect that.}}<br />
The EMAC Open Embedded SDK is primarily distributed with our apt repository as a deb file for Ubuntu. EMAC also provides a tarbell you can extract, but recommends the deb file because it's the only version EMAC officially supports.<br />
<br />
Each SDK includes the C/C++ header files and libraries compatible with the target hardware. It also includes the C/C++ cross-compiler toolchain components necessary to compile and debug custom application code. The links below will help you get started building and running the example projects on the target hardware.<br />
<br />
More information on using Qt Creator with the EMAC SDK is available on the [[Getting_Started_With_Qt_Creator |Getting Started With Qt Creator]] page.<br />
{{warning|Using commanding language ("Follow the links to do this") sounds a bit unfriendly when talking to customers (as opposed to internal documentation). We've tried to steer away from that in our documentation as much as possible. Instead, we try to phrase sentences in a friendly, informative way. I reworded two sentences above to show what I mean.}}<br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /***************************************** Using/Working With ******************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
{{:Templateimpl:using | initials=BS | title=Getting Started with the EMAC OE SDK | desc=Basic tutorial for using the EMAC OE SDK. | project=OE 5.0 }} <br />
=== Connecting to a Target Board ===<br />
The next step after establishing a physical connection to the board is logging in. More information on establishing a physical connection to a board is available on the [[Serrial_Connections |Serial Connections]] and [[Network_Connections |Network Connections]] page. <br />
<br />
EMAC OE Linux allows login from getty, and SSH (Secure Shell). A getty uses the serial connection or console while SSH utilizes a network connection. For more information visit the [[System_Log_In | System Log In]] page.<br />
{{warning|This is too abrupt. It feels like a paragraph or more is missing. You're assuming the reader already knows how to establish a physical connection. You need to either document how to do so here, or provide a link for information on how to do this. Remember, pages which are found via google need to stand on their own, since it may be the only page on our site that a potential customer will ever see. If they like it, they may come back and become a customer. If it leaves them hanging, they probably won't. It may be annoying to have to cater to that idea with every document we write, but it really is very important.}}<br />
<br />
=== Setting up the Filesystem Read-Write ===<br />
The filesystems on the remote machines are mounted read-only by default. In order to put your program on the board, you need to make the filesystem read-write. <br />
<br />
To set up the root filesytem read-write, enter the following into the terminal: <br />
{{cli | oemntrw | hostname=ipac9x25}}<br />
<br />
{{warning|Why would they want to do this? Because our filesystems are mounted read-only by default, which means they're not going to be able to put their program on the board unless they make it read-write first? There's a good chance they don't know that. Let them know. ;)}}<br />
=== Transferring Files ===<br />
The command line syntax for transferring a file using the SSH protocol is <code>scp file user@host:/directory</code>. SCP or Secure Copy is a way of securely transferring files between a local and remote host. For example, to send the file ''example.text'' to the <code>/home</code> directory of a system with the IP address 10.0.6.221, enter the following command:<br />
{{cli | username=developer | hostname=ldc | scp example.text root@10.0.6.221:/home }}<br />
<br /><br />
Alternatively, you can leave of the path after the ':' if you want the file to go directly into the home directory.<br />
{{cli | username=developer | hostname=ldc | scp example.text root@10.0.6.221: }}<br />
<br /><br />
Be aware that this copy operation will fail if the filesystem on the remote machine is mounted read-only, which is the default on most EMAC systems.<br />
<br />
{{warning|(I'm only using the warning box so it stands out, and so you can remove it easily). It would be nice to let the reader know that they can leave off the path after the : if they want the file to go directly into their home directory. I like that trick a lot because it saves me a lot of typing. They'll probably like it too.<br />
<br />
Also, be careful where you put comments/notes. I moved the line above this box from below, because it was attached to the remote execution command before.}}<br />
=== Remote Execution ===<br />
SSH can also be used to execute programs on remote systems without logging in. The syntax for SSH remote execution is <code>ssh user@host "my_command -args file"</code>. For example, to run the program ''hello'' with the ''-hi'' flags on a system with the IP address of 10.0.6.221, enter the following command:<br />
{{cli | username=developer | hostname=ldc | ssh root@10.0.6.221 "/path/to/executable -args" }} <br />
<br />
<br />
=== Basic Compiling ===<br />
==== Host Machine Compiling ====<br />
Create a file called hello.c using a text editor such as vi, vim, nano, or gedit.<br />
<br />
Use the following syntax to compile the program called hello.c:<br />
{{cli | username=developer | hostname=ldc | gcc -o hello hello.c }}<br />
<br />
If there is no error in your code then the compiler will successfully create an executable file called hello in the current directory. <br />
<br />
To verify this, enter the following command:<br />
{{clo|indent=2}}<br />
{{clio | username=developer | hostname=ldc | ls -l hello* }}<br />
-rwxrwxr-x 1 bserrano bserrano 9583 Apr 6 12:45 hello <br /><br />
-rwxr-xr-x 1 bserrano bserrano 129 Apr 6 12:28 hello.c <br />
{{clos}}<br />
<br />
To run the program, enter the following command:<br />
{{clo|indent=2}}<br />
{{clio | username=developer | hostname=ldc | ./hello }}<br />
Hello EMAC OE!<br />
{{clos}}<br />
<br />
OR<br />
{{clo|indent=2}}<br />
{{clio | username=developer | hostname=ldc | /path/to/hello }}<br />
Hello EMAC OE!<br />
{{clos}}<br />
<br />
<br />
==== Target Board Compiling ====<br />
{{note|In these examples we are using the Ipac-9x25 board. Your board's processor's architecture will determine which file needs to be sourced. These files come from the EMAC SDK toolchain.}}<br />
{{warning|This is the manual way to do it, and only works well for ultra simple programs which only have one source file. Our customers are professional programmers, which means they will almost never have only one source file. We put a lot of work into CMake to make the cross compiling process much easier, and Klint created a tool to generate the CMake files automatically for a project. This is an important selling point for EMAC (everyone hates doing this by hand the manual way), so this is the method that should be documented first. Here's the script in our version control system: http://gitlab.emacinc.com/oe/cmake-new-project We will have a deb package in apt for this when we get a chance to make it, or we may incorporate it into one of our existing packages (like the tools package). You can leave a stub for how to install it before describing it.}}<br />
<br />
To compile on the target board, you must <code>source</code> the <code>environment-setup-armv5te-emac-linux-gnueabi</code> file.<br />
{{cli | username=developer | hostname=ldc | source /opt/emac/5.0/environment-setup-armv5te-emac-linux-gnueabi }}<br />
<br />
Once you are in the directory with the source file, enter the following command:<br />
{{cli | username=developer | hostname=ldc | $CC -o hello hello.c }}<br />
<br />
{{note|Once you source the file in your current terminal, you can only use it to cross-compile your program for the target board. You can no longer compile it for your host machine. To compile it to your host machine, simply open a new terminal.}}<br />
<br />
After sourcing the file, copy the program over to the target board using <code>scp</code>. Enter the following command:<br />
{{clo|indent=2}}<br />
{{clio | username=developer | hostname=ldc | scp hello root@10.0.6.221: }}<br />
root@10.0.6.221's password: <br />
hello 100% 9583 9.4KB/s 00:00 <br />
{{clos}}<br />
<br />
After copying the program, you can now execute the program on the target board. Enter the following command:<br />
{{clo|indent=2}}<br />
{{clio | username=developer | hostname=ldc | ssh root@10.0.6.221 ./hello}}<br />
root@10.0.6.221's password: <br /> <br />
Hello EMAC OE!<br />
{{clos}}<br />
<br />
=== Linux Filesystem Organization ===<br />
In order to prevent confusion and promote portability, a standard was created for the organization of the Linux filesystem. To ensure future portability of software created today, promote maintainability of software, and ensure proper utilization of available storage on an embedded machine, this standard should be followed as much as possible. This document covers parts of the standard and gives information about the customizations made to it by EMAC OE to accommodate embedded hardware. A link is provided to the standards document which covers the organization of the Linux filesystem at the end of this document. For more information visit the [[Linux_Filesystem_Organization | Linux Filesystem Organization]] page.<br />
<br />
EMAC recommends ''/usr/local/bin'' as the location for software you deploy.<br />
<br />
/usr/local/bin<br />
<br />
{{note|It is important to pay attention to the filesystem structure in order to ensure that your application will work as expected when the filesystem is in production. Reasons for this include:<br />
<cl><br />
1. Only certain directories, such as ''/var/'' and ''/tmp/'', are writeable when the filesystem is read-only.<br />
* Only certain directories should contain executables, such as ''/bin/'', ''/usr/bin/'', and ''/usr/local/bin/''.<br />
* Following this directory structure properly will make it easier to port your software to a newer release of EMAC OE later on.<br />
</cl>}}<br />
<br />
=== Remote Debugging ===<br />
Sometimes a program has no technical errors that cause the compile to fail, but fails to meet the developer's expectations when run. This is typically due to algorithm or data structure design errors which can be difficult to find with just visual inspection of the code. Because of this, it can be beneficial to run a debugger targeting the executable process. Debugging is the process of watching what is going on inside of another program while it is running. When a program is compiled with debug symbols included in the binary, it is possible to observe the source code and corresponding assembly code while running the debugger.<br />
<br />
When working with embedded systems the binary is usually compiled on a development machine with a different CPU architecture than what is on the target machine. This can be a problem when, as is typically the case, the target machine lacks the system resources to run a debugger. In these cases, it is possible to use the GNU debugger, or GDB, on the development machine to remotely debug the target machine provided it has a program called gdbserver. All EMAC OE builds are packaged with gdbserver to simplify the setup process for developers.<br />
<br />
For more information visit the [[Remote_Debugging_EMAC_OE_SDK_with_gdbserver | Remote Debugging EMAC OE SDK Projects with gdbserver]] page.<br />
<br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /***************************************** Examples *****************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
{{:Templateimpl:examples | initials=BS | title=Getting Started with the EMAC OE SDK | desc=Basic tutorial for using the EMAC OE SDK. | project=OE 5.0 }}<br />
=== Hello World System Log Example ===<br />
This example will print <code>Hello EMAC OE!</code> to the syslog facility as well as the console. This will allow you to log, debug, and send status messages to the system logger.<br />
<br />
To compile and run this program, see the sections above.<br />
<br />
{{warning|I removed the GPL copyright because this code should be unlicensed and free for the customers to use any way they want. Virtually no customer is going to want to release their source code to the public, so pushing the GPL on them can give the wrong impression.}}<br />
<syntaxhighlight lang="c"><br />
#include <stdio.h><br />
#include <stdlib.h><br />
#include <unistd.h><br />
#include <syslog.h><br />
<br />
int main(int argc, char** argv)<br />
{ <br />
char message[] = "Hello EMAC OE!";<br />
<br />
openlog("slog", LOG_PID|LOG_CONS, LOG_USER);<br />
syslog(LOG_INFO, "%s", message);<br />
closelog(); <br />
<br />
printf("%s\n", message);<br />
<br />
return 0;<br />
}<br />
</syntaxhighlight><br />
<br />
This is extremely useful because it allows you to save a record of the output that you might not see first hand.<br />
<br />
To verify the program went into the syslog, enter the following command:<br />
{{clo|indent=2}}<br />
{{clio | username=developer | hostname=ldc | tail /var/log/syslog}}<br />
Apr 7 14:10:06 ENG-26-LX dhclient: DHCPACK of 10.0.6.237 from 10.0.2.1<br /><br />
Apr 7 14:10:06 ENG-26-LX dhclient: bound to 10.0.6.237 -- renewal in 3306 seconds.<br /><br />
Apr 7 14:17:01 ENG-26-LX CRON[21193]: (root) CMD ( cd / && run-parts --report /etc/cron.hourly)<br /><br />
Apr 7 14:54:41 ENG-26-LX hpcups[21266]: prnt/hpcups/HPCupsFilter.cpp 689: First raster data plane..<br /><br />
Apr 7 14:55:31 hpcups[21266]: last message repeated 3 times<br /><br />
Apr 7 15:05:12 ENG-26-LX dhclient: DHCPREQUEST of 10.0.6.237 on eth0 to 10.0.2.1 port 67<br /><br />
Apr 7 15:05:12 ENG-26-LX dhclient: DHCPACK of 10.0.6.237 from 10.0.2.1<br /><br />
Apr 7 15:05:12 ENG-26-LX dhclient: bound to 10.0.6.237 -- renewal in 3559 seconds.<br /><br />
Apr 7 15:17:01 ENG-26-LX CRON[21302]: (root) CMD ( cd / && run-parts --report /etc/cron.hourly)<br /><br />
Apr 7 15:27:08 ENG-26-LX slog[21375]: Hello EMAC OE!<br />
{{clos}}<br />
<br />
As you can see on the bottom line, your program output has been recorded and date stamped in the syslog.<br />
{{warning|I think we have a page which talks more about the system logging facility. If not, we do at least have it on our TODO list of pages to write. See if you can find that page, and link to it here. If we don't have it yet, please create a stub page for it and link to it here (using the template, of course).}}<br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /****************************************** More Information *****************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
{{:Templateimpl:moreinfo | initials=BS | title=Getting Started with the EMAC OE SDK | desc=Basic tutorial for using the EMAC OE SDK. | project=OE 5.0 }}<br />
* [[Getting_Started_With_Qt_Creator |Getting Started With Qt Creator]]<br />
<br />
{{:Templateimpl:whatnext | initials=BS | title=Getting Started with the EMAC OE SDK | desc=Basic tutorial for using the EMAC OE SDK. | project=OE 5.0 }}<br />
* [[System_Log_In | System Log In]]<br />
* [[Linux_Filesystem_Organization | Linux Filesystem Organization]]<br />
* [[Remote_Debugging_EMAC_OE_SDK_with_gdbserver | Remote Debugging EMAC OE SDK Projects with gdbserver]]</div>Bserranohttps://wiki.emacinc.com/index.php?title=System_Logging&diff=4267System Logging2015-04-13T19:44:39Z<p>Bserrano: Created page with "{{ subst:Pgtempl | initials={{subst::Templateimpl:getinitials}} | project=OE 5.0 | title=System Logging | desc=The page describes how to system log. }}"</p>
<hr />
<div>{{todo| NotStarted (04.13.2015-14:44->BS+)| Bserrano | project=OE 5.0,BS }}<br />
{{#seo:<br />
|title=System Logging<br />
|titlemode=append<br />
|keywords=<br />
|description=The page describes how to system log.<br />
}}<br />
<br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /**************************************** Page Description Text ****************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
<span style="background:#00FF00;color:#FF0000;font-size:300%">'''''Put the page description text here.'''''</span><br />
<br />
__TOC__<br />
<br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /***************************************** Background Information ****************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
{{:Templateimpl:bg | initials=BS | title=System Logging | desc=The page describes how to system log. | project=OE 5.0 }}<br />
<br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /***************************************** General Information *****************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
{{:Templateimpl:geninfo | initials=BS | title=System Logging | desc=The page describes how to system log. | project=OE 5.0 }}<br />
<br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /***************************************** Using/Working With ******************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
{{:Templateimpl:using | initials=BS | title=System Logging | desc=The page describes how to system log. | project=OE 5.0 }}<br />
<br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /***************************************** Examples *****************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
{{:Templateimpl:examples | initials=BS | title=System Logging | desc=The page describes how to system log. | project=OE 5.0 }}<br />
<br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /****************************************** Conclusion ******************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
{{:Templateimpl:conclusion | initials=BS | title=System Logging | desc=The page describes how to system log. | project=OE 5.0 }}<br />
<br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /****************************************** More Information *****************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
{{:Templateimpl:moreinfo | initials=BS | title=System Logging | desc=The page describes how to system log. | project=OE 5.0 }}<br />
* <br />
<br />
{{:Templateimpl:whatnext | initials=BS | title=System Logging | desc=The page describes how to system log. | project=OE 5.0 }}<br />
*</div>Bserranohttps://wiki.emacinc.com/index.php?title=Getting_Started_with_the_EMAC_OE_SDK&diff=4264Getting Started with the EMAC OE SDK2015-04-08T20:06:19Z<p>Bserrano: </p>
<hr />
<div>{{todo| Review (03.31.2015-13:42->BS+), (04.08.2015-15:00->BS+) |Brian Serrano| project=OE 5.0,BS }}<br />
{{#seo:<br />
|title=Getting Started with the EMAC OE SDK<br />
|titlemode=append<br />
|keywords=<br />
|description=A basic tutorial for using the EMAC OE SDK.<br />
}}<br />
<br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /**************************************** Page Description Text ****************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
<span style="background:#00FF00;color:#FF0000;font-size:300%"></span><br />
The EMAC OE SDK is distributed with a set of example projects intended to demonstrate how to use the EMAC OE toolchain and libraries. This page demonstrates the process of compiling an example project and running it on the target machine. <br />
<br />
This guide consists of a simple hello.c source file.<br />
__TOC__<br />
<br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /***************************************** General Information *****************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
{{:Templateimpl:geninfo | initials=BS | title=Getting Started with the EMAC OE SDK | desc=Basic tutorial for using the EMAC OE SDK. | project=OE 5.0 }}<br />
The EMAC Open Embedded SDK is distributed in an archive that can be extracted and used from a Linux terminal or from within an integrated development environment such as Qt Creator.<br />
<br />
Each SDK includes the C/C++ header files and libraries compatible with the target hardware. It also includes the C/C++ cross-compiler toolchain components necessary to compile and debug custom application code. Follow the links below to get started building and running the example projects on the target hardware.<br />
<br />
For more information on using Qt Creator with the EMAC SDK visit the [[Getting_Started_With_Qt_Creator |Getting Started With Qt Creator]] page.<br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /***************************************** Using/Working With ******************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
{{:Templateimpl:using | initials=BS | title=Getting Started with the EMAC OE SDK | desc=Basic tutorial for using the EMAC OE SDK. | project=OE 5.0 }} <br />
=== Connecting to a Target Board ===<br />
The next step after establishing a physical connection to the board is logging in. EMAC OE Linux allows login from getty, and SSH (Secure Shell). A getty uses the serial connection or console while SSH utilizes a network connection. For more information visit the [[System_Log_In | System Log In]] page.<br />
<br />
=== Setting up the Filesystem Read-Write ===<br />
To set up the root filesytem read-write, enter the following into the terminal: <br />
{{cli | oemntrw | hostname=ipac9x25}}<br />
<br />
To revert back the root filesytem to read-only, enter the following into the terminal:<br />
{{cli | oemntrw -r | hostname=ipac9x25}}<br />
<br />
=== Transferring Files ===<br />
The command line syntax for transferring a file using the SSH protocol is <code>scp file user@host:/directory</code>. SCP or Secure Copy is a way of securely transferring files between a local and remote host. For example, to send the file ''example.text'' to the <code>/home</code> directory of a system with the IP address 10.0.6.221, enter the following command:<br />
{{cli | username=developer | hostname=ldc | scp example.text root@10.0.6.221:/home }}<br />
<br />
=== Remote Execution ===<br />
SSH can also be used to execute programs on remote systems without logging in. The syntax for SSH remote execution is <code>ssh user@host "my_command -args file"</code>. For example, to run the program ''hello'' with the ''-hi'' flags on a system with the IP address of 10.0.6.221, enter the following command:<br />
{{cli | username=developer | hostname=ldc | ssh root@10.0.6.221 "/path/to/executable -args" }} <br />
<br /><br />
Be aware that this copy operation will fail if the filesystem on the remote machine is mounted read-only, which is the default on most EMAC systems.<br />
<br />
=== Basic Compiling ===<br />
==== Host Machine Compiling ====<br />
Create a file called hello.c using a text editor such as vi, vim, nano, or gedit.<br />
<br />
Use the following syntax to compile the program called hello.c:<br />
{{cli | username=developer | hostname=ldc | gcc -o hello hello.c }}<br />
<br />
If there is no error in your code then the compiler will successfully create an executable file called hello in the current directory. <br />
<br />
To verify this, enter the following command:<br />
{{clo|indent=2}}<br />
{{clio | username=developer | hostname=ldc | ls -l hello* }}<br />
-rwxrwxr-x 1 bserrano bserrano 9583 Apr 6 12:45 hello <br /><br />
-rwxr-xr-x 1 bserrano bserrano 129 Apr 6 12:28 hello.c <br />
{{clos}}<br />
<br />
To run the program, enter the following command:<br />
{{clo|indent=2}}<br />
{{clio | username=developer | hostname=ldc | ./hello }}<br />
Hello EMAC OE!<br />
{{clos}}<br />
<br />
OR<br />
{{clo|indent=2}}<br />
{{clio | username=developer | hostname=ldc | /path/to/hello }}<br />
Hello EMAC OE!<br />
{{clos}}<br />
<br />
==== Target Board Compiling ====<br />
{{note|In these examples we are using the Ipac-9x25 board. So depending on your board architecture it will determine which file needs to be source. These files come from the EMAC SDK toolchain.}}<br />
<br />
To compile on the target board, you must <code>source</code> the <code>environment-setup-armv5te-emac-linux-gnueabi</code> file.<br />
{{cli | username=developer | hostname=ldc | source /opt/emac/5.0/environment-setup-armv5te-emac-linux-gnueabi }}<br />
<br />
Once you are in the directory with the source file, enter the following command:<br />
{{cli | username=developer | hostname=ldc | $CC -o hello hello.c }}<br />
<br />
{{note|Once you source the file in your current terminal, you can only use it to cross-compile your program for the target board. You can no longer compile it for your host machine. To compile it to your host machine, simply open a new terminal.}}<br />
<br />
After sourcing the file, copy the program over to the target board using <code>scp</code>. Enter the following command:<br />
{{clo|indent=2}}<br />
{{clio | username=developer | hostname=ldc | scp hello root@10.0.6.221: }}<br />
root@10.0.6.221's password: <br />
hello 100% 9583 9.4KB/s 00:00 <br />
{{clos}}<br />
<br />
After copying the program, you can now execute the program on the target board. Enter the following command:<br />
{{clo|indent=2}}<br />
{{clio | username=developer | hostname=ldc | ssh root@10.0.6.221 ./hello}}<br />
root@10.0.6.221's password: <br /> <br />
Hello EMAC OE!<br />
{{clos}}<br />
<br />
=== Linux Filesystem Organization ===<br />
In order to prevent confusion and promote portability, a standard was created for the organization of the Linux filesystem. To ensure future portability of software created today, promote maintainability of software, and ensure proper utilization of available storage on an embedded machine, this standard should be followed as much as possible. This document covers parts of the standard and gives information about the customizations made to it by EMAC OE to accommodate embedded hardware. A link is provided to the standards document which covers the organization of the Linux filesystem at the end of this document. For more information visit the [[Linux_Filesystem_Organization | Linux Filesystem Organization]] page.<br />
<br />
EMAC recommends ''/usr/local/bin'' as the location for software you deploy.<br />
<br />
/usr/local/bin<br />
<br />
<cl><br />
1. It is important to pay attention to the filesystem structure in order to ensure that your application will work as expected when the filesystem is in production. Reason for this:<br />
i. Only certain directories, such as ''/var/'' and ''/tmp/'', are writeable when the filesystem is read-only.<br />
* Only certain directories should contain executables, such as ''/bin/'', ''/usr/bin/'', and ''/usr/local/bin/''.<br />
* Following this directory structure properly will make it easier to port your software to a newer release of EMAC OE later on.<br />
</cl><br />
<br />
=== Remote Debugging ===<br />
Sometimes a program has no technical errors that cause the compile to fail, but fails to meet the developer's expectations when run. This is typically due to algorithm or data structure design errors which can be difficult to find with just visual inspection of the code. Because of this, it can be beneficial to run a debugger targeting the executable process. Debugging is the process of watching what is going on inside of another program while it is running. When a program is compiled with debug symbols included in the binary, it is possible to observe the source code and corresponding assembly code while running the debugger.<br />
<br />
When working with embedded systems the binary is usually compiled on a development machine with a different CPU architecture than what is on the target machine. This can be a problem when, as is typically the case, the target machine lacks the system resources to run a debugger. In these cases, it is possible to use the GNU debugger, or GDB, on the development machine to remotely debug the target machine provided it has a program called gdbserver. All EMAC OE builds are packaged with gdbserver to simplify the setup process for developers.<br />
<br />
For more information visit the [[Remote_Debugging_EMAC_OE_SDK_with_gdbserver | Remote Debugging EMAC OE SDK Projects with gdbserver]] page.<br />
<br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /***************************************** Examples *****************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
{{:Templateimpl:examples | initials=BS | title=Getting Started with the EMAC OE SDK | desc=Basic tutorial for using the EMAC OE SDK. | project=OE 5.0 }}<br />
=== Hello World System Log Example ===<br />
This example will print <code>Hello EMAC OE!</code> to the syslog facility as well as the console. This will allow you to log, debug, and send status messages to the system logger.<br />
<br />
To compile and run this program, see the sections above.<br />
<br />
<syntaxhighlight lang="c"><br />
/**<br />
* @file hello.c<br />
*<br />
* Simple Hello World application for EMAC OE.<br />
*<br />
* @author EMAC, Inc. <support@emacinc.com><br />
*/<br />
/***************************************************************************<br />
* *<br />
* This program is free software; you can redistribute it and/or modify *<br />
* it under the terms of the GNU General Public License as published by *<br />
* the Free Software Foundation; either version 2 of the License, or *<br />
* (at your option) any later version. *<br />
* *<br />
***************************************************************************/<br />
<br />
#include <stdio.h><br />
#include <stdlib.h><br />
#include <unistd.h><br />
#include <syslog.h><br />
<br />
int main(int argc, char** argv)<br />
{ <br />
char message[] = "Hello EMAC OE!";<br />
<br />
openlog("slog", LOG_PID|LOG_CONS, LOG_USER);<br />
syslog(LOG_INFO, "%s", message);<br />
closelog(); <br />
<br />
printf("%s\n", message);<br />
<br />
return 0;<br />
}<br />
</syntaxhighlight><br />
<br />
This is extremely useful because it allows you to save a record of the output that you might not see first hand.<br />
<br />
To verify the program went into the syslog, enter the following command:<br />
{{clo|indent=2}}<br />
{{clio | username=developer | hostname=ldc | tail /var/log/syslog}}<br />
Apr 7 14:10:06 ENG-26-LX dhclient: DHCPACK of 10.0.6.237 from 10.0.2.1<br /><br />
Apr 7 14:10:06 ENG-26-LX dhclient: bound to 10.0.6.237 -- renewal in 3306 seconds.<br /><br />
Apr 7 14:17:01 ENG-26-LX CRON[21193]: (root) CMD ( cd / && run-parts --report /etc/cron.hourly)<br /><br />
Apr 7 14:54:41 ENG-26-LX hpcups[21266]: prnt/hpcups/HPCupsFilter.cpp 689: First raster data plane..<br /><br />
Apr 7 14:55:31 hpcups[21266]: last message repeated 3 times<br /><br />
Apr 7 15:05:12 ENG-26-LX dhclient: DHCPREQUEST of 10.0.6.237 on eth0 to 10.0.2.1 port 67<br /><br />
Apr 7 15:05:12 ENG-26-LX dhclient: DHCPACK of 10.0.6.237 from 10.0.2.1<br /><br />
Apr 7 15:05:12 ENG-26-LX dhclient: bound to 10.0.6.237 -- renewal in 3559 seconds.<br /><br />
Apr 7 15:17:01 ENG-26-LX CRON[21302]: (root) CMD ( cd / && run-parts --report /etc/cron.hourly)<br /><br />
Apr 7 15:27:08 ENG-26-LX slog[21375]: Hello EMAC OE!<br />
{{clos}}<br />
<br />
As you can see on the bottom line, your program output has been recorded and date stamped in the syslog.<br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /****************************************** More Information *****************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
{{:Templateimpl:moreinfo | initials=BS | title=Getting Started with the EMAC OE SDK | desc=Basic tutorial for using the EMAC OE SDK. | project=OE 5.0 }}<br />
* [[Getting_Started_With_Qt_Creator |Getting Started With Qt Creator]]<br />
<br />
{{:Templateimpl:whatnext | initials=BS | title=Getting Started with the EMAC OE SDK | desc=Basic tutorial for using the EMAC OE SDK. | project=OE 5.0 }}<br />
* [[System_Log_In | System Log In]]<br />
* [[Linux_Filesystem_Organization | Linux Filesystem Organization]]<br />
* [[Remote_Debugging_EMAC_OE_SDK_with_gdbserver | Remote Debugging EMAC OE SDK Projects with gdbserver]]</div>Bserranohttps://wiki.emacinc.com/index.php?title=Getting_Started_with_the_EMAC_OE_SDK&diff=4263Getting Started with the EMAC OE SDK2015-04-07T21:18:15Z<p>Bserrano: </p>
<hr />
<div>{{todo| InProgress (03.31.2015-13:42->BS+)|Brian Serrano| project=OE 5.0,BS }}<br />
{{#seo:<br />
|title=Getting Started with the EMAC OE SDK<br />
|titlemode=append<br />
|keywords=<br />
|description=A basic tutorial for using the EMAC OE SDK.<br />
}}<br />
<br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /**************************************** Page Description Text ****************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
<span style="background:#00FF00;color:#FF0000;font-size:300%"></span><br />
The EMAC OE SDK is distributed with a set of example projects intended to demonstrate how to use the EMAC OE toolchain and libraries. This page demonstrates the process of compiling a example project and running it on the target machine. <br />
<br />
This guide consists of a simple hello.c source file.<br />
__TOC__<br />
<br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /***************************************** General Information *****************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
{{:Templateimpl:geninfo | initials=BS | title=Getting Started with the EMAC OE SDK | desc=Basic tutorial for using the EMAC OE SDK. | project=OE 5.0 }}<br />
The EMAC Open Embedded SDK is distributed in an archive that can be extracted and used from a Linux terminal or from within an integrated development environment such as Qt Creator.<br />
<br />
Each SDK includes the C/C++ header files and libraries compatible with the target hardware. It also includes the C/C++ cross-compiler toolchain components necessary to compile and debug custom application code. Follow the links below to get started building and running the example projects on the target hardware.<br />
<br />
For more information on using Qt Creator with the EMAC SDK visit the [[Getting_Started_With_Qt_Creator |Getting Started With Qt Creator]] page.<br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /***************************************** Using/Working With ******************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
{{:Templateimpl:using | initials=BS | title=Getting Started with the EMAC OE SDK | desc=Basic tutorial for using the EMAC OE SDK. | project=OE 5.0 }} <br />
=== Connecting to a Target Board ===<br />
The next step after establishing a physical connection to the board is logging in. EMAC OE Linux allows login from getty, and SSH (Secure Shell). A getty uses the serial connection or console while SSH utilizes a network connection. For more information visit the [[System_Log_In | System Log In]] page.<br />
<br />
=== Setting up the Filesystem Read-Write ===<br />
To set up the root filesytem read-write, enter the following into the terminal: <br />
{{cli | oemntrw | hostname=ipac9x25}}<br />
<br />
To revert back the root filesytem to read-only, enter the following into the terminal:<br />
{{cli | oemntrw -r | hostname=ipac9x25}}<br />
<br />
=== Transferring Files ===<br />
The command line syntax for transferring a file using the SSH protocol is <code>scp file user@host:/directory</code>. SCP or Secure Copy is a way of securely transferring files between a local and remote host. For example, to send the file ''example.text'' to the <code>/home</code> directory of a system with the IP address 10.0.6.221, enter the following command:<br />
{{cli | username=developer | hostname=ldc | scp example.text root@10.0.6.221:/home }}<br />
<br />
=== Remote Execution ===<br />
SSH can also be used to execute programs on remote systems without logging in. The syntax for SSH remote execution is <code>ssh user@host "my_command -args file"</code>. For example, to run the program ''hello_world'' with the ''-hi'' flags on a system with the IP address of 10.0.6.221, enter the following command:<br />
{{cli | username=developer | hostname=ldc | ssh root@10.0.6.221 "/path/to/executable -args" }} <br />
<br /><br />
Be aware that this copy operation will fail if the filesystem on the remote machine is mounted read-only, which is the default on most EMAC systems.<br />
<br />
=== Basic Compiling ===<br />
==== Host Machine Compiling ====<br />
Create a file called hello.c using a text editor such as vi, vim, nano, or gedit.<br />
<br />
Use the following syntax to compile the program called hello.c:<br />
{{cli | username=developer | hostname=ldc | gcc -o hello hello.c }}<br />
<br />
If there is no error in your code then the compiler will successfully create an executable file called hello in the current directory. <br />
<br />
To verify this, enter the following command:<br />
{{clo|indent=2}}<br />
{{clio | username=developer | hostname=ldc | ls -l hello* }}<br />
-rwxrwxr-x 1 bserrano bserrano 9583 Apr 6 12:45 hello <br /><br />
-rwxr-xr-x 1 bserrano bserrano 129 Apr 6 12:28 hello.c <br />
{{clos}}<br />
<br />
To run the program, enter the following command:<br />
{{clo|indent=2}}<br />
{{clio | username=developer | hostname=ldc | ./hello }}<br />
Hello EMAC OE!<br />
{{clos}}<br />
<br />
OR<br />
{{clo|indent=2}}<br />
{{clio | username=developer | hostname=ldc | /path/to/hello }}<br />
Hello EMAC OE!<br />
{{clos}}<br />
<br />
==== Target Board Compiling ====<br />
{{note|In these examples we are using the Ipac-9x25 board. So depending on your board architecture it will determine which file needs to be source. These files come from the EMAC SDK toolchain.}}<br />
<br />
To compile on the target board, you must <code>source</code> the <code>environment-setup-armv5te-emac-linux-gnueabi</code> file.<br />
{{cli | username=developer | hostname=ldc | source /opt/emac/5.0/environment-setup-armv5te-emac-linux-gnueabi }}<br />
<br />
Once you are in the directory with the source file, enter the following command:<br />
{{cli | username=developer | hostname=ldc | $CC -o hello hello.c }}<br />
<br />
{{note|Once you source the file in your current terminal, you can only use it to cross-compile your program for the target board. You can no longer compile it for your host machine. To compile it to your host machine, simply open a new terminal.}}<br />
<br />
After sourcing the file, copy the program over to the target board using <code>scp</code>. Enter the following command:<br />
{{clo|indent=2}}<br />
{{clio | username=developer | hostname=ldc | scp hello root@10.0.6.221: }}<br />
root@10.0.6.221's password: <br />
hello 100% 9583 9.4KB/s 00:00 <br />
{{clos}}<br />
<br />
After copying the program, you can now execute the program on the target board. Enter the following command:<br />
{{clo|indent=2}}<br />
{{clio | username=developer | hostname=ldc | ssh root@10.0.6.221 ./hello}}<br />
root@10.0.6.221's password: <br /> <br />
Hello EMAC OE!<br />
{{clos}}<br />
<br />
=== Linux Filesystem Organization ===<br />
In order to prevent confusion and promote portability, a standard was created for the organization of the Linux filesystem. To ensure future portability of software created today, promote maintainability of software, and ensure proper utilization of available storage on an embedded machine, this standard should be followed as much as possible. This document covers parts of the standard and gives information about the customizations made to it by EMAC OE to accommodate embedded hardware. A link is provided to the standards document which covers the organization of the Linux filesystem at the end of this document. For more information visit the [[Linux_Filesystem_Organization | Linux Filesystem Organization]] page.<br />
<br />
EMAC recommends ''/usr/local/bin'' as the location for software you deploy.<br />
<br />
/usr/local/bin<br />
<br />
<cl><br />
1. It is important to pay attention to the filesystem structure in order to ensure that your application will work as expected when the filesystem is in production. Reason for this:<br />
i. Only certain directories, such as ''/var/'' and ''/tmp/'', are writeable when the filesystem is read-only.<br />
* Only certain directories should contain executables, such as ''/bin/'', ''/usr/bin/'', and ''/usr/local/bin/''.<br />
* Following this directory structure properly will make it easier to port your software to a newer release of EMAC OE later on.<br />
</cl><br />
<br />
=== Remote Debugging ===<br />
Sometimes a program has no technical errors that cause the compile to fail, but fails to meet the developer's expectations when run. This is typically due to algorithm or data structure design errors which can be difficult to find with just visual inspection of the code. Because of this, it can be beneficial to run a debugger targeting the executable process. Debugging is the process of watching what is going on inside of another program while it is running. When a program is compiled with debug symbols included in the binary, it is possible to observe the source code and corresponding assembly code while running the debugger.<br />
<br />
When working with embedded systems the binary is usually compiled on a development machine with a different CPU architecture than what is on the target machine. This can be a problem when, as is typically the case, the target machine lacks the system resources to run a debugger. In these cases, it is possible to use the GNU debugger, or GDB, on the development machine to remotely debug the target machine provided it has a program called gdbserver. All EMAC OE builds are packaged with gdbserver to simplify the setup process for developers.<br />
<br />
For more information visit the [[Remote_Debugging_EMAC_OE_SDK_with_gdbserver | Remote Debugging EMAC OE SDK Projects with gdbserver]] page.<br />
<br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /***************************************** Examples *****************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
{{:Templateimpl:examples | initials=BS | title=Getting Started with the EMAC OE SDK | desc=Basic tutorial for using the EMAC OE SDK. | project=OE 5.0 }}<br />
=== Hello World System Log Example ===<br />
This example will print <code>Hello EMAC OE!</code> to the syslog facility as well as the console. This will allow you to log, debug, and send status messages to the system logger.<br />
<br />
To compile and run this program, see the sections above.<br />
<br />
<syntaxhighlight lang="c"><br />
/**<br />
* @file hello.c<br />
*<br />
* Simple Hello World application for EMAC OE.<br />
*<br />
* @author EMAC, Inc. <support@emacinc.com><br />
*/<br />
/***************************************************************************<br />
* *<br />
* This program is free software; you can redistribute it and/or modify *<br />
* it under the terms of the GNU General Public License as published by *<br />
* the Free Software Foundation; either version 2 of the License, or *<br />
* (at your option) any later version. *<br />
* *<br />
***************************************************************************/<br />
<br />
#include <stdio.h><br />
#include <stdlib.h><br />
#include <unistd.h><br />
#include <syslog.h><br />
<br />
int main(int argc, char** argv)<br />
{ <br />
char message[] = "Hello EMAC OE!";<br />
<br />
openlog("slog", LOG_PID|LOG_CONS, LOG_USER);<br />
syslog(LOG_INFO, "%s", message);<br />
closelog(); <br />
<br />
printf("%s\n", message);<br />
<br />
return 0;<br />
}<br />
</syntaxhighlight><br />
<br />
This is extremely useful because it allows you to save a record of the output that you might not see first hand.<br />
<br />
To verify the program went into the syslog, enter the following command:<br />
{{clo|indent=2}}<br />
{{clio | username=developer | hostname=ldc | tail /var/log/syslog}}<br />
Apr 7 14:10:06 ENG-26-LX dhclient: DHCPACK of 10.0.6.237 from 10.0.2.1<br /><br />
Apr 7 14:10:06 ENG-26-LX dhclient: bound to 10.0.6.237 -- renewal in 3306 seconds.<br /><br />
Apr 7 14:17:01 ENG-26-LX CRON[21193]: (root) CMD ( cd / && run-parts --report /etc/cron.hourly)<br /><br />
Apr 7 14:54:41 ENG-26-LX hpcups[21266]: prnt/hpcups/HPCupsFilter.cpp 689: First raster data plane..<br /><br />
Apr 7 14:55:31 hpcups[21266]: last message repeated 3 times<br /><br />
Apr 7 15:05:12 ENG-26-LX dhclient: DHCPREQUEST of 10.0.6.237 on eth0 to 10.0.2.1 port 67<br /><br />
Apr 7 15:05:12 ENG-26-LX dhclient: DHCPACK of 10.0.6.237 from 10.0.2.1<br /><br />
Apr 7 15:05:12 ENG-26-LX dhclient: bound to 10.0.6.237 -- renewal in 3559 seconds.<br /><br />
Apr 7 15:17:01 ENG-26-LX CRON[21302]: (root) CMD ( cd / && run-parts --report /etc/cron.hourly)<br /><br />
Apr 7 15:27:08 ENG-26-LX slog[21375]: Hello EMAC OE!<br />
{{clos}}<br />
<br />
As you can see on the bottom line, your program output has been recorded and date stamped in the syslog.<br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /****************************************** More Information *****************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
{{:Templateimpl:moreinfo | initials=BS | title=Getting Started with the EMAC OE SDK | desc=Basic tutorial for using the EMAC OE SDK. | project=OE 5.0 }}<br />
* [[Getting_Started_With_Qt_Creator |Getting Started With Qt Creator]]<br />
<br />
{{:Templateimpl:whatnext | initials=BS | title=Getting Started with the EMAC OE SDK | desc=Basic tutorial for using the EMAC OE SDK. | project=OE 5.0 }}<br />
* [[System_Log_In | System Log In]]<br />
* [[Linux_Filesystem_Organization | Linux Filesystem Organization]]<br />
* [[Remote_Debugging_EMAC_OE_SDK_with_gdbserver | Remote Debugging EMAC OE SDK Projects with gdbserver]]</div>Bserranohttps://wiki.emacinc.com/index.php?title=Getting_Started_With_Qt_Creator&diff=4262Getting Started With Qt Creator2015-04-07T20:03:35Z<p>Bserrano: </p>
<hr />
<div>{{todo| InProgress (02.03.2015-10:42->BS+)|Brian Serrano| project=OE 5.0,BS}}<br />
{{#seo:<br />
|title=Getting Started with Qt Creator<br />
|titlemode=append<br />
|keywords=Qt Creator, Tutorial, Qt Creator Examples<br />
|description=The following page can be used to get familiarized with EMAC Qt Creator.<br />
}}<br />
<br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /**************************************** Page Description Text ****************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
<span style="background:#00FF00;color:#FF0000;font-size:300%"></span><br />
The following page describes the process of getting familiar with EMAC Qt Creator.<br />
__TOC__<br />
<br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /***************************************** Background Information ****************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
{{:Templateimpl:bg | initials=BS | title=Getting Started with Qt Creator | desc=The following page can be used to get familiarized with EMAC Qt Creator. | project=OE 5.0 }}<br />
Qt Creator is a cross-platform Open Source Integrated Development Environment (IDE) that can be used to develop software for many different languages. It includes a visual debugger and an integrated GUI layout and forms designer. See the Qt Project site for more information http://qt-project.org/wiki/Category:Tools::QtCreator.<br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /***************************************** General Information *****************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
{{:Templateimpl:geninfo | initials=BS | title=Getting Started with Qt Creator | desc=The following page can be used to get familiarized with EMAC Qt Creator. | project=OE 5.0 }}<br />
=== Tools Required ===<br />
* EMAC OE SDK 5.0<br />
* EMAC Qt Creator<br />
* GNU ''make''<br />
* ''cmake''<br />
=== Setup === <br />
# Make sure the system is [[Configuring_Qt_Creator | configured]] for the correct target machine and that the IP and user/password are set.<br />
# Launch EMAC Qt Creator.<br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /***************************************** Using/Working With ******************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
{{:Templateimpl:using | initials=BS | title=Getting Started with Qt Creator | desc=The following page can be used to get familiarized with EMAC Qt Creator. | project=OE 5.0 }}<br />
<br />
After installing EMAC SDK, launch the EMAC Qt Creator desktop icon.<br />
<br />
1. Press the Start key or Alt + F2 and search for Qt Creator EMAC<br />
<br />
2. Put the Qt Creator EMAC icon on the Launcher for easy access.<br />
<br />
[[File:Qt_Creator_Icon.png|600px|left|thumb|Figure 1: Qt Launcher Icon]]<br />
<br clear=all><br />
<br />
3. To generate a new project from Qt Creator, select '''New Project''' on the opening splash window. The examples being used are all written in <code> C programming </code> language.<br />
<br />
[[File:Qtcreator_gui.png|600px|left|thumb|Figure 2: Qt Creator GUI]]<br />
<br clear=all><br />
<br />
4. After selecting '''New Project''' a new window will pop up. To run a <code> C programming </code> example using EMAC hardware, select '''EMAC Project''' under the Projects tab. Then select '''EMAC C Project (CMake Build)'''. Click the '''Choose''' button on the bottom right of window to continue to the next page as shown in Figure 3.<br />
<br />
[[File:EMAC_C_Project.png|600px|left|thumb|Figure 3: Qt Creator EMAC Project]]<br />
<br clear=all><br />
<br />
5. The next page will be '''Introduction and Project Location'''. Select a name for the <code> C </code> project. Once the project name is given, choose a a directory to store the project. Note: It is highly recommended to store your project other than the default location. For this example, we used ''/home/developer/Projects''.<br />
<br />
[[File:Project_location1.png|600px|left|thumb|Figure 4: Qt Creator Project Location]]<br />
<br clear=all><br />
<br />
6. The next page summarizes the '''EMAC C Project'''. Click '''Finish''' to continue.<br />
<br />
[[File:Project_summary1.png|600px|left|thumb|Figure 5: Qt Creator Project Summary]]<br />
<br clear=all><br />
<br />
7. Next, it will prompt you to the '''CMake Wizard Build Location'''. Click '''Next''' to continue. Note: It is highly recommended to use the default build directory as stated below in Figure 6. <br />
<br />
[[File:Build_location.png|600px|left|thumb|Figure 6: Qt Creator Build Location]] <br />
<br clear=all><br />
<br />
8. '''CMake Wizard''' will then prompt you to '''Run CMake'''. For setting up the Desktop Kit, click '''Run CMake''' and the output should be similar to Figure 7 below. Click '''Finish''' to start new project.<br />
<br />
[[File:Run_cmake1.png|600px|left|thumb|Figure 7: Qt Creator Run CMake]]<br />
<br clear=all><br />
<br />
9. The next step is to setup your device which you'll be using for the Qt Creator examples. Click Tools -> Options<br />
{{note|The board being used will be the iPac-9x25. The iPac-9x25 is a 32-bit ARM architecture. Make sure to connect power, Ethernet, and serial to the board.}}<br />
<br />
10. Select '''Devices''' from the left pane.<br />
<br />
[[File:Options_devices.png|600px|left|thumb|Figure 8: Qt Creator Device Option]] <br />
<br clear=all><br />
<br />
11. Click the '''Add''' button <br />
<br />
12. Select Generic Linux Device, then click '''Start Wizard'''.<br />
<br />
[[File:Generic_linux.png|600px|left|thumb|Figure 9: Qt Creator Wizard Selection]]<br />
<br clear=all><br />
<br />
13. Type in a name, the IP address, user name and password for the device. Use the credentials below to sign in.<br />
<br />
{| class="wikitable"<br />
!colspan="2"|Table 4: Default Login Credentials <br />
|-<br />
! Username !! Password<br />
|-<br />
| root || emac_inc<br />
|}<br />
<br />
[[File:Device_connection.png|600px|left|thumb|Figure 10: Qt Creator Configuration Setup]]<br />
<br clear=all><br />
<br />
14. Click '''Next'''.<br />
<br />
15. Click '''Finish'''.<br />
<br />
16. A connection will be established with the target device.<br />
<br />
[[File:Device_test.png|600px|left|thumb|Figure 11: Qt Creator Device Test]]<br />
<br clear=all><br />
<br />
17. Click '''Close'''.<br />
<br />
18. Click '''Apply'''.<br />
<br />
19. Once the Desktop Kit is configured, and the device is setup the hardware architecture kit needs to be installed. Navigate to '''Add Kit''' in the '''Projects''' tab. Under '''Add Kit''' select the architecture for the board being used. Click '''EMAC OE 5.0 arm'''. <br />
<br />
<br />
[[File:Add_kit_arm.jpg|600px|left|thumb|Figure 12: Qt Creator Add Kit]]<br />
<br clear=all><br />
<br />
20. As previously stated in step 7 it will prompt you to the '''CMake Wizard Build Location'''. Click '''Next''' to continue. Note: It is highly recommended to use the default build directory as stated below in Figure 13.<br />
<br />
[[File:Add_arm.png|600px|left|thumb|Figure 13: Qt Creator Add Kit Build Location]]<br />
<br clear=all><br />
<br />
21. '''CMake Wizard''' will then prompt you to '''Run CMake'''. For setting up the iPac-9x25 arm kit, click the box next to '''Arguments'''. Copy and paste the string below: <br />
''-DARCH:STRING=arm''<br />
<br />
[[File:Arm_argument_string.png|600px|left|thumb|Figure 14: Qt Creator Argument String]] <br />
<br clear=all><br />
<br />
EMAC SDK provides another architectural kit for x86 hardware. If using an x86 architecture, copy and paste the argument string below in the '''Arguments''' box. <br />
''-DARCH:STRING=x86'' <br />
<br />
22. Once the arguments string is pasted in the box, click '''Run CMake''' and the output should be similar to Figure 15 below. Click '''Finish''' to add the arm kit to the current project.<br />
<br />
[[File:Run_arm_cmake.png|600px|left|thumb|Figure 15: Qt Creator Run CMake]] <br />
<br clear=all><br />
<br />
23. To confirm if the kits installed correctly, click on the '''Kit Selector''' tab (Monitor symbol) on the left hand side of the Qt Creator window as shown in Figure 16. Both '''Desktop''' and '''OE 5.0 arm''' kit will be present.<br />
<br />
[[File:Arm_kit.jpg|600px|left|thumb|Figure 16: Qt Creator Kits Installed]] <br />
<br clear=all><br />
<br />
24. To run the example projects on the target board remotely, you'll need to add it to the '''Run Configuration'''. Click on '''Projects'''.<br />
<br />
25. Select '''Run''' under the '''OE 5.0 arm''' tab.<br />
<br />
26. Next to '''Run Configuration''', click on '''Add''' and select your project name (on Remote Generic Linux Host). In this case, our project name is Prime_Numbers (on Remote Generic Linux Host).<br />
<br />
[[File:Run_config.jpg|600px|left|thumb|Figure 17: Qt Creator Run Configuration]]<br />
<br clear=all><br />
<br />
You are now all set up to run the examples below on Qt Creator.<br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /***************************************** Examples *****************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
{{:Templateimpl:examples | initials=BS | title=Getting Started with Qt Creator | desc=The following page can be used to get familiarized with EMAC Qt Creator. | project=OE 5.0 }}<br />
This section will show how to run <code> C programming </code> examples through the Qt Creator IDE. The example board will be the iPac-9x25. <br />
<br />
The first example is a basic <code> hello c </code> example project. <br />
<br />
1. After creating a new project and installing the necessary kits for the target board, navigate to the '''Edit''' tab on Qt Creator. Qt Creator will automatically have the <code> hello c </code> example uploaded as shown in Figure 18.<br />
<br />
<syntaxhighlight lang="c"><br />
#include <stdio.h><br />
#include <stdlib.h><br />
<br />
int main(int argc, char * argv[])<br />
{<br />
printf("Hello EMAC OE!\n");<br />
<br />
exit(EXIT_SUCCESS);<br />
}<br />
</syntaxhighlight><br />
<br />
[[File:Edit_window.png|600px|left|thumb|Figure 18: Qt Creator Edit Window]] <br />
<br clear=all><br />
<br />
2. Before executing the example, you must build the program first. Click on the build icon (hammer symbol) on the bottom left of Qt Creator. If the build was successful, a green bar will fill on the bottom right of the window.<br />
<br />
3. Once the program successfully builds, you can now run the program. Click on the run icon (green arrow symbol) on the left hand side of Qt Creator. The program prints <code> Hello EMAC OE! </code> in the '''Application Output''' terminal. <br />
<br />
[[File:Final_output.png|600px|left|thumb|Figure 19: Qt Creator Edit Window]]<br />
<br clear=all><br />
<br />
The second example will show how to run a <code> c programming </code> project on a target board. This example will show all prime numbers from 1 - 100 and output it on Qt Creator remote terminal.<br />
<br />
1. Create a new project and install the necessary kits for the target board just as shown before. Call this project <code> Prime_Numbers </code>. Then Navigate to the '''Edit''' tab on Qt Creator. Copy and paste the following code below to the Qt Creator terminal. <br />
<br />
<syntaxhighlight lang="c"><br />
#include <stdio.h><br />
#include <stdlib.h><br />
<br />
int main(int argc, char * argv[])<br />
{ <br />
int i;<br />
int j;<br />
<br />
for (i = 2; i <= 100; i++)<br />
{<br />
for (j = 2; j <= i; j++)<br />
{<br />
if (i%j==0)<br />
{<br />
break;<br />
}<br />
}<br />
if (i == j)<br />
{<br />
printf ("%d is a prime number. \n", i);<br />
}<br />
}<br />
return 0;<br />
}<br />
</syntaxhighlight><br />
<br />
[[File:Prime_Numbers_edit.png|600px|left|thumb|Figure 210: Qt Creator Edit Window]] <br />
<br clear=all><br />
<br />
2. Click on the build icon (hammer symbol) on the bottom left of the Qt Creator. If the build was successful, a green bar will fill on the bottom right of Qt Creator.<br />
<br />
3. Click on the run icon (green arrow symbol) on the left hand side of Qt Creator. The program prints all prime numbers from 1 - 100 in the '''Application Output''' terminal. <br />
<br />
[[File:Final_Prime_Numbers.png|600px|left|thumb|Figure 21: Qt Creator Edit Window]] <br />
<br clear=all><br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /****************************************** Conclusion ******************************************/ --> <br />
<!-- /*********************************************************************************************************/ --><br />
{{:Templateimpl:conclusion | initials=BS | title=Getting Started with Qt Creator | desc=The following page can be used to get familiarized with EMAC Qt Creator. | project=OE 5.0 }}<br />
This page is a quick getting started tutorial on how to use EMAC Qt Creator for the first time. It shows you how to create an EMAC C Project, set up the necessary kits for your target board, setup your target board, and how to build and run example projects. <br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /****************************************** More Information *****************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
{{:Templateimpl:moreinfo | initials=BS | title=Getting Started with Qt Creator | desc=The following page can be used to get familiarized with EMAC Qt Creator. | project=OE 5.0 }}<br />
* '''TBD'''<br />
<br />
{{:Templateimpl:whatnext | initials=BS | title=Getting Started with Qt Creator | desc=The following page can be used to get familiarized with EMAC Qt Creator. | project=OE 5.0 }}<br />
* '''TBD'''</div>Bserranohttps://wiki.emacinc.com/index.php?title=Getting_Started_with_the_EMAC_OE_SDK&diff=4261Getting Started with the EMAC OE SDK2015-04-07T20:03:05Z<p>Bserrano: </p>
<hr />
<div>{{todo| InProgress (03.31.2015-13:42->BS+)|Brian Serrano| project=OE 5.0,BS }}<br />
{{#seo:<br />
|title=Getting Started with the EMAC OE SDK<br />
|titlemode=append<br />
|keywords=<br />
|description=Basic tutorial for using the EMAC OE SDK.<br />
}}<br />
<br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /**************************************** Page Description Text ****************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
<span style="background:#00FF00;color:#FF0000;font-size:300%"></span><br />
A Basic tutorial for using the EMAC OE SDK.<br />
__TOC__<br />
<br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /***************************************** General Information *****************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
{{:Templateimpl:geninfo | initials=BS | title=Getting Started with the EMAC OE SDK | desc=Basic tutorial for using the EMAC OE SDK. | project=OE 5.0 }}<br />
The EMAC Open Embedded SDK is distributed in an archive that can be extracted and used from a Linux terminal or from within an integrated development environment such as Qt Creator.<br />
<br />
Each SDK includes the C/C++ header files and libraries compatible with the target hardware. It also includes the C/C++ cross-compiler toolchain components necessary to compile and debug custom application code. Follow the links below to get started building and running the example projects on the target hardware.<br />
<br />
For more information on using Qt Creator with the EMAC SDK visit the [[Getting_Started_With_Qt_Creator |Getting Started With Qt Creator]] page.<br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /***************************************** Using/Working With ******************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
{{:Templateimpl:using | initials=BS | title=Getting Started with the EMAC OE SDK | desc=Basic tutorial for using the EMAC OE SDK. | project=OE 5.0 }} <br />
=== Connecting to a Target Board ===<br />
The next step after establishing a physical connection to the board is logging in. EMAC OE Linux allows login from getty, and SSH (Secure Shell). A getty uses the serial connection or console while SSH utilizes a network connection. For more information visit the [[System_Log_In | System Log In]] page.<br />
<br />
=== Setting up the Filesystem Read-Write ===<br />
To set up the root filesytem read-write, enter the following into the terminal: <br />
{{cli | oemntrw | hostname=ipac9x25}}<br />
<br />
To revert back the root filesytem to read-only, enter the following into the terminal:<br />
{{cli | oemntrw -r | hostname=ipac9x25}}<br />
<br />
=== Transferring Files ===<br />
The command line syntax for transferring a file using the SSH protocol is <code>scp file user@host:/directory</code>. SCP or Secure Copy is a way of securely transferring files between a local and remote host. For example, to send the file ''example.text'' to the <code>/home</code> directory of a system with the IP address 10.0.6.221, enter the following command:<br />
{{cli | username=developer | hostname=ldc | scp example.text root@10.0.6.221:/home }}<br />
<br />
=== Remote Execution ===<br />
SSH can also be used to execute programs on remote systems without logging in. The syntax for SSH remote execution is <code>ssh user@host "my_command -args file"</code>. For example, to run the program ''hello_world'' with the ''-hi'' flags on a system with the IP address of 10.0.6.221, enter the following command:<br />
{{cli | username=developer | hostname=ldc | ssh root@10.0.6.221 "/path/to/executable -args" }} <br />
<br /><br />
Be aware that this copy operation will fail if the filesystem on the remote machine is mounted read-only, which is the default on most EMAC systems.<br />
<br />
=== Basic Compiling ===<br />
==== Host Machine Compiling ====<br />
Create a file called hello.c using a text editor such as vi, vim, nano, or gedit.<br />
<br />
Use the following syntax to compile the program called hello.c:<br />
{{cli | username=developer | hostname=ldc | gcc -o hello hello.c }}<br />
<br />
If there is no error in your code then the compiler will successfully create an executable file called hello in the current directory. <br />
<br />
To verify this, enter the following command:<br />
{{clo|indent=2}}<br />
{{clio | username=developer | hostname=ldc | ls -l hello* }}<br />
-rwxrwxr-x 1 bserrano bserrano 9583 Apr 6 12:45 hello <br /><br />
-rwxr-xr-x 1 bserrano bserrano 129 Apr 6 12:28 hello.c <br />
{{clos}}<br />
<br />
To run the program, enter the following command:<br />
{{clo|indent=2}}<br />
{{clio | username=developer | hostname=ldc | ./hello }}<br />
Hello EMAC OE!<br />
{{clos}}<br />
<br />
OR<br />
{{clo|indent=2}}<br />
{{clio | username=developer | hostname=ldc | /path/to/hello }}<br />
Hello EMAC OE!<br />
{{clos}}<br />
<br />
==== Target Board Compiling ====<br />
{{note|In these examples we are using the Ipac-9x25 board. So depending on your board architecture it will determine which file needs to be source. These files come from the EMAC SDK toolchain.}}<br />
<br />
To compile on the target board, you must <code>source</code> the <code>environment-setup-armv5te-emac-linux-gnueabi</code> file.<br />
{{cli | username=developer | hostname=ldc | source /opt/emac/5.0/environment-setup-armv5te-emac-linux-gnueabi }}<br />
<br />
Once you are in the directory with the source file, enter the following command:<br />
{{cli | username=developer | hostname=ldc | $CC -o hello hello.c }}<br />
<br />
{{note|Once you source the file in your current terminal, you can only use it to cross-compile your program for the target board. You can no longer compile it for your host machine. To compile it to your host machine, simply open a new terminal.}}<br />
<br />
After sourcing the file, copy the program over to the target board using <code>scp</code>. Enter the following command:<br />
{{clo|indent=2}}<br />
{{clio | username=developer | hostname=ldc | scp hello root@10.0.6.221: }}<br />
root@10.0.6.221's password: <br />
hello 100% 9583 9.4KB/s 00:00 <br />
{{clos}}<br />
<br />
After copying the program, you can now execute the program on the target board. Enter the following command:<br />
{{clo|indent=2}}<br />
{{clio | username=developer | hostname=ldc | ssh root@10.0.6.221 ./hello}}<br />
root@10.0.6.221's password: <br /> <br />
Hello EMAC OE!<br />
{{clos}}<br />
<br />
=== Linux Filesystem Organization ===<br />
In order to prevent confusion and promote portability, a standard was created for the organization of the Linux filesystem. To ensure future portability of software created today, promote maintainability of software, and ensure proper utilization of available storage on an embedded machine, this standard should be followed as much as possible. This document covers parts of the standard and gives information about the customizations made to it by EMAC OE to accommodate embedded hardware. A link is provided to the standards document which covers the organization of the Linux filesystem at the end of this document. For more information visit the [[Linux_Filesystem_Organization | Linux Filesystem Organization]] page.<br />
<br />
EMAC recommends ''/usr/local/bin'' as the location for software you deploy.<br />
<br />
/usr/local/bin<br />
<br />
<cl><br />
1. It is important to pay attention to the filesystem structure in order to ensure that your application will work as expected when the filesystem is in production. Reason for this:<br />
i. Only certain directories, such as ''/var/'' and ''/tmp/'', are writeable when the filesystem is read-only.<br />
* Only certain directories should contain executables, such as ''/bin/'', ''/usr/bin/'', and ''/usr/local/bin/''.<br />
* Following this directory structure properly will make it easier to port your software to a newer release of EMAC OE later on.<br />
</cl><br />
<br />
=== Remote Debugging ===<br />
Sometimes a program has no technical errors that cause the compile to fail, but fails to meet the developer's expectations when run. This is typically due to algorithm or data structure design errors which can be difficult to find with just visual inspection of the code. Because of this, it can be beneficial to run a debugger targeting the executable process. Debugging is the process of watching what is going on inside of another program while it is running. When a program is compiled with debug symbols included in the binary, it is possible to observe the source code and corresponding assembly code while running the debugger.<br />
<br />
When working with embedded systems the binary is usually compiled on a development machine with a different CPU architecture than what is on the target machine. This can be a problem when, as is typically the case, the target machine lacks the system resources to run a debugger. In these cases, it is possible to use the GNU debugger, or GDB, on the development machine to remotely debug the target machine provided it has a program called gdbserver. All EMAC OE builds are packaged with gdbserver to simplify the setup process for developers.<br />
<br />
For more information visit the [[Remote_Debugging_EMAC_OE_SDK_with_gdbserver | Remote Debugging EMAC OE SDK Projects with gdbserver]] page.<br />
<br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /***************************************** Examples *****************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
{{:Templateimpl:examples | initials=BS | title=Getting Started with the EMAC OE SDK | desc=Basic tutorial for using the EMAC OE SDK. | project=OE 5.0 }}<br />
=== Hello World System Log Example ===<br />
This example will print <code>Hello EMAC OE!</code> to the syslog facility as well as the console. This will allow you to log, debug, and send status messages to the system logger.<br />
<br />
<syntaxhighlight lang="c"><br />
#include <stdio.h><br />
#include <stdlib.h><br />
#include <unistd.h><br />
#include <syslog.h><br />
<br />
int main(int argc, char** argv)<br />
{ <br />
char message[] = "Hello EMAC OE!";<br />
<br />
openlog("slog", LOG_PID|LOG_CONS, LOG_USER);<br />
syslog(LOG_INFO, "%s", message);<br />
closelog(); <br />
<br />
printf("%s\n", message);<br />
<br />
return 0;<br />
}<br />
</syntaxhighlight><br />
<br />
This is extremely useful because it allows you to save a record of the output that you might not see first hand.<br />
<br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /****************************************** More Information *****************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
{{:Templateimpl:moreinfo | initials=BS | title=Getting Started with the EMAC OE SDK | desc=Basic tutorial for using the EMAC OE SDK. | project=OE 5.0 }}<br />
* [[Getting_Started_With_Qt_Creator |Getting Started With Qt Creator]]<br />
<br />
{{:Templateimpl:whatnext | initials=BS | title=Getting Started with the EMAC OE SDK | desc=Basic tutorial for using the EMAC OE SDK. | project=OE 5.0 }}<br />
* [[System_Log_In | System Log In]]<br />
* [[Linux_Filesystem_Organization | Linux Filesystem Organization]]<br />
* [[Remote_Debugging_EMAC_OE_SDK_with_gdbserver | Remote Debugging EMAC OE SDK Projects with gdbserver]]</div>Bserranohttps://wiki.emacinc.com/index.php?title=Getting_Started_with_the_EMAC_OE_SDK&diff=4260Getting Started with the EMAC OE SDK2015-04-07T19:48:51Z<p>Bserrano: </p>
<hr />
<div>{{todo| InProgress (03.31.2015-13:42->BS+)|Brian Serrano| project=OE 5.0,BS }}<br />
{{#seo:<br />
|title=Getting Started with the EMAC OE SDK<br />
|titlemode=append<br />
|keywords=<br />
|description=Basic tutorial for using the EMAC OE SDK.<br />
}}<br />
<br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /**************************************** Page Description Text ****************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
<span style="background:#00FF00;color:#FF0000;font-size:300%">A Basic tutorial for using the EMAC OE SDK.</span><br />
<br />
__TOC__<br />
<br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /***************************************** General Information *****************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
{{:Templateimpl:geninfo | initials=BS | title=Getting Started with the EMAC OE SDK | desc=Basic tutorial for using the EMAC OE SDK. | project=OE 5.0 }}<br />
The EMAC Open Embedded SDK is distributed in an archive that can be extracted and used from a Linux terminal or from within an integrated development environment such as Qt Creator.<br />
<br />
Each SDK includes the C/C++ header files and libraries compatible with the target hardware. It also includes the C/C++ cross-compiler toolchain components necessary to compile and debug custom application code. Follow the links below to get started building and running the example projects on the target hardware.<br />
<br />
For more information on using Qt Creator with the EMAC SDK visit the [[Getting_Started_With_Qt_Creator |Getting Started With Qt Creator]] page.<br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /***************************************** Using/Working With ******************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
{{:Templateimpl:using | initials=BS | title=Getting Started with the EMAC OE SDK | desc=Basic tutorial for using the EMAC OE SDK. | project=OE 5.0 }} <br />
=== Connecting to a Target Board ===<br />
The next step after establishing a physical connection to the board is logging in. EMAC OE Linux allows login from getty, and SSH (Secure Shell). A getty uses the serial connection or console while SSH utilizes a network connection. For more information visit the [[System_Log_In | System Log In]] page.<br />
<br />
=== Setting up the Filesystem Read-Write ===<br />
To set up the root filesytem read-write, enter the following into the terminal: <br />
{{cli | oemntrw | hostname=ipac9x25}}<br />
<br />
To revert back the root filesytem to read-only, enter the following into the terminal:<br />
{{cli | oemntrw -r | hostname=ipac9x25}}<br />
<br />
=== Transferring Files ===<br />
The command line syntax for transferring a file using the SSH protocol is <code>scp file user@host:/directory</code>. SCP or Secure Copy is a way of securely transferring files between a local and remote host. For example, to send the file ''example.text'' to the <code>/home</code> directory of a system with the IP address 10.0.6.221, enter the following command:<br />
{{cli | username=developer | hostname=ldc | scp example.text root@10.0.6.221:/home }}<br />
<br />
=== Remote Execution ===<br />
SSH can also be used to execute programs on remote systems without logging in. The syntax for SSH remote execution is <code>ssh user@host "my_command -args file"</code>. For example, to run the program ''hello_world'' with the ''-hi'' flags on a system with the IP address of 10.0.6.221, enter the following command:<br />
{{cli | username=developer | hostname=ldc | ssh root@10.0.6.221 "/path/to/executable -args" }} <br />
<br /><br />
Be aware that this copy operation will fail if the filesystem on the remote machine is mounted read-only, which is the default on most EMAC systems.<br />
<br />
=== Basic Compiling ===<br />
==== Host Machine Compiling ====<br />
Create a file called hello.c using a text editor such as vi, vim, nano, or gedit.<br />
<br />
Use the following syntax to compile the program called hello.c:<br />
{{cli | username=developer | hostname=ldc | gcc -o hello hello.c }}<br />
<br />
If there is no error in your code then the compiler will successfully create an executable file called hello in the current directory. <br />
<br />
To verify this, enter the following command:<br />
{{clo|indent=2}}<br />
{{clio | username=developer | hostname=ldc | ls -l hello* }}<br />
-rwxrwxr-x 1 bserrano bserrano 9583 Apr 6 12:45 hello <br /><br />
-rwxr-xr-x 1 bserrano bserrano 129 Apr 6 12:28 hello.c <br />
{{clos}}<br />
<br />
To run the program, enter the following command:<br />
{{clo|indent=2}}<br />
{{clio | username=developer | hostname=ldc | ./hello }}<br />
Hello EMAC OE!<br />
{{clos}}<br />
<br />
OR<br />
{{clo|indent=2}}<br />
{{clio | username=developer | hostname=ldc | /path/to/hello }}<br />
Hello EMAC OE!<br />
{{clos}}<br />
<br />
==== Target Board Compiling ====<br />
{{note|In these examples we are using the Ipac-9x25 board. So depending on your board architecture it will determine which file needs to be source. These files come from the EMAC SDK toolchain.}}<br />
<br />
To compile on the target board, you must <code>source</code> the <code>environment-setup-armv5te-emac-linux-gnueabi</code> file.<br />
{{cli | username=developer | hostname=ldc | source /opt/emac/5.0/environment-setup-armv5te-emac-linux-gnueabi }}<br />
<br />
Once you are in the directory with the source file, enter the following command:<br />
{{cli | username=developer | hostname=ldc | $CC -o hello hello.c }}<br />
<br />
{{note|Once you source the file in your current terminal, you can only use it to cross-compile your program for the target board. You can no longer compile it for your host machine. To compile it to your host machine, simply open a new terminal.}}<br />
<br />
After sourcing the file, copy the program over to the target board using <code>scp</code>. Enter the following command:<br />
{{clo|indent=2}}<br />
{{clio | username=developer | hostname=ldc | scp hello root@10.0.6.221: }}<br />
root@10.0.6.221's password: <br />
hello 100% 9583 9.4KB/s 00:00 <br />
{{clos}}<br />
<br />
After copying the program, you can now execute the program on the target board. Enter the following command:<br />
{{clo|indent=2}}<br />
{{clio | username=developer | hostname=ldc | ssh root@10.0.6.221 ./hello}}<br />
root@10.0.6.221's password: <br /> <br />
Hello EMAC OE!<br />
{{clos}}<br />
<br />
=== Linux Filesystem Organization ===<br />
In order to prevent confusion and promote portability, a standard was created for the organization of the Linux filesystem. To ensure future portability of software created today, promote maintainability of software, and ensure proper utilization of available storage on an embedded machine, this standard should be followed as much as possible. This document covers parts of the standard and gives information about the customizations made to it by EMAC OE to accommodate embedded hardware. A link is provided to the standards document which covers the organization of the Linux filesystem at the end of this document. For more information visit the [[Linux_Filesystem_Organization | Linux Filesystem Organization]] page.<br />
<br />
EMAC recommends ''/usr/local/bin'' as the location for software you deploy.<br />
<br />
/usr/local/bin<br />
<br />
<cl><br />
1. It is important to pay attention to the filesystem structure in order to ensure that your application will work as expected when the filesystem is in production. Reason for this:<br />
i. Only certain directories, such as ''/var/'' and ''/tmp/'', are writeable when the filesystem is read-only.<br />
* Only certain directories should contain executables, such as ''/bin/'', ''/usr/bin/'', and ''/usr/local/bin/''.<br />
* Following this directory structure properly will make it easier to port your software to a newer release of EMAC OE later on.<br />
</cl><br />
<br />
=== Remote Debugging ===<br />
Sometimes a program has no technical errors that cause the compile to fail, but fails to meet the developer's expectations when run. This is typically due to algorithm or data structure design errors which can be difficult to find with just visual inspection of the code. Because of this, it can be beneficial to run a debugger targeting the executable process. Debugging is the process of watching what is going on inside of another program while it is running. When a program is compiled with debug symbols included in the binary, it is possible to observe the source code and corresponding assembly code while running the debugger.<br />
<br />
When working with embedded systems the binary is usually compiled on a development machine with a different CPU architecture than what is on the target machine. This can be a problem when, as is typically the case, the target machine lacks the system resources to run a debugger. In these cases, it is possible to use the GNU debugger, or GDB, on the development machine to remotely debug the target machine provided it has a program called gdbserver. All EMAC OE builds are packaged with gdbserver to simplify the setup process for developers.<br />
<br />
For more information visit the [[Remote_Debugging_EMAC_OE_SDK_with_gdbserver | Remote Debugging EMAC OE SDK Projects with gdbserver]] page.<br />
<br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /***************************************** Examples *****************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
{{:Templateimpl:examples | initials=BS | title=Getting Started with the EMAC OE SDK | desc=Basic tutorial for using the EMAC OE SDK. | project=OE 5.0 }}<br />
=== Hello World System Log Example ===<br />
This example will print <code>Hello EMAC OE!</code> to the syslog facility as well as the console. This will allow you to log, debug, and send status messages to the system logger.<br />
<br />
<syntaxhighlight lang="c"><br />
#include <stdio.h><br />
#include <stdlib.h><br />
#include <unistd.h><br />
#include <syslog.h><br />
<br />
int main(int argc, char** argv)<br />
{ <br />
char message[] = "Hello EMAC OE!";<br />
<br />
openlog("slog", LOG_PID|LOG_CONS, LOG_USER);<br />
syslog(LOG_INFO, "%s", message);<br />
closelog(); <br />
<br />
printf("%s\n", message);<br />
<br />
return 0;<br />
}<br />
</syntaxhighlight><br />
<br />
This is extremely useful because it allows you to save a record of the output that you might not see first hand.<br />
<br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /****************************************** More Information *****************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
{{:Templateimpl:moreinfo | initials=BS | title=Getting Started with the EMAC OE SDK | desc=Basic tutorial for using the EMAC OE SDK. | project=OE 5.0 }}<br />
* [[Getting_Started_With_Qt_Creator |Getting Started With Qt Creator]]<br />
<br />
{{:Templateimpl:whatnext | initials=BS | title=Getting Started with the EMAC OE SDK | desc=Basic tutorial for using the EMAC OE SDK. | project=OE 5.0 }}<br />
* [[System_Log_In | System Log In]]<br />
* [[Linux_Filesystem_Organization | Linux Filesystem Organization]]<br />
* [[Remote_Debugging_EMAC_OE_SDK_with_gdbserver | Remote Debugging EMAC OE SDK Projects with gdbserver]]</div>Bserranohttps://wiki.emacinc.com/index.php?title=Getting_Started_with_the_EMAC_OE_SDK&diff=4259Getting Started with the EMAC OE SDK2015-04-07T19:12:12Z<p>Bserrano: </p>
<hr />
<div>{{todo| InProgress (03.31.2015-13:42->BS+)|Brian Serrano| project=OE 5.0,BS }}<br />
{{#seo:<br />
|title=Getting Started with the EMAC OE SDK<br />
|titlemode=append<br />
|keywords=<br />
|description=Basic tutorial for using the EMAC OE SDK.<br />
}}<br />
<br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /**************************************** Page Description Text ****************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
<span style="background:#00FF00;color:#FF0000;font-size:300%">'''''A Basic tutorial for using the EMAC OE SDK.'''''</span><br />
<br />
__TOC__<br />
<br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /***************************************** General Information *****************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
{{:Templateimpl:geninfo | initials=BS | title=Getting Started with the EMAC OE SDK | desc=Basic tutorial for using the EMAC OE SDK. | project=OE 5.0 }}<br />
The EMAC Open Embedded SDK is distributed in an archive that can be extracted and used from a Linux terminal or from within an integrated development environment such as Qt Creator.<br />
<br />
Each SDK includes the C/C++ header files and libraries compatible with the target hardware. It also includes the C/C++ cross-compiler toolchain components necessary to compile and debug custom application code. Follow the links below to get started building and running the example projects on the target hardware.<br />
<br />
For more information on using Qt Creator with the EMAC SDK visit the [[Getting_Started_With_Qt_Creator |Getting Started With Qt Creator]] page.<br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /***************************************** Using/Working With ******************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
{{:Templateimpl:using | initials=BS | title=Getting Started with the EMAC OE SDK | desc=Basic tutorial for using the EMAC OE SDK. | project=OE 5.0 }} <br />
=== Connecting to a Target Board ===<br />
The next step after establishing a physical connection to the board is logging in. EMAC OE Linux allows login from getty, and SSH (Secure Shell). A getty uses the serial connection or console while SSH utilizes a network connection. For more information visit the [[System_Log_In | System Log In]] page.<br />
<br />
=== Setting up the Filesystem Read-Write ===<br />
To set up the root filesytem read-write, enter the following into the terminal: <br />
{{cli | oemntrw | hostname=ipac9x25}}<br />
<br />
To revert back the root filesytem to read-only, enter the following into the terminal:<br />
{{cli | oemntrw -r | hostname=ipac9x25}}<br />
<br />
=== Transferring Files ===<br />
The command line syntax for transferring a file using the SSH protocol is <code>scp file user@host:/directory</code>. SCP or Secure Copy is a way of securely transferring files between a local and remote host. For example, to send the file ''example.text'' to the <code>/home</code> directory of a system with the IP address 10.0.6.221, enter the following command:<br />
{{cli | username=developer | hostname=ldc | scp example.text root@10.0.6.221:/home }}<br />
<br />
=== Remote Execution ===<br />
SSH can also be used to execute programs on remote systems without logging in. The syntax for SSH remote execution is <code>ssh user@host "my_command -args file"</code>. For example, to run the program ''hello_world'' with the ''-hi'' flags on a system with the IP address of 10.0.6.221, enter the following command:<br />
{{cli | username=developer | hostname=ldc | ssh root@10.0.6.221 "/path/to/executable -args" }} <br />
<br /><br />
Be aware that this copy operation will fail if the filesystem on the remote machine is mounted read-only, which is the default on most EMAC systems.<br />
<br />
=== Basic Compiling ===<br />
==== Host Machine Compiling ====<br />
Create a file called hello.c using a text editor such as vi, vim, nano, or gedit.<br />
<br />
Use the following syntax to compile the program called hello.c:<br />
{{cli | username=developer | hostname=ldc | gcc -o hello hello.c }}<br />
<br />
If there is no error in your code then the compiler will successfully create an executable file called hello in the current directory. <br />
<br />
To verify this, enter the following command:<br />
{{clo|indent=2}}<br />
{{clio | username=developer | hostname=ldc | ls -l hello* }}<br />
-rwxrwxr-x 1 bserrano bserrano 9583 Apr 6 12:45 hello <br /><br />
-rwxr-xr-x 1 bserrano bserrano 129 Apr 6 12:28 hello.c <br />
{{clos}}<br />
<br />
To run the program, enter the following command:<br />
{{clo|indent=2}}<br />
{{clio | username=developer | hostname=ldc | ./hello }}<br />
Hello EMAC OE!<br />
{{clos}}<br />
<br />
OR<br />
{{clo|indent=2}}<br />
{{clio | username=developer | hostname=ldc | /path/to/hello }}<br />
Hello EMAC OE!<br />
{{clos}}<br />
<br />
==== Target Board Compiling ====<br />
{{note|In these examples we are using the Ipac-9x25 board. So depending on your board architecture it will determine which file needs to be source. These files come from the EMAC SDK toolchain.}}<br />
<br />
To compile on the target board, you must <code>source</code> the <code>environment-setup-armv5te-emac-linux-gnueabi</code> file.<br />
{{cli | username=developer | hostname=ldc | source /opt/emac/5.0/environment-setup-armv5te-emac-linux-gnueabi }}<br />
<br />
Once you are in the directory with the source file, enter the following command:<br />
{{cli | username=developer | hostname=ldc | $CC -o hello hello.c }}<br />
<br />
{{note|Once you source the file in your current terminal, you can only use it to cross-compile your program for the target board. You can no longer compile it for your host machine. To compile it to your host machine, simply open a new terminal.}}<br />
<br />
After sourcing the file, copy the program over to the target board using <code>scp</code>. Enter the following command:<br />
{{clo|indent=2}}<br />
{{clio | username=developer | hostname=ldc | scp hello root@10.0.6.221: }}<br />
root@10.0.6.221's password: <br />
hello 100% 9583 9.4KB/s 00:00 <br />
{{clos}}<br />
<br />
After copying the program, you can now execute the program on the target board. Enter the following command:<br />
{{clo|indent=2}}<br />
{{clio | username=developer | hostname=ldc | ssh root@10.0.6.221 ./hello}}<br />
root@10.0.6.221's password: <br /> <br />
Hello EMAC OE!<br />
{{clos}}<br />
<br />
=== Linux Filesystem Organization ===<br />
In order to prevent confusion and promote portability, a standard was created for the organization of the Linux filesystem. To ensure future portability of software created today, promote maintainability of software, and ensure proper utilization of available storage on an embedded machine, this standard should be followed as much as possible. This document covers parts of the standard and gives information about the customizations made to it by EMAC OE to accommodate embedded hardware. A link is provided to the standards document which covers the organization of the Linux filesystem at the end of this document. For more information visit the [[Linux_Filesystem_Organization | Linux Filesystem Organization]] page.<br />
<br />
EMAC recommends ''/usr/local/bin'' as the location for software you deploy.<br />
<br />
/usr/local/bin<br />
<br />
<cl><br />
1. It is important to pay attention to the filesystem structure in order to ensure that your application will work as expected when the filesystem is in production. Reason for this:<br />
i. Only certain directories, such as ''/var/'' and ''/tmp/'', are writeable when the filesystem is read-only.<br />
* Only certain directories should contain executables, such as ''/bin/'', ''/usr/bin/'', and ''/usr/local/bin/''.<br />
* Following this directory structure properly will make it easier to port your software to a newer release of EMAC OE later on.<br />
</cl><br />
<br />
=== Remote Debugging ===<br />
Sometimes a program has no technical errors that cause the compile to fail, but fails to meet the developer's expectations when run. This is typically due to algorithm or data structure design errors which can be difficult to find with just visual inspection of the code. Because of this, it can be beneficial to run a debugger targeting the executable process. Debugging is the process of watching what is going on inside of another program while it is running. When a program is compiled with debug symbols included in the binary, it is possible to observe the source code and corresponding assembly code while running the debugger.<br />
<br />
When working with embedded systems the binary is usually compiled on a development machine with a different CPU architecture than what is on the target machine. This can be a problem when, as is typically the case, the target machine lacks the system resources to run a debugger. In these cases, it is possible to use the GNU debugger, or GDB, on the development machine to remotely debug the target machine provided it has a program called gdbserver. All EMAC OE builds are packaged with gdbserver to simplify the setup process for developers.<br />
<br />
For more information visit the [[Remote_Debugging_EMAC_OE_SDK_with_gdbserver | Remote Debugging EMAC OE SDK Projects with gdbserver]] page.<br />
<br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /***************************************** Examples *****************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
{{:Templateimpl:examples | initials=BS | title=Getting Started with the EMAC OE SDK | desc=Basic tutorial for using the EMAC OE SDK. | project=OE 5.0 }}<br />
=== Hello World System Log Example ===<br />
This example will print <code>Hello EMAC OE!</code> to the syslog facility as well as the console. This will allow you to log, debug, and send status messages to the system logger.<br />
<br />
<syntaxhighlight lang="c"><br />
#include <stdio.h><br />
#include <stdlib.h><br />
#include <unistd.h><br />
#include <syslog.h><br />
<br />
int main(int argc, char** argv)<br />
{ <br />
char message[] = "Hello EMAC OE!";<br />
<br />
openlog("slog", LOG_PID|LOG_CONS, LOG_USER);<br />
syslog(LOG_INFO, "%s", message);<br />
closelog(); <br />
<br />
printf("%s\n", message);<br />
<br />
return 0;<br />
}<br />
</syntaxhighlight><br />
<br />
This is extremely useful because it allows you to save a record of the output that you might not see first hand.<br />
<br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /****************************************** More Information *****************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
{{:Templateimpl:moreinfo | initials=BS | title=Getting Started with the EMAC OE SDK | desc=Basic tutorial for using the EMAC OE SDK. | project=OE 5.0 }}<br />
* [[Getting_Started_With_Qt_Creator |Getting Started With Qt Creator]]<br />
<br />
{{:Templateimpl:whatnext | initials=BS | title=Getting Started with the EMAC OE SDK | desc=Basic tutorial for using the EMAC OE SDK. | project=OE 5.0 }}<br />
* [[System_Log_In | System Log In]]<br />
* [[Linux_Filesystem_Organization | Linux Filesystem Organization]]<br />
* [[Remote_Debugging_EMAC_OE_SDK_with_gdbserver | Remote Debugging EMAC OE SDK Projects with gdbserver]]</div>Bserranohttps://wiki.emacinc.com/index.php?title=Getting_Started_with_the_EMAC_OE_SDK&diff=4258Getting Started with the EMAC OE SDK2015-04-06T17:55:00Z<p>Bserrano: </p>
<hr />
<div>{{todo| InProgress (03.31.2015-13:42->BS+)|Brian Serrano| project=OE 5.0,BS }}<br />
{{#seo:<br />
|title=Getting Started with the EMAC OE SDK<br />
|titlemode=append<br />
|keywords=<br />
|description=Basic tutorial for using the EMAC OE SDK.<br />
}}<br />
<br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /**************************************** Page Description Text ****************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
<span style="background:#00FF00;color:#FF0000;font-size:300%">'''''Put the page description text here.'''''</span><br />
<br />
__TOC__<br />
<br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /***************************************** General Information *****************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
{{:Templateimpl:geninfo | initials=BS | title=Getting Started with the EMAC OE SDK | desc=Basic tutorial for using the EMAC OE SDK. | project=OE 5.0 }}<br />
The EMAC Open Embedded SDK is distributed in an archive that can be extracted and used from a Linux terminal or from within an integrated development environment such as Qt Creator.<br />
<br />
Each SDK includes the C/C++ header files and libraries compatible with the target hardware. It also includes the C/C++ cross-compiler toolchain components necessary to compile and debug custom application code. Follow the links below to get started building and running the example projects on the target hardware.<br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /***************************************** Using/Working With ******************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
{{:Templateimpl:using | initials=BS | title=Getting Started with the EMAC OE SDK | desc=Basic tutorial for using the EMAC OE SDK. | project=OE 5.0 }} <br />
=== Connecting to a Target Board ===<br />
The next step after establishing a physical connection to the board is logging in. EMAC OE Linux allows login from getty, and SSH (Secure Shell). A getty uses the serial connection or console while SSH utilizes a network connection. For more information visit the [[System_Log_In | System Log In]] page.<br />
<br />
=== Setting up the Filesystem Read-Write ===<br />
To set up the root filesytem read-write, enter the following into the terminal: <br />
{{cli | oemntrw | hostname=ipac9x25}}<br />
<br />
To revert back the root filesytem to read-only, enter the following into the terminal:<br />
{{cli | oemntrw -r | hostname=ipac9x25}}<br />
<br />
===Transferring Files===<br />
The command line syntax for transferring a file using the SSH protocol is <code>scp file user@host:/directory</code>. SCP or Secure Copy is a way of securely transferring files between a local and remote host. For example, to send the file ''example.text'' to the <code>/home</code> directory of a system with the IP address 10.0.6.221, enter the following command:<br />
{{cli | username=developer | hostname=ldc | scp example.text root@10.0.6.221:/home }}<br />
<br />
<br />
Be aware that this copy operation will fail if the filesystem on the remote machine is mounted read-only, which is the default on most EMAC systems.<br />
<br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /***************************************** Examples *****************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
{{:Templateimpl:examples | initials=BS | title=Getting Started with the EMAC OE SDK | desc=Basic tutorial for using the EMAC OE SDK. | project=OE 5.0 }}<br />
<br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /****************************************** Conclusion ******************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
{{:Templateimpl:conclusion | initials=BS | title=Getting Started with the EMAC OE SDK | desc=Basic tutorial for using the EMAC OE SDK. | project=OE 5.0 }}<br />
<br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /****************************************** More Information *****************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
{{:Templateimpl:moreinfo | initials=BS | title=Getting Started with the EMAC OE SDK | desc=Basic tutorial for using the EMAC OE SDK. | project=OE 5.0 }}<br />
* <br />
<br />
{{:Templateimpl:whatnext | initials=BS | title=Getting Started with the EMAC OE SDK | desc=Basic tutorial for using the EMAC OE SDK. | project=OE 5.0 }}<br />
*</div>Bserranohttps://wiki.emacinc.com/index.php?title=Getting_Started_with_the_EMAC_OE_SDK&diff=4257Getting Started with the EMAC OE SDK2015-04-06T14:15:38Z<p>Bserrano: </p>
<hr />
<div>{{todo| InProgress (03.31.2015-13:42->BS+)|Brian Serrano| project=OE 5.0,BS }}<br />
{{#seo:<br />
|title=Getting Started with the EMAC OE SDK<br />
|titlemode=append<br />
|keywords=<br />
|description=Basic tutorial for using the EMAC OE SDK.<br />
}}<br />
<br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /**************************************** Page Description Text ****************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
<span style="background:#00FF00;color:#FF0000;font-size:300%">'''''Put the page description text here.'''''</span><br />
<br />
__TOC__<br />
<br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /***************************************** General Information *****************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
{{:Templateimpl:geninfo | initials=BS | title=Getting Started with the EMAC OE SDK | desc=Basic tutorial for using the EMAC OE SDK. | project=OE 5.0 }}<br />
The EMAC Open Embedded SDK is distributed in an archive that can be extracted and used from a Linux terminal or from within an integrated development environment such as Qt Creator.<br />
<br />
Each SDK includes the C/C++ header files and libraries compatible with the target hardware. It also includes the C/C++ cross-compiler toolchain components necessary to compile and debug custom application code. Follow the links below to get started building and running the example projects on the target hardware.<br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /***************************************** Using/Working With ******************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
{{:Templateimpl:using | initials=BS | title=Getting Started with the EMAC OE SDK | desc=Basic tutorial for using the EMAC OE SDK. | project=OE 5.0 }} <br />
=== Connecting to a Target Board ===<br />
The next step after establishing a physical connection to the board is logging in. EMAC OE Linux allows login from getty, and SSH (Secure Shell). A getty uses the serial connection or console while SSH utilizes a network connection. For more information visit the [[System_Log_In | System Log In]] page.<br />
<br />
=== Setting up the Filesystem Read-Write ===<br />
To set up the root filesytem read-write, enter the following into the terminal: <br />
{{cli | oemntrw | hostname=ipac9x25}}<br />
<br />
To revert back the root filesytem to read-only, enter the following into the terminal:<br />
{{cli | oemntrw -r | hostname=ipac9x25}}<br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /***************************************** Examples *****************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
{{:Templateimpl:examples | initials=BS | title=Getting Started with the EMAC OE SDK | desc=Basic tutorial for using the EMAC OE SDK. | project=OE 5.0 }}<br />
<br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /****************************************** Conclusion ******************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
{{:Templateimpl:conclusion | initials=BS | title=Getting Started with the EMAC OE SDK | desc=Basic tutorial for using the EMAC OE SDK. | project=OE 5.0 }}<br />
<br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /****************************************** More Information *****************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
{{:Templateimpl:moreinfo | initials=BS | title=Getting Started with the EMAC OE SDK | desc=Basic tutorial for using the EMAC OE SDK. | project=OE 5.0 }}<br />
* <br />
<br />
{{:Templateimpl:whatnext | initials=BS | title=Getting Started with the EMAC OE SDK | desc=Basic tutorial for using the EMAC OE SDK. | project=OE 5.0 }}<br />
*</div>Bserranohttps://wiki.emacinc.com/index.php?title=Getting_Started_with_the_EMAC_OE_SDK&diff=4256Getting Started with the EMAC OE SDK2015-04-01T15:46:48Z<p>Bserrano: </p>
<hr />
<div>{{todo| InProgress (03.31.2015-13:42->BS+)|Brian Serrano| project=OE 5.0,BS }}<br />
{{#seo:<br />
|title=Getting Started with the EMAC OE SDK<br />
|titlemode=append<br />
|keywords=<br />
|description=Basic tutorial for using the EMAC OE SDK.<br />
}}<br />
<br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /**************************************** Page Description Text ****************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
<span style="background:#00FF00;color:#FF0000;font-size:300%">'''''Put the page description text here.'''''</span><br />
<br />
__TOC__<br />
<br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /***************************************** General Information *****************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
{{:Templateimpl:geninfo | initials=BS | title=Getting Started with the EMAC OE SDK | desc=Basic tutorial for using the EMAC OE SDK. | project=OE 5.0 }}<br />
The EMAC Open Embedded SDK is distributed in an archive that can be extracted and used from a Linux terminal or from within an integrated development environment such as Qt Creator.<br />
<br />
Each SDK includes the C/C++ header files and libraries compatible with the target hardware. It also includes the C/C++ cross-compiler toolchain components necessary to compile and debug custom application code. Follow the links below to get started building and running the example projects on the target hardware.<br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /***************************************** Using/Working With ******************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
{{:Templateimpl:using | initials=BS | title=Getting Started with the EMAC OE SDK | desc=Basic tutorial for using the EMAC OE SDK. | project=OE 5.0 }} <br />
=== Connecting to a Target Board ===<br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /***************************************** Examples *****************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
{{:Templateimpl:examples | initials=BS | title=Getting Started with the EMAC OE SDK | desc=Basic tutorial for using the EMAC OE SDK. | project=OE 5.0 }}<br />
<br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /****************************************** Conclusion ******************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
{{:Templateimpl:conclusion | initials=BS | title=Getting Started with the EMAC OE SDK | desc=Basic tutorial for using the EMAC OE SDK. | project=OE 5.0 }}<br />
<br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /****************************************** More Information *****************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
{{:Templateimpl:moreinfo | initials=BS | title=Getting Started with the EMAC OE SDK | desc=Basic tutorial for using the EMAC OE SDK. | project=OE 5.0 }}<br />
* <br />
<br />
{{:Templateimpl:whatnext | initials=BS | title=Getting Started with the EMAC OE SDK | desc=Basic tutorial for using the EMAC OE SDK. | project=OE 5.0 }}<br />
*</div>Bserranohttps://wiki.emacinc.com/index.php?title=Getting_Started_with_the_EMAC_OE_SDK&diff=4255Getting Started with the EMAC OE SDK2015-03-31T18:42:32Z<p>Bserrano: </p>
<hr />
<div>{{todo| InProgress (03.31.2015-13:42->BS+)|Brian Serrano| project=OE 5.0,BS }}<br />
{{#seo:<br />
|title=Getting Started with the EMAC OE SDK<br />
|titlemode=append<br />
|keywords=<br />
|description=Basic tutorial for using the EMAC OE SDK.<br />
}}<br />
<br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /**************************************** Page Description Text ****************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
<span style="background:#00FF00;color:#FF0000;font-size:300%">'''''Put the page description text here.'''''</span><br />
<br />
__TOC__<br />
<br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /***************************************** Background Information ****************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
{{:Templateimpl:bg | initials=BS | title=Getting Started with the EMAC OE SDK | desc=Basic tutorial for using the EMAC OE SDK. | project=OE 5.0 }}<br />
<br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /***************************************** General Information *****************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
{{:Templateimpl:geninfo | initials=BS | title=Getting Started with the EMAC OE SDK | desc=Basic tutorial for using the EMAC OE SDK. | project=OE 5.0 }}<br />
<br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /***************************************** Using/Working With ******************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
{{:Templateimpl:using | initials=BS | title=Getting Started with the EMAC OE SDK | desc=Basic tutorial for using the EMAC OE SDK. | project=OE 5.0 }}<br />
<br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /***************************************** Examples *****************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
{{:Templateimpl:examples | initials=BS | title=Getting Started with the EMAC OE SDK | desc=Basic tutorial for using the EMAC OE SDK. | project=OE 5.0 }}<br />
<br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /****************************************** Conclusion ******************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
{{:Templateimpl:conclusion | initials=BS | title=Getting Started with the EMAC OE SDK | desc=Basic tutorial for using the EMAC OE SDK. | project=OE 5.0 }}<br />
<br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /****************************************** More Information *****************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
{{:Templateimpl:moreinfo | initials=BS | title=Getting Started with the EMAC OE SDK | desc=Basic tutorial for using the EMAC OE SDK. | project=OE 5.0 }}<br />
* <br />
<br />
{{:Templateimpl:whatnext | initials=BS | title=Getting Started with the EMAC OE SDK | desc=Basic tutorial for using the EMAC OE SDK. | project=OE 5.0 }}<br />
*</div>Bserranohttps://wiki.emacinc.com/index.php?title=Getting_Started_with_the_EMAC_OE_SDK&diff=4254Getting Started with the EMAC OE SDK2015-03-31T18:42:07Z<p>Bserrano: Created page with "{{ subst:Pgtempl | initials={{subst::Templateimpl:getinitials}} | project=OE 5.0 | title=Getting Started with the EMAC OE SDK | desc=Basic tutorial for using the EMAC OE SDK. }}"</p>
<hr />
<div>{{todo| NotStarted (03.31.2015-13:42->BS+)| Bserrano | project=OE 5.0,BS }}<br />
{{#seo:<br />
|title=Getting Started with the EMAC OE SDK<br />
|titlemode=append<br />
|keywords=<br />
|description=Basic tutorial for using the EMAC OE SDK.<br />
}}<br />
<br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /**************************************** Page Description Text ****************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
<span style="background:#00FF00;color:#FF0000;font-size:300%">'''''Put the page description text here.'''''</span><br />
<br />
__TOC__<br />
<br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /***************************************** Background Information ****************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
{{:Templateimpl:bg | initials=BS | title=Getting Started with the EMAC OE SDK | desc=Basic tutorial for using the EMAC OE SDK. | project=OE 5.0 }}<br />
<br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /***************************************** General Information *****************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
{{:Templateimpl:geninfo | initials=BS | title=Getting Started with the EMAC OE SDK | desc=Basic tutorial for using the EMAC OE SDK. | project=OE 5.0 }}<br />
<br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /***************************************** Using/Working With ******************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
{{:Templateimpl:using | initials=BS | title=Getting Started with the EMAC OE SDK | desc=Basic tutorial for using the EMAC OE SDK. | project=OE 5.0 }}<br />
<br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /***************************************** Examples *****************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
{{:Templateimpl:examples | initials=BS | title=Getting Started with the EMAC OE SDK | desc=Basic tutorial for using the EMAC OE SDK. | project=OE 5.0 }}<br />
<br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /****************************************** Conclusion ******************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
{{:Templateimpl:conclusion | initials=BS | title=Getting Started with the EMAC OE SDK | desc=Basic tutorial for using the EMAC OE SDK. | project=OE 5.0 }}<br />
<br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /****************************************** More Information *****************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
{{:Templateimpl:moreinfo | initials=BS | title=Getting Started with the EMAC OE SDK | desc=Basic tutorial for using the EMAC OE SDK. | project=OE 5.0 }}<br />
* <br />
<br />
{{:Templateimpl:whatnext | initials=BS | title=Getting Started with the EMAC OE SDK | desc=Basic tutorial for using the EMAC OE SDK. | project=OE 5.0 }}<br />
*</div>Bserranohttps://wiki.emacinc.com/index.php?title=Getting_Started_With_Qt_Creator&diff=4253Getting Started With Qt Creator2015-03-24T15:46:31Z<p>Bserrano: </p>
<hr />
<div>{{todo| InProgress (02.03.2015-10:42->BS+)|Brian Serrano| project=OE 5.0,BS}}<br />
{{#seo:<br />
|title=Getting Started with Qt Creator<br />
|titlemode=append<br />
|keywords=Qt Creator, Tutorial, Qt Creator Examples<br />
|description=The following page can be used to get familiarized with EMAC Qt Creator.<br />
}}<br />
<br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /**************************************** Page Description Text ****************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
<span style="background:#00FF00;color:#FF0000;font-size:300%">'''''The following page describes the process of getting familiar with EMAC Qt Creator.'''''</span><br />
<br />
__TOC__<br />
<br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /***************************************** Background Information ****************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
{{:Templateimpl:bg | initials=BS | title=Getting Started with Qt Creator | desc=The following page can be used to get familiarized with EMAC Qt Creator. | project=OE 5.0 }}<br />
Qt Creator is a cross-platform Open Source Integrated Development Environment (IDE) that can be used to develop software for many different languages. It includes a visual debugger and an integrated GUI layout and forms designer. See the Qt Project site for more information http://qt-project.org/wiki/Category:Tools::QtCreator.<br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /***************************************** General Information *****************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
{{:Templateimpl:geninfo | initials=BS | title=Getting Started with Qt Creator | desc=The following page can be used to get familiarized with EMAC Qt Creator. | project=OE 5.0 }}<br />
=== Tools Required ===<br />
* EMAC OE SDK 5.0<br />
* EMAC Qt Creator<br />
* GNU ''make''<br />
* ''cmake''<br />
=== Setup === <br />
# Make sure the system is [[Configuring_Qt_Creator | configured]] for the correct target machine and that the IP and user/password are set.<br />
# Launch EMAC Qt Creator.<br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /***************************************** Using/Working With ******************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
{{:Templateimpl:using | initials=BS | title=Getting Started with Qt Creator | desc=The following page can be used to get familiarized with EMAC Qt Creator. | project=OE 5.0 }}<br />
<br />
After installing EMAC SDK, launch the EMAC Qt Creator desktop icon.<br />
<br />
1. Press the Start key or Alt + F2 and search for Qt Creator EMAC<br />
<br />
2. Put the Qt Creator EMAC icon on the Launcher for easy access.<br />
<br />
[[File:Qt_Creator_Icon.png|600px|left|thumb|Figure 1: Qt Launcher Icon]]<br />
<br clear=all><br />
<br />
3. To generate a new project from Qt Creator, select '''New Project''' on the opening splash window. The examples being used are all written in <code> C programming </code> language.<br />
<br />
[[File:Qtcreator_gui.png|600px|left|thumb|Figure 2: Qt Creator GUI]]<br />
<br clear=all><br />
<br />
4. After selecting '''New Project''' a new window will pop up. To run a <code> C programming </code> example using EMAC hardware, select '''EMAC Project''' under the Projects tab. Then select '''EMAC C Project (CMake Build)'''. Click the '''Choose''' button on the bottom right of window to continue to the next page as shown in Figure 3.<br />
<br />
[[File:EMAC_C_Project.png|600px|left|thumb|Figure 3: Qt Creator EMAC Project]]<br />
<br clear=all><br />
<br />
5. The next page will be '''Introduction and Project Location'''. Select a name for the <code> C </code> project. Once the project name is given, choose a a directory to store the project. Note: It is highly recommended to store your project other than the default location. For this example, we used ''/home/developer/Projects''.<br />
<br />
[[File:Project_location1.png|600px|left|thumb|Figure 4: Qt Creator Project Location]]<br />
<br clear=all><br />
<br />
6. The next page summarizes the '''EMAC C Project'''. Click '''Finish''' to continue.<br />
<br />
[[File:Project_summary1.png|600px|left|thumb|Figure 5: Qt Creator Project Summary]]<br />
<br clear=all><br />
<br />
7. Next, it will prompt you to the '''CMake Wizard Build Location'''. Click '''Next''' to continue. Note: It is highly recommended to use the default build directory as stated below in Figure 6. <br />
<br />
[[File:Build_location.png|600px|left|thumb|Figure 6: Qt Creator Build Location]] <br />
<br clear=all><br />
<br />
8. '''CMake Wizard''' will then prompt you to '''Run CMake'''. For setting up the Desktop Kit, click '''Run CMake''' and the output should be similar to Figure 7 below. Click '''Finish''' to start new project.<br />
<br />
[[File:Run_cmake1.png|600px|left|thumb|Figure 7: Qt Creator Run CMake]]<br />
<br clear=all><br />
<br />
9. The next step is to setup your device which you'll be using for the Qt Creator examples. Click Tools -> Options<br />
{{note|The board being used will be the iPac-9x25. The iPac-9x25 is a 32-bit ARM architecture. Make sure to connect power, Ethernet, and serial to the board.}}<br />
<br />
10. Select '''Devices''' from the left pane.<br />
<br />
[[File:Options_devices.png|600px|left|thumb|Figure 8: Qt Creator Device Option]] <br />
<br clear=all><br />
<br />
11. Click the '''Add''' button <br />
<br />
12. Select Generic Linux Device, then click '''Start Wizard'''.<br />
<br />
[[File:Generic_linux.png|600px|left|thumb|Figure 9: Qt Creator Wizard Selection]]<br />
<br clear=all><br />
<br />
13. Type in a name, the IP address, user name and password for the device. Use the credentials below to sign in.<br />
<br />
{| class="wikitable"<br />
!colspan="2"|Table 4: Default Login Credentials <br />
|-<br />
! Username !! Password<br />
|-<br />
| root || emac_inc<br />
|}<br />
<br />
[[File:Device_connection.png|600px|left|thumb|Figure 10: Qt Creator Configuration Setup]]<br />
<br clear=all><br />
<br />
14. Click '''Next'''.<br />
<br />
15. Click '''Finish'''.<br />
<br />
16. A connection will be established with the target device.<br />
<br />
[[File:Device_test.png|600px|left|thumb|Figure 11: Qt Creator Device Test]]<br />
<br clear=all><br />
<br />
17. Click '''Close'''.<br />
<br />
18. Click '''Apply'''.<br />
<br />
19. Once the Desktop Kit is configured, and the device is setup the hardware architecture kit needs to be installed. Navigate to '''Add Kit''' in the '''Projects''' tab. Under '''Add Kit''' select the architecture for the board being used. Click '''EMAC OE 5.0 arm'''. <br />
<br />
<br />
[[File:Add_kit_arm.jpg|600px|left|thumb|Figure 12: Qt Creator Add Kit]]<br />
<br clear=all><br />
<br />
20. As previously stated in step 7 it will prompt you to the '''CMake Wizard Build Location'''. Click '''Next''' to continue. Note: It is highly recommended to use the default build directory as stated below in Figure 13.<br />
<br />
[[File:Add_arm.png|600px|left|thumb|Figure 13: Qt Creator Add Kit Build Location]]<br />
<br clear=all><br />
<br />
21. '''CMake Wizard''' will then prompt you to '''Run CMake'''. For setting up the iPac-9x25 arm kit, click the box next to '''Arguments'''. Copy and paste the string below: <br />
''-DARCH:STRING=arm''<br />
<br />
[[File:Arm_argument_string.png|600px|left|thumb|Figure 14: Qt Creator Argument String]] <br />
<br clear=all><br />
<br />
EMAC SDK provides another architectural kit for x86 hardware. If using an x86 architecture, copy and paste the argument string below in the '''Arguments''' box. <br />
''-DARCH:STRING=x86'' <br />
<br />
22. Once the arguments string is pasted in the box, click '''Run CMake''' and the output should be similar to Figure 15 below. Click '''Finish''' to add the arm kit to the current project.<br />
<br />
[[File:Run_arm_cmake.png|600px|left|thumb|Figure 15: Qt Creator Run CMake]] <br />
<br clear=all><br />
<br />
23. To confirm if the kits installed correctly, click on the '''Kit Selector''' tab (Monitor symbol) on the left hand side of the Qt Creator window as shown in Figure 16. Both '''Desktop''' and '''OE 5.0 arm''' kit will be present.<br />
<br />
[[File:Arm_kit.jpg|600px|left|thumb|Figure 16: Qt Creator Kits Installed]] <br />
<br clear=all><br />
<br />
24. To run the example projects on the target board remotely, you'll need to add it to the '''Run Configuration'''. Click on '''Projects'''.<br />
<br />
25. Select '''Run''' under the '''OE 5.0 arm''' tab.<br />
<br />
26. Next to '''Run Configuration''', click on '''Add''' and select your project name (on Remote Generic Linux Host). In this case, our project name is Prime_Numbers (on Remote Generic Linux Host).<br />
<br />
[[File:Run_config.jpg|600px|left|thumb|Figure 17: Qt Creator Run Configuration]]<br />
<br clear=all><br />
<br />
You are now all set up to run the examples below on Qt Creator.<br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /***************************************** Examples *****************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
{{:Templateimpl:examples | initials=BS | title=Getting Started with Qt Creator | desc=The following page can be used to get familiarized with EMAC Qt Creator. | project=OE 5.0 }}<br />
This section will show how to run <code> C programming </code> examples through the Qt Creator IDE. The example board will be the iPac-9x25. <br />
<br />
The first example is a basic <code> hello c </code> example project. <br />
<br />
1. After creating a new project and installing the necessary kits for the target board, navigate to the '''Edit''' tab on Qt Creator. Qt Creator will automatically have the <code> hello c </code> example uploaded as shown in Figure 18.<br />
<br />
<syntaxhighlight lang="c"><br />
#include <stdio.h><br />
#include <stdlib.h><br />
<br />
int main(int argc, char * argv[])<br />
{<br />
printf("Hello EMAC OE!\n");<br />
<br />
exit(EXIT_SUCCESS);<br />
}<br />
</syntaxhighlight><br />
<br />
[[File:Edit_window.png|600px|left|thumb|Figure 18: Qt Creator Edit Window]] <br />
<br clear=all><br />
<br />
2. Before executing the example, you must build the program first. Click on the build icon (hammer symbol) on the bottom left of Qt Creator. If the build was successful, a green bar will fill on the bottom right of the window.<br />
<br />
3. Once the program successfully builds, you can now run the program. Click on the run icon (green arrow symbol) on the left hand side of Qt Creator. The program prints <code> Hello EMAC OE! </code> in the '''Application Output''' terminal. <br />
<br />
[[File:Final_output.png|600px|left|thumb|Figure 19: Qt Creator Edit Window]]<br />
<br clear=all><br />
<br />
The second example will show how to run a <code> c programming </code> project on a target board. This example will show all prime numbers from 1 - 100 and output it on Qt Creator remote terminal.<br />
<br />
1. Create a new project and install the necessary kits for the target board just as shown before. Call this project <code> Prime_Numbers </code>. Then Navigate to the '''Edit''' tab on Qt Creator. Copy and paste the following code below to the Qt Creator terminal. <br />
<br />
<syntaxhighlight lang="c"><br />
#include <stdio.h><br />
#include <stdlib.h><br />
<br />
int main(int argc, char * argv[])<br />
{ <br />
int i;<br />
int j;<br />
<br />
for (i = 2; i <= 100; i++)<br />
{<br />
for (j = 2; j <= i; j++)<br />
{<br />
if (i%j==0)<br />
{<br />
break;<br />
}<br />
}<br />
if (i == j)<br />
{<br />
printf ("%d is a prime number. \n", i);<br />
}<br />
}<br />
return 0;<br />
}<br />
</syntaxhighlight><br />
<br />
[[File:Prime_Numbers_edit.png|600px|left|thumb|Figure 210: Qt Creator Edit Window]] <br />
<br clear=all><br />
<br />
2. Click on the build icon (hammer symbol) on the bottom left of the Qt Creator. If the build was successful, a green bar will fill on the bottom right of Qt Creator.<br />
<br />
3. Click on the run icon (green arrow symbol) on the left hand side of Qt Creator. The program prints all prime numbers from 1 - 100 in the '''Application Output''' terminal. <br />
<br />
[[File:Final_Prime_Numbers.png|600px|left|thumb|Figure 21: Qt Creator Edit Window]] <br />
<br clear=all><br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /****************************************** Conclusion ******************************************/ --> <br />
<!-- /*********************************************************************************************************/ --><br />
{{:Templateimpl:conclusion | initials=BS | title=Getting Started with Qt Creator | desc=The following page can be used to get familiarized with EMAC Qt Creator. | project=OE 5.0 }}<br />
This page is a quick getting started tutorial on how to use EMAC Qt Creator for the first time. It shows you how to create an EMAC C Project, set up the necessary kits for your target board, setup your target board, and how to build and run example projects. <br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /****************************************** More Information *****************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
{{:Templateimpl:moreinfo | initials=BS | title=Getting Started with Qt Creator | desc=The following page can be used to get familiarized with EMAC Qt Creator. | project=OE 5.0 }}<br />
* '''TBD'''<br />
<br />
{{:Templateimpl:whatnext | initials=BS | title=Getting Started with Qt Creator | desc=The following page can be used to get familiarized with EMAC Qt Creator. | project=OE 5.0 }}<br />
* '''TBD'''</div>Bserranohttps://wiki.emacinc.com/index.php?title=Getting_Started_With_Qt_Creator&diff=4251Getting Started With Qt Creator2015-03-16T14:44:36Z<p>Bserrano: </p>
<hr />
<div>{{todo| NotStarted (02.03.2015-10:42->BS+)|Brian Serrano| project=OE 5.0,BS }}<br />
{{#seo:<br />
|title=Getting Started with Qt Creator<br />
|titlemode=append<br />
|keywords=Qt Creator, Tutorial, Qt Creator Examples<br />
|description=The following page can be used to get familiarized with EMAC Qt Creator.<br />
}}<br />
<br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /**************************************** Page Description Text ****************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
<span style="background:#00FF00;color:#FF0000;font-size:300%">'''''The following page describes the process of getting familiar with EMAC Qt Creator.'''''</span><br />
<br />
__TOC__<br />
<br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /***************************************** Background Information ****************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
{{:Templateimpl:bg | initials=BS | title=Getting Started with Qt Creator | desc=The following page can be used to get familiarized with EMAC Qt Creator. | project=OE 5.0 }}<br />
Qt Creator is a cross-platform Open Source Integrated Development Environment (IDE) that can be used to develop software for many different languages. It includes a visual debugger and an integrated GUI layout and forms designer. See the Qt Project site for more information http://qt-project.org/wiki/Category:Tools::QtCreator.<br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /***************************************** General Information *****************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
{{:Templateimpl:geninfo | initials=BS | title=Getting Started with Qt Creator | desc=The following page can be used to get familiarized with EMAC Qt Creator. | project=OE 5.0 }}<br />
=== Tools Required ===<br />
* EMAC OE SDK 5.0<br />
* EMAC Qt Creator<br />
* GNU ''make''<br />
* ''cmake''<br />
=== Setup === <br />
# Make sure the system is [[Configuring_Qt_Creator | configured]] for the correct target machine and that the IP and user/password are set.<br />
# Launch EMAC Qt Creator.<br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /***************************************** Using/Working With ******************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
{{:Templateimpl:using | initials=BS | title=Getting Started with Qt Creator | desc=The following page can be used to get familiarized with EMAC Qt Creator. | project=OE 5.0 }}<br />
<br />
After installing EMAC SDK, launch the EMAC Qt Creator desktop icon.<br />
<br />
1. Press the Start key or Alt + F2 and search for Qt Creator EMAC<br />
<br />
2. Put the Qt Creator EMAC icon on the Launcher for easy access.<br />
<br />
[[File:Qt_Creator_Icon.png|600px|left|thumb|Figure 1: Qt Launcher Icon]]<br />
<br clear=all><br />
<br />
3. To generate a new project from Qt Creator, select '''New Project''' on the opening splash window. The examples being used are all written in <code> C programming </code> language.<br />
<br />
[[File:Qtcreator_gui.png|600px|left|thumb|Figure 2: Qt Creator GUI]]<br />
<br clear=all><br />
<br />
4. After selecting '''New Project''' a new window will pop up. To run a <code> C programming </code> example using EMAC hardware, select '''EMAC Project''' under the Projects tab. Then select '''EMAC C Project (CMake Build)'''. Click the '''Choose''' button on the bottom right of window to continue to the next page as shown in Figure 3.<br />
<br />
[[File:EMAC_C_Project.png|600px|left|thumb|Figure 3: Qt Creator EMAC Project]]<br />
<br clear=all><br />
<br />
5. The next page will be '''Introduction and Project Location'''. Select a name for the <code> C </code> project. Once the project name is given, choose a a directory to store the project. Note: It is highly recommended to store your project other than the default location. For this example, we used ''/home/developer/Projects''.<br />
<br />
[[File:Project_location1.png|600px|left|thumb|Figure 4: Qt Creator Project Location]]<br />
<br clear=all><br />
<br />
6. The next page summarizes the '''EMAC C Project'''. Click '''Finish''' to continue.<br />
<br />
[[File:Project_summary1.png|600px|left|thumb|Figure 5: Qt Creator Project Summary]]<br />
<br clear=all><br />
<br />
7. Next, it will prompt you to the '''CMake Wizard Build Location'''. Click '''Next''' to continue. Note: It is highly recommended to use the default build directory as stated below in Figure 6. <br />
<br />
[[File:Build_location.png|600px|left|thumb|Figure 6: Qt Creator Build Location]] <br />
<br clear=all><br />
<br />
8. '''CMake Wizard''' will then prompt you to '''Run CMake'''. For setting up the Desktop Kit, click '''Run CMake''' and the output should be similar to Figure 7 below. Click '''Finish''' to start new project.<br />
<br />
[[File:Run_cmake1.png|600px|left|thumb|Figure 7: Qt Creator Run CMake]]<br />
<br clear=all><br />
<br />
9. The next step is to setup your device which you'll be using for the Qt Creator examples. Click Tools -> Options<br />
{{note|The board being used will be the iPac-9x25. The iPac-9x25 is a 32-bit ARM architecture. Make sure to connect power, Ethernet, and serial to the board.}}<br />
<br />
10. Select '''Devices''' from the left pane.<br />
<br />
[[File:Options_devices.png|600px|left|thumb|Figure 8: Qt Creator Device Option]] <br />
<br clear=all><br />
<br />
11. Click the '''Add''' button <br />
<br />
12. Select Generic Linux Device, then click '''Start Wizard'''.<br />
<br />
[[File:Generic_linux.png|600px|left|thumb|Figure 9: Qt Creator Wizard Selection]]<br />
<br clear=all><br />
<br />
13. Type in a name, the IP address, user name and password for the device. Use the credentials below to sign in.<br />
<br />
{| class="wikitable"<br />
!colspan="2"|Table 4: Default Login Credentials <br />
|-<br />
! Username !! Password<br />
|-<br />
| root || emac_inc<br />
|}<br />
<br />
[[File:Device_connection.png|600px|left|thumb|Figure 10: Qt Creator Configuration Setup]]<br />
<br clear=all><br />
<br />
14. Click '''Next'''.<br />
<br />
15. Click '''Finish'''.<br />
<br />
16. A connection will be established with the target device.<br />
<br />
[[File:Device_test.png|600px|left|thumb|Figure 11: Qt Creator Device Test]]<br />
<br clear=all><br />
<br />
17. Click '''Close'''.<br />
<br />
18. Click '''Apply'''.<br />
<br />
19. Once the Desktop Kit is configured, and the device is setup the hardware architecture kit needs to be installed. Navigate to '''Add Kit''' in the '''Projects''' tab. Under '''Add Kit''' select the architecture for the board being used. Click '''EMAC OE 5.0 arm'''. <br />
<br />
<br />
[[File:Add_kit_arm.jpg|600px|left|thumb|Figure 12: Qt Creator Add Kit]]<br />
<br clear=all><br />
<br />
20. As previously stated in step 7 it will prompt you to the '''CMake Wizard Build Location'''. Click '''Next''' to continue. Note: It is highly recommended to use the default build directory as stated below in Figure 13.<br />
<br />
[[File:Add_arm.png|600px|left|thumb|Figure 13: Qt Creator Add Kit Build Location]]<br />
<br clear=all><br />
<br />
21. '''CMake Wizard''' will then prompt you to '''Run CMake'''. For setting up the iPac-9x25 arm kit, click the box next to '''Arguments'''. Copy and paste the string below: <br />
''-DARCH:STRING=arm''<br />
<br />
[[File:Arm_argument_string.png|600px|left|thumb|Figure 14: Qt Creator Argument String]] <br />
<br clear=all><br />
<br />
EMAC SDK provides another architectural kit for x86 hardware. If using an x86 architecture, copy and paste the argument string below in the '''Arguments''' box. <br />
''-DARCH:STRING=x86'' <br />
<br />
22. Once the arguments string is pasted in the box, click '''Run CMake''' and the output should be similar to Figure 15 below. Click '''Finish''' to add the arm kit to the current project.<br />
<br />
[[File:Run_arm_cmake.png|600px|left|thumb|Figure 15: Qt Creator Run CMake]] <br />
<br clear=all><br />
<br />
23. To confirm if the kits installed correctly, click on the '''Kit Selector''' tab (Monitor symbol) on the left hand side of the Qt Creator window as shown in Figure 16. Both '''Desktop''' and '''OE 5.0 arm''' kit will be present.<br />
<br />
[[File:Arm_kit.jpg|600px|left|thumb|Figure 16: Qt Creator Kits Installed]] <br />
<br clear=all><br />
<br />
24. To run the example projects on the target board remotely, you'll need to add it to the '''Run Configuration'''. Click on '''Projects'''.<br />
<br />
25. Select '''Run''' under the '''OE 5.0 arm''' tab.<br />
<br />
26. Next to '''Run Configuration''', click on '''Add''' and select your project name (on Remote Generic Linux Host). In this case, our project name is Prime_Numbers (on Remote Generic Linux Host).<br />
<br />
[[File:Run_config.jpg|600px|left|thumb|Figure 17: Qt Creator Run Configuration]]<br />
<br clear=all><br />
<br />
You are now all set up to run the examples below on Qt Creator.<br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /***************************************** Examples *****************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
{{:Templateimpl:examples | initials=BS | title=Getting Started with Qt Creator | desc=The following page can be used to get familiarized with EMAC Qt Creator. | project=OE 5.0 }}<br />
This section will show how to run <code> C programming </code> examples through the Qt Creator IDE. The example board will be the iPac-9x25. <br />
<br />
The first example is a basic <code> hello c </code> example project. <br />
<br />
1. After creating a new project and installing the necessary kits for the target board, navigate to the '''Edit''' tab on Qt Creator. Qt Creator will automatically have the <code> hello c </code> example uploaded as shown in Figure 18.<br />
<br />
<syntaxhighlight lang="c"><br />
#include <stdio.h><br />
#include <stdlib.h><br />
<br />
int main(int argc, char * argv[])<br />
{<br />
printf("Hello EMAC OE!\n");<br />
<br />
exit(EXIT_SUCCESS);<br />
}<br />
</syntaxhighlight><br />
<br />
[[File:Edit_window.png|600px|left|thumb|Figure 18: Qt Creator Edit Window]] <br />
<br clear=all><br />
<br />
2. Before executing the example, you must build the program first. Click on the build icon (hammer symbol) on the bottom left of Qt Creator. If the build was successful, a green bar will fill on the bottom right of the window.<br />
<br />
3. Once the program successfully builds, you can now run the program. Click on the run icon (green arrow symbol) on the left hand side of Qt Creator. The program prints <code> Hello EMAC OE! </code> in the '''Application Output''' terminal. <br />
<br />
[[File:Final_output.png|600px|left|thumb|Figure 19: Qt Creator Edit Window]]<br />
<br clear=all><br />
<br />
The second example will show how to run a <code> c programming </code> project on a target board. This example will show all prime numbers from 1 - 100 and output it on Qt Creator remote terminal.<br />
<br />
1. Create a new project and install the necessary kits for the target board just as shown before. Call this project <code> Prime_Numbers </code>. Then Navigate to the '''Edit''' tab on Qt Creator. Copy and paste the following code below to the Qt Creator terminal. <br />
<br />
<syntaxhighlight lang="c"><br />
#include <stdio.h><br />
#include <stdlib.h><br />
<br />
int main(int argc, char * argv[])<br />
{ <br />
int i;<br />
int j;<br />
<br />
for (i = 2; i <= 100; i++)<br />
{<br />
for (j = 2; j <= i; j++)<br />
{<br />
if (i%j==0)<br />
{<br />
break;<br />
}<br />
}<br />
if (i == j)<br />
{<br />
printf ("%d is a prime number. \n", i);<br />
}<br />
}<br />
return 0;<br />
}<br />
</syntaxhighlight><br />
<br />
[[File:Prime_Numbers_edit.png|600px|left|thumb|Figure 210: Qt Creator Edit Window]] <br />
<br clear=all><br />
<br />
2. Click on the build icon (hammer symbol) on the bottom left of the Qt Creator. If the build was successful, a green bar will fill on the bottom right of Qt Creator.<br />
<br />
3. Click on the run icon (green arrow symbol) on the left hand side of Qt Creator. The program prints all prime numbers from 1 - 100 in the '''Application Output''' terminal. <br />
<br />
[[File:Final_Prime_Numbers.png|600px|left|thumb|Figure 21: Qt Creator Edit Window]] <br />
<br clear=all><br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /****************************************** Conclusion ******************************************/ --> <br />
<!-- /*********************************************************************************************************/ --><br />
{{:Templateimpl:conclusion | initials=BS | title=Getting Started with Qt Creator | desc=The following page can be used to get familiarized with EMAC Qt Creator. | project=OE 5.0 }}<br />
This page is a quick getting started tutorial on how to use EMAC Qt Creator for the first time. It shows you how to create an EMAC C Project, set up the necessary kits for your target board, setup your target board, and how to build and run example projects. <br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /****************************************** More Information *****************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
{{:Templateimpl:moreinfo | initials=BS | title=Getting Started with Qt Creator | desc=The following page can be used to get familiarized with EMAC Qt Creator. | project=OE 5.0 }}<br />
* '''TBD'''<br />
<br />
{{:Templateimpl:whatnext | initials=BS | title=Getting Started with Qt Creator | desc=The following page can be used to get familiarized with EMAC Qt Creator. | project=OE 5.0 }}<br />
* '''TBD'''</div>Bserranohttps://wiki.emacinc.com/index.php?title=Getting_Started_With_Qt_Creator&diff=4249Getting Started With Qt Creator2015-02-25T16:10:19Z<p>Bserrano: </p>
<hr />
<div>{{todo| NotStarted (02.03.2015-10:42->BS+)|Brian Serrano| project=OE 5.0,BS }}<br />
{{#seo:<br />
|title=Getting Started with Qt Creator<br />
|titlemode=append<br />
|keywords=Qt Creator, Tutorial, Qt Creator Examples<br />
|description=The following page can be used to get familiarized with EMAC Qt Creator.<br />
}}<br />
<br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /**************************************** Page Description Text ****************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
<span style="background:#00FF00;color:#FF0000;font-size:300%">'''''The following page describes the process of getting familiar with EMAC Qt Creator.'''''</span><br />
<br />
__TOC__<br />
<br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /***************************************** Background Information ****************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
{{:Templateimpl:bg | initials=BS | title=Getting Started with Qt Creator | desc=The following page can be used to get familiarized with EMAC Qt Creator. | project=OE 5.0 }}<br />
Qt Creator is a cross-platform Open Source Integrated Development Environment (IDE) that can be used to develop software for many different languages. It includes a visual debugger and an integrated GUI layout and forms designer. See the Qt Project site for more information http://qt-project.org/wiki/Category:Tools::QtCreator.<br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /***************************************** General Information *****************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
{{:Templateimpl:geninfo | initials=BS | title=Getting Started with Qt Creator | desc=The following page can be used to get familiarized with EMAC Qt Creator. | project=OE 5.0 }}<br />
=== Tools Required ===<br />
* EMAC OE SDK 5.0<br />
* EMAC Qt Creator<br />
* GNU ''make''<br />
* ''cmake''<br />
=== Setup === <br />
# Make sure the system is [[Configuring_Qt_Creator | configured]] for the correct target machine and that the IP and user/password are set.<br />
# Launch EMAC Qt Creator.<br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /***************************************** Using/Working With ******************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
{{:Templateimpl:using | initials=BS | title=Getting Started with Qt Creator | desc=The following page can be used to get familiarized with EMAC Qt Creator. | project=OE 5.0 }}<br />
<br />
After installing EMAC SDK, launch the EMAC Qt Creator desktop icon.<br />
<br />
1. Press the Windows key and search for '''Qt Creator EMAC'''<br />
<br />
2. Put the Qt Creator EMAC icon on the Launcher for easy access.<br />
<br />
[[File:Qt_Creator_Icon.png|600px|left|thumb|Figure 1: Qt Launcher Icon]]<br />
<br clear=all><br />
<br />
3. To generate a new project from Qt Creator, select '''New Project''' on the opening splash window. The examples being used are all written in <code> C programming </code> language.<br />
<br />
[[File:Qtcreator_gui.png|600px|left|thumb|Figure 2: Qt Creator GUI]]<br />
<br clear=all><br />
<br />
4. After selecting '''New Project''' a new window will pop up. To run a <code> C programming </code> example using EMAC hardware, select '''EMAC Project''' under the Projects tab. Then select '''EMAC C Project (CMake Build)'''. Click the '''Choose''' button on the bottom right of window to continue to the next page as shown in Figure 3.<br />
<br />
[[File:EMAC_C_Project.png|600px|left|thumb|Figure 3: Qt Creator EMAC Project]]<br />
<br clear=all><br />
<br />
5. The next page will be '''Introduction and Project Location'''. Select a name for the <code> C </code> project. Once the project name is given, choose a a directory to store the project. Note: It is highly recommended to store your project other than the default location. For this example, we used ''/home/developer/Projects''.<br />
<br />
[[File:Project_location1.png|600px|left|thumb|Figure 4: Qt Creator Project Location]]<br />
<br clear=all><br />
<br />
6. The next page summarizes the '''EMAC C Project'''. Click '''Finish''' to continue.<br />
<br />
[[File:Project_summary1.png|600px|left|thumb|Figure 5: Qt Creator Project Summary]]<br />
<br clear=all><br />
<br />
7. Next, it will prompt you to the '''CMake Wizard Build Location'''. Click '''Next''' to continue. Note: It is highly recommended to use the default build directory as stated below in Figure 6. <br />
<br />
[[File:Build_location.png|600px|left|thumb|Figure 6: Qt Creator Build Location]] <br />
<br clear=all><br />
<br />
8. '''CMake Wizard''' will then prompt you to '''Run CMake'''. For setting up the Desktop Kit, click '''Run CMake''' and the output should be similar to Figure 7 below. Click '''Finish''' to start new project.<br />
<br />
[[File:Run_cmake1.png|600px|left|thumb|Figure 7: Qt Creator Run CMake]]<br />
<br clear=all><br />
<br />
9. The next step is to setup your device which you'll be using for the Qt Creator examples. Click Tools -> Options<br />
{{note|The board being used will be the iPac-9x25. The iPac-9x25 is a 32-bit ARM architecture.}}<br />
<br />
10. Select '''Devices''' from the left pane.<br />
<br />
[[File:Options_devices.png|600px|left|thumb|Figure 8: Qt Creator Device Option]]<br />
<br clear=all><br />
<br />
11. Press the '''Add''' button<br />
<br />
12. Select Generic Linux Device, then press '''Start Wizard'''.<br />
<br />
[[File:Generic_linux.png|600px|left|thumb|Figure 9: Qt Creator Wizard Selection]]<br />
<br clear=all><br />
<br />
13. Type in a name, the IP address, user name and password for the device. Use the credentials below to sign in.<br />
<br />
{| class="wikitable"<br />
!colspan="2"|Table 4: Default Login Credentials <br />
|-<br />
! Username !! Password<br />
|-<br />
| root || emac_inc<br />
|}<br />
<br />
[[File:Device_connection.png|600px|left|thumb|Figure 10: Qt Creator Configuration Setup]]<br />
<br clear=all><br />
<br />
14. Click '''Next'''.<br />
<br />
15. Click '''Finish'''.<br />
<br />
16. A connection will be established with the target device.<br />
<br />
[[File:Device_test.png|600px|left|thumb|Figure 11: Qt Creator Device Test]]<br />
<br clear=all><br />
<br />
17. Click '''Close'''.<br />
<br />
18. Click '''Apply'''.<br />
<br />
19. Once the Desktop Kit is configured, and the device is setup the hardware architecture kit needs to be installed. Navigate to '''Add Kit''' in the '''Projects''' tab. Under '''Add Kit''' select the architecture for the board being used. Click '''EMAC OE 5.0 arm'''. <br />
<br />
<br />
[[File:Add_kit_arm.jpg|600px|left|thumb|Figure 12: Qt Creator Add Kit]]<br />
<br clear=all><br />
<br />
20. As previously stated in step 7 it will prompt you to the '''CMake Wizard Build Location'''. Click '''Next''' to continue. Note: It is highly recommended to use the default build directory as stated below in Figure 13.<br />
<br />
[[File:Add_arm.png|600px|left|thumb|Figure 13: Qt Creator Add Kit Build Location]]<br />
<br clear=all><br />
<br />
21. '''CMake Wizard''' will then prompt you to '''Run CMake'''. For setting up the iPac-9x25 arm kit, click the box next to '''Arguments'''. Copy and paste the string below: <br />
''-DARCH:STRING=arm''<br />
<br />
[[File:Arm_argument_string.png|600px|left|thumb|Figure 14: Qt Creator Argument String]]<br />
<br clear=all><br />
<br />
EMAC SDK provides another architectural kit for x86 hardware. If using an x86 architecture, copy and paste the argument string below in the '''Arguments''' box. <br />
''-DARCH:STRING=x86'' <br />
<br />
22. Once the arguments string is pasted in the box, click '''Run CMake''' and the output should be similar to Figure 15 below. Click '''Finish''' to add the arm kit to the current project.<br />
<br />
[[File:Run_arm_cmake.png|600px|left|thumb|Figure 15: Qt Creator Run CMake]]<br />
<br clear=all><br />
<br />
23. To confirm if the kits installed correctly, click on the '''Kit Selector''' tab (Monitor symbol) on the left hand side of the Qt Creator window as shown in Figure 16. Both '''Desktop''' and '''OE 5.0 arm''' kit will be present.<br />
<br />
[[File:Arm_kit.jpg|600px|left|thumb|Figure 16: Qt Creator Kits Installed]]<br />
<br clear=all><br />
<br />
24. To run the example projects on the target board remotely, you'll need to add it to the '''Run Configuration'''. Click on '''Projects'''.<br />
<br />
25. Select '''Run''' under the '''OE 5.0 arm''' tab.<br />
<br />
26. Next to '''Run Configuration''', click on '''Add''' and select your project name (on Remote Generic Linux Host). In this case, our project name is Prime_Numbers (on Remote Generic Linux Host).<br />
<br />
[[File:Run_config.jpg|600px|left|thumb|Figure 17: Qt Creator Run Configuration]]<br />
<br clear=all><br />
<br />
You are now all set up to run the examples below on Qt Creator.<br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /***************************************** Examples *****************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
{{:Templateimpl:examples | initials=BS | title=Getting Started with Qt Creator | desc=The following page can be used to get familiarized with EMAC Qt Creator. | project=OE 5.0 }}<br />
This section will show how to run <code> C programming </code> examples through the Qt Creator IDE. The example board will be the iPac-9x25. <br />
<br />
The first example is a basic <code> hello c </code> example project. <br />
<br />
1. After creating a new project and installing the necessary kits for the target board, navigate to the '''Edit''' tab on Qt Creator. Qt Creator will automatically have the <code> hello c </code> example uploaded as shown in Figure 18.<br />
<br />
<syntaxhighlight lang="c"><br />
#include <stdio.h><br />
#include <stdlib.h><br />
<br />
int main(int argc, char * argv[])<br />
{<br />
printf("Hello EMAC OE!\n");<br />
<br />
exit(EXIT_SUCCESS);<br />
}<br />
</syntaxhighlight><br />
<br />
[[File:Edit_window.png|600px|left|thumb|Figure 18: Qt Creator Edit Window]] <br />
<br clear=all><br />
<br />
2. Before executing the example, you must build the program first. Click on the build icon (hammer symbol) on the bottom left of Qt Creator. If the build was successful, a green bar will fill on the bottom right of the window.<br />
<br />
3. Once the program successfully builds, you can now run the program. Click on the run icon (green arrow symbol) on the left hand side of Qt Creator. The program prints <code> Hello EMAC OE! </code> in the '''Application Output''' terminal. <br />
<br />
[[File:Final_output.png|600px|left|thumb|Figure 19: Qt Creator Edit Window]]<br />
<br clear=all><br />
<br />
The second example will show how to run a <code> c programming </code> project on a target board. This example will show all prime numbers from 1 - 100 and output it on Qt Creator remote terminal.<br />
<br />
1. Create a new project and install the necessary kits for the target board just as shown before. Call this project <code> Prime_Numbers </code>. Then Navigate to the '''Edit''' tab on Qt Creator. Copy and paste the following code below to the Qt Creator terminal. <br />
<br />
<syntaxhighlight lang="c"><br />
#include <stdio.h><br />
#include <stdlib.h><br />
<br />
int main(int argc, char * argv[])<br />
{ <br />
int i;<br />
int j;<br />
<br />
for (i = 2; i <= 100; i++)<br />
{<br />
for (j = 2; j <= i; j++)<br />
{<br />
if (i%j==0)<br />
{<br />
break;<br />
}<br />
}<br />
if (i == j)<br />
{<br />
printf ("%d is a prime number. \n", i);<br />
}<br />
}<br />
return 0;<br />
}<br />
</syntaxhighlight><br />
<br />
[[File:Prime_Numbers_edit.png|600px|left|thumb|Figure 210: Qt Creator Edit Window]] <br />
<br clear=all><br />
<br />
2. Click on the build icon (hammer symbol) on the bottom left of the Qt Creator. If the build was successful, a green bar will fill on the bottom right of Qt Creator.<br />
<br />
3. Click on the run icon (green arrow symbol) on the left hand side of Qt Creator. The program prints all prime numbers from 1 - 100 in the '''Application Output''' terminal. <br />
<br />
[[File:Final_Prime_Numbers.png|600px|left|thumb|Figure 21: Qt Creator Edit Window]] <br />
<br clear=all><br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /****************************************** Conclusion ******************************************/ --> <br />
<!-- /*********************************************************************************************************/ --><br />
{{:Templateimpl:conclusion | initials=BS | title=Getting Started with Qt Creator | desc=The following page can be used to get familiarized with EMAC Qt Creator. | project=OE 5.0 }}<br />
This page is a quick getting started tutorial on how to use EMAC Qt Creator for the first time. It shows you how to create an EMAC C Project, set up the necessary kits for your target board, setup your target board, and how to build and run example projects. <br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /****************************************** More Information *****************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
{{:Templateimpl:moreinfo | initials=BS | title=Getting Started with Qt Creator | desc=The following page can be used to get familiarized with EMAC Qt Creator. | project=OE 5.0 }}<br />
* '''TBD'''<br />
<br />
{{:Templateimpl:whatnext | initials=BS | title=Getting Started with Qt Creator | desc=The following page can be used to get familiarized with EMAC Qt Creator. | project=OE 5.0 }}<br />
* '''TBD'''</div>Bserranohttps://wiki.emacinc.com/index.php?title=File:Run_config.jpg&diff=4248File:Run config.jpg2015-02-24T20:48:21Z<p>Bserrano: </p>
<hr />
<div></div>Bserranohttps://wiki.emacinc.com/index.php?title=File:Arm_run.png&diff=4247File:Arm run.png2015-02-24T20:35:27Z<p>Bserrano: </p>
<hr />
<div></div>Bserranohttps://wiki.emacinc.com/index.php?title=File:Remote_device.jpg&diff=4246File:Remote device.jpg2015-02-24T18:58:18Z<p>Bserrano: </p>
<hr />
<div></div>Bserranohttps://wiki.emacinc.com/index.php?title=File:Device_test.png&diff=4245File:Device test.png2015-02-24T18:41:26Z<p>Bserrano: </p>
<hr />
<div></div>Bserranohttps://wiki.emacinc.com/index.php?title=File:Device_connection.png&diff=4244File:Device connection.png2015-02-24T18:37:35Z<p>Bserrano: </p>
<hr />
<div></div>Bserranohttps://wiki.emacinc.com/index.php?title=File:Generic_linux.png&diff=4243File:Generic linux.png2015-02-24T18:32:23Z<p>Bserrano: </p>
<hr />
<div></div>Bserranohttps://wiki.emacinc.com/index.php?title=File:Options_devices.png&diff=4242File:Options devices.png2015-02-24T18:27:29Z<p>Bserrano: </p>
<hr />
<div></div>Bserranohttps://wiki.emacinc.com/index.php?title=File:Qtcreator_gui.png&diff=4241File:Qtcreator gui.png2015-02-23T20:29:05Z<p>Bserrano: Bserrano uploaded a new version of &quot;File:Qtcreator gui.png&quot;</p>
<hr />
<div>Qt Creator GUI</div>Bserranohttps://wiki.emacinc.com/index.php?title=File:Qt_Creator_Icon.png&diff=4240File:Qt Creator Icon.png2015-02-23T20:26:01Z<p>Bserrano: </p>
<hr />
<div></div>Bserranohttps://wiki.emacinc.com/index.php?title=Getting_Started_With_Qt_Creator&diff=4239Getting Started With Qt Creator2015-02-23T20:22:14Z<p>Bserrano: </p>
<hr />
<div>{{todo| NotStarted (02.03.2015-10:42->BS+)|Brian Serrano| project=OE 5.0,BS }}<br />
{{#seo:<br />
|title=Getting Started with Qt Creator<br />
|titlemode=append<br />
|keywords=<br />
|description=The following page can be used to get familiarized with EMAC Qt Creator.<br />
}}<br />
<br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /**************************************** Page Description Text ****************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
<span style="background:#00FF00;color:#FF0000;font-size:300%">'''''The following page describes the process of getting familiar with EMAC Qt Creator.'''''</span><br />
<br />
__TOC__<br />
<br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /***************************************** Background Information ****************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
{{:Templateimpl:bg | initials=BS | title=Getting Started with Qt Creator | desc=The following page can be used to get familiarized with EMAC Qt Creator. | project=OE 5.0 }}<br />
Qt Creator is a cross-platform Open Source Integrated Development Environment (IDE) that can be used to develop software for many different languages. It includes a visual debugger and an integrated GUI layout and forms designer. See the Qt Project site for more information http://qt-project.org/wiki/Category:Tools::QtCreator.<br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /***************************************** General Information *****************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
{{:Templateimpl:geninfo | initials=BS | title=Getting Started with Qt Creator | desc=The following page can be used to get familiarized with EMAC Qt Creator. | project=OE 5.0 }}<br />
=== Tools Required ===<br />
* EMAC OE SDK 5.0<br />
* EMAC Qt Creator<br />
* GNU ''make''<br />
* ''cmake''<br />
=== Setup === <br />
# Make sure the system is [[Configuring_Qt_Creator | configured]] for the correct target machine and that the IP and user/password are set.<br />
# Launch EMAC Qt Creator.<br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /***************************************** Using/Working With ******************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
{{:Templateimpl:using | initials=BS | title=Getting Started with Qt Creator | desc=The following page can be used to get familiarized with EMAC Qt Creator. | project=OE 5.0 }}<br />
<br />
After installing EMAC SDK, launch the EMAC Qt Creator desktop icon.<br />
<br />
1. Press the Windows key and search for "Qt Creator EMAC"<br />
<br />
2. Put the Qt Creator EMAC icon on the Launcher for easy access.<br />
<br />
[[File:Qt_Creator_Icon.jpg|600px|left|thumb|Figure 1: Qt Launcher Icon]]<br />
<br clear=all><br />
<br />
3. To generate a new project from Qt Creator, select "New Project" on the opening splash window. The examples being used are all written in <code> C programming </code> language.<br />
<br />
4. After selecting "New Project" a new window will pop up. To run a <code> C programming </code> example using EMAC hardware, select "EMAC Project" under the Projects tab. Then select "EMAC C Project (CMake Build)". Click the "Choose" button on the bottom right of window to continue to the next page as shown in Figure 2.<br />
<br />
[[File:EMAC_C_Project.png|600px|left|thumb|Figure 2: Qt Creator EMAC Project]]<br />
<br clear=all><br />
<br />
5. The next page will be "Introduction and Project Location". Select a name for the <code> C </code> project. Once the project name is given, choose a a directory to store the project. Note: It is '''highly recommended''' to store your project other than the default location. For this example, we used ''/home/developer/Projects''.<br />
<br />
[[File:Project_location1.png|600px|left|thumb|Figure 3: Qt Creator Project Location]]<br />
<br clear=all><br />
<br />
6. The next page summarizes the '''EMAC C Project'''. Click "Finish" to continue.<br />
<br />
[[File:Project_summary1.png|600px|left|thumb|Figure 4: Qt Creator Project Summary]]<br />
<br clear=all><br />
<br />
7. Next, it will prompt you to the "CMake Wizard Build Location". Click "Next" to continue. Note: It is '''highly recommended''' to use the default build directory as stated below in Figure 5. <br />
<br />
[[File:Build_location.png|600px|left|thumb|Figure 5: Qt Creator Build Location]] <br />
<br clear=all><br />
<br />
8. "CMake Wizard" will then prompt you to "Run CMake". For setting up the Desktop Kit, click "Run CMake" and the output should be similar to Figure 6 below. Click "Finish" to start new project.<br />
<br />
[[File:Run_cmake1.png|600px|left|thumb|Figure 6: Qt Creator Run CMake]]<br />
<br clear=all<br />
<br />
>9. Once the Desktop Kit is configured, the hardware architecture kit needs to be installed. Navigate to "Add Kit" in the "Projects" tab. Under "Add Kit" select the architecture for the board being used. Click "EMAC OE 5.0 arm". <br />
{{note|The board being used will be the iPac-9x25. The iPac-9x25 is a 32-bit architecture armv5te. }}<br />
<br />
[[File:Add_kit_arm.jpg|600px|left|thumb|Figure 7: Qt Creator Add Kit]]<br />
<br clear=all><br />
<br />
10. As previously stated in step 7 it will prompt you to the "CMake Wizard Build Location". Click "Next" to continue. Note: It is '''highly recommended''' to use the default build directory as stated below in Figure 8.<br />
<br />
[[File:Add_arm.png|600px|left|thumb|Figure 8: Qt Creator Add Kit Build Location]]<br />
<br clear=all><br />
<br />
11. "CMake Wizard" will then prompt you to "Run CMake". For setting up the iPac-9x25 arm kit, click the box next to "Arguments". Copy and paste the string below: <br />
''-DARCH:STRING=arm''<br />
<br />
[[File:Arm_argument_string.png|600px|left|thumb|Figure 9: Qt Creator Argument String]]<br />
<br clear=all><br />
<br />
EMAC SDK provides another architectural kit for x86 hardware. If using an x86 architecture, copy and paste the argument string below in the "Arguments" box. <br />
''-DARCH:STRING=x86'' <br />
<br />
12. Once the arguments string is pasted in the box, click "Run CMake" and the output should be similar to Figure 10 below. Click "Finish" to add the arm kit to the current project.<br />
<br />
[[File:Run_arm_cmake.png|600px|left|thumb|Figure 10: Qt Creator Run CMake]]<br />
<br clear=all><br />
<br />
13. To confirm if the kits installed correctly, click on the "All" tab (Monitor symbol) on the left hand side of the Qt Creator window as shown in Figure 11. Both "Desktop" and "OE 5.0 arm" kit will be present.<br />
<br />
[[File:Arm_kit.jpg|600px|left|thumb|Figure 11: Qt Creator Kits Installed]]<br />
<br clear=all><br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /***************************************** Examples *****************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
{{:Templateimpl:examples | initials=BS | title=Getting Started with Qt Creator | desc=The following page can be used to get familiarized with EMAC Qt Creator. | project=OE 5.0 }}<br />
This section will show how to run <code> C programming </code> examples through the Qt Creator IDE. The example board will be the iPac-9x25. <br />
<br />
The first example is a basic <code> hello c </code> example project. <br />
<br />
1. After creating a new project and installing the necessary kits for the target board, navigate to the "Edit" tab on Qt Creator. Qt Creator will automatically have the <code> hello c </code> example uploaded as shown in Figure 12.<br />
<br />
<syntaxhighlight lang="c"><br />
#include <stdio.h><br />
#include <stdlib.h><br />
<br />
int main(int argc, char * argv[])<br />
{<br />
printf("Hello EMAC OE!\n");<br />
<br />
exit(EXIT_SUCCESS);<br />
}<br />
</syntaxhighlight><br />
<br />
[[File:Edit_window.png|600px|left|thumb|Figure 12: Qt Creator Edit Window]] <br />
<br clear=all><br />
<br />
2. Before executing the example, you must build the program first. Click on the build icon (hammer symbol) on the bottom left of the Qt Creator. If the build was successful, a green bar will fill on the bottom right of the Qt Creator.<br />
<br />
3. Once the program successfully builds, you can now run the program. Click on the run icon (green arrow symbol) on the left hand side of Qt Creator. The program prints <code> Hello EMAC OE! </code> in the "Application Output" terminal. <br />
<br />
[[File:Final_output.png|600px|left|thumb|Figure 13: Qt Creator Edit Window]]<br />
<br clear=all><br />
<br />
The second example will show how to run a <code> c programming </code> project on a target board. This example will show all prime numbers from 1 - 100 and output it on Qt Creator remote terminal.<br />
<br />
1. Create a new project and install the necessary kits for the target board just as shown before. Call this project <code> Prime_Numbers </code>. Then Navigate to the "Edit" tab on Qt Creator. Copy and paste the following code below to the Qt Creator terminal. <br />
<br />
<syntaxhighlight lang="c"><br />
#include <stdio.h><br />
#include <stdlib.h><br />
<br />
int main(int argc, char * argv[])<br />
{ <br />
int i;<br />
int j;<br />
<br />
for (i = 2; i <= 100; i++)<br />
{<br />
for (j = 2; j <= i; j++)<br />
{<br />
if (i%j==0)<br />
{<br />
break;<br />
}<br />
}<br />
if (i == j)<br />
{<br />
printf ("%d is a prime number. \n", i);<br />
}<br />
}<br />
return 0;<br />
}<br />
</syntaxhighlight><br />
<br />
[[File:Prime_Numbers_edit.png|600px|left|thumb|Figure 14: Qt Creator Edit Window]] <br />
<br clear=all><br />
<br />
2. Click on the build icon (hammer symbol) on the bottom left of the Qt Creator. If the build was successful, a green bar will fill on the bottom right of the Qt Creator.<br />
<br />
3. Click on the run icon (green arrow symbol) on the left hand side of Qt Creator. The program prints all prime numbers from 1 - 100 in the "Application Output" terminal. <br />
<br />
[[File:Final_Prime_Numbers.png|600px|left|thumb|Figure 14: Qt Creator Edit Window]] <br />
<br clear=all><br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /****************************************** Conclusion ******************************************/ --> <br />
<!-- /*********************************************************************************************************/ --><br />
{{:Templateimpl:conclusion | initials=BS | title=Getting Started with Qt Creator | desc=The following page can be used to get familiarized with EMAC Qt Creator. | project=OE 5.0 }}<br />
This page is a quick getting started tutorial on how to use EMAC Qt Creator for the first time. It shows you how to create an EMAC C Project, set up the necessary kits for your target board, and how to build and run example projects. <br />
<!-- /*********************************************************************************************************/ --><br />
<!-- /****************************************** More Information *****************************************/ --><br />
<!-- /*********************************************************************************************************/ --><br />
{{:Templateimpl:moreinfo | initials=BS | title=Getting Started with Qt Creator | desc=The following page can be used to get familiarized with EMAC Qt Creator. | project=OE 5.0 }}<br />
* '''TBD'''<br />
<br />
{{:Templateimpl:whatnext | initials=BS | title=Getting Started with Qt Creator | desc=The following page can be used to get familiarized with EMAC Qt Creator. | project=OE 5.0 }}<br />
* '''TBD'''</div>Bserranohttps://wiki.emacinc.com/index.php?title=File:Qt_Creator_Icon.jpg&diff=4238File:Qt Creator Icon.jpg2015-02-23T20:21:32Z<p>Bserrano: Bserrano uploaded a new version of &quot;File:Qt Creator Icon.jpg&quot;</p>
<hr />
<div></div>Bserranohttps://wiki.emacinc.com/index.php?title=File:Add_arm.png&diff=4237File:Add arm.png2015-02-23T19:53:01Z<p>Bserrano: </p>
<hr />
<div></div>Bserrano