<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.emacinc.com/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Mcoleman</id>
	<title>wiki.emacinc.com - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.emacinc.com/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Mcoleman"/>
	<link rel="alternate" type="text/html" href="https://wiki.emacinc.com/wiki/Special:Contributions/Mcoleman"/>
	<updated>2026-05-09T17:31:04Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.31.6</generator>
	<entry>
		<id>https://wiki.emacinc.com/index.php?title=Loading_Images_with_RedBoot&amp;diff=533</id>
		<title>Loading Images with RedBoot</title>
		<link rel="alternate" type="text/html" href="https://wiki.emacinc.com/index.php?title=Loading_Images_with_RedBoot&amp;diff=533"/>
		<updated>2013-05-31T18:55:41Z</updated>

		<summary type="html">&lt;p&gt;Mcoleman: content init&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;RedBoot is the bootloader currently used on EMAC's Cirrus EP93xx-based products. These include the SoM-9307, PPC-E7, and iPac-9302. This page explains the process of using RedBoot for programming the root flash on EMAC boards. &lt;br /&gt;
&lt;br /&gt;
==Setup==&lt;br /&gt;
&lt;br /&gt;
In order to access RedBoot, the board will need to be connected through the standard serial connection described in the [[EMAC OE Getting Started Document]]. The local network will also need to have a TFTP server available. This is easily installed on most Linux distributions through the package manager. Free TFTP servers exist for Windows as well. The board will need to have an Ethernet connection to the local network. The images that are to be programmed onto the board should be placed in the TFTP server root directory so that they can be loaded from RedBoot.&lt;br /&gt;
&lt;br /&gt;
==Accessing RedBoot==&lt;br /&gt;
&lt;br /&gt;
After all connections have been made, start the serial terminal application and apply power to the board. Press Ctrl+C several times on the serial terminal until you see the RedBoot&amp;gt; prompt. If the kernel begins to boot, reset the board and try again (the standard timeout before booting the kernel is one second). On most versions of RedBoot, you will see either a '+' or a message from RedBoot before it boots the kernel, but some configurations have this disabled.&lt;br /&gt;
&lt;br /&gt;
Once you are at the RedBoot prompt, a list of available commands can be found by typing help as shown below:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
RedBoot&amp;gt; help&lt;br /&gt;
Manage aliases kept in FLASH memory&lt;br /&gt;
   alias name [value]&lt;br /&gt;
Manage machine caches&lt;br /&gt;
   cache [ON | OFF]&lt;br /&gt;
boot a WIndows CE 5.0 image&lt;br /&gt;
   ce [-v &amp;lt;validate only&amp;gt;] [-b &amp;lt;image location&amp;gt;]&lt;br /&gt;
Display/switch console channel&lt;br /&gt;
   channel [-1|&amp;lt;channel number&amp;gt;]&lt;br /&gt;
Compute a 32bit checksum [POSIX algorithm] for a range of memory&lt;br /&gt;
   cksum -b &amp;lt;location&amp;gt; -l &amp;lt;length&amp;gt;&lt;br /&gt;
Display disks/partitions.&lt;br /&gt;
   disks&lt;br /&gt;
Display (hex dump) a range of memory&lt;br /&gt;
   dump -b &amp;lt;location&amp;gt; [-l &amp;lt;length&amp;gt;] [-s] [-1|2|4]&lt;br /&gt;
Execute an image - with MMU off&lt;br /&gt;
   exec [-w timeout] [-b &amp;lt;load addr&amp;gt; [-l &amp;lt;length&amp;gt;]]&lt;br /&gt;
        [-r &amp;lt;ramdisk addr&amp;gt; [-s &amp;lt;ramdisk length&amp;gt;]]&lt;br /&gt;
        [-c &amp;quot;kernel command line&amp;quot;] [&amp;lt;entry_point&amp;gt;]&lt;br /&gt;
Manage FLASH images&lt;br /&gt;
   fis {cmds}&lt;br /&gt;
Manage configuration kept in FLASH memory&lt;br /&gt;
   fconfig [-i] [-l] [-n] [-f] [-d] | [-d] nickname [value]&lt;br /&gt;
Execute code at a location&lt;br /&gt;
   go [-w &amp;lt;timeout&amp;gt;] [entry]&lt;br /&gt;
Help about help?&lt;br /&gt;
   help [&amp;lt;topic&amp;gt;]&lt;br /&gt;
Read CE INI file into global variables&lt;br /&gt;
   iniparse -b &amp;lt;mem_base&amp;gt;&lt;br /&gt;
Set/change IP addresses&lt;br /&gt;
   ip_address [-l &amp;lt;local_ip_address&amp;gt;] [-h &amp;lt;server_address&amp;gt;]&lt;br /&gt;
Load a file&lt;br /&gt;
   load [-r] [-v] [-h &amp;lt;host&amp;gt;] [-m &amp;lt;varies&amp;gt;] [-c &amp;lt;channel_number&amp;gt;]&lt;br /&gt;
        [-b &amp;lt;base_address&amp;gt;] &amp;lt;file_name&amp;gt;&lt;br /&gt;
Compare two blocks of memory&lt;br /&gt;
   mcmp -s &amp;lt;location&amp;gt; -d &amp;lt;location&amp;gt; -l &amp;lt;length&amp;gt; [-1|-2|-4]&lt;br /&gt;
Fill a block of memory with a pattern&lt;br /&gt;
   mfill -b &amp;lt;location&amp;gt; -l &amp;lt;length&amp;gt; -p &amp;lt;pattern&amp;gt; [-1|-2|-4]&lt;br /&gt;
test a section of memory by writing a changing pattern and verifying&lt;br /&gt;
   mtest -b &amp;lt;start&amp;gt; -e &amp;lt;end&amp;gt; -d &amp;lt;display increment&amp;gt;&lt;br /&gt;
Network connectivity test&lt;br /&gt;
   ping [-v] [-n &amp;lt;count&amp;gt;] [-l &amp;lt;length&amp;gt;] [-t &amp;lt;timeout&amp;gt;] [-r &amp;lt;rate&amp;gt;]&lt;br /&gt;
        [-i &amp;lt;IP_addr&amp;gt;] -h &amp;lt;IP_addr&amp;gt;&lt;br /&gt;
read a raw file to a disk partition, ignoring any filesystem&lt;br /&gt;
   rawread -b &amp;lt;mem_base&amp;gt; -l &amp;lt;image_length&amp;gt; &amp;lt;file name&amp;gt;&lt;br /&gt;
write a raw file to a disk partition, ignoring any filesystem&lt;br /&gt;
   rawwrite -b &amp;lt;mem_base&amp;gt; -l &amp;lt;image_length&amp;gt; &amp;lt;file name&amp;gt;&lt;br /&gt;
Reset the system&lt;br /&gt;
   reset&lt;br /&gt;
run a script of redboot commands&lt;br /&gt;
   script -b &amp;lt;mem_base&amp;gt;&lt;br /&gt;
display system parameters&lt;br /&gt;
   system&lt;br /&gt;
configure tftp client&lt;br /&gt;
   tftpconfig [-t &amp;lt;timeout&amp;gt;]  [-r &amp;lt;retries&amp;gt;]&lt;br /&gt;
Display RedBoot version information&lt;br /&gt;
   version&lt;br /&gt;
Display (hex dump) a range of memory&lt;br /&gt;
   x -b &amp;lt;location&amp;gt; [-l &amp;lt;length&amp;gt;] [-s] [-1|2|4]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ mbox | type = warning | text = When entering data into RedBoot, the command line interface does not support moving the cursor (i.e. using the cursor/arrow keys). The backspace key must be used to edit any information that has been entered.}}&lt;br /&gt;
&lt;br /&gt;
==Configuring RedBoot==&lt;br /&gt;
&lt;br /&gt;
Before the new images can be loaded, RedBoot must be configured to match the local network settings. Although it is possible to use a local DHCP/BOOTP server to lease an IP address to the board through RedBoot, EMAC recommends using a static IP address. If DHCP is enabled in RedBoot and the board cannot access the server or obtain a lease, it will take approximately 30 seconds before timing out and proceeding with the boot process. Contact your IT department for a valid static IP address to be used. You will also need the subnetwork mask, default gateway IP address, and TFTP server IP address. The examples below assume that the network settings are as follows:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
| IP Address || 10.0.2.41&lt;br /&gt;
|-&lt;br /&gt;
| Default Gateway || 10.0.2.1&lt;br /&gt;
|-&lt;br /&gt;
| Subnet Mask || 255.255.255.0&lt;br /&gt;
|-&lt;br /&gt;
| TFTP Server IP || 10.0.2.60&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;fconfig&amp;lt;/code&amp;gt; command is used to set configuration data in RedBoot. When run with no options, &amp;lt;code&amp;gt;fconfig&amp;lt;/code&amp;gt; will start an interactive prompt for setting all configuration variables. This is seldom necessary as generally most of the options are left as default. To see the current configuration, run &amp;lt;code&amp;gt;fconfig -l&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;fconfig -l -n&amp;lt;/code&amp;gt; to trigger using variable names rather than descriptions. The &amp;lt;code&amp;gt;-n&amp;lt;/code&amp;gt; flag is handy because the variable names are needed when setting only one variable.&lt;br /&gt;
&lt;br /&gt;
The following is an example of the default settings (note that some of these settings are board specific):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
RedBoot&amp;gt; fconfig -l&lt;br /&gt;
Run script at boot: true&lt;br /&gt;
Boot script:&lt;br /&gt;
.. fis unlock -f 0x60000000 -l 0x1fdffff&lt;br /&gt;
.. fis load zImage&lt;br /&gt;
.. exec -c &amp;quot;root=/dev/mtdblock2 rootfstype=jffs2 console=ttyAM&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Boot script timeout (1000ms resolution): 1&lt;br /&gt;
Use BOOTP for network configuration: false&lt;br /&gt;
Gateway IP address: 10.0.2.1&lt;br /&gt;
Local IP address: 10.0.2.14&lt;br /&gt;
Local IP address mask: 255.255.255.0&lt;br /&gt;
Default server IP address: 10.0.2.60&lt;br /&gt;
DNS server IP address: 10.0.2.1&lt;br /&gt;
Set eth0 network hardware address [MAC]: false&lt;br /&gt;
GDB connection port: 9000&lt;br /&gt;
Force console for special debug messages: false&lt;br /&gt;
Network debug at boot time: false&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
RedBoot&amp;gt; fconfig -l -n&lt;br /&gt;
boot_script: true&lt;br /&gt;
boot_script_data:&lt;br /&gt;
.. fis unlock -f 0x60000000 -l 0x1fdffff&lt;br /&gt;
.. fis load zImage&lt;br /&gt;
.. exec -c &amp;quot;root=/dev/mtdblock2 rootfstype=jffs2 console=ttyAM&amp;quot;&lt;br /&gt;
&lt;br /&gt;
boot_script_timeout: 1&lt;br /&gt;
bootp: false&lt;br /&gt;
bootp_my_gateway_ip: 10.0.2.1&lt;br /&gt;
bootp_my_ip: 10.0.2.14&lt;br /&gt;
bootp_my_ip_mask: 255.255.255.0&lt;br /&gt;
bootp_server_ip: 10.0.2.60&lt;br /&gt;
dns_ip: 10.0.2.1&lt;br /&gt;
ep93xx_esa: false&lt;br /&gt;
gdb_port: 9000&lt;br /&gt;
info_console_force: false&lt;br /&gt;
net_debug: false&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The values in the second listing show the variable names rather than descriptions.&lt;br /&gt;
&lt;br /&gt;
Run the following commands to configure RedBoot using the network settings listed above. Replace the values with the correct settings for your local network. Note that if you change a variable from its current value, RedBoot will prompt you to commit the value to non-volatile storage. Type 'y' and press Enter when this occurs so that the new setting will be stored in flash.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
fconfig bootp false&lt;br /&gt;
fconfig bootp_my_gateway_ip 10.0.2.1&lt;br /&gt;
fconfig bootp_my_ip 10.0.2.41&lt;br /&gt;
fconfig bootp_my_ip_mask 255.255.255.0&lt;br /&gt;
fconfig bootp_server_ip 10.0.2.60&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ mbox | type = notice | text = Note that if DHCP/BOOTP is desired, set the &amp;lt;code&amp;gt;bootp&amp;lt;/code&amp;gt; variable to &amp;lt;code&amp;gt;true&amp;lt;/code&amp;gt; rather than &amp;lt;code&amp;gt;false&amp;lt;/code&amp;gt; and leave the other configuration options blank except for &amp;lt;code&amp;gt;bootp_server_ip&amp;lt;/code&amp;gt;. See above for a discussion on DHCP versus static configuration. }}&lt;br /&gt;
&lt;br /&gt;
RedBoot uses a bootscript that is run automatically on boot to load and execute the Linux kernel. The values specified here are somewhat hardware-specific. In most cases, the default EMAC values should be used. In general, the commands will perform the following steps:&lt;br /&gt;
&lt;br /&gt;
# Unlock the NOR flash&lt;br /&gt;
# Load the kernel image from flash into RAM&lt;br /&gt;
# Execute the kernel, passing it a set of boot arguments&lt;br /&gt;
&lt;br /&gt;
To change the boot script, run the following commands:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
fconfig boot_script true&lt;br /&gt;
fconfig boot_script_timeout 1&lt;br /&gt;
fconfig boot_script_data&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
After the last command above has been entered, a prompt will appear to Enter &amp;lt;code&amp;gt;script&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;terminate&amp;lt;/code&amp;gt; with &amp;lt;code&amp;gt;empty line&amp;lt;/code&amp;gt;. The current value of the boot_script_data variable will be printed as well. Enter the desired boot script line-by-line at the prompts. After the last line of the boot script, leave the next line empty and press enter to signal that all data has been entered. An example is shown below:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
RedBoot&amp;gt; fconfig boot_script_data&lt;br /&gt;
boot_script_data:&lt;br /&gt;
.. fis unlock -f 0x60000000 -l 0x1fdffff&lt;br /&gt;
.. fis load zImage&lt;br /&gt;
.. exec -c &amp;quot;root=/dev/mtdblock2 rootfstype=jffs2 console=ttyAM&amp;quot;&lt;br /&gt;
Enter script, terminate with empty line&lt;br /&gt;
&amp;gt;&amp;gt; fis unlock -f 0x60000000 -l 0x1fdffff&lt;br /&gt;
&amp;gt;&amp;gt; fis load zImage&lt;br /&gt;
&amp;gt;&amp;gt; exec -c &amp;quot;root=/dev/mtdblock2 rootfstype=jffs2 console=ttyAM&amp;quot;&lt;br /&gt;
&amp;gt;&amp;gt;&lt;br /&gt;
Update RedBoot non-volatile configuration - continue (y/n)? y&lt;br /&gt;
... Unlock from 0x61fc0000-0x61fc1000: .&lt;br /&gt;
... Erase from 0x61fc0000-0x61fc1000: .&lt;br /&gt;
... Program from 0x03fde000-0x03fdf000 at 0x61fc0000: .&lt;br /&gt;
... Lock from 0x61fc0000-0x61fc1000: .&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
After the configuration above has been entered, &amp;lt;code&amp;gt;reset&amp;lt;/code&amp;gt; the board using the reset button or &amp;lt;code&amp;gt;reset&amp;lt;/code&amp;gt; command and press Ctrl+C to interrupt the boot process and return to the &amp;lt;code&amp;gt;RedBoot&amp;gt;&amp;lt;/code&amp;gt; prompt.&lt;br /&gt;
&lt;br /&gt;
==Preparing the Flash==&lt;br /&gt;
&lt;br /&gt;
If you are starting with a flash that has not been pre-programmed or want to completely erase the existing image, the flash will need to be formatted. To do this, run the &amp;lt;code&amp;gt;fis init -f&amp;lt;/code&amp;gt; command. Note that this does not erase the RedBoot image or configuration partition. This command will take several minutes to run. This command is not necessary if the goal is simply to overwrite an existing filesystem or kernel image without changing the existing partition values.&lt;br /&gt;
&lt;br /&gt;
==Loading Images==&lt;br /&gt;
&lt;br /&gt;
Images are loaded and programmed to the board using a two-step process. First, the image is loaded to RAM through the network using the TFTP protocol. Once the image has been loaded into RAM, the image may be programmed to the flash using the fis command.&lt;br /&gt;
&lt;br /&gt;
===Loading the Kernel===&lt;br /&gt;
&lt;br /&gt;
The kernel is stored in a small binary partition of the flash separate from the root filesystem. The example below assumes that the kernel image is stored on the TFTP server in a file named &amp;lt;code&amp;gt;zImage-2.6.25&amp;lt;/code&amp;gt;. The following steps are required to program the new kernel image:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;cl&amp;gt;&lt;br /&gt;
1. Unlock the flash (necessary only if the image will be programmed to the flash):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
fis unlock -f 0x60000000 -l 0x1fdffff&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
* Load the kernel image via TFTP:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
load -r -v -b 0x80000 zImage-2.6.25&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
If the kernel does not load successfully, there is an error with the networking setup; do not proceed until the issue is resolved.&lt;br /&gt;
* At this point the image may be booted without programming to flash. This feature is very helpful for development and testing. Also note that changing the &amp;lt;code&amp;gt;boot_script_data&amp;lt;/code&amp;gt; variable so that &amp;lt;code&amp;gt;fis load zImage&amp;lt;/code&amp;gt; is replaced with the TFTP load command above will cause the board to load the kernel from TFTP at each boot. To manually execute the kernel from RAM, run the exec command from the boot script, i.e. &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
exec -c &amp;quot;root=/dev/mtdblock2 rootfstype=jffs2 console=ttyAM&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
* After the image has been loaded into RAM, it may be programmed to the flash:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
fis create -b 0x80000 -l 0x200000 zImage&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/cl&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Loading the Filesystem===&lt;br /&gt;
&lt;br /&gt;
The default filesystem for EMAC boards using RedBoot is a JFFS2 image stored on the NOR flash. The steps below describe the process of programming a new image via TFTP assuming the image is stored on the TFTP server with the name &amp;lt;code&amp;gt;emac-image.jffs2&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;cl&amp;gt;&lt;br /&gt;
1. Unlock the flash:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
fis unlock -f 0x60000000 -l 0x1fdffff&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
* Load the image to RAM (this will take serveral minutes):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
load -r -v -b 0x300000 emac-image.jffs2&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
* Program the image to flash (do not proceed with this step unless the image has successfully been loaded into RAM):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
fis create -b 0x300000 -l 0x1c00000 jffs2&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/cl&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ mbox | type = notice | text = Note that the length of the image programmed above was 28 MB (0x1c00000). This is the default size for boards with 32 MB and 64 MB flash chips. For other boards, the image length will need to be adjusted accordingly. }}&lt;br /&gt;
&lt;br /&gt;
==Scripting==&lt;br /&gt;
&lt;br /&gt;
An additional feature of RedBoot is the ability to execute scripts of commands. This is handy for repetitive tasks and programming several boards with the same image. A RedBoot script is simply a text file containing the commands that should be run listed line-by-line in the correct order. This file can then be loaded via TFTP and executed. For example, to script the programming process detailed above, a script file would be created and stored on the TFTP server with the following contents:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
fis unlock -f 0x60000000 -l 0x1fdffff&lt;br /&gt;
load -r -v -b 0x80000 zImage-2.6.25&lt;br /&gt;
fis create -b 0x80000 -l 0x200000 zImage&lt;br /&gt;
fis unlock -f 0x60000000 -l 0x1fdffff&lt;br /&gt;
load -r -v -b 0x300000 emac-image.jffs2&lt;br /&gt;
fis create -b 0x300000 -l 0x1c00000 jffs2&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Assuming that the script file was saved with the name &amp;lt;code&amp;gt;flash-script&amp;lt;/code&amp;gt;, it could be loaded and executed from RedBoot through the following commands:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
load -r -v -b 0x50000 flash-script&lt;br /&gt;
script -b 0x50000&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Mcoleman</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.emacinc.com/index.php?title=Building_and_Customizing_EMAC_OE&amp;diff=511</id>
		<title>Building and Customizing EMAC OE</title>
		<link rel="alternate" type="text/html" href="https://wiki.emacinc.com/index.php?title=Building_and_Customizing_EMAC_OE&amp;diff=511"/>
		<updated>2013-05-28T20:14:03Z</updated>

		<summary type="html">&lt;p&gt;Mcoleman: content init&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;An EMAC [OpenEmbedded] Linux build is the end product of several different build systems. These consist of three core components: [BitBake], [OpenEmbedded], and EMAC [OpenEmbedded]. Each one of these tools is built one upon the other: BitBake → OpenEmbedded → EMAC OpenEmbedded. You will need to download each component separately. &lt;br /&gt;
&lt;br /&gt;
Please familiarize yourself with [OpenEmbedded's Wiki] before continuing.&lt;br /&gt;
&lt;br /&gt;
{{ mbox | type = notice | text = EMAC, Inc. provides this page for informational use for its customers and will not be held liable for any mistakes or omissions on this page which may cause your computer operating system to fail. Use at your own risk.}}&lt;br /&gt;
&lt;br /&gt;
==System Preparation==&lt;br /&gt;
&lt;br /&gt;
{{ mbox | type = warning | type = After initial preparation, only run the commands on this page from a user in the oe group (see below). Doing so can do serious damage to the running operating system.}}&lt;br /&gt;
&lt;br /&gt;
You need to be running a GNU/Linux operating system to use OpenEmbedded. If you do not currently have a Linux distribution, EMAC recommends installing a [Debian] 5.0 or higher distribution (except for the unstable branch).&lt;br /&gt;
&lt;br /&gt;
OpenEmbedded requires a large number of development tools to work correctly with your Linux distribution. However due to the large number of distributions available, please see the OpenEmbedded Wiki page [OEandYourDistro] for the instruction on the installation of the development packages which are required.&lt;br /&gt;
&lt;br /&gt;
After installing all of the necessary packages to your distribution you will need to set up the location of EMAC OE. By default EMAC OE expects to be installed in &amp;lt;code&amp;gt;/opt/oe&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{{ mbox | type = notice | text = The “oe” provider is not currently registered as a LANANA provider and this name should not conflict with other commercial *nix providers.}}&lt;br /&gt;
&lt;br /&gt;
As the superuser (root or as sudo):&lt;br /&gt;
# Create a group called &amp;lt;code&amp;gt;oe&amp;lt;/code&amp;gt; and add the development users to the group.&lt;br /&gt;
# Make a directory in &amp;lt;code&amp;gt;/opt&amp;lt;/code&amp;gt; called &amp;lt;code&amp;gt;oe&amp;lt;/code&amp;gt;.&lt;br /&gt;
# Change the permissions of &amp;lt;code&amp;gt;/opt/oe&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;6775&amp;lt;/code&amp;gt;.&lt;br /&gt;
# Add a umask of &amp;lt;code&amp;gt;0002&amp;lt;/code&amp;gt; to each account.&lt;br /&gt;
&lt;br /&gt;
In Debian Lenny, you can do the following: &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ add-group oe developer&lt;br /&gt;
developer@ldc:~$ mkdir /opt/oe&lt;br /&gt;
developer@ldc:~$ chmod 6775 /opt/oe&lt;br /&gt;
developer@ldc:~$ oe /opt/oe&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;umask&amp;lt;/code&amp;gt; can be run by the user on the command line or added to the user's startup script. These are typically &amp;lt;code&amp;gt;.&amp;lt;shell_name&amp;gt;rc&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;.profile&amp;lt;/code&amp;gt; in the user's home directory. Failure to do so will result in files without write access to group members. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ umask 0002 &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;umask&amp;lt;/code&amp;gt; without any argument will show the current environment umask.&lt;br /&gt;
&lt;br /&gt;
After adding the development users to the oe group and modifying the umask, log out of the development system and log back in before continuing.&lt;br /&gt;
&lt;br /&gt;
==Installing Dependencies (Debian)==&lt;br /&gt;
&lt;br /&gt;
This information is from [OEandYourDistro].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ sudo aptitude update&lt;br /&gt;
&lt;br /&gt;
developer@ldc:~$ sudo aptitude -y install sed wget cvs subversion git-core \&lt;br /&gt;
		 coreutils unzip texi2html texinfo libsdl1.2-dev docbook-utils \&lt;br /&gt;
		 gawk python-pysqlite2 diffstat help2man make gcc build-essential g++ \&lt;br /&gt;
		 libxml2-utils xmlto python-psyco \&lt;br /&gt;
		 docbook \&lt;br /&gt;
		 ccache bash \&lt;br /&gt;
		 ncurses-dev fakeroot \&lt;br /&gt;
		 qemu kvm&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Installing BitBake===&lt;br /&gt;
&lt;br /&gt;
This information is from [OpenEmbedded's Getting Started page].&lt;br /&gt;
&lt;br /&gt;
EMAC OE Linux 4.0 is based on the stable-2009 branch of [OpenEmbedded]. For stable-2009 use BitBake versions between 1.8.12 and 1.8.18. As a user in the oe group, download and extract BitBake:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ cd /opt/oe&lt;br /&gt;
developer@ldc:~$ wget http://download.berlios.de/bitbake/bitbake-1.8.18.tar.gz&lt;br /&gt;
developer@ldc:~$ tar xzvf bitbake-1.8.18.tar.gz&lt;br /&gt;
developer@ldc:~$ ln -s bitbake-1.8.18/bin/bitbake bitbake&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Installing OpenEmbedded===&lt;br /&gt;
&lt;br /&gt;
Checkout the stable-2009 branch of the OpenEmbedded git repository: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ cd /opt/oe&lt;br /&gt;
developer@ldc:~$ git clone git://git.openembedded.org/openembedded /opt/oe/openembedded&lt;br /&gt;
developer@ldc:~$ cd openembedded&lt;br /&gt;
developer@ldc:~$ git checkout -b stable/2009 origin/stable/2009&lt;br /&gt;
developer@ldc:~$ git pull&lt;br /&gt;
developer@ldc:~$ git status&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If everything went correctly, &amp;lt;code&amp;gt;git status&amp;lt;/code&amp;gt; should reply as follows: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
# On branch stable/2009&lt;br /&gt;
nothing to commit (working directory clean)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Installing EMAC OpenEmbedded===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;cl&amp;gt;&lt;br /&gt;
1. Checkout the public build tree of EMAC OE from EMAC's Subversion repository:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ cd /opt/oe&lt;br /&gt;
developer@ldc:~$ svn checkout https://svn.emacinc.com/public/EMAC-OE-2009.03-STABLE/trunk /opt/oe/emac-oe_stable-2009&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
* Download the additional source package from the EMAC FTP server:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ cd /opt/oe&lt;br /&gt;
developer@ldc:~$ wget ftp://ftp.emacinc.com/Controllers/Development_Kits/EMAC_Open_Tools/Linux/emac-oe_stable-2009_sources.tar.bz2&lt;br /&gt;
developer@ldc:~$ tar xjvf emac-oe_stable-2009_sources.tar.bz2&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/cl&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Making the Build==&lt;br /&gt;
&lt;br /&gt;
===Set the Machine Type===&lt;br /&gt;
&lt;br /&gt;
OpenEmbedded uses configuration files to determine the features, recipe versions, architecture, and setup of the build. The &amp;lt;code&amp;gt;local.conf&amp;lt;/code&amp;gt; file specifies the machine and distribution configuration to use as well as other settings. EMAC provides default configuration files for all of our supported target machines. The &amp;lt;code&amp;gt;oe-set-machine.sh&amp;lt;/code&amp;gt; script is provided to automatically create a symbolic link from &amp;lt;code&amp;gt;local.conf&amp;lt;/code&amp;gt; to the configuration file set up for the selected machine. This must be done to configure EMAC OE prior to starting a build.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ cd /opt/oe/emac-oe_stable-2009&lt;br /&gt;
developer@ldc:~$ ./oe-set-machine.sh&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Type in the selection for the desired target machine and press enter.&lt;br /&gt;
&lt;br /&gt;
===Generate a Base Build===&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;oe-run.sh&amp;lt;/code&amp;gt; script is a wrapper script for &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; which sets all of the environment variables internally on each run. This isolates EMAC OE's &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; version from other &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; versions on the system. If directory locations were used that differ from the set up instructions on this page, the variables in &amp;lt;code&amp;gt;oe-run.sh&amp;lt;/code&amp;gt; will need to be modified accordingly.&lt;br /&gt;
&lt;br /&gt;
This step will take several hours depending on the time it takes to download and compile the sources. All of the sources will be downloaded and compiled in the order they are called by the build recipes. The default configurations provided by EMAC specify that recipes should be built in parallel when possible, so bitbake will generally be performing multiple fetch / compile operations at any point during the build.&lt;br /&gt;
&lt;br /&gt;
The default headless image for EMAC machines is named emac-image. This recipe is located in &amp;lt;code&amp;gt;recipes/images/emac-image.bb&amp;lt;/code&amp;gt; in the EMAC OE tree. This should be the first image built for any target to verify the setup.&lt;br /&gt;
&lt;br /&gt;
Run the emac-image image recipe.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ ./oe-run.sh emac-image&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Bitbake performs a sanity check on the system each time that it is run. If any misconfigurations are detected, the user will be notified of the issue and a suggested fix. Depending on the system, there may be several issues to correct on the first run. For example, a common issue is the value of &amp;lt;code&amp;gt;/proc/sys/vm/mmap_min_addr&amp;lt;/code&amp;gt;, as illustrated below: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
ERROR:  Openembedded's config sanity checker detected a potential misconfiguration.&lt;br /&gt;
        Either fix the cause of this error or at your own risk disable the checker (see sanity.conf).&lt;br /&gt;
        Following is the list of potential problems / advisories:&lt;br /&gt;
 &lt;br /&gt;
        /proc/sys/vm/mmap_min_addr is not 0. This will cause problems with qemu so please fix the value (as root).&lt;br /&gt;
 &lt;br /&gt;
To fix this in later reboots, set vm.mmap_min_addr = 0 in /etc/sysctl.conf.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
EMAC recommends fixing this issue as suggested, but the user should be aware of the possible security implications, as described on the Debian wiki: [http://wiki.debian.org/mmap_min_addr]&lt;br /&gt;
&lt;br /&gt;
On the first build, bitbake will create a cache of the recipes in the build system, which will take a few minutes. After this is complete, bitbake attempts to run all of the recipes required for the image to be built. This is done in multiple threads utilizing the dependencies between recipes to determine which packages are built first. The first task is to “fetch” the software required to build each recipe; this takes a long time. After the source is downloaded the first time, any further builds will use the existing local source copy rather than downloading the source again.&lt;br /&gt;
&lt;br /&gt;
Occasionally, project maintainers or mirrors will move or obsolete a source download such that the location specified in the recipe &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is no longer valid. If this happens, bitbake will print an error and stop the build. For example, the following error occurred when the zlib version 1.2.3 recipe was run:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
Connecting to www.zlib.net|69.73.181.135|:80... connected.&lt;br /&gt;
HTTP request sent, awaiting response... 404 Not Found&lt;br /&gt;
2011-06-26 10:55:33 ERROR 404: Not Found.&lt;br /&gt;
&lt;br /&gt;
NOTE: Task failed: Fetch failed: http://www.zlib.net/zlib-1.2.3.tar.bz2&lt;br /&gt;
ERROR: TaskFailed event exception, aborting&lt;br /&gt;
ERROR: Build of /opt/oe-test/openembedded/recipes/zlib/zlib-native_1.2.3.bb do_fetch failed&lt;br /&gt;
ERROR: Task 633 (/opt/oe-test/openembedded/recipes/zlib/zlib-native_1.2.3.bb, do_fetch) failed&lt;br /&gt;
NOTE: Waiting for 1 active tasks to finish&lt;br /&gt;
NOTE: 1: /opt/oe-test/openembedded/recipes/gettext/gettext-native_0.17.bb, do_populate_staging (27565)&lt;br /&gt;
NOTE: Tasks Summary: Attempted 160 tasks of which 159 didn't need to be rerun and 1 failed.&lt;br /&gt;
ERROR: '/opt/oe-test/openembedded/recipes/zlib/zlib-native_1.2.3.bb' failed&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Although EMAC attempts to keep up with source availability issues, they still occur due to constant development in the open source community. If you encounter an error like this, please contact EMAC technical support with the error message.&lt;br /&gt;
&lt;br /&gt;
All build files will be generated in the &amp;lt;code&amp;gt;tmp&amp;lt;/code&amp;gt; directory. If a tmp directory does not exist it will be created. Image files will be located in &amp;lt;code&amp;gt;tmp/deploy/images&amp;lt;/code&amp;gt; after the build has successfully completed.&lt;br /&gt;
&lt;br /&gt;
The default graphical image for EMAC OE is called emac-ppc-image (“ppc” refers to “Panel PC”) and expands on the emac-image recipe to add a GUI using X11 and the Matchbox Desktop environment. If the target machine has support for a graphical interface, this image can be built using the same process as with the emac-image above:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ ./oe-run.sh emac-ppc-image&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Install the Build Image===&lt;br /&gt;
&lt;br /&gt;
After building the image, it can be loaded to the board for testing. This process differs between target systems based on the architecture, bootloader, and media type. Some general information is provided in this section.&lt;br /&gt;
&lt;br /&gt;
====x86 Image Install====&lt;br /&gt;
&lt;br /&gt;
This example is for x86 based single board computers only using a CompactFlash SSD. For other boards contact EMAC Technical Support1).&lt;br /&gt;
&lt;br /&gt;
{{ mbox | type = warning | text = This will require superuser access as sudo or root and is '''VERY DANGEROUS TO USE''' on a running development system. Although checks have been added to prevent user errors, misusing this script can '''DESTROY the root file system partition'''. Make sure to have a system backup before proceeding.}}&lt;br /&gt;
&lt;br /&gt;
You will a USB CompactFlash card reader to complete this step. &lt;br /&gt;
&lt;br /&gt;
In &amp;lt;code&amp;gt;tmp/deploy/images&amp;lt;/code&amp;gt; find the file named &amp;lt;code&amp;gt;emac-image-x86.tar.gz&amp;lt;/code&amp;gt;. This is a symbolic link to the most recently generated build image. There is a problem with the GRUB bootloader in stable-2009 and does not work properly on x86 systems. In order to get a working image you will need to use a supplied bootloader install script in &amp;lt;code&amp;gt;/opt/oe/emac-oe_stable-2009/contrib/put-image&amp;lt;/code&amp;gt;. Read the README.txt for the script usage.&lt;br /&gt;
&lt;br /&gt;
Everything on the CompactFlash will be deleted.&lt;br /&gt;
&lt;br /&gt;
A simple example below:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ sudo put-image --target=/dev/sdc --boot=/dev/sda --append=&amp;quot;irqpoll&amp;quot; emac-image-x86.tar.gz&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====ARM Image Install====&lt;br /&gt;
&lt;br /&gt;
EMAC ARM systems utilize U-Boot or RedBoot for the bootloader. While the procedure differs between each board, images are loaded from a TFTP server on the local network and programmed to flash through U-Boot or RedBoot. EMAC maintains documentation on how to load and program images for each of these bootloaders; please refer to these guides for specific instructions.&lt;br /&gt;
&lt;br /&gt;
[[Loading Images with U-Boot]]&lt;br /&gt;
[[Loading Images with RedBoot]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Custom Development]]&lt;/div&gt;</summary>
		<author><name>Mcoleman</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.emacinc.com/index.php?title=Building_the_Linux_Kernel&amp;diff=510</id>
		<title>Building the Linux Kernel</title>
		<link rel="alternate" type="text/html" href="https://wiki.emacinc.com/index.php?title=Building_the_Linux_Kernel&amp;diff=510"/>
		<updated>2013-05-28T19:35:51Z</updated>

		<summary type="html">&lt;p&gt;Mcoleman: complex lists&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page covers the process of configuring and compiling the Linux kernel for a particular board using the standard EMAC kernel build script. This process assumes that you have already acquired the following software: &lt;br /&gt;
&lt;br /&gt;
# Software Development Kit for target hardware&lt;br /&gt;
# Linux kernel source for target hardware (generally provided via EMAC public SVN server)&lt;br /&gt;
# Kernel build script for target hardware&lt;br /&gt;
&lt;br /&gt;
If you do not know where to access the items above for your board, contact EMAC for more information.&lt;br /&gt;
&lt;br /&gt;
The example below will assume that a kernel image for the [[SoM-9307]] module will be created, but the instructions apply to other hardware as well assuming that the correct SDK, kernel tree, and build script is used.&lt;br /&gt;
&lt;br /&gt;
==Setup==&lt;br /&gt;
&lt;br /&gt;
The current kernel tree for the [[SoM]]-9307 is &amp;lt;/code&amp;gt;linux-2.6.25-ep93xx&amp;lt;/code&amp;gt;. The&lt;br /&gt;
current SDK is the EMAC OE arm SDK, which should be configured for the&lt;br /&gt;
SoM-9307. The steps below assume that the &amp;lt;code&amp;gt;kernel-build-cross.sh&amp;lt;/code&amp;gt; script is&lt;br /&gt;
located in the same directory as the kernel tree. Be sure to modify the script&lt;br /&gt;
so that the CROSS variable references the location of the SDK on your system.&lt;br /&gt;
Also note that you may have difficulties using this script with the dash shell&lt;br /&gt;
(default on Ubuntu Linux variants and some other distributions). If this is the&lt;br /&gt;
case, change the top line of the kernel build script to reference &amp;lt;code&amp;gt;/bin/bash&amp;lt;/code&amp;gt;&lt;br /&gt;
rather than &amp;lt;code&amp;gt;/bin/sh&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==Configuring the Kernel==&lt;br /&gt;
&lt;br /&gt;
The first step for building the kernel is to [[configure it]] as desired. EMAC&lt;br /&gt;
provides default configuration files for each board as a part of the kernel&lt;br /&gt;
tree. For the SoM-9307, this file is&lt;br /&gt;
&amp;lt;code&amp;gt;linux-2.6.25-ep93xx/arch/arm/configs/som9307_defconfig&amp;lt;/code&amp;gt;. When configuring the&lt;br /&gt;
kernel it is important to remember that many configuration options are&lt;br /&gt;
necessary to have a working kernel image. Use the following steps to configure&lt;br /&gt;
the kernel:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;cl&amp;gt;&lt;br /&gt;
1. Copy the default configuration file to &amp;lt;code&amp;gt;.config&amp;lt;/code&amp;gt; in the kernel source tree. This only needs to be done the first time that you start a new build from a blank configuration. &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ cp linux-2.6.25-ep93xx/arch/arm/configs/som9307_defconfig linux-2.6.25-ep93xx/.config&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
* Run the kernel build script with the config option to bring up the kernel&lt;br /&gt;
“menuconfig”. The first argument to the script is the kernel source tree. The&lt;br /&gt;
second option is one of &amp;lt;code&amp;gt;config&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;build&amp;lt;/code&amp;gt;. The final option is a build-suffix;&lt;br /&gt;
this is used as a tag for the directory that the kernel will be built in. You&lt;br /&gt;
may use any string that you like, such as a date tag (&amp;lt;code&amp;gt;20090101&amp;lt;/code&amp;gt;) or machine&lt;br /&gt;
name (&amp;lt;code&amp;gt;som9307&amp;lt;/code&amp;gt;). Using &amp;lt;code&amp;gt;som9307&amp;lt;/code&amp;gt; as the build-suffix will cause the kernel to be&lt;br /&gt;
built in a directory named &amp;lt;code&amp;gt;build-2.6.25-som9307&amp;lt;/code&amp;gt;. &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ ./kernel-build-cross.sh linux-2.6.25-ep93xx config som9307&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
* This will bring up the kernel menu-driven configuration utility. Make any configuration changes desired, selecting features as a built-in or as modules (when available). The space bar is used to select an option, the 'm' key can be used to configure the selected option as a module. After you are finished, select &amp;lt;code&amp;gt;Exit&amp;lt;/code&amp;gt;. The new configuration will be saved as &amp;lt;code&amp;gt;.config&amp;lt;/code&amp;gt; under the newly created build directory. When you use the same build-suffix with the kernel build script in the future, this configuration will be used. Note that the build script removes the &amp;lt;code&amp;gt;.config&amp;lt;/code&amp;gt; file from the kernel source tree and saves it to a file called &amp;lt;code&amp;gt;prevconfig&amp;lt;/code&amp;gt; in the kernel source tree.&lt;br /&gt;
&amp;lt;/cl&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Building the Kernel==&lt;br /&gt;
&lt;br /&gt;
Once the kernel is configured, a new image can be built. Use the following steps to build a new kernel image:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;cl&amp;gt;&lt;br /&gt;
1. Run the kernel build script with the build option, using the same build-suffix used in the configuration step. &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ ./kernel-build-cross.sh linux-2.6.25-ep93xx build som9307&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
* The kernel should begin compiling now. This will take several minutes to complete depending on your configuration and the speed of the development machine that you are using. Only move on to the next step if the build completes with no errors.&lt;br /&gt;
* The new kernel image is located in the build directory, the exact location depending on your architecture and image type. For the SoM-9307, the image is under &amp;lt;code&amp;gt;build-2.6.25-som9307/arch/arm/boot/zImage&amp;lt;/code&amp;gt;. This is the image that will get loaded onto the board and executed by the bootloader. Another important file created by the build script is an archive of all of the modules that were created during the build process. This file is stored under the build directory. From the build steps above, the archive would be &amp;lt;code&amp;gt;build-2.6.25-som9307/kernel-2.6.25.tar.gz&amp;lt;/code&amp;gt;.&lt;br /&gt;
&amp;lt;/cl&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{mbox | type = notice | text = Note that if you recompile the kernel but do not change the configuration or source code for any of the modules, it may not be necessary to reload the modules archive. This is often the case for custom driver development.}}&lt;br /&gt;
&lt;br /&gt;
==Loading==&lt;br /&gt;
&lt;br /&gt;
===Kernel Image===&lt;br /&gt;
&lt;br /&gt;
This step is highly architecture dependent. On most x86 boards and some other systems, the kernel image is stored and loaded from the root flash. If this is the case, the only step required is to load the kernel archive (i.e. &amp;lt;code&amp;gt;kernel-2.6.25.tar.gz&amp;lt;/code&amp;gt;) onto the system and extract it. Many ARM systems typically store the kernel in a binary partition on the flash storage device separate from the root filesystem. In this case, the kernel image file must be loaded onto the system and written to the flash. The basic process for loading and testing the new kernel is as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;cl&amp;gt;&lt;br /&gt;
1. Load the kernel modules archive onto the board. The example below assumes that the IP address of the board is &amp;lt;code&amp;gt;10.0.2.41&amp;lt;/code&amp;gt;. &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ scp build-2.6.25-som9307/kernel-2.6.25.tar.gz root@10.0.2.41:/tmp &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
* Extract the kernel modules archive to &amp;lt;code&amp;gt;/&amp;lt;/code&amp;gt; on the board. Make sure that the root flash is mounted read/write and run the following on the board after logging in as root:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@emac-oe:~# cd /&lt;br /&gt;
root@emac-oe:~# tar xzvf /tmp/kernel-2.6.25.tar.gz /lib/modules&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/cl&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Custom Development]]&lt;/div&gt;</summary>
		<author><name>Mcoleman</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.emacinc.com/index.php?title=Building_Existing_Software_Packages_with_EMAC_OE_SDK&amp;diff=509</id>
		<title>Building Existing Software Packages with EMAC OE SDK</title>
		<link rel="alternate" type="text/html" href="https://wiki.emacinc.com/index.php?title=Building_Existing_Software_Packages_with_EMAC_OE_SDK&amp;diff=509"/>
		<updated>2013-05-28T19:34:07Z</updated>

		<summary type="html">&lt;p&gt;Mcoleman: complex list&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{EMAC OE SDK Conventions}}&lt;br /&gt;
&lt;br /&gt;
It is very common to need to be able to build existing software projects for the target hardware rather than developing the software from scratch. This feature is especially important in an open source environment, where countless libraries and utilities are available for use and often times need to be compiled to match the target architecture. Fortunately, EMAC OE SDK toolchains are standard GCC packages designed and configured to make this process as easy as possible. In addition, most software projects are developed to allow for cross-platform development.&lt;br /&gt;
&lt;br /&gt;
This guide provides an overview of the most common tasks associated with compiling existing software projects using the SDK. Note, however, that build methods differ significantly depending on the project design. Refer to the project documentation or support for information on how to cross-compile the software; the EMAC OE SDK can be treated as a standard GCC toolchain in this respect. Table 1 below denotes some conventions used in this guide.&lt;br /&gt;
&lt;br /&gt;
==Makefile-based Projects==&lt;br /&gt;
&lt;br /&gt;
Some projects have a build system based on a set of makefiles that are responsible for compiling and packaging the software. In general, configuring these projects to compile using the EMAC OE SDK is a simple process. In some instances, the software designers may have included a variable in the makefile which allows a cross-compiler prefix setting. In other cases, the CC and other makefile variables can be modified to direct make to compile using the EMAC OE SDK.&lt;br /&gt;
&lt;br /&gt;
It may be advantageous to add the cross-compiler bin directory to the system PATH variable temporarily before compiling to simplify Makefile modifications. This can be done with a command such as the following:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ export PATH=$PATH:/path/to/sdk/EMAC-OE-arm-linux-gnueabi-SDK_XX.YY/gcc-4.2.4-arm-linux-gnueabi/bin&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{mbox | type = notice | text = Note that running the command above will only affect the current terminal session.}}&lt;br /&gt;
&lt;br /&gt;
===MTD Utilities Project Example===&lt;br /&gt;
&lt;br /&gt;
The MTD Utilities project &amp;lt;code&amp;gt;mtd-utils&amp;lt;/code&amp;gt; is a good example of a Makefile-based build system that can easily be built using the EMAC OE SDK. Follow the steps below to accomplish this task.&lt;br /&gt;
&lt;br /&gt;
{{mbox | type = notice | text = The instructions in this section are valid as of the master git branch on 4/09/11. Future source changes may impact the required steps for compilation.}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;cl&amp;gt;&lt;br /&gt;
1. Begin by downloading the mtd-utils source code. Assuming that git is installed on the development system, run the following command to get the most recent version. Note that this version will be different from the stable release installed on EMAC OE systems by default.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ git clone git://git.infradead.org/mtd-utils.git &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
*  After downloading the source, navigate to the source directory &amp;lt;code&amp;gt;mtd-utils&amp;lt;/code&amp;gt; and open &amp;lt;code&amp;gt;Makefile&amp;lt;/code&amp;gt; in the top-level directory. This file defines various make targets and compilation flags used to compile the source. Notice that the file &amp;lt;code&amp;gt;common.mk&amp;lt;/code&amp;gt; is sourced with the line include &amp;lt;code&amp;gt;common.mk&amp;lt;/code&amp;gt;. This is similar to the &amp;lt;code&amp;gt;global.properties&amp;lt;/code&amp;gt; file in the EMAC OE SDK.&lt;br /&gt;
* Close the &amp;lt;code&amp;gt;Makefile&amp;lt;/code&amp;gt; editor and open the &amp;lt;code&amp;gt;common.mk&amp;lt;/code&amp;gt; file. At the top of the file, &amp;lt;code&amp;gt;CC&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;AR&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;RANLIB&amp;lt;/code&amp;gt; are defined using the &amp;lt;code&amp;gt;CROSS&amp;lt;/code&amp;gt; variable, which is not set in either &amp;lt;code&amp;gt;common.mk&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;Makefile&amp;lt;/code&amp;gt;. An exert is shown below:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;make&amp;quot;&amp;gt;&lt;br /&gt;
CC := $(CROSS)gcc&lt;br /&gt;
AR := $(CROSS)ar&lt;br /&gt;
RANLIB := $(CROSS)ranlib&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
If the &amp;lt;code&amp;gt;CROSS&amp;lt;/code&amp;gt; variable is defined when &amp;lt;code&amp;gt;make&amp;lt;/code&amp;gt; is run, the specific toolchain to use can be specified. Also note that &amp;lt;code&amp;gt;CFLAGS&amp;lt;/code&amp;gt; is defined using a &amp;lt;code&amp;gt;?=&amp;lt;/code&amp;gt; assignment, which means that the assignment will only be made if &amp;lt;code&amp;gt;CFLAGS&amp;lt;/code&amp;gt; is undefined:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;make&amp;quot;&amp;gt;&lt;br /&gt;
CFLAGS ?= -O2 -g&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
* Close &amp;lt;code&amp;gt;common.mk&amp;lt;/code&amp;gt; without making any changes.&lt;br /&gt;
* In order to compile the source correctly, the &amp;lt;code&amp;gt;CROSS&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;CFLAGS&amp;lt;/code&amp;gt; variables should be defined. The tuning flags for the target architecture to be added to the &amp;lt;code&amp;gt;CFLAGS&amp;lt;/code&amp;gt; variable should be used from the &amp;lt;code&amp;gt;ARCHFLAGS&amp;lt;/code&amp;gt; variable in the &amp;lt;code&amp;gt;global.properties&amp;lt;/code&amp;gt; file of the EMAC OE SDK. The following steps utilize tuning flags for an armv5te processor-based system. Although the path to the SDK toolchain could be included directly in the &amp;lt;code&amp;gt;CROSS&amp;lt;/code&amp;gt; variable in this instance, this example works by adding the SDK toolchain to the system &amp;lt;code&amp;gt;PATH&amp;lt;/code&amp;gt; variable. The path and prefix used will differ depending on the target architecture of the EMAC OE SDK; refer to &amp;lt;code&amp;gt;global.properties&amp;lt;/code&amp;gt; in the SDK to determine the correct settings. The &amp;lt;code&amp;gt;DESTDIR&amp;lt;/code&amp;gt; variable controls where the files are put when running the &amp;lt;code&amp;gt;install&amp;lt;/code&amp;gt; make target. The &amp;lt;code&amp;gt;WITHOUT_XATTR&amp;lt;/code&amp;gt; flag must be set to disable features of the software that are not available on EMAC OE.&lt;br /&gt;
 i. Before compiling, several source changes are required to match the setup of the SDK. These include changing references from &amp;lt;code&amp;gt;lzo2&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;lzo&amp;lt;/code&amp;gt;, and changing the lzo include prefix. Run the following commands from the mtd-utils directory to make these changes:&lt;br /&gt;
 &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
 developer@ldc:~$ for file in `find . -name Makefile`; do sed -i 's:lzo2:lzo:g' $file; done&lt;br /&gt;
 developer@ldc:~$ for file in `find . -name '*.c'`; do sed -i 's:lzo/::g' $file; done&lt;br /&gt;
 &amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
 * Run the following commands to set the variables:&lt;br /&gt;
 &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
 developer@ldc:~$ export PATH=$PATH:/path/to/sdk/EMAC-OE-arm-linux-gnueabi-SDK_XX.YY/gcc-4.2.4-arm-linux-gnueabi/bin&lt;br /&gt;
 developer@ldc:~$ export CROSS=arm-linux-gnueabi-&lt;br /&gt;
 developer@ldc:~$ export CFLAGS=&amp;quot;-O2 -g -march=armv5te -mtune=arm926ej-s&amp;quot;&lt;br /&gt;
 developer@ldc:~$ export DESTDIR=Install&lt;br /&gt;
 developer@ldc:~$ export WITHOUT_XATTR=1&lt;br /&gt;
 &amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
* Once the environment has been set up, &amp;lt;code&amp;gt;make&amp;lt;/code&amp;gt; can be used to compile the source code:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ make all&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
* After successfully compiling the project, the &amp;lt;code&amp;gt;install&amp;lt;/code&amp;gt; make target can be used to package all of the software into the &amp;lt;code&amp;gt;Install&amp;lt;/code&amp;gt; directory as specified by the &amp;lt;code&amp;gt;DESTDIR&amp;lt;/code&amp;gt; variable:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ make install&lt;br /&gt;
developer@ldc:~$ ls -R Install&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
Install:&lt;br /&gt;
usr&lt;br /&gt;
 &lt;br /&gt;
Install/usr:&lt;br /&gt;
sbin  share&lt;br /&gt;
 &lt;br /&gt;
Install/usr/sbin:&lt;br /&gt;
docfdisk      flash_erase     flash_lock      flash_unlock  jffs2dump   nanddump   nftldump     rfddump      sumtool&lt;br /&gt;
doc_loadbios  flash_eraseall  flash_otp_dump  ftl_check     mkfs.jffs2  nandtest   nftl_format  rfdformat&lt;br /&gt;
flashcp       flash_info      flash_otp_info  ftl_format    mtd_debug   nandwrite  recv_image   serve_image&lt;br /&gt;
 &lt;br /&gt;
Install/usr/share:&lt;br /&gt;
man&lt;br /&gt;
 &lt;br /&gt;
Install/usr/share/man:&lt;br /&gt;
man1&lt;br /&gt;
 &lt;br /&gt;
Install/usr/share/man/man1:&lt;br /&gt;
mkfs.jffs2.1.gz&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
While the procedure in this example is specific to &amp;lt;code&amp;gt;mtd-utils&amp;lt;/code&amp;gt;, many makefile-based projects will require similar steps for cross-compiling.&lt;br /&gt;
&amp;lt;/cl&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Autotools-based Projects==&lt;br /&gt;
&lt;br /&gt;
The GNU build system is known as Autotools. Autotools is a group of applications that are designed to provide a configurable build system to allow compilation on different platforms and environments. A &amp;lt;code&amp;gt;configure&amp;lt;/code&amp;gt; script and set of input files are used to generate makefiles based on options passed to the configure script and deduced from the system environment. This includes tests for compiler options, library functions, install configuration, and other assorted variables.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;configure&amp;lt;/code&amp;gt; script is the most important step in building an autotools-based project. Although available options for &amp;lt;code&amp;gt;configure&amp;lt;/code&amp;gt; vary depending on the project design, there are common options shared between most autotools projects. &lt;br /&gt;
&lt;br /&gt;
===libConfuse Example Project===&lt;br /&gt;
&lt;br /&gt;
The libConfuse project is a simple C library written for parsing configuration files. It uses an autotools build system for configuration. The steps below demonstrate how to build libConfuse and should be used as an example for building other autotools-based projects. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;cl&amp;gt;&lt;br /&gt;
1. The source code for the libConfuse project can be downloaded as described on the project website [http://www.nongnu.org/confuse/]. For this example, release 2.7 is used: [http://savannah.nongnu.org/download/confuse/confuse-2.7.tar.gz]. After downloading the source, extract the archive and navigate to the top-level directory of the project (i.e. `confuse-2.7`).&lt;br /&gt;
* Read through the &amp;lt;code&amp;gt;README&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;INSTALL&amp;lt;/code&amp;gt; files for information on the project and general information on how to build it. Also, look at the help output from &amp;lt;code&amp;gt;configure&amp;lt;/code&amp;gt; to see a summary of the available options:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ ./configure --help&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
* Before beginning, the system &amp;lt;code&amp;gt;PATH&amp;lt;/code&amp;gt; variable should be changed to include the SDK toolchain as in the makefile-based project example. The &amp;lt;code&amp;gt;CFLAGS&amp;lt;/code&amp;gt; variable should also be set. If the &amp;lt;code&amp;gt;CC&amp;lt;/code&amp;gt; variable is set, it should be set to &amp;lt;code&amp;gt;arm-linux-gnueabi-gcc&amp;lt;/code&amp;gt; (or the appropriate value for the target); if not set the compiler name will be detected from the options passed to configure. The &amp;lt;code&amp;gt;CFLAGS&amp;lt;/code&amp;gt; architecture tuning values should be set according to the &amp;lt;code&amp;gt;global.properties&amp;lt;/code&amp;gt; file in the EMAC OE SDK. The &amp;lt;code&amp;gt;DESTDIR&amp;lt;/code&amp;gt; variable determines where the files will be installed to when the &amp;lt;code&amp;gt;install&amp;lt;/code&amp;gt; make target is run. &amp;lt;code&amp;gt;DESTDIR&amp;lt;/code&amp;gt; must be an absolute path for the libConfuse project, so the current working directory is added to the variable using the &amp;lt;code&amp;gt;pwd&amp;lt;/code&amp;gt; command. The following commands are an example of how to set up the environment correctly:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ export CFLAGS=&amp;quot;-O2 -march=armv5te -mtune=arm926ej-s&amp;quot;&lt;br /&gt;
developer@ldc:~$ export DESTDIR=`pwd`/Install&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
* After setting the environment, &amp;lt;code&amp;gt;configure&amp;lt;/code&amp;gt; can be run with the appropriate options to configure the build system and generate the makefiles. The code below shows an example configuration used by EMAC OE. Be sure to set the host and target correctly based on the architecture:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ ./configure --build=i686-linux --host=arm-linux-gnueabi --target=arm-linux-gnueabi \&lt;br /&gt;
        --prefix=/usr --exec_prefix=/usr --bindir=/usr/bin --sbindir=/usr/sbin \&lt;br /&gt;
        --datadir=/usr/share  \&lt;br /&gt;
        --infodir=/usr/share/info \&lt;br /&gt;
        --mandir=/usr/share/man --enable-shared&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The configuration should complete successfully. If any problems are reported that result in an error, check the environment settings and &amp;lt;code&amp;gt;configure&amp;lt;/code&amp;gt; options again. &lt;br /&gt;
* Now that &amp;lt;code&amp;gt;configure&amp;lt;/code&amp;gt; has generated all of the makefiles for the project, &amp;lt;code&amp;gt;make&amp;lt;/code&amp;gt; can be used to compile the source code:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ make all&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
If any errors are encountered during compilation, examine the output of &amp;lt;code&amp;gt;configure&amp;lt;/code&amp;gt; and make sure that all of the environment variables and &amp;lt;code&amp;gt;configure&amp;lt;/code&amp;gt; options were specified correctly. &lt;br /&gt;
* Once compilation is complete, the &amp;lt;code&amp;gt;install&amp;lt;/code&amp;gt; target can be used to package all of the necessary files together so that they can be transferred to the target board.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ make install&lt;br /&gt;
developer@ldc:~$ ls -R Install&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
Install:&lt;br /&gt;
usr&lt;br /&gt;
 &lt;br /&gt;
Install/usr:&lt;br /&gt;
include  lib  share&lt;br /&gt;
 &lt;br /&gt;
Install/usr/include:&lt;br /&gt;
confuse.h&lt;br /&gt;
 &lt;br /&gt;
Install/usr/lib:&lt;br /&gt;
libconfuse.a  libconfuse.la  libconfuse.so  libconfuse.so.0  libconfuse.so.0.0.0  pkgconfig&lt;br /&gt;
 &lt;br /&gt;
Install/usr/lib/pkgconfig:&lt;br /&gt;
libconfuse.pc&lt;br /&gt;
 &lt;br /&gt;
Install/usr/share:&lt;br /&gt;
locale&lt;br /&gt;
 &lt;br /&gt;
Install/usr/share/locale:&lt;br /&gt;
fr  sv&lt;br /&gt;
 &lt;br /&gt;
Install/usr/share/locale/fr:&lt;br /&gt;
LC_MESSAGES&lt;br /&gt;
 &lt;br /&gt;
Install/usr/share/locale/fr/LC_MESSAGES:&lt;br /&gt;
confuse.mo&lt;br /&gt;
 &lt;br /&gt;
Install/usr/share/locale/sv:&lt;br /&gt;
LC_MESSAGES&lt;br /&gt;
 &lt;br /&gt;
Install/usr/share/locale/sv/LC_MESSAGES:&lt;br /&gt;
confuse.mo&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Note that not all of the files installed would be necessary to install on the board, such as the man pages and pkgconfig information.&lt;br /&gt;
&amp;lt;/cl&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:EMAC OE SDK]]&lt;/div&gt;</summary>
		<author><name>Mcoleman</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.emacinc.com/index.php?title=Remote_Debugging_EMAC_OE_SDK_Projects_with_gdbserver&amp;diff=508</id>
		<title>Remote Debugging EMAC OE SDK Projects with gdbserver</title>
		<link rel="alternate" type="text/html" href="https://wiki.emacinc.com/index.php?title=Remote_Debugging_EMAC_OE_SDK_Projects_with_gdbserver&amp;diff=508"/>
		<updated>2013-05-28T19:13:50Z</updated>

		<summary type="html">&lt;p&gt;Mcoleman: complex list&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{EMAC OE SDK Conventions}}&lt;br /&gt;
&lt;br /&gt;
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 binary resulting from the compile 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 while running the debugger.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
This guide is intended to build a basic understanding of how to use gdbserver with EMAC products. It is not intended as a general guide to debugging computer programs. For help with that, see the GDB man pages on the development system or read [this manual] on debugging with GDB.&lt;br /&gt;
&lt;br /&gt;
==Setup==&lt;br /&gt;
&lt;br /&gt;
Using &amp;lt;code&amp;gt;gdbserver&amp;lt;/code&amp;gt; involves setting up both the target machine and the development machine. This requires that the binary application be present on both development and target machines. The development machine copy of the application must be compiled with debug flags whereas this is not strictly necessary for the target machine. See the [Optional &amp;lt;code&amp;gt;global.properties&amp;lt;/code&amp;gt; Modifications Section] on the New EMAC OE SDK Project Guide for more information. See the [[[EMAC OE Getting Started Guide]]] for more information on how to connect to the target EMAC product using a serial port or Ethernet connection.&lt;br /&gt;
&lt;br /&gt;
===Target Machine===&lt;br /&gt;
&lt;br /&gt;
Because EMAC OE builds are distributed with &amp;lt;code&amp;gt;gdbserver&amp;lt;/code&amp;gt;, installation is not a concern. The only setup necessary is to run &amp;lt;code&amp;gt;gdbserver&amp;lt;/code&amp;gt; with &amp;lt;code&amp;gt;target_program&amp;lt;/code&amp;gt;: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;cl&amp;gt;&lt;br /&gt;
1. If the target application is already running, use the attachpid option to connect &amp;lt;code&amp;gt;gdbserver&amp;lt;/code&amp;gt; to the application as shown below. The &amp;lt;code&amp;gt;PID&amp;lt;/code&amp;gt; argument can be determined using &amp;lt;code&amp;gt;pidof&amp;lt;/code&amp;gt;.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ pidof target_program&lt;br /&gt;
developer@ldc:~$ gdbserver target_machine --attach PID&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* If the target application is not already running, the name of the binary may be included as an argument to the &amp;lt;code&amp;gt;gdbserver&amp;lt;/code&amp;gt; program call.&lt;br /&gt;
&amp;lt;snytaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ gdbserver target_machine target_program [ARGS]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/cl&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This establishes a &amp;lt;code&amp;gt;gdbserver&amp;lt;/code&amp;gt; port on the target machine that listens for incoming connections from GDB on the development machine. In debug terminology, &amp;lt;code&amp;gt;gdbserver&amp;lt;/code&amp;gt; is “attached” to the process ID of the program being debugged. In reality, though, GDB is attached to the process ID of a proxy which passes the messages to and from the remote device under test. &lt;br /&gt;
&lt;br /&gt;
The next step is to run GDB on the development machine using the &amp;lt;code&amp;gt;target_program&amp;lt;/code&amp;gt;/&lt;br /&gt;
&lt;br /&gt;
===Development Machine===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;cl&amp;gt;&lt;br /&gt;
1. First, &amp;lt;code&amp;gt;cd&amp;lt;/code&amp;gt; to the directory where the targe executable is stored.&lt;br /&gt;
* Run the EMAC OE SDK GDB:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ /path/to/sdk/EMAC-OE-arm-linux-gnueabi-SDK_4.0/gcc-4.2.4-arm-linux-gnueabi/bin/arm-linux-gnueabi-gdb target_program&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
* Run the following commands in GDB to prepare for the debug session:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;gdb&amp;quot;&amp;gt;&lt;br /&gt;
(gdb) target remote target_machine&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/cl&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{mbox | type = warning | text = Note that the location of the GDB in the toolchain may differ from what is shown above depending on which version of the SDK is used.}}&lt;br /&gt;
&lt;br /&gt;
{{mbox | type = notice | text = If the gdb executable, or any other executable you run, is located in a directory which is in the PATH environment variable, you can simply run that command without the long path prefix. Sourcing the environment variables generated by the EMAC script for this will provide you with such a path. The script which creates the file to source also creates a symbolic link for arm-linux-gnueabi-gdb called, simply, gdb. With your shell environment setup this way, you could simply execute: &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ gdb target_program&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
in place of the long command given in step 2, above.&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
==Sample GDB Session==&lt;br /&gt;
&lt;br /&gt;
This example GDB session uses the EMAC OE SDK example project named &amp;lt;code&amp;gt;pthread_demo&amp;lt;/code&amp;gt;. It consists of the single source file &amp;lt;code&amp;gt;pthread_demo.c&amp;lt;/code&amp;gt;. The program is called with a single integer argument indicating how many &amp;lt;code&amp;gt;reader&amp;lt;/code&amp;gt; threads the user wishes to create. The following describes the tasks of the &amp;lt;code&amp;gt;main&amp;lt;/code&amp;gt; thread: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;cl&amp;gt;&lt;br /&gt;
1. The &amp;lt;code&amp;gt;main&amp;lt;/code&amp;gt; thread performs user input validation. It prints a usage message according to the argument passed to it on the command line. The function expects the user to pass a number indicating how many threads should be spawned.&lt;br /&gt;
* The &amp;lt;code&amp;gt;main&amp;lt;/code&amp;gt; thread initiates a new thread which uses the &amp;lt;code&amp;gt;generator()&amp;lt;/code&amp;gt; function to perform the following tasks:&lt;br /&gt;
 i. Checks to see if the number of &amp;lt;code&amp;gt;reader&amp;lt;/code&amp;gt; threads matches the number of times a &amp;lt;code&amp;gt;reader&amp;lt;/code&amp;gt; thread has acquired the mutex lock and performed its task. If the two values do match, then the &amp;lt;code&amp;gt;generator&amp;lt;/code&amp;gt; thread unlocks the mutex, breaks out of the while loop and moves on to line 167 to gracefully exit. If the two values do not match, then the &amp;lt;code&amp;gt;generator&amp;lt;/code&amp;gt; thread continues through the rest of the while loop described in steps 2.2 and 2.3.&lt;br /&gt;
 * Generates random data to be stored in the data struct shared by all the threads. To do this, it protects the data struct with the use of a mutex variable.&lt;br /&gt;
 * Sleeps after giving up its lock on the mutex so that another thread might have a chance to acquire the lock.&lt;br /&gt;
* After creating the &amp;lt;code&amp;gt;generator&amp;lt;/code&amp;gt; thread the &amp;lt;code&amp;gt;main&amp;lt;/code&amp;gt; thread iteratively creates as many &amp;lt;code&amp;gt;reader&amp;lt;/code&amp;gt; threads as indicated by the single integer argument. Each &amp;lt;code&amp;gt;reader&amp;lt;/code&amp;gt; thread performs the following tasks:&lt;br /&gt;
 i. Waits for a chance to acquire the mutex &amp;lt;code&amp;gt;lock&amp;lt;/code&amp;gt;. Once the mutex &amp;lt;code&amp;gt;lock&amp;lt;/code&amp;gt; is acquired, it prints the value of the random number &amp;lt;code&amp;gt;generated&amp;lt;/code&amp;gt; by the generator thread in its last run.&lt;br /&gt;
 * Increments an integer in the &amp;lt;code&amp;gt;data&amp;lt;/code&amp;gt; struct to indicate that it has completed its task.&lt;br /&gt;
 * Gives up its lock on the mutex and exits.&lt;br /&gt;
* After creating the prescribed number of &amp;lt;code&amp;gt;reader&amp;lt;/code&amp;gt; threads, the &amp;lt;code&amp;gt;main&amp;lt;/code&amp;gt; thread then waits for each thread created to exit gracefully. &lt;br /&gt;
* The &amp;lt;code&amp;gt;main&amp;lt;/code&amp;gt; thread exists.&lt;br /&gt;
&amp;lt;/cl&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The SDK version of &amp;lt;code&amp;gt;pthread_demo.c&amp;lt;/code&amp;gt; works according to the description above with a &amp;lt;code&amp;gt;MAX_THREAD&amp;lt;/code&amp;gt; value of 100. However, for the purpose of this example debug session it is instructive to use a faulty version of the same program. Replace lines 75-80 in &amp;lt;code&amp;gt;pthread_demo.c&amp;lt;/code&amp;gt; with the code snippet shown in Listing 1 below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
if ((data.num_threads &amp;lt; 1) || (data.num_threads &amp;lt; MAX_THREAD)) {&lt;br /&gt;
        fprintf(stderr,&lt;br /&gt;
                &amp;quot;The number of thread should between 1 and %d\n&amp;quot;,&lt;br /&gt;
                MAX_THREAD);&lt;br /&gt;
        exit(EXIT_FAILURE);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/cl&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Useful GDB Commands===&lt;br /&gt;
&lt;br /&gt;
The following is a brief description of some essential GDB commands. Each description is followed by a link to the official GDB documentation page that has more specific information about what the command does and how to use it. Please note that the official GDB documentation is targeted for the latest GDB release which at the time of writing this documentation is 7.4. The version of GDB that EMAC distributes with the OE products, however, is version 6.8. Because of this, the links to documentation below may provide slightly different information. The biggest difference between the two version of GDB, however, is in the support for debugging programs with multiple threads. This is reflected in the documentation as well. Because of this, EMAC has set up ftp access to GDB 6.8 documentation on its web server. It is highly recommended that the GDB 6.8 documentation be referenced in cases where the program does not seem to support commands or options specified in the current official documentation. &lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Command !! Description &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;start/run&amp;lt;/code&amp;gt;&lt;br /&gt;
|| These commands are used to start the debugged program with the only difference being that start automatically pauses execution at the beginning of the program's main function whereas run must be told explicitly where to pause using the breakpoint command listed below.&lt;br /&gt;
See also [Debugging with GDB, Section 4.2: Starting your Program]&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;kill&amp;lt;/code&amp;gt;&lt;br /&gt;
|| Used to kill the currently-running instance of target_program.&lt;br /&gt;
See also [Debugging with GDB, Section 4.9: Killing the Child Process]&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;print&amp;lt;/code&amp;gt;&lt;br /&gt;
|| Used to print the value of an expression.&lt;br /&gt;
See also [Debugging with GDB, Section 10: Examining Data]&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;list&amp;lt;/code&amp;gt;&lt;br /&gt;
|| List contents of function or specified line.&lt;br /&gt;
See also [Debugging with GDB, Section 9: Examining Source Files]&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;layout&amp;lt;/code&amp;gt;&lt;br /&gt;
|| This is a TUI (Text User Interface) command that enables the programmer to view multiple debug views at once including source code, assembly, and registers.&lt;br /&gt;
See also [Debugging with GDB, Section 25.4: TUI Commands]&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;disassemble&amp;lt;/code&amp;gt;&lt;br /&gt;
|| This command allows the programmer to see assembler instructions.&lt;br /&gt;
See also [Debugging with GDB, Section 9.6: Source and Machine Code]&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;break&amp;lt;/code&amp;gt;&lt;br /&gt;
|| This command specifies a function name, line number, or instruction at which GDB is to pause execution.&lt;br /&gt;
See also [Debugging with GDB, Section 5.1: Breakpoints]&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;next/nexti, step/stepi&amp;lt;/code&amp;gt;&lt;br /&gt;
|| Allow the programmer to step through a program without specifying breakpoints. The &amp;lt;code&amp;gt;next/nexti&amp;lt;/code&amp;gt; commands step over function calls, stopping on the next line of the same stack frame; &amp;lt;code&amp;gt;step/stepi&amp;lt;/code&amp;gt;, step into function calls, stopping on the first line in the next stack frame. The difference between &amp;lt;code&amp;gt;step/next&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;stepi/nexti&amp;lt;/code&amp;gt; is that the &amp;lt;code&amp;gt;i&amp;lt;/code&amp;gt; indicates instruction-by-instruction stepping at the assembly language level.&lt;br /&gt;
See also [Debugging with GDB, Section 5.2: Continuing and Stepping]&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;continue&amp;lt;/code&amp;gt;&lt;br /&gt;
|| Used to continue program execution from the address where it was last stopped.&lt;br /&gt;
See the Debugging with GDB link for &amp;lt;code&amp;gt;next/step&amp;lt;/code&amp;gt; for more information about the &amp;lt;code&amp;gt;continue&amp;lt;/code&amp;gt; command.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;bt&amp;lt;/code&amp;gt;&lt;br /&gt;
|| Short for &amp;quot;backtrace,&amp;quot; which displays to the programmer a brief summary of execution up to the current point in the program. This is useful because it shows a nested list of stack frames starting with the current one.&lt;br /&gt;
See also [Debugging with GDB, Section 8.2: Backtrace]&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;quit&amp;lt;/code&amp;gt;&lt;br /&gt;
||  This will quit the debugging session, and return you to the shell. The Control-D key combination is another way to accomplish this.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Session Walk-through===&lt;br /&gt;
&lt;br /&gt;
This debug session walk-through assumes that the program has been compiled using the modified source code above and that both the target machine and the development machine have been set up according to the above Setup section. The walk-through is divided into multiple “lessons” with the intent of first introducing the use of the commands described above and then actually running GDB to debug a known programming problem. Each lesson may be run independently of the others, but it is recommended that each be run in order starting from Lesson 1 for the first time through.&lt;br /&gt;
&lt;br /&gt;
====Lesson 1: Navigation and Code Display====&lt;br /&gt;
&lt;br /&gt;
This lesson assumes that &amp;lt;code&amp;gt;gdbserver&amp;lt;/code&amp;gt; has been run as in the [Target Machine Setup] section above with an ARG value of 3. Other values are fine so long as they fall within the range of 1 to 100. The number '3' was arbitrarily chosen to avoid having to use a symbolic variable in the explanations below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;cl&amp;gt;&lt;br /&gt;
1. Type &amp;lt;code&amp;gt;b main&amp;lt;/code&amp;gt; to set a breakpoint at the main function in the source code.&lt;br /&gt;
* Type &amp;lt;code&amp;gt;continue&amp;lt;/code&amp;gt;. This will cause the program to continue from the breakpoint set by GDB at startup. The program was passed an argument of 3, indicating that three threads should be created. &lt;br /&gt;
* Type &amp;lt;code&amp;gt;b 73&amp;lt;/code&amp;gt; to set a breakpoint at line 73 in the source code, which should be the line containing &amp;lt;code&amp;gt;data.num_threads = atoi(argv[1]);&amp;lt;/code&amp;gt;&lt;br /&gt;
* Type &amp;lt;code&amp;gt;continue&amp;lt;/code&amp;gt;. The program will continue execution up until line 73 in the source code. At this point, type layout split to view a split screen containing both the source code and the assembly-level machine instructions. Both screens show the program's current location in execution. The assembly-level display shows what the target's processor is actually executing at that point in the source code as shown in the source-level display. To view either of these without the other type layout &amp;lt;code&amp;gt;asm&amp;lt;/code&amp;gt; for just assembly-level and &amp;lt;code&amp;gt;layout src&amp;lt;/code&amp;gt; for just source-level.&lt;br /&gt;
* Type &amp;lt;code&amp;gt;nexti&amp;lt;/code&amp;gt;. This will cause the program to execute the next instruction in the current stack frame which is a mov instruction beginning to prepare the current stack for a call to the library function &amp;lt;code&amp;gt;atoi()&amp;lt;/code&amp;gt;. The details of this process are beyond the scope of this tutorial; essentially, the program needs to store information about the current execution location in the stack for when the &amp;lt;code&amp;gt;atoi()&amp;lt;/code&amp;gt; function finishes. Type &amp;lt;code&amp;gt;ni&amp;lt;/code&amp;gt; (alias for nexti) three more times. You should end up on a &amp;lt;code&amp;gt;bl&amp;lt;/code&amp;gt; instruction in the assembly view as shown in Listing 2 below. The source layout should still show the program on line 73.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;asm&amp;quot;&amp;gt;&lt;br /&gt;
B+ |0x887c &amp;lt;main+112&amp;gt;       ldr    r3, [r11, #-84]                   │&lt;br /&gt;
   |0x8880 &amp;lt;main+116&amp;gt;       add    r3, r3, #4      ; 0x4             │&lt;br /&gt;
   |0x8884 &amp;lt;main+120&amp;gt;       ldr    r3, [r3]                          │&lt;br /&gt;
   |0x8888 &amp;lt;main+124&amp;gt;       mov    r0, r3                            │&lt;br /&gt;
  &amp;gt;|0x888c &amp;lt;main+128&amp;gt;       bl     0x86e0 &amp;lt;atoi&amp;gt;                     │&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
'''Listing 2. GDB Assembly Layout''' - ''Note that the assembly may look different depending on the target architecture.''&lt;br /&gt;
* Type &amp;lt;code&amp;gt;stepi&amp;lt;/code&amp;gt;. This will cause the program to move into the next stack frame and GDB to show the assembly-level instructions of the &amp;lt;code&amp;gt;atoi()&amp;lt;/code&amp;gt; call. Since the library containing &amp;lt;code&amp;gt;atoi()&amp;lt;/code&amp;gt; was likely not compiled with debug symbols, the source-level layout will show the message &amp;lt;code&amp;gt;[ No Source Available ]&amp;lt;/code&amp;gt;.&lt;br /&gt;
* Type &amp;lt;code&amp;gt;bt&amp;lt;/code&amp;gt;. This will cause the program to display a human-readable version of the current stack. Each stack “frame” is represented by the name of the function call it represents with that function's location in memory. Type &amp;lt;code&amp;gt;bt full&amp;lt;/code&amp;gt; to get a list of the variables local to each stack frame.&lt;br /&gt;
* Type &amp;lt;code&amp;gt;finish&amp;lt;/code&amp;gt;. This will cause the current stack frame to return and execution to pause on the next instruction of the previous stack frame.&lt;br /&gt;
* Type &amp;lt;code&amp;gt;kill&amp;lt;/code&amp;gt;. This will cause the current process to be killed by &amp;lt;code&amp;gt;gdbserver&amp;lt;/code&amp;gt; at the target machine. &amp;lt;code&amp;gt;gdbserver&amp;lt;/code&amp;gt; will also terminate at this point. In order to start a new remote debug session, start gdbserver as described in the Target Machine Setup section and re-run step 3 of the [Development Machine Setup] section.&lt;br /&gt;
&amp;lt;/cl&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{mbox | type = warning | text = '''Note:''' &amp;lt;code&amp;gt;b&amp;lt;/code&amp;gt; is an alias for the &amp;lt;code&amp;gt;break&amp;lt;/code&amp;gt; command. &lt;br /&gt;
&amp;lt;code&amp;gt;ni&amp;lt;/code&amp;gt; is an alias for &amp;lt;code&amp;gt;nexti&amp;lt;/code&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
====Lesson 2: Finding the Bug====&lt;br /&gt;
&lt;br /&gt;
Though this sample is contrived, it is still useful to demonstrate how to find a design mistake in an otherwise well-written (no errors or warnings) program. These types of mistakes typically have to do with the array boundary miscalculations, logic and comparison operator mistakes, or other simple mistakes. For the sake of demonstration, assume that the actual mistake is unknown. This lesson assumes that gdbserver has just been started as in the [Target Machine] Setup above with an &amp;lt;code&amp;gt;ARG&amp;lt;/code&amp;gt; value of 5.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;cl&amp;gt;&lt;br /&gt;
1. Before starting the program in the debugger again, run it by itself on the target machine to see what the actual program output is: &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@emac-oe:~# /tmp/pthread_demo 5&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
The number of threads should be between 1 and 100&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The program was given an input of '5' yet the output message seems to indicate that this is out of range which is obviously not true.&lt;br /&gt;
* Start the debugger again and connect to the target machine as described in the Setup section.&lt;br /&gt;
* Type &amp;lt;code&amp;gt;b main&amp;lt;/code&amp;gt; to set a breakpoint at the main function in the source code.&lt;br /&gt;
* Type &amp;lt;code&amp;gt;continue&amp;lt;/code&amp;gt;. This will cause the program to continue from the breakpoint set by GDB at startup. &lt;br /&gt;
* Type &amp;lt;code&amp;gt;n&amp;lt;/code&amp;gt;. This will cause the program to step over the next line of source code. The reason for using &amp;lt;code&amp;gt;n&amp;lt;/code&amp;gt; rather than &amp;lt;code&amp;gt;s&amp;lt;/code&amp;gt; or one of the instruction stepping commands is because the erroneous output indicates that the coding mistake is in the programmer's source code rather than the c library functions &amp;lt;code&amp;gt;atoi()&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;fprintf()&amp;lt;/code&amp;gt;. Stepping over the function will save all the time required to step through every detail of what the library functions are doing. Later passes through the code can be used to step into functions called from within that stack frame if the first pass proves unsuccessful.&lt;br /&gt;
* Continue to type &amp;lt;code&amp;gt;n&amp;lt;/code&amp;gt; until one of the program's &amp;lt;code&amp;gt;exit()&amp;lt;/code&amp;gt; calls is reached, but do not actually step into that &amp;lt;code&amp;gt;exit()&amp;lt;/code&amp;gt; call. Judging by the program's output above, this should bring you to the conditional block that checks the value of the local variable n used to store the output of &amp;lt;code&amp;gt;atoi()&amp;lt;/code&amp;gt; as shown in Listing 3. Note that once execution reaches line 79 of the source code, GDB will display the output of the &amp;lt;code&amp;gt;fprintf()&amp;lt;/code&amp;gt; function from line 76. This may cause display problems within the text-based UI library that GDB uses which will require the command refresh to fix.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;gdb&amp;quot;&amp;gt;&lt;br /&gt;
B+ |75              if ((data.num_threads &amp;lt; 1) || (data.num_threads &amp;lt; MAX_THREAD)) {       |&lt;br /&gt;
   |76                      fprintf(stderr,                                                |&lt;br /&gt;
   |77                              &amp;quot;The number of thread should between 1 and %d\n&amp;quot;,      |&lt;br /&gt;
   |78                              MAX_THREAD);                                           |&lt;br /&gt;
  &amp;gt;|79                      exit(EXIT_FAILURE);                                            |&lt;br /&gt;
   |80              }                                                                      |&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
* Type &amp;lt;code&amp;gt;p/d data→num_threads&amp;lt;/code&amp;gt;. &amp;lt;code&amp;gt;p&amp;lt;/code&amp;gt; is an alias for &amp;lt;code&amp;gt;print&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;/d&amp;lt;/code&amp;gt; tells GDB to treat the expression requested as an integer in signed decimal, and &amp;lt;code&amp;gt;data→num&amp;lt;/code&amp;gt;_threads is the element &amp;lt;code&amp;gt;num_threads&amp;lt;/code&amp;gt; within &amp;lt;code&amp;gt;struct thread_data&amp;lt;/code&amp;gt;. This should provide the following output:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;gdb&amp;quot;&amp;gt;&lt;br /&gt;
(gdb) p/d data-&amp;gt;num_threads&lt;br /&gt;
$6 = 5&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Note that the integer part of &amp;lt;code&amp;gt;$6&amp;lt;/code&amp;gt; will increment with each call to the gdb command &amp;lt;code&amp;gt;print&amp;lt;/code&amp;gt;. The above output confirms that the argument '5' was successfully passed to the program and read into a variable to be tested, indicating that one of the logical tests for the current conditional block contains a mistake. This merits a closer look at line 75:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;gdb&amp;quot;&amp;gt;&lt;br /&gt;
B+ |75              if ((data.num_threads &amp;lt; 1) || (data.num_threads &amp;lt; MAX_THREAD)) {       |&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Line 75 consists of a conditional test which is the logical OR of two arithmetic tests involving the values of &amp;lt;code&amp;gt;data.num_threads&amp;lt;/code&amp;gt;, '1', and &amp;lt;code&amp;gt;MAX_THREAD&amp;lt;/code&amp;gt;. The first test is true the input integer is less than &amp;lt;code&amp;gt;1–(data.num_threads &amp;amp;lt; 1)&amp;lt;/code&amp;gt;. The second tests whether the input integer is less than the symbolic constant, &amp;lt;code&amp;gt;MAX_THREAD–(data.num_threads &amp;amp;lt; MAX_THREAD)&amp;lt;/code&amp;gt;. Judging by the name of this constant and the result of the test (we know it resolves to true because the value of &amp;lt;code&amp;gt;data.num_threads&amp;lt;/code&amp;gt; in this case is not less than one), we can see that the comparison operator used is the culprit. The correct interpretation is that it should be '&amp;amp;gt;' rather than '&amp;amp;lt;'.&lt;br /&gt;
* Type &amp;lt;code&amp;gt;kill&amp;lt;/code&amp;gt;.&lt;br /&gt;
&amp;lt;/cl&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This was a simple problem to solve but the method used above could apply in any situation where source code compiles and runs without errors yet provides varied or unexpected output.&lt;br /&gt;
&lt;br /&gt;
====Lesson 3: Debugging With Threads====&lt;br /&gt;
&lt;br /&gt;
Do not fix the programming mistake found in Lesson 2. This lesson will cover the use of the jump command to skip blocks of code and commands specific to debugging multi-threaded programs. Before getting started, see [http://sourceware.org/gdb/current/onlinedocs/gdb/Thread-Stops.html#Thread-Stops Debugging with GDB: 5. Stopping and Starting Multi-thread Programs].&lt;br /&gt;
&lt;br /&gt;
This lesson assumes that &amp;lt;code&amp;gt;gdbserver&amp;lt;/code&amp;gt; has just been started as in the Target Machine Setup above with an &amp;lt;code&amp;gt;ARG&amp;lt;/code&amp;gt; value of 7.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;cl&amp;gt;&lt;br /&gt;
1. Start the debugger again and connect to the target machine as described in the Setup section.&lt;br /&gt;
* Type set &amp;lt;code&amp;gt;scheduler-locking&amp;lt;/code&amp;gt; on. This command enables GDB to lock all threads save for the currently-selected thread from running when the &amp;lt;code&amp;gt;step/stepi&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;next/nexti&amp;lt;/code&amp;gt; commands are given. &lt;br /&gt;
* Set all the breakpoints that you will need for this session: &lt;br /&gt;
 i. Type &amp;lt;code&amp;gt;b main&amp;lt;/code&amp;gt; to set a breakpoint at the main function in the source code.&lt;br /&gt;
 * Type &amp;lt;code&amp;gt;b 75&amp;lt;/code&amp;gt;. This will set a break point at the conditional block that checks the value of the program's single integer argument. If you recall from Lesson 2, this is the conditional which evaluates incorrectly in the modified version of the application.&lt;br /&gt;
 * Type &amp;lt;code&amp;gt;b 143&amp;lt;/code&amp;gt;. This will set a breakpoint in the variable assignment in the &amp;lt;code&amp;gt;generator&amp;lt;/code&amp;gt; function. Careful examination of the source code will show that this function is called from a thread created by the main thread of execution but never from the main thread itself.&lt;br /&gt;
 * Type &amp;lt;code&amp;gt;b 129&amp;lt;/code&amp;gt;. This will set a breakpoint in the variable assignment of the &amp;lt;code&amp;gt;reader&amp;lt;/code&amp;gt; function. As with the &amp;lt;code&amp;gt;generator&amp;lt;/code&amp;gt; function, any time the &amp;lt;code&amp;gt;reader&amp;lt;/code&amp;gt; function is called it will be inside a thread that is not the main thread.&lt;br /&gt;
 * Type &amp;lt;code&amp;gt;b 135&amp;lt;/code&amp;gt;. This will set a breakpoint just after the &amp;lt;code&amp;gt;fflush(stdout)&amp;lt;/code&amp;gt; statement in the &amp;lt;code&amp;gt;reader&amp;lt;/code&amp;gt; function.&lt;br /&gt;
 * Type &amp;lt;code&amp;gt;b 97&amp;lt;/code&amp;gt;. This will set a breakpoint in the main thread after the &amp;lt;code&amp;gt;generator&amp;lt;/code&amp;gt; thread has been created but before the main thread begins creating &amp;lt;code&amp;gt;reader&amp;lt;/code&amp;gt; threads.&lt;br /&gt;
 * Type &amp;lt;code&amp;gt;b 119&amp;lt;/code&amp;gt;. This will set a breakpoint after the main thread iteratively creates the &amp;lt;code&amp;gt;reader&amp;lt;/code&amp;gt; threads.&lt;br /&gt;
* Optional: You may want to run the &amp;lt;code&amp;gt;layout split&amp;lt;/code&amp;gt; command so that you can see both the assembly and the source code during the debug session.&lt;br /&gt;
* Type &amp;lt;code&amp;gt;continue&amp;lt;/code&amp;gt; then hit 'Enter' once. This will bring you to line 75 in the source code.&lt;br /&gt;
* Type &amp;lt;code&amp;gt;j 81&amp;lt;/code&amp;gt;. This is an alias for jump 81 that tells GDB to have the program jump to line 81 of the source code and resume execution at the first assembly instruction represented by line 81 of the source code. This line is labeled &amp;lt;code&amp;gt;&amp;lt;main.c+196&amp;gt;&amp;lt;/code&amp;gt;. Note that the program effectively no longer checks the input it receives.&lt;br /&gt;
* Type &amp;lt;code&amp;gt;i th&amp;lt;/code&amp;gt;. This will cause GDB to display a list of the application's threads currently in memory. Take a moment to consider what is happening in the program. We know that in Step 2 of this lesson we used &amp;lt;code&amp;gt;set scheduler-locking&amp;lt;/code&amp;gt; to tell GDB to effectively only allow the currently-selected thread of execution to be affected by the GDB &amp;lt;code&amp;gt;step&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;next&amp;lt;/code&amp;gt; commands. Others will wait at their respective breakpoints until explicitly told by the programmer to execute the next line of source code or instruction. The next breakpoint that &amp;lt;code&amp;gt;main&amp;lt;/code&amp;gt; reaches occurs after the &amp;lt;code&amp;gt;generator&amp;lt;/code&amp;gt; thread is created. This means that there are currently two threads of execution, the &amp;lt;code&amp;gt;main&amp;lt;/code&amp;gt; thread paused at line 97 and the &amp;lt;code&amp;gt;generator&amp;lt;/code&amp;gt; thread paused at line 143. &lt;br /&gt;
* Type &amp;lt;code&amp;gt;thread 2&amp;lt;/code&amp;gt;. This will select the &amp;lt;code&amp;gt;generator&amp;lt;/code&amp;gt; thread.&lt;br /&gt;
* Type &amp;lt;code&amp;gt;thread apply 2 n&amp;lt;/code&amp;gt;. This will tell the &amp;lt;code&amp;gt;generator&amp;lt;/code&amp;gt; thread to execute the next line of source code and pause again on the line following that. Without typing any other commands into the GDB prompt, hit 'Enter' seven more times. This should bring you to line 165 of the source code:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
usleep(1);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Notice the output of the program on the remote terminal on which &amp;lt;code&amp;gt;gdbserver&amp;lt;/code&amp;gt; was run. Standard output on that terminal should show the output from the &amp;lt;code&amp;gt;printf()&amp;lt;/code&amp;gt; call on line 154.&lt;br /&gt;
* Type &amp;lt;code&amp;gt;thread 1&amp;lt;/code&amp;gt;. This will select the &amp;lt;code&amp;gt;main&amp;lt;/code&amp;gt; thread.&lt;br /&gt;
* Type &amp;lt;code&amp;gt;continue&amp;lt;/code&amp;gt;. This will cause the &amp;lt;code&amp;gt;main&amp;lt;/code&amp;gt; thread to continue execution while &amp;lt;code&amp;gt;generator&amp;lt;/code&amp;gt; remains paused at line 165. &amp;lt;code&amp;gt;main&amp;lt;/code&amp;gt; pauses again at line 119, once the 7 &amp;lt;code&amp;gt;reader&amp;lt;/code&amp;gt; threads have been created. Recall from step 3.4 that &amp;lt;code&amp;gt;b 129&amp;lt;/code&amp;gt; set a breakpoint in the &amp;lt;code&amp;gt;reader&amp;lt;/code&amp;gt; function so that the &amp;lt;code&amp;gt;reader&amp;lt;/code&amp;gt; threads would pause at line 129.&lt;br /&gt;
* Type &amp;lt;code&amp;gt;i th&amp;lt;/code&amp;gt;. This is an alias for &amp;lt;code&amp;gt;info threads&amp;lt;/code&amp;gt;. This causes GDB to print out all the threads currently in memory. Notice that there are three types of threads, &amp;lt;code&amp;gt;main&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;generator&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;reader&amp;lt;/code&amp;gt;. The &amp;lt;code&amp;gt;info threads&amp;lt;/code&amp;gt; command also shows that the &amp;lt;code&amp;gt;reader&amp;lt;/code&amp;gt; threads are all paused at line 129, the &amp;lt;code&amp;gt;generator&amp;lt;/code&amp;gt; thread is paused at line 165, and the &amp;lt;code&amp;gt;main&amp;lt;/code&amp;gt; thread is paused at line 119.&lt;br /&gt;
* Type &amp;lt;code&amp;gt;thread 5&amp;lt;/code&amp;gt;. This will select the third &amp;lt;code&amp;gt;reader&amp;lt;/code&amp;gt; thread.&lt;br /&gt;
* Type &amp;lt;code&amp;gt;thread apply 5 n&amp;lt;/code&amp;gt;. Then press 'enter' seven times. This will cause the third &amp;lt;code&amp;gt;reader&amp;lt;/code&amp;gt; thread to complete its task and exit gracefully using the &amp;lt;code&amp;gt;pthread_exit()&amp;lt;/code&amp;gt; function.&lt;br /&gt;
* Type &amp;lt;code&amp;gt;thread 1&amp;lt;/code&amp;gt;. This will select the &amp;lt;code&amp;gt;main&amp;lt;/code&amp;gt; thread.&lt;br /&gt;
* Type &amp;lt;code&amp;gt;p data&amp;lt;/code&amp;gt;. This will show the current state of the data structure that was passed to each thread. Note that each thread contains a pointer to the same data structure. This requires the use of what is known as a mutex (MUTual EXclusion) variable which is used to protect the data structure from concurrent modifications. In other words, any time the data structure is read or written to by one of the threads, they must first call the function pthread_&amp;lt;code&amp;gt;mutex_lock()&amp;lt;/code&amp;gt; to ensure that no other thread currently “has” the lock. When a thread is done with the shared data structure, it calls the function &amp;lt;code&amp;gt;pthread_mutex_unlock()&amp;lt;/code&amp;gt; to make the lock available to other threads. Notice that nothing about the mutex's inclusion in the data structure requires it to be used in order to read or write to the data structure. This means that any programmer who wishes to use threads to implement concurrent programming must pay close attention to code that accesses shared data structures to ensure concurrent modifications do not occur.&lt;br /&gt;
* Perform the previous four steps for as many of the &amp;lt;code&amp;gt;reader&amp;lt;/code&amp;gt; threads as you want. Notice that each one prints a message to standard out providing information about the state of the shared &amp;lt;code&amp;gt;data&amp;lt;/code&amp;gt; variable at the time that it has the lock. By switching to the &amp;lt;code&amp;gt;generator&amp;lt;/code&amp;gt; thread once the mutex variable is unlocked, that code can be stepped through to generate a new random number for the data structure. IMPORTANT: Do not execute a line of source code containing a call to &amp;lt;code&amp;gt;pthread_mutex_lock()&amp;lt;/code&amp;gt; without first ensuring that the mutex variable is unlocked. To do this, carefully perform the following steps:&lt;br /&gt;
 i. Type &amp;lt;code&amp;gt;p data-&amp;amp;gt;lock&amp;lt;/code&amp;gt;. This will show the values of the mutex variable in the &amp;lt;code&amp;gt;data&amp;lt;/code&amp;gt; structure variable. Make note of the value of the &amp;lt;code&amp;gt;owner&amp;lt;/code&amp;gt; field.&lt;br /&gt;
 * Type &amp;lt;code&amp;gt;i th&amp;lt;/code&amp;gt;. This will show the current list of threads in the program. What follows is a possible output from these two commands:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;gdb&amp;quot;&amp;gt;&lt;br /&gt;
(gdb) p data-&amp;gt;lock&lt;br /&gt;
$3 = {__data = {__lock = 1, __count = 0, __owner = 1288, __kind = 0, __nusers = 1, {__spins = 0, __list = {__next = 0x0}}},&lt;br /&gt;
  __size = &amp;quot;\001\000\000\000\000\000\000\000\b\005\000\000\000\000\000\000\001\000\000\000\000\000\000&amp;quot;, __align = 1}&lt;br /&gt;
(gdb) i th&lt;br /&gt;
  9 Thread 1289  reader (arg=0xbeddec8c) at pthread_demo.c:129&lt;br /&gt;
  8 Thread 1288  reader (arg=0xbeddec8c) at pthread_demo.c:134&lt;br /&gt;
  7 Thread 1287  reader (arg=0xbeddec8c) at pthread_demo.c:129&lt;br /&gt;
  6 Thread 1286  0x00008b04 in reader (arg=0xbeddec8c) at pthread_demo.c:129&lt;br /&gt;
  3 Thread 1283  0x00008b04 in reader (arg=0xbeddec8c) at pthread_demo.c:129&lt;br /&gt;
* 2 Thread 1282  generator (arg=0xbeddec8c) at pthread_demo.c:165&lt;br /&gt;
  1 Thread 1281  0x00008a64 in main (argc=2, argv=0xbeddee24) at pthread_demo.c:119&lt;br /&gt;
(gdb)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Analysis of this output requires the understanding that the third column of the &amp;lt;code&amp;gt;i th&amp;lt;/code&amp;gt; output indicates that particular thread's process ID. The important part of the &amp;lt;code&amp;gt;p data-&amp;amp;gt;lock&amp;lt;/code&amp;gt; output is the &amp;lt;code&amp;gt;owner&amp;lt;/code&amp;gt; field, whose value will always either be zero or correspond to the process ID of one of the currently-running threads. In this case, the lock-&amp;amp;gt;__owner field clearly indicates that thread 8 currently owns the data-&amp;amp;gt;lock mutex variable. This would indicate that thread 8 should be stepped through until it has called the &amp;lt;code&amp;gt;pthread_mutex_unlock()&amp;lt;/code&amp;gt; function before stepping into a call to &amp;lt;code&amp;gt;pthread_mutex_lock()&amp;lt;/code&amp;gt; in any other function.&lt;br /&gt;
To summarize, always ensure that the &amp;lt;code&amp;gt;owner&amp;lt;/code&amp;gt; field of the mutex variable is equal to zero before using &amp;lt;code&amp;gt;pthread_mutex_lock()&amp;lt;/code&amp;gt; while debugging. If the lock is currently owned by another thread, GDB will hang until sent an interrupt signal which will require that the entire debug process be started over.&lt;br /&gt;
* The walktrhough is complete. There are two ways to end the debug session gracefully:&lt;br /&gt;
 * Type &amp;lt;code&amp;gt;monitor exit&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;kill&amp;lt;/code&amp;gt; (confirm with 'y'), then &amp;lt;code&amp;gt;quit&amp;lt;/code&amp;gt;.&lt;br /&gt;
 * Type &amp;lt;code&amp;gt;set scheduler-locking off&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;delete&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;thread 1&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;continue&amp;lt;/code&amp;gt;, then &amp;lt;code&amp;gt;monitor exit&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;kill&amp;lt;/code&amp;gt; (confirm with 'y'), &amp;lt;code&amp;gt;quit&amp;lt;/code&amp;gt;. This will allow the program to finish executing before ending the session.&lt;br /&gt;
&amp;lt;/cl&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===GNU GDB Documentation===&lt;br /&gt;
&lt;br /&gt;
Again, for more information on how to debug with GDB, refer to the [http://sourceware.org/gdb/current/onlinedocs/gdb.html GDB Manual]. This is a valuable resource for anyone just learning to debug software and will go into much greater detail than is possible in this guide.&lt;br /&gt;
&lt;br /&gt;
==Next Steps==&lt;br /&gt;
&lt;br /&gt;
If you have not done so already, be sure to check out the [[EMAC OE SDK Example Projects]] or learn to create your own [[New Project]].&lt;br /&gt;
&lt;br /&gt;
Also, give the [[EMAC Eclipse IDE]] a try. Sometimes it is simpler to use an IDE for large projects, especially with the ability to automate the makefile creation process.&lt;br /&gt;
&lt;br /&gt;
[[Category:EMAC OE SDK]]&lt;/div&gt;</summary>
		<author><name>Mcoleman</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.emacinc.com/index.php?title=Installing_EMAC_OE_4.0_SDK&amp;diff=507</id>
		<title>Installing EMAC OE 4.0 SDK</title>
		<link rel="alternate" type="text/html" href="https://wiki.emacinc.com/index.php?title=Installing_EMAC_OE_4.0_SDK&amp;diff=507"/>
		<updated>2013-05-28T19:06:57Z</updated>

		<summary type="html">&lt;p&gt;Mcoleman: complex list&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{EMAC OE SDK Conventions}}&lt;br /&gt;
&lt;br /&gt;
Before beginning installation of the SDK, it is important to prepare the development system with the tools necessary to get the job done. These tools can either be command line interface (CLI) or graphical utilities. Both options are described in this guide.&lt;br /&gt;
&lt;br /&gt;
{{mbox | type = notice | style = margin-left: 0; margin-bottom: 1em; | text = The SDK archive and directory names will differ based on which SDK is being installed. For example, the toolchain binary names will reflect the target CPU architecture. What is shown in this guide is for demonstration's sake.}}&lt;br /&gt;
&lt;br /&gt;
== Required tools ==&lt;br /&gt;
* Web browser (recommended [https://www.mozilla.org/en-US/firefox/new/ Mozilla Firefox], [https://www.gnu.org/software/gnuzilla/ Gnuzilla Icecat], [http://www.konqueror.org/download/ KDE Konqueror])&lt;br /&gt;
* Archiving tool. There are two options available:&lt;br /&gt;
** Graphical tools ([[Ark]] for KDE, [[File Roller]] for GNOME)&lt;br /&gt;
** CLI tool ([[tar]] is standard)&lt;br /&gt;
* &amp;lt;code&amp;gt;dialog&amp;lt;/code&amp;gt; required for CLI use of SDK ([[see the developer's website]]).&lt;br /&gt;
&lt;br /&gt;
== Recommendations ==&lt;br /&gt;
The following are some recommended install opations&lt;br /&gt;
* The SDK should be kept in the user's home directory. For example, &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# /path/to/sdk/ might expand to something like &lt;br /&gt;
/home/user_name/cust_software/&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
To clarify, this is the location where &amp;lt;code&amp;gt;EMAC-OE-arm-linux-gnueabi-SDK_XX.YY/&amp;lt;/code&amp;gt; will end up.&lt;br /&gt;
* The default SDK root folder name should be kept at its default name since this preserves the version information for the EMAC OE SDK.&lt;br /&gt;
&lt;br /&gt;
== Procedure ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;cl&amp;gt;&lt;br /&gt;
1. Download the SDK. The latest version can be found on the public EMAC FTP site. Be sure to download the SDK that matches the architecture of your target system. Contact EMAC if unsure.&lt;br /&gt;
* Uncompress the SDK.&lt;br /&gt;
 * Using a graphical archiving tool, uncompress the archive files to the chosen development directory. If you need assistance with this, please see the documentation for your graphical archiving tool.&lt;br /&gt;
 * Alternatively, you can uncompress the archive from the CLI using tar: &lt;br /&gt;
 &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
 developer@ldc:~$ cd /target/directory&lt;br /&gt;
 developer@ldc:~$ bzip2 -cd /download/directory/EMAC-OE-arm-linux-gnuabi-SDK_XX.YY.rZZ.tar.bz2 | tar xvf -&lt;br /&gt;
 &amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
 This will produce a subdirectory within the target directory:&lt;br /&gt;
 &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
 developer@ldc:~$ ls&lt;br /&gt;
 &amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
 &amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
 ...&lt;br /&gt;
 EMAC-OE-arm-linux-gnueabi-SDK_XX.YY/&lt;br /&gt;
 ...&lt;br /&gt;
 &amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/cl&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Next Steps ==&lt;br /&gt;
Once the EMAC SDK is installed, the next step is to [[configure it]].&lt;br /&gt;
&lt;br /&gt;
[[Category:EMAC OE SDK]]&lt;/div&gt;</summary>
		<author><name>Mcoleman</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.emacinc.com/index.php?title=Configuring_EMAC_OE_4.0_SDK&amp;diff=506</id>
		<title>Configuring EMAC OE 4.0 SDK</title>
		<link rel="alternate" type="text/html" href="https://wiki.emacinc.com/index.php?title=Configuring_EMAC_OE_4.0_SDK&amp;diff=506"/>
		<updated>2013-05-28T19:04:39Z</updated>

		<summary type="html">&lt;p&gt;Mcoleman: complex list&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{EMAC OE SDK Conventions}}&lt;br /&gt;
&lt;br /&gt;
When Eclipse generates a Makefile to use for building a project, the generated Makefile includes a file named global.properties before it performs any other steps. This file is located in the projects directory, which is the root directory for Eclipse projects. The projects directory is located within the EMAC SDK directory provided by the EMAC SDK package (or installed on the LDC). &lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;global.properties&amp;lt;/code&amp;gt; file provides information needed to build projects and upload them to the target machine (the board supplied by EMAC). The following information is provided by this file: &lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Configuration variable !! Description &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;SDKBASE&amp;lt;/code&amp;gt; || The base directory for the SDK .&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;CC&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;CXX&amp;lt;/code&amp;gt; || Exectuable binaries to use for compiling for the C and C++ compiler, respectively.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;LD_LIBRARY_PATH&amp;lt;/code&amp;gt; || The path the linker should use to search for shared library files.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;CFLAGS&amp;lt;/code&amp;gt; || The flags passed to the compiler to specify target processor architecture, debugging flags, etc.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;OFLAGS&amp;lt;/code&amp;gt; || The flags passed to the compiler to specify optimization options to use.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;TARGET_IP&amp;lt;/code&amp;gt; || The IP Address of the target machine (needed for uploading the compiled binary to the target machine).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;LOGIN&amp;lt;/code&amp;gt; || The user name to use for logging into the target machine.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;PASSWORD&amp;lt;/code&amp;gt; || The password to use for logging into the target machine.*&lt;br /&gt;
|- &lt;br /&gt;
| &amp;lt;code&amp;gt;WPUT&amp;lt;/code&amp;gt; ||  The location of the &amp;lt;code&amp;gt;wput&amp;lt;/code&amp;gt; command, along with options to pass to &amp;lt;code&amp;gt;wput&amp;lt;/code&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
'''*NOTE''' The password is stored in plain text in this file. However, read permission is required to view this password. In most development environments, this should not be an issue. If development is taking place in a shared environment (such as a University lab) and secrecy of this password is required, simply ensure that only trusted users have read permission for this file.&lt;br /&gt;
&lt;br /&gt;
{{mbox | type = warning | text = Configuring permissions on files is a common source of problems for people new to doing so under Linux. EMAC does not recommend altering the default settings (which should be secure in most environments) unless absolutely necessary. EMAC will only be able to provide very limited support should these settings be manually configured. The standard Linux commands, &amp;lt;code&amp;gt;chmod&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;chgrp&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;chown&amp;lt;/code&amp;gt; are typically used to configure these permissions. Please see the documentation for these commands using the man command, or find a reference with your favorite search engine. '''Caveat''': This will require any user wishing to build this software to have such permission, since programs run by a user can only read files the user is permitted to use.}}&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;global.properties&amp;lt;/code&amp;gt; file is actually a type of virtual file, called a softlink. This softlink acts as a pointer which points to another file. The file it points to is chosen when the CPU architecture is chosen. To see why it works this way, see the above information about the flags specified for the processor architecture, and note that different library and compiler paths may be required to support different hardware. The softlink is updated when the hardware to use for the development project is selected.&lt;br /&gt;
&lt;br /&gt;
{{mbox | type = notice | text = Should problems relating to this part of the build system show up during the development process, these files or softlinks may have been accidentally modified. Inspecting these files and softlinks, and/or rerunning the hardware selection script, may provide the fix for the problems. The &amp;lt;code&amp;gt;ln&amp;lt;/code&amp;gt; command with the &amp;lt;code&amp;gt;-s&amp;lt;/code&amp;gt; option (see &amp;lt;code&amp;gt;man ln&amp;lt;/code&amp;gt;) is the command used to create softlinks.}}&lt;br /&gt;
&lt;br /&gt;
==Configuration Steps==&lt;br /&gt;
&lt;br /&gt;
The following configuration steps are necessary to begin using the EMAC OE SDK. &lt;br /&gt;
&lt;br /&gt;
Before cross-compiling source code on the development machine for the target machine: &lt;br /&gt;
&lt;br /&gt;
* A [[set up script]] linking &amp;lt;code&amp;gt;global.properties&amp;lt;/code&amp;gt; to an architecture-specific &amp;lt;code&amp;gt;global.properties&amp;lt;/code&amp;gt; file must be run.&lt;br /&gt;
* The &amp;lt;code&amp;gt;TARGET_IP&amp;lt;/code&amp;gt; variable in the [[global.properties]] file must be changed to the IP address or hostname belonging to the target board.&lt;br /&gt;
&lt;br /&gt;
{{mbox | type = notice | text = These configurations assume that the [[EMAC OE SDK]] is installed.}}&lt;br /&gt;
&lt;br /&gt;
==SDK Set Up Script==&lt;br /&gt;
&lt;br /&gt;
Before compiling source code for the target machine, toolchain libraries for the target machine must be specified by running &amp;lt;code&amp;gt;setmachine.sh&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
===Procedure===&lt;br /&gt;
&amp;lt;cl&amp;gt;&lt;br /&gt;
1. Navigate to the SDK directory.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ cd /path/to/sdk/EMAC-OE-arm-linux-gnueabi-SDK_XX.YY/&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Run the script using the command shown below to produce a menu as shown in Figure 1 with options for the target machine for which the source will be compiled.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ ./setmachine.sh&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/cl&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Emac_oe_sdk_setup-2.png]]&lt;br /&gt;
&lt;br /&gt;
==Remote Upload Set-up==&lt;br /&gt;
&lt;br /&gt;
In the &amp;lt;code&amp;gt;global.properties&amp;lt;/code&amp;gt; file there is a variable, &amp;lt;code&amp;gt;IP&amp;lt;/code&amp;gt; which must be set to the target board IP address as shown in Listing 1 below. This step is necessary to ensure that the Make target, &amp;lt;code&amp;gt;'upload'&amp;lt;/code&amp;gt; will work as expected.&lt;br /&gt;
&lt;br /&gt;
===Procedure===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;cl&amp;gt;&lt;br /&gt;
1. Navigate to the projects directory within the SDK.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ cd /path/to/sdk/EMAC-OE-arm-linux-gnueabi-SDK_XX.YY/projects&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* The &amp;lt;code&amp;gt;global.properties&amp;lt;/code&amp;gt; file should be listed in the current directory. The relevant lines from &amp;lt;code&amp;gt;global.properties&amp;lt;/code&amp;gt; are shown in Listing 1 below.&lt;br /&gt;
'''Listing 1. &amp;lt;code&amp;gt;global.properties&amp;lt;/code&amp;gt; snippet'''&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
TARGET_IP=&lt;br /&gt;
LOGIN=root&lt;br /&gt;
PASSWORD=emac_inc_90210&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Change the value of &amp;lt;code&amp;gt;TARGET_IP&amp;lt;/code&amp;gt; to the target system's IP address.&lt;br /&gt;
This can be found using the following command from a shell on the target system:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@emac-oe:~# /sbin/ifconfig eth0 | grep inet&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
For more information on how to connect to the remote system, see the [[initial connections section]] of the [[EMAC OE Getting Started Guide|EMAC OE getting started guide]].&lt;br /&gt;
&lt;br /&gt;
* Change the value of &amp;lt;code&amp;gt;PASSWORD&amp;lt;/code&amp;gt; to whatever value was set in the [[System Login section]] of the [[EMAC OE Getting Started Guide|EMAC OE getting started guide]]. Listing 1 shows the default user name and password.&lt;br /&gt;
&amp;lt;/cl&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:EMAC OE SDK]]&lt;/div&gt;</summary>
		<author><name>Mcoleman</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.emacinc.com/index.php?title=Configuring_EMAC_OE_4.0_SDK&amp;diff=505</id>
		<title>Configuring EMAC OE 4.0 SDK</title>
		<link rel="alternate" type="text/html" href="https://wiki.emacinc.com/index.php?title=Configuring_EMAC_OE_4.0_SDK&amp;diff=505"/>
		<updated>2013-05-28T19:01:27Z</updated>

		<summary type="html">&lt;p&gt;Mcoleman: complexlist&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{EMAC OE SDK Conventions}}&lt;br /&gt;
&lt;br /&gt;
When Eclipse generates a Makefile to use for building a project, the generated Makefile includes a file named global.properties before it performs any other steps. This file is located in the projects directory, which is the root directory for Eclipse projects. The projects directory is located within the EMAC SDK directory provided by the EMAC SDK package (or installed on the LDC). &lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;global.properties&amp;lt;/code&amp;gt; file provides information needed to build projects and upload them to the target machine (the board supplied by EMAC). The following information is provided by this file: &lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Configuration variable !! Description &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;SDKBASE&amp;lt;/code&amp;gt; || The base directory for the SDK .&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;CC&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;CXX&amp;lt;/code&amp;gt; || Exectuable binaries to use for compiling for the C and C++ compiler, respectively.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;LD_LIBRARY_PATH&amp;lt;/code&amp;gt; || The path the linker should use to search for shared library files.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;CFLAGS&amp;lt;/code&amp;gt; || The flags passed to the compiler to specify target processor architecture, debugging flags, etc.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;OFLAGS&amp;lt;/code&amp;gt; || The flags passed to the compiler to specify optimization options to use.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;TARGET_IP&amp;lt;/code&amp;gt; || The IP Address of the target machine (needed for uploading the compiled binary to the target machine).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;LOGIN&amp;lt;/code&amp;gt; || The user name to use for logging into the target machine.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;PASSWORD&amp;lt;/code&amp;gt; || The password to use for logging into the target machine.*&lt;br /&gt;
|- &lt;br /&gt;
| &amp;lt;code&amp;gt;WPUT&amp;lt;/code&amp;gt; ||  The location of the &amp;lt;code&amp;gt;wput&amp;lt;/code&amp;gt; command, along with options to pass to &amp;lt;code&amp;gt;wput&amp;lt;/code&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
'''*NOTE''' The password is stored in plain text in this file. However, read permission is required to view this password. In most development environments, this should not be an issue. If development is taking place in a shared environment (such as a University lab) and secrecy of this password is required, simply ensure that only trusted users have read permission for this file.&lt;br /&gt;
&lt;br /&gt;
{{mbox | type = warning | text = Configuring permissions on files is a common source of problems for people new to doing so under Linux. EMAC does not recommend altering the default settings (which should be secure in most environments) unless absolutely necessary. EMAC will only be able to provide very limited support should these settings be manually configured. The standard Linux commands, &amp;lt;code&amp;gt;chmod&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;chgrp&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;chown&amp;lt;/code&amp;gt; are typically used to configure these permissions. Please see the documentation for these commands using the man command, or find a reference with your favorite search engine. '''Caveat''': This will require any user wishing to build this software to have such permission, since programs run by a user can only read files the user is permitted to use.}}&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;global.properties&amp;lt;/code&amp;gt; file is actually a type of virtual file, called a softlink. This softlink acts as a pointer which points to another file. The file it points to is chosen when the CPU architecture is chosen. To see why it works this way, see the above information about the flags specified for the processor architecture, and note that different library and compiler paths may be required to support different hardware. The softlink is updated when the hardware to use for the development project is selected.&lt;br /&gt;
&lt;br /&gt;
{{mbox | type = notice | text = Should problems relating to this part of the build system show up during the development process, these files or softlinks may have been accidentally modified. Inspecting these files and softlinks, and/or rerunning the hardware selection script, may provide the fix for the problems. The &amp;lt;code&amp;gt;ln&amp;lt;/code&amp;gt; command with the &amp;lt;code&amp;gt;-s&amp;lt;/code&amp;gt; option (see &amp;lt;code&amp;gt;man ln&amp;lt;/code&amp;gt;) is the command used to create softlinks.}}&lt;br /&gt;
&lt;br /&gt;
==Configuration Steps==&lt;br /&gt;
&lt;br /&gt;
The following configuration steps are necessary to begin using the EMAC OE SDK. &lt;br /&gt;
&lt;br /&gt;
Before cross-compiling source code on the development machine for the target machine: &lt;br /&gt;
&lt;br /&gt;
* A [[set up script]] linking &amp;lt;code&amp;gt;global.properties&amp;lt;/code&amp;gt; to an architecture-specific &amp;lt;code&amp;gt;global.properties&amp;lt;/code&amp;gt; file must be run.&lt;br /&gt;
* The &amp;lt;code&amp;gt;TARGET_IP&amp;lt;/code&amp;gt; variable in the [[global.properties]] file must be changed to the IP address or hostname belonging to the target board.&lt;br /&gt;
&lt;br /&gt;
{{mbox | type = notice | text = These configurations assume that the [[EMAC OE SDK]] is installed.}}&lt;br /&gt;
&lt;br /&gt;
==SDK Set Up Script==&lt;br /&gt;
&lt;br /&gt;
Before compiling source code for the target machine, toolchain libraries for the target machine must be specified by running &amp;lt;code&amp;gt;setmachine.sh&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
===Procedure===&lt;br /&gt;
&amp;lt;cl&amp;gt;&lt;br /&gt;
1. Navigate to the SDK directory.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ cd /path/to/sdk/EMAC-OE-arm-linux-gnueabi-SDK_XX.YY/&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Run the script using the command shown below to produce a menu as shown in Figure 1 with options for the target machine for which the source will be compiled.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ ./setmachine.sh&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/cl&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Emac_oe_sdk_setup-2.png]]&lt;br /&gt;
&lt;br /&gt;
==Remote Upload Set-up==&lt;br /&gt;
&lt;br /&gt;
In the &amp;lt;code&amp;gt;global.properties&amp;lt;/code&amp;gt; file there is a variable, &amp;lt;code&amp;gt;IP&amp;lt;/code&amp;gt; which must be set to the target board IP address as shown in Listing 1 below. This step is necessary to ensure that the Make target, &amp;lt;code&amp;gt;'upload'&amp;lt;/code&amp;gt; will work as expected.&lt;br /&gt;
&lt;br /&gt;
===Procedure===&lt;br /&gt;
&lt;br /&gt;
# Navigate to the projects directory within the SDK.&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ cd /path/to/sdk/EMAC-OE-arm-linux-gnueabi-SDK_XX.YY/projects&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
# The &amp;lt;code&amp;gt;global.properties&amp;lt;/code&amp;gt; file should be listed in the current directory. The relevant lines from &amp;lt;code&amp;gt;global.properties&amp;lt;/code&amp;gt; are shown in Listing 1 below.&lt;br /&gt;
'''Listing 1. &amp;lt;code&amp;gt;global.properties&amp;lt;/code&amp;gt; snippet'''&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
TARGET_IP=&lt;br /&gt;
LOGIN=root&lt;br /&gt;
PASSWORD=emac_inc_90210&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
# Change the value of &amp;lt;code&amp;gt;TARGET_IP&amp;lt;/code&amp;gt; to the target system's IP address.&lt;br /&gt;
This can be found using the following command from a shell on the target system:&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@emac-oe:~# /sbin/ifconfig eth0 | grep inet&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
For more information on how to connect to the remote system, see the [[initial connections section]] of the [[EMAC OE Getting Started Guide|EMAC OE getting started guide]].&lt;br /&gt;
# Change the value of &amp;lt;code&amp;gt;PASSWORD&amp;lt;/code&amp;gt; to whatever value was set in the [[System Login section]] of the [[EMAC OE Getting Started Guide|EMAC OE getting started guide]]. Listing 1 shows the default user name and password.&lt;br /&gt;
&lt;br /&gt;
[[Category:EMAC OE SDK]]&lt;/div&gt;</summary>
		<author><name>Mcoleman</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.emacinc.com/index.php?title=Configuring_EMAC_OE_4.0_SDK&amp;diff=504</id>
		<title>Configuring EMAC OE 4.0 SDK</title>
		<link rel="alternate" type="text/html" href="https://wiki.emacinc.com/index.php?title=Configuring_EMAC_OE_4.0_SDK&amp;diff=504"/>
		<updated>2013-05-28T18:51:12Z</updated>

		<summary type="html">&lt;p&gt;Mcoleman: /* Procedure */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{EMAC OE SDK Conventions}}&lt;br /&gt;
&lt;br /&gt;
When Eclipse generates a Makefile to use for building a project, the generated Makefile includes a file named global.properties before it performs any other steps. This file is located in the projects directory, which is the root directory for Eclipse projects. The projects directory is located within the EMAC SDK directory provided by the EMAC SDK package (or installed on the LDC). &lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;global.properties&amp;lt;/code&amp;gt; file provides information needed to build projects and upload them to the target machine (the board supplied by EMAC). The following information is provided by this file: &lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Configuration variable !! Description &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;SDKBASE&amp;lt;/code&amp;gt; || The base directory for the SDK .&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;CC&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;CXX&amp;lt;/code&amp;gt; || Exectuable binaries to use for compiling for the C and C++ compiler, respectively.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;LD_LIBRARY_PATH&amp;lt;/code&amp;gt; || The path the linker should use to search for shared library files.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;CFLAGS&amp;lt;/code&amp;gt; || The flags passed to the compiler to specify target processor architecture, debugging flags, etc.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;OFLAGS&amp;lt;/code&amp;gt; || The flags passed to the compiler to specify optimization options to use.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;TARGET_IP&amp;lt;/code&amp;gt; || The IP Address of the target machine (needed for uploading the compiled binary to the target machine).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;LOGIN&amp;lt;/code&amp;gt; || The user name to use for logging into the target machine.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;PASSWORD&amp;lt;/code&amp;gt; || The password to use for logging into the target machine.*&lt;br /&gt;
|- &lt;br /&gt;
| &amp;lt;code&amp;gt;WPUT&amp;lt;/code&amp;gt; ||  The location of the &amp;lt;code&amp;gt;wput&amp;lt;/code&amp;gt; command, along with options to pass to &amp;lt;code&amp;gt;wput&amp;lt;/code&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
'''*NOTE''' The password is stored in plain text in this file. However, read permission is required to view this password. In most development environments, this should not be an issue. If development is taking place in a shared environment (such as a University lab) and secrecy of this password is required, simply ensure that only trusted users have read permission for this file.&lt;br /&gt;
&lt;br /&gt;
{{mbox | type = warning | text = Configuring permissions on files is a common source of problems for people new to doing so under Linux. EMAC does not recommend altering the default settings (which should be secure in most environments) unless absolutely necessary. EMAC will only be able to provide very limited support should these settings be manually configured. The standard Linux commands, &amp;lt;code&amp;gt;chmod&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;chgrp&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;chown&amp;lt;/code&amp;gt; are typically used to configure these permissions. Please see the documentation for these commands using the man command, or find a reference with your favorite search engine. '''Caveat''': This will require any user wishing to build this software to have such permission, since programs run by a user can only read files the user is permitted to use.}}&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;global.properties&amp;lt;/code&amp;gt; file is actually a type of virtual file, called a softlink. This softlink acts as a pointer which points to another file. The file it points to is chosen when the CPU architecture is chosen. To see why it works this way, see the above information about the flags specified for the processor architecture, and note that different library and compiler paths may be required to support different hardware. The softlink is updated when the hardware to use for the development project is selected.&lt;br /&gt;
&lt;br /&gt;
{{mbox | type = notice | text = Should problems relating to this part of the build system show up during the development process, these files or softlinks may have been accidentally modified. Inspecting these files and softlinks, and/or rerunning the hardware selection script, may provide the fix for the problems. The &amp;lt;code&amp;gt;ln&amp;lt;/code&amp;gt; command with the &amp;lt;code&amp;gt;-s&amp;lt;/code&amp;gt; option (see &amp;lt;code&amp;gt;man ln&amp;lt;/code&amp;gt;) is the command used to create softlinks.}}&lt;br /&gt;
&lt;br /&gt;
==Configuration Steps==&lt;br /&gt;
&lt;br /&gt;
The following configuration steps are necessary to begin using the EMAC OE SDK. &lt;br /&gt;
&lt;br /&gt;
Before cross-compiling source code on the development machine for the target machine: &lt;br /&gt;
&lt;br /&gt;
* A [[set up script]] linking &amp;lt;code&amp;gt;global.properties&amp;lt;/code&amp;gt; to an architecture-specific &amp;lt;code&amp;gt;global.properties&amp;lt;/code&amp;gt; file must be run.&lt;br /&gt;
* The &amp;lt;code&amp;gt;TARGET_IP&amp;lt;/code&amp;gt; variable in the [[global.properties]] file must be changed to the IP address or hostname belonging to the target board.&lt;br /&gt;
&lt;br /&gt;
{{mbox | type = notice | text = These configurations assume that the [[EMAC OE SDK]] is installed.}}&lt;br /&gt;
&lt;br /&gt;
==SDK Set Up Script==&lt;br /&gt;
&lt;br /&gt;
Before compiling source code for the target machine, toolchain libraries for the target machine must be specified by running &amp;lt;code&amp;gt;setmachine.sh&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
===Procedure===&lt;br /&gt;
&lt;br /&gt;
# Navigate to the SDK directory.&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ cd /path/to/sdk/EMAC-OE-arm-linux-gnueabi-SDK_XX.YY/&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
# Run the script using the command shown below to produce a menu as shown in Figure 1 with options for the target machine for which the source will be compiled.&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ ./setmachine.sh&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
[[File:Emac_oe_sdk_setup-2.png]]&lt;br /&gt;
&lt;br /&gt;
==Remote Upload Set-up==&lt;br /&gt;
&lt;br /&gt;
In the &amp;lt;code&amp;gt;global.properties&amp;lt;/code&amp;gt; file there is a variable, &amp;lt;code&amp;gt;IP&amp;lt;/code&amp;gt; which must be set to the target board IP address as shown in Listing 1 below. This step is necessary to ensure that the Make target, &amp;lt;code&amp;gt;'upload'&amp;lt;/code&amp;gt; will work as expected.&lt;br /&gt;
&lt;br /&gt;
===Procedure===&lt;br /&gt;
&lt;br /&gt;
# Navigate to the projects directory within the SDK.&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ cd /path/to/sdk/EMAC-OE-arm-linux-gnueabi-SDK_XX.YY/projects&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
# The &amp;lt;code&amp;gt;global.properties&amp;lt;/code&amp;gt; file should be listed in the current directory. The relevant lines from &amp;lt;code&amp;gt;global.properties&amp;lt;/code&amp;gt; are shown in Listing 1 below.&lt;br /&gt;
'''Listing 1. &amp;lt;code&amp;gt;global.properties&amp;lt;/code&amp;gt; snippet'''&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
TARGET_IP=&lt;br /&gt;
LOGIN=root&lt;br /&gt;
PASSWORD=emac_inc_90210&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
# Change the value of &amp;lt;code&amp;gt;TARGET_IP&amp;lt;/code&amp;gt; to the target system's IP address.&lt;br /&gt;
This can be found using the following command from a shell on the target system:&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@emac-oe:~# /sbin/ifconfig eth0 | grep inet&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
For more information on how to connect to the remote system, see the [[initial connections section]] of the [[EMAC OE Getting Started Guide|EMAC OE getting started guide]].&lt;br /&gt;
# Change the value of &amp;lt;code&amp;gt;PASSWORD&amp;lt;/code&amp;gt; to whatever value was set in the [[System Login section]] of the [[EMAC OE Getting Started Guide|EMAC OE getting started guide]]. Listing 1 shows the default user name and password.&lt;br /&gt;
&lt;br /&gt;
[[Category:EMAC OE SDK]]&lt;/div&gt;</summary>
		<author><name>Mcoleman</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.emacinc.com/index.php?title=Configuring_EMAC_OE_4.0_SDK&amp;diff=503</id>
		<title>Configuring EMAC OE 4.0 SDK</title>
		<link rel="alternate" type="text/html" href="https://wiki.emacinc.com/index.php?title=Configuring_EMAC_OE_4.0_SDK&amp;diff=503"/>
		<updated>2013-05-28T18:50:48Z</updated>

		<summary type="html">&lt;p&gt;Mcoleman: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{EMAC OE SDK Conventions}}&lt;br /&gt;
&lt;br /&gt;
When Eclipse generates a Makefile to use for building a project, the generated Makefile includes a file named global.properties before it performs any other steps. This file is located in the projects directory, which is the root directory for Eclipse projects. The projects directory is located within the EMAC SDK directory provided by the EMAC SDK package (or installed on the LDC). &lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;global.properties&amp;lt;/code&amp;gt; file provides information needed to build projects and upload them to the target machine (the board supplied by EMAC). The following information is provided by this file: &lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Configuration variable !! Description &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;SDKBASE&amp;lt;/code&amp;gt; || The base directory for the SDK .&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;CC&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;CXX&amp;lt;/code&amp;gt; || Exectuable binaries to use for compiling for the C and C++ compiler, respectively.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;LD_LIBRARY_PATH&amp;lt;/code&amp;gt; || The path the linker should use to search for shared library files.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;CFLAGS&amp;lt;/code&amp;gt; || The flags passed to the compiler to specify target processor architecture, debugging flags, etc.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;OFLAGS&amp;lt;/code&amp;gt; || The flags passed to the compiler to specify optimization options to use.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;TARGET_IP&amp;lt;/code&amp;gt; || The IP Address of the target machine (needed for uploading the compiled binary to the target machine).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;LOGIN&amp;lt;/code&amp;gt; || The user name to use for logging into the target machine.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;PASSWORD&amp;lt;/code&amp;gt; || The password to use for logging into the target machine.*&lt;br /&gt;
|- &lt;br /&gt;
| &amp;lt;code&amp;gt;WPUT&amp;lt;/code&amp;gt; ||  The location of the &amp;lt;code&amp;gt;wput&amp;lt;/code&amp;gt; command, along with options to pass to &amp;lt;code&amp;gt;wput&amp;lt;/code&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
'''*NOTE''' The password is stored in plain text in this file. However, read permission is required to view this password. In most development environments, this should not be an issue. If development is taking place in a shared environment (such as a University lab) and secrecy of this password is required, simply ensure that only trusted users have read permission for this file.&lt;br /&gt;
&lt;br /&gt;
{{mbox | type = warning | text = Configuring permissions on files is a common source of problems for people new to doing so under Linux. EMAC does not recommend altering the default settings (which should be secure in most environments) unless absolutely necessary. EMAC will only be able to provide very limited support should these settings be manually configured. The standard Linux commands, &amp;lt;code&amp;gt;chmod&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;chgrp&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;chown&amp;lt;/code&amp;gt; are typically used to configure these permissions. Please see the documentation for these commands using the man command, or find a reference with your favorite search engine. '''Caveat''': This will require any user wishing to build this software to have such permission, since programs run by a user can only read files the user is permitted to use.}}&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;global.properties&amp;lt;/code&amp;gt; file is actually a type of virtual file, called a softlink. This softlink acts as a pointer which points to another file. The file it points to is chosen when the CPU architecture is chosen. To see why it works this way, see the above information about the flags specified for the processor architecture, and note that different library and compiler paths may be required to support different hardware. The softlink is updated when the hardware to use for the development project is selected.&lt;br /&gt;
&lt;br /&gt;
{{mbox | type = notice | text = Should problems relating to this part of the build system show up during the development process, these files or softlinks may have been accidentally modified. Inspecting these files and softlinks, and/or rerunning the hardware selection script, may provide the fix for the problems. The &amp;lt;code&amp;gt;ln&amp;lt;/code&amp;gt; command with the &amp;lt;code&amp;gt;-s&amp;lt;/code&amp;gt; option (see &amp;lt;code&amp;gt;man ln&amp;lt;/code&amp;gt;) is the command used to create softlinks.}}&lt;br /&gt;
&lt;br /&gt;
==Configuration Steps==&lt;br /&gt;
&lt;br /&gt;
The following configuration steps are necessary to begin using the EMAC OE SDK. &lt;br /&gt;
&lt;br /&gt;
Before cross-compiling source code on the development machine for the target machine: &lt;br /&gt;
&lt;br /&gt;
* A [[set up script]] linking &amp;lt;code&amp;gt;global.properties&amp;lt;/code&amp;gt; to an architecture-specific &amp;lt;code&amp;gt;global.properties&amp;lt;/code&amp;gt; file must be run.&lt;br /&gt;
* The &amp;lt;code&amp;gt;TARGET_IP&amp;lt;/code&amp;gt; variable in the [[global.properties]] file must be changed to the IP address or hostname belonging to the target board.&lt;br /&gt;
&lt;br /&gt;
{{mbox | type = notice | text = These configurations assume that the [[EMAC OE SDK]] is installed.}}&lt;br /&gt;
&lt;br /&gt;
==SDK Set Up Script==&lt;br /&gt;
&lt;br /&gt;
Before compiling source code for the target machine, toolchain libraries for the target machine must be specified by running &amp;lt;code&amp;gt;setmachine.sh&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
===Procedure===&lt;br /&gt;
&lt;br /&gt;
# Navigate to the SDK directory.&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ cd /path/to/sdk/EMAC-OE-arm-linux-gnueabi-SDK_XX.YY/&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
# Run the script using the command shown below to produce a menu as shown in Figure 1 with options for the target machine for which the source will be compiled.&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ ./setmachine.sh&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
[[File:Emac_oe_sdk_setup-2.png]]&lt;br /&gt;
&lt;br /&gt;
==Remote Upload Set-up==&lt;br /&gt;
&lt;br /&gt;
In the &amp;lt;code&amp;gt;global.properties&amp;lt;/code&amp;gt; file there is a variable, &amp;lt;code&amp;gt;IP&amp;lt;/code&amp;gt; which must be set to the target board IP address as shown in Listing 1 below. This step is necessary to ensure that the Make target, &amp;lt;code&amp;gt;'upload'&amp;lt;/code&amp;gt; will work as expected.&lt;br /&gt;
&lt;br /&gt;
===Procedure===&lt;br /&gt;
&lt;br /&gt;
# Navigate to the projects directory within the SDK.&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ cd /path/to/sdk/EMAC-OE-arm-linux-gnueabi-SDK_XX.YY/projects&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
# The &amp;lt;code&amp;gt;global.properties&amp;lt;/code&amp;gt; file should be listed in the current directory. The relevant lines from &amp;lt;code&amp;gt;global.properties&amp;lt;/code&amp;gt; are shown in Listing 1 below.&lt;br /&gt;
'''Listing 1. &amp;lt;code&amp;gt;global.properties&amp;lt;/code&amp;gt; snippet'''&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
TARGET_IP=&lt;br /&gt;
LOGIN=root&lt;br /&gt;
PASSWORD=emac_inc_90210&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
# Change the value of &amp;lt;code&amp;gt;TARGET_IP&amp;lt;/code&amp;gt; to the target system's IP address.&amp;lt;br /&amp;gt;&lt;br /&gt;
This can be found using the following command from a shell on the target system:&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@emac-oe:~# /sbin/ifconfig eth0 | grep inet&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
For more information on how to connect to the remote system, see the [[initial connections section]] of the [[EMAC OE Getting Started Guide|EMAC OE getting started guide]].&lt;br /&gt;
# Change the value of &amp;lt;code&amp;gt;PASSWORD&amp;lt;/code&amp;gt; to whatever value was set in the [[System Login section]] of the [[EMAC OE Getting Started Guide|EMAC OE getting started guide]]. Listing 1 shows the default user name and password.&lt;br /&gt;
&lt;br /&gt;
[[Category:EMAC OE SDK]]&lt;/div&gt;</summary>
		<author><name>Mcoleman</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.emacinc.com/index.php?title=Configuring_EMAC_OE_4.0_SDK&amp;diff=502</id>
		<title>Configuring EMAC OE 4.0 SDK</title>
		<link rel="alternate" type="text/html" href="https://wiki.emacinc.com/index.php?title=Configuring_EMAC_OE_4.0_SDK&amp;diff=502"/>
		<updated>2013-05-28T18:50:21Z</updated>

		<summary type="html">&lt;p&gt;Mcoleman: fixing list counting with embedded syntax blocks&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{EMAC OE SDK Conventions}}&lt;br /&gt;
&lt;br /&gt;
When Eclipse generates a Makefile to use for building a project, the generated Makefile includes a file named global.properties before it performs any other steps. This file is located in the projects directory, which is the root directory for Eclipse projects. The projects directory is located within the EMAC SDK directory provided by the EMAC SDK package (or installed on the LDC). &lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;global.properties&amp;lt;/code&amp;gt; file provides information needed to build projects and upload them to the target machine (the board supplied by EMAC). The following information is provided by this file: &lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Configuration variable !! Description &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;SDKBASE&amp;lt;/code&amp;gt; || The base directory for the SDK .&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;CC&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;CXX&amp;lt;/code&amp;gt; || Exectuable binaries to use for compiling for the C and C++ compiler, respectively.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;LD_LIBRARY_PATH&amp;lt;/code&amp;gt; || The path the linker should use to search for shared library files.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;CFLAGS&amp;lt;/code&amp;gt; || The flags passed to the compiler to specify target processor architecture, debugging flags, etc.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;OFLAGS&amp;lt;/code&amp;gt; || The flags passed to the compiler to specify optimization options to use.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;TARGET_IP&amp;lt;/code&amp;gt; || The IP Address of the target machine (needed for uploading the compiled binary to the target machine).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;LOGIN&amp;lt;/code&amp;gt; || The user name to use for logging into the target machine.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;PASSWORD&amp;lt;/code&amp;gt; || The password to use for logging into the target machine.*&lt;br /&gt;
|- &lt;br /&gt;
| &amp;lt;code&amp;gt;WPUT&amp;lt;/code&amp;gt; ||  The location of the &amp;lt;code&amp;gt;wput&amp;lt;/code&amp;gt; command, along with options to pass to &amp;lt;code&amp;gt;wput&amp;lt;/code&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
'''*NOTE''' The password is stored in plain text in this file. However, read permission is required to view this password. In most development environments, this should not be an issue. If development is taking place in a shared environment (such as a University lab) and secrecy of this password is required, simply ensure that only trusted users have read permission for this file.&lt;br /&gt;
&lt;br /&gt;
{{mbox | type = warning | text = Configuring permissions on files is a common source of problems for people new to doing so under Linux. EMAC does not recommend altering the default settings (which should be secure in most environments) unless absolutely necessary. EMAC will only be able to provide very limited support should these settings be manually configured. The standard Linux commands, &amp;lt;code&amp;gt;chmod&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;chgrp&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;chown&amp;lt;/code&amp;gt; are typically used to configure these permissions. Please see the documentation for these commands using the man command, or find a reference with your favorite search engine. '''Caveat''': This will require any user wishing to build this software to have such permission, since programs run by a user can only read files the user is permitted to use.}}&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;global.properties&amp;lt;/code&amp;gt; file is actually a type of virtual file, called a softlink. This softlink acts as a pointer which points to another file. The file it points to is chosen when the CPU architecture is chosen. To see why it works this way, see the above information about the flags specified for the processor architecture, and note that different library and compiler paths may be required to support different hardware. The softlink is updated when the hardware to use for the development project is selected.&lt;br /&gt;
&lt;br /&gt;
{{mbox | type = notice | text = Should problems relating to this part of the build system show up during the development process, these files or softlinks may have been accidentally modified. Inspecting these files and softlinks, and/or rerunning the hardware selection script, may provide the fix for the problems. The &amp;lt;code&amp;gt;ln&amp;lt;/code&amp;gt; command with the &amp;lt;code&amp;gt;-s&amp;lt;/code&amp;gt; option (see &amp;lt;code&amp;gt;man ln&amp;lt;/code&amp;gt;) is the command used to create softlinks.}}&lt;br /&gt;
&lt;br /&gt;
==Configuration Steps==&lt;br /&gt;
&lt;br /&gt;
The following configuration steps are necessary to begin using the EMAC OE SDK. &lt;br /&gt;
&lt;br /&gt;
Before cross-compiling source code on the development machine for the target machine: &lt;br /&gt;
&lt;br /&gt;
* A [[set up script]] linking &amp;lt;code&amp;gt;global.properties&amp;lt;/code&amp;gt; to an architecture-specific &amp;lt;code&amp;gt;global.properties&amp;lt;/code&amp;gt; file must be run.&lt;br /&gt;
* The &amp;lt;code&amp;gt;TARGET_IP&amp;lt;/code&amp;gt; variable in the [[global.properties]] file must be changed to the IP address or hostname belonging to the target board.&lt;br /&gt;
&lt;br /&gt;
{{mbox | type = notice | text = These configurations assume that the [[EMAC OE SDK]] is installed.}}&lt;br /&gt;
&lt;br /&gt;
==SDK Set Up Script==&lt;br /&gt;
&lt;br /&gt;
Before compiling source code for the target machine, toolchain libraries for the target machine must be specified by running &amp;lt;code&amp;gt;setmachine.sh&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
===Procedure===&lt;br /&gt;
&lt;br /&gt;
# Navigate to the SDK directory.&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ cd /path/to/sdk/EMAC-OE-arm-linux-gnueabi-SDK_XX.YY/&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
# Run the script using the command shown below to produce a menu as shown in Figure 1 with options for the target machine for which the source will be compiled.&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ ./setmachine.sh&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
[[File:Emac_oe_sdk_setup-2.png]]&lt;br /&gt;
&lt;br /&gt;
==Remote Upload Set-up==&lt;br /&gt;
&lt;br /&gt;
In the &amp;lt;code&amp;gt;global.properties&amp;lt;/code&amp;gt; file there is a variable, &amp;lt;code&amp;gt;IP&amp;lt;/code&amp;gt; which must be set to the target board IP address as shown in Listing 1 below. This step is necessary to ensure that the Make target, &amp;lt;code&amp;gt;'upload'&amp;lt;/code&amp;gt; will work as expected.&lt;br /&gt;
&lt;br /&gt;
===Procedure===&lt;br /&gt;
&lt;br /&gt;
# Navigate to the projects directory within the SDK.&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ cd /path/to/sdk/EMAC-OE-arm-linux-gnueabi-SDK_XX.YY/projects&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
# The &amp;lt;code&amp;gt;global.properties&amp;lt;/code&amp;gt; file should be listed in the current directory. The relevant lines from &amp;lt;code&amp;gt;global.properties&amp;lt;/code&amp;gt; are shown in Listing 1 below.&lt;br /&gt;
'''Listing 1. &amp;lt;code&amp;gt;global.properties&amp;lt;/code&amp;gt; snippet'''&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
TARGET_IP=&lt;br /&gt;
LOGIN=root&lt;br /&gt;
PASSWORD=emac_inc_90210&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
# Change the value of &amp;lt;code&amp;gt;TARGET_IP&amp;lt;/code&amp;gt; to the target system's IP address.&lt;br /&gt;
This can be found using the following command from a shell on the target system:&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@emac-oe:~# /sbin/ifconfig eth0 | grep inet&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
For more information on how to connect to the remote system, see the [[initial connections section]] of the [[EMAC OE Getting Started Guide|EMAC OE getting started guide]].&lt;br /&gt;
# Change the value of &amp;lt;code&amp;gt;PASSWORD&amp;lt;/code&amp;gt; to whatever value was set in the [[System Login section]] of the [[EMAC OE Getting Started Guide|EMAC OE getting started guide]]. Listing 1 shows the default user name and password.&lt;br /&gt;
&lt;br /&gt;
[[Category:EMAC OE SDK]]&lt;/div&gt;</summary>
		<author><name>Mcoleman</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.emacinc.com/index.php?title=Configuring_EMAC_OE_4.0_SDK&amp;diff=501</id>
		<title>Configuring EMAC OE 4.0 SDK</title>
		<link rel="alternate" type="text/html" href="https://wiki.emacinc.com/index.php?title=Configuring_EMAC_OE_4.0_SDK&amp;diff=501"/>
		<updated>2013-05-28T18:49:46Z</updated>

		<summary type="html">&lt;p&gt;Mcoleman: fixing list counting with embedded syntax blocks&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{EMAC OE SDK Conventions}}&lt;br /&gt;
&lt;br /&gt;
When Eclipse generates a Makefile to use for building a project, the generated Makefile includes a file named global.properties before it performs any other steps. This file is located in the projects directory, which is the root directory for Eclipse projects. The projects directory is located within the EMAC SDK directory provided by the EMAC SDK package (or installed on the LDC). &lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;global.properties&amp;lt;/code&amp;gt; file provides information needed to build projects and upload them to the target machine (the board supplied by EMAC). The following information is provided by this file: &lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Configuration variable !! Description &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;SDKBASE&amp;lt;/code&amp;gt; || The base directory for the SDK .&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;CC&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;CXX&amp;lt;/code&amp;gt; || Exectuable binaries to use for compiling for the C and C++ compiler, respectively.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;LD_LIBRARY_PATH&amp;lt;/code&amp;gt; || The path the linker should use to search for shared library files.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;CFLAGS&amp;lt;/code&amp;gt; || The flags passed to the compiler to specify target processor architecture, debugging flags, etc.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;OFLAGS&amp;lt;/code&amp;gt; || The flags passed to the compiler to specify optimization options to use.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;TARGET_IP&amp;lt;/code&amp;gt; || The IP Address of the target machine (needed for uploading the compiled binary to the target machine).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;LOGIN&amp;lt;/code&amp;gt; || The user name to use for logging into the target machine.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;PASSWORD&amp;lt;/code&amp;gt; || The password to use for logging into the target machine.*&lt;br /&gt;
|- &lt;br /&gt;
| &amp;lt;code&amp;gt;WPUT&amp;lt;/code&amp;gt; ||  The location of the &amp;lt;code&amp;gt;wput&amp;lt;/code&amp;gt; command, along with options to pass to &amp;lt;code&amp;gt;wput&amp;lt;/code&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
'''*NOTE''' The password is stored in plain text in this file. However, read permission is required to view this password. In most development environments, this should not be an issue. If development is taking place in a shared environment (such as a University lab) and secrecy of this password is required, simply ensure that only trusted users have read permission for this file.&lt;br /&gt;
&lt;br /&gt;
{{mbox | type = warning | text = Configuring permissions on files is a common source of problems for people new to doing so under Linux. EMAC does not recommend altering the default settings (which should be secure in most environments) unless absolutely necessary. EMAC will only be able to provide very limited support should these settings be manually configured. The standard Linux commands, &amp;lt;code&amp;gt;chmod&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;chgrp&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;chown&amp;lt;/code&amp;gt; are typically used to configure these permissions. Please see the documentation for these commands using the man command, or find a reference with your favorite search engine. '''Caveat''': This will require any user wishing to build this software to have such permission, since programs run by a user can only read files the user is permitted to use.}}&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;global.properties&amp;lt;/code&amp;gt; file is actually a type of virtual file, called a softlink. This softlink acts as a pointer which points to another file. The file it points to is chosen when the CPU architecture is chosen. To see why it works this way, see the above information about the flags specified for the processor architecture, and note that different library and compiler paths may be required to support different hardware. The softlink is updated when the hardware to use for the development project is selected.&lt;br /&gt;
&lt;br /&gt;
{{mbox | type = notice | text = Should problems relating to this part of the build system show up during the development process, these files or softlinks may have been accidentally modified. Inspecting these files and softlinks, and/or rerunning the hardware selection script, may provide the fix for the problems. The &amp;lt;code&amp;gt;ln&amp;lt;/code&amp;gt; command with the &amp;lt;code&amp;gt;-s&amp;lt;/code&amp;gt; option (see &amp;lt;code&amp;gt;man ln&amp;lt;/code&amp;gt;) is the command used to create softlinks.}}&lt;br /&gt;
&lt;br /&gt;
==Configuration Steps==&lt;br /&gt;
&lt;br /&gt;
The following configuration steps are necessary to begin using the EMAC OE SDK. &lt;br /&gt;
&lt;br /&gt;
Before cross-compiling source code on the development machine for the target machine: &lt;br /&gt;
&lt;br /&gt;
* A [[set up script]] linking &amp;lt;code&amp;gt;global.properties&amp;lt;/code&amp;gt; to an architecture-specific &amp;lt;code&amp;gt;global.properties&amp;lt;/code&amp;gt; file must be run.&lt;br /&gt;
* The &amp;lt;code&amp;gt;TARGET_IP&amp;lt;/code&amp;gt; variable in the [[global.properties]] file must be changed to the IP address or hostname belonging to the target board.&lt;br /&gt;
&lt;br /&gt;
{{mbox | type = notice | text = These configurations assume that the [[EMAC OE SDK]] is installed.}}&lt;br /&gt;
&lt;br /&gt;
==SDK Set Up Script==&lt;br /&gt;
&lt;br /&gt;
Before compiling source code for the target machine, toolchain libraries for the target machine must be specified by running &amp;lt;code&amp;gt;setmachine.sh&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
===Procedure===&lt;br /&gt;
&lt;br /&gt;
# Navigate to the SDK directory.&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ cd /path/to/sdk/EMAC-OE-arm-linux-gnueabi-SDK_XX.YY/&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
# Run the script using the command shown below to produce a menu as shown in Figure 1 with options for the target machine for which the source will be compiled.&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ ./setmachine.sh&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
[[File:Emac_oe_sdk_setup-2.png]]&lt;br /&gt;
&lt;br /&gt;
==Remote Upload Set-up==&lt;br /&gt;
&lt;br /&gt;
In the &amp;lt;code&amp;gt;global.properties&amp;lt;/code&amp;gt; file there is a variable, &amp;lt;code&amp;gt;IP&amp;lt;/code&amp;gt; which must be set to the target board IP address as shown in Listing 1 below. This step is necessary to ensure that the Make target, &amp;lt;code&amp;gt;'upload'&amp;lt;/code&amp;gt; will work as expected.&lt;br /&gt;
&lt;br /&gt;
===Procedure===&lt;br /&gt;
&lt;br /&gt;
# Navigate to the projects directory within the SDK.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ cd /path/to/sdk/EMAC-OE-arm-linux-gnueabi-SDK_XX.YY/projects&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
# The &amp;lt;code&amp;gt;global.properties&amp;lt;/code&amp;gt; file should be listed in the current directory. The relevant lines from &amp;lt;code&amp;gt;global.properties&amp;lt;/code&amp;gt; are shown in Listing 1 below.&lt;br /&gt;
'''Listing 1. &amp;lt;code&amp;gt;global.properties&amp;lt;/code&amp;gt; snippet'''&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
TARGET_IP=&lt;br /&gt;
LOGIN=root&lt;br /&gt;
PASSWORD=emac_inc_90210&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
# Change the value of &amp;lt;code&amp;gt;TARGET_IP&amp;lt;/code&amp;gt; to the target system's IP address.&lt;br /&gt;
This can be found using the following command from a shell on the target system:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@emac-oe:~# /sbin/ifconfig eth0 | grep inet&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
For more information on how to connect to the remote system, see the [[initial connections section]] of the [[EMAC OE Getting Started Guide|EMAC OE getting started guide]].&lt;br /&gt;
# Change the value of &amp;lt;code&amp;gt;PASSWORD&amp;lt;/code&amp;gt; to whatever value was set in the [[System Login section]] of the [[EMAC OE Getting Started Guide|EMAC OE getting started guide]]. Listing 1 shows the default user name and password.&lt;br /&gt;
&lt;br /&gt;
[[Category:EMAC OE SDK]]&lt;/div&gt;</summary>
		<author><name>Mcoleman</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.emacinc.com/index.php?title=Using_the_EMAC_GPIO_Class&amp;diff=495</id>
		<title>Using the EMAC GPIO Class</title>
		<link rel="alternate" type="text/html" href="https://wiki.emacinc.com/index.php?title=Using_the_EMAC_GPIO_Class&amp;diff=495"/>
		<updated>2013-05-24T21:09:28Z</updated>

		<summary type="html">&lt;p&gt;Mcoleman: init&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The EMAC GPIO Class is a generic programming interface for General Purpose Input Output (GPIO) devices in the Linux Kernel. The GPIO class driver has two main interfaces under standard Linux: Linux sysfs and character device. The GPIO class is extremely flexible and uses a set of function pointers at the kernel level to allow for specialized read/write functions for each device. EMAC utilizes the GPIO class to create devices that use the same simple interface, such as GPIO registers, simple configuration variables, hardware registers, and Analog-to-Digital converter drivers where the user needs to retrieve a single value from the device.&lt;br /&gt;
&lt;br /&gt;
At this point the EMAC GPIO Class is only available in EMAC patched kernels for select devices.&lt;br /&gt;
&lt;br /&gt;
==Components==&lt;br /&gt;
&lt;br /&gt;
An EMAC GPIO Class Device has three main components. A clear understanding of these components is important for proper use and implementation.&lt;br /&gt;
&lt;br /&gt;
===Data===&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;data&amp;lt;/code&amp;gt; member of a GPIO device is the primary component. In the most simple devices, this is the only component accessible from userspace. The &amp;lt;code&amp;gt;data&amp;lt;/code&amp;gt; member is read and/or written to access or set the current value of the GPIO device. The actual function of the &amp;lt;code&amp;gt;data&amp;lt;/code&amp;gt; member is implementation specific. For a GPIO device in its purest form, such as the GPIO ports present in many of EMAC's CPLD designs, the &amp;lt;code&amp;gt;data&amp;lt;/code&amp;gt; member is a register value with each of the 8 least significant bits representing the digital state of a single line in the GPIO port. In contrast, AtoD devices implemented with the EMAC GPIO Class will typically provide the analog value of the currently selected channel in the &amp;lt;code&amp;gt;data&amp;lt;/code&amp;gt; member.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;data&amp;lt;/code&amp;gt; member is allocated as a 32-bit unsigned integer regardless of implementation. Many devices use only the least significant byte or the least significant bit. &lt;br /&gt;
&lt;br /&gt;
===DDR===&lt;br /&gt;
&lt;br /&gt;
DANCE DANCE REVOLUTION&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;ddr&amp;lt;/code&amp;gt; or Data Direction Register is a member of the EMAC GPIO Class that is used primarily for direction-configurable GPIO devices. Many devices do not register this aspect of the interface. The &amp;lt;code&amp;gt;ddr&amp;lt;/code&amp;gt; member is used to determine if a particular device should act as an input or output. Depending on the implementation, many devices are bit-configurable GPIO devices, meaning that each bit/line in the GPIO device can be configured as an input or output by its respective value in the &amp;lt;code&amp;gt;ddr&amp;lt;/code&amp;gt;. Typically, a '1' value in the &amp;lt;code&amp;gt;ddr&amp;lt;/code&amp;gt; configures the device as an output and a '0' value in the ddr configures the device as an input. Bidirectional GPIO devices are generally configured as inputs by default until explicitly configured as an output to prevent hardware contention.&lt;br /&gt;
&lt;br /&gt;
For example, an EMAC GPIO Class device porta is a one-byte bit-configurable bidirectional GPIO device. Each bit in the &amp;lt;code&amp;gt;data&amp;lt;/code&amp;gt; register corresponds to the digital status of the corresponding line porta[0-7]. On reset, the &amp;lt;code&amp;gt;ddr&amp;lt;/code&amp;gt; member is read at &amp;lt;code&amp;gt;0x00&amp;lt;/code&amp;gt;, indicating that the device is configured with all lines as inputs. If the &amp;lt;code&amp;gt;ddr&amp;lt;/code&amp;gt; member is set to &amp;lt;code&amp;gt;0xAA&amp;lt;/code&amp;gt; (binary 1010 1010) bits 0, 2, 4, and 6 will remain configured as inputs while the rest of the bits will be configured as outputs. Reading and setting the value in the &amp;lt;code&amp;gt;data&amp;lt;/code&amp;gt; member will react according to the configuration set in the &amp;lt;code&amp;gt;ddr&amp;lt;/code&amp;gt;. The &amp;lt;code&amp;gt;ddr&amp;lt;/code&amp;gt; is allocated as a 32-bit unsigned integer regardless of implementation.&lt;br /&gt;
&lt;br /&gt;
===Index===&lt;br /&gt;
&lt;br /&gt;
Many EMAC GPIO Class devices are implemented as indexed GPIO Devices. These devices utilize a member named &amp;lt;code&amp;gt;index&amp;lt;/code&amp;gt; which impacts the device according to the implementation. The &amp;lt;code&amp;gt;index&amp;lt;/code&amp;gt; member is typically used to specify a memory offset from some base for the &amp;lt;code&amp;gt;data&amp;lt;/code&amp;gt; member or some type of channel setting or controller selection. Many devices ignore the &amp;lt;code&amp;gt;index&amp;lt;/code&amp;gt; value or do not register this member at all.&lt;br /&gt;
&lt;br /&gt;
An example of an indexed GPIO Class device is the &amp;lt;code&amp;gt;indexed_atod&amp;lt;/code&amp;gt; device (and other [[AtoD]] devices) found on many EMAC boards. In this case, the &amp;lt;code&amp;gt;index&amp;lt;/code&amp;gt; member is used to set the current channel of the AtoD to read from the &amp;lt;code&amp;gt;data&amp;lt;/code&amp;gt; member. When the &amp;lt;code&amp;gt;index&amp;lt;/code&amp;gt; is set to 0, channel 0 will be accessed. When the index is set to 3, the &amp;lt;code&amp;gt;data&amp;lt;/code&amp;gt; register will reflect the current value on channel 3 of the device. Another example would be two identical counter registers in a device where setting the index would control which counter was accessed when reading the &amp;lt;code&amp;gt;data&amp;lt;/code&amp;gt; register. This would be an alternative to registering a separate device for each counter.&lt;br /&gt;
&lt;br /&gt;
Indexed GPIO devices should check the applicable range for the &amp;lt;code&amp;gt;index&amp;lt;/code&amp;gt; when the user attempts to set the device. For example, an 8-channel AtoD device implemented as an EMAC GPIO Class device would have a valid range for the &amp;lt;code&amp;gt;index&amp;lt;/code&amp;gt; member of 0-7. Attempting to set the &amp;lt;code&amp;gt;index&amp;lt;/code&amp;gt; to anything greater than 7 would cause the &amp;lt;code&amp;gt;index&amp;lt;/code&amp;gt; to be set to the maximum allowed value of 7.&lt;br /&gt;
&lt;br /&gt;
===Lock===&lt;/div&gt;</summary>
		<author><name>Mcoleman</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.emacinc.com/index.php?title=Building_the_Linux_Kernel&amp;diff=494</id>
		<title>Building the Linux Kernel</title>
		<link rel="alternate" type="text/html" href="https://wiki.emacinc.com/index.php?title=Building_the_Linux_Kernel&amp;diff=494"/>
		<updated>2013-05-24T19:19:42Z</updated>

		<summary type="html">&lt;p&gt;Mcoleman: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page covers the process of configuring and compiling the Linux kernel for a particular board using the standard EMAC kernel build script. This process assumes that you have already acquired the following software: &lt;br /&gt;
&lt;br /&gt;
# Software Development Kit for target hardware&lt;br /&gt;
# Linux kernel source for target hardware (generally provided via EMAC public SVN server)&lt;br /&gt;
# Kernel build script for target hardware&lt;br /&gt;
&lt;br /&gt;
If you do not know where to access the items above for your board, contact EMAC for more information.&lt;br /&gt;
&lt;br /&gt;
The example below will assume that a kernel image for the [[SoM-9307]] module will be created, but the instructions apply to other hardware as well assuming that the correct SDK, kernel tree, and build script is used.&lt;br /&gt;
&lt;br /&gt;
==Setup==&lt;br /&gt;
&lt;br /&gt;
The current kernel tree for the [[SoM]]-9307 is &amp;lt;/code&amp;gt;linux-2.6.25-ep93xx&amp;lt;/code&amp;gt;. The&lt;br /&gt;
current SDK is the EMAC OE arm SDK, which should be configured for the&lt;br /&gt;
SoM-9307. The steps below assume that the &amp;lt;code&amp;gt;kernel-build-cross.sh&amp;lt;/code&amp;gt; script is&lt;br /&gt;
located in the same directory as the kernel tree. Be sure to modify the script&lt;br /&gt;
so that the CROSS variable references the location of the SDK on your system.&lt;br /&gt;
Also note that you may have difficulties using this script with the dash shell&lt;br /&gt;
(default on Ubuntu Linux variants and some other distributions). If this is the&lt;br /&gt;
case, change the top line of the kernel build script to reference &amp;lt;code&amp;gt;/bin/bash&amp;lt;/code&amp;gt;&lt;br /&gt;
rather than &amp;lt;code&amp;gt;/bin/sh&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==Configuring the Kernel==&lt;br /&gt;
&lt;br /&gt;
The first step for building the kernel is to [[configure it]] as desired. EMAC&lt;br /&gt;
provides default configuration files for each board as a part of the kernel&lt;br /&gt;
tree. For the SoM-9307, this file is&lt;br /&gt;
&amp;lt;code&amp;gt;linux-2.6.25-ep93xx/arch/arm/configs/som9307_defconfig&amp;lt;/code&amp;gt;. When configuring the&lt;br /&gt;
kernel it is important to remember that many configuration options are&lt;br /&gt;
necessary to have a working kernel image. Use the following steps to configure&lt;br /&gt;
the kernel:&lt;br /&gt;
&lt;br /&gt;
# Copy the default configuration file to &amp;lt;code&amp;gt;.config&amp;lt;/code&amp;gt; in the kernel source tree. This only needs to be done the first time that you start a new build from a blank configuration. &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ cp linux-2.6.25-ep93xx/arch/arm/configs/som9307_defconfig linux-2.6.25-ep93xx/.config&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
# Run the kernel build script with the config option to bring up the kernel&lt;br /&gt;
“menuconfig”. The first argument to the script is the kernel source tree. The&lt;br /&gt;
second option is one of &amp;lt;code&amp;gt;config&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;build&amp;lt;/code&amp;gt;. The final option is a build-suffix;&lt;br /&gt;
this is used as a tag for the directory that the kernel will be built in. You&lt;br /&gt;
may use any string that you like, such as a date tag (&amp;lt;code&amp;gt;20090101&amp;lt;/code&amp;gt;) or machine&lt;br /&gt;
name (&amp;lt;code&amp;gt;som9307&amp;lt;/code&amp;gt;). Using &amp;lt;code&amp;gt;som9307&amp;lt;/code&amp;gt; as the build-suffix will cause the kernel to be&lt;br /&gt;
built in a directory named &amp;lt;code&amp;gt;build-2.6.25-som9307&amp;lt;/code&amp;gt;. &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ ./kernel-build-cross.sh linux-2.6.25-ep93xx config som9307&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
# This will bring up the kernel menu-driven configuration utility. Make any configuration changes desired, selecting features as a built-in or as modules (when available). The space bar is used to select an option, the 'm' key can be used to configure the selected option as a module. After you are finished, select &amp;lt;code&amp;gt;Exit&amp;lt;/code&amp;gt;. The new configuration will be saved as &amp;lt;code&amp;gt;.config&amp;lt;/code&amp;gt; under the newly created build directory. When you use the same build-suffix with the kernel build script in the future, this configuration will be used. Note that the build script removes the &amp;lt;code&amp;gt;.config&amp;lt;/code&amp;gt; file from the kernel source tree and saves it to a file called &amp;lt;code&amp;gt;prevconfig&amp;lt;/code&amp;gt; in the kernel source tree.&lt;br /&gt;
&lt;br /&gt;
==Building the Kernel==&lt;br /&gt;
&lt;br /&gt;
Once the kernel is configured, a new image can be built. Use the following steps to build a new kernel image:&lt;br /&gt;
&lt;br /&gt;
# Run the kernel build script with the build option, using the same build-suffix used in the configuration step. &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ ./kernel-build-cross.sh linux-2.6.25-ep93xx build som9307&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
# The kernel should begin compiling now. This will take several minutes to complete depending on your configuration and the speed of the development machine that you are using. Only move on to the next step if the build completes with no errors.&lt;br /&gt;
# The new kernel image is located in the build directory, the exact location depending on your architecture and image type. For the SoM-9307, the image is under &amp;lt;code&amp;gt;build-2.6.25-som9307/arch/arm/boot/zImage&amp;lt;/code&amp;gt;. This is the image that will get loaded onto the board and executed by the bootloader. Another important file created by the build script is an archive of all of the modules that were created during the build process. This file is stored under the build directory. From the build steps above, the archive would be &amp;lt;code&amp;gt;build-2.6.25-som9307/kernel-2.6.25.tar.gz&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{{mbox | type = notice | text = Note that if you recompile the kernel but do not change the configuration or source code for any of the modules, it may not be necessary to reload the modules archive. This is often the case for custom driver development.}}&lt;br /&gt;
&lt;br /&gt;
==Loading==&lt;br /&gt;
&lt;br /&gt;
===Kernel Image===&lt;br /&gt;
&lt;br /&gt;
This step is highly architecture dependent. On most x86 boards and some other systems, the kernel image is stored and loaded from the root flash. If this is the case, the only step required is to load the kernel archive (i.e. &amp;lt;code&amp;gt;kernel-2.6.25.tar.gz&amp;lt;/code&amp;gt;) onto the system and extract it. Many ARM systems typically store the kernel in a binary partition on the flash storage device separate from the root filesystem. In this case, the kernel image file must be loaded onto the system and written to the flash. The basic process for loading and testing the new kernel is as follows:&lt;br /&gt;
&lt;br /&gt;
# Load the kernel modules archive onto the board. The example below assumes that the IP address of the board is &amp;lt;code&amp;gt;10.0.2.41&amp;lt;/code&amp;gt;. &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ scp build-2.6.25-som9307/kernel-2.6.25.tar.gz root@10.0.2.41:/tmp &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
# Extract the kernel modules archive to &amp;lt;code&amp;gt;/&amp;lt;/code&amp;gt; on the board. Make sure that the root flash is mounted read/write and run the following on the board after logging in as root:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@emac-oe:~# cd /&lt;br /&gt;
root@emac-oe:~# tar xzvf /tmp/kernel-2.6.25.tar.gz /lib/modules&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Custom Development]]&lt;/div&gt;</summary>
		<author><name>Mcoleman</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.emacinc.com/index.php?title=Building_the_Linux_Kernel&amp;diff=493</id>
		<title>Building the Linux Kernel</title>
		<link rel="alternate" type="text/html" href="https://wiki.emacinc.com/index.php?title=Building_the_Linux_Kernel&amp;diff=493"/>
		<updated>2013-05-24T19:19:22Z</updated>

		<summary type="html">&lt;p&gt;Mcoleman: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page covers the process of configuring and compiling the Linux kernel for a particular board using the standard EMAC kernel build script. This process assumes that you have already acquired the following software: &lt;br /&gt;
&lt;br /&gt;
# Software Development Kit for target hardware&lt;br /&gt;
# Linux kernel source for target hardware (generally provided via EMAC public SVN server)&lt;br /&gt;
# Kernel build script for target hardware&lt;br /&gt;
&lt;br /&gt;
If you do not know where to access the items above for your board, contact EMAC for more information.&lt;br /&gt;
&lt;br /&gt;
The example below will assume that a kernel image for the [[SoM-9307]] module will be created, but the instructions apply to other hardware as well assuming that the correct SDK, kernel tree, and build script is used.&lt;br /&gt;
&lt;br /&gt;
==Setup==&lt;br /&gt;
&lt;br /&gt;
The current kernel tree for the [[SoM]]-9307 is &amp;lt;/code&amp;gt;linux-2.6.25-ep93xx&amp;lt;/code&amp;gt;. The&lt;br /&gt;
current SDK is the EMAC OE arm SDK, which should be configured for the&lt;br /&gt;
SoM-9307. The steps below assume that the &amp;lt;code&amp;gt;kernel-build-cross.sh&amp;lt;/code&amp;gt; script is&lt;br /&gt;
located in the same directory as the kernel tree. Be sure to modify the script&lt;br /&gt;
so that the CROSS variable references the location of the SDK on your system.&lt;br /&gt;
Also note that you may have difficulties using this script with the dash shell&lt;br /&gt;
(default on Ubuntu Linux variants and some other distributions). If this is the&lt;br /&gt;
case, change the top line of the kernel build script to reference &amp;lt;code&amp;gt;/bin/bash&amp;lt;/code&amp;gt;&lt;br /&gt;
rather than &amp;lt;code&amp;gt;/bin/sh&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==Configuring the Kernel==&lt;br /&gt;
&lt;br /&gt;
The first step for building the kernel is to [[configure it]] as desired. EMAC&lt;br /&gt;
provides default configuration files for each board as a part of the kernel&lt;br /&gt;
tree. For the SoM-9307, this file is&lt;br /&gt;
&amp;lt;code&amp;gt;linux-2.6.25-ep93xx/arch/arm/configs/som9307_defconfig&amp;lt;/code&amp;gt;. When configuring the&lt;br /&gt;
kernel it is important to remember that many configuration options are&lt;br /&gt;
necessary to have a working kernel image. Use the following steps to configure&lt;br /&gt;
the kernel:&lt;br /&gt;
&lt;br /&gt;
# Copy the default configuration file to &amp;lt;code&amp;gt;.config&amp;lt;/code&amp;gt; in the kernel source tree. This only needs to be done the first time that you start a new build from a blank configuration. &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ cp linux-2.6.25-ep93xx/arch/arm/configs/som9307_defconfig linux-2.6.25-ep93xx/.config&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
# Run the kernel build script with the config option to bring up the kernel&lt;br /&gt;
“menuconfig”. The first argument to the script is the kernel source tree. The&lt;br /&gt;
second option is one of &amp;lt;code&amp;gt;config&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;build&amp;lt;/code&amp;gt;. The final option is a build-suffix;&lt;br /&gt;
this is used as a tag for the directory that the kernel will be built in. You&lt;br /&gt;
may use any string that you like, such as a date tag (&amp;lt;code&amp;gt;20090101&amp;lt;/code&amp;gt;) or machine&lt;br /&gt;
name (&amp;lt;code&amp;gt;som9307&amp;lt;/code&amp;gt;). Using &amp;lt;code&amp;gt;som9307&amp;lt;/code&amp;gt; as the build-suffix will cause the kernel to be&lt;br /&gt;
built in a directory named &amp;lt;code&amp;gt;build-2.6.25-som9307&amp;lt;/code&amp;gt;. &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ ./kernel-build-cross.sh linux-2.6.25-ep93xx config som9307&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
# This will bring up the kernel menu-driven configuration utility. Make any configuration changes desired, selecting features as a built-in or as modules (when available). The space bar is used to select an option, the 'm' key can be used to configure the selected option as a module. After you are finished, select &amp;lt;code&amp;gt;Exit&amp;lt;/code&amp;gt;. The new configuration will be saved as &amp;lt;code&amp;gt;.config&amp;lt;/code&amp;gt; under the newly created build directory. When you use the same build-suffix with the kernel build script in the future, this configuration will be used. Note that the build script removes the &amp;lt;code&amp;gt;.config&amp;lt;/code&amp;gt; file from the kernel source tree and saves it to a file called &amp;lt;code&amp;gt;prevconfig&amp;lt;/code&amp;gt; in the kernel source tree.&lt;br /&gt;
&lt;br /&gt;
==Building the Kernel==&lt;br /&gt;
&lt;br /&gt;
Once the kernel is configured, a new image can be built. Use the following steps to build a new kernel image:&lt;br /&gt;
&lt;br /&gt;
# Run the kernel build script with the build option, using the same build-suffix used in the configuration step. &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ ./kernel-build-cross.sh linux-2.6.25-ep93xx build som9307&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
# The kernel should begin compiling now. This will take several minutes to complete depending on your configuration and the speed of the development machine that you are using. Only move on to the next step if the build completes with no errors.&lt;br /&gt;
# The new kernel image is located in the build directory, the exact location depending on your architecture and image type. For the SoM-9307, the image is under &amp;lt;code&amp;gt;build-2.6.25-som9307/arch/arm/boot/zImage&amp;lt;/code&amp;gt;. This is the image that will get loaded onto the board and executed by the bootloader. Another important file created by the build script is an archive of all of the modules that were created during the build process. This file is stored under the build directory. From the build steps above, the archive would be &amp;lt;code&amp;gt;build-2.6.25-som9307/kernel-2.6.25.tar.gz&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{{mbox | type = notice | text = Note that if you recompile the kernel but do not change the configuration or source code for any of the modules, it may not be necessary to reload the modules archive. This is often the case for custom driver development.}}&lt;br /&gt;
&lt;br /&gt;
==Loading==&lt;br /&gt;
&lt;br /&gt;
===Kernel Image===&lt;br /&gt;
&lt;br /&gt;
This step is highly architecture dependent. On most x86 boards and some other systems, the kernel image is stored and loaded from the root flash. If this is the case, the only step required is to load the kernel archive (i.e. &amp;lt;code&amp;gt;kernel-2.6.25.tar.gz&amp;lt;/code&amp;gt;) onto the system and extract it. Many ARM systems typically store the kernel in a binary partition on the flash storage device separate from the root filesystem. In this case, the kernel image file must be loaded onto the system and written to the flash. The basic process for loading and testing the new kernel is as follows:&lt;br /&gt;
&lt;br /&gt;
# Load the kernel modules archive onto the board. The example below assumes that the IP address of the board is &amp;lt;code&amp;gt;10.0.2.41&amp;lt;/code&amp;gt;. &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ scp build-2.6.25-som9307/kernel-2.6.25.tar.gz root@10.0.2.41:/tmp &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
# Extract the kernel modules archive to &amp;lt;code&amp;gt;/&amp;lt;/code&amp;gt; on the board. Make sure that the root flash is mounted read/write and run the following on the board after logging in as root:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@emac-oe:~# cd /&lt;br /&gt;
root@emac-oe:~# tar xzvf /tmp/kernel-2.6.25.tar.gz /lib/modules&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{Category::Custom Development}}&lt;/div&gt;</summary>
		<author><name>Mcoleman</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.emacinc.com/index.php?title=Building_the_Linux_Kernel&amp;diff=492</id>
		<title>Building the Linux Kernel</title>
		<link rel="alternate" type="text/html" href="https://wiki.emacinc.com/index.php?title=Building_the_Linux_Kernel&amp;diff=492"/>
		<updated>2013-05-24T19:18:56Z</updated>

		<summary type="html">&lt;p&gt;Mcoleman: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page covers the process of configuring and compiling the Linux kernel for a particular board using the standard EMAC kernel build script. This process assumes that you have already acquired the following software: &lt;br /&gt;
&lt;br /&gt;
# Software Development Kit for target hardware&lt;br /&gt;
# Linux kernel source for target hardware (generally provided via EMAC public SVN server)&lt;br /&gt;
# Kernel build script for target hardware&lt;br /&gt;
&lt;br /&gt;
If you do not know where to access the items above for your board, contact EMAC for more information.&lt;br /&gt;
&lt;br /&gt;
The example below will assume that a kernel image for the [[SoM-9307]] module will be created, but the instructions apply to other hardware as well assuming that the correct SDK, kernel tree, and build script is used.&lt;br /&gt;
&lt;br /&gt;
==Setup==&lt;br /&gt;
&lt;br /&gt;
The current kernel tree for the [[SoM]]-9307 is &amp;lt;/code&amp;gt;linux-2.6.25-ep93xx&amp;lt;/code&amp;gt;. The&lt;br /&gt;
current SDK is the EMAC OE arm SDK, which should be configured for the&lt;br /&gt;
SoM-9307. The steps below assume that the &amp;lt;code&amp;gt;kernel-build-cross.sh&amp;lt;/code&amp;gt; script is&lt;br /&gt;
located in the same directory as the kernel tree. Be sure to modify the script&lt;br /&gt;
so that the CROSS variable references the location of the SDK on your system.&lt;br /&gt;
Also note that you may have difficulties using this script with the dash shell&lt;br /&gt;
(default on Ubuntu Linux variants and some other distributions). If this is the&lt;br /&gt;
case, change the top line of the kernel build script to reference &amp;lt;code&amp;gt;/bin/bash&amp;lt;/code&amp;gt;&lt;br /&gt;
rather than &amp;lt;code&amp;gt;/bin/sh&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==Configuring the Kernel==&lt;br /&gt;
&lt;br /&gt;
The first step for building the kernel is to [[configure it]] as desired. EMAC&lt;br /&gt;
provides default configuration files for each board as a part of the kernel&lt;br /&gt;
tree. For the SoM-9307, this file is&lt;br /&gt;
&amp;lt;code&amp;gt;linux-2.6.25-ep93xx/arch/arm/configs/som9307_defconfig&amp;lt;/code&amp;gt;. When configuring the&lt;br /&gt;
kernel it is important to remember that many configuration options are&lt;br /&gt;
necessary to have a working kernel image. Use the following steps to configure&lt;br /&gt;
the kernel:&lt;br /&gt;
&lt;br /&gt;
# Copy the default configuration file to &amp;lt;code&amp;gt;.config&amp;lt;/code&amp;gt; in the kernel source tree. This only needs to be done the first time that you start a new build from a blank configuration. &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ cp linux-2.6.25-ep93xx/arch/arm/configs/som9307_defconfig linux-2.6.25-ep93xx/.config&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
# Run the kernel build script with the config option to bring up the kernel&lt;br /&gt;
“menuconfig”. The first argument to the script is the kernel source tree. The&lt;br /&gt;
second option is one of &amp;lt;code&amp;gt;config&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;build&amp;lt;/code&amp;gt;. The final option is a build-suffix;&lt;br /&gt;
this is used as a tag for the directory that the kernel will be built in. You&lt;br /&gt;
may use any string that you like, such as a date tag (&amp;lt;code&amp;gt;20090101&amp;lt;/code&amp;gt;) or machine&lt;br /&gt;
name (&amp;lt;code&amp;gt;som9307&amp;lt;/code&amp;gt;). Using &amp;lt;code&amp;gt;som9307&amp;lt;/code&amp;gt; as the build-suffix will cause the kernel to be&lt;br /&gt;
built in a directory named &amp;lt;code&amp;gt;build-2.6.25-som9307&amp;lt;/code&amp;gt;. &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ ./kernel-build-cross.sh linux-2.6.25-ep93xx config som9307&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
# This will bring up the kernel menu-driven configuration utility. Make any configuration changes desired, selecting features as a built-in or as modules (when available). The space bar is used to select an option, the 'm' key can be used to configure the selected option as a module. After you are finished, select &amp;lt;code&amp;gt;Exit&amp;lt;/code&amp;gt;. The new configuration will be saved as &amp;lt;code&amp;gt;.config&amp;lt;/code&amp;gt; under the newly created build directory. When you use the same build-suffix with the kernel build script in the future, this configuration will be used. Note that the build script removes the &amp;lt;code&amp;gt;.config&amp;lt;/code&amp;gt; file from the kernel source tree and saves it to a file called &amp;lt;code&amp;gt;prevconfig&amp;lt;/code&amp;gt; in the kernel source tree.&lt;br /&gt;
&lt;br /&gt;
==Building the Kernel==&lt;br /&gt;
&lt;br /&gt;
Once the kernel is configured, a new image can be built. Use the following steps to build a new kernel image:&lt;br /&gt;
&lt;br /&gt;
# Run the kernel build script with the build option, using the same build-suffix used in the configuration step. &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ ./kernel-build-cross.sh linux-2.6.25-ep93xx build som9307&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
# The kernel should begin compiling now. This will take several minutes to complete depending on your configuration and the speed of the development machine that you are using. Only move on to the next step if the build completes with no errors.&lt;br /&gt;
# The new kernel image is located in the build directory, the exact location depending on your architecture and image type. For the SoM-9307, the image is under &amp;lt;code&amp;gt;build-2.6.25-som9307/arch/arm/boot/zImage&amp;lt;/code&amp;gt;. This is the image that will get loaded onto the board and executed by the bootloader. Another important file created by the build script is an archive of all of the modules that were created during the build process. This file is stored under the build directory. From the build steps above, the archive would be &amp;lt;code&amp;gt;build-2.6.25-som9307/kernel-2.6.25.tar.gz&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{{mbox | type = notice | text = Note that if you recompile the kernel but do not change the configuration or source code for any of the modules, it may not be necessary to reload the modules archive. This is often the case for custom driver development.}}&lt;br /&gt;
&lt;br /&gt;
==Loading==&lt;br /&gt;
&lt;br /&gt;
===Kernel Image===&lt;br /&gt;
&lt;br /&gt;
This step is highly architecture dependent. On most x86 boards and some other systems, the kernel image is stored and loaded from the root flash. If this is the case, the only step required is to load the kernel archive (i.e. &amp;lt;code&amp;gt;kernel-2.6.25.tar.gz&amp;lt;/code&amp;gt;) onto the system and extract it. Many ARM systems typically store the kernel in a binary partition on the flash storage device separate from the root filesystem. In this case, the kernel image file must be loaded onto the system and written to the flash. The basic process for loading and testing the new kernel is as follows:&lt;br /&gt;
&lt;br /&gt;
# Load the kernel modules archive onto the board. The example below assumes that the IP address of the board is &amp;lt;code&amp;gt;10.0.2.41&amp;lt;/code&amp;gt;. &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ scp build-2.6.25-som9307/kernel-2.6.25.tar.gz root@10.0.2.41:/tmp &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
# Extract the kernel modules archive to &amp;lt;code&amp;gt;/&amp;lt;/code&amp;gt; on the board. Make sure that the root flash is mounted read/write and run the following on the board after logging in as root:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@emac-oe:~# cd /&lt;br /&gt;
root@emac-oe:~# tar xzvf /tmp/kernel-2.6.25.tar.gz /lib/modules&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category::Custom Development]]&lt;/div&gt;</summary>
		<author><name>Mcoleman</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.emacinc.com/index.php?title=Building_the_Linux_Kernel&amp;diff=491</id>
		<title>Building the Linux Kernel</title>
		<link rel="alternate" type="text/html" href="https://wiki.emacinc.com/index.php?title=Building_the_Linux_Kernel&amp;diff=491"/>
		<updated>2013-05-24T19:18:16Z</updated>

		<summary type="html">&lt;p&gt;Mcoleman: content init&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page covers the process of configuring and compiling the Linux kernel for a particular board using the standard EMAC kernel build script. This process assumes that you have already acquired the following software: &lt;br /&gt;
&lt;br /&gt;
# Software Development Kit for target hardware&lt;br /&gt;
# Linux kernel source for target hardware (generally provided via EMAC public SVN server)&lt;br /&gt;
# Kernel build script for target hardware&lt;br /&gt;
&lt;br /&gt;
If you do not know where to access the items above for your board, contact EMAC for more information.&lt;br /&gt;
&lt;br /&gt;
The example below will assume that a kernel image for the [[SoM-9307]] module will be created, but the instructions apply to other hardware as well assuming that the correct SDK, kernel tree, and build script is used.&lt;br /&gt;
&lt;br /&gt;
==Setup==&lt;br /&gt;
&lt;br /&gt;
The current kernel tree for the [[SoM]]-9307 is &amp;lt;/code&amp;gt;linux-2.6.25-ep93xx&amp;lt;/code&amp;gt;. The&lt;br /&gt;
current SDK is the EMAC OE arm SDK, which should be configured for the&lt;br /&gt;
SoM-9307. The steps below assume that the &amp;lt;code&amp;gt;kernel-build-cross.sh&amp;lt;/code&amp;gt; script is&lt;br /&gt;
located in the same directory as the kernel tree. Be sure to modify the script&lt;br /&gt;
so that the CROSS variable references the location of the SDK on your system.&lt;br /&gt;
Also note that you may have difficulties using this script with the dash shell&lt;br /&gt;
(default on Ubuntu Linux variants and some other distributions). If this is the&lt;br /&gt;
case, change the top line of the kernel build script to reference &amp;lt;code&amp;gt;/bin/bash&amp;lt;/code&amp;gt;&lt;br /&gt;
rather than &amp;lt;code&amp;gt;/bin/sh&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==Configuring the Kernel==&lt;br /&gt;
&lt;br /&gt;
The first step for building the kernel is to [[configure it]] as desired. EMAC&lt;br /&gt;
provides default configuration files for each board as a part of the kernel&lt;br /&gt;
tree. For the SoM-9307, this file is&lt;br /&gt;
&amp;lt;code&amp;gt;linux-2.6.25-ep93xx/arch/arm/configs/som9307_defconfig&amp;lt;/code&amp;gt;. When configuring the&lt;br /&gt;
kernel it is important to remember that many configuration options are&lt;br /&gt;
necessary to have a working kernel image. Use the following steps to configure&lt;br /&gt;
the kernel:&lt;br /&gt;
&lt;br /&gt;
# Copy the default configuration file to &amp;lt;code&amp;gt;.config&amp;lt;/code&amp;gt; in the kernel source tree. This only needs to be done the first time that you start a new build from a blank configuration. &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ cp linux-2.6.25-ep93xx/arch/arm/configs/som9307_defconfig linux-2.6.25-ep93xx/.config&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
# Run the kernel build script with the config option to bring up the kernel&lt;br /&gt;
“menuconfig”. The first argument to the script is the kernel source tree. The&lt;br /&gt;
second option is one of &amp;lt;code&amp;gt;config&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;build&amp;lt;/code&amp;gt;. The final option is a build-suffix;&lt;br /&gt;
this is used as a tag for the directory that the kernel will be built in. You&lt;br /&gt;
may use any string that you like, such as a date tag (&amp;lt;code&amp;gt;20090101&amp;lt;/code&amp;gt;) or machine&lt;br /&gt;
name (&amp;lt;code&amp;gt;som9307&amp;lt;/code&amp;gt;). Using &amp;lt;code&amp;gt;som9307&amp;lt;/code&amp;gt; as the build-suffix will cause the kernel to be&lt;br /&gt;
built in a directory named &amp;lt;code&amp;gt;build-2.6.25-som9307&amp;lt;/code&amp;gt;. &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ ./kernel-build-cross.sh linux-2.6.25-ep93xx config som9307&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
# This will bring up the kernel menu-driven configuration utility. Make any configuration changes desired, selecting features as a built-in or as modules (when available). The space bar is used to select an option, the 'm' key can be used to configure the selected option as a module. After you are finished, select &amp;lt;code&amp;gt;Exit&amp;lt;/code&amp;gt;. The new configuration will be saved as &amp;lt;code&amp;gt;.config&amp;lt;/code&amp;gt; under the newly created build directory. When you use the same build-suffix with the kernel build script in the future, this configuration will be used. Note that the build script removes the &amp;lt;code&amp;gt;.config&amp;lt;/code&amp;gt; file from the kernel source tree and saves it to a file called &amp;lt;code&amp;gt;prevconfig&amp;lt;/code&amp;gt; in the kernel source tree.&lt;br /&gt;
&lt;br /&gt;
==Building the Kernel==&lt;br /&gt;
&lt;br /&gt;
Once the kernel is configured, a new image can be built. Use the following steps to build a new kernel image:&lt;br /&gt;
&lt;br /&gt;
# Run the kernel build script with the build option, using the same build-suffix used in the configuration step. &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ ./kernel-build-cross.sh linux-2.6.25-ep93xx build som9307&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
# The kernel should begin compiling now. This will take several minutes to complete depending on your configuration and the speed of the development machine that you are using. Only move on to the next step if the build completes with no errors.&lt;br /&gt;
# The new kernel image is located in the build directory, the exact location depending on your architecture and image type. For the SoM-9307, the image is under &amp;lt;code&amp;gt;build-2.6.25-som9307/arch/arm/boot/zImage&amp;lt;/code&amp;gt;. This is the image that will get loaded onto the board and executed by the bootloader. Another important file created by the build script is an archive of all of the modules that were created during the build process. This file is stored under the build directory. From the build steps above, the archive would be &amp;lt;code&amp;gt;build-2.6.25-som9307/kernel-2.6.25.tar.gz&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{{mbox | type = notice | text = Note that if you recompile the kernel but do not change the configuration or source code for any of the modules, it may not be necessary to reload the modules archive. This is often the case for custom driver development.}}&lt;br /&gt;
&lt;br /&gt;
==Loading==&lt;br /&gt;
&lt;br /&gt;
===Kernel Image===&lt;br /&gt;
&lt;br /&gt;
This step is highly architecture dependent. On most x86 boards and some other systems, the kernel image is stored and loaded from the root flash. If this is the case, the only step required is to load the kernel archive (i.e. &amp;lt;code&amp;gt;kernel-2.6.25.tar.gz&amp;lt;/code&amp;gt;) onto the system and extract it. Many ARM systems typically store the kernel in a binary partition on the flash storage device separate from the root filesystem. In this case, the kernel image file must be loaded onto the system and written to the flash. The basic process for loading and testing the new kernel is as follows:&lt;br /&gt;
&lt;br /&gt;
# Load the kernel modules archive onto the board. The example below assumes that the IP address of the board is &amp;lt;code&amp;gt;10.0.2.41&amp;lt;/code&amp;gt;. &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ scp build-2.6.25-som9307/kernel-2.6.25.tar.gz root@10.0.2.41:/tmp &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
# Extract the kernel modules archive to &amp;lt;code&amp;gt;/&amp;lt;/code&amp;gt; on the board. Make sure that the root flash is mounted read/write and run the following on the board after logging in as root:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@emac-oe:~# cd /&lt;br /&gt;
root@emac-oe:~# tar xzvf /tmp/kernel-2.6.25.tar.gz /lib/modules&lt;br /&gt;
&lt;br /&gt;
[[Category::Custom Development]]&lt;/div&gt;</summary>
		<author><name>Mcoleman</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.emacinc.com/index.php?title=Building_Existing_Software_Packages_with_EMAC_OE_SDK&amp;diff=472</id>
		<title>Building Existing Software Packages with EMAC OE SDK</title>
		<link rel="alternate" type="text/html" href="https://wiki.emacinc.com/index.php?title=Building_Existing_Software_Packages_with_EMAC_OE_SDK&amp;diff=472"/>
		<updated>2013-05-17T20:16:58Z</updated>

		<summary type="html">&lt;p&gt;Mcoleman: adding conventions table&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{EMAC OE SDK Conventions}}&lt;br /&gt;
&lt;br /&gt;
It is very common to need to be able to build existing software projects for the target hardware rather than developing the software from scratch. This feature is especially important in an open source environment, where countless libraries and utilities are available for use and often times need to be compiled to match the target architecture. Fortunately, EMAC OE SDK toolchains are standard GCC packages designed and configured to make this process as easy as possible. In addition, most software projects are developed to allow for cross-platform development.&lt;br /&gt;
&lt;br /&gt;
This guide provides an overview of the most common tasks associated with compiling existing software projects using the SDK. Note, however, that build methods differ significantly depending on the project design. Refer to the project documentation or support for information on how to cross-compile the software; the EMAC OE SDK can be treated as a standard GCC toolchain in this respect. Table 1 below denotes some conventions used in this guide.&lt;br /&gt;
&lt;br /&gt;
==Makefile-based Projects==&lt;br /&gt;
&lt;br /&gt;
Some projects have a build system based on a set of makefiles that are responsible for compiling and packaging the software. In general, configuring these projects to compile using the EMAC OE SDK is a simple process. In some instances, the software designers may have included a variable in the makefile which allows a cross-compiler prefix setting. In other cases, the CC and other makefile variables can be modified to direct make to compile using the EMAC OE SDK.&lt;br /&gt;
&lt;br /&gt;
It may be advantageous to add the cross-compiler bin directory to the system PATH variable temporarily before compiling to simplify Makefile modifications. This can be done with a command such as the following:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ export PATH=$PATH:/path/to/sdk/EMAC-OE-arm-linux-gnueabi-SDK_XX.YY/gcc-4.2.4-arm-linux-gnueabi/bin&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{mbox | type = notice | text = Note that running the command above will only affect the current terminal session.}}&lt;br /&gt;
&lt;br /&gt;
===MTD Utilities Project Example===&lt;br /&gt;
&lt;br /&gt;
The MTD Utilities project &amp;lt;code&amp;gt;mtd-utils&amp;lt;/code&amp;gt; is a good example of a Makefile-based build system that can easily be built using the EMAC OE SDK. Follow the steps below to accomplish this task.&lt;br /&gt;
&lt;br /&gt;
{{mbox | type = notice | text = The instructions in this section are valid as of the master git branch on 4/09/11. Future source changes may impact the required steps for compilation.}}&lt;br /&gt;
&lt;br /&gt;
# Begin by downloading the mtd-utils source code. Assuming that git is installed on the development system, run the following command to get the most recent version. Note that this version will be different from the stable release installed on EMAC OE systems by default.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ git clone git://git.infradead.org/mtd-utils.git &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
# After downloading the source, navigate to the source directory &amp;lt;code&amp;gt;mtd-utils&amp;lt;/code&amp;gt; and open &amp;lt;code&amp;gt;Makefile&amp;lt;/code&amp;gt; in the top-level directory. This file defines various make targets and compilation flags used to compile the source. Notice that the file &amp;lt;code&amp;gt;common.mk&amp;lt;/code&amp;gt; is sourced with the line include &amp;lt;code&amp;gt;common.mk&amp;lt;/code&amp;gt;. This is similar to the &amp;lt;code&amp;gt;global.properties&amp;lt;/code&amp;gt; file in the EMAC OE SDK.&lt;br /&gt;
# Close the &amp;lt;code&amp;gt;Makefile&amp;lt;/code&amp;gt; editor and open the &amp;lt;code&amp;gt;common.mk&amp;lt;/code&amp;gt; file. At the top of the file, &amp;lt;code&amp;gt;CC&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;AR&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;RANLIB&amp;lt;/code&amp;gt; are defined using the &amp;lt;code&amp;gt;CROSS&amp;lt;/code&amp;gt; variable, which is not set in either &amp;lt;code&amp;gt;common.mk&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;Makefile&amp;lt;/code&amp;gt;. An exert is shown below:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;make&amp;quot;&amp;gt;&lt;br /&gt;
CC := $(CROSS)gcc&lt;br /&gt;
AR := $(CROSS)ar&lt;br /&gt;
RANLIB := $(CROSS)ranlib&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
If the &amp;lt;code&amp;gt;CROSS&amp;lt;/code&amp;gt; variable is defined when &amp;lt;code&amp;gt;make&amp;lt;/code&amp;gt; is run, the specific toolchain to use can be specified. Also note that &amp;lt;code&amp;gt;CFLAGS&amp;lt;/code&amp;gt; is defined using a &amp;lt;code&amp;gt;?=&amp;lt;/code&amp;gt; assignment, which means that the assignment will only be made if &amp;lt;code&amp;gt;CFLAGS&amp;lt;/code&amp;gt; is undefined:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;make&amp;quot;&amp;gt;&lt;br /&gt;
CFLAGS ?= -O2 -g&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
# Close &amp;lt;code&amp;gt;common.mk&amp;lt;/code&amp;gt; without making any changes.&lt;br /&gt;
# In order to compile the source correctly, the &amp;lt;code&amp;gt;CROSS&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;CFLAGS&amp;lt;/code&amp;gt; variables should be defined. The tuning flags for the target architecture to be added to the &amp;lt;code&amp;gt;CFLAGS&amp;lt;/code&amp;gt; variable should be used from the &amp;lt;code&amp;gt;ARCHFLAGS&amp;lt;/code&amp;gt; variable in the &amp;lt;code&amp;gt;global.properties&amp;lt;/code&amp;gt; file of the EMAC OE SDK. The following steps utilize tuning flags for an armv5te processor-based system. Although the path to the SDK toolchain could be included directly in the &amp;lt;code&amp;gt;CROSS&amp;lt;/code&amp;gt; variable in this instance, this example works by adding the SDK toolchain to the system &amp;lt;code&amp;gt;PATH&amp;lt;/code&amp;gt; variable. The path and prefix used will differ depending on the target architecture of the EMAC OE SDK; refer to &amp;lt;code&amp;gt;global.properties&amp;lt;/code&amp;gt; in the SDK to determine the correct settings. The &amp;lt;code&amp;gt;DESTDIR&amp;lt;/code&amp;gt; variable controls where the files are put when running the &amp;lt;code&amp;gt;install&amp;lt;/code&amp;gt; make target. The &amp;lt;code&amp;gt;WITHOUT_XATTR&amp;lt;/code&amp;gt; flag must be set to disable features of the software that are not available on EMAC OE.&lt;br /&gt;
## Before compiling, several source changes are required to match the setup of the SDK. These include changing references from &amp;lt;code&amp;gt;lzo2&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;lzo&amp;lt;/code&amp;gt;, and changing the lzo include prefix. Run the following commands from the mtd-utils directory to make these changes:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ for file in `find . -name Makefile`; do sed -i 's:lzo2:lzo:g' $file; done&lt;br /&gt;
developer@ldc:~$ for file in `find . -name '*.c'`; do sed -i 's:lzo/::g' $file; done&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
## Run the following commands to set the variables:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ export PATH=$PATH:/path/to/sdk/EMAC-OE-arm-linux-gnueabi-SDK_XX.YY/gcc-4.2.4-arm-linux-gnueabi/bin&lt;br /&gt;
developer@ldc:~$ export CROSS=arm-linux-gnueabi-&lt;br /&gt;
developer@ldc:~$ export CFLAGS=&amp;quot;-O2 -g -march=armv5te -mtune=arm926ej-s&amp;quot;&lt;br /&gt;
developer@ldc:~$ export DESTDIR=Install&lt;br /&gt;
developer@ldc:~$ export WITHOUT_XATTR=1&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
# Once the environment has been set up, &amp;lt;code&amp;gt;make&amp;lt;/code&amp;gt; can be used to compile the source code:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ make all&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
# After successfully compiling the project, the &amp;lt;code&amp;gt;install&amp;lt;/code&amp;gt; make target can be used to package all of the software into the &amp;lt;code&amp;gt;Install&amp;lt;/code&amp;gt; directory as specified by the &amp;lt;code&amp;gt;DESTDIR&amp;lt;/code&amp;gt; variable:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ make install&lt;br /&gt;
developer@ldc:~$ ls -R Install&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
Install:&lt;br /&gt;
usr&lt;br /&gt;
 &lt;br /&gt;
Install/usr:&lt;br /&gt;
sbin  share&lt;br /&gt;
 &lt;br /&gt;
Install/usr/sbin:&lt;br /&gt;
docfdisk      flash_erase     flash_lock      flash_unlock  jffs2dump   nanddump   nftldump     rfddump      sumtool&lt;br /&gt;
doc_loadbios  flash_eraseall  flash_otp_dump  ftl_check     mkfs.jffs2  nandtest   nftl_format  rfdformat&lt;br /&gt;
flashcp       flash_info      flash_otp_info  ftl_format    mtd_debug   nandwrite  recv_image   serve_image&lt;br /&gt;
 &lt;br /&gt;
Install/usr/share:&lt;br /&gt;
man&lt;br /&gt;
 &lt;br /&gt;
Install/usr/share/man:&lt;br /&gt;
man1&lt;br /&gt;
 &lt;br /&gt;
Install/usr/share/man/man1:&lt;br /&gt;
mkfs.jffs2.1.gz&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
While the procedure in this example is specific to &amp;lt;code&amp;gt;mtd-utils&amp;lt;/code&amp;gt;, many makefile-based projects will require similar steps for cross-compiling.&lt;br /&gt;
&lt;br /&gt;
==Autotools-based Projects==&lt;br /&gt;
&lt;br /&gt;
The GNU build system is known as Autotools. Autotools is a group of applications that are designed to provide a configurable build system to allow compilation on different platforms and environments. A &amp;lt;code&amp;gt;configure&amp;lt;/code&amp;gt; script and set of input files are used to generate makefiles based on options passed to the configure script and deduced from the system environment. This includes tests for compiler options, library functions, install configuration, and other assorted variables.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;configure&amp;lt;/code&amp;gt; script is the most important step in building an autotools-based project. Although available options for &amp;lt;code&amp;gt;configure&amp;lt;/code&amp;gt; vary depending on the project design, there are common options shared between most autotools projects. &lt;br /&gt;
&lt;br /&gt;
===libConfuse Example Project===&lt;br /&gt;
&lt;br /&gt;
The libConfuse project is a simple C library written for parsing configuration files. It uses an autotools build system for configuration. The steps below demonstrate how to build libConfuse and should be used as an example for building other autotools-based projects. &lt;br /&gt;
&lt;br /&gt;
# The source code for the libConfuse project can be downloaded as described on the project website [http://www.nongnu.org/confuse/]. For this example, release 2.7 is used: [http://savannah.nongnu.org/download/confuse/confuse-2.7.tar.gz]. After downloading the source, extract the archive and navigate to the top-level directory of the project (i.e. `confuse-2.7`).&lt;br /&gt;
# Read through the &amp;lt;code&amp;gt;README&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;INSTALL&amp;lt;/code&amp;gt; files for information on the project and general information on how to build it. Also, look at the help output from &amp;lt;code&amp;gt;configure&amp;lt;/code&amp;gt; to see a summary of the available options:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ ./configure --help&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
# Before beginning, the system &amp;lt;code&amp;gt;PATH&amp;lt;/code&amp;gt; variable should be changed to include the SDK toolchain as in the makefile-based project example. The &amp;lt;code&amp;gt;CFLAGS&amp;lt;/code&amp;gt; variable should also be set. If the &amp;lt;code&amp;gt;CC&amp;lt;/code&amp;gt; variable is set, it should be set to &amp;lt;code&amp;gt;arm-linux-gnueabi-gcc&amp;lt;/code&amp;gt; (or the appropriate value for the target); if not set the compiler name will be detected from the options passed to configure. The &amp;lt;code&amp;gt;CFLAGS&amp;lt;/code&amp;gt; architecture tuning values should be set according to the &amp;lt;code&amp;gt;global.properties&amp;lt;/code&amp;gt; file in the EMAC OE SDK. The &amp;lt;code&amp;gt;DESTDIR&amp;lt;/code&amp;gt; variable determines where the files will be installed to when the &amp;lt;code&amp;gt;install&amp;lt;/code&amp;gt; make target is run. &amp;lt;code&amp;gt;DESTDIR&amp;lt;/code&amp;gt; must be an absolute path for the libConfuse project, so the current working directory is added to the variable using the &amp;lt;code&amp;gt;pwd&amp;lt;/code&amp;gt; command. The following commands are an example of how to set up the environment correctly:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ export CFLAGS=&amp;quot;-O2 -march=armv5te -mtune=arm926ej-s&amp;quot;&lt;br /&gt;
developer@ldc:~$ export DESTDIR=`pwd`/Install&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
# After setting the environment, &amp;lt;code&amp;gt;configure&amp;lt;/code&amp;gt; can be run with the appropriate options to configure the build system and generate the makefiles. The code below shows an example configuration used by EMAC OE. Be sure to set the host and target correctly based on the architecture:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ ./configure --build=i686-linux --host=arm-linux-gnueabi --target=arm-linux-gnueabi \&lt;br /&gt;
        --prefix=/usr --exec_prefix=/usr --bindir=/usr/bin --sbindir=/usr/sbin \&lt;br /&gt;
        --datadir=/usr/share  \&lt;br /&gt;
        --infodir=/usr/share/info \&lt;br /&gt;
        --mandir=/usr/share/man --enable-shared&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The configuration should complete successfully. If any problems are reported that result in an error, check the environment settings and &amp;lt;code&amp;gt;configure&amp;lt;/code&amp;gt; options again. &lt;br /&gt;
# Now that &amp;lt;code&amp;gt;configure&amp;lt;/code&amp;gt; has generated all of the makefiles for the project, &amp;lt;code&amp;gt;make&amp;lt;/code&amp;gt; can be used to compile the source code:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ make all&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
If any errors are encountered during compilation, examine the output of &amp;lt;code&amp;gt;configure&amp;lt;/code&amp;gt; and make sure that all of the environment variables and &amp;lt;code&amp;gt;configure&amp;lt;/code&amp;gt; options were specified correctly. &lt;br /&gt;
# Once compilation is complete, the &amp;lt;code&amp;gt;install&amp;lt;/code&amp;gt; target can be used to package all of the necessary files together so that they can be transferred to the target board.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ make install&lt;br /&gt;
developer@ldc:~$ ls -R Install&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
Install:&lt;br /&gt;
usr&lt;br /&gt;
 &lt;br /&gt;
Install/usr:&lt;br /&gt;
include  lib  share&lt;br /&gt;
 &lt;br /&gt;
Install/usr/include:&lt;br /&gt;
confuse.h&lt;br /&gt;
 &lt;br /&gt;
Install/usr/lib:&lt;br /&gt;
libconfuse.a  libconfuse.la  libconfuse.so  libconfuse.so.0  libconfuse.so.0.0.0  pkgconfig&lt;br /&gt;
 &lt;br /&gt;
Install/usr/lib/pkgconfig:&lt;br /&gt;
libconfuse.pc&lt;br /&gt;
 &lt;br /&gt;
Install/usr/share:&lt;br /&gt;
locale&lt;br /&gt;
 &lt;br /&gt;
Install/usr/share/locale:&lt;br /&gt;
fr  sv&lt;br /&gt;
 &lt;br /&gt;
Install/usr/share/locale/fr:&lt;br /&gt;
LC_MESSAGES&lt;br /&gt;
 &lt;br /&gt;
Install/usr/share/locale/fr/LC_MESSAGES:&lt;br /&gt;
confuse.mo&lt;br /&gt;
 &lt;br /&gt;
Install/usr/share/locale/sv:&lt;br /&gt;
LC_MESSAGES&lt;br /&gt;
 &lt;br /&gt;
Install/usr/share/locale/sv/LC_MESSAGES:&lt;br /&gt;
confuse.mo&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Note that not all of the files installed would be necessary to install on the board, such as the man pages and pkgconfig information.&lt;br /&gt;
&lt;br /&gt;
[[Category:EMAC OE SDK]]&lt;/div&gt;</summary>
		<author><name>Mcoleman</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.emacinc.com/index.php?title=Creating_a_New_EMAC_OE_SDK_Project&amp;diff=471</id>
		<title>Creating a New EMAC OE SDK Project</title>
		<link rel="alternate" type="text/html" href="https://wiki.emacinc.com/index.php?title=Creating_a_New_EMAC_OE_SDK_Project&amp;diff=471"/>
		<updated>2013-05-17T20:15:56Z</updated>

		<summary type="html">&lt;p&gt;Mcoleman: adding conventions table&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{EMAC OE SDK Conventions}}&lt;br /&gt;
&lt;br /&gt;
The EMAC OE SDK is a complete development kit for creating C/C++ applications for EMAC products. The SDK can be used to compile code anywhere in the development system. This procedure explains the process of creating and building a new project within the SDK.&lt;br /&gt;
&lt;br /&gt;
==New Project Procedure==&lt;br /&gt;
&lt;br /&gt;
This guide assumes that the EMAC OE SDK has been [[installed]] and [[configured]]. It also assumes a basic familiarity with the C programming language and that a basic text editor is available. The example code calculates the perimeter of a right triangle given the length of its longest edge and the angle between that edge and one of the other edges.&lt;br /&gt;
&lt;br /&gt;
===Set Up the Project===&lt;br /&gt;
&lt;br /&gt;
The first step in creating an EMAC OE project is creating a project directory in &amp;lt;code&amp;gt;/path/to/sdk/EMAC-OE-arm-linux-gnueabi-SDK_XX.YY/projects&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ mkdir /path/to/sdk/EMAC-OE-arm-linux-gnueabi-SDK_XX.YY/projects/example&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Creating the project in this directory is necessary in order for the &amp;lt;code&amp;gt;global.properties&amp;lt;/code&amp;gt; include and the path variables in global.properties to be correct. If it is created in any other directory, then the make targets will fail without modifications on the Makefile that go beyond the scope of this guide.&lt;br /&gt;
&lt;br /&gt;
===Write the C Code===&lt;br /&gt;
&lt;br /&gt;
This guide uses the C code from Listing 1 as an example. It is simple enough that the basic familiarity with C expected of those viewing this guide precludes the need for explanation. As a general step in application development using the EMAC OE SDK, the C files in this step should be saved in the project's top-level directory. In this case, &amp;lt;code&amp;gt;example.c&amp;lt;/code&amp;gt; should be saved as &amp;lt;code&amp;gt;/path/to/sdk/EMAC-OE-arm-linux-gnueabi-SDK_XX.YY/projects/example/example.c&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;lt;string.h&amp;gt;&lt;br /&gt;
#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
#include &amp;lt;stdlib.h&amp;gt;&lt;br /&gt;
#include &amp;lt;math.h&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
#define HYP 10.0&lt;br /&gt;
#define DEG 30.0&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
int main(void)&lt;br /&gt;
{&lt;br /&gt;
	float opp, adj;&lt;br /&gt;
 &lt;br /&gt;
	opp = HYP * sin(DEG);&lt;br /&gt;
	adj = HYP * cos(DEG);&lt;br /&gt;
 &lt;br /&gt;
	printf(&amp;quot;Hypotenuse: \t%3.2f\n&amp;quot;, HYP);&lt;br /&gt;
	printf(&amp;quot;Angle: \t\t%3.2f\n&amp;quot;, DEG);&lt;br /&gt;
	printf(&amp;quot;Opposite Side: \t%3.2f\n&amp;quot;, opp);&lt;br /&gt;
	printf(&amp;quot;Adjacent Side: \t%3.2f\n&amp;quot;, adj);&lt;br /&gt;
	printf(&amp;quot;%3.2f + %3.2f + %3.2f = %3.2f \n&amp;quot;, HYP, opp, adj, (HYP + opp + adj));&lt;br /&gt;
 &lt;br /&gt;
	exit(EXIT_SUCCESS);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Modify the Makefile===&lt;br /&gt;
&lt;br /&gt;
====Create the New Makefile====&lt;br /&gt;
&lt;br /&gt;
Now that the C file has been written, it is time to copy a suitable Makefile from one of the example projects. The following command will accomplish this: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ cd /path/to/sdk/EMAC-OE-arm-linux-gnueabi-SDK_XX.YY/projects/example/&lt;br /&gt;
developer@ldc:~$ cp ../hello/Makefile ./&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Tell the Makefile What Files to Compile====&lt;br /&gt;
&lt;br /&gt;
The project is almost ready to be compiled. However, there are a few lines in the Makefile which must be modified before this can happen. First, the &amp;lt;code&amp;gt;CFILES&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;TARGET&amp;lt;/code&amp;gt; variables in the Makefile must be modified to suit this project: &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;CFILES=example.c&amp;lt;/code&amp;gt; instead of &amp;lt;code&amp;gt;CFILES=hello.c&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;TARGET=example&amp;lt;/code&amp;gt; instead of &amp;lt;code&amp;gt;TARGET=hello&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This tells the Makefile that the source file used is &amp;lt;code&amp;gt;example.c&amp;lt;/code&amp;gt;. This variable can be assigned a space-delimited list of C files. In the example there is only one file so this is not a concern. &lt;br /&gt;
&lt;br /&gt;
====Tell the Makefile What Libraries to Link====&lt;br /&gt;
&lt;br /&gt;
The last change that must be made to this Makefile is that we need to modify &amp;lt;code&amp;gt;LIBFLAGS&amp;lt;/code&amp;gt; to reflect the use of the math library for the trigonometric functions in the C file. The math library is &amp;lt;code&amp;gt;libm.so&amp;lt;/code&amp;gt;; therefore, we use &amp;lt;code&amp;gt;-lm&amp;lt;/code&amp;gt; to indicate to the linker to link &amp;lt;code&amp;gt;libm&amp;lt;/code&amp;gt; to the binary. If the library for readline were needed, instead, this would be specified with &amp;lt;code&amp;gt;-lreadline&amp;lt;/code&amp;gt; to link &amp;lt;code&amp;gt;libreadline.so&amp;lt;/code&amp;gt; Add the following line to the Makefile: &lt;br /&gt;
* &amp;lt;code&amp;gt;LIBFLAGS+=-lm&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Where in the Makefile this line is added does not matter, though it makes sense to group it with the other variable declarations. &lt;br /&gt;
&lt;br /&gt;
{{mbox | type = notice | text = Much more detailed information on working with libraries and the linker under Linux can be found at [http://www.yolinux.com/TUTORIALS/LibraryArchives-StaticAndDynamic.html YoLinux - Static, Shared Dynamic and Loadable Linux Libraries]}}&lt;br /&gt;
&lt;br /&gt;
Listing 2 shows the complete modified makefile for the &amp;lt;code&amp;gt;example.c&amp;lt;/code&amp;gt; project.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;Make&amp;quot;&amp;gt;&lt;br /&gt;
include ../global.properties&lt;br /&gt;
 &lt;br /&gt;
TARGET=example&lt;br /&gt;
CFILES=example.c&lt;br /&gt;
 &lt;br /&gt;
LIBFLAGS+=-lm&lt;br /&gt;
 &lt;br /&gt;
OBJS=$(CFILES:.c=.o)&lt;br /&gt;
DEPS=$(OBJS:.o=.d)&lt;br /&gt;
 &lt;br /&gt;
all: $(TARGET)&lt;br /&gt;
 &lt;br /&gt;
$(TARGET): $(OBJS) Makefile&lt;br /&gt;
  $(CC) $(VERBOSE) $(OBJS) $(OFLAGS) $(LIBFLAGS) $(SLIBS) -o $@&lt;br /&gt;
 &lt;br /&gt;
%.o: %.c&lt;br /&gt;
  $(CC) $(VERBOSE) $(CFLAGS) -o $@ -c $&amp;lt;&lt;br /&gt;
 &lt;br /&gt;
clean:&lt;br /&gt;
  $(RM) *.o *.gdb $(TARGET) $(DEPS)&lt;br /&gt;
 &lt;br /&gt;
upload: all&lt;br /&gt;
  $(WPUT) $(TARGET) ftp://$(LOGIN):$(PASSWORD)@$(TARGET_IP)/../../tmp/$(TARGET)&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
-include $(DEPS)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
'''Listing 2. Modified Example Makefile'''&lt;br /&gt;
&lt;br /&gt;
====Telling ''make'' About Make Targets====&lt;br /&gt;
&lt;br /&gt;
In &amp;lt;code&amp;gt;global.properties&amp;lt;/code&amp;gt; there are also variables which must be modified in order for all the &amp;lt;code&amp;gt;make&amp;lt;/code&amp;gt; targets to accomplish their purpose. For instructions on how to do this, please refer to the [[Remote Upload Set Up Guide]].&lt;br /&gt;
&lt;br /&gt;
===Cross-Compile with the EMAC OE SDK===&lt;br /&gt;
&lt;br /&gt;
Now it is time to use GNU make to compile the example source code into an application that can be run on the target machine. Makefile-based development with the EMAC OE SDK is a powerful tool which enables the customer to compile code for the target EMAC product on the Linux development machine. Once a project has been set up as described above, development can begin using the GNU make targets as described below. &lt;br /&gt;
&lt;br /&gt;
First, set the current directory to the one containing the Makefile, then execute the make targets as shown in Listing 3. For a description of each make target, read the bullet items below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ cd /path/to/sdk/EMAC-OE-arm-linux-gnueabi-SDK_XX.YY/projects/example/&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
#### Target 1 ####&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ make clean &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
rm -f *.o *.gdb example example.d&lt;br /&gt;
&lt;br /&gt;
#### Target 2 ####&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ make all &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
../../gcc-4.2.4-arm-linux-gnueabi/bin/arm-linux-gnueabi-gcc  -Wall -MMD -g -march=armv5te -mtune=arm926ej-s -o example.o -c example.c\&lt;br /&gt;
../../gcc-4.2.4-arm-linux-gnueabi/bin/arm-linux-gnueabi-gcc  example.o  -lm  -o example&lt;br /&gt;
&lt;br /&gt;
#### Target 3 ####&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ make upload &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
wput --reupload --dont-continue sentence ftp://root:emac_inc@10.0.2.41/../../tmp/example&lt;br /&gt;
--16:52:48-- `app_name'&lt;br /&gt;
    =&amp;gt; ftp://root:xxxxx@10.0.2.41:21/../../tmp/example&lt;br /&gt;
Connecting to 10.0.2.41:21... connected!&lt;br /&gt;
Logging in as root ... Logged in!&lt;br /&gt;
Length: 13,774&lt;br /&gt;
 &lt;br /&gt;
16:52:48 (example) - `350.6K/s' [13774]&lt;br /&gt;
 &lt;br /&gt;
FINISHED --16:52:48--&lt;br /&gt;
Transfered 13,774 bytes in 1 file at 107.3K/s&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
'''Listing 3. Example Make Target Invocation'''&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;make clean&amp;lt;/code&amp;gt; removes all object, dependency, and executable files generated by previous invocations of make. It literally “cleans” the directory as shown in Listing 1, Target 1.&lt;br /&gt;
* &amp;lt;code&amp;gt;make all&amp;lt;/code&amp;gt; resolves dependencies for the source code necessary to cross-compile the target file. The &amp;lt;code&amp;gt;gcc&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;g++&amp;lt;/code&amp;gt; binaries used are specified in &amp;lt;code&amp;gt;global.properties&amp;lt;/code&amp;gt; as relative paths to the &amp;lt;code&amp;gt;/path/to/sdk/EMAC-OE-arm-linux-gnueabi-SDK_XX.YY/projects/example/&amp;lt;/code&amp;gt; directory. This is why the source files must be kept in their own directory within &amp;lt;code&amp;gt;/path/to/sdk/EMAC-OE-arm-linux-gnueabi-SDK_XX.YY/projects&amp;lt;/code&amp;gt;. Listing 1, Target 2 demonstrates a successful &amp;lt;code&amp;gt;make all&amp;lt;/code&amp;gt; invocation.&lt;br /&gt;
* &amp;lt;code&amp;gt;make upload&amp;lt;/code&amp;gt; uses &amp;lt;code&amp;gt;wput&amp;lt;/code&amp;gt; to send example to the remote machine. This requires the remote EMAC product have network connection whose IP is available to the development machine. This IP address must be set as the value of the &amp;lt;code&amp;gt;TARGET_IP&amp;lt;/code&amp;gt; variable in &amp;lt;code&amp;gt;global.properties&amp;lt;/code&amp;gt;. Listing 1, Target 3 demonstrates a successful make upload invocation with &amp;lt;code&amp;gt;TARGET_IP&amp;lt;/code&amp;gt; set to 10.0.2.41.&lt;br /&gt;
&lt;br /&gt;
===Optional global.properties Modifications===&lt;br /&gt;
&lt;br /&gt;
In order to debug applications effectively, the &amp;lt;code&amp;gt;-g&amp;lt;/code&amp;gt; debug flag must be specified when running the compiler. This is set up to occur automatically by its inclusion in the &amp;lt;code&amp;gt;global.properties CFLAGS&amp;lt;/code&amp;gt; variable.&lt;br /&gt;
&lt;br /&gt;
For release builds, however, this can be harmful to the application's performance since keeping the debug symbols in the executable bloats its size. In a typical general-purpose computer this may not be noticeable, but for embedded systems there are typically memory and disk limitations. For production or release versions of an application EMAC recommends modifying the &amp;lt;code&amp;gt;global.properties CFLAGS&amp;lt;/code&amp;gt; variable to replace &amp;lt;code&amp;gt;-g&amp;lt;/code&amp;gt; with &amp;lt;code&amp;gt;-g0&amp;lt;/code&amp;gt; which tells the compiler not to include debug information in the executable.&lt;br /&gt;
&lt;br /&gt;
Using the &amp;lt;code&amp;gt;file&amp;lt;/code&amp;gt; command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ file myexecutable&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
myexecutable: ELF 32-bit LSB executable, ARM, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.14, not stripped&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Will tell you if debugging information is available within the executable. If you see, &amp;lt;code&amp;gt;not stripped&amp;lt;/code&amp;gt;, that means debugging symbols are in the binary. If you wish to remove them without using a release target build, you can use the &amp;lt;code&amp;gt;strip&amp;lt;/code&amp;gt; command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ strip myexecutable&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
If you see no output after running that command, you may assume the command succeeded (this is default behavior upon successful completion of an operation for most Unix and Linux tools). In order to make sure it succeeded, you can run the file command on it again: &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ file myexecutable&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
myexecutable: ELF 32-bit LSB executable, ARM, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.14, stripped&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The output above shows, stripped, which tells us the &amp;lt;code&amp;gt;strip&amp;lt;/code&amp;gt; command succeeded in removing debugging symbols from the binary.&lt;br /&gt;
&lt;br /&gt;
==Next Steps==&lt;br /&gt;
&lt;br /&gt;
Once the target binary has been compiled, the project is ready to be debugged. &lt;br /&gt;
&lt;br /&gt;
{{mbox | type = notice | text = Useful tools related to this article:&lt;br /&gt;
* &amp;lt;code&amp;gt;make&amp;lt;/code&amp;gt; - Automates builds&lt;br /&gt;
* &amp;lt;code&amp;gt;ld&amp;lt;/code&amp;gt; - The linker&lt;br /&gt;
* &amp;lt;code&amp;gt;ldd&amp;lt;/code&amp;gt; - Displays shared library dependencies for a binary executable.&lt;br /&gt;
* &amp;lt;code&amp;gt;strip&amp;lt;/code&amp;gt; - Removes debugging symbols from a binary executable.&lt;br /&gt;
* &amp;lt;code&amp;gt;gdb&amp;lt;/code&amp;gt; - The GNU Debugger. Often used indirectly through the Eclipse IDE interface.&lt;br /&gt;
* &amp;lt;code&amp;gt;file&amp;lt;/code&amp;gt; - Command which displays information about a file passed to it as an argument. Useful for determining whether debugging information has been stripped from a binary executable, among other things.&lt;br /&gt;
}} &lt;br /&gt;
&lt;br /&gt;
[[Category:EMAC OE SDK]]&lt;/div&gt;</summary>
		<author><name>Mcoleman</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.emacinc.com/index.php?title=Using_EMAC_OE_SDK_Example_Projects&amp;diff=470</id>
		<title>Using EMAC OE SDK Example Projects</title>
		<link rel="alternate" type="text/html" href="https://wiki.emacinc.com/index.php?title=Using_EMAC_OE_SDK_Example_Projects&amp;diff=470"/>
		<updated>2013-05-17T20:15:26Z</updated>

		<summary type="html">&lt;p&gt;Mcoleman: adding conventions table&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{EMAC OE SDK Conventions}}&lt;br /&gt;
&lt;br /&gt;
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 guide demonstrates the process of compiling one of the example projects and running it on the target machine. NOTE: It is assumed that the procedure in the EMAC OE SDK Configuration Guide has been followed prior to reading this page. &lt;br /&gt;
&lt;br /&gt;
This guide consists of two example files, a C file and a Makefile. They are located within Listing 2 and Listing 3, respectively. &lt;br /&gt;
&lt;br /&gt;
==Tools==&lt;br /&gt;
&lt;br /&gt;
* GNU &amp;lt;code&amp;gt;make&amp;lt;/code&amp;gt;. Manages project dependencies.&lt;br /&gt;
* EMAC OE SDK. [See the EMAC OE SDK Install Page].&lt;br /&gt;
* &amp;lt;code&amp;gt;wput&amp;lt;/code&amp;gt;, Provides FTP capability to the build process.&lt;br /&gt;
&lt;br /&gt;
==EMAC SDK Example: Compile the &amp;quot;hello&amp;quot; Project==&lt;br /&gt;
&lt;br /&gt;
This procedure provides an overview of how to compile and run C applications for EMAC products. It assumes familiarity with the C programming language and is intended to be used by experienced programmers who are looking to learn the EMAC SDK. The “hello” example project source can be found in the projects/ subdirectory of the EMAC OE SDK root directory. The full path to the source is as follows: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
/path/to/sdk/EMAC-OE-arm-linux-gnueabi-SDK_XX.YY/projects/hello/&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Cross-compile the program using GNU Make.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ cd /path/to/sdk/EMAC-OE-arm-linux-gnueabi-SDK_XX.YY/projects/hello/&lt;br /&gt;
developer@ldc:~$ make all&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;all&amp;lt;/code&amp;gt; is a make target. This command is the equivalent to the commonly seen, Build All command found in most IDE's. The build system will only compile files which have been modified since the last build.&lt;br /&gt;
&lt;br /&gt;
Alternatively, you can simply run: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ make&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When &amp;lt;code&amp;gt;make&amp;lt;/code&amp;gt; is run by itself, it chooses its default make target. In this example, &amp;lt;code&amp;gt;all&amp;lt;/code&amp;gt; is the default make target. In any normal project, the default make target will be the one which builds the project. This allows a programmer to simply run &amp;lt;code&amp;gt;make&amp;lt;/code&amp;gt; most of the time they are doing development work.&lt;br /&gt;
&lt;br /&gt;
The Makefile based build system fully supports incremental builds. Should you desire a full rebuild, two steps will need to be followed instead of one:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ make clean&lt;br /&gt;
developer@ldc:~$ make&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;make clean&amp;lt;/code&amp;gt; command will delete any object files (these have the &amp;lt;code&amp;gt;.o&amp;lt;/code&amp;gt; extension in the gcc on Linux build system), debugger information files (with the &amp;lt;code&amp;gt;.gdb&amp;lt;/code&amp;gt; extension), executable binaries (generally, no extension) and any other files which are generated during the build process. Once this cleaning step is complete, the build system will attempt to rebuild everything.&lt;br /&gt;
&lt;br /&gt;
For a more in-depth explanation on how gcc approaches the incremental build process, see the [http://www.gnu.org/software/make/manual/make.html GNU &amp;quot;make&amp;quot; Manual].&lt;br /&gt;
&lt;br /&gt;
==EMAC SDK Example: Uploading and Running the &amp;quot;hello&amp;quot; Project&amp;quot;==&lt;br /&gt;
&lt;br /&gt;
===Uploading the Program to the Target Machine===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ make upload&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;upload&amp;lt;/code&amp;gt; is another make target. This command will send your freshly compiled binary to the target machine.&lt;br /&gt;
&lt;br /&gt;
This make target uses the development system's &amp;lt;code&amp;gt;wput&amp;lt;/code&amp;gt; program to send the binary to the target machine through FTP. This is accomplished using variables stored in the &amp;lt;code&amp;gt;global.properties&amp;lt;/code&amp;gt; file, which is included in the Makefile using the &amp;lt;code&amp;gt;include&amp;lt;/code&amp;gt; keyword. The &amp;lt;code&amp;gt;global.properties&amp;lt;/code&amp;gt; file also contains variables which &amp;lt;code&amp;gt;make&amp;lt;/code&amp;gt; passes to the compiler to ensure that the executable produced is compatible with the target CPU architecture. &lt;br /&gt;
&lt;br /&gt;
===Running the Program on the Target Machine===&lt;br /&gt;
&lt;br /&gt;
Connect remotely to the target machine. Run the program as shown in Listing 1 using the remote connection.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@emac-oe:~# chmod u+x /tmp/hello&lt;br /&gt;
root@emac-oe:~# /tmp/hello&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
'''Listing 1. Running the Remote Application'''&lt;br /&gt;
&lt;br /&gt;
{{mbox | type = notice | text = &amp;lt;code&amp;gt;chmod u+x&amp;lt;/code&amp;gt; sets the root user's permissions to allow execution of the binary. Note that this assumes that you are logged in as the system root user.}}&lt;br /&gt;
&lt;br /&gt;
{{mbox | type = notice | text = &amp;lt;code&amp;gt;/tmp/hello&amp;lt;/code&amp;gt; runs the program without any arguments.}}&lt;br /&gt;
&lt;br /&gt;
{{mbox | type = notice | text = '''NOTE:''' If you wish to run a program located in your current directory, you must run it as &amp;lt;code&amp;gt;./hello&amp;lt;/code&amp;gt;. Without the &amp;lt;code&amp;gt;./&amp;lt;/code&amp;gt; prefix, the program will not be run by the shell. The shell will only look for a program in the default search &amp;lt;code&amp;gt;PATH&amp;lt;/code&amp;gt;, unless the program's name is prefixed with a specific path. The &amp;lt;code&amp;gt;./&amp;lt;/code&amp;gt; prefix is a relative path. The &amp;lt;code&amp;gt;.&amp;lt;/code&amp;gt; represents the current directory, just as &amp;lt;code&amp;gt;..&amp;lt;/code&amp;gt; represents the previous directory. The &amp;lt;code&amp;gt;/&amp;lt;/code&amp;gt; following the &amp;lt;code&amp;gt;.&amp;lt;/code&amp;gt; indicates to the shell to look inside the current directory. In POSIX systems, such as Linux, filenames can have a &amp;lt;code&amp;gt;.&amp;lt;/code&amp;gt; as their first character, which is why the &amp;lt;code&amp;gt;/&amp;lt;/code&amp;gt; is needed. &lt;br /&gt;
&lt;br /&gt;
Incidentally, a &amp;lt;code&amp;gt;.&amp;lt;/code&amp;gt; as the first character of the filename indicates that the file is hidden. Use the &amp;lt;code&amp;gt;ls -a&amp;lt;/code&amp;gt; command to see such files.}}&lt;br /&gt;
&lt;br /&gt;
If the file compiles without trouble but has runtime bugs, you can remotely debug the application using gdbserver. Read the [[EMAC OE SDK Remote Debugging Guide]] to learn more.&lt;br /&gt;
&lt;br /&gt;
===Example C File===&lt;br /&gt;
&lt;br /&gt;
This C file can be used by programmers as an example to ensure their build configuration for EMAC products is functioning correctly.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
/**&lt;br /&gt;
 * @file hello.c&lt;br /&gt;
 *&lt;br /&gt;
 * Simple Hello World application for EMAC OE.&lt;br /&gt;
 *&lt;br /&gt;
 * @author EMAC, Inc. &amp;lt;support@emacinc.com&amp;gt;&lt;br /&gt;
 */&lt;br /&gt;
/***************************************************************************&lt;br /&gt;
 *                                                                         *&lt;br /&gt;
 *   This program is free software; you can redistribute it and/or modify  *&lt;br /&gt;
 *   it under the terms of the GNU General Public License as published by  *&lt;br /&gt;
 *   the Free Software Foundation; either version 2 of the License, or     *&lt;br /&gt;
 *   (at your option) any later version.                                   *&lt;br /&gt;
 *                                                                         *&lt;br /&gt;
 ***************************************************************************/&lt;br /&gt;
 &lt;br /&gt;
#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
#include &amp;lt;stdlib.h&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
int main(void)&lt;br /&gt;
{&lt;br /&gt;
    printf(&amp;quot;Hello EMAC OE!\n&amp;quot;);&lt;br /&gt;
    exit(EXIT_SUCCESS);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
'''Listing 2. &amp;quot;Hello World&amp;quot; example project&lt;br /&gt;
&lt;br /&gt;
===Example Makefile===&lt;br /&gt;
&lt;br /&gt;
Listing 3 shows the default &amp;lt;code&amp;gt;Makefile&amp;lt;/code&amp;gt; used for the hello example project. This is a necessary component of the EMAC SDK which directs GNU Make in resolving source code dependencies before calling the cross-compiler to create a binary for the target platform. It also provides a convenient upload target which utilizes the development system's &amp;lt;code&amp;gt;wput&amp;lt;/code&amp;gt; command to send the compiled binary to the target system. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;Make&amp;quot;&amp;gt;&lt;br /&gt;
include ../global.properties&lt;br /&gt;
 &lt;br /&gt;
TARGET=hello&lt;br /&gt;
CFILES=hello.c&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
OBJS=$(CFILES:.c=.o)&lt;br /&gt;
DEPS=$(OBJS:.o=.d)&lt;br /&gt;
 &lt;br /&gt;
all: $(TARGET)&lt;br /&gt;
 &lt;br /&gt;
$(TARGET): $(OBJS) Makefile&lt;br /&gt;
  $(CC) $(VERBOSE) $(OBJS) $(OFLAGS) $(LIBFLAGS) $(SLIBS) -o $@&lt;br /&gt;
 &lt;br /&gt;
%.o: %.c&lt;br /&gt;
  $(CC) $(VERBOSE) $(CFLAGS) -o $@ -c $&amp;lt;&lt;br /&gt;
 &lt;br /&gt;
clean:&lt;br /&gt;
  $(RM) *.o *.gdb $(TARGET) $(DEPS)&lt;br /&gt;
 &lt;br /&gt;
upload: all&lt;br /&gt;
  $(WPUT) $(TARGET) ftp://$(LOGIN):$(PASSWORD)@$(TARGET_IP)/../../tmp/$(TARGET)&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
-include $(DEPS)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
'''Listing 3. Example EMAC OE SDK Makefile'''&lt;br /&gt;
&lt;br /&gt;
{{mbox | type = notice | text = '''NOTE:''' Using the documentation for GNU Make will be required to gain a solid understanding of the build system. Here is a brief description of this Makefile to help you get started.&lt;br /&gt;
* The &amp;lt;code&amp;gt;include&amp;lt;/code&amp;gt; command tells &amp;lt;code&amp;gt;make&amp;lt;/code&amp;gt; to pull in the file specified in a way similar to the C/C++ &amp;lt;code&amp;gt;#include&amp;lt;/code&amp;gt; preprocessor directive.&lt;br /&gt;
* The &amp;lt;code&amp;gt;TARGET=&amp;lt;/code&amp;gt; directive tells &amp;lt;code&amp;gt;make&amp;lt;/code&amp;gt; the name and location it should use for any executable binaries or shared object binaries (shared objects are similar to Windows &amp;lt;code&amp;gt;.dlls&amp;lt;/code&amp;gt;) it produces.&lt;br /&gt;
* The &amp;lt;code&amp;gt;CFILES=&amp;lt;/code&amp;gt; directive tells &amp;lt;code&amp;gt;make&amp;lt;/code&amp;gt; the names of the C source files it needs to build.&lt;br /&gt;
* The &amp;lt;code&amp;gt;OBJS=&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;DEPS=&amp;lt;/code&amp;gt; directives tell &amp;lt;code&amp;gt;make&amp;lt;/code&amp;gt; how to produce file names for the object and dependency files it generates. This file specifies a method for these which will work for most projects, and is unlikely to need modification.&lt;br /&gt;
* &amp;lt;code&amp;gt;all:&amp;lt;/code&amp;gt; specifies the make target named “all.” &amp;lt;code&amp;gt;clean:&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;upload:&amp;lt;/code&amp;gt;, similarly, specify the make targets for targets of these names, respectively. New make targets can be given names this way. make will perform all the steps listed after the target name until it encounters another target name.&lt;br /&gt;
* The &amp;lt;code&amp;gt;CC&amp;lt;/code&amp;gt; variable refers to the &amp;lt;code&amp;gt;gcc&amp;lt;/code&amp;gt; command, because &amp;lt;code&amp;gt;CC&amp;lt;/code&amp;gt; is so defined in the &amp;lt;code&amp;gt;global.properties&amp;lt;/code&amp;gt; file included by this Makefile. The &amp;lt;code&amp;gt;$(CC)&amp;lt;/code&amp;gt; syntax tells &amp;lt;code&amp;gt;make&amp;lt;/code&amp;gt; to read the value of the variable, &amp;lt;code&amp;gt;CC&amp;lt;/code&amp;gt;, and replace &amp;lt;code&amp;gt;$(CC)&amp;lt;/code&amp;gt; with the value of &amp;lt;code&amp;gt;CC&amp;lt;/code&amp;gt; prior to attempting to execute the command. This is similar to the way many scripting languages work, and hopefully will feel pretty natural to any developer working with Makefiles for the first time.}}&lt;br /&gt;
&lt;br /&gt;
{{mbox | type = notice | text = '''NOTE:''' This is a simple, basic Makefile which can be extended as needed to support many projects. Should your build requirements become complex, more sophistication may be required. A ''build system builder'' may be the tool you need. If this becomes necessary, options you may wish to consider include: &lt;br /&gt;
* Buy a good book on &amp;lt;code&amp;gt;make&amp;lt;/code&amp;gt; and learn the system thoroughly.&lt;br /&gt;
* Adopt a build system builder tool. ''CMake'' has proven to be popular for many large projects, and is simpler to use than ''autotools''. Buying a book on the build system builder tool chosen may prove wise.&lt;br /&gt;
* The build system builder in Eclipse may be able to handle the complexity of your requirements. This is probably the simplest option.&lt;br /&gt;
''NOTE: '''Build system builder''' refers to a tool which generates a set of scripts and/or Makefiles which are then used to build a project.''&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
==Next Steps==&lt;br /&gt;
&lt;br /&gt;
After compiling and running an example project, the next step is to create a new project. The [[EMAC OE SDK New Project Guide]] details this process from start to finish.&lt;br /&gt;
&lt;br /&gt;
[[Category:EMAC OE SDK]]&lt;/div&gt;</summary>
		<author><name>Mcoleman</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.emacinc.com/index.php?title=Configuring_EMAC_OE_4.0_SDK&amp;diff=469</id>
		<title>Configuring EMAC OE 4.0 SDK</title>
		<link rel="alternate" type="text/html" href="https://wiki.emacinc.com/index.php?title=Configuring_EMAC_OE_4.0_SDK&amp;diff=469"/>
		<updated>2013-05-17T20:14:45Z</updated>

		<summary type="html">&lt;p&gt;Mcoleman: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{EMAC OE SDK Conventions}}&lt;br /&gt;
&lt;br /&gt;
When Eclipse generates a Makefile to use for building a project, the generated Makefile includes a file named global.properties before it performs any other steps. This file is located in the projects directory, which is the root directory for Eclipse projects. The projects directory is located within the EMAC SDK directory provided by the EMAC SDK package (or installed on the LDC). &lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;global.properties&amp;lt;/code&amp;gt; file provides information needed to build projects and upload them to the target machine (the board supplied by EMAC). The following information is provided by this file: &lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Configuration variable !! Description &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;SDKBASE&amp;lt;/code&amp;gt; || The base directory for the SDK .&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;CC&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;CXX&amp;lt;/code&amp;gt; || Exectuable binaries to use for compiling for the C and C++ compiler, respectively.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;LD_LIBRARY_PATH&amp;lt;/code&amp;gt; || The path the linker should use to search for shared library files.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;CFLAGS&amp;lt;/code&amp;gt; || The flags passed to the compiler to specify target processor architecture, debugging flags, etc.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;OFLAGS&amp;lt;/code&amp;gt; || The flags passed to the compiler to specify optimization options to use.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;TARGET_IP&amp;lt;/code&amp;gt; || The IP Address of the target machine (needed for uploading the compiled binary to the target machine).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;LOGIN&amp;lt;/code&amp;gt; || The user name to use for logging into the target machine.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;PASSWORD&amp;lt;/code&amp;gt; || The password to use for logging into the target machine.*&lt;br /&gt;
|- &lt;br /&gt;
| &amp;lt;code&amp;gt;WPUT&amp;lt;/code&amp;gt; ||  The location of the &amp;lt;code&amp;gt;wput&amp;lt;/code&amp;gt; command, along with options to pass to &amp;lt;code&amp;gt;wput&amp;lt;/code&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
'''*NOTE''' The password is stored in plain text in this file. However, read permission is required to view this password. In most development environments, this should not be an issue. If development is taking place in a shared environment (such as a University lab) and secrecy of this password is required, simply ensure that only trusted users have read permission for this file.&lt;br /&gt;
&lt;br /&gt;
{{mbox | type = warning | text = Configuring permissions on files is a common source of problems for people new to doing so under Linux. EMAC does not recommend altering the default settings (which should be secure in most environments) unless absolutely necessary. EMAC will only be able to provide very limited support should these settings be manually configured. The standard Linux commands, &amp;lt;code&amp;gt;chmod&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;chgrp&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;chown&amp;lt;/code&amp;gt; are typically used to configure these permissions. Please see the documentation for these commands using the man command, or find a reference with your favorite search engine. '''Caveat''': This will require any user wishing to build this software to have such permission, since programs run by a user can only read files the user is permitted to use.}}&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;global.properties&amp;lt;/code&amp;gt; file is actually a type of virtual file, called a softlink. This softlink acts as a pointer which points to another file. The file it points to is chosen when the CPU architecture is chosen. To see why it works this way, see the above information about the flags specified for the processor architecture, and note that different library and compiler paths may be required to support different hardware. The softlink is updated when the hardware to use for the development project is selected.&lt;br /&gt;
&lt;br /&gt;
{{mbox | type = notice | text = Should problems relating to this part of the build system show up during the development process, these files or softlinks may have been accidentally modified. Inspecting these files and softlinks, and/or rerunning the hardware selection script, may provide the fix for the problems. The &amp;lt;code&amp;gt;ln&amp;lt;/code&amp;gt; command with the &amp;lt;code&amp;gt;-s&amp;lt;/code&amp;gt; option (see &amp;lt;code&amp;gt;man ln&amp;lt;/code&amp;gt;) is the command used to create softlinks.}}&lt;br /&gt;
&lt;br /&gt;
==Configuration Steps==&lt;br /&gt;
&lt;br /&gt;
The following configuration steps are necessary to begin using the EMAC OE SDK. &lt;br /&gt;
&lt;br /&gt;
Before cross-compiling source code on the development machine for the target machine: &lt;br /&gt;
&lt;br /&gt;
* A [[set up script]] linking &amp;lt;code&amp;gt;global.properties&amp;lt;/code&amp;gt; to an architecture-specific &amp;lt;code&amp;gt;global.properties&amp;lt;/code&amp;gt; file must be run.&lt;br /&gt;
* The &amp;lt;code&amp;gt;TARGET_IP&amp;lt;/code&amp;gt; variable in the [[global.properties]] file must be changed to the IP address or hostname belonging to the target board.&lt;br /&gt;
&lt;br /&gt;
{{mbox | type = notice | text = These configurations assume that the [[EMAC OE SDK]] is installed.}}&lt;br /&gt;
&lt;br /&gt;
==SDK Set Up Script==&lt;br /&gt;
&lt;br /&gt;
Before compiling source code for the target machine, toolchain libraries for the target machine must be specified by running &amp;lt;code&amp;gt;setmachine.sh&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
===Procedure===&lt;br /&gt;
&lt;br /&gt;
# Navigate to the SDK directory.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ cd /path/to/sdk/EMAC-OE-arm-linux-gnueabi-SDK_XX.YY/&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
# Run the script using the command shown below to produce a menu as shown in Figure 1 with options for the target machine for which the source will be compiled.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ ./setmachine.sh&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
[[File:Emac_oe_sdk_setup-2.png]]&lt;br /&gt;
&lt;br /&gt;
==Remote Upload Set-up==&lt;br /&gt;
&lt;br /&gt;
In the &amp;lt;code&amp;gt;global.properties&amp;lt;/code&amp;gt; file there is a variable, &amp;lt;code&amp;gt;IP&amp;lt;/code&amp;gt; which must be set to the target board IP address as shown in Listing 1 below. This step is necessary to ensure that the Make target, &amp;lt;code&amp;gt;'upload'&amp;lt;/code&amp;gt; will work as expected.&lt;br /&gt;
&lt;br /&gt;
===Procedure===&lt;br /&gt;
&lt;br /&gt;
# Navigate to the projects directory within the SDK.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ cd /path/to/sdk/EMAC-OE-arm-linux-gnueabi-SDK_XX.YY/projects&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
# The &amp;lt;code&amp;gt;global.properties&amp;lt;/code&amp;gt; file should be listed in the current directory. The relevant lines from &amp;lt;code&amp;gt;global.properties&amp;lt;/code&amp;gt; are shown in Listing 1 below.&lt;br /&gt;
'''Listing 1. &amp;lt;code&amp;gt;global.properties&amp;lt;/code&amp;gt; snippet'''&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
TARGET_IP=&lt;br /&gt;
LOGIN=root&lt;br /&gt;
PASSWORD=emac_inc_90210&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
# Change the value of &amp;lt;code&amp;gt;TARGET_IP&amp;lt;/code&amp;gt; to the target system's IP address.&lt;br /&gt;
This can be found using the following command from a shell on the target system:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@emac-oe:~# /sbin/ifconfig eth0 | grep inet&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
For more information on how to connect to the remote system, see the [[initial connections section]] of the [[EMAC OE Getting Started Guide|EMAC OE getting started guide]].&lt;br /&gt;
# Change the value of &amp;lt;code&amp;gt;PASSWORD&amp;lt;/code&amp;gt; to whatever value was set in the [[System Login section]] of the [[EMAC OE Getting Started Guide|EMAC OE getting started guide]]. Listing 1 shows the default user name and password.&lt;br /&gt;
&lt;br /&gt;
[[Category:EMAC OE SDK]]&lt;/div&gt;</summary>
		<author><name>Mcoleman</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.emacinc.com/index.php?title=EMAC_OE_SDK_Introduction&amp;diff=468</id>
		<title>EMAC OE SDK Introduction</title>
		<link rel="alternate" type="text/html" href="https://wiki.emacinc.com/index.php?title=EMAC_OE_SDK_Introduction&amp;diff=468"/>
		<updated>2013-05-17T20:13:43Z</updated>

		<summary type="html">&lt;p&gt;Mcoleman: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{EMAC OE SDK Conventions}}&lt;br /&gt;
&lt;br /&gt;
The EMAC Open Embedded SDK is distributed in an archive that can be extracted and used from a Linux shell or imported into Eclipse as a ready-to-develop project. The archive contains a hardware-specific SDK which must be set up using the [[EMAC OE SDK Configuration]] page.&lt;br /&gt;
&lt;br /&gt;
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. Understanding the details of this toolchain is not necessary for the application developer. However, the setup is simple enough for those with an intermediate knowledge of GNU/Linux development to understand and modify the configuration to suit application-specific needs if, necessary.&lt;br /&gt;
&lt;br /&gt;
To learn how to put these features into use, see the links below.&lt;br /&gt;
&lt;br /&gt;
[[Category:EMAC OE SDK]]&lt;/div&gt;</summary>
		<author><name>Mcoleman</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.emacinc.com/index.php?title=EMAC_OE_SDK_Introduction&amp;diff=467</id>
		<title>EMAC OE SDK Introduction</title>
		<link rel="alternate" type="text/html" href="https://wiki.emacinc.com/index.php?title=EMAC_OE_SDK_Introduction&amp;diff=467"/>
		<updated>2013-05-17T20:13:30Z</updated>

		<summary type="html">&lt;p&gt;Mcoleman: adding conventions table&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{EMAC OE SD Conventions}}&lt;br /&gt;
&lt;br /&gt;
The EMAC Open Embedded SDK is distributed in an archive that can be extracted and used from a Linux shell or imported into Eclipse as a ready-to-develop project. The archive contains a hardware-specific SDK which must be set up using the [[EMAC OE SDK Configuration]] page.&lt;br /&gt;
&lt;br /&gt;
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. Understanding the details of this toolchain is not necessary for the application developer. However, the setup is simple enough for those with an intermediate knowledge of GNU/Linux development to understand and modify the configuration to suit application-specific needs if, necessary.&lt;br /&gt;
&lt;br /&gt;
To learn how to put these features into use, see the links below.&lt;br /&gt;
&lt;br /&gt;
[[Category:EMAC OE SDK]]&lt;/div&gt;</summary>
		<author><name>Mcoleman</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.emacinc.com/index.php?title=Remote_Debugging_EMAC_OE_SDK_Projects_with_gdbserver&amp;diff=466</id>
		<title>Remote Debugging EMAC OE SDK Projects with gdbserver</title>
		<link rel="alternate" type="text/html" href="https://wiki.emacinc.com/index.php?title=Remote_Debugging_EMAC_OE_SDK_Projects_with_gdbserver&amp;diff=466"/>
		<updated>2013-05-17T20:10:39Z</updated>

		<summary type="html">&lt;p&gt;Mcoleman: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{EMAC OE SDK Conventions}}&lt;br /&gt;
&lt;br /&gt;
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 binary resulting from the compile 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 while running the debugger.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
This guide is intended to build a basic understanding of how to use gdbserver with EMAC products. It is not intended as a general guide to debugging computer programs. For help with that, see the GDB man pages on the development system or read [this manual] on debugging with GDB.&lt;br /&gt;
&lt;br /&gt;
==Setup==&lt;br /&gt;
&lt;br /&gt;
Using &amp;lt;code&amp;gt;gdbserver&amp;lt;/code&amp;gt; involves setting up both the target machine and the development machine. This requires that the binary application be present on both development and target machines. The development machine copy of the application must be compiled with debug flags whereas this is not strictly necessary for the target machine. See the [Optional &amp;lt;code&amp;gt;global.properties&amp;lt;/code&amp;gt; Modifications Section] on the New EMAC OE SDK Project Guide for more information. See the [[[EMAC OE Getting Started Guide]]] for more information on how to connect to the target EMAC product using a serial port or Ethernet connection.&lt;br /&gt;
&lt;br /&gt;
===Target Machine===&lt;br /&gt;
&lt;br /&gt;
Because EMAC OE builds are distributed with &amp;lt;code&amp;gt;gdbserver&amp;lt;/code&amp;gt;, installation is not a concern. The only setup necessary is to run &amp;lt;code&amp;gt;gdbserver&amp;lt;/code&amp;gt; with &amp;lt;code&amp;gt;target_program&amp;lt;/code&amp;gt;: &lt;br /&gt;
&lt;br /&gt;
# If the target application is already running, use the attachpid option to connect &amp;lt;code&amp;gt;gdbserver&amp;lt;/code&amp;gt; to the application as shown below. The &amp;lt;code&amp;gt;PID&amp;lt;/code&amp;gt; argument can be determined using &amp;lt;code&amp;gt;pidof&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ pidof target_program&lt;br /&gt;
developer@ldc:~$ gdbserver target_machine --attach PID&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
# If the target application is not already running, the name of the binary may be included as an argument to the &amp;lt;code&amp;gt;gdbserver&amp;lt;/code&amp;gt; program call.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;snytaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ gdbserver target_machine target_program [ARGS]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This establishes a &amp;lt;code&amp;gt;gdbserver&amp;lt;/code&amp;gt; port on the target machine that listens for incoming connections from GDB on the development machine. In debug terminology, &amp;lt;code&amp;gt;gdbserver&amp;lt;/code&amp;gt; is “attached” to the process ID of the program being debugged. In reality, though, GDB is attached to the process ID of a proxy which passes the messages to and from the remote device under test. &lt;br /&gt;
&lt;br /&gt;
The next step is to run GDB on the development machine using the &amp;lt;code&amp;gt;target_program&amp;lt;/code&amp;gt;/&lt;br /&gt;
&lt;br /&gt;
===Development Machine===&lt;br /&gt;
&lt;br /&gt;
# First, &amp;lt;code&amp;gt;cd&amp;lt;/code&amp;gt; to the directory where the targe executable is stored.&lt;br /&gt;
# Run the EMAC OE SDK GDB:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ /path/to/sdk/EMAC-OE-arm-linux-gnueabi-SDK_4.0/gcc-4.2.4-arm-linux-gnueabi/bin/arm-linux-gnueabi-gdb target_program&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
# Run the following commands in GDB to prepare for the debug session:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;gdb&amp;quot;&amp;gt;&lt;br /&gt;
(gdb) target remote target_machine&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{mbox | type = warning | text = Note that the location of the GDB in the toolchain may differ from what is shown above depending on which version of the SDK is used.}}&lt;br /&gt;
&lt;br /&gt;
{{mbox | type = notice | text = If the gdb executable, or any other executable you run, is located in a directory which is in the PATH environment variable, you can simply run that command without the long path prefix. Sourcing the environment variables generated by the EMAC script for this will provide you with such a path. The script which creates the file to source also creates a symbolic link for arm-linux-gnueabi-gdb called, simply, gdb. With your shell environment setup this way, you could simply execute: &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ gdb target_program&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
in place of the long command given in step 2, above.&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
==Sample GDB Session==&lt;br /&gt;
&lt;br /&gt;
This example GDB session uses the EMAC OE SDK example project named &amp;lt;code&amp;gt;pthread_demo&amp;lt;/code&amp;gt;. It consists of the single source file &amp;lt;code&amp;gt;pthread_demo.c&amp;lt;/code&amp;gt;. The program is called with a single integer argument indicating how many &amp;lt;code&amp;gt;reader&amp;lt;/code&amp;gt; threads the user wishes to create. The following describes the tasks of the &amp;lt;code&amp;gt;main&amp;lt;/code&amp;gt; thread: &lt;br /&gt;
&lt;br /&gt;
# The &amp;lt;code&amp;gt;main&amp;lt;/code&amp;gt; thread performs user input validation. It prints a usage message according to the argument passed to it on the command line. The function expects the user to pass a number indicating how many threads should be spawned.&lt;br /&gt;
# The &amp;lt;code&amp;gt;main&amp;lt;/code&amp;gt; thread initiates a new thread which uses the &amp;lt;code&amp;gt;generator()&amp;lt;/code&amp;gt; function to perform the following tasks:&lt;br /&gt;
## Checks to see if the number of &amp;lt;code&amp;gt;reader&amp;lt;/code&amp;gt; threads matches the number of times a &amp;lt;code&amp;gt;reader&amp;lt;/code&amp;gt; thread has acquired the mutex lock and performed its task. If the two values do match, then the &amp;lt;code&amp;gt;generator&amp;lt;/code&amp;gt; thread unlocks the mutex, breaks out of the while loop and moves on to line 167 to gracefully exit. If the two values do not match, then the &amp;lt;code&amp;gt;generator&amp;lt;/code&amp;gt; thread continues through the rest of the while loop described in steps 2.2 and 2.3.&lt;br /&gt;
## Generates random data to be stored in the data struct shared by all the threads. To do this, it protects the data struct with the use of a mutex variable.&lt;br /&gt;
## Sleeps after giving up its lock on the mutex so that another thread might have a chance to acquire the lock.&lt;br /&gt;
# After creating the &amp;lt;code&amp;gt;generator&amp;lt;/code&amp;gt; thread the &amp;lt;code&amp;gt;main&amp;lt;/code&amp;gt; thread iteratively creates as many &amp;lt;code&amp;gt;reader&amp;lt;/code&amp;gt; threads as indicated by the single integer argument. Each &amp;lt;code&amp;gt;reader&amp;lt;/code&amp;gt; thread performs the following tasks:&lt;br /&gt;
## Waits for a chance to acquire the mutex &amp;lt;code&amp;gt;lock&amp;lt;/code&amp;gt;. Once the mutex &amp;lt;code&amp;gt;lock&amp;lt;/code&amp;gt; is acquired, it prints the value of the random number &amp;lt;code&amp;gt;generated&amp;lt;/code&amp;gt; by the generator thread in its last run.&lt;br /&gt;
## Increments an integer in the &amp;lt;code&amp;gt;data&amp;lt;/code&amp;gt; struct to indicate that it has completed its task.&lt;br /&gt;
## Gives up its lock on the mutex and exits.&lt;br /&gt;
# After creating the prescribed number of &amp;lt;code&amp;gt;reader&amp;lt;/code&amp;gt; threads, the &amp;lt;code&amp;gt;main&amp;lt;/code&amp;gt; thread then waits for each thread created to exit gracefully. &lt;br /&gt;
# The &amp;lt;code&amp;gt;main&amp;lt;/code&amp;gt; thread exists.&lt;br /&gt;
&lt;br /&gt;
The SDK version of &amp;lt;code&amp;gt;pthread_demo.c&amp;lt;/code&amp;gt; works according to the description above with a &amp;lt;code&amp;gt;MAX_THREAD&amp;lt;/code&amp;gt; value of 100. However, for the purpose of this example debug session it is instructive to use a faulty version of the same program. Replace lines 75-80 in &amp;lt;code&amp;gt;pthread_demo.c&amp;lt;/code&amp;gt; with the code snippet shown in Listing 1 below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
if ((data.num_threads &amp;lt; 1) || (data.num_threads &amp;lt; MAX_THREAD)) {&lt;br /&gt;
        fprintf(stderr,&lt;br /&gt;
                &amp;quot;The number of thread should between 1 and %d\n&amp;quot;,&lt;br /&gt;
                MAX_THREAD);&lt;br /&gt;
        exit(EXIT_FAILURE);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Useful GDB Commands===&lt;br /&gt;
&lt;br /&gt;
The following is a brief description of some essential GDB commands. Each description is followed by a link to the official GDB documentation page that has more specific information about what the command does and how to use it. Please note that the official GDB documentation is targeted for the latest GDB release which at the time of writing this documentation is 7.4. The version of GDB that EMAC distributes with the OE products, however, is version 6.8. Because of this, the links to documentation below may provide slightly different information. The biggest difference between the two version of GDB, however, is in the support for debugging programs with multiple threads. This is reflected in the documentation as well. Because of this, EMAC has set up ftp access to GDB 6.8 documentation on its web server. It is highly recommended that the GDB 6.8 documentation be referenced in cases where the program does not seem to support commands or options specified in the current official documentation. &lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Command !! Description &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;start/run&amp;lt;/code&amp;gt;&lt;br /&gt;
|| These commands are used to start the debugged program with the only difference being that start automatically pauses execution at the beginning of the program's main function whereas run must be told explicitly where to pause using the breakpoint command listed below.&lt;br /&gt;
See also [Debugging with GDB, Section 4.2: Starting your Program]&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;kill&amp;lt;/code&amp;gt;&lt;br /&gt;
|| Used to kill the currently-running instance of target_program.&lt;br /&gt;
See also [Debugging with GDB, Section 4.9: Killing the Child Process]&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;print&amp;lt;/code&amp;gt;&lt;br /&gt;
|| Used to print the value of an expression.&lt;br /&gt;
See also [Debugging with GDB, Section 10: Examining Data]&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;list&amp;lt;/code&amp;gt;&lt;br /&gt;
|| List contents of function or specified line.&lt;br /&gt;
See also [Debugging with GDB, Section 9: Examining Source Files]&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;layout&amp;lt;/code&amp;gt;&lt;br /&gt;
|| This is a TUI (Text User Interface) command that enables the programmer to view multiple debug views at once including source code, assembly, and registers.&lt;br /&gt;
See also [Debugging with GDB, Section 25.4: TUI Commands]&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;disassemble&amp;lt;/code&amp;gt;&lt;br /&gt;
|| This command allows the programmer to see assembler instructions.&lt;br /&gt;
See also [Debugging with GDB, Section 9.6: Source and Machine Code]&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;break&amp;lt;/code&amp;gt;&lt;br /&gt;
|| This command specifies a function name, line number, or instruction at which GDB is to pause execution.&lt;br /&gt;
See also [Debugging with GDB, Section 5.1: Breakpoints]&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;next/nexti, step/stepi&amp;lt;/code&amp;gt;&lt;br /&gt;
|| Allow the programmer to step through a program without specifying breakpoints. The &amp;lt;code&amp;gt;next/nexti&amp;lt;/code&amp;gt; commands step over function calls, stopping on the next line of the same stack frame; &amp;lt;code&amp;gt;step/stepi&amp;lt;/code&amp;gt;, step into function calls, stopping on the first line in the next stack frame. The difference between &amp;lt;code&amp;gt;step/next&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;stepi/nexti&amp;lt;/code&amp;gt; is that the &amp;lt;code&amp;gt;i&amp;lt;/code&amp;gt; indicates instruction-by-instruction stepping at the assembly language level.&lt;br /&gt;
See also [Debugging with GDB, Section 5.2: Continuing and Stepping]&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;continue&amp;lt;/code&amp;gt;&lt;br /&gt;
|| Used to continue program execution from the address where it was last stopped.&lt;br /&gt;
See the Debugging with GDB link for &amp;lt;code&amp;gt;next/step&amp;lt;/code&amp;gt; for more information about the &amp;lt;code&amp;gt;continue&amp;lt;/code&amp;gt; command.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;bt&amp;lt;/code&amp;gt;&lt;br /&gt;
|| Short for &amp;quot;backtrace,&amp;quot; which displays to the programmer a brief summary of execution up to the current point in the program. This is useful because it shows a nested list of stack frames starting with the current one.&lt;br /&gt;
See also [Debugging with GDB, Section 8.2: Backtrace]&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;quit&amp;lt;/code&amp;gt;&lt;br /&gt;
||  This will quit the debugging session, and return you to the shell. The Control-D key combination is another way to accomplish this.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Session Walk-through===&lt;br /&gt;
&lt;br /&gt;
This debug session walk-through assumes that the program has been compiled using the modified source code above and that both the target machine and the development machine have been set up according to the above Setup section. The walk-through is divided into multiple “lessons” with the intent of first introducing the use of the commands described above and then actually running GDB to debug a known programming problem. Each lesson may be run independently of the others, but it is recommended that each be run in order starting from Lesson 1 for the first time through.&lt;br /&gt;
&lt;br /&gt;
====Lesson 1: Navigation and Code Display====&lt;br /&gt;
&lt;br /&gt;
This lesson assumes that &amp;lt;code&amp;gt;gdbserver&amp;lt;/code&amp;gt; has been run as in the [Target Machine Setup] section above with an ARG value of 3. Other values are fine so long as they fall within the range of 1 to 100. The number '3' was arbitrarily chosen to avoid having to use a symbolic variable in the explanations below.&lt;br /&gt;
&lt;br /&gt;
# Type &amp;lt;code&amp;gt;b main&amp;lt;/code&amp;gt; to set a breakpoint at the main function in the source code.&lt;br /&gt;
# Type &amp;lt;code&amp;gt;continue&amp;lt;/code&amp;gt;. This will cause the program to continue from the breakpoint set by GDB at startup. The program was passed an argument of 3, indicating that three threads should be created. &lt;br /&gt;
# Type &amp;lt;code&amp;gt;b 73&amp;lt;/code&amp;gt; to set a breakpoint at line 73 in the source code, which should be the line containing &amp;lt;code&amp;gt;data.num_threads = atoi(argv[1]);&amp;lt;/code&amp;gt;&lt;br /&gt;
# Type &amp;lt;code&amp;gt;continue&amp;lt;/code&amp;gt;. The program will continue execution up until line 73 in the source code. At this point, type layout split to view a split screen containing both the source code and the assembly-level machine instructions. Both screens show the program's current location in execution. The assembly-level display shows what the target's processor is actually executing at that point in the source code as shown in the source-level display. To view either of these without the other type layout &amp;lt;code&amp;gt;asm&amp;lt;/code&amp;gt; for just assembly-level and &amp;lt;code&amp;gt;layout src&amp;lt;/code&amp;gt; for just source-level.&lt;br /&gt;
# Type &amp;lt;code&amp;gt;nexti&amp;lt;/code&amp;gt;. This will cause the program to execute the next instruction in the current stack frame which is a mov instruction beginning to prepare the current stack for a call to the library function &amp;lt;code&amp;gt;atoi()&amp;lt;/code&amp;gt;. The details of this process are beyond the scope of this tutorial; essentially, the program needs to store information about the current execution location in the stack for when the &amp;lt;code&amp;gt;atoi()&amp;lt;/code&amp;gt; function finishes. Type &amp;lt;code&amp;gt;ni&amp;lt;/code&amp;gt; (alias for nexti) three more times. You should end up on a &amp;lt;code&amp;gt;bl&amp;lt;/code&amp;gt; instruction in the assembly view as shown in Listing 2 below. The source layout should still show the program on line 73.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;asm&amp;quot;&amp;gt;&lt;br /&gt;
B+ |0x887c &amp;lt;main+112&amp;gt;       ldr    r3, [r11, #-84]                   │&lt;br /&gt;
   |0x8880 &amp;lt;main+116&amp;gt;       add    r3, r3, #4      ; 0x4             │&lt;br /&gt;
   |0x8884 &amp;lt;main+120&amp;gt;       ldr    r3, [r3]                          │&lt;br /&gt;
   |0x8888 &amp;lt;main+124&amp;gt;       mov    r0, r3                            │&lt;br /&gt;
  &amp;gt;|0x888c &amp;lt;main+128&amp;gt;       bl     0x86e0 &amp;lt;atoi&amp;gt;                     │&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
'''Listing 2. GDB Assembly Layout''' - ''Note that the assembly may look different depending on the target architecture.''&lt;br /&gt;
# Type &amp;lt;code&amp;gt;stepi&amp;lt;/code&amp;gt;. This will cause the program to move into the next stack frame and GDB to show the assembly-level instructions of the &amp;lt;code&amp;gt;atoi()&amp;lt;/code&amp;gt; call. Since the library containing &amp;lt;code&amp;gt;atoi()&amp;lt;/code&amp;gt; was likely not compiled with debug symbols, the source-level layout will show the message &amp;lt;code&amp;gt;[ No Source Available ]&amp;lt;/code&amp;gt;.&lt;br /&gt;
# Type &amp;lt;code&amp;gt;bt&amp;lt;/code&amp;gt;. This will cause the program to display a human-readable version of the current stack. Each stack “frame” is represented by the name of the function call it represents with that function's location in memory. Type &amp;lt;code&amp;gt;bt full&amp;lt;/code&amp;gt; to get a list of the variables local to each stack frame.&lt;br /&gt;
# Type &amp;lt;code&amp;gt;finish&amp;lt;/code&amp;gt;. This will cause the current stack frame to return and execution to pause on the next instruction of the previous stack frame.&lt;br /&gt;
# Type &amp;lt;code&amp;gt;kill&amp;lt;/code&amp;gt;. This will cause the current process to be killed by &amp;lt;code&amp;gt;gdbserver&amp;lt;/code&amp;gt; at the target machine. &amp;lt;code&amp;gt;gdbserver&amp;lt;/code&amp;gt; will also terminate at this point. In order to start a new remote debug session, start gdbserver as described in the Target Machine Setup section and re-run step 3 of the [Development Machine Setup] section.&lt;br /&gt;
&lt;br /&gt;
{{mbox | type = warning | text = '''Note:''' &amp;lt;code&amp;gt;b&amp;lt;/code&amp;gt; is an alias for the &amp;lt;code&amp;gt;break&amp;lt;/code&amp;gt; command. &lt;br /&gt;
&amp;lt;code&amp;gt;ni&amp;lt;/code&amp;gt; is an alias for &amp;lt;code&amp;gt;nexti&amp;lt;/code&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
====Lesson 2: Finding the Bug====&lt;br /&gt;
&lt;br /&gt;
Though this sample is contrived, it is still useful to demonstrate how to find a design mistake in an otherwise well-written (no errors or warnings) program. These types of mistakes typically have to do with the array boundary miscalculations, logic and comparison operator mistakes, or other simple mistakes. For the sake of demonstration, assume that the actual mistake is unknown. This lesson assumes that gdbserver has just been started as in the [Target Machine] Setup above with an &amp;lt;code&amp;gt;ARG&amp;lt;/code&amp;gt; value of 5.&lt;br /&gt;
&lt;br /&gt;
# Before starting the program in the debugger again, run it by itself on the target machine to see what the actual program output is: &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@emac-oe:~# /tmp/pthread_demo 5&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
The number of threads should be between 1 and 100&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The program was given an input of '5' yet the output message seems to indicate that this is out of range which is obviously not true.&lt;br /&gt;
# Start the debugger again and connect to the target machine as described in the Setup section.&lt;br /&gt;
# Type &amp;lt;code&amp;gt;b main&amp;lt;/code&amp;gt; to set a breakpoint at the main function in the source code.&lt;br /&gt;
# Type &amp;lt;code&amp;gt;continue&amp;lt;/code&amp;gt;. This will cause the program to continue from the breakpoint set by GDB at startup. &lt;br /&gt;
# Type &amp;lt;code&amp;gt;n&amp;lt;/code&amp;gt;. This will cause the program to step over the next line of source code. The reason for using &amp;lt;code&amp;gt;n&amp;lt;/code&amp;gt; rather than &amp;lt;code&amp;gt;s&amp;lt;/code&amp;gt; or one of the instruction stepping commands is because the erroneous output indicates that the coding mistake is in the programmer's source code rather than the c library functions &amp;lt;code&amp;gt;atoi()&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;fprintf()&amp;lt;/code&amp;gt;. Stepping over the function will save all the time required to step through every detail of what the library functions are doing. Later passes through the code can be used to step into functions called from within that stack frame if the first pass proves unsuccessful.&lt;br /&gt;
# Continue to type &amp;lt;code&amp;gt;n&amp;lt;/code&amp;gt; until one of the program's &amp;lt;code&amp;gt;exit()&amp;lt;/code&amp;gt; calls is reached, but do not actually step into that &amp;lt;code&amp;gt;exit()&amp;lt;/code&amp;gt; call. Judging by the program's output above, this should bring you to the conditional block that checks the value of the local variable n used to store the output of &amp;lt;code&amp;gt;atoi()&amp;lt;/code&amp;gt; as shown in Listing 3. Note that once execution reaches line 79 of the source code, GDB will display the output of the &amp;lt;code&amp;gt;fprintf()&amp;lt;/code&amp;gt; function from line 76. This may cause display problems within the text-based UI library that GDB uses which will require the command refresh to fix.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;gdb&amp;quot;&amp;gt;&lt;br /&gt;
B+ |75              if ((data.num_threads &amp;lt; 1) || (data.num_threads &amp;lt; MAX_THREAD)) {       |&lt;br /&gt;
   |76                      fprintf(stderr,                                                |&lt;br /&gt;
   |77                              &amp;quot;The number of thread should between 1 and %d\n&amp;quot;,      |&lt;br /&gt;
   |78                              MAX_THREAD);                                           |&lt;br /&gt;
  &amp;gt;|79                      exit(EXIT_FAILURE);                                            |&lt;br /&gt;
   |80              }                                                                      |&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
# Type &amp;lt;code&amp;gt;p/d data→num_threads&amp;lt;/code&amp;gt;. &amp;lt;code&amp;gt;p&amp;lt;/code&amp;gt; is an alias for &amp;lt;code&amp;gt;print&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;/d&amp;lt;/code&amp;gt; tells GDB to treat the expression requested as an integer in signed decimal, and &amp;lt;code&amp;gt;data→num&amp;lt;/code&amp;gt;_threads is the element &amp;lt;code&amp;gt;num_threads&amp;lt;/code&amp;gt; within &amp;lt;code&amp;gt;struct thread_data&amp;lt;/code&amp;gt;. This should provide the following output:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;gdb&amp;quot;&amp;gt;&lt;br /&gt;
(gdb) p/d data-&amp;gt;num_threads&lt;br /&gt;
$6 = 5&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Note that the integer part of &amp;lt;code&amp;gt;$6&amp;lt;/code&amp;gt; will increment with each call to the gdb command &amp;lt;code&amp;gt;print&amp;lt;/code&amp;gt;. The above output confirms that the argument '5' was successfully passed to the program and read into a variable to be tested, indicating that one of the logical tests for the current conditional block contains a mistake. This merits a closer look at line 75:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;gdb&amp;quot;&amp;gt;&lt;br /&gt;
B+ |75              if ((data.num_threads &amp;lt; 1) || (data.num_threads &amp;lt; MAX_THREAD)) {       |&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Line 75 consists of a conditional test which is the logical OR of two arithmetic tests involving the values of &amp;lt;code&amp;gt;data.num_threads&amp;lt;/code&amp;gt;, '1', and &amp;lt;code&amp;gt;MAX_THREAD&amp;lt;/code&amp;gt;. The first test is true the input integer is less than &amp;lt;code&amp;gt;1–(data.num_threads &amp;amp;lt; 1)&amp;lt;/code&amp;gt;. The second tests whether the input integer is less than the symbolic constant, &amp;lt;code&amp;gt;MAX_THREAD–(data.num_threads &amp;amp;lt; MAX_THREAD)&amp;lt;/code&amp;gt;. Judging by the name of this constant and the result of the test (we know it resolves to true because the value of &amp;lt;code&amp;gt;data.num_threads&amp;lt;/code&amp;gt; in this case is not less than one), we can see that the comparison operator used is the culprit. The correct interpretation is that it should be '&amp;amp;gt;' rather than '&amp;amp;lt;'.&lt;br /&gt;
# Type &amp;lt;code&amp;gt;kill&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
This was a simple problem to solve but the method used above could apply in any situation where source code compiles and runs without errors yet provides varied or unexpected output.&lt;br /&gt;
&lt;br /&gt;
====Lesson 3: Debugging With Threads====&lt;br /&gt;
&lt;br /&gt;
Do not fix the programming mistake found in Lesson 2. This lesson will cover the use of the jump command to skip blocks of code and commands specific to debugging multi-threaded programs. Before getting started, see [http://sourceware.org/gdb/current/onlinedocs/gdb/Thread-Stops.html#Thread-Stops Debugging with GDB: 5. Stopping and Starting Multi-thread Programs].&lt;br /&gt;
&lt;br /&gt;
This lesson assumes that &amp;lt;code&amp;gt;gdbserver&amp;lt;/code&amp;gt; has just been started as in the Target Machine Setup above with an &amp;lt;code&amp;gt;ARG&amp;lt;/code&amp;gt; value of 7.&lt;br /&gt;
&lt;br /&gt;
# Start the debugger again and connect to the target machine as described in the Setup section.&lt;br /&gt;
# Type set &amp;lt;code&amp;gt;scheduler-locking&amp;lt;/code&amp;gt; on. This command enables GDB to lock all threads save for the currently-selected thread from running when the &amp;lt;code&amp;gt;step/stepi&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;next/nexti&amp;lt;/code&amp;gt; commands are given. &lt;br /&gt;
# Set all the breakpoints that you will need for this session: &lt;br /&gt;
## Type &amp;lt;code&amp;gt;b main&amp;lt;/code&amp;gt; to set a breakpoint at the main function in the source code.&lt;br /&gt;
## Type &amp;lt;code&amp;gt;b 75&amp;lt;/code&amp;gt;. This will set a break point at the conditional block that checks the value of the program's single integer argument. If you recall from Lesson 2, this is the conditional which evaluates incorrectly in the modified version of the application.&lt;br /&gt;
## Type &amp;lt;code&amp;gt;b 143&amp;lt;/code&amp;gt;. This will set a breakpoint in the variable assignment in the &amp;lt;code&amp;gt;generator&amp;lt;/code&amp;gt; function. Careful examination of the source code will show that this function is called from a thread created by the main thread of execution but never from the main thread itself.&lt;br /&gt;
## Type &amp;lt;code&amp;gt;b 129&amp;lt;/code&amp;gt;. This will set a breakpoint in the variable assignment of the &amp;lt;code&amp;gt;reader&amp;lt;/code&amp;gt; function. As with the &amp;lt;code&amp;gt;generator&amp;lt;/code&amp;gt; function, any time the &amp;lt;code&amp;gt;reader&amp;lt;/code&amp;gt; function is called it will be inside a thread that is not the main thread.&lt;br /&gt;
## Type &amp;lt;code&amp;gt;b 135&amp;lt;/code&amp;gt;. This will set a breakpoint just after the &amp;lt;code&amp;gt;fflush(stdout)&amp;lt;/code&amp;gt; statement in the &amp;lt;code&amp;gt;reader&amp;lt;/code&amp;gt; function.&lt;br /&gt;
## Type &amp;lt;code&amp;gt;b 97&amp;lt;/code&amp;gt;. This will set a breakpoint in the main thread after the &amp;lt;code&amp;gt;generator&amp;lt;/code&amp;gt; thread has been created but before the main thread begins creating &amp;lt;code&amp;gt;reader&amp;lt;/code&amp;gt; threads.&lt;br /&gt;
## Type &amp;lt;code&amp;gt;b 119&amp;lt;/code&amp;gt;. This will set a breakpoint after the main thread iteratively creates the &amp;lt;code&amp;gt;reader&amp;lt;/code&amp;gt; threads.&lt;br /&gt;
# Optional: You may want to run the &amp;lt;code&amp;gt;layout split&amp;lt;/code&amp;gt; command so that you can see both the assembly and the source code during the debug session.&lt;br /&gt;
# Type &amp;lt;code&amp;gt;continue&amp;lt;/code&amp;gt; then hit 'Enter' once. This will bring you to line 75 in the source code.&lt;br /&gt;
# Type &amp;lt;code&amp;gt;j 81&amp;lt;/code&amp;gt;. This is an alias for jump 81 that tells GDB to have the program jump to line 81 of the source code and resume execution at the first assembly instruction represented by line 81 of the source code. This line is labeled &amp;lt;code&amp;gt;&amp;lt;main.c+196&amp;gt;&amp;lt;/code&amp;gt;. Note that the program effectively no longer checks the input it receives.&lt;br /&gt;
# Type &amp;lt;code&amp;gt;i th&amp;lt;/code&amp;gt;. This will cause GDB to display a list of the application's threads currently in memory. Take a moment to consider what is happening in the program. We know that in Step 2 of this lesson we used &amp;lt;code&amp;gt;set scheduler-locking&amp;lt;/code&amp;gt; to tell GDB to effectively only allow the currently-selected thread of execution to be affected by the GDB &amp;lt;code&amp;gt;step&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;next&amp;lt;/code&amp;gt; commands. Others will wait at their respective breakpoints until explicitly told by the programmer to execute the next line of source code or instruction. The next breakpoint that &amp;lt;code&amp;gt;main&amp;lt;/code&amp;gt; reaches occurs after the &amp;lt;code&amp;gt;generator&amp;lt;/code&amp;gt; thread is created. This means that there are currently two threads of execution, the &amp;lt;code&amp;gt;main&amp;lt;/code&amp;gt; thread paused at line 97 and the &amp;lt;code&amp;gt;generator&amp;lt;/code&amp;gt; thread paused at line 143. &lt;br /&gt;
# Type &amp;lt;code&amp;gt;thread 2&amp;lt;/code&amp;gt;. This will select the &amp;lt;code&amp;gt;generator&amp;lt;/code&amp;gt; thread.&lt;br /&gt;
# Type &amp;lt;code&amp;gt;thread apply 2 n&amp;lt;/code&amp;gt;. This will tell the &amp;lt;code&amp;gt;generator&amp;lt;/code&amp;gt; thread to execute the next line of source code and pause again on the line following that. Without typing any other commands into the GDB prompt, hit 'Enter' seven more times. This should bring you to line 165 of the source code:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
usleep(1);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Notice the output of the program on the remote terminal on which &amp;lt;code&amp;gt;gdbserver&amp;lt;/code&amp;gt; was run. Standard output on that terminal should show the output from the &amp;lt;code&amp;gt;printf()&amp;lt;/code&amp;gt; call on line 154.&lt;br /&gt;
# Type &amp;lt;code&amp;gt;thread 1&amp;lt;/code&amp;gt;. This will select the &amp;lt;code&amp;gt;main&amp;lt;/code&amp;gt; thread.&lt;br /&gt;
# Type &amp;lt;code&amp;gt;continue&amp;lt;/code&amp;gt;. This will cause the &amp;lt;code&amp;gt;main&amp;lt;/code&amp;gt; thread to continue execution while &amp;lt;code&amp;gt;generator&amp;lt;/code&amp;gt; remains paused at line 165. &amp;lt;code&amp;gt;main&amp;lt;/code&amp;gt; pauses again at line 119, once the 7 &amp;lt;code&amp;gt;reader&amp;lt;/code&amp;gt; threads have been created. Recall from step 3.4 that &amp;lt;code&amp;gt;b 129&amp;lt;/code&amp;gt; set a breakpoint in the &amp;lt;code&amp;gt;reader&amp;lt;/code&amp;gt; function so that the &amp;lt;code&amp;gt;reader&amp;lt;/code&amp;gt; threads would pause at line 129.&lt;br /&gt;
# Type &amp;lt;code&amp;gt;i th&amp;lt;/code&amp;gt;. This is an alias for &amp;lt;code&amp;gt;info threads&amp;lt;/code&amp;gt;. This causes GDB to print out all the threads currently in memory. Notice that there are three types of threads, &amp;lt;code&amp;gt;main&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;generator&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;reader&amp;lt;/code&amp;gt;. The &amp;lt;code&amp;gt;info threads&amp;lt;/code&amp;gt; command also shows that the &amp;lt;code&amp;gt;reader&amp;lt;/code&amp;gt; threads are all paused at line 129, the &amp;lt;code&amp;gt;generator&amp;lt;/code&amp;gt; thread is paused at line 165, and the &amp;lt;code&amp;gt;main&amp;lt;/code&amp;gt; thread is paused at line 119.&lt;br /&gt;
# Type &amp;lt;code&amp;gt;thread 5&amp;lt;/code&amp;gt;. This will select the third &amp;lt;code&amp;gt;reader&amp;lt;/code&amp;gt; thread.&lt;br /&gt;
# Type &amp;lt;code&amp;gt;thread apply 5 n&amp;lt;/code&amp;gt;. Then press 'enter' seven times. This will cause the third &amp;lt;code&amp;gt;reader&amp;lt;/code&amp;gt; thread to complete its task and exit gracefully using the &amp;lt;code&amp;gt;pthread_exit()&amp;lt;/code&amp;gt; function.&lt;br /&gt;
# Type &amp;lt;code&amp;gt;thread 1&amp;lt;/code&amp;gt;. This will select the &amp;lt;code&amp;gt;main&amp;lt;/code&amp;gt; thread.&lt;br /&gt;
# Type &amp;lt;code&amp;gt;p data&amp;lt;/code&amp;gt;. This will show the current state of the data structure that was passed to each thread. Note that each thread contains a pointer to the same data structure. This requires the use of what is known as a mutex (MUTual EXclusion) variable which is used to protect the data structure from concurrent modifications. In other words, any time the data structure is read or written to by one of the threads, they must first call the function pthread_&amp;lt;code&amp;gt;mutex_lock()&amp;lt;/code&amp;gt; to ensure that no other thread currently “has” the lock. When a thread is done with the shared data structure, it calls the function &amp;lt;code&amp;gt;pthread_mutex_unlock()&amp;lt;/code&amp;gt; to make the lock available to other threads. Notice that nothing about the mutex's inclusion in the data structure requires it to be used in order to read or write to the data structure. This means that any programmer who wishes to use threads to implement concurrent programming must pay close attention to code that accesses shared data structures to ensure concurrent modifications do not occur.&lt;br /&gt;
# Perform the previous four steps for as many of the &amp;lt;code&amp;gt;reader&amp;lt;/code&amp;gt; threads as you want. Notice that each one prints a message to standard out providing information about the state of the shared &amp;lt;code&amp;gt;data&amp;lt;/code&amp;gt; variable at the time that it has the lock. By switching to the &amp;lt;code&amp;gt;generator&amp;lt;/code&amp;gt; thread once the mutex variable is unlocked, that code can be stepped through to generate a new random number for the data structure. IMPORTANT: Do not execute a line of source code containing a call to &amp;lt;code&amp;gt;pthread_mutex_lock()&amp;lt;/code&amp;gt; without first ensuring that the mutex variable is unlocked. To do this, carefully perform the following steps:&lt;br /&gt;
## Type &amp;lt;code&amp;gt;p data-&amp;amp;gt;lock&amp;lt;/code&amp;gt;. This will show the values of the mutex variable in the &amp;lt;code&amp;gt;data&amp;lt;/code&amp;gt; structure variable. Make note of the value of the &amp;lt;code&amp;gt;owner&amp;lt;/code&amp;gt; field.&lt;br /&gt;
## Type &amp;lt;code&amp;gt;i th&amp;lt;/code&amp;gt;. This will show the current list of threads in the program. What follows is a possible output from these two commands:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;gdb&amp;quot;&amp;gt;&lt;br /&gt;
(gdb) p data-&amp;gt;lock&lt;br /&gt;
$3 = {__data = {__lock = 1, __count = 0, __owner = 1288, __kind = 0, __nusers = 1, {__spins = 0, __list = {__next = 0x0}}},&lt;br /&gt;
  __size = &amp;quot;\001\000\000\000\000\000\000\000\b\005\000\000\000\000\000\000\001\000\000\000\000\000\000&amp;quot;, __align = 1}&lt;br /&gt;
(gdb) i th&lt;br /&gt;
  9 Thread 1289  reader (arg=0xbeddec8c) at pthread_demo.c:129&lt;br /&gt;
  8 Thread 1288  reader (arg=0xbeddec8c) at pthread_demo.c:134&lt;br /&gt;
  7 Thread 1287  reader (arg=0xbeddec8c) at pthread_demo.c:129&lt;br /&gt;
  6 Thread 1286  0x00008b04 in reader (arg=0xbeddec8c) at pthread_demo.c:129&lt;br /&gt;
  3 Thread 1283  0x00008b04 in reader (arg=0xbeddec8c) at pthread_demo.c:129&lt;br /&gt;
* 2 Thread 1282  generator (arg=0xbeddec8c) at pthread_demo.c:165&lt;br /&gt;
  1 Thread 1281  0x00008a64 in main (argc=2, argv=0xbeddee24) at pthread_demo.c:119&lt;br /&gt;
(gdb)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Analysis of this output requires the understanding that the third column of the &amp;lt;code&amp;gt;i th&amp;lt;/code&amp;gt; output indicates that particular thread's process ID. The important part of the &amp;lt;code&amp;gt;p data-&amp;amp;gt;lock&amp;lt;/code&amp;gt; output is the &amp;lt;code&amp;gt;owner&amp;lt;/code&amp;gt; field, whose value will always either be zero or correspond to the process ID of one of the currently-running threads. In this case, the lock-&amp;amp;gt;__owner field clearly indicates that thread 8 currently owns the data-&amp;amp;gt;lock mutex variable. This would indicate that thread 8 should be stepped through until it has called the &amp;lt;code&amp;gt;pthread_mutex_unlock()&amp;lt;/code&amp;gt; function before stepping into a call to &amp;lt;code&amp;gt;pthread_mutex_lock()&amp;lt;/code&amp;gt; in any other function.&lt;br /&gt;
To summarize, always ensure that the &amp;lt;code&amp;gt;owner&amp;lt;/code&amp;gt; field of the mutex variable is equal to zero before using &amp;lt;code&amp;gt;pthread_mutex_lock()&amp;lt;/code&amp;gt; while debugging. If the lock is currently owned by another thread, GDB will hang until sent an interrupt signal which will require that the entire debug process be started over.&lt;br /&gt;
# The walktrhough is complete. There are two ways to end the debug session gracefully:&lt;br /&gt;
** Type &amp;lt;code&amp;gt;monitor exit&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;kill&amp;lt;/code&amp;gt; (confirm with 'y'), then &amp;lt;code&amp;gt;quit&amp;lt;/code&amp;gt;.&lt;br /&gt;
** Type &amp;lt;code&amp;gt;set scheduler-locking off&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;delete&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;thread 1&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;continue&amp;lt;/code&amp;gt;, then &amp;lt;code&amp;gt;monitor exit&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;kill&amp;lt;/code&amp;gt; (confirm with 'y'), &amp;lt;code&amp;gt;quit&amp;lt;/code&amp;gt;. This will allow the program to finish executing before ending the session.&lt;br /&gt;
&lt;br /&gt;
===GNU GDB Documentation===&lt;br /&gt;
&lt;br /&gt;
Again, for more information on how to debug with GDB, refer to the [http://sourceware.org/gdb/current/onlinedocs/gdb.html GDB Manual]. This is a valuable resource for anyone just learning to debug software and will go into much greater detail than is possible in this guide.&lt;br /&gt;
&lt;br /&gt;
==Next Steps==&lt;br /&gt;
&lt;br /&gt;
If you have not done so already, be sure to check out the [[EMAC OE SDK Example Projects]] or learn to create your own [[New Project]].&lt;br /&gt;
&lt;br /&gt;
Also, give the [[EMAC Eclipse IDE]] a try. Sometimes it is simpler to use an IDE for large projects, especially with the ability to automate the makefile creation process.&lt;br /&gt;
&lt;br /&gt;
[[Category:EMAC OE SDK]]&lt;/div&gt;</summary>
		<author><name>Mcoleman</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.emacinc.com/index.php?title=Template:EMAC_OE_SDK_Conventions&amp;diff=465</id>
		<title>Template:EMAC OE SDK Conventions</title>
		<link rel="alternate" type="text/html" href="https://wiki.emacinc.com/index.php?title=Template:EMAC_OE_SDK_Conventions&amp;diff=465"/>
		<updated>2013-05-17T20:10:11Z</updated>

		<summary type="html">&lt;p&gt;Mcoleman: combining multi-article conventions&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{| class=&amp;quot;wikitable conventions&amp;quot;&lt;br /&gt;
!colspan=&amp;quot;2&amp;quot;|Table 1: Conventions&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;/download/directory/&amp;lt;/code&amp;gt; || Placeholder indicating the directory to which the SDK archive will be downloaded.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;/path/to/sdk/&amp;lt;/code&amp;gt; || Placeholder indicating the directory to which the SDK will be extracted.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;EMAC-OE-arm-linux-gnueabi-SDK_XX.YY.rZZ.tar.bz2&amp;lt;/code&amp;gt;&amp;lt;br /&amp;gt;&amp;lt;code&amp;gt;EMAC-OE-arm-linux-gnueabi-SDK_XX.YY&amp;lt;/code&amp;gt;&lt;br /&gt;
|| '''XX''' is the major version&amp;lt;br /&amp;gt;'''YY''' is the minor version&amp;lt;br /&amp;gt;'''ZZ''' is the current revision&amp;lt;br /&amp;gt;The major and minor version numbers will match the version of OE for which the SDK is created.&lt;br /&gt;
|-&lt;br /&gt;
| target_program || When debugging, the program being debugged. This is the result of the Makefile process&lt;br /&gt;
|-&lt;br /&gt;
| target_machine || Connection information for the target machine. This can either be a serial port (ie. /dev/ttyS2) or a TCP connection in the form of HOST:PORT. &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;developer@ldc:~$&amp;lt;/syntaxhighlight&amp;gt; || Prompt and commands to be run on a development machine that will run compliation tasks.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;root@emac-oe:~#&amp;lt;/syntaxhighlight&amp;gt; || Prompt and commands to be run on a target machine.&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Mcoleman</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.emacinc.com/index.php?title=Installing_EMAC_OE_4.0_SDK&amp;diff=464</id>
		<title>Installing EMAC OE 4.0 SDK</title>
		<link rel="alternate" type="text/html" href="https://wiki.emacinc.com/index.php?title=Installing_EMAC_OE_4.0_SDK&amp;diff=464"/>
		<updated>2013-05-17T20:06:37Z</updated>

		<summary type="html">&lt;p&gt;Mcoleman: templating conventions table&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{EMAC OE SDK Conventions}}&lt;br /&gt;
&lt;br /&gt;
Before beginning installation of the SDK, it is important to prepare the development system with the tools necessary to get the job done. These tools can either be command line interface (CLI) or graphical utilities. Both options are described in this guide.&lt;br /&gt;
&lt;br /&gt;
{{mbox | type = notice | style = margin-left: 0; margin-bottom: 1em; | text = The SDK archive and directory names will differ based on which SDK is being installed. For example, the toolchain binary names will reflect the target CPU architecture. What is shown in this guide is for demonstration's sake.}}&lt;br /&gt;
&lt;br /&gt;
== Required tools ==&lt;br /&gt;
* Web browser (recommended [https://www.mozilla.org/en-US/firefox/new/ Mozilla Firefox], [https://www.gnu.org/software/gnuzilla/ Gnuzilla Icecat], [http://www.konqueror.org/download/ KDE Konqueror])&lt;br /&gt;
* Archiving tool. There are two options available:&lt;br /&gt;
** Graphical tools ([[Ark]] for KDE, [[File Roller]] for GNOME)&lt;br /&gt;
** CLI tool ([[tar]] is standard)&lt;br /&gt;
* &amp;lt;code&amp;gt;dialog&amp;lt;/code&amp;gt; required for CLI use of SDK ([[see the developer's website]]).&lt;br /&gt;
&lt;br /&gt;
== Recommendations ==&lt;br /&gt;
The following are some recommended install opations&lt;br /&gt;
* The SDK should be kept in the user's home directory. For example, &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# /path/to/sdk/ might expand to something like &lt;br /&gt;
/home/user_name/cust_software/&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
To clarify, this is the location where &amp;lt;code&amp;gt;EMAC-OE-arm-linux-gnueabi-SDK_XX.YY/&amp;lt;/code&amp;gt; will end up.&lt;br /&gt;
* The default SDK root folder name should be kept at its default name since this preserves the version information for the EMAC OE SDK.&lt;br /&gt;
&lt;br /&gt;
== Procedure ==&lt;br /&gt;
# Download the SDK. The latest version can be found on the public EMAC FTP site. Be sure to download the SDK that matches the architecture of your target system. Contact EMAC if unsure.&lt;br /&gt;
# Uncompress the SDK.&lt;br /&gt;
** Using a graphical archiving tool, uncompress the archive files to the chosen development directory. If you need assistance with this, please see the documentation for your graphical archiving tool.&lt;br /&gt;
** Alternatively, you can uncompress the archive from the CLI using tar: &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ cd /target/directory&lt;br /&gt;
developer@ldc:~$ bzip2 -cd /download/directory/EMAC-OE-arm-linux-gnuabi-SDK_XX.YY.rZZ.tar.bz2 | tar xvf -&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
This will produce a subdirectory within the target directory:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ ls&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
EMAC-OE-arm-linux-gnueabi-SDK_XX.YY/&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Next Steps ==&lt;br /&gt;
Once the EMAC SDK is installed, the next step is to [[configure it]].&lt;br /&gt;
&lt;br /&gt;
[[Category:EMAC OE SDK]]&lt;/div&gt;</summary>
		<author><name>Mcoleman</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.emacinc.com/index.php?title=Template:EMAC_OE_SDK_Conventions&amp;diff=463</id>
		<title>Template:EMAC OE SDK Conventions</title>
		<link rel="alternate" type="text/html" href="https://wiki.emacinc.com/index.php?title=Template:EMAC_OE_SDK_Conventions&amp;diff=463"/>
		<updated>2013-05-17T20:06:13Z</updated>

		<summary type="html">&lt;p&gt;Mcoleman: init&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{| class=&amp;quot;wikitable conventions&amp;quot;&lt;br /&gt;
!colspan=&amp;quot;2&amp;quot;|Table 1: Conventions&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;/download/directory/&amp;lt;/code&amp;gt; || Placeholder indicating the directory to which the SDK archive will be downloaded.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;/path/to/sdk/&amp;lt;/code&amp;gt; || Placeholder indicating the directory to which the SDK will be extracted.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;EMAC-OE-arm-linux-gnueabi-SDK_XX.YY.rZZ.tar.bz2&amp;lt;/code&amp;gt;&amp;lt;br /&amp;gt;&amp;lt;code&amp;gt;EMAC-OE-arm-linux-gnueabi-SDK_XX.YY&amp;lt;/code&amp;gt;&lt;br /&gt;
|| '''XX''' is the major version&amp;lt;br /&amp;gt;'''YY''' is the minor version&amp;lt;br /&amp;gt;'''ZZ''' is the current revision&amp;lt;br /&amp;gt;The major and minor version numbers will match the version of OE for which the SDK is created.&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Mcoleman</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.emacinc.com/index.php?title=Installing_EMAC_OE_4.0_SDK&amp;diff=462</id>
		<title>Installing EMAC OE 4.0 SDK</title>
		<link rel="alternate" type="text/html" href="https://wiki.emacinc.com/index.php?title=Installing_EMAC_OE_4.0_SDK&amp;diff=462"/>
		<updated>2013-05-17T20:05:37Z</updated>

		<summary type="html">&lt;p&gt;Mcoleman: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Before beginning installation of the SDK, it is important to prepare the development system with the tools necessary to get the job done. These tools can either be command line interface (CLI) or graphical utilities. Both options are described in this guide.&lt;br /&gt;
&lt;br /&gt;
{{EMAC OE SDK Conventions}}&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable conventions&amp;quot;&lt;br /&gt;
!colspan=&amp;quot;2&amp;quot;|Table 1: Conventions&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;/download/directory/&amp;lt;/code&amp;gt; || Placeholder indicating the directory to which the SDK archive will be downloaded.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;/path/to/sdk/&amp;lt;/code&amp;gt; || Placeholder indicating the directory to which the SDK will be extracted.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;EMAC-OE-arm-linux-gnueabi-SDK_XX.YY.rZZ.tar.bz2&amp;lt;/code&amp;gt;&amp;lt;br /&amp;gt;&amp;lt;code&amp;gt;EMAC-OE-arm-linux-gnueabi-SDK_XX.YY&amp;lt;/code&amp;gt;&lt;br /&gt;
|| '''XX''' is the major version&amp;lt;br /&amp;gt;'''YY''' is the minor version&amp;lt;br /&amp;gt;'''ZZ''' is the current revision&amp;lt;br /&amp;gt;The major and minor version numbers will match the version of OE for which the SDK is created.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{{mbox | type = notice | style = margin-left: 0; margin-bottom: 1em; | text = The SDK archive and directory names will differ based on which SDK is being installed. For example, the toolchain binary names will reflect the target CPU architecture. What is shown in this guide is for demonstration's sake.}}&lt;br /&gt;
&lt;br /&gt;
== Required tools ==&lt;br /&gt;
* Web browser (recommended [https://www.mozilla.org/en-US/firefox/new/ Mozilla Firefox], [https://www.gnu.org/software/gnuzilla/ Gnuzilla Icecat], [http://www.konqueror.org/download/ KDE Konqueror])&lt;br /&gt;
* Archiving tool. There are two options available:&lt;br /&gt;
** Graphical tools ([[Ark]] for KDE, [[File Roller]] for GNOME)&lt;br /&gt;
** CLI tool ([[tar]] is standard)&lt;br /&gt;
* &amp;lt;code&amp;gt;dialog&amp;lt;/code&amp;gt; required for CLI use of SDK ([[see the developer's website]]).&lt;br /&gt;
&lt;br /&gt;
== Recommendations ==&lt;br /&gt;
The following are some recommended install opations&lt;br /&gt;
* The SDK should be kept in the user's home directory. For example, &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# /path/to/sdk/ might expand to something like &lt;br /&gt;
/home/user_name/cust_software/&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
To clarify, this is the location where &amp;lt;code&amp;gt;EMAC-OE-arm-linux-gnueabi-SDK_XX.YY/&amp;lt;/code&amp;gt; will end up.&lt;br /&gt;
* The default SDK root folder name should be kept at its default name since this preserves the version information for the EMAC OE SDK.&lt;br /&gt;
&lt;br /&gt;
== Procedure ==&lt;br /&gt;
# Download the SDK. The latest version can be found on the public EMAC FTP site. Be sure to download the SDK that matches the architecture of your target system. Contact EMAC if unsure.&lt;br /&gt;
# Uncompress the SDK.&lt;br /&gt;
** Using a graphical archiving tool, uncompress the archive files to the chosen development directory. If you need assistance with this, please see the documentation for your graphical archiving tool.&lt;br /&gt;
** Alternatively, you can uncompress the archive from the CLI using tar: &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ cd /target/directory&lt;br /&gt;
developer@ldc:~$ bzip2 -cd /download/directory/EMAC-OE-arm-linux-gnuabi-SDK_XX.YY.rZZ.tar.bz2 | tar xvf -&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
This will produce a subdirectory within the target directory:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ ls&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
EMAC-OE-arm-linux-gnueabi-SDK_XX.YY/&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Next Steps ==&lt;br /&gt;
Once the EMAC SDK is installed, the next step is to [[configure it]].&lt;br /&gt;
&lt;br /&gt;
[[Category:EMAC OE SDK]]&lt;/div&gt;</summary>
		<author><name>Mcoleman</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.emacinc.com/index.php?title=Building_Existing_Software_Packages_with_EMAC_OE_SDK&amp;diff=461</id>
		<title>Building Existing Software Packages with EMAC OE SDK</title>
		<link rel="alternate" type="text/html" href="https://wiki.emacinc.com/index.php?title=Building_Existing_Software_Packages_with_EMAC_OE_SDK&amp;diff=461"/>
		<updated>2013-05-17T20:01:44Z</updated>

		<summary type="html">&lt;p&gt;Mcoleman: adding category tag&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{| class=&amp;quot;wikitable conventions&amp;quot;&lt;br /&gt;
!colspan=&amp;quot;2&amp;quot;|Table 1: Conventions&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;/path/to/sdk/&amp;lt;/code&amp;gt; ||  Represents the development system path to the EMAC OE SDK.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;EMAC-OE-arm-linux-gnueabi-SDK_XX.YY.rZZ.tar.bz2&amp;lt;/code&amp;gt;&amp;lt;br /&amp;gt;&amp;lt;code&amp;gt;EMAC-OE-arm-linux-gnueabi-SDK_XX.YY&amp;lt;/code&amp;gt;&lt;br /&gt;
|| '''XX''' is the major version&amp;lt;br /&amp;gt;'''YY''' is the minor version&amp;lt;br /&amp;gt;'''ZZ''' is the current revision&amp;lt;br /&amp;gt;The major and minor version numbers will match the version of OE for which the SDK is created.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
It is very common to need to be able to build existing software projects for the target hardware rather than developing the software from scratch. This feature is especially important in an open source environment, where countless libraries and utilities are available for use and often times need to be compiled to match the target architecture. Fortunately, EMAC OE SDK toolchains are standard GCC packages designed and configured to make this process as easy as possible. In addition, most software projects are developed to allow for cross-platform development.&lt;br /&gt;
&lt;br /&gt;
This guide provides an overview of the most common tasks associated with compiling existing software projects using the SDK. Note, however, that build methods differ significantly depending on the project design. Refer to the project documentation or support for information on how to cross-compile the software; the EMAC OE SDK can be treated as a standard GCC toolchain in this respect. Table 1 below denotes some conventions used in this guide.&lt;br /&gt;
&lt;br /&gt;
==Makefile-based Projects==&lt;br /&gt;
&lt;br /&gt;
Some projects have a build system based on a set of makefiles that are responsible for compiling and packaging the software. In general, configuring these projects to compile using the EMAC OE SDK is a simple process. In some instances, the software designers may have included a variable in the makefile which allows a cross-compiler prefix setting. In other cases, the CC and other makefile variables can be modified to direct make to compile using the EMAC OE SDK.&lt;br /&gt;
&lt;br /&gt;
It may be advantageous to add the cross-compiler bin directory to the system PATH variable temporarily before compiling to simplify Makefile modifications. This can be done with a command such as the following:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ export PATH=$PATH:/path/to/sdk/EMAC-OE-arm-linux-gnueabi-SDK_XX.YY/gcc-4.2.4-arm-linux-gnueabi/bin&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{mbox | type = notice | text = Note that running the command above will only affect the current terminal session.}}&lt;br /&gt;
&lt;br /&gt;
===MTD Utilities Project Example===&lt;br /&gt;
&lt;br /&gt;
The MTD Utilities project &amp;lt;code&amp;gt;mtd-utils&amp;lt;/code&amp;gt; is a good example of a Makefile-based build system that can easily be built using the EMAC OE SDK. Follow the steps below to accomplish this task.&lt;br /&gt;
&lt;br /&gt;
{{mbox | type = notice | text = The instructions in this section are valid as of the master git branch on 4/09/11. Future source changes may impact the required steps for compilation.}}&lt;br /&gt;
&lt;br /&gt;
# Begin by downloading the mtd-utils source code. Assuming that git is installed on the development system, run the following command to get the most recent version. Note that this version will be different from the stable release installed on EMAC OE systems by default.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ git clone git://git.infradead.org/mtd-utils.git &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
# After downloading the source, navigate to the source directory &amp;lt;code&amp;gt;mtd-utils&amp;lt;/code&amp;gt; and open &amp;lt;code&amp;gt;Makefile&amp;lt;/code&amp;gt; in the top-level directory. This file defines various make targets and compilation flags used to compile the source. Notice that the file &amp;lt;code&amp;gt;common.mk&amp;lt;/code&amp;gt; is sourced with the line include &amp;lt;code&amp;gt;common.mk&amp;lt;/code&amp;gt;. This is similar to the &amp;lt;code&amp;gt;global.properties&amp;lt;/code&amp;gt; file in the EMAC OE SDK.&lt;br /&gt;
# Close the &amp;lt;code&amp;gt;Makefile&amp;lt;/code&amp;gt; editor and open the &amp;lt;code&amp;gt;common.mk&amp;lt;/code&amp;gt; file. At the top of the file, &amp;lt;code&amp;gt;CC&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;AR&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;RANLIB&amp;lt;/code&amp;gt; are defined using the &amp;lt;code&amp;gt;CROSS&amp;lt;/code&amp;gt; variable, which is not set in either &amp;lt;code&amp;gt;common.mk&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;Makefile&amp;lt;/code&amp;gt;. An exert is shown below:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;make&amp;quot;&amp;gt;&lt;br /&gt;
CC := $(CROSS)gcc&lt;br /&gt;
AR := $(CROSS)ar&lt;br /&gt;
RANLIB := $(CROSS)ranlib&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
If the &amp;lt;code&amp;gt;CROSS&amp;lt;/code&amp;gt; variable is defined when &amp;lt;code&amp;gt;make&amp;lt;/code&amp;gt; is run, the specific toolchain to use can be specified. Also note that &amp;lt;code&amp;gt;CFLAGS&amp;lt;/code&amp;gt; is defined using a &amp;lt;code&amp;gt;?=&amp;lt;/code&amp;gt; assignment, which means that the assignment will only be made if &amp;lt;code&amp;gt;CFLAGS&amp;lt;/code&amp;gt; is undefined:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;make&amp;quot;&amp;gt;&lt;br /&gt;
CFLAGS ?= -O2 -g&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
# Close &amp;lt;code&amp;gt;common.mk&amp;lt;/code&amp;gt; without making any changes.&lt;br /&gt;
# In order to compile the source correctly, the &amp;lt;code&amp;gt;CROSS&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;CFLAGS&amp;lt;/code&amp;gt; variables should be defined. The tuning flags for the target architecture to be added to the &amp;lt;code&amp;gt;CFLAGS&amp;lt;/code&amp;gt; variable should be used from the &amp;lt;code&amp;gt;ARCHFLAGS&amp;lt;/code&amp;gt; variable in the &amp;lt;code&amp;gt;global.properties&amp;lt;/code&amp;gt; file of the EMAC OE SDK. The following steps utilize tuning flags for an armv5te processor-based system. Although the path to the SDK toolchain could be included directly in the &amp;lt;code&amp;gt;CROSS&amp;lt;/code&amp;gt; variable in this instance, this example works by adding the SDK toolchain to the system &amp;lt;code&amp;gt;PATH&amp;lt;/code&amp;gt; variable. The path and prefix used will differ depending on the target architecture of the EMAC OE SDK; refer to &amp;lt;code&amp;gt;global.properties&amp;lt;/code&amp;gt; in the SDK to determine the correct settings. The &amp;lt;code&amp;gt;DESTDIR&amp;lt;/code&amp;gt; variable controls where the files are put when running the &amp;lt;code&amp;gt;install&amp;lt;/code&amp;gt; make target. The &amp;lt;code&amp;gt;WITHOUT_XATTR&amp;lt;/code&amp;gt; flag must be set to disable features of the software that are not available on EMAC OE.&lt;br /&gt;
## Before compiling, several source changes are required to match the setup of the SDK. These include changing references from &amp;lt;code&amp;gt;lzo2&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;lzo&amp;lt;/code&amp;gt;, and changing the lzo include prefix. Run the following commands from the mtd-utils directory to make these changes:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ for file in `find . -name Makefile`; do sed -i 's:lzo2:lzo:g' $file; done&lt;br /&gt;
developer@ldc:~$ for file in `find . -name '*.c'`; do sed -i 's:lzo/::g' $file; done&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
## Run the following commands to set the variables:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ export PATH=$PATH:/path/to/sdk/EMAC-OE-arm-linux-gnueabi-SDK_XX.YY/gcc-4.2.4-arm-linux-gnueabi/bin&lt;br /&gt;
developer@ldc:~$ export CROSS=arm-linux-gnueabi-&lt;br /&gt;
developer@ldc:~$ export CFLAGS=&amp;quot;-O2 -g -march=armv5te -mtune=arm926ej-s&amp;quot;&lt;br /&gt;
developer@ldc:~$ export DESTDIR=Install&lt;br /&gt;
developer@ldc:~$ export WITHOUT_XATTR=1&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
# Once the environment has been set up, &amp;lt;code&amp;gt;make&amp;lt;/code&amp;gt; can be used to compile the source code:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ make all&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
# After successfully compiling the project, the &amp;lt;code&amp;gt;install&amp;lt;/code&amp;gt; make target can be used to package all of the software into the &amp;lt;code&amp;gt;Install&amp;lt;/code&amp;gt; directory as specified by the &amp;lt;code&amp;gt;DESTDIR&amp;lt;/code&amp;gt; variable:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ make install&lt;br /&gt;
developer@ldc:~$ ls -R Install&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
Install:&lt;br /&gt;
usr&lt;br /&gt;
 &lt;br /&gt;
Install/usr:&lt;br /&gt;
sbin  share&lt;br /&gt;
 &lt;br /&gt;
Install/usr/sbin:&lt;br /&gt;
docfdisk      flash_erase     flash_lock      flash_unlock  jffs2dump   nanddump   nftldump     rfddump      sumtool&lt;br /&gt;
doc_loadbios  flash_eraseall  flash_otp_dump  ftl_check     mkfs.jffs2  nandtest   nftl_format  rfdformat&lt;br /&gt;
flashcp       flash_info      flash_otp_info  ftl_format    mtd_debug   nandwrite  recv_image   serve_image&lt;br /&gt;
 &lt;br /&gt;
Install/usr/share:&lt;br /&gt;
man&lt;br /&gt;
 &lt;br /&gt;
Install/usr/share/man:&lt;br /&gt;
man1&lt;br /&gt;
 &lt;br /&gt;
Install/usr/share/man/man1:&lt;br /&gt;
mkfs.jffs2.1.gz&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
While the procedure in this example is specific to &amp;lt;code&amp;gt;mtd-utils&amp;lt;/code&amp;gt;, many makefile-based projects will require similar steps for cross-compiling.&lt;br /&gt;
&lt;br /&gt;
==Autotools-based Projects==&lt;br /&gt;
&lt;br /&gt;
The GNU build system is known as Autotools. Autotools is a group of applications that are designed to provide a configurable build system to allow compilation on different platforms and environments. A &amp;lt;code&amp;gt;configure&amp;lt;/code&amp;gt; script and set of input files are used to generate makefiles based on options passed to the configure script and deduced from the system environment. This includes tests for compiler options, library functions, install configuration, and other assorted variables.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;configure&amp;lt;/code&amp;gt; script is the most important step in building an autotools-based project. Although available options for &amp;lt;code&amp;gt;configure&amp;lt;/code&amp;gt; vary depending on the project design, there are common options shared between most autotools projects. &lt;br /&gt;
&lt;br /&gt;
===libConfuse Example Project===&lt;br /&gt;
&lt;br /&gt;
The libConfuse project is a simple C library written for parsing configuration files. It uses an autotools build system for configuration. The steps below demonstrate how to build libConfuse and should be used as an example for building other autotools-based projects. &lt;br /&gt;
&lt;br /&gt;
# The source code for the libConfuse project can be downloaded as described on the project website [http://www.nongnu.org/confuse/]. For this example, release 2.7 is used: [http://savannah.nongnu.org/download/confuse/confuse-2.7.tar.gz]. After downloading the source, extract the archive and navigate to the top-level directory of the project (i.e. `confuse-2.7`).&lt;br /&gt;
# Read through the &amp;lt;code&amp;gt;README&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;INSTALL&amp;lt;/code&amp;gt; files for information on the project and general information on how to build it. Also, look at the help output from &amp;lt;code&amp;gt;configure&amp;lt;/code&amp;gt; to see a summary of the available options:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ ./configure --help&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
# Before beginning, the system &amp;lt;code&amp;gt;PATH&amp;lt;/code&amp;gt; variable should be changed to include the SDK toolchain as in the makefile-based project example. The &amp;lt;code&amp;gt;CFLAGS&amp;lt;/code&amp;gt; variable should also be set. If the &amp;lt;code&amp;gt;CC&amp;lt;/code&amp;gt; variable is set, it should be set to &amp;lt;code&amp;gt;arm-linux-gnueabi-gcc&amp;lt;/code&amp;gt; (or the appropriate value for the target); if not set the compiler name will be detected from the options passed to configure. The &amp;lt;code&amp;gt;CFLAGS&amp;lt;/code&amp;gt; architecture tuning values should be set according to the &amp;lt;code&amp;gt;global.properties&amp;lt;/code&amp;gt; file in the EMAC OE SDK. The &amp;lt;code&amp;gt;DESTDIR&amp;lt;/code&amp;gt; variable determines where the files will be installed to when the &amp;lt;code&amp;gt;install&amp;lt;/code&amp;gt; make target is run. &amp;lt;code&amp;gt;DESTDIR&amp;lt;/code&amp;gt; must be an absolute path for the libConfuse project, so the current working directory is added to the variable using the &amp;lt;code&amp;gt;pwd&amp;lt;/code&amp;gt; command. The following commands are an example of how to set up the environment correctly:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ export CFLAGS=&amp;quot;-O2 -march=armv5te -mtune=arm926ej-s&amp;quot;&lt;br /&gt;
developer@ldc:~$ export DESTDIR=`pwd`/Install&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
# After setting the environment, &amp;lt;code&amp;gt;configure&amp;lt;/code&amp;gt; can be run with the appropriate options to configure the build system and generate the makefiles. The code below shows an example configuration used by EMAC OE. Be sure to set the host and target correctly based on the architecture:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ ./configure --build=i686-linux --host=arm-linux-gnueabi --target=arm-linux-gnueabi \&lt;br /&gt;
        --prefix=/usr --exec_prefix=/usr --bindir=/usr/bin --sbindir=/usr/sbin \&lt;br /&gt;
        --datadir=/usr/share  \&lt;br /&gt;
        --infodir=/usr/share/info \&lt;br /&gt;
        --mandir=/usr/share/man --enable-shared&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The configuration should complete successfully. If any problems are reported that result in an error, check the environment settings and &amp;lt;code&amp;gt;configure&amp;lt;/code&amp;gt; options again. &lt;br /&gt;
# Now that &amp;lt;code&amp;gt;configure&amp;lt;/code&amp;gt; has generated all of the makefiles for the project, &amp;lt;code&amp;gt;make&amp;lt;/code&amp;gt; can be used to compile the source code:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ make all&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
If any errors are encountered during compilation, examine the output of &amp;lt;code&amp;gt;configure&amp;lt;/code&amp;gt; and make sure that all of the environment variables and &amp;lt;code&amp;gt;configure&amp;lt;/code&amp;gt; options were specified correctly. &lt;br /&gt;
# Once compilation is complete, the &amp;lt;code&amp;gt;install&amp;lt;/code&amp;gt; target can be used to package all of the necessary files together so that they can be transferred to the target board.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ make install&lt;br /&gt;
developer@ldc:~$ ls -R Install&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
Install:&lt;br /&gt;
usr&lt;br /&gt;
 &lt;br /&gt;
Install/usr:&lt;br /&gt;
include  lib  share&lt;br /&gt;
 &lt;br /&gt;
Install/usr/include:&lt;br /&gt;
confuse.h&lt;br /&gt;
 &lt;br /&gt;
Install/usr/lib:&lt;br /&gt;
libconfuse.a  libconfuse.la  libconfuse.so  libconfuse.so.0  libconfuse.so.0.0.0  pkgconfig&lt;br /&gt;
 &lt;br /&gt;
Install/usr/lib/pkgconfig:&lt;br /&gt;
libconfuse.pc&lt;br /&gt;
 &lt;br /&gt;
Install/usr/share:&lt;br /&gt;
locale&lt;br /&gt;
 &lt;br /&gt;
Install/usr/share/locale:&lt;br /&gt;
fr  sv&lt;br /&gt;
 &lt;br /&gt;
Install/usr/share/locale/fr:&lt;br /&gt;
LC_MESSAGES&lt;br /&gt;
 &lt;br /&gt;
Install/usr/share/locale/fr/LC_MESSAGES:&lt;br /&gt;
confuse.mo&lt;br /&gt;
 &lt;br /&gt;
Install/usr/share/locale/sv:&lt;br /&gt;
LC_MESSAGES&lt;br /&gt;
 &lt;br /&gt;
Install/usr/share/locale/sv/LC_MESSAGES:&lt;br /&gt;
confuse.mo&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Note that not all of the files installed would be necessary to install on the board, such as the man pages and pkgconfig information.&lt;br /&gt;
&lt;br /&gt;
[[Category:EMAC OE SDK]]&lt;/div&gt;</summary>
		<author><name>Mcoleman</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.emacinc.com/index.php?title=Remote_Debugging_EMAC_OE_SDK_Projects_with_gdbserver&amp;diff=460</id>
		<title>Remote Debugging EMAC OE SDK Projects with gdbserver</title>
		<link rel="alternate" type="text/html" href="https://wiki.emacinc.com/index.php?title=Remote_Debugging_EMAC_OE_SDK_Projects_with_gdbserver&amp;diff=460"/>
		<updated>2013-05-17T20:01:15Z</updated>

		<summary type="html">&lt;p&gt;Mcoleman: adding category tag&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{| class=&amp;quot;wikitable conventions&amp;quot;&lt;br /&gt;
!colspan=&amp;quot;2&amp;quot;|Table 1: Conventions&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;target_program&amp;lt;/code&amp;gt; || The name of the application being debugged. This is the result of the Makefile build process. &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;target_machine&amp;lt;/code&amp;gt; || Connection information for the target machine. This can either be a serial port (ie. &amp;lt;code&amp;gt;/dev/ttyS2&amp;lt;/code&amp;gt;) or a TCP connection in the form of HOST:PORT.  &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;/path/to/sdk/&amp;lt;/code&amp;gt; ||  Represents the development system path to the EMAC OE SDK. &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
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 binary resulting from the compile 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 while running the debugger.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
This guide is intended to build a basic understanding of how to use gdbserver with EMAC products. It is not intended as a general guide to debugging computer programs. For help with that, see the GDB man pages on the development system or read [this manual] on debugging with GDB.&lt;br /&gt;
&lt;br /&gt;
==Setup==&lt;br /&gt;
&lt;br /&gt;
Using &amp;lt;code&amp;gt;gdbserver&amp;lt;/code&amp;gt; involves setting up both the target machine and the development machine. This requires that the binary application be present on both development and target machines. The development machine copy of the application must be compiled with debug flags whereas this is not strictly necessary for the target machine. See the [Optional &amp;lt;code&amp;gt;global.properties&amp;lt;/code&amp;gt; Modifications Section] on the New EMAC OE SDK Project Guide for more information. See the [[[EMAC OE Getting Started Guide]]] for more information on how to connect to the target EMAC product using a serial port or Ethernet connection.&lt;br /&gt;
&lt;br /&gt;
===Target Machine===&lt;br /&gt;
&lt;br /&gt;
Because EMAC OE builds are distributed with &amp;lt;code&amp;gt;gdbserver&amp;lt;/code&amp;gt;, installation is not a concern. The only setup necessary is to run &amp;lt;code&amp;gt;gdbserver&amp;lt;/code&amp;gt; with &amp;lt;code&amp;gt;target_program&amp;lt;/code&amp;gt;: &lt;br /&gt;
&lt;br /&gt;
# If the target application is already running, use the attachpid option to connect &amp;lt;code&amp;gt;gdbserver&amp;lt;/code&amp;gt; to the application as shown below. The &amp;lt;code&amp;gt;PID&amp;lt;/code&amp;gt; argument can be determined using &amp;lt;code&amp;gt;pidof&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ pidof target_program&lt;br /&gt;
developer@ldc:~$ gdbserver target_machine --attach PID&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
# If the target application is not already running, the name of the binary may be included as an argument to the &amp;lt;code&amp;gt;gdbserver&amp;lt;/code&amp;gt; program call.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;snytaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ gdbserver target_machine target_program [ARGS]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This establishes a &amp;lt;code&amp;gt;gdbserver&amp;lt;/code&amp;gt; port on the target machine that listens for incoming connections from GDB on the development machine. In debug terminology, &amp;lt;code&amp;gt;gdbserver&amp;lt;/code&amp;gt; is “attached” to the process ID of the program being debugged. In reality, though, GDB is attached to the process ID of a proxy which passes the messages to and from the remote device under test. &lt;br /&gt;
&lt;br /&gt;
The next step is to run GDB on the development machine using the &amp;lt;code&amp;gt;target_program&amp;lt;/code&amp;gt;/&lt;br /&gt;
&lt;br /&gt;
===Development Machine===&lt;br /&gt;
&lt;br /&gt;
# First, &amp;lt;code&amp;gt;cd&amp;lt;/code&amp;gt; to the directory where the targe executable is stored.&lt;br /&gt;
# Run the EMAC OE SDK GDB:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ /path/to/sdk/EMAC-OE-arm-linux-gnueabi-SDK_4.0/gcc-4.2.4-arm-linux-gnueabi/bin/arm-linux-gnueabi-gdb target_program&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
# Run the following commands in GDB to prepare for the debug session:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;gdb&amp;quot;&amp;gt;&lt;br /&gt;
(gdb) target remote target_machine&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{mbox | type = warning | text = Note that the location of the GDB in the toolchain may differ from what is shown above depending on which version of the SDK is used.}}&lt;br /&gt;
&lt;br /&gt;
{{mbox | type = notice | text = If the gdb executable, or any other executable you run, is located in a directory which is in the PATH environment variable, you can simply run that command without the long path prefix. Sourcing the environment variables generated by the EMAC script for this will provide you with such a path. The script which creates the file to source also creates a symbolic link for arm-linux-gnueabi-gdb called, simply, gdb. With your shell environment setup this way, you could simply execute: &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ gdb target_program&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
in place of the long command given in step 2, above.&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
==Sample GDB Session==&lt;br /&gt;
&lt;br /&gt;
This example GDB session uses the EMAC OE SDK example project named &amp;lt;code&amp;gt;pthread_demo&amp;lt;/code&amp;gt;. It consists of the single source file &amp;lt;code&amp;gt;pthread_demo.c&amp;lt;/code&amp;gt;. The program is called with a single integer argument indicating how many &amp;lt;code&amp;gt;reader&amp;lt;/code&amp;gt; threads the user wishes to create. The following describes the tasks of the &amp;lt;code&amp;gt;main&amp;lt;/code&amp;gt; thread: &lt;br /&gt;
&lt;br /&gt;
# The &amp;lt;code&amp;gt;main&amp;lt;/code&amp;gt; thread performs user input validation. It prints a usage message according to the argument passed to it on the command line. The function expects the user to pass a number indicating how many threads should be spawned.&lt;br /&gt;
# The &amp;lt;code&amp;gt;main&amp;lt;/code&amp;gt; thread initiates a new thread which uses the &amp;lt;code&amp;gt;generator()&amp;lt;/code&amp;gt; function to perform the following tasks:&lt;br /&gt;
## Checks to see if the number of &amp;lt;code&amp;gt;reader&amp;lt;/code&amp;gt; threads matches the number of times a &amp;lt;code&amp;gt;reader&amp;lt;/code&amp;gt; thread has acquired the mutex lock and performed its task. If the two values do match, then the &amp;lt;code&amp;gt;generator&amp;lt;/code&amp;gt; thread unlocks the mutex, breaks out of the while loop and moves on to line 167 to gracefully exit. If the two values do not match, then the &amp;lt;code&amp;gt;generator&amp;lt;/code&amp;gt; thread continues through the rest of the while loop described in steps 2.2 and 2.3.&lt;br /&gt;
## Generates random data to be stored in the data struct shared by all the threads. To do this, it protects the data struct with the use of a mutex variable.&lt;br /&gt;
## Sleeps after giving up its lock on the mutex so that another thread might have a chance to acquire the lock.&lt;br /&gt;
# After creating the &amp;lt;code&amp;gt;generator&amp;lt;/code&amp;gt; thread the &amp;lt;code&amp;gt;main&amp;lt;/code&amp;gt; thread iteratively creates as many &amp;lt;code&amp;gt;reader&amp;lt;/code&amp;gt; threads as indicated by the single integer argument. Each &amp;lt;code&amp;gt;reader&amp;lt;/code&amp;gt; thread performs the following tasks:&lt;br /&gt;
## Waits for a chance to acquire the mutex &amp;lt;code&amp;gt;lock&amp;lt;/code&amp;gt;. Once the mutex &amp;lt;code&amp;gt;lock&amp;lt;/code&amp;gt; is acquired, it prints the value of the random number &amp;lt;code&amp;gt;generated&amp;lt;/code&amp;gt; by the generator thread in its last run.&lt;br /&gt;
## Increments an integer in the &amp;lt;code&amp;gt;data&amp;lt;/code&amp;gt; struct to indicate that it has completed its task.&lt;br /&gt;
## Gives up its lock on the mutex and exits.&lt;br /&gt;
# After creating the prescribed number of &amp;lt;code&amp;gt;reader&amp;lt;/code&amp;gt; threads, the &amp;lt;code&amp;gt;main&amp;lt;/code&amp;gt; thread then waits for each thread created to exit gracefully. &lt;br /&gt;
# The &amp;lt;code&amp;gt;main&amp;lt;/code&amp;gt; thread exists.&lt;br /&gt;
&lt;br /&gt;
The SDK version of &amp;lt;code&amp;gt;pthread_demo.c&amp;lt;/code&amp;gt; works according to the description above with a &amp;lt;code&amp;gt;MAX_THREAD&amp;lt;/code&amp;gt; value of 100. However, for the purpose of this example debug session it is instructive to use a faulty version of the same program. Replace lines 75-80 in &amp;lt;code&amp;gt;pthread_demo.c&amp;lt;/code&amp;gt; with the code snippet shown in Listing 1 below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
if ((data.num_threads &amp;lt; 1) || (data.num_threads &amp;lt; MAX_THREAD)) {&lt;br /&gt;
        fprintf(stderr,&lt;br /&gt;
                &amp;quot;The number of thread should between 1 and %d\n&amp;quot;,&lt;br /&gt;
                MAX_THREAD);&lt;br /&gt;
        exit(EXIT_FAILURE);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Useful GDB Commands===&lt;br /&gt;
&lt;br /&gt;
The following is a brief description of some essential GDB commands. Each description is followed by a link to the official GDB documentation page that has more specific information about what the command does and how to use it. Please note that the official GDB documentation is targeted for the latest GDB release which at the time of writing this documentation is 7.4. The version of GDB that EMAC distributes with the OE products, however, is version 6.8. Because of this, the links to documentation below may provide slightly different information. The biggest difference between the two version of GDB, however, is in the support for debugging programs with multiple threads. This is reflected in the documentation as well. Because of this, EMAC has set up ftp access to GDB 6.8 documentation on its web server. It is highly recommended that the GDB 6.8 documentation be referenced in cases where the program does not seem to support commands or options specified in the current official documentation. &lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Command !! Description &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;start/run&amp;lt;/code&amp;gt;&lt;br /&gt;
|| These commands are used to start the debugged program with the only difference being that start automatically pauses execution at the beginning of the program's main function whereas run must be told explicitly where to pause using the breakpoint command listed below.&lt;br /&gt;
See also [Debugging with GDB, Section 4.2: Starting your Program]&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;kill&amp;lt;/code&amp;gt;&lt;br /&gt;
|| Used to kill the currently-running instance of target_program.&lt;br /&gt;
See also [Debugging with GDB, Section 4.9: Killing the Child Process]&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;print&amp;lt;/code&amp;gt;&lt;br /&gt;
|| Used to print the value of an expression.&lt;br /&gt;
See also [Debugging with GDB, Section 10: Examining Data]&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;list&amp;lt;/code&amp;gt;&lt;br /&gt;
|| List contents of function or specified line.&lt;br /&gt;
See also [Debugging with GDB, Section 9: Examining Source Files]&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;layout&amp;lt;/code&amp;gt;&lt;br /&gt;
|| This is a TUI (Text User Interface) command that enables the programmer to view multiple debug views at once including source code, assembly, and registers.&lt;br /&gt;
See also [Debugging with GDB, Section 25.4: TUI Commands]&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;disassemble&amp;lt;/code&amp;gt;&lt;br /&gt;
|| This command allows the programmer to see assembler instructions.&lt;br /&gt;
See also [Debugging with GDB, Section 9.6: Source and Machine Code]&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;break&amp;lt;/code&amp;gt;&lt;br /&gt;
|| This command specifies a function name, line number, or instruction at which GDB is to pause execution.&lt;br /&gt;
See also [Debugging with GDB, Section 5.1: Breakpoints]&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;next/nexti, step/stepi&amp;lt;/code&amp;gt;&lt;br /&gt;
|| Allow the programmer to step through a program without specifying breakpoints. The &amp;lt;code&amp;gt;next/nexti&amp;lt;/code&amp;gt; commands step over function calls, stopping on the next line of the same stack frame; &amp;lt;code&amp;gt;step/stepi&amp;lt;/code&amp;gt;, step into function calls, stopping on the first line in the next stack frame. The difference between &amp;lt;code&amp;gt;step/next&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;stepi/nexti&amp;lt;/code&amp;gt; is that the &amp;lt;code&amp;gt;i&amp;lt;/code&amp;gt; indicates instruction-by-instruction stepping at the assembly language level.&lt;br /&gt;
See also [Debugging with GDB, Section 5.2: Continuing and Stepping]&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;continue&amp;lt;/code&amp;gt;&lt;br /&gt;
|| Used to continue program execution from the address where it was last stopped.&lt;br /&gt;
See the Debugging with GDB link for &amp;lt;code&amp;gt;next/step&amp;lt;/code&amp;gt; for more information about the &amp;lt;code&amp;gt;continue&amp;lt;/code&amp;gt; command.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;bt&amp;lt;/code&amp;gt;&lt;br /&gt;
|| Short for &amp;quot;backtrace,&amp;quot; which displays to the programmer a brief summary of execution up to the current point in the program. This is useful because it shows a nested list of stack frames starting with the current one.&lt;br /&gt;
See also [Debugging with GDB, Section 8.2: Backtrace]&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;quit&amp;lt;/code&amp;gt;&lt;br /&gt;
||  This will quit the debugging session, and return you to the shell. The Control-D key combination is another way to accomplish this.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Session Walk-through===&lt;br /&gt;
&lt;br /&gt;
This debug session walk-through assumes that the program has been compiled using the modified source code above and that both the target machine and the development machine have been set up according to the above Setup section. The walk-through is divided into multiple “lessons” with the intent of first introducing the use of the commands described above and then actually running GDB to debug a known programming problem. Each lesson may be run independently of the others, but it is recommended that each be run in order starting from Lesson 1 for the first time through.&lt;br /&gt;
&lt;br /&gt;
====Lesson 1: Navigation and Code Display====&lt;br /&gt;
&lt;br /&gt;
This lesson assumes that &amp;lt;code&amp;gt;gdbserver&amp;lt;/code&amp;gt; has been run as in the [Target Machine Setup] section above with an ARG value of 3. Other values are fine so long as they fall within the range of 1 to 100. The number '3' was arbitrarily chosen to avoid having to use a symbolic variable in the explanations below.&lt;br /&gt;
&lt;br /&gt;
# Type &amp;lt;code&amp;gt;b main&amp;lt;/code&amp;gt; to set a breakpoint at the main function in the source code.&lt;br /&gt;
# Type &amp;lt;code&amp;gt;continue&amp;lt;/code&amp;gt;. This will cause the program to continue from the breakpoint set by GDB at startup. The program was passed an argument of 3, indicating that three threads should be created. &lt;br /&gt;
# Type &amp;lt;code&amp;gt;b 73&amp;lt;/code&amp;gt; to set a breakpoint at line 73 in the source code, which should be the line containing &amp;lt;code&amp;gt;data.num_threads = atoi(argv[1]);&amp;lt;/code&amp;gt;&lt;br /&gt;
# Type &amp;lt;code&amp;gt;continue&amp;lt;/code&amp;gt;. The program will continue execution up until line 73 in the source code. At this point, type layout split to view a split screen containing both the source code and the assembly-level machine instructions. Both screens show the program's current location in execution. The assembly-level display shows what the target's processor is actually executing at that point in the source code as shown in the source-level display. To view either of these without the other type layout &amp;lt;code&amp;gt;asm&amp;lt;/code&amp;gt; for just assembly-level and &amp;lt;code&amp;gt;layout src&amp;lt;/code&amp;gt; for just source-level.&lt;br /&gt;
# Type &amp;lt;code&amp;gt;nexti&amp;lt;/code&amp;gt;. This will cause the program to execute the next instruction in the current stack frame which is a mov instruction beginning to prepare the current stack for a call to the library function &amp;lt;code&amp;gt;atoi()&amp;lt;/code&amp;gt;. The details of this process are beyond the scope of this tutorial; essentially, the program needs to store information about the current execution location in the stack for when the &amp;lt;code&amp;gt;atoi()&amp;lt;/code&amp;gt; function finishes. Type &amp;lt;code&amp;gt;ni&amp;lt;/code&amp;gt; (alias for nexti) three more times. You should end up on a &amp;lt;code&amp;gt;bl&amp;lt;/code&amp;gt; instruction in the assembly view as shown in Listing 2 below. The source layout should still show the program on line 73.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;asm&amp;quot;&amp;gt;&lt;br /&gt;
B+ |0x887c &amp;lt;main+112&amp;gt;       ldr    r3, [r11, #-84]                   │&lt;br /&gt;
   |0x8880 &amp;lt;main+116&amp;gt;       add    r3, r3, #4      ; 0x4             │&lt;br /&gt;
   |0x8884 &amp;lt;main+120&amp;gt;       ldr    r3, [r3]                          │&lt;br /&gt;
   |0x8888 &amp;lt;main+124&amp;gt;       mov    r0, r3                            │&lt;br /&gt;
  &amp;gt;|0x888c &amp;lt;main+128&amp;gt;       bl     0x86e0 &amp;lt;atoi&amp;gt;                     │&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
'''Listing 2. GDB Assembly Layout''' - ''Note that the assembly may look different depending on the target architecture.''&lt;br /&gt;
# Type &amp;lt;code&amp;gt;stepi&amp;lt;/code&amp;gt;. This will cause the program to move into the next stack frame and GDB to show the assembly-level instructions of the &amp;lt;code&amp;gt;atoi()&amp;lt;/code&amp;gt; call. Since the library containing &amp;lt;code&amp;gt;atoi()&amp;lt;/code&amp;gt; was likely not compiled with debug symbols, the source-level layout will show the message &amp;lt;code&amp;gt;[ No Source Available ]&amp;lt;/code&amp;gt;.&lt;br /&gt;
# Type &amp;lt;code&amp;gt;bt&amp;lt;/code&amp;gt;. This will cause the program to display a human-readable version of the current stack. Each stack “frame” is represented by the name of the function call it represents with that function's location in memory. Type &amp;lt;code&amp;gt;bt full&amp;lt;/code&amp;gt; to get a list of the variables local to each stack frame.&lt;br /&gt;
# Type &amp;lt;code&amp;gt;finish&amp;lt;/code&amp;gt;. This will cause the current stack frame to return and execution to pause on the next instruction of the previous stack frame.&lt;br /&gt;
# Type &amp;lt;code&amp;gt;kill&amp;lt;/code&amp;gt;. This will cause the current process to be killed by &amp;lt;code&amp;gt;gdbserver&amp;lt;/code&amp;gt; at the target machine. &amp;lt;code&amp;gt;gdbserver&amp;lt;/code&amp;gt; will also terminate at this point. In order to start a new remote debug session, start gdbserver as described in the Target Machine Setup section and re-run step 3 of the [Development Machine Setup] section.&lt;br /&gt;
&lt;br /&gt;
{{mbox | type = warning | text = '''Note:''' &amp;lt;code&amp;gt;b&amp;lt;/code&amp;gt; is an alias for the &amp;lt;code&amp;gt;break&amp;lt;/code&amp;gt; command. &lt;br /&gt;
&amp;lt;code&amp;gt;ni&amp;lt;/code&amp;gt; is an alias for &amp;lt;code&amp;gt;nexti&amp;lt;/code&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
====Lesson 2: Finding the Bug====&lt;br /&gt;
&lt;br /&gt;
Though this sample is contrived, it is still useful to demonstrate how to find a design mistake in an otherwise well-written (no errors or warnings) program. These types of mistakes typically have to do with the array boundary miscalculations, logic and comparison operator mistakes, or other simple mistakes. For the sake of demonstration, assume that the actual mistake is unknown. This lesson assumes that gdbserver has just been started as in the [Target Machine] Setup above with an &amp;lt;code&amp;gt;ARG&amp;lt;/code&amp;gt; value of 5.&lt;br /&gt;
&lt;br /&gt;
# Before starting the program in the debugger again, run it by itself on the target machine to see what the actual program output is: &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@emac-oe:~# /tmp/pthread_demo 5&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
The number of threads should be between 1 and 100&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The program was given an input of '5' yet the output message seems to indicate that this is out of range which is obviously not true.&lt;br /&gt;
# Start the debugger again and connect to the target machine as described in the Setup section.&lt;br /&gt;
# Type &amp;lt;code&amp;gt;b main&amp;lt;/code&amp;gt; to set a breakpoint at the main function in the source code.&lt;br /&gt;
# Type &amp;lt;code&amp;gt;continue&amp;lt;/code&amp;gt;. This will cause the program to continue from the breakpoint set by GDB at startup. &lt;br /&gt;
# Type &amp;lt;code&amp;gt;n&amp;lt;/code&amp;gt;. This will cause the program to step over the next line of source code. The reason for using &amp;lt;code&amp;gt;n&amp;lt;/code&amp;gt; rather than &amp;lt;code&amp;gt;s&amp;lt;/code&amp;gt; or one of the instruction stepping commands is because the erroneous output indicates that the coding mistake is in the programmer's source code rather than the c library functions &amp;lt;code&amp;gt;atoi()&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;fprintf()&amp;lt;/code&amp;gt;. Stepping over the function will save all the time required to step through every detail of what the library functions are doing. Later passes through the code can be used to step into functions called from within that stack frame if the first pass proves unsuccessful.&lt;br /&gt;
# Continue to type &amp;lt;code&amp;gt;n&amp;lt;/code&amp;gt; until one of the program's &amp;lt;code&amp;gt;exit()&amp;lt;/code&amp;gt; calls is reached, but do not actually step into that &amp;lt;code&amp;gt;exit()&amp;lt;/code&amp;gt; call. Judging by the program's output above, this should bring you to the conditional block that checks the value of the local variable n used to store the output of &amp;lt;code&amp;gt;atoi()&amp;lt;/code&amp;gt; as shown in Listing 3. Note that once execution reaches line 79 of the source code, GDB will display the output of the &amp;lt;code&amp;gt;fprintf()&amp;lt;/code&amp;gt; function from line 76. This may cause display problems within the text-based UI library that GDB uses which will require the command refresh to fix.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;gdb&amp;quot;&amp;gt;&lt;br /&gt;
B+ |75              if ((data.num_threads &amp;lt; 1) || (data.num_threads &amp;lt; MAX_THREAD)) {       |&lt;br /&gt;
   |76                      fprintf(stderr,                                                |&lt;br /&gt;
   |77                              &amp;quot;The number of thread should between 1 and %d\n&amp;quot;,      |&lt;br /&gt;
   |78                              MAX_THREAD);                                           |&lt;br /&gt;
  &amp;gt;|79                      exit(EXIT_FAILURE);                                            |&lt;br /&gt;
   |80              }                                                                      |&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
# Type &amp;lt;code&amp;gt;p/d data→num_threads&amp;lt;/code&amp;gt;. &amp;lt;code&amp;gt;p&amp;lt;/code&amp;gt; is an alias for &amp;lt;code&amp;gt;print&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;/d&amp;lt;/code&amp;gt; tells GDB to treat the expression requested as an integer in signed decimal, and &amp;lt;code&amp;gt;data→num&amp;lt;/code&amp;gt;_threads is the element &amp;lt;code&amp;gt;num_threads&amp;lt;/code&amp;gt; within &amp;lt;code&amp;gt;struct thread_data&amp;lt;/code&amp;gt;. This should provide the following output:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;gdb&amp;quot;&amp;gt;&lt;br /&gt;
(gdb) p/d data-&amp;gt;num_threads&lt;br /&gt;
$6 = 5&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Note that the integer part of &amp;lt;code&amp;gt;$6&amp;lt;/code&amp;gt; will increment with each call to the gdb command &amp;lt;code&amp;gt;print&amp;lt;/code&amp;gt;. The above output confirms that the argument '5' was successfully passed to the program and read into a variable to be tested, indicating that one of the logical tests for the current conditional block contains a mistake. This merits a closer look at line 75:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;gdb&amp;quot;&amp;gt;&lt;br /&gt;
B+ |75              if ((data.num_threads &amp;lt; 1) || (data.num_threads &amp;lt; MAX_THREAD)) {       |&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Line 75 consists of a conditional test which is the logical OR of two arithmetic tests involving the values of &amp;lt;code&amp;gt;data.num_threads&amp;lt;/code&amp;gt;, '1', and &amp;lt;code&amp;gt;MAX_THREAD&amp;lt;/code&amp;gt;. The first test is true the input integer is less than &amp;lt;code&amp;gt;1–(data.num_threads &amp;amp;lt; 1)&amp;lt;/code&amp;gt;. The second tests whether the input integer is less than the symbolic constant, &amp;lt;code&amp;gt;MAX_THREAD–(data.num_threads &amp;amp;lt; MAX_THREAD)&amp;lt;/code&amp;gt;. Judging by the name of this constant and the result of the test (we know it resolves to true because the value of &amp;lt;code&amp;gt;data.num_threads&amp;lt;/code&amp;gt; in this case is not less than one), we can see that the comparison operator used is the culprit. The correct interpretation is that it should be '&amp;amp;gt;' rather than '&amp;amp;lt;'.&lt;br /&gt;
# Type &amp;lt;code&amp;gt;kill&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
This was a simple problem to solve but the method used above could apply in any situation where source code compiles and runs without errors yet provides varied or unexpected output.&lt;br /&gt;
&lt;br /&gt;
====Lesson 3: Debugging With Threads====&lt;br /&gt;
&lt;br /&gt;
Do not fix the programming mistake found in Lesson 2. This lesson will cover the use of the jump command to skip blocks of code and commands specific to debugging multi-threaded programs. Before getting started, see [http://sourceware.org/gdb/current/onlinedocs/gdb/Thread-Stops.html#Thread-Stops Debugging with GDB: 5. Stopping and Starting Multi-thread Programs].&lt;br /&gt;
&lt;br /&gt;
This lesson assumes that &amp;lt;code&amp;gt;gdbserver&amp;lt;/code&amp;gt; has just been started as in the Target Machine Setup above with an &amp;lt;code&amp;gt;ARG&amp;lt;/code&amp;gt; value of 7.&lt;br /&gt;
&lt;br /&gt;
# Start the debugger again and connect to the target machine as described in the Setup section.&lt;br /&gt;
# Type set &amp;lt;code&amp;gt;scheduler-locking&amp;lt;/code&amp;gt; on. This command enables GDB to lock all threads save for the currently-selected thread from running when the &amp;lt;code&amp;gt;step/stepi&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;next/nexti&amp;lt;/code&amp;gt; commands are given. &lt;br /&gt;
# Set all the breakpoints that you will need for this session: &lt;br /&gt;
## Type &amp;lt;code&amp;gt;b main&amp;lt;/code&amp;gt; to set a breakpoint at the main function in the source code.&lt;br /&gt;
## Type &amp;lt;code&amp;gt;b 75&amp;lt;/code&amp;gt;. This will set a break point at the conditional block that checks the value of the program's single integer argument. If you recall from Lesson 2, this is the conditional which evaluates incorrectly in the modified version of the application.&lt;br /&gt;
## Type &amp;lt;code&amp;gt;b 143&amp;lt;/code&amp;gt;. This will set a breakpoint in the variable assignment in the &amp;lt;code&amp;gt;generator&amp;lt;/code&amp;gt; function. Careful examination of the source code will show that this function is called from a thread created by the main thread of execution but never from the main thread itself.&lt;br /&gt;
## Type &amp;lt;code&amp;gt;b 129&amp;lt;/code&amp;gt;. This will set a breakpoint in the variable assignment of the &amp;lt;code&amp;gt;reader&amp;lt;/code&amp;gt; function. As with the &amp;lt;code&amp;gt;generator&amp;lt;/code&amp;gt; function, any time the &amp;lt;code&amp;gt;reader&amp;lt;/code&amp;gt; function is called it will be inside a thread that is not the main thread.&lt;br /&gt;
## Type &amp;lt;code&amp;gt;b 135&amp;lt;/code&amp;gt;. This will set a breakpoint just after the &amp;lt;code&amp;gt;fflush(stdout)&amp;lt;/code&amp;gt; statement in the &amp;lt;code&amp;gt;reader&amp;lt;/code&amp;gt; function.&lt;br /&gt;
## Type &amp;lt;code&amp;gt;b 97&amp;lt;/code&amp;gt;. This will set a breakpoint in the main thread after the &amp;lt;code&amp;gt;generator&amp;lt;/code&amp;gt; thread has been created but before the main thread begins creating &amp;lt;code&amp;gt;reader&amp;lt;/code&amp;gt; threads.&lt;br /&gt;
## Type &amp;lt;code&amp;gt;b 119&amp;lt;/code&amp;gt;. This will set a breakpoint after the main thread iteratively creates the &amp;lt;code&amp;gt;reader&amp;lt;/code&amp;gt; threads.&lt;br /&gt;
# Optional: You may want to run the &amp;lt;code&amp;gt;layout split&amp;lt;/code&amp;gt; command so that you can see both the assembly and the source code during the debug session.&lt;br /&gt;
# Type &amp;lt;code&amp;gt;continue&amp;lt;/code&amp;gt; then hit 'Enter' once. This will bring you to line 75 in the source code.&lt;br /&gt;
# Type &amp;lt;code&amp;gt;j 81&amp;lt;/code&amp;gt;. This is an alias for jump 81 that tells GDB to have the program jump to line 81 of the source code and resume execution at the first assembly instruction represented by line 81 of the source code. This line is labeled &amp;lt;code&amp;gt;&amp;lt;main.c+196&amp;gt;&amp;lt;/code&amp;gt;. Note that the program effectively no longer checks the input it receives.&lt;br /&gt;
# Type &amp;lt;code&amp;gt;i th&amp;lt;/code&amp;gt;. This will cause GDB to display a list of the application's threads currently in memory. Take a moment to consider what is happening in the program. We know that in Step 2 of this lesson we used &amp;lt;code&amp;gt;set scheduler-locking&amp;lt;/code&amp;gt; to tell GDB to effectively only allow the currently-selected thread of execution to be affected by the GDB &amp;lt;code&amp;gt;step&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;next&amp;lt;/code&amp;gt; commands. Others will wait at their respective breakpoints until explicitly told by the programmer to execute the next line of source code or instruction. The next breakpoint that &amp;lt;code&amp;gt;main&amp;lt;/code&amp;gt; reaches occurs after the &amp;lt;code&amp;gt;generator&amp;lt;/code&amp;gt; thread is created. This means that there are currently two threads of execution, the &amp;lt;code&amp;gt;main&amp;lt;/code&amp;gt; thread paused at line 97 and the &amp;lt;code&amp;gt;generator&amp;lt;/code&amp;gt; thread paused at line 143. &lt;br /&gt;
# Type &amp;lt;code&amp;gt;thread 2&amp;lt;/code&amp;gt;. This will select the &amp;lt;code&amp;gt;generator&amp;lt;/code&amp;gt; thread.&lt;br /&gt;
# Type &amp;lt;code&amp;gt;thread apply 2 n&amp;lt;/code&amp;gt;. This will tell the &amp;lt;code&amp;gt;generator&amp;lt;/code&amp;gt; thread to execute the next line of source code and pause again on the line following that. Without typing any other commands into the GDB prompt, hit 'Enter' seven more times. This should bring you to line 165 of the source code:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
usleep(1);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Notice the output of the program on the remote terminal on which &amp;lt;code&amp;gt;gdbserver&amp;lt;/code&amp;gt; was run. Standard output on that terminal should show the output from the &amp;lt;code&amp;gt;printf()&amp;lt;/code&amp;gt; call on line 154.&lt;br /&gt;
# Type &amp;lt;code&amp;gt;thread 1&amp;lt;/code&amp;gt;. This will select the &amp;lt;code&amp;gt;main&amp;lt;/code&amp;gt; thread.&lt;br /&gt;
# Type &amp;lt;code&amp;gt;continue&amp;lt;/code&amp;gt;. This will cause the &amp;lt;code&amp;gt;main&amp;lt;/code&amp;gt; thread to continue execution while &amp;lt;code&amp;gt;generator&amp;lt;/code&amp;gt; remains paused at line 165. &amp;lt;code&amp;gt;main&amp;lt;/code&amp;gt; pauses again at line 119, once the 7 &amp;lt;code&amp;gt;reader&amp;lt;/code&amp;gt; threads have been created. Recall from step 3.4 that &amp;lt;code&amp;gt;b 129&amp;lt;/code&amp;gt; set a breakpoint in the &amp;lt;code&amp;gt;reader&amp;lt;/code&amp;gt; function so that the &amp;lt;code&amp;gt;reader&amp;lt;/code&amp;gt; threads would pause at line 129.&lt;br /&gt;
# Type &amp;lt;code&amp;gt;i th&amp;lt;/code&amp;gt;. This is an alias for &amp;lt;code&amp;gt;info threads&amp;lt;/code&amp;gt;. This causes GDB to print out all the threads currently in memory. Notice that there are three types of threads, &amp;lt;code&amp;gt;main&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;generator&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;reader&amp;lt;/code&amp;gt;. The &amp;lt;code&amp;gt;info threads&amp;lt;/code&amp;gt; command also shows that the &amp;lt;code&amp;gt;reader&amp;lt;/code&amp;gt; threads are all paused at line 129, the &amp;lt;code&amp;gt;generator&amp;lt;/code&amp;gt; thread is paused at line 165, and the &amp;lt;code&amp;gt;main&amp;lt;/code&amp;gt; thread is paused at line 119.&lt;br /&gt;
# Type &amp;lt;code&amp;gt;thread 5&amp;lt;/code&amp;gt;. This will select the third &amp;lt;code&amp;gt;reader&amp;lt;/code&amp;gt; thread.&lt;br /&gt;
# Type &amp;lt;code&amp;gt;thread apply 5 n&amp;lt;/code&amp;gt;. Then press 'enter' seven times. This will cause the third &amp;lt;code&amp;gt;reader&amp;lt;/code&amp;gt; thread to complete its task and exit gracefully using the &amp;lt;code&amp;gt;pthread_exit()&amp;lt;/code&amp;gt; function.&lt;br /&gt;
# Type &amp;lt;code&amp;gt;thread 1&amp;lt;/code&amp;gt;. This will select the &amp;lt;code&amp;gt;main&amp;lt;/code&amp;gt; thread.&lt;br /&gt;
# Type &amp;lt;code&amp;gt;p data&amp;lt;/code&amp;gt;. This will show the current state of the data structure that was passed to each thread. Note that each thread contains a pointer to the same data structure. This requires the use of what is known as a mutex (MUTual EXclusion) variable which is used to protect the data structure from concurrent modifications. In other words, any time the data structure is read or written to by one of the threads, they must first call the function pthread_&amp;lt;code&amp;gt;mutex_lock()&amp;lt;/code&amp;gt; to ensure that no other thread currently “has” the lock. When a thread is done with the shared data structure, it calls the function &amp;lt;code&amp;gt;pthread_mutex_unlock()&amp;lt;/code&amp;gt; to make the lock available to other threads. Notice that nothing about the mutex's inclusion in the data structure requires it to be used in order to read or write to the data structure. This means that any programmer who wishes to use threads to implement concurrent programming must pay close attention to code that accesses shared data structures to ensure concurrent modifications do not occur.&lt;br /&gt;
# Perform the previous four steps for as many of the &amp;lt;code&amp;gt;reader&amp;lt;/code&amp;gt; threads as you want. Notice that each one prints a message to standard out providing information about the state of the shared &amp;lt;code&amp;gt;data&amp;lt;/code&amp;gt; variable at the time that it has the lock. By switching to the &amp;lt;code&amp;gt;generator&amp;lt;/code&amp;gt; thread once the mutex variable is unlocked, that code can be stepped through to generate a new random number for the data structure. IMPORTANT: Do not execute a line of source code containing a call to &amp;lt;code&amp;gt;pthread_mutex_lock()&amp;lt;/code&amp;gt; without first ensuring that the mutex variable is unlocked. To do this, carefully perform the following steps:&lt;br /&gt;
## Type &amp;lt;code&amp;gt;p data-&amp;amp;gt;lock&amp;lt;/code&amp;gt;. This will show the values of the mutex variable in the &amp;lt;code&amp;gt;data&amp;lt;/code&amp;gt; structure variable. Make note of the value of the &amp;lt;code&amp;gt;owner&amp;lt;/code&amp;gt; field.&lt;br /&gt;
## Type &amp;lt;code&amp;gt;i th&amp;lt;/code&amp;gt;. This will show the current list of threads in the program. What follows is a possible output from these two commands:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;gdb&amp;quot;&amp;gt;&lt;br /&gt;
(gdb) p data-&amp;gt;lock&lt;br /&gt;
$3 = {__data = {__lock = 1, __count = 0, __owner = 1288, __kind = 0, __nusers = 1, {__spins = 0, __list = {__next = 0x0}}},&lt;br /&gt;
  __size = &amp;quot;\001\000\000\000\000\000\000\000\b\005\000\000\000\000\000\000\001\000\000\000\000\000\000&amp;quot;, __align = 1}&lt;br /&gt;
(gdb) i th&lt;br /&gt;
  9 Thread 1289  reader (arg=0xbeddec8c) at pthread_demo.c:129&lt;br /&gt;
  8 Thread 1288  reader (arg=0xbeddec8c) at pthread_demo.c:134&lt;br /&gt;
  7 Thread 1287  reader (arg=0xbeddec8c) at pthread_demo.c:129&lt;br /&gt;
  6 Thread 1286  0x00008b04 in reader (arg=0xbeddec8c) at pthread_demo.c:129&lt;br /&gt;
  3 Thread 1283  0x00008b04 in reader (arg=0xbeddec8c) at pthread_demo.c:129&lt;br /&gt;
* 2 Thread 1282  generator (arg=0xbeddec8c) at pthread_demo.c:165&lt;br /&gt;
  1 Thread 1281  0x00008a64 in main (argc=2, argv=0xbeddee24) at pthread_demo.c:119&lt;br /&gt;
(gdb)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Analysis of this output requires the understanding that the third column of the &amp;lt;code&amp;gt;i th&amp;lt;/code&amp;gt; output indicates that particular thread's process ID. The important part of the &amp;lt;code&amp;gt;p data-&amp;amp;gt;lock&amp;lt;/code&amp;gt; output is the &amp;lt;code&amp;gt;owner&amp;lt;/code&amp;gt; field, whose value will always either be zero or correspond to the process ID of one of the currently-running threads. In this case, the lock-&amp;amp;gt;__owner field clearly indicates that thread 8 currently owns the data-&amp;amp;gt;lock mutex variable. This would indicate that thread 8 should be stepped through until it has called the &amp;lt;code&amp;gt;pthread_mutex_unlock()&amp;lt;/code&amp;gt; function before stepping into a call to &amp;lt;code&amp;gt;pthread_mutex_lock()&amp;lt;/code&amp;gt; in any other function.&lt;br /&gt;
To summarize, always ensure that the &amp;lt;code&amp;gt;owner&amp;lt;/code&amp;gt; field of the mutex variable is equal to zero before using &amp;lt;code&amp;gt;pthread_mutex_lock()&amp;lt;/code&amp;gt; while debugging. If the lock is currently owned by another thread, GDB will hang until sent an interrupt signal which will require that the entire debug process be started over.&lt;br /&gt;
# The walktrhough is complete. There are two ways to end the debug session gracefully:&lt;br /&gt;
** Type &amp;lt;code&amp;gt;monitor exit&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;kill&amp;lt;/code&amp;gt; (confirm with 'y'), then &amp;lt;code&amp;gt;quit&amp;lt;/code&amp;gt;.&lt;br /&gt;
** Type &amp;lt;code&amp;gt;set scheduler-locking off&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;delete&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;thread 1&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;continue&amp;lt;/code&amp;gt;, then &amp;lt;code&amp;gt;monitor exit&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;kill&amp;lt;/code&amp;gt; (confirm with 'y'), &amp;lt;code&amp;gt;quit&amp;lt;/code&amp;gt;. This will allow the program to finish executing before ending the session.&lt;br /&gt;
&lt;br /&gt;
===GNU GDB Documentation===&lt;br /&gt;
&lt;br /&gt;
Again, for more information on how to debug with GDB, refer to the [http://sourceware.org/gdb/current/onlinedocs/gdb.html GDB Manual]. This is a valuable resource for anyone just learning to debug software and will go into much greater detail than is possible in this guide.&lt;br /&gt;
&lt;br /&gt;
==Next Steps==&lt;br /&gt;
&lt;br /&gt;
If you have not done so already, be sure to check out the [[EMAC OE SDK Example Projects]] or learn to create your own [[New Project]].&lt;br /&gt;
&lt;br /&gt;
Also, give the [[EMAC Eclipse IDE]] a try. Sometimes it is simpler to use an IDE for large projects, especially with the ability to automate the makefile creation process.&lt;br /&gt;
&lt;br /&gt;
[[Category:EMAC OE SDK]]&lt;/div&gt;</summary>
		<author><name>Mcoleman</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.emacinc.com/index.php?title=Creating_a_New_EMAC_OE_SDK_Project&amp;diff=459</id>
		<title>Creating a New EMAC OE SDK Project</title>
		<link rel="alternate" type="text/html" href="https://wiki.emacinc.com/index.php?title=Creating_a_New_EMAC_OE_SDK_Project&amp;diff=459"/>
		<updated>2013-05-17T20:00:33Z</updated>

		<summary type="html">&lt;p&gt;Mcoleman: adding category tag&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{| class=&amp;quot;wikitable conventions&amp;quot;&lt;br /&gt;
!colspan=&amp;quot;2&amp;quot;|Table 1: Conventions&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;/download/directory/&amp;lt;/code&amp;gt; || Placeholder indicating the directory to which the SDK archive will be downloaded.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;/path/to/sdk/&amp;lt;/code&amp;gt; || Placeholder indicating the directory to which the SDK will be extracted.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;EMAC-OE-arm-linux-gnueabi-SDK_XX.YY.rZZ.tar.bz2&amp;lt;/code&amp;gt;&amp;lt;br /&amp;gt;&amp;lt;code&amp;gt;EMAC-OE-arm-linux-gnueabi-SDK_XX.YY&amp;lt;/code&amp;gt;&lt;br /&gt;
|| '''XX''' is the major version&amp;lt;br /&amp;gt;'''YY''' is the minor version&amp;lt;br /&amp;gt;'''ZZ''' is the current revision&amp;lt;br /&amp;gt;The major and minor version numbers will match the version of OE for which the SDK is created.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The EMAC OE SDK is a complete development kit for creating C/C++ applications for EMAC products. The SDK can be used to compile code anywhere in the development system. This procedure explains the process of creating and building a new project within the SDK.&lt;br /&gt;
&lt;br /&gt;
==New Project Procedure==&lt;br /&gt;
&lt;br /&gt;
This guide assumes that the EMAC OE SDK has been [[installed]] and [[configured]]. It also assumes a basic familiarity with the C programming language and that a basic text editor is available. The example code calculates the perimeter of a right triangle given the length of its longest edge and the angle between that edge and one of the other edges.&lt;br /&gt;
&lt;br /&gt;
===Set Up the Project===&lt;br /&gt;
&lt;br /&gt;
The first step in creating an EMAC OE project is creating a project directory in &amp;lt;code&amp;gt;/path/to/sdk/EMAC-OE-arm-linux-gnueabi-SDK_XX.YY/projects&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ mkdir /path/to/sdk/EMAC-OE-arm-linux-gnueabi-SDK_XX.YY/projects/example&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Creating the project in this directory is necessary in order for the &amp;lt;code&amp;gt;global.properties&amp;lt;/code&amp;gt; include and the path variables in global.properties to be correct. If it is created in any other directory, then the make targets will fail without modifications on the Makefile that go beyond the scope of this guide.&lt;br /&gt;
&lt;br /&gt;
===Write the C Code===&lt;br /&gt;
&lt;br /&gt;
This guide uses the C code from Listing 1 as an example. It is simple enough that the basic familiarity with C expected of those viewing this guide precludes the need for explanation. As a general step in application development using the EMAC OE SDK, the C files in this step should be saved in the project's top-level directory. In this case, &amp;lt;code&amp;gt;example.c&amp;lt;/code&amp;gt; should be saved as &amp;lt;code&amp;gt;/path/to/sdk/EMAC-OE-arm-linux-gnueabi-SDK_XX.YY/projects/example/example.c&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;lt;string.h&amp;gt;&lt;br /&gt;
#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
#include &amp;lt;stdlib.h&amp;gt;&lt;br /&gt;
#include &amp;lt;math.h&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
#define HYP 10.0&lt;br /&gt;
#define DEG 30.0&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
int main(void)&lt;br /&gt;
{&lt;br /&gt;
	float opp, adj;&lt;br /&gt;
 &lt;br /&gt;
	opp = HYP * sin(DEG);&lt;br /&gt;
	adj = HYP * cos(DEG);&lt;br /&gt;
 &lt;br /&gt;
	printf(&amp;quot;Hypotenuse: \t%3.2f\n&amp;quot;, HYP);&lt;br /&gt;
	printf(&amp;quot;Angle: \t\t%3.2f\n&amp;quot;, DEG);&lt;br /&gt;
	printf(&amp;quot;Opposite Side: \t%3.2f\n&amp;quot;, opp);&lt;br /&gt;
	printf(&amp;quot;Adjacent Side: \t%3.2f\n&amp;quot;, adj);&lt;br /&gt;
	printf(&amp;quot;%3.2f + %3.2f + %3.2f = %3.2f \n&amp;quot;, HYP, opp, adj, (HYP + opp + adj));&lt;br /&gt;
 &lt;br /&gt;
	exit(EXIT_SUCCESS);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Modify the Makefile===&lt;br /&gt;
&lt;br /&gt;
====Create the New Makefile====&lt;br /&gt;
&lt;br /&gt;
Now that the C file has been written, it is time to copy a suitable Makefile from one of the example projects. The following command will accomplish this: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ cd /path/to/sdk/EMAC-OE-arm-linux-gnueabi-SDK_XX.YY/projects/example/&lt;br /&gt;
developer@ldc:~$ cp ../hello/Makefile ./&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Tell the Makefile What Files to Compile====&lt;br /&gt;
&lt;br /&gt;
The project is almost ready to be compiled. However, there are a few lines in the Makefile which must be modified before this can happen. First, the &amp;lt;code&amp;gt;CFILES&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;TARGET&amp;lt;/code&amp;gt; variables in the Makefile must be modified to suit this project: &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;CFILES=example.c&amp;lt;/code&amp;gt; instead of &amp;lt;code&amp;gt;CFILES=hello.c&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;TARGET=example&amp;lt;/code&amp;gt; instead of &amp;lt;code&amp;gt;TARGET=hello&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This tells the Makefile that the source file used is &amp;lt;code&amp;gt;example.c&amp;lt;/code&amp;gt;. This variable can be assigned a space-delimited list of C files. In the example there is only one file so this is not a concern. &lt;br /&gt;
&lt;br /&gt;
====Tell the Makefile What Libraries to Link====&lt;br /&gt;
&lt;br /&gt;
The last change that must be made to this Makefile is that we need to modify &amp;lt;code&amp;gt;LIBFLAGS&amp;lt;/code&amp;gt; to reflect the use of the math library for the trigonometric functions in the C file. The math library is &amp;lt;code&amp;gt;libm.so&amp;lt;/code&amp;gt;; therefore, we use &amp;lt;code&amp;gt;-lm&amp;lt;/code&amp;gt; to indicate to the linker to link &amp;lt;code&amp;gt;libm&amp;lt;/code&amp;gt; to the binary. If the library for readline were needed, instead, this would be specified with &amp;lt;code&amp;gt;-lreadline&amp;lt;/code&amp;gt; to link &amp;lt;code&amp;gt;libreadline.so&amp;lt;/code&amp;gt; Add the following line to the Makefile: &lt;br /&gt;
* &amp;lt;code&amp;gt;LIBFLAGS+=-lm&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Where in the Makefile this line is added does not matter, though it makes sense to group it with the other variable declarations. &lt;br /&gt;
&lt;br /&gt;
{{mbox | type = notice | text = Much more detailed information on working with libraries and the linker under Linux can be found at [http://www.yolinux.com/TUTORIALS/LibraryArchives-StaticAndDynamic.html YoLinux - Static, Shared Dynamic and Loadable Linux Libraries]}}&lt;br /&gt;
&lt;br /&gt;
Listing 2 shows the complete modified makefile for the &amp;lt;code&amp;gt;example.c&amp;lt;/code&amp;gt; project.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;Make&amp;quot;&amp;gt;&lt;br /&gt;
include ../global.properties&lt;br /&gt;
 &lt;br /&gt;
TARGET=example&lt;br /&gt;
CFILES=example.c&lt;br /&gt;
 &lt;br /&gt;
LIBFLAGS+=-lm&lt;br /&gt;
 &lt;br /&gt;
OBJS=$(CFILES:.c=.o)&lt;br /&gt;
DEPS=$(OBJS:.o=.d)&lt;br /&gt;
 &lt;br /&gt;
all: $(TARGET)&lt;br /&gt;
 &lt;br /&gt;
$(TARGET): $(OBJS) Makefile&lt;br /&gt;
  $(CC) $(VERBOSE) $(OBJS) $(OFLAGS) $(LIBFLAGS) $(SLIBS) -o $@&lt;br /&gt;
 &lt;br /&gt;
%.o: %.c&lt;br /&gt;
  $(CC) $(VERBOSE) $(CFLAGS) -o $@ -c $&amp;lt;&lt;br /&gt;
 &lt;br /&gt;
clean:&lt;br /&gt;
  $(RM) *.o *.gdb $(TARGET) $(DEPS)&lt;br /&gt;
 &lt;br /&gt;
upload: all&lt;br /&gt;
  $(WPUT) $(TARGET) ftp://$(LOGIN):$(PASSWORD)@$(TARGET_IP)/../../tmp/$(TARGET)&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
-include $(DEPS)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
'''Listing 2. Modified Example Makefile'''&lt;br /&gt;
&lt;br /&gt;
====Telling ''make'' About Make Targets====&lt;br /&gt;
&lt;br /&gt;
In &amp;lt;code&amp;gt;global.properties&amp;lt;/code&amp;gt; there are also variables which must be modified in order for all the &amp;lt;code&amp;gt;make&amp;lt;/code&amp;gt; targets to accomplish their purpose. For instructions on how to do this, please refer to the [[Remote Upload Set Up Guide]].&lt;br /&gt;
&lt;br /&gt;
===Cross-Compile with the EMAC OE SDK===&lt;br /&gt;
&lt;br /&gt;
Now it is time to use GNU make to compile the example source code into an application that can be run on the target machine. Makefile-based development with the EMAC OE SDK is a powerful tool which enables the customer to compile code for the target EMAC product on the Linux development machine. Once a project has been set up as described above, development can begin using the GNU make targets as described below. &lt;br /&gt;
&lt;br /&gt;
First, set the current directory to the one containing the Makefile, then execute the make targets as shown in Listing 3. For a description of each make target, read the bullet items below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ cd /path/to/sdk/EMAC-OE-arm-linux-gnueabi-SDK_XX.YY/projects/example/&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
#### Target 1 ####&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ make clean &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
rm -f *.o *.gdb example example.d&lt;br /&gt;
&lt;br /&gt;
#### Target 2 ####&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ make all &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
../../gcc-4.2.4-arm-linux-gnueabi/bin/arm-linux-gnueabi-gcc  -Wall -MMD -g -march=armv5te -mtune=arm926ej-s -o example.o -c example.c\&lt;br /&gt;
../../gcc-4.2.4-arm-linux-gnueabi/bin/arm-linux-gnueabi-gcc  example.o  -lm  -o example&lt;br /&gt;
&lt;br /&gt;
#### Target 3 ####&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ make upload &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
wput --reupload --dont-continue sentence ftp://root:emac_inc@10.0.2.41/../../tmp/example&lt;br /&gt;
--16:52:48-- `app_name'&lt;br /&gt;
    =&amp;gt; ftp://root:xxxxx@10.0.2.41:21/../../tmp/example&lt;br /&gt;
Connecting to 10.0.2.41:21... connected!&lt;br /&gt;
Logging in as root ... Logged in!&lt;br /&gt;
Length: 13,774&lt;br /&gt;
 &lt;br /&gt;
16:52:48 (example) - `350.6K/s' [13774]&lt;br /&gt;
 &lt;br /&gt;
FINISHED --16:52:48--&lt;br /&gt;
Transfered 13,774 bytes in 1 file at 107.3K/s&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
'''Listing 3. Example Make Target Invocation'''&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;make clean&amp;lt;/code&amp;gt; removes all object, dependency, and executable files generated by previous invocations of make. It literally “cleans” the directory as shown in Listing 1, Target 1.&lt;br /&gt;
* &amp;lt;code&amp;gt;make all&amp;lt;/code&amp;gt; resolves dependencies for the source code necessary to cross-compile the target file. The &amp;lt;code&amp;gt;gcc&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;g++&amp;lt;/code&amp;gt; binaries used are specified in &amp;lt;code&amp;gt;global.properties&amp;lt;/code&amp;gt; as relative paths to the &amp;lt;code&amp;gt;/path/to/sdk/EMAC-OE-arm-linux-gnueabi-SDK_XX.YY/projects/example/&amp;lt;/code&amp;gt; directory. This is why the source files must be kept in their own directory within &amp;lt;code&amp;gt;/path/to/sdk/EMAC-OE-arm-linux-gnueabi-SDK_XX.YY/projects&amp;lt;/code&amp;gt;. Listing 1, Target 2 demonstrates a successful &amp;lt;code&amp;gt;make all&amp;lt;/code&amp;gt; invocation.&lt;br /&gt;
* &amp;lt;code&amp;gt;make upload&amp;lt;/code&amp;gt; uses &amp;lt;code&amp;gt;wput&amp;lt;/code&amp;gt; to send example to the remote machine. This requires the remote EMAC product have network connection whose IP is available to the development machine. This IP address must be set as the value of the &amp;lt;code&amp;gt;TARGET_IP&amp;lt;/code&amp;gt; variable in &amp;lt;code&amp;gt;global.properties&amp;lt;/code&amp;gt;. Listing 1, Target 3 demonstrates a successful make upload invocation with &amp;lt;code&amp;gt;TARGET_IP&amp;lt;/code&amp;gt; set to 10.0.2.41.&lt;br /&gt;
&lt;br /&gt;
===Optional global.properties Modifications===&lt;br /&gt;
&lt;br /&gt;
In order to debug applications effectively, the &amp;lt;code&amp;gt;-g&amp;lt;/code&amp;gt; debug flag must be specified when running the compiler. This is set up to occur automatically by its inclusion in the &amp;lt;code&amp;gt;global.properties CFLAGS&amp;lt;/code&amp;gt; variable.&lt;br /&gt;
&lt;br /&gt;
For release builds, however, this can be harmful to the application's performance since keeping the debug symbols in the executable bloats its size. In a typical general-purpose computer this may not be noticeable, but for embedded systems there are typically memory and disk limitations. For production or release versions of an application EMAC recommends modifying the &amp;lt;code&amp;gt;global.properties CFLAGS&amp;lt;/code&amp;gt; variable to replace &amp;lt;code&amp;gt;-g&amp;lt;/code&amp;gt; with &amp;lt;code&amp;gt;-g0&amp;lt;/code&amp;gt; which tells the compiler not to include debug information in the executable.&lt;br /&gt;
&lt;br /&gt;
Using the &amp;lt;code&amp;gt;file&amp;lt;/code&amp;gt; command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ file myexecutable&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
myexecutable: ELF 32-bit LSB executable, ARM, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.14, not stripped&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Will tell you if debugging information is available within the executable. If you see, &amp;lt;code&amp;gt;not stripped&amp;lt;/code&amp;gt;, that means debugging symbols are in the binary. If you wish to remove them without using a release target build, you can use the &amp;lt;code&amp;gt;strip&amp;lt;/code&amp;gt; command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ strip myexecutable&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
If you see no output after running that command, you may assume the command succeeded (this is default behavior upon successful completion of an operation for most Unix and Linux tools). In order to make sure it succeeded, you can run the file command on it again: &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ file myexecutable&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
myexecutable: ELF 32-bit LSB executable, ARM, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.14, stripped&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The output above shows, stripped, which tells us the &amp;lt;code&amp;gt;strip&amp;lt;/code&amp;gt; command succeeded in removing debugging symbols from the binary.&lt;br /&gt;
&lt;br /&gt;
==Next Steps==&lt;br /&gt;
&lt;br /&gt;
Once the target binary has been compiled, the project is ready to be debugged. &lt;br /&gt;
&lt;br /&gt;
{{mbox | type = notice | text = Useful tools related to this article:&lt;br /&gt;
* &amp;lt;code&amp;gt;make&amp;lt;/code&amp;gt; - Automates builds&lt;br /&gt;
* &amp;lt;code&amp;gt;ld&amp;lt;/code&amp;gt; - The linker&lt;br /&gt;
* &amp;lt;code&amp;gt;ldd&amp;lt;/code&amp;gt; - Displays shared library dependencies for a binary executable.&lt;br /&gt;
* &amp;lt;code&amp;gt;strip&amp;lt;/code&amp;gt; - Removes debugging symbols from a binary executable.&lt;br /&gt;
* &amp;lt;code&amp;gt;gdb&amp;lt;/code&amp;gt; - The GNU Debugger. Often used indirectly through the Eclipse IDE interface.&lt;br /&gt;
* &amp;lt;code&amp;gt;file&amp;lt;/code&amp;gt; - Command which displays information about a file passed to it as an argument. Useful for determining whether debugging information has been stripped from a binary executable, among other things.&lt;br /&gt;
}} &lt;br /&gt;
&lt;br /&gt;
[[Category:EMAC OE SDK]]&lt;/div&gt;</summary>
		<author><name>Mcoleman</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.emacinc.com/index.php?title=Using_EMAC_OE_SDK_Example_Projects&amp;diff=458</id>
		<title>Using EMAC OE SDK Example Projects</title>
		<link rel="alternate" type="text/html" href="https://wiki.emacinc.com/index.php?title=Using_EMAC_OE_SDK_Example_Projects&amp;diff=458"/>
		<updated>2013-05-17T19:59:36Z</updated>

		<summary type="html">&lt;p&gt;Mcoleman: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;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 guide demonstrates the process of compiling one of the example projects and running it on the target machine. NOTE: It is assumed that the procedure in the EMAC OE SDK Configuration Guide has been followed prior to reading this page. &lt;br /&gt;
&lt;br /&gt;
This guide consists of two example files, a C file and a Makefile. They are located within Listing 2 and Listing 3, respectively. &lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable conventions&amp;quot;&lt;br /&gt;
!colspan=&amp;quot;2&amp;quot;|Table 1: Conventions&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;/download/directory/&amp;lt;/code&amp;gt; || Placeholder indicating the directory to which the SDK archive will be downloaded.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;/path/to/sdk/&amp;lt;/code&amp;gt; || Placeholder indicating the directory to which the SDK will be extracted.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;EMAC-OE-arm-linux-gnueabi-SDK_XX.YY.rZZ.tar.bz2&amp;lt;/code&amp;gt;&amp;lt;br /&amp;gt;&amp;lt;code&amp;gt;EMAC-OE-arm-linux-gnueabi-SDK_XX.YY&amp;lt;/code&amp;gt;&lt;br /&gt;
|| '''XX''' is the major version&amp;lt;br /&amp;gt;'''YY''' is the minor version&amp;lt;br /&amp;gt;'''ZZ''' is the current revision&amp;lt;br /&amp;gt;The major and minor version numbers will match the version of OE for which the SDK is created.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Tools==&lt;br /&gt;
&lt;br /&gt;
* GNU &amp;lt;code&amp;gt;make&amp;lt;/code&amp;gt;. Manages project dependencies.&lt;br /&gt;
* EMAC OE SDK. [See the EMAC OE SDK Install Page].&lt;br /&gt;
* &amp;lt;code&amp;gt;wput&amp;lt;/code&amp;gt;, Provides FTP capability to the build process.&lt;br /&gt;
&lt;br /&gt;
==EMAC SDK Example: Compile the &amp;quot;hello&amp;quot; Project==&lt;br /&gt;
&lt;br /&gt;
This procedure provides an overview of how to compile and run C applications for EMAC products. It assumes familiarity with the C programming language and is intended to be used by experienced programmers who are looking to learn the EMAC SDK. The “hello” example project source can be found in the projects/ subdirectory of the EMAC OE SDK root directory. The full path to the source is as follows: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
/path/to/sdk/EMAC-OE-arm-linux-gnueabi-SDK_XX.YY/projects/hello/&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Cross-compile the program using GNU Make.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ cd /path/to/sdk/EMAC-OE-arm-linux-gnueabi-SDK_XX.YY/projects/hello/&lt;br /&gt;
developer@ldc:~$ make all&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;all&amp;lt;/code&amp;gt; is a make target. This command is the equivalent to the commonly seen, Build All command found in most IDE's. The build system will only compile files which have been modified since the last build.&lt;br /&gt;
&lt;br /&gt;
Alternatively, you can simply run: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ make&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When &amp;lt;code&amp;gt;make&amp;lt;/code&amp;gt; is run by itself, it chooses its default make target. In this example, &amp;lt;code&amp;gt;all&amp;lt;/code&amp;gt; is the default make target. In any normal project, the default make target will be the one which builds the project. This allows a programmer to simply run &amp;lt;code&amp;gt;make&amp;lt;/code&amp;gt; most of the time they are doing development work.&lt;br /&gt;
&lt;br /&gt;
The Makefile based build system fully supports incremental builds. Should you desire a full rebuild, two steps will need to be followed instead of one:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ make clean&lt;br /&gt;
developer@ldc:~$ make&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;make clean&amp;lt;/code&amp;gt; command will delete any object files (these have the &amp;lt;code&amp;gt;.o&amp;lt;/code&amp;gt; extension in the gcc on Linux build system), debugger information files (with the &amp;lt;code&amp;gt;.gdb&amp;lt;/code&amp;gt; extension), executable binaries (generally, no extension) and any other files which are generated during the build process. Once this cleaning step is complete, the build system will attempt to rebuild everything.&lt;br /&gt;
&lt;br /&gt;
For a more in-depth explanation on how gcc approaches the incremental build process, see the [http://www.gnu.org/software/make/manual/make.html GNU &amp;quot;make&amp;quot; Manual].&lt;br /&gt;
&lt;br /&gt;
==EMAC SDK Example: Uploading and Running the &amp;quot;hello&amp;quot; Project&amp;quot;==&lt;br /&gt;
&lt;br /&gt;
===Uploading the Program to the Target Machine===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ make upload&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;upload&amp;lt;/code&amp;gt; is another make target. This command will send your freshly compiled binary to the target machine.&lt;br /&gt;
&lt;br /&gt;
This make target uses the development system's &amp;lt;code&amp;gt;wput&amp;lt;/code&amp;gt; program to send the binary to the target machine through FTP. This is accomplished using variables stored in the &amp;lt;code&amp;gt;global.properties&amp;lt;/code&amp;gt; file, which is included in the Makefile using the &amp;lt;code&amp;gt;include&amp;lt;/code&amp;gt; keyword. The &amp;lt;code&amp;gt;global.properties&amp;lt;/code&amp;gt; file also contains variables which &amp;lt;code&amp;gt;make&amp;lt;/code&amp;gt; passes to the compiler to ensure that the executable produced is compatible with the target CPU architecture. &lt;br /&gt;
&lt;br /&gt;
===Running the Program on the Target Machine===&lt;br /&gt;
&lt;br /&gt;
Connect remotely to the target machine. Run the program as shown in Listing 1 using the remote connection.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@emac-oe:~# chmod u+x /tmp/hello&lt;br /&gt;
root@emac-oe:~# /tmp/hello&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
'''Listing 1. Running the Remote Application'''&lt;br /&gt;
&lt;br /&gt;
{{mbox | type = notice | text = &amp;lt;code&amp;gt;chmod u+x&amp;lt;/code&amp;gt; sets the root user's permissions to allow execution of the binary. Note that this assumes that you are logged in as the system root user.}}&lt;br /&gt;
&lt;br /&gt;
{{mbox | type = notice | text = &amp;lt;code&amp;gt;/tmp/hello&amp;lt;/code&amp;gt; runs the program without any arguments.}}&lt;br /&gt;
&lt;br /&gt;
{{mbox | type = notice | text = '''NOTE:''' If you wish to run a program located in your current directory, you must run it as &amp;lt;code&amp;gt;./hello&amp;lt;/code&amp;gt;. Without the &amp;lt;code&amp;gt;./&amp;lt;/code&amp;gt; prefix, the program will not be run by the shell. The shell will only look for a program in the default search &amp;lt;code&amp;gt;PATH&amp;lt;/code&amp;gt;, unless the program's name is prefixed with a specific path. The &amp;lt;code&amp;gt;./&amp;lt;/code&amp;gt; prefix is a relative path. The &amp;lt;code&amp;gt;.&amp;lt;/code&amp;gt; represents the current directory, just as &amp;lt;code&amp;gt;..&amp;lt;/code&amp;gt; represents the previous directory. The &amp;lt;code&amp;gt;/&amp;lt;/code&amp;gt; following the &amp;lt;code&amp;gt;.&amp;lt;/code&amp;gt; indicates to the shell to look inside the current directory. In POSIX systems, such as Linux, filenames can have a &amp;lt;code&amp;gt;.&amp;lt;/code&amp;gt; as their first character, which is why the &amp;lt;code&amp;gt;/&amp;lt;/code&amp;gt; is needed. &lt;br /&gt;
&lt;br /&gt;
Incidentally, a &amp;lt;code&amp;gt;.&amp;lt;/code&amp;gt; as the first character of the filename indicates that the file is hidden. Use the &amp;lt;code&amp;gt;ls -a&amp;lt;/code&amp;gt; command to see such files.}}&lt;br /&gt;
&lt;br /&gt;
If the file compiles without trouble but has runtime bugs, you can remotely debug the application using gdbserver. Read the [[EMAC OE SDK Remote Debugging Guide]] to learn more.&lt;br /&gt;
&lt;br /&gt;
===Example C File===&lt;br /&gt;
&lt;br /&gt;
This C file can be used by programmers as an example to ensure their build configuration for EMAC products is functioning correctly.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
/**&lt;br /&gt;
 * @file hello.c&lt;br /&gt;
 *&lt;br /&gt;
 * Simple Hello World application for EMAC OE.&lt;br /&gt;
 *&lt;br /&gt;
 * @author EMAC, Inc. &amp;lt;support@emacinc.com&amp;gt;&lt;br /&gt;
 */&lt;br /&gt;
/***************************************************************************&lt;br /&gt;
 *                                                                         *&lt;br /&gt;
 *   This program is free software; you can redistribute it and/or modify  *&lt;br /&gt;
 *   it under the terms of the GNU General Public License as published by  *&lt;br /&gt;
 *   the Free Software Foundation; either version 2 of the License, or     *&lt;br /&gt;
 *   (at your option) any later version.                                   *&lt;br /&gt;
 *                                                                         *&lt;br /&gt;
 ***************************************************************************/&lt;br /&gt;
 &lt;br /&gt;
#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
#include &amp;lt;stdlib.h&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
int main(void)&lt;br /&gt;
{&lt;br /&gt;
    printf(&amp;quot;Hello EMAC OE!\n&amp;quot;);&lt;br /&gt;
    exit(EXIT_SUCCESS);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
'''Listing 2. &amp;quot;Hello World&amp;quot; example project&lt;br /&gt;
&lt;br /&gt;
===Example Makefile===&lt;br /&gt;
&lt;br /&gt;
Listing 3 shows the default &amp;lt;code&amp;gt;Makefile&amp;lt;/code&amp;gt; used for the hello example project. This is a necessary component of the EMAC SDK which directs GNU Make in resolving source code dependencies before calling the cross-compiler to create a binary for the target platform. It also provides a convenient upload target which utilizes the development system's &amp;lt;code&amp;gt;wput&amp;lt;/code&amp;gt; command to send the compiled binary to the target system. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;Make&amp;quot;&amp;gt;&lt;br /&gt;
include ../global.properties&lt;br /&gt;
 &lt;br /&gt;
TARGET=hello&lt;br /&gt;
CFILES=hello.c&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
OBJS=$(CFILES:.c=.o)&lt;br /&gt;
DEPS=$(OBJS:.o=.d)&lt;br /&gt;
 &lt;br /&gt;
all: $(TARGET)&lt;br /&gt;
 &lt;br /&gt;
$(TARGET): $(OBJS) Makefile&lt;br /&gt;
  $(CC) $(VERBOSE) $(OBJS) $(OFLAGS) $(LIBFLAGS) $(SLIBS) -o $@&lt;br /&gt;
 &lt;br /&gt;
%.o: %.c&lt;br /&gt;
  $(CC) $(VERBOSE) $(CFLAGS) -o $@ -c $&amp;lt;&lt;br /&gt;
 &lt;br /&gt;
clean:&lt;br /&gt;
  $(RM) *.o *.gdb $(TARGET) $(DEPS)&lt;br /&gt;
 &lt;br /&gt;
upload: all&lt;br /&gt;
  $(WPUT) $(TARGET) ftp://$(LOGIN):$(PASSWORD)@$(TARGET_IP)/../../tmp/$(TARGET)&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
-include $(DEPS)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
'''Listing 3. Example EMAC OE SDK Makefile'''&lt;br /&gt;
&lt;br /&gt;
{{mbox | type = notice | text = '''NOTE:''' Using the documentation for GNU Make will be required to gain a solid understanding of the build system. Here is a brief description of this Makefile to help you get started.&lt;br /&gt;
* The &amp;lt;code&amp;gt;include&amp;lt;/code&amp;gt; command tells &amp;lt;code&amp;gt;make&amp;lt;/code&amp;gt; to pull in the file specified in a way similar to the C/C++ &amp;lt;code&amp;gt;#include&amp;lt;/code&amp;gt; preprocessor directive.&lt;br /&gt;
* The &amp;lt;code&amp;gt;TARGET=&amp;lt;/code&amp;gt; directive tells &amp;lt;code&amp;gt;make&amp;lt;/code&amp;gt; the name and location it should use for any executable binaries or shared object binaries (shared objects are similar to Windows &amp;lt;code&amp;gt;.dlls&amp;lt;/code&amp;gt;) it produces.&lt;br /&gt;
* The &amp;lt;code&amp;gt;CFILES=&amp;lt;/code&amp;gt; directive tells &amp;lt;code&amp;gt;make&amp;lt;/code&amp;gt; the names of the C source files it needs to build.&lt;br /&gt;
* The &amp;lt;code&amp;gt;OBJS=&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;DEPS=&amp;lt;/code&amp;gt; directives tell &amp;lt;code&amp;gt;make&amp;lt;/code&amp;gt; how to produce file names for the object and dependency files it generates. This file specifies a method for these which will work for most projects, and is unlikely to need modification.&lt;br /&gt;
* &amp;lt;code&amp;gt;all:&amp;lt;/code&amp;gt; specifies the make target named “all.” &amp;lt;code&amp;gt;clean:&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;upload:&amp;lt;/code&amp;gt;, similarly, specify the make targets for targets of these names, respectively. New make targets can be given names this way. make will perform all the steps listed after the target name until it encounters another target name.&lt;br /&gt;
* The &amp;lt;code&amp;gt;CC&amp;lt;/code&amp;gt; variable refers to the &amp;lt;code&amp;gt;gcc&amp;lt;/code&amp;gt; command, because &amp;lt;code&amp;gt;CC&amp;lt;/code&amp;gt; is so defined in the &amp;lt;code&amp;gt;global.properties&amp;lt;/code&amp;gt; file included by this Makefile. The &amp;lt;code&amp;gt;$(CC)&amp;lt;/code&amp;gt; syntax tells &amp;lt;code&amp;gt;make&amp;lt;/code&amp;gt; to read the value of the variable, &amp;lt;code&amp;gt;CC&amp;lt;/code&amp;gt;, and replace &amp;lt;code&amp;gt;$(CC)&amp;lt;/code&amp;gt; with the value of &amp;lt;code&amp;gt;CC&amp;lt;/code&amp;gt; prior to attempting to execute the command. This is similar to the way many scripting languages work, and hopefully will feel pretty natural to any developer working with Makefiles for the first time.}}&lt;br /&gt;
&lt;br /&gt;
{{mbox | type = notice | text = '''NOTE:''' This is a simple, basic Makefile which can be extended as needed to support many projects. Should your build requirements become complex, more sophistication may be required. A ''build system builder'' may be the tool you need. If this becomes necessary, options you may wish to consider include: &lt;br /&gt;
* Buy a good book on &amp;lt;code&amp;gt;make&amp;lt;/code&amp;gt; and learn the system thoroughly.&lt;br /&gt;
* Adopt a build system builder tool. ''CMake'' has proven to be popular for many large projects, and is simpler to use than ''autotools''. Buying a book on the build system builder tool chosen may prove wise.&lt;br /&gt;
* The build system builder in Eclipse may be able to handle the complexity of your requirements. This is probably the simplest option.&lt;br /&gt;
''NOTE: '''Build system builder''' refers to a tool which generates a set of scripts and/or Makefiles which are then used to build a project.''&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
==Next Steps==&lt;br /&gt;
&lt;br /&gt;
After compiling and running an example project, the next step is to create a new project. The [[EMAC OE SDK New Project Guide]] details this process from start to finish.&lt;br /&gt;
&lt;br /&gt;
[[Category:EMAC OE SDK]]&lt;/div&gt;</summary>
		<author><name>Mcoleman</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.emacinc.com/index.php?title=Configuring_EMAC_OE_4.0_SDK&amp;diff=457</id>
		<title>Configuring EMAC OE 4.0 SDK</title>
		<link rel="alternate" type="text/html" href="https://wiki.emacinc.com/index.php?title=Configuring_EMAC_OE_4.0_SDK&amp;diff=457"/>
		<updated>2013-05-17T19:55:41Z</updated>

		<summary type="html">&lt;p&gt;Mcoleman: adding category tag&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{| class=&amp;quot;wikitable conventions&amp;quot;&lt;br /&gt;
!colspan=&amp;quot;2&amp;quot;|Table 1: Conventions&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;/download/directory/&amp;lt;/code&amp;gt; || Placeholder indicating the directory to which the SDK archive will be downloaded.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;/path/to/sdk/&amp;lt;/code&amp;gt; || Placeholder indicating the directory to which the SDK will be extracted.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;EMAC-OE-arm-linux-gnueabi-SDK_XX.YY.rZZ.tar.bz2&amp;lt;/code&amp;gt;&amp;lt;br /&amp;gt;&amp;lt;code&amp;gt;EMAC-OE-arm-linux-gnueabi-SDK_XX.YY&amp;lt;/code&amp;gt;&lt;br /&gt;
|| '''XX''' is the major version&amp;lt;br /&amp;gt;'''YY''' is the minor version&amp;lt;br /&amp;gt;'''ZZ''' is the current revision&amp;lt;br /&amp;gt;The major and minor version numbers will match the version of OE for which the SDK is created.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
When Eclipse generates a Makefile to use for building a project, the generated Makefile includes a file named global.properties before it performs any other steps. This file is located in the projects directory, which is the root directory for Eclipse projects. The projects directory is located within the EMAC SDK directory provided by the EMAC SDK package (or installed on the LDC). &lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;global.properties&amp;lt;/code&amp;gt; file provides information needed to build projects and upload them to the target machine (the board supplied by EMAC). The following information is provided by this file: &lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Configuration variable !! Description &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;SDKBASE&amp;lt;/code&amp;gt; || The base directory for the SDK .&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;CC&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;CXX&amp;lt;/code&amp;gt; || Exectuable binaries to use for compiling for the C and C++ compiler, respectively.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;LD_LIBRARY_PATH&amp;lt;/code&amp;gt; || The path the linker should use to search for shared library files.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;CFLAGS&amp;lt;/code&amp;gt; || The flags passed to the compiler to specify target processor architecture, debugging flags, etc.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;OFLAGS&amp;lt;/code&amp;gt; || The flags passed to the compiler to specify optimization options to use.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;TARGET_IP&amp;lt;/code&amp;gt; || The IP Address of the target machine (needed for uploading the compiled binary to the target machine).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;LOGIN&amp;lt;/code&amp;gt; || The user name to use for logging into the target machine.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;PASSWORD&amp;lt;/code&amp;gt; || The password to use for logging into the target machine.*&lt;br /&gt;
|- &lt;br /&gt;
| &amp;lt;code&amp;gt;WPUT&amp;lt;/code&amp;gt; ||  The location of the &amp;lt;code&amp;gt;wput&amp;lt;/code&amp;gt; command, along with options to pass to &amp;lt;code&amp;gt;wput&amp;lt;/code&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
'''*NOTE''' The password is stored in plain text in this file. However, read permission is required to view this password. In most development environments, this should not be an issue. If development is taking place in a shared environment (such as a University lab) and secrecy of this password is required, simply ensure that only trusted users have read permission for this file.&lt;br /&gt;
&lt;br /&gt;
{{mbox | type = warning | text = Configuring permissions on files is a common source of problems for people new to doing so under Linux. EMAC does not recommend altering the default settings (which should be secure in most environments) unless absolutely necessary. EMAC will only be able to provide very limited support should these settings be manually configured. The standard Linux commands, &amp;lt;code&amp;gt;chmod&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;chgrp&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;chown&amp;lt;/code&amp;gt; are typically used to configure these permissions. Please see the documentation for these commands using the man command, or find a reference with your favorite search engine. '''Caveat''': This will require any user wishing to build this software to have such permission, since programs run by a user can only read files the user is permitted to use.}}&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;global.properties&amp;lt;/code&amp;gt; file is actually a type of virtual file, called a softlink. This softlink acts as a pointer which points to another file. The file it points to is chosen when the CPU architecture is chosen. To see why it works this way, see the above information about the flags specified for the processor architecture, and note that different library and compiler paths may be required to support different hardware. The softlink is updated when the hardware to use for the development project is selected.&lt;br /&gt;
&lt;br /&gt;
{{mbox | type = notice | text = Should problems relating to this part of the build system show up during the development process, these files or softlinks may have been accidentally modified. Inspecting these files and softlinks, and/or rerunning the hardware selection script, may provide the fix for the problems. The &amp;lt;code&amp;gt;ln&amp;lt;/code&amp;gt; command with the &amp;lt;code&amp;gt;-s&amp;lt;/code&amp;gt; option (see &amp;lt;code&amp;gt;man ln&amp;lt;/code&amp;gt;) is the command used to create softlinks.}}&lt;br /&gt;
&lt;br /&gt;
==Configuration Steps==&lt;br /&gt;
&lt;br /&gt;
The following configuration steps are necessary to begin using the EMAC OE SDK. &lt;br /&gt;
&lt;br /&gt;
Before cross-compiling source code on the development machine for the target machine: &lt;br /&gt;
&lt;br /&gt;
* A [[set up script]] linking &amp;lt;code&amp;gt;global.properties&amp;lt;/code&amp;gt; to an architecture-specific &amp;lt;code&amp;gt;global.properties&amp;lt;/code&amp;gt; file must be run.&lt;br /&gt;
* The &amp;lt;code&amp;gt;TARGET_IP&amp;lt;/code&amp;gt; variable in the [[global.properties]] file must be changed to the IP address or hostname belonging to the target board.&lt;br /&gt;
&lt;br /&gt;
{{mbox | type = notice | text = These configurations assume that the [[EMAC OE SDK]] is installed.}}&lt;br /&gt;
&lt;br /&gt;
==SDK Set Up Script==&lt;br /&gt;
&lt;br /&gt;
Before compiling source code for the target machine, toolchain libraries for the target machine must be specified by running &amp;lt;code&amp;gt;setmachine.sh&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
===Procedure===&lt;br /&gt;
&lt;br /&gt;
# Navigate to the SDK directory.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ cd /path/to/sdk/EMAC-OE-arm-linux-gnueabi-SDK_XX.YY/&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
# Run the script using the command shown below to produce a menu as shown in Figure 1 with options for the target machine for which the source will be compiled.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ ./setmachine.sh&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
[[File:Emac_oe_sdk_setup-2.png]]&lt;br /&gt;
&lt;br /&gt;
==Remote Upload Set-up==&lt;br /&gt;
&lt;br /&gt;
In the &amp;lt;code&amp;gt;global.properties&amp;lt;/code&amp;gt; file there is a variable, &amp;lt;code&amp;gt;IP&amp;lt;/code&amp;gt; which must be set to the target board IP address as shown in Listing 1 below. This step is necessary to ensure that the Make target, &amp;lt;code&amp;gt;'upload'&amp;lt;/code&amp;gt; will work as expected.&lt;br /&gt;
&lt;br /&gt;
===Procedure===&lt;br /&gt;
&lt;br /&gt;
# Navigate to the projects directory within the SDK.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ cd /path/to/sdk/EMAC-OE-arm-linux-gnueabi-SDK_XX.YY/projects&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
# The &amp;lt;code&amp;gt;global.properties&amp;lt;/code&amp;gt; file should be listed in the current directory. The relevant lines from &amp;lt;code&amp;gt;global.properties&amp;lt;/code&amp;gt; are shown in Listing 1 below.&lt;br /&gt;
'''Listing 1. &amp;lt;code&amp;gt;global.properties&amp;lt;/code&amp;gt; snippet'''&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
TARGET_IP=&lt;br /&gt;
LOGIN=root&lt;br /&gt;
PASSWORD=emac_inc_90210&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
# Change the value of &amp;lt;code&amp;gt;TARGET_IP&amp;lt;/code&amp;gt; to the target system's IP address.&lt;br /&gt;
This can be found using the following command from a shell on the target system:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@emac-oe:~# /sbin/ifconfig eth0 | grep inet&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
For more information on how to connect to the remote system, see the [[initial connections section]] of the [[EMAC OE Getting Started Guide|EMAC OE getting started guide]].&lt;br /&gt;
# Change the value of &amp;lt;code&amp;gt;PASSWORD&amp;lt;/code&amp;gt; to whatever value was set in the [[System Login section]] of the [[EMAC OE Getting Started Guide|EMAC OE getting started guide]]. Listing 1 shows the default user name and password.&lt;br /&gt;
&lt;br /&gt;
[[Category:EMAC OE SDK]]&lt;/div&gt;</summary>
		<author><name>Mcoleman</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.emacinc.com/index.php?title=EMAC_OE_SDK_Introduction&amp;diff=456</id>
		<title>EMAC OE SDK Introduction</title>
		<link rel="alternate" type="text/html" href="https://wiki.emacinc.com/index.php?title=EMAC_OE_SDK_Introduction&amp;diff=456"/>
		<updated>2013-05-17T19:54:42Z</updated>

		<summary type="html">&lt;p&gt;Mcoleman: adding category tag&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The EMAC Open Embedded SDK is distributed in an archive that can be extracted and used from a Linux shell or imported into Eclipse as a ready-to-develop project. The archive contains a hardware-specific SDK which must be set up using the [[EMAC OE SDK Configuration]] page.&lt;br /&gt;
&lt;br /&gt;
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. Understanding the details of this toolchain is not necessary for the application developer. However, the setup is simple enough for those with an intermediate knowledge of GNU/Linux development to understand and modify the configuration to suit application-specific needs if, necessary.&lt;br /&gt;
&lt;br /&gt;
To learn how to put these features into use, see the links below.&lt;br /&gt;
&lt;br /&gt;
[[Category:EMAC OE SDK]]&lt;/div&gt;</summary>
		<author><name>Mcoleman</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.emacinc.com/index.php?title=Building_Existing_Software_Packages_with_EMAC_OE_SDK&amp;diff=455</id>
		<title>Building Existing Software Packages with EMAC OE SDK</title>
		<link rel="alternate" type="text/html" href="https://wiki.emacinc.com/index.php?title=Building_Existing_Software_Packages_with_EMAC_OE_SDK&amp;diff=455"/>
		<updated>2013-05-17T19:15:30Z</updated>

		<summary type="html">&lt;p&gt;Mcoleman: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{| class=&amp;quot;wikitable conventions&amp;quot;&lt;br /&gt;
!colspan=&amp;quot;2&amp;quot;|Table 1: Conventions&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;/path/to/sdk/&amp;lt;/code&amp;gt; ||  Represents the development system path to the EMAC OE SDK.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;EMAC-OE-arm-linux-gnueabi-SDK_XX.YY.rZZ.tar.bz2&amp;lt;/code&amp;gt;&amp;lt;br /&amp;gt;&amp;lt;code&amp;gt;EMAC-OE-arm-linux-gnueabi-SDK_XX.YY&amp;lt;/code&amp;gt;&lt;br /&gt;
|| '''XX''' is the major version&amp;lt;br /&amp;gt;'''YY''' is the minor version&amp;lt;br /&amp;gt;'''ZZ''' is the current revision&amp;lt;br /&amp;gt;The major and minor version numbers will match the version of OE for which the SDK is created.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
It is very common to need to be able to build existing software projects for the target hardware rather than developing the software from scratch. This feature is especially important in an open source environment, where countless libraries and utilities are available for use and often times need to be compiled to match the target architecture. Fortunately, EMAC OE SDK toolchains are standard GCC packages designed and configured to make this process as easy as possible. In addition, most software projects are developed to allow for cross-platform development.&lt;br /&gt;
&lt;br /&gt;
This guide provides an overview of the most common tasks associated with compiling existing software projects using the SDK. Note, however, that build methods differ significantly depending on the project design. Refer to the project documentation or support for information on how to cross-compile the software; the EMAC OE SDK can be treated as a standard GCC toolchain in this respect. Table 1 below denotes some conventions used in this guide.&lt;br /&gt;
&lt;br /&gt;
==Makefile-based Projects==&lt;br /&gt;
&lt;br /&gt;
Some projects have a build system based on a set of makefiles that are responsible for compiling and packaging the software. In general, configuring these projects to compile using the EMAC OE SDK is a simple process. In some instances, the software designers may have included a variable in the makefile which allows a cross-compiler prefix setting. In other cases, the CC and other makefile variables can be modified to direct make to compile using the EMAC OE SDK.&lt;br /&gt;
&lt;br /&gt;
It may be advantageous to add the cross-compiler bin directory to the system PATH variable temporarily before compiling to simplify Makefile modifications. This can be done with a command such as the following:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ export PATH=$PATH:/path/to/sdk/EMAC-OE-arm-linux-gnueabi-SDK_XX.YY/gcc-4.2.4-arm-linux-gnueabi/bin&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{mbox | type = notice | text = Note that running the command above will only affect the current terminal session.}}&lt;br /&gt;
&lt;br /&gt;
===MTD Utilities Project Example===&lt;br /&gt;
&lt;br /&gt;
The MTD Utilities project &amp;lt;code&amp;gt;mtd-utils&amp;lt;/code&amp;gt; is a good example of a Makefile-based build system that can easily be built using the EMAC OE SDK. Follow the steps below to accomplish this task.&lt;br /&gt;
&lt;br /&gt;
{{mbox | type = notice | text = The instructions in this section are valid as of the master git branch on 4/09/11. Future source changes may impact the required steps for compilation.}}&lt;br /&gt;
&lt;br /&gt;
# Begin by downloading the mtd-utils source code. Assuming that git is installed on the development system, run the following command to get the most recent version. Note that this version will be different from the stable release installed on EMAC OE systems by default.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ git clone git://git.infradead.org/mtd-utils.git &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
# After downloading the source, navigate to the source directory &amp;lt;code&amp;gt;mtd-utils&amp;lt;/code&amp;gt; and open &amp;lt;code&amp;gt;Makefile&amp;lt;/code&amp;gt; in the top-level directory. This file defines various make targets and compilation flags used to compile the source. Notice that the file &amp;lt;code&amp;gt;common.mk&amp;lt;/code&amp;gt; is sourced with the line include &amp;lt;code&amp;gt;common.mk&amp;lt;/code&amp;gt;. This is similar to the &amp;lt;code&amp;gt;global.properties&amp;lt;/code&amp;gt; file in the EMAC OE SDK.&lt;br /&gt;
# Close the &amp;lt;code&amp;gt;Makefile&amp;lt;/code&amp;gt; editor and open the &amp;lt;code&amp;gt;common.mk&amp;lt;/code&amp;gt; file. At the top of the file, &amp;lt;code&amp;gt;CC&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;AR&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;RANLIB&amp;lt;/code&amp;gt; are defined using the &amp;lt;code&amp;gt;CROSS&amp;lt;/code&amp;gt; variable, which is not set in either &amp;lt;code&amp;gt;common.mk&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;Makefile&amp;lt;/code&amp;gt;. An exert is shown below:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;make&amp;quot;&amp;gt;&lt;br /&gt;
CC := $(CROSS)gcc&lt;br /&gt;
AR := $(CROSS)ar&lt;br /&gt;
RANLIB := $(CROSS)ranlib&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
If the &amp;lt;code&amp;gt;CROSS&amp;lt;/code&amp;gt; variable is defined when &amp;lt;code&amp;gt;make&amp;lt;/code&amp;gt; is run, the specific toolchain to use can be specified. Also note that &amp;lt;code&amp;gt;CFLAGS&amp;lt;/code&amp;gt; is defined using a &amp;lt;code&amp;gt;?=&amp;lt;/code&amp;gt; assignment, which means that the assignment will only be made if &amp;lt;code&amp;gt;CFLAGS&amp;lt;/code&amp;gt; is undefined:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;make&amp;quot;&amp;gt;&lt;br /&gt;
CFLAGS ?= -O2 -g&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
# Close &amp;lt;code&amp;gt;common.mk&amp;lt;/code&amp;gt; without making any changes.&lt;br /&gt;
# In order to compile the source correctly, the &amp;lt;code&amp;gt;CROSS&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;CFLAGS&amp;lt;/code&amp;gt; variables should be defined. The tuning flags for the target architecture to be added to the &amp;lt;code&amp;gt;CFLAGS&amp;lt;/code&amp;gt; variable should be used from the &amp;lt;code&amp;gt;ARCHFLAGS&amp;lt;/code&amp;gt; variable in the &amp;lt;code&amp;gt;global.properties&amp;lt;/code&amp;gt; file of the EMAC OE SDK. The following steps utilize tuning flags for an armv5te processor-based system. Although the path to the SDK toolchain could be included directly in the &amp;lt;code&amp;gt;CROSS&amp;lt;/code&amp;gt; variable in this instance, this example works by adding the SDK toolchain to the system &amp;lt;code&amp;gt;PATH&amp;lt;/code&amp;gt; variable. The path and prefix used will differ depending on the target architecture of the EMAC OE SDK; refer to &amp;lt;code&amp;gt;global.properties&amp;lt;/code&amp;gt; in the SDK to determine the correct settings. The &amp;lt;code&amp;gt;DESTDIR&amp;lt;/code&amp;gt; variable controls where the files are put when running the &amp;lt;code&amp;gt;install&amp;lt;/code&amp;gt; make target. The &amp;lt;code&amp;gt;WITHOUT_XATTR&amp;lt;/code&amp;gt; flag must be set to disable features of the software that are not available on EMAC OE.&lt;br /&gt;
## Before compiling, several source changes are required to match the setup of the SDK. These include changing references from &amp;lt;code&amp;gt;lzo2&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;lzo&amp;lt;/code&amp;gt;, and changing the lzo include prefix. Run the following commands from the mtd-utils directory to make these changes:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ for file in `find . -name Makefile`; do sed -i 's:lzo2:lzo:g' $file; done&lt;br /&gt;
developer@ldc:~$ for file in `find . -name '*.c'`; do sed -i 's:lzo/::g' $file; done&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
## Run the following commands to set the variables:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ export PATH=$PATH:/path/to/sdk/EMAC-OE-arm-linux-gnueabi-SDK_XX.YY/gcc-4.2.4-arm-linux-gnueabi/bin&lt;br /&gt;
developer@ldc:~$ export CROSS=arm-linux-gnueabi-&lt;br /&gt;
developer@ldc:~$ export CFLAGS=&amp;quot;-O2 -g -march=armv5te -mtune=arm926ej-s&amp;quot;&lt;br /&gt;
developer@ldc:~$ export DESTDIR=Install&lt;br /&gt;
developer@ldc:~$ export WITHOUT_XATTR=1&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
# Once the environment has been set up, &amp;lt;code&amp;gt;make&amp;lt;/code&amp;gt; can be used to compile the source code:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ make all&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
# After successfully compiling the project, the &amp;lt;code&amp;gt;install&amp;lt;/code&amp;gt; make target can be used to package all of the software into the &amp;lt;code&amp;gt;Install&amp;lt;/code&amp;gt; directory as specified by the &amp;lt;code&amp;gt;DESTDIR&amp;lt;/code&amp;gt; variable:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ make install&lt;br /&gt;
developer@ldc:~$ ls -R Install&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
Install:&lt;br /&gt;
usr&lt;br /&gt;
 &lt;br /&gt;
Install/usr:&lt;br /&gt;
sbin  share&lt;br /&gt;
 &lt;br /&gt;
Install/usr/sbin:&lt;br /&gt;
docfdisk      flash_erase     flash_lock      flash_unlock  jffs2dump   nanddump   nftldump     rfddump      sumtool&lt;br /&gt;
doc_loadbios  flash_eraseall  flash_otp_dump  ftl_check     mkfs.jffs2  nandtest   nftl_format  rfdformat&lt;br /&gt;
flashcp       flash_info      flash_otp_info  ftl_format    mtd_debug   nandwrite  recv_image   serve_image&lt;br /&gt;
 &lt;br /&gt;
Install/usr/share:&lt;br /&gt;
man&lt;br /&gt;
 &lt;br /&gt;
Install/usr/share/man:&lt;br /&gt;
man1&lt;br /&gt;
 &lt;br /&gt;
Install/usr/share/man/man1:&lt;br /&gt;
mkfs.jffs2.1.gz&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
While the procedure in this example is specific to &amp;lt;code&amp;gt;mtd-utils&amp;lt;/code&amp;gt;, many makefile-based projects will require similar steps for cross-compiling.&lt;br /&gt;
&lt;br /&gt;
==Autotools-based Projects==&lt;br /&gt;
&lt;br /&gt;
The GNU build system is known as Autotools. Autotools is a group of applications that are designed to provide a configurable build system to allow compilation on different platforms and environments. A &amp;lt;code&amp;gt;configure&amp;lt;/code&amp;gt; script and set of input files are used to generate makefiles based on options passed to the configure script and deduced from the system environment. This includes tests for compiler options, library functions, install configuration, and other assorted variables.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;configure&amp;lt;/code&amp;gt; script is the most important step in building an autotools-based project. Although available options for &amp;lt;code&amp;gt;configure&amp;lt;/code&amp;gt; vary depending on the project design, there are common options shared between most autotools projects. &lt;br /&gt;
&lt;br /&gt;
===libConfuse Example Project===&lt;br /&gt;
&lt;br /&gt;
The libConfuse project is a simple C library written for parsing configuration files. It uses an autotools build system for configuration. The steps below demonstrate how to build libConfuse and should be used as an example for building other autotools-based projects. &lt;br /&gt;
&lt;br /&gt;
# The source code for the libConfuse project can be downloaded as described on the project website [http://www.nongnu.org/confuse/]. For this example, release 2.7 is used: [http://savannah.nongnu.org/download/confuse/confuse-2.7.tar.gz]. After downloading the source, extract the archive and navigate to the top-level directory of the project (i.e. `confuse-2.7`).&lt;br /&gt;
# Read through the &amp;lt;code&amp;gt;README&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;INSTALL&amp;lt;/code&amp;gt; files for information on the project and general information on how to build it. Also, look at the help output from &amp;lt;code&amp;gt;configure&amp;lt;/code&amp;gt; to see a summary of the available options:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ ./configure --help&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
# Before beginning, the system &amp;lt;code&amp;gt;PATH&amp;lt;/code&amp;gt; variable should be changed to include the SDK toolchain as in the makefile-based project example. The &amp;lt;code&amp;gt;CFLAGS&amp;lt;/code&amp;gt; variable should also be set. If the &amp;lt;code&amp;gt;CC&amp;lt;/code&amp;gt; variable is set, it should be set to &amp;lt;code&amp;gt;arm-linux-gnueabi-gcc&amp;lt;/code&amp;gt; (or the appropriate value for the target); if not set the compiler name will be detected from the options passed to configure. The &amp;lt;code&amp;gt;CFLAGS&amp;lt;/code&amp;gt; architecture tuning values should be set according to the &amp;lt;code&amp;gt;global.properties&amp;lt;/code&amp;gt; file in the EMAC OE SDK. The &amp;lt;code&amp;gt;DESTDIR&amp;lt;/code&amp;gt; variable determines where the files will be installed to when the &amp;lt;code&amp;gt;install&amp;lt;/code&amp;gt; make target is run. &amp;lt;code&amp;gt;DESTDIR&amp;lt;/code&amp;gt; must be an absolute path for the libConfuse project, so the current working directory is added to the variable using the &amp;lt;code&amp;gt;pwd&amp;lt;/code&amp;gt; command. The following commands are an example of how to set up the environment correctly:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ export CFLAGS=&amp;quot;-O2 -march=armv5te -mtune=arm926ej-s&amp;quot;&lt;br /&gt;
developer@ldc:~$ export DESTDIR=`pwd`/Install&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
# After setting the environment, &amp;lt;code&amp;gt;configure&amp;lt;/code&amp;gt; can be run with the appropriate options to configure the build system and generate the makefiles. The code below shows an example configuration used by EMAC OE. Be sure to set the host and target correctly based on the architecture:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ ./configure --build=i686-linux --host=arm-linux-gnueabi --target=arm-linux-gnueabi \&lt;br /&gt;
        --prefix=/usr --exec_prefix=/usr --bindir=/usr/bin --sbindir=/usr/sbin \&lt;br /&gt;
        --datadir=/usr/share  \&lt;br /&gt;
        --infodir=/usr/share/info \&lt;br /&gt;
        --mandir=/usr/share/man --enable-shared&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The configuration should complete successfully. If any problems are reported that result in an error, check the environment settings and &amp;lt;code&amp;gt;configure&amp;lt;/code&amp;gt; options again. &lt;br /&gt;
# Now that &amp;lt;code&amp;gt;configure&amp;lt;/code&amp;gt; has generated all of the makefiles for the project, &amp;lt;code&amp;gt;make&amp;lt;/code&amp;gt; can be used to compile the source code:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ make all&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
If any errors are encountered during compilation, examine the output of &amp;lt;code&amp;gt;configure&amp;lt;/code&amp;gt; and make sure that all of the environment variables and &amp;lt;code&amp;gt;configure&amp;lt;/code&amp;gt; options were specified correctly. &lt;br /&gt;
# Once compilation is complete, the &amp;lt;code&amp;gt;install&amp;lt;/code&amp;gt; target can be used to package all of the necessary files together so that they can be transferred to the target board.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ make install&lt;br /&gt;
developer@ldc:~$ ls -R Install&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
Install:&lt;br /&gt;
usr&lt;br /&gt;
 &lt;br /&gt;
Install/usr:&lt;br /&gt;
include  lib  share&lt;br /&gt;
 &lt;br /&gt;
Install/usr/include:&lt;br /&gt;
confuse.h&lt;br /&gt;
 &lt;br /&gt;
Install/usr/lib:&lt;br /&gt;
libconfuse.a  libconfuse.la  libconfuse.so  libconfuse.so.0  libconfuse.so.0.0.0  pkgconfig&lt;br /&gt;
 &lt;br /&gt;
Install/usr/lib/pkgconfig:&lt;br /&gt;
libconfuse.pc&lt;br /&gt;
 &lt;br /&gt;
Install/usr/share:&lt;br /&gt;
locale&lt;br /&gt;
 &lt;br /&gt;
Install/usr/share/locale:&lt;br /&gt;
fr  sv&lt;br /&gt;
 &lt;br /&gt;
Install/usr/share/locale/fr:&lt;br /&gt;
LC_MESSAGES&lt;br /&gt;
 &lt;br /&gt;
Install/usr/share/locale/fr/LC_MESSAGES:&lt;br /&gt;
confuse.mo&lt;br /&gt;
 &lt;br /&gt;
Install/usr/share/locale/sv:&lt;br /&gt;
LC_MESSAGES&lt;br /&gt;
 &lt;br /&gt;
Install/usr/share/locale/sv/LC_MESSAGES:&lt;br /&gt;
confuse.mo&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Note that not all of the files installed would be necessary to install on the board, such as the man pages and pkgconfig information.&lt;/div&gt;</summary>
		<author><name>Mcoleman</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.emacinc.com/index.php?title=Remote_Debugging_EMAC_OE_SDK_Projects_with_gdbserver&amp;diff=454</id>
		<title>Remote Debugging EMAC OE SDK Projects with gdbserver</title>
		<link rel="alternate" type="text/html" href="https://wiki.emacinc.com/index.php?title=Remote_Debugging_EMAC_OE_SDK_Projects_with_gdbserver&amp;diff=454"/>
		<updated>2013-05-17T19:11:21Z</updated>

		<summary type="html">&lt;p&gt;Mcoleman: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{| class=&amp;quot;wikitable conventions&amp;quot;&lt;br /&gt;
!colspan=&amp;quot;2&amp;quot;|Table 1: Conventions&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;target_program&amp;lt;/code&amp;gt; || The name of the application being debugged. This is the result of the Makefile build process. &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;target_machine&amp;lt;/code&amp;gt; || Connection information for the target machine. This can either be a serial port (ie. &amp;lt;code&amp;gt;/dev/ttyS2&amp;lt;/code&amp;gt;) or a TCP connection in the form of HOST:PORT.  &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;/path/to/sdk/&amp;lt;/code&amp;gt; ||  Represents the development system path to the EMAC OE SDK. &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
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 binary resulting from the compile 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 while running the debugger.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
This guide is intended to build a basic understanding of how to use gdbserver with EMAC products. It is not intended as a general guide to debugging computer programs. For help with that, see the GDB man pages on the development system or read [this manual] on debugging with GDB.&lt;br /&gt;
&lt;br /&gt;
==Setup==&lt;br /&gt;
&lt;br /&gt;
Using &amp;lt;code&amp;gt;gdbserver&amp;lt;/code&amp;gt; involves setting up both the target machine and the development machine. This requires that the binary application be present on both development and target machines. The development machine copy of the application must be compiled with debug flags whereas this is not strictly necessary for the target machine. See the [Optional &amp;lt;code&amp;gt;global.properties&amp;lt;/code&amp;gt; Modifications Section] on the New EMAC OE SDK Project Guide for more information. See the [[[EMAC OE Getting Started Guide]]] for more information on how to connect to the target EMAC product using a serial port or Ethernet connection.&lt;br /&gt;
&lt;br /&gt;
===Target Machine===&lt;br /&gt;
&lt;br /&gt;
Because EMAC OE builds are distributed with &amp;lt;code&amp;gt;gdbserver&amp;lt;/code&amp;gt;, installation is not a concern. The only setup necessary is to run &amp;lt;code&amp;gt;gdbserver&amp;lt;/code&amp;gt; with &amp;lt;code&amp;gt;target_program&amp;lt;/code&amp;gt;: &lt;br /&gt;
&lt;br /&gt;
# If the target application is already running, use the attachpid option to connect &amp;lt;code&amp;gt;gdbserver&amp;lt;/code&amp;gt; to the application as shown below. The &amp;lt;code&amp;gt;PID&amp;lt;/code&amp;gt; argument can be determined using &amp;lt;code&amp;gt;pidof&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ pidof target_program&lt;br /&gt;
developer@ldc:~$ gdbserver target_machine --attach PID&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
# If the target application is not already running, the name of the binary may be included as an argument to the &amp;lt;code&amp;gt;gdbserver&amp;lt;/code&amp;gt; program call.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;snytaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ gdbserver target_machine target_program [ARGS]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This establishes a &amp;lt;code&amp;gt;gdbserver&amp;lt;/code&amp;gt; port on the target machine that listens for incoming connections from GDB on the development machine. In debug terminology, &amp;lt;code&amp;gt;gdbserver&amp;lt;/code&amp;gt; is “attached” to the process ID of the program being debugged. In reality, though, GDB is attached to the process ID of a proxy which passes the messages to and from the remote device under test. &lt;br /&gt;
&lt;br /&gt;
The next step is to run GDB on the development machine using the &amp;lt;code&amp;gt;target_program&amp;lt;/code&amp;gt;/&lt;br /&gt;
&lt;br /&gt;
===Development Machine===&lt;br /&gt;
&lt;br /&gt;
# First, &amp;lt;code&amp;gt;cd&amp;lt;/code&amp;gt; to the directory where the targe executable is stored.&lt;br /&gt;
# Run the EMAC OE SDK GDB:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ /path/to/sdk/EMAC-OE-arm-linux-gnueabi-SDK_4.0/gcc-4.2.4-arm-linux-gnueabi/bin/arm-linux-gnueabi-gdb target_program&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
# Run the following commands in GDB to prepare for the debug session:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;gdb&amp;quot;&amp;gt;&lt;br /&gt;
(gdb) target remote target_machine&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{mbox | type = warning | text = Note that the location of the GDB in the toolchain may differ from what is shown above depending on which version of the SDK is used.}}&lt;br /&gt;
&lt;br /&gt;
{{mbox | type = notice | text = If the gdb executable, or any other executable you run, is located in a directory which is in the PATH environment variable, you can simply run that command without the long path prefix. Sourcing the environment variables generated by the EMAC script for this will provide you with such a path. The script which creates the file to source also creates a symbolic link for arm-linux-gnueabi-gdb called, simply, gdb. With your shell environment setup this way, you could simply execute: &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ gdb target_program&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
in place of the long command given in step 2, above.&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
==Sample GDB Session==&lt;br /&gt;
&lt;br /&gt;
This example GDB session uses the EMAC OE SDK example project named &amp;lt;code&amp;gt;pthread_demo&amp;lt;/code&amp;gt;. It consists of the single source file &amp;lt;code&amp;gt;pthread_demo.c&amp;lt;/code&amp;gt;. The program is called with a single integer argument indicating how many &amp;lt;code&amp;gt;reader&amp;lt;/code&amp;gt; threads the user wishes to create. The following describes the tasks of the &amp;lt;code&amp;gt;main&amp;lt;/code&amp;gt; thread: &lt;br /&gt;
&lt;br /&gt;
# The &amp;lt;code&amp;gt;main&amp;lt;/code&amp;gt; thread performs user input validation. It prints a usage message according to the argument passed to it on the command line. The function expects the user to pass a number indicating how many threads should be spawned.&lt;br /&gt;
# The &amp;lt;code&amp;gt;main&amp;lt;/code&amp;gt; thread initiates a new thread which uses the &amp;lt;code&amp;gt;generator()&amp;lt;/code&amp;gt; function to perform the following tasks:&lt;br /&gt;
## Checks to see if the number of &amp;lt;code&amp;gt;reader&amp;lt;/code&amp;gt; threads matches the number of times a &amp;lt;code&amp;gt;reader&amp;lt;/code&amp;gt; thread has acquired the mutex lock and performed its task. If the two values do match, then the &amp;lt;code&amp;gt;generator&amp;lt;/code&amp;gt; thread unlocks the mutex, breaks out of the while loop and moves on to line 167 to gracefully exit. If the two values do not match, then the &amp;lt;code&amp;gt;generator&amp;lt;/code&amp;gt; thread continues through the rest of the while loop described in steps 2.2 and 2.3.&lt;br /&gt;
## Generates random data to be stored in the data struct shared by all the threads. To do this, it protects the data struct with the use of a mutex variable.&lt;br /&gt;
## Sleeps after giving up its lock on the mutex so that another thread might have a chance to acquire the lock.&lt;br /&gt;
# After creating the &amp;lt;code&amp;gt;generator&amp;lt;/code&amp;gt; thread the &amp;lt;code&amp;gt;main&amp;lt;/code&amp;gt; thread iteratively creates as many &amp;lt;code&amp;gt;reader&amp;lt;/code&amp;gt; threads as indicated by the single integer argument. Each &amp;lt;code&amp;gt;reader&amp;lt;/code&amp;gt; thread performs the following tasks:&lt;br /&gt;
## Waits for a chance to acquire the mutex &amp;lt;code&amp;gt;lock&amp;lt;/code&amp;gt;. Once the mutex &amp;lt;code&amp;gt;lock&amp;lt;/code&amp;gt; is acquired, it prints the value of the random number &amp;lt;code&amp;gt;generated&amp;lt;/code&amp;gt; by the generator thread in its last run.&lt;br /&gt;
## Increments an integer in the &amp;lt;code&amp;gt;data&amp;lt;/code&amp;gt; struct to indicate that it has completed its task.&lt;br /&gt;
## Gives up its lock on the mutex and exits.&lt;br /&gt;
# After creating the prescribed number of &amp;lt;code&amp;gt;reader&amp;lt;/code&amp;gt; threads, the &amp;lt;code&amp;gt;main&amp;lt;/code&amp;gt; thread then waits for each thread created to exit gracefully. &lt;br /&gt;
# The &amp;lt;code&amp;gt;main&amp;lt;/code&amp;gt; thread exists.&lt;br /&gt;
&lt;br /&gt;
The SDK version of &amp;lt;code&amp;gt;pthread_demo.c&amp;lt;/code&amp;gt; works according to the description above with a &amp;lt;code&amp;gt;MAX_THREAD&amp;lt;/code&amp;gt; value of 100. However, for the purpose of this example debug session it is instructive to use a faulty version of the same program. Replace lines 75-80 in &amp;lt;code&amp;gt;pthread_demo.c&amp;lt;/code&amp;gt; with the code snippet shown in Listing 1 below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
if ((data.num_threads &amp;lt; 1) || (data.num_threads &amp;lt; MAX_THREAD)) {&lt;br /&gt;
        fprintf(stderr,&lt;br /&gt;
                &amp;quot;The number of thread should between 1 and %d\n&amp;quot;,&lt;br /&gt;
                MAX_THREAD);&lt;br /&gt;
        exit(EXIT_FAILURE);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Useful GDB Commands===&lt;br /&gt;
&lt;br /&gt;
The following is a brief description of some essential GDB commands. Each description is followed by a link to the official GDB documentation page that has more specific information about what the command does and how to use it. Please note that the official GDB documentation is targeted for the latest GDB release which at the time of writing this documentation is 7.4. The version of GDB that EMAC distributes with the OE products, however, is version 6.8. Because of this, the links to documentation below may provide slightly different information. The biggest difference between the two version of GDB, however, is in the support for debugging programs with multiple threads. This is reflected in the documentation as well. Because of this, EMAC has set up ftp access to GDB 6.8 documentation on its web server. It is highly recommended that the GDB 6.8 documentation be referenced in cases where the program does not seem to support commands or options specified in the current official documentation. &lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Command !! Description &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;start/run&amp;lt;/code&amp;gt;&lt;br /&gt;
|| These commands are used to start the debugged program with the only difference being that start automatically pauses execution at the beginning of the program's main function whereas run must be told explicitly where to pause using the breakpoint command listed below.&lt;br /&gt;
See also [Debugging with GDB, Section 4.2: Starting your Program]&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;kill&amp;lt;/code&amp;gt;&lt;br /&gt;
|| Used to kill the currently-running instance of target_program.&lt;br /&gt;
See also [Debugging with GDB, Section 4.9: Killing the Child Process]&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;print&amp;lt;/code&amp;gt;&lt;br /&gt;
|| Used to print the value of an expression.&lt;br /&gt;
See also [Debugging with GDB, Section 10: Examining Data]&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;list&amp;lt;/code&amp;gt;&lt;br /&gt;
|| List contents of function or specified line.&lt;br /&gt;
See also [Debugging with GDB, Section 9: Examining Source Files]&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;layout&amp;lt;/code&amp;gt;&lt;br /&gt;
|| This is a TUI (Text User Interface) command that enables the programmer to view multiple debug views at once including source code, assembly, and registers.&lt;br /&gt;
See also [Debugging with GDB, Section 25.4: TUI Commands]&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;disassemble&amp;lt;/code&amp;gt;&lt;br /&gt;
|| This command allows the programmer to see assembler instructions.&lt;br /&gt;
See also [Debugging with GDB, Section 9.6: Source and Machine Code]&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;break&amp;lt;/code&amp;gt;&lt;br /&gt;
|| This command specifies a function name, line number, or instruction at which GDB is to pause execution.&lt;br /&gt;
See also [Debugging with GDB, Section 5.1: Breakpoints]&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;next/nexti, step/stepi&amp;lt;/code&amp;gt;&lt;br /&gt;
|| Allow the programmer to step through a program without specifying breakpoints. The &amp;lt;code&amp;gt;next/nexti&amp;lt;/code&amp;gt; commands step over function calls, stopping on the next line of the same stack frame; &amp;lt;code&amp;gt;step/stepi&amp;lt;/code&amp;gt;, step into function calls, stopping on the first line in the next stack frame. The difference between &amp;lt;code&amp;gt;step/next&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;stepi/nexti&amp;lt;/code&amp;gt; is that the &amp;lt;code&amp;gt;i&amp;lt;/code&amp;gt; indicates instruction-by-instruction stepping at the assembly language level.&lt;br /&gt;
See also [Debugging with GDB, Section 5.2: Continuing and Stepping]&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;continue&amp;lt;/code&amp;gt;&lt;br /&gt;
|| Used to continue program execution from the address where it was last stopped.&lt;br /&gt;
See the Debugging with GDB link for &amp;lt;code&amp;gt;next/step&amp;lt;/code&amp;gt; for more information about the &amp;lt;code&amp;gt;continue&amp;lt;/code&amp;gt; command.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;bt&amp;lt;/code&amp;gt;&lt;br /&gt;
|| Short for &amp;quot;backtrace,&amp;quot; which displays to the programmer a brief summary of execution up to the current point in the program. This is useful because it shows a nested list of stack frames starting with the current one.&lt;br /&gt;
See also [Debugging with GDB, Section 8.2: Backtrace]&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;quit&amp;lt;/code&amp;gt;&lt;br /&gt;
||  This will quit the debugging session, and return you to the shell. The Control-D key combination is another way to accomplish this.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Session Walk-through===&lt;br /&gt;
&lt;br /&gt;
This debug session walk-through assumes that the program has been compiled using the modified source code above and that both the target machine and the development machine have been set up according to the above Setup section. The walk-through is divided into multiple “lessons” with the intent of first introducing the use of the commands described above and then actually running GDB to debug a known programming problem. Each lesson may be run independently of the others, but it is recommended that each be run in order starting from Lesson 1 for the first time through.&lt;br /&gt;
&lt;br /&gt;
====Lesson 1: Navigation and Code Display====&lt;br /&gt;
&lt;br /&gt;
This lesson assumes that &amp;lt;code&amp;gt;gdbserver&amp;lt;/code&amp;gt; has been run as in the [Target Machine Setup] section above with an ARG value of 3. Other values are fine so long as they fall within the range of 1 to 100. The number '3' was arbitrarily chosen to avoid having to use a symbolic variable in the explanations below.&lt;br /&gt;
&lt;br /&gt;
# Type &amp;lt;code&amp;gt;b main&amp;lt;/code&amp;gt; to set a breakpoint at the main function in the source code.&lt;br /&gt;
# Type &amp;lt;code&amp;gt;continue&amp;lt;/code&amp;gt;. This will cause the program to continue from the breakpoint set by GDB at startup. The program was passed an argument of 3, indicating that three threads should be created. &lt;br /&gt;
# Type &amp;lt;code&amp;gt;b 73&amp;lt;/code&amp;gt; to set a breakpoint at line 73 in the source code, which should be the line containing &amp;lt;code&amp;gt;data.num_threads = atoi(argv[1]);&amp;lt;/code&amp;gt;&lt;br /&gt;
# Type &amp;lt;code&amp;gt;continue&amp;lt;/code&amp;gt;. The program will continue execution up until line 73 in the source code. At this point, type layout split to view a split screen containing both the source code and the assembly-level machine instructions. Both screens show the program's current location in execution. The assembly-level display shows what the target's processor is actually executing at that point in the source code as shown in the source-level display. To view either of these without the other type layout &amp;lt;code&amp;gt;asm&amp;lt;/code&amp;gt; for just assembly-level and &amp;lt;code&amp;gt;layout src&amp;lt;/code&amp;gt; for just source-level.&lt;br /&gt;
# Type &amp;lt;code&amp;gt;nexti&amp;lt;/code&amp;gt;. This will cause the program to execute the next instruction in the current stack frame which is a mov instruction beginning to prepare the current stack for a call to the library function &amp;lt;code&amp;gt;atoi()&amp;lt;/code&amp;gt;. The details of this process are beyond the scope of this tutorial; essentially, the program needs to store information about the current execution location in the stack for when the &amp;lt;code&amp;gt;atoi()&amp;lt;/code&amp;gt; function finishes. Type &amp;lt;code&amp;gt;ni&amp;lt;/code&amp;gt; (alias for nexti) three more times. You should end up on a &amp;lt;code&amp;gt;bl&amp;lt;/code&amp;gt; instruction in the assembly view as shown in Listing 2 below. The source layout should still show the program on line 73.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;asm&amp;quot;&amp;gt;&lt;br /&gt;
B+ |0x887c &amp;lt;main+112&amp;gt;       ldr    r3, [r11, #-84]                   │&lt;br /&gt;
   |0x8880 &amp;lt;main+116&amp;gt;       add    r3, r3, #4      ; 0x4             │&lt;br /&gt;
   |0x8884 &amp;lt;main+120&amp;gt;       ldr    r3, [r3]                          │&lt;br /&gt;
   |0x8888 &amp;lt;main+124&amp;gt;       mov    r0, r3                            │&lt;br /&gt;
  &amp;gt;|0x888c &amp;lt;main+128&amp;gt;       bl     0x86e0 &amp;lt;atoi&amp;gt;                     │&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
'''Listing 2. GDB Assembly Layout''' - ''Note that the assembly may look different depending on the target architecture.''&lt;br /&gt;
# Type &amp;lt;code&amp;gt;stepi&amp;lt;/code&amp;gt;. This will cause the program to move into the next stack frame and GDB to show the assembly-level instructions of the &amp;lt;code&amp;gt;atoi()&amp;lt;/code&amp;gt; call. Since the library containing &amp;lt;code&amp;gt;atoi()&amp;lt;/code&amp;gt; was likely not compiled with debug symbols, the source-level layout will show the message &amp;lt;code&amp;gt;[ No Source Available ]&amp;lt;/code&amp;gt;.&lt;br /&gt;
# Type &amp;lt;code&amp;gt;bt&amp;lt;/code&amp;gt;. This will cause the program to display a human-readable version of the current stack. Each stack “frame” is represented by the name of the function call it represents with that function's location in memory. Type &amp;lt;code&amp;gt;bt full&amp;lt;/code&amp;gt; to get a list of the variables local to each stack frame.&lt;br /&gt;
# Type &amp;lt;code&amp;gt;finish&amp;lt;/code&amp;gt;. This will cause the current stack frame to return and execution to pause on the next instruction of the previous stack frame.&lt;br /&gt;
# Type &amp;lt;code&amp;gt;kill&amp;lt;/code&amp;gt;. This will cause the current process to be killed by &amp;lt;code&amp;gt;gdbserver&amp;lt;/code&amp;gt; at the target machine. &amp;lt;code&amp;gt;gdbserver&amp;lt;/code&amp;gt; will also terminate at this point. In order to start a new remote debug session, start gdbserver as described in the Target Machine Setup section and re-run step 3 of the [Development Machine Setup] section.&lt;br /&gt;
&lt;br /&gt;
{{mbox | type = warning | text = '''Note:''' &amp;lt;code&amp;gt;b&amp;lt;/code&amp;gt; is an alias for the &amp;lt;code&amp;gt;break&amp;lt;/code&amp;gt; command. &lt;br /&gt;
&amp;lt;code&amp;gt;ni&amp;lt;/code&amp;gt; is an alias for &amp;lt;code&amp;gt;nexti&amp;lt;/code&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
====Lesson 2: Finding the Bug====&lt;br /&gt;
&lt;br /&gt;
Though this sample is contrived, it is still useful to demonstrate how to find a design mistake in an otherwise well-written (no errors or warnings) program. These types of mistakes typically have to do with the array boundary miscalculations, logic and comparison operator mistakes, or other simple mistakes. For the sake of demonstration, assume that the actual mistake is unknown. This lesson assumes that gdbserver has just been started as in the [Target Machine] Setup above with an &amp;lt;code&amp;gt;ARG&amp;lt;/code&amp;gt; value of 5.&lt;br /&gt;
&lt;br /&gt;
# Before starting the program in the debugger again, run it by itself on the target machine to see what the actual program output is: &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@emac-oe:~# /tmp/pthread_demo 5&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
The number of threads should be between 1 and 100&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The program was given an input of '5' yet the output message seems to indicate that this is out of range which is obviously not true.&lt;br /&gt;
# Start the debugger again and connect to the target machine as described in the Setup section.&lt;br /&gt;
# Type &amp;lt;code&amp;gt;b main&amp;lt;/code&amp;gt; to set a breakpoint at the main function in the source code.&lt;br /&gt;
# Type &amp;lt;code&amp;gt;continue&amp;lt;/code&amp;gt;. This will cause the program to continue from the breakpoint set by GDB at startup. &lt;br /&gt;
# Type &amp;lt;code&amp;gt;n&amp;lt;/code&amp;gt;. This will cause the program to step over the next line of source code. The reason for using &amp;lt;code&amp;gt;n&amp;lt;/code&amp;gt; rather than &amp;lt;code&amp;gt;s&amp;lt;/code&amp;gt; or one of the instruction stepping commands is because the erroneous output indicates that the coding mistake is in the programmer's source code rather than the c library functions &amp;lt;code&amp;gt;atoi()&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;fprintf()&amp;lt;/code&amp;gt;. Stepping over the function will save all the time required to step through every detail of what the library functions are doing. Later passes through the code can be used to step into functions called from within that stack frame if the first pass proves unsuccessful.&lt;br /&gt;
# Continue to type &amp;lt;code&amp;gt;n&amp;lt;/code&amp;gt; until one of the program's &amp;lt;code&amp;gt;exit()&amp;lt;/code&amp;gt; calls is reached, but do not actually step into that &amp;lt;code&amp;gt;exit()&amp;lt;/code&amp;gt; call. Judging by the program's output above, this should bring you to the conditional block that checks the value of the local variable n used to store the output of &amp;lt;code&amp;gt;atoi()&amp;lt;/code&amp;gt; as shown in Listing 3. Note that once execution reaches line 79 of the source code, GDB will display the output of the &amp;lt;code&amp;gt;fprintf()&amp;lt;/code&amp;gt; function from line 76. This may cause display problems within the text-based UI library that GDB uses which will require the command refresh to fix.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;gdb&amp;quot;&amp;gt;&lt;br /&gt;
B+ |75              if ((data.num_threads &amp;lt; 1) || (data.num_threads &amp;lt; MAX_THREAD)) {       |&lt;br /&gt;
   |76                      fprintf(stderr,                                                |&lt;br /&gt;
   |77                              &amp;quot;The number of thread should between 1 and %d\n&amp;quot;,      |&lt;br /&gt;
   |78                              MAX_THREAD);                                           |&lt;br /&gt;
  &amp;gt;|79                      exit(EXIT_FAILURE);                                            |&lt;br /&gt;
   |80              }                                                                      |&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
# Type &amp;lt;code&amp;gt;p/d data→num_threads&amp;lt;/code&amp;gt;. &amp;lt;code&amp;gt;p&amp;lt;/code&amp;gt; is an alias for &amp;lt;code&amp;gt;print&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;/d&amp;lt;/code&amp;gt; tells GDB to treat the expression requested as an integer in signed decimal, and &amp;lt;code&amp;gt;data→num&amp;lt;/code&amp;gt;_threads is the element &amp;lt;code&amp;gt;num_threads&amp;lt;/code&amp;gt; within &amp;lt;code&amp;gt;struct thread_data&amp;lt;/code&amp;gt;. This should provide the following output:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;gdb&amp;quot;&amp;gt;&lt;br /&gt;
(gdb) p/d data-&amp;gt;num_threads&lt;br /&gt;
$6 = 5&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Note that the integer part of &amp;lt;code&amp;gt;$6&amp;lt;/code&amp;gt; will increment with each call to the gdb command &amp;lt;code&amp;gt;print&amp;lt;/code&amp;gt;. The above output confirms that the argument '5' was successfully passed to the program and read into a variable to be tested, indicating that one of the logical tests for the current conditional block contains a mistake. This merits a closer look at line 75:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;gdb&amp;quot;&amp;gt;&lt;br /&gt;
B+ |75              if ((data.num_threads &amp;lt; 1) || (data.num_threads &amp;lt; MAX_THREAD)) {       |&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Line 75 consists of a conditional test which is the logical OR of two arithmetic tests involving the values of &amp;lt;code&amp;gt;data.num_threads&amp;lt;/code&amp;gt;, '1', and &amp;lt;code&amp;gt;MAX_THREAD&amp;lt;/code&amp;gt;. The first test is true the input integer is less than &amp;lt;code&amp;gt;1–(data.num_threads &amp;amp;lt; 1)&amp;lt;/code&amp;gt;. The second tests whether the input integer is less than the symbolic constant, &amp;lt;code&amp;gt;MAX_THREAD–(data.num_threads &amp;amp;lt; MAX_THREAD)&amp;lt;/code&amp;gt;. Judging by the name of this constant and the result of the test (we know it resolves to true because the value of &amp;lt;code&amp;gt;data.num_threads&amp;lt;/code&amp;gt; in this case is not less than one), we can see that the comparison operator used is the culprit. The correct interpretation is that it should be '&amp;amp;gt;' rather than '&amp;amp;lt;'.&lt;br /&gt;
# Type &amp;lt;code&amp;gt;kill&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
This was a simple problem to solve but the method used above could apply in any situation where source code compiles and runs without errors yet provides varied or unexpected output.&lt;br /&gt;
&lt;br /&gt;
====Lesson 3: Debugging With Threads====&lt;br /&gt;
&lt;br /&gt;
Do not fix the programming mistake found in Lesson 2. This lesson will cover the use of the jump command to skip blocks of code and commands specific to debugging multi-threaded programs. Before getting started, see [http://sourceware.org/gdb/current/onlinedocs/gdb/Thread-Stops.html#Thread-Stops Debugging with GDB: 5. Stopping and Starting Multi-thread Programs].&lt;br /&gt;
&lt;br /&gt;
This lesson assumes that &amp;lt;code&amp;gt;gdbserver&amp;lt;/code&amp;gt; has just been started as in the Target Machine Setup above with an &amp;lt;code&amp;gt;ARG&amp;lt;/code&amp;gt; value of 7.&lt;br /&gt;
&lt;br /&gt;
# Start the debugger again and connect to the target machine as described in the Setup section.&lt;br /&gt;
# Type set &amp;lt;code&amp;gt;scheduler-locking&amp;lt;/code&amp;gt; on. This command enables GDB to lock all threads save for the currently-selected thread from running when the &amp;lt;code&amp;gt;step/stepi&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;next/nexti&amp;lt;/code&amp;gt; commands are given. &lt;br /&gt;
# Set all the breakpoints that you will need for this session: &lt;br /&gt;
## Type &amp;lt;code&amp;gt;b main&amp;lt;/code&amp;gt; to set a breakpoint at the main function in the source code.&lt;br /&gt;
## Type &amp;lt;code&amp;gt;b 75&amp;lt;/code&amp;gt;. This will set a break point at the conditional block that checks the value of the program's single integer argument. If you recall from Lesson 2, this is the conditional which evaluates incorrectly in the modified version of the application.&lt;br /&gt;
## Type &amp;lt;code&amp;gt;b 143&amp;lt;/code&amp;gt;. This will set a breakpoint in the variable assignment in the &amp;lt;code&amp;gt;generator&amp;lt;/code&amp;gt; function. Careful examination of the source code will show that this function is called from a thread created by the main thread of execution but never from the main thread itself.&lt;br /&gt;
## Type &amp;lt;code&amp;gt;b 129&amp;lt;/code&amp;gt;. This will set a breakpoint in the variable assignment of the &amp;lt;code&amp;gt;reader&amp;lt;/code&amp;gt; function. As with the &amp;lt;code&amp;gt;generator&amp;lt;/code&amp;gt; function, any time the &amp;lt;code&amp;gt;reader&amp;lt;/code&amp;gt; function is called it will be inside a thread that is not the main thread.&lt;br /&gt;
## Type &amp;lt;code&amp;gt;b 135&amp;lt;/code&amp;gt;. This will set a breakpoint just after the &amp;lt;code&amp;gt;fflush(stdout)&amp;lt;/code&amp;gt; statement in the &amp;lt;code&amp;gt;reader&amp;lt;/code&amp;gt; function.&lt;br /&gt;
## Type &amp;lt;code&amp;gt;b 97&amp;lt;/code&amp;gt;. This will set a breakpoint in the main thread after the &amp;lt;code&amp;gt;generator&amp;lt;/code&amp;gt; thread has been created but before the main thread begins creating &amp;lt;code&amp;gt;reader&amp;lt;/code&amp;gt; threads.&lt;br /&gt;
## Type &amp;lt;code&amp;gt;b 119&amp;lt;/code&amp;gt;. This will set a breakpoint after the main thread iteratively creates the &amp;lt;code&amp;gt;reader&amp;lt;/code&amp;gt; threads.&lt;br /&gt;
# Optional: You may want to run the &amp;lt;code&amp;gt;layout split&amp;lt;/code&amp;gt; command so that you can see both the assembly and the source code during the debug session.&lt;br /&gt;
# Type &amp;lt;code&amp;gt;continue&amp;lt;/code&amp;gt; then hit 'Enter' once. This will bring you to line 75 in the source code.&lt;br /&gt;
# Type &amp;lt;code&amp;gt;j 81&amp;lt;/code&amp;gt;. This is an alias for jump 81 that tells GDB to have the program jump to line 81 of the source code and resume execution at the first assembly instruction represented by line 81 of the source code. This line is labeled &amp;lt;code&amp;gt;&amp;lt;main.c+196&amp;gt;&amp;lt;/code&amp;gt;. Note that the program effectively no longer checks the input it receives.&lt;br /&gt;
# Type &amp;lt;code&amp;gt;i th&amp;lt;/code&amp;gt;. This will cause GDB to display a list of the application's threads currently in memory. Take a moment to consider what is happening in the program. We know that in Step 2 of this lesson we used &amp;lt;code&amp;gt;set scheduler-locking&amp;lt;/code&amp;gt; to tell GDB to effectively only allow the currently-selected thread of execution to be affected by the GDB &amp;lt;code&amp;gt;step&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;next&amp;lt;/code&amp;gt; commands. Others will wait at their respective breakpoints until explicitly told by the programmer to execute the next line of source code or instruction. The next breakpoint that &amp;lt;code&amp;gt;main&amp;lt;/code&amp;gt; reaches occurs after the &amp;lt;code&amp;gt;generator&amp;lt;/code&amp;gt; thread is created. This means that there are currently two threads of execution, the &amp;lt;code&amp;gt;main&amp;lt;/code&amp;gt; thread paused at line 97 and the &amp;lt;code&amp;gt;generator&amp;lt;/code&amp;gt; thread paused at line 143. &lt;br /&gt;
# Type &amp;lt;code&amp;gt;thread 2&amp;lt;/code&amp;gt;. This will select the &amp;lt;code&amp;gt;generator&amp;lt;/code&amp;gt; thread.&lt;br /&gt;
# Type &amp;lt;code&amp;gt;thread apply 2 n&amp;lt;/code&amp;gt;. This will tell the &amp;lt;code&amp;gt;generator&amp;lt;/code&amp;gt; thread to execute the next line of source code and pause again on the line following that. Without typing any other commands into the GDB prompt, hit 'Enter' seven more times. This should bring you to line 165 of the source code:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
usleep(1);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Notice the output of the program on the remote terminal on which &amp;lt;code&amp;gt;gdbserver&amp;lt;/code&amp;gt; was run. Standard output on that terminal should show the output from the &amp;lt;code&amp;gt;printf()&amp;lt;/code&amp;gt; call on line 154.&lt;br /&gt;
# Type &amp;lt;code&amp;gt;thread 1&amp;lt;/code&amp;gt;. This will select the &amp;lt;code&amp;gt;main&amp;lt;/code&amp;gt; thread.&lt;br /&gt;
# Type &amp;lt;code&amp;gt;continue&amp;lt;/code&amp;gt;. This will cause the &amp;lt;code&amp;gt;main&amp;lt;/code&amp;gt; thread to continue execution while &amp;lt;code&amp;gt;generator&amp;lt;/code&amp;gt; remains paused at line 165. &amp;lt;code&amp;gt;main&amp;lt;/code&amp;gt; pauses again at line 119, once the 7 &amp;lt;code&amp;gt;reader&amp;lt;/code&amp;gt; threads have been created. Recall from step 3.4 that &amp;lt;code&amp;gt;b 129&amp;lt;/code&amp;gt; set a breakpoint in the &amp;lt;code&amp;gt;reader&amp;lt;/code&amp;gt; function so that the &amp;lt;code&amp;gt;reader&amp;lt;/code&amp;gt; threads would pause at line 129.&lt;br /&gt;
# Type &amp;lt;code&amp;gt;i th&amp;lt;/code&amp;gt;. This is an alias for &amp;lt;code&amp;gt;info threads&amp;lt;/code&amp;gt;. This causes GDB to print out all the threads currently in memory. Notice that there are three types of threads, &amp;lt;code&amp;gt;main&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;generator&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;reader&amp;lt;/code&amp;gt;. The &amp;lt;code&amp;gt;info threads&amp;lt;/code&amp;gt; command also shows that the &amp;lt;code&amp;gt;reader&amp;lt;/code&amp;gt; threads are all paused at line 129, the &amp;lt;code&amp;gt;generator&amp;lt;/code&amp;gt; thread is paused at line 165, and the &amp;lt;code&amp;gt;main&amp;lt;/code&amp;gt; thread is paused at line 119.&lt;br /&gt;
# Type &amp;lt;code&amp;gt;thread 5&amp;lt;/code&amp;gt;. This will select the third &amp;lt;code&amp;gt;reader&amp;lt;/code&amp;gt; thread.&lt;br /&gt;
# Type &amp;lt;code&amp;gt;thread apply 5 n&amp;lt;/code&amp;gt;. Then press 'enter' seven times. This will cause the third &amp;lt;code&amp;gt;reader&amp;lt;/code&amp;gt; thread to complete its task and exit gracefully using the &amp;lt;code&amp;gt;pthread_exit()&amp;lt;/code&amp;gt; function.&lt;br /&gt;
# Type &amp;lt;code&amp;gt;thread 1&amp;lt;/code&amp;gt;. This will select the &amp;lt;code&amp;gt;main&amp;lt;/code&amp;gt; thread.&lt;br /&gt;
# Type &amp;lt;code&amp;gt;p data&amp;lt;/code&amp;gt;. This will show the current state of the data structure that was passed to each thread. Note that each thread contains a pointer to the same data structure. This requires the use of what is known as a mutex (MUTual EXclusion) variable which is used to protect the data structure from concurrent modifications. In other words, any time the data structure is read or written to by one of the threads, they must first call the function pthread_&amp;lt;code&amp;gt;mutex_lock()&amp;lt;/code&amp;gt; to ensure that no other thread currently “has” the lock. When a thread is done with the shared data structure, it calls the function &amp;lt;code&amp;gt;pthread_mutex_unlock()&amp;lt;/code&amp;gt; to make the lock available to other threads. Notice that nothing about the mutex's inclusion in the data structure requires it to be used in order to read or write to the data structure. This means that any programmer who wishes to use threads to implement concurrent programming must pay close attention to code that accesses shared data structures to ensure concurrent modifications do not occur.&lt;br /&gt;
# Perform the previous four steps for as many of the &amp;lt;code&amp;gt;reader&amp;lt;/code&amp;gt; threads as you want. Notice that each one prints a message to standard out providing information about the state of the shared &amp;lt;code&amp;gt;data&amp;lt;/code&amp;gt; variable at the time that it has the lock. By switching to the &amp;lt;code&amp;gt;generator&amp;lt;/code&amp;gt; thread once the mutex variable is unlocked, that code can be stepped through to generate a new random number for the data structure. IMPORTANT: Do not execute a line of source code containing a call to &amp;lt;code&amp;gt;pthread_mutex_lock()&amp;lt;/code&amp;gt; without first ensuring that the mutex variable is unlocked. To do this, carefully perform the following steps:&lt;br /&gt;
## Type &amp;lt;code&amp;gt;p data-&amp;amp;gt;lock&amp;lt;/code&amp;gt;. This will show the values of the mutex variable in the &amp;lt;code&amp;gt;data&amp;lt;/code&amp;gt; structure variable. Make note of the value of the &amp;lt;code&amp;gt;owner&amp;lt;/code&amp;gt; field.&lt;br /&gt;
## Type &amp;lt;code&amp;gt;i th&amp;lt;/code&amp;gt;. This will show the current list of threads in the program. What follows is a possible output from these two commands:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;gdb&amp;quot;&amp;gt;&lt;br /&gt;
(gdb) p data-&amp;gt;lock&lt;br /&gt;
$3 = {__data = {__lock = 1, __count = 0, __owner = 1288, __kind = 0, __nusers = 1, {__spins = 0, __list = {__next = 0x0}}},&lt;br /&gt;
  __size = &amp;quot;\001\000\000\000\000\000\000\000\b\005\000\000\000\000\000\000\001\000\000\000\000\000\000&amp;quot;, __align = 1}&lt;br /&gt;
(gdb) i th&lt;br /&gt;
  9 Thread 1289  reader (arg=0xbeddec8c) at pthread_demo.c:129&lt;br /&gt;
  8 Thread 1288  reader (arg=0xbeddec8c) at pthread_demo.c:134&lt;br /&gt;
  7 Thread 1287  reader (arg=0xbeddec8c) at pthread_demo.c:129&lt;br /&gt;
  6 Thread 1286  0x00008b04 in reader (arg=0xbeddec8c) at pthread_demo.c:129&lt;br /&gt;
  3 Thread 1283  0x00008b04 in reader (arg=0xbeddec8c) at pthread_demo.c:129&lt;br /&gt;
* 2 Thread 1282  generator (arg=0xbeddec8c) at pthread_demo.c:165&lt;br /&gt;
  1 Thread 1281  0x00008a64 in main (argc=2, argv=0xbeddee24) at pthread_demo.c:119&lt;br /&gt;
(gdb)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Analysis of this output requires the understanding that the third column of the &amp;lt;code&amp;gt;i th&amp;lt;/code&amp;gt; output indicates that particular thread's process ID. The important part of the &amp;lt;code&amp;gt;p data-&amp;amp;gt;lock&amp;lt;/code&amp;gt; output is the &amp;lt;code&amp;gt;owner&amp;lt;/code&amp;gt; field, whose value will always either be zero or correspond to the process ID of one of the currently-running threads. In this case, the lock-&amp;amp;gt;__owner field clearly indicates that thread 8 currently owns the data-&amp;amp;gt;lock mutex variable. This would indicate that thread 8 should be stepped through until it has called the &amp;lt;code&amp;gt;pthread_mutex_unlock()&amp;lt;/code&amp;gt; function before stepping into a call to &amp;lt;code&amp;gt;pthread_mutex_lock()&amp;lt;/code&amp;gt; in any other function.&lt;br /&gt;
To summarize, always ensure that the &amp;lt;code&amp;gt;owner&amp;lt;/code&amp;gt; field of the mutex variable is equal to zero before using &amp;lt;code&amp;gt;pthread_mutex_lock()&amp;lt;/code&amp;gt; while debugging. If the lock is currently owned by another thread, GDB will hang until sent an interrupt signal which will require that the entire debug process be started over.&lt;br /&gt;
# The walktrhough is complete. There are two ways to end the debug session gracefully:&lt;br /&gt;
** Type &amp;lt;code&amp;gt;monitor exit&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;kill&amp;lt;/code&amp;gt; (confirm with 'y'), then &amp;lt;code&amp;gt;quit&amp;lt;/code&amp;gt;.&lt;br /&gt;
** Type &amp;lt;code&amp;gt;set scheduler-locking off&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;delete&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;thread 1&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;continue&amp;lt;/code&amp;gt;, then &amp;lt;code&amp;gt;monitor exit&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;kill&amp;lt;/code&amp;gt; (confirm with 'y'), &amp;lt;code&amp;gt;quit&amp;lt;/code&amp;gt;. This will allow the program to finish executing before ending the session.&lt;br /&gt;
&lt;br /&gt;
===GNU GDB Documentation===&lt;br /&gt;
&lt;br /&gt;
Again, for more information on how to debug with GDB, refer to the [http://sourceware.org/gdb/current/onlinedocs/gdb.html GDB Manual]. This is a valuable resource for anyone just learning to debug software and will go into much greater detail than is possible in this guide.&lt;br /&gt;
&lt;br /&gt;
==Next Steps==&lt;br /&gt;
&lt;br /&gt;
If you have not done so already, be sure to check out the [[EMAC OE SDK Example Projects]] or learn to create your own [[New Project]].&lt;br /&gt;
&lt;br /&gt;
Also, give the [[EMAC Eclipse IDE]] a try. Sometimes it is simpler to use an IDE for large projects, especially with the ability to automate the makefile creation process.&lt;/div&gt;</summary>
		<author><name>Mcoleman</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.emacinc.com/index.php?title=Building_Existing_Software_Packages_with_EMAC_OE_SDK&amp;diff=453</id>
		<title>Building Existing Software Packages with EMAC OE SDK</title>
		<link rel="alternate" type="text/html" href="https://wiki.emacinc.com/index.php?title=Building_Existing_Software_Packages_with_EMAC_OE_SDK&amp;diff=453"/>
		<updated>2013-05-17T16:57:09Z</updated>

		<summary type="html">&lt;p&gt;Mcoleman: Created page with &amp;quot;{| class=&amp;quot;wikitable conventions&amp;quot; !colspan=&amp;quot;2&amp;quot;|Table 1: Conventions |- | &amp;lt;code&amp;gt;target_program&amp;lt;/code&amp;gt; || The name of the application being debugged. This is the result of the Ma...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{| class=&amp;quot;wikitable conventions&amp;quot;&lt;br /&gt;
!colspan=&amp;quot;2&amp;quot;|Table 1: Conventions&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;target_program&amp;lt;/code&amp;gt; || The name of the application being debugged. This is the result of the Makefile build process. &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;target_machine&amp;lt;/code&amp;gt; || Connection information for the target machine. This can either be a serial port (ie. &amp;lt;code&amp;gt;/dev/ttyS2&amp;lt;/code&amp;gt;) or a TCP connection in the form of HOST:PORT.  &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;/path/to/sdk/&amp;lt;/code&amp;gt; ||  Represents the development system path to the EMAC OE SDK. &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
It is very common to need to be able to build existing software projects for the target hardware rather than developing the software from scratch. This feature is especially important in an open source environment, where countless libraries and utilities are available for use and often times need to be compiled to match the target architecture. Fortunately, EMAC OE SDK toolchains are standard GCC packages designed and configured to make this process as easy as possible. In addition, most software projects are developed to allow for cross-platform development.&lt;br /&gt;
&lt;br /&gt;
This guide provides an overview of the most common tasks associated with compiling existing software projects using the SDK. Note, however, that build methods differ significantly depending on the project design. Refer to the project documentation or support for information on how to cross-compile the software; the EMAC OE SDK can be treated as a standard GCC toolchain in this respect. Table 1 below denotes some conventions used in this guide.&lt;br /&gt;
&lt;br /&gt;
==Makefile-based Projects==&lt;br /&gt;
&lt;br /&gt;
Some projects have a build system based on a set of makefiles that are responsible for compiling and packaging the software. In general, configuring these projects to compile using the EMAC OE SDK is a simple process. In some instances, the software designers may have included a variable in the makefile which allows a cross-compiler prefix setting. In other cases, the CC and other makefile variables can be modified to direct make to compile using the EMAC OE SDK.&lt;br /&gt;
&lt;br /&gt;
It may be advantageous to add the cross-compiler bin directory to the system PATH variable temporarily before compiling to simplify Makefile modifications. This can be done with a command such as the following:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ export PATH=$PATH:/path/to/sdk/EMAC-OE-arm-linux-gnueabi-SDK_XX.YY/gcc-4.2.4-arm-linux-gnueabi/bin&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{mbox | type = notice | text = Note that running the command above will only affect the current terminal session.}}&lt;br /&gt;
&lt;br /&gt;
===MTD Utilities Project Example===&lt;br /&gt;
&lt;br /&gt;
The MTD Utilities project &amp;lt;code&amp;gt;mtd-utils&amp;lt;/code&amp;gt; is a good example of a Makefile-based build system that can easily be built using the EMAC OE SDK. Follow the steps below to accomplish this task.&lt;br /&gt;
&lt;br /&gt;
{{mbox | type = notice | text = The instructions in this section are valid as of the master git branch on 4/09/11. Future source changes may impact the required steps for compilation.}}&lt;br /&gt;
&lt;br /&gt;
# Begin by downloading the mtd-utils source code. Assuming that git is installed on the development system, run the following command to get the most recent version. Note that this version will be different from the stable release installed on EMAC OE systems by default.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ git clone git://git.infradead.org/mtd-utils.git &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
# After downloading the source, navigate to the source directory &amp;lt;code&amp;gt;mtd-utils&amp;lt;/code&amp;gt; and open &amp;lt;code&amp;gt;Makefile&amp;lt;/code&amp;gt; in the top-level directory. This file defines various make targets and compilation flags used to compile the source. Notice that the file &amp;lt;code&amp;gt;common.mk&amp;lt;/code&amp;gt; is sourced with the line include &amp;lt;code&amp;gt;common.mk&amp;lt;/code&amp;gt;. This is similar to the &amp;lt;code&amp;gt;global.properties&amp;lt;/code&amp;gt; file in the EMAC OE SDK.&lt;br /&gt;
# Close the &amp;lt;code&amp;gt;Makefile&amp;lt;/code&amp;gt; editor and open the &amp;lt;code&amp;gt;common.mk&amp;lt;/code&amp;gt; file. At the top of the file, &amp;lt;code&amp;gt;CC&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;AR&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;RANLIB&amp;lt;/code&amp;gt; are defined using the &amp;lt;code&amp;gt;CROSS&amp;lt;/code&amp;gt; variable, which is not set in either &amp;lt;code&amp;gt;common.mk&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;Makefile&amp;lt;/code&amp;gt;. An exert is shown below:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;make&amp;quot;&amp;gt;&lt;br /&gt;
CC := $(CROSS)gcc&lt;br /&gt;
AR := $(CROSS)ar&lt;br /&gt;
RANLIB := $(CROSS)ranlib&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
If the &amp;lt;code&amp;gt;CROSS&amp;lt;/code&amp;gt; variable is defined when &amp;lt;code&amp;gt;make&amp;lt;/code&amp;gt; is run, the specific toolchain to use can be specified. Also note that &amp;lt;code&amp;gt;CFLAGS&amp;lt;/code&amp;gt; is defined using a &amp;lt;code&amp;gt;?=&amp;lt;/code&amp;gt; assignment, which means that the assignment will only be made if &amp;lt;code&amp;gt;CFLAGS&amp;lt;/code&amp;gt; is undefined:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;make&amp;quot;&amp;gt;&lt;br /&gt;
CFLAGS ?= -O2 -g&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
# Close &amp;lt;code&amp;gt;common.mk&amp;lt;/code&amp;gt; without making any changes.&lt;br /&gt;
# In order to compile the source correctly, the &amp;lt;code&amp;gt;CROSS&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;CFLAGS&amp;lt;/code&amp;gt; variables should be defined. The tuning flags for the target architecture to be added to the &amp;lt;code&amp;gt;CFLAGS&amp;lt;/code&amp;gt; variable should be used from the &amp;lt;code&amp;gt;ARCHFLAGS&amp;lt;/code&amp;gt; variable in the &amp;lt;code&amp;gt;global.properties&amp;lt;/code&amp;gt; file of the EMAC OE SDK. The following steps utilize tuning flags for an armv5te processor-based system. Although the path to the SDK toolchain could be included directly in the &amp;lt;code&amp;gt;CROSS&amp;lt;/code&amp;gt; variable in this instance, this example works by adding the SDK toolchain to the system &amp;lt;code&amp;gt;PATH&amp;lt;/code&amp;gt; variable. The path and prefix used will differ depending on the target architecture of the EMAC OE SDK; refer to &amp;lt;code&amp;gt;global.properties&amp;lt;/code&amp;gt; in the SDK to determine the correct settings. The &amp;lt;code&amp;gt;DESTDIR&amp;lt;/code&amp;gt; variable controls where the files are put when running the &amp;lt;code&amp;gt;install&amp;lt;/code&amp;gt; make target. The &amp;lt;code&amp;gt;WITHOUT_XATTR&amp;lt;/code&amp;gt; flag must be set to disable features of the software that are not available on EMAC OE.&lt;br /&gt;
## Before compiling, several source changes are required to match the setup of the SDK. These include changing references from &amp;lt;code&amp;gt;lzo2&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;lzo&amp;lt;/code&amp;gt;, and changing the lzo include prefix. Run the following commands from the mtd-utils directory to make these changes:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ for file in `find . -name Makefile`; do sed -i 's:lzo2:lzo:g' $file; done&lt;br /&gt;
developer@ldc:~$ for file in `find . -name '*.c'`; do sed -i 's:lzo/::g' $file; done&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
## Run the following commands to set the variables:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ export PATH=$PATH:/path/to/sdk/EMAC-OE-arm-linux-gnueabi-SDK_XX.YY/gcc-4.2.4-arm-linux-gnueabi/bin&lt;br /&gt;
developer@ldc:~$ export CROSS=arm-linux-gnueabi-&lt;br /&gt;
developer@ldc:~$ export CFLAGS=&amp;quot;-O2 -g -march=armv5te -mtune=arm926ej-s&amp;quot;&lt;br /&gt;
developer@ldc:~$ export DESTDIR=Install&lt;br /&gt;
developer@ldc:~$ export WITHOUT_XATTR=1&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
# Once the environment has been set up, &amp;lt;code&amp;gt;make&amp;lt;/code&amp;gt; can be used to compile the source code:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ make all&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
# After successfully compiling the project, the &amp;lt;code&amp;gt;install&amp;lt;/code&amp;gt; make target can be used to package all of the software into the &amp;lt;code&amp;gt;Install&amp;lt;/code&amp;gt; directory as specified by the &amp;lt;code&amp;gt;DESTDIR&amp;lt;/code&amp;gt; variable:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ make install&lt;br /&gt;
developer@ldc:~$ ls -R Install&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
Install:&lt;br /&gt;
usr&lt;br /&gt;
 &lt;br /&gt;
Install/usr:&lt;br /&gt;
sbin  share&lt;br /&gt;
 &lt;br /&gt;
Install/usr/sbin:&lt;br /&gt;
docfdisk      flash_erase     flash_lock      flash_unlock  jffs2dump   nanddump   nftldump     rfddump      sumtool&lt;br /&gt;
doc_loadbios  flash_eraseall  flash_otp_dump  ftl_check     mkfs.jffs2  nandtest   nftl_format  rfdformat&lt;br /&gt;
flashcp       flash_info      flash_otp_info  ftl_format    mtd_debug   nandwrite  recv_image   serve_image&lt;br /&gt;
 &lt;br /&gt;
Install/usr/share:&lt;br /&gt;
man&lt;br /&gt;
 &lt;br /&gt;
Install/usr/share/man:&lt;br /&gt;
man1&lt;br /&gt;
 &lt;br /&gt;
Install/usr/share/man/man1:&lt;br /&gt;
mkfs.jffs2.1.gz&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
While the procedure in this example is specific to &amp;lt;code&amp;gt;mtd-utils&amp;lt;/code&amp;gt;, many makefile-based projects will require similar steps for cross-compiling.&lt;br /&gt;
&lt;br /&gt;
==Autotools-based Projects==&lt;br /&gt;
&lt;br /&gt;
The GNU build system is known as Autotools. Autotools is a group of applications that are designed to provide a configurable build system to allow compilation on different platforms and environments. A &amp;lt;code&amp;gt;configure&amp;lt;/code&amp;gt; script and set of input files are used to generate makefiles based on options passed to the configure script and deduced from the system environment. This includes tests for compiler options, library functions, install configuration, and other assorted variables.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;configure&amp;lt;/code&amp;gt; script is the most important step in building an autotools-based project. Although available options for &amp;lt;code&amp;gt;configure&amp;lt;/code&amp;gt; vary depending on the project design, there are common options shared between most autotools projects. &lt;br /&gt;
&lt;br /&gt;
===libConfuse Example Project===&lt;br /&gt;
&lt;br /&gt;
The libConfuse project is a simple C library written for parsing configuration files. It uses an autotools build system for configuration. The steps below demonstrate how to build libConfuse and should be used as an example for building other autotools-based projects. &lt;br /&gt;
&lt;br /&gt;
# The source code for the libConfuse project can be downloaded as described on the project website [http://www.nongnu.org/confuse/]. For this example, release 2.7 is used: [http://savannah.nongnu.org/download/confuse/confuse-2.7.tar.gz]. After downloading the source, extract the archive and navigate to the top-level directory of the project (i.e. `confuse-2.7`).&lt;br /&gt;
# Read through the &amp;lt;code&amp;gt;README&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;INSTALL&amp;lt;/code&amp;gt; files for information on the project and general information on how to build it. Also, look at the help output from &amp;lt;code&amp;gt;configure&amp;lt;/code&amp;gt; to see a summary of the available options:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ ./configure --help&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
# Before beginning, the system &amp;lt;code&amp;gt;PATH&amp;lt;/code&amp;gt; variable should be changed to include the SDK toolchain as in the makefile-based project example. The &amp;lt;code&amp;gt;CFLAGS&amp;lt;/code&amp;gt; variable should also be set. If the &amp;lt;code&amp;gt;CC&amp;lt;/code&amp;gt; variable is set, it should be set to &amp;lt;code&amp;gt;arm-linux-gnueabi-gcc&amp;lt;/code&amp;gt; (or the appropriate value for the target); if not set the compiler name will be detected from the options passed to configure. The &amp;lt;code&amp;gt;CFLAGS&amp;lt;/code&amp;gt; architecture tuning values should be set according to the &amp;lt;code&amp;gt;global.properties&amp;lt;/code&amp;gt; file in the EMAC OE SDK. The &amp;lt;code&amp;gt;DESTDIR&amp;lt;/code&amp;gt; variable determines where the files will be installed to when the &amp;lt;code&amp;gt;install&amp;lt;/code&amp;gt; make target is run. &amp;lt;code&amp;gt;DESTDIR&amp;lt;/code&amp;gt; must be an absolute path for the libConfuse project, so the current working directory is added to the variable using the &amp;lt;code&amp;gt;pwd&amp;lt;/code&amp;gt; command. The following commands are an example of how to set up the environment correctly:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ export CFLAGS=&amp;quot;-O2 -march=armv5te -mtune=arm926ej-s&amp;quot;&lt;br /&gt;
developer@ldc:~$ export DESTDIR=`pwd`/Install&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
# After setting the environment, &amp;lt;code&amp;gt;configure&amp;lt;/code&amp;gt; can be run with the appropriate options to configure the build system and generate the makefiles. The code below shows an example configuration used by EMAC OE. Be sure to set the host and target correctly based on the architecture:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ ./configure --build=i686-linux --host=arm-linux-gnueabi --target=arm-linux-gnueabi \&lt;br /&gt;
        --prefix=/usr --exec_prefix=/usr --bindir=/usr/bin --sbindir=/usr/sbin \&lt;br /&gt;
        --datadir=/usr/share  \&lt;br /&gt;
        --infodir=/usr/share/info \&lt;br /&gt;
        --mandir=/usr/share/man --enable-shared&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The configuration should complete successfully. If any problems are reported that result in an error, check the environment settings and &amp;lt;code&amp;gt;configure&amp;lt;/code&amp;gt; options again. &lt;br /&gt;
# Now that &amp;lt;code&amp;gt;configure&amp;lt;/code&amp;gt; has generated all of the makefiles for the project, &amp;lt;code&amp;gt;make&amp;lt;/code&amp;gt; can be used to compile the source code:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ make all&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
If any errors are encountered during compilation, examine the output of &amp;lt;code&amp;gt;configure&amp;lt;/code&amp;gt; and make sure that all of the environment variables and &amp;lt;code&amp;gt;configure&amp;lt;/code&amp;gt; options were specified correctly. &lt;br /&gt;
# Once compilation is complete, the &amp;lt;code&amp;gt;install&amp;lt;/code&amp;gt; target can be used to package all of the necessary files together so that they can be transferred to the target board.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ make install&lt;br /&gt;
developer@ldc:~$ ls -R Install&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
Install:&lt;br /&gt;
usr&lt;br /&gt;
 &lt;br /&gt;
Install/usr:&lt;br /&gt;
include  lib  share&lt;br /&gt;
 &lt;br /&gt;
Install/usr/include:&lt;br /&gt;
confuse.h&lt;br /&gt;
 &lt;br /&gt;
Install/usr/lib:&lt;br /&gt;
libconfuse.a  libconfuse.la  libconfuse.so  libconfuse.so.0  libconfuse.so.0.0.0  pkgconfig&lt;br /&gt;
 &lt;br /&gt;
Install/usr/lib/pkgconfig:&lt;br /&gt;
libconfuse.pc&lt;br /&gt;
 &lt;br /&gt;
Install/usr/share:&lt;br /&gt;
locale&lt;br /&gt;
 &lt;br /&gt;
Install/usr/share/locale:&lt;br /&gt;
fr  sv&lt;br /&gt;
 &lt;br /&gt;
Install/usr/share/locale/fr:&lt;br /&gt;
LC_MESSAGES&lt;br /&gt;
 &lt;br /&gt;
Install/usr/share/locale/fr/LC_MESSAGES:&lt;br /&gt;
confuse.mo&lt;br /&gt;
 &lt;br /&gt;
Install/usr/share/locale/sv:&lt;br /&gt;
LC_MESSAGES&lt;br /&gt;
 &lt;br /&gt;
Install/usr/share/locale/sv/LC_MESSAGES:&lt;br /&gt;
confuse.mo&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Note that not all of the files installed would be necessary to install on the board, such as the man pages and pkgconfig information.&lt;/div&gt;</summary>
		<author><name>Mcoleman</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.emacinc.com/index.php?title=Remote_Debugging_EMAC_OE_SDK_Projects_with_gdbserver&amp;diff=427</id>
		<title>Remote Debugging EMAC OE SDK Projects with gdbserver</title>
		<link rel="alternate" type="text/html" href="https://wiki.emacinc.com/index.php?title=Remote_Debugging_EMAC_OE_SDK_Projects_with_gdbserver&amp;diff=427"/>
		<updated>2013-05-10T22:39:20Z</updated>

		<summary type="html">&lt;p&gt;Mcoleman: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{| class=&amp;quot;wikitable conventions&amp;quot;&lt;br /&gt;
!colspan=&amp;quot;2&amp;quot;|Table 1: Conventions&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;target_program&amp;lt;/code&amp;gt; || The name of the application being debugged. This is the result of the Makefile build process. &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;target_machine&amp;lt;/code&amp;gt; || Connection information for the target machine. This can either be a serial port (ie. &amp;lt;code&amp;gt;/dev/ttyS2&amp;lt;/code&amp;gt;) or a TCP connection in the form of HOST:PORT.  &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;/path/to/sdk/&amp;lt;/code&amp;gt; ||  Represents the development system path to the EMAC OE SDK. &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
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 binary resulting from the compile 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 while running the debugger.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
This guide is intended to build a basic understanding of how to use gdbserver with EMAC products. It is not intended as a general guide to debugging computer programs. For help with that, see the GDB man pages on the development system or read [this manual] on debugging with GDB.&lt;br /&gt;
&lt;br /&gt;
==Setup==&lt;br /&gt;
&lt;br /&gt;
Using &amp;lt;code&amp;gt;gdbserver&amp;lt;/code&amp;gt; involves setting up both the target machine and the development machine. This requires that the binary application be present on both development and target machines. The development machine copy of the application must be compiled with debug flags whereas this is not strictly necessary for the target machine. See the [Optional &amp;lt;code&amp;gt;global.properties&amp;lt;/code&amp;gt; Modifications Section] on the New EMAC OE SDK Project Guide for more information. See the [[[EMAC OE Getting Started Guide]]] for more information on how to connect to the target EMAC product using a serial port or Ethernet connection.&lt;br /&gt;
&lt;br /&gt;
===Target Machine===&lt;br /&gt;
&lt;br /&gt;
Because EMAC OE builds are distributed with &amp;lt;code&amp;gt;gdbserver&amp;lt;/code&amp;gt;, installation is not a concern. The only setup necessary is to run &amp;lt;code&amp;gt;gdbserver&amp;lt;/code&amp;gt; with &amp;lt;code&amp;gt;target_program&amp;lt;/code&amp;gt;: &lt;br /&gt;
&lt;br /&gt;
# If the target application is already running, use the attachpid option to connect &amp;lt;code&amp;gt;gdbserver&amp;lt;/code&amp;gt; to the application as shown below. The &amp;lt;code&amp;gt;PID&amp;lt;/code&amp;gt; argument can be determined using &amp;lt;code&amp;gt;pidof&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ pidof target_program&lt;br /&gt;
developer@ldc:~$ gdbserver target_machine --attach PID&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
# If the target application is not already running, the name of the binary may be included as an argument to the &amp;lt;code&amp;gt;gdbserver&amp;lt;/code&amp;gt; program call.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;snytaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ gdbserver target_machine target_program [ARGS]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This establishes a &amp;lt;code&amp;gt;gdbserver&amp;lt;/code&amp;gt; port on the target machine that listens for incoming connections from GDB on the development machine. In debug terminology, &amp;lt;code&amp;gt;gdbserver&amp;lt;/code&amp;gt; is “attached” to the process ID of the program being debugged. In reality, though, GDB is attached to the process ID of a proxy which passes the messages to and from the remote device under test. &lt;br /&gt;
&lt;br /&gt;
The next step is to run GDB on the development machine using the &amp;lt;code&amp;gt;target_program&amp;lt;/code&amp;gt;/&lt;br /&gt;
&lt;br /&gt;
===Development Machine===&lt;br /&gt;
&lt;br /&gt;
# First, &amp;lt;code&amp;gt;cd&amp;lt;/code&amp;gt; to the directory where the targe executable is stored.&lt;br /&gt;
# Run the EMAC OE SDK GDB:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ /path/to/sdk/EMAC-OE-arm-linux-gnueabi-SDK_4.0/gcc-4.2.4-arm-linux-gnueabi/bin/arm-linux-gnueabi-gdb target_program&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
# Run the following commands in GDB to prepare for the debug session:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;gdb&amp;quot;&amp;gt;&lt;br /&gt;
(gdb) target remote target_machine&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{mbox | type = warning | text = Note that the location of the GDB in the toolchain may differ from what is shown above depending on which version of the SDK is used.}}&lt;br /&gt;
&lt;br /&gt;
{{mbox | type = notice | text = If the gdb executable, or any other executable you run, is located in a directory which is in the PATH environment variable, you can simply run that command without the long path prefix. Sourcing the environment variables generated by the EMAC script for this will provide you with such a path. The script which creates the file to source also creates a symbolic link for arm-linux-gnueabi-gdb called, simply, gdb. With your shell environment setup this way, you could simply execute: &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ gdb target_program&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
in place of the long command given in step 2, above.&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
==Sample GDB Session==&lt;br /&gt;
&lt;br /&gt;
This example GDB session uses the EMAC OE SDK example project named &amp;lt;code&amp;gt;pthread_demo&amp;lt;/code&amp;gt;. It consists of the single source file &amp;lt;code&amp;gt;pthread_demo.c&amp;lt;/code&amp;gt;. The program is called with a single integer argument indicating how many &amp;lt;code&amp;gt;reader&amp;lt;/code&amp;gt; threads the user wishes to create. The following describes the tasks of the &amp;lt;code&amp;gt;main&amp;lt;/code&amp;gt; thread: &lt;br /&gt;
&lt;br /&gt;
# The &amp;lt;code&amp;gt;main&amp;lt;/code&amp;gt; thread performs user input validation. It prints a usage message according to the argument passed to it on the command line. The function expects the user to pass a number indicating how many threads should be spawned.&lt;br /&gt;
# The &amp;lt;code&amp;gt;main&amp;lt;/code&amp;gt; thread initiates a new thread which uses the &amp;lt;code&amp;gt;generator()&amp;lt;/code&amp;gt; function to perform the following tasks:&lt;br /&gt;
## Checks to see if the number of &amp;lt;code&amp;gt;reader&amp;lt;/code&amp;gt; threads matches the number of times a &amp;lt;code&amp;gt;reader&amp;lt;/code&amp;gt; thread has acquired the mutex lock and performed its task. If the two values do match, then the &amp;lt;code&amp;gt;generator&amp;lt;/code&amp;gt; thread unlocks the mutex, breaks out of the while loop and moves on to line 167 to gracefully exit. If the two values do not match, then the &amp;lt;code&amp;gt;generator&amp;lt;/code&amp;gt; thread continues through the rest of the while loop described in steps 2.2 and 2.3.&lt;br /&gt;
## Generates random data to be stored in the data struct shared by all the threads. To do this, it protects the data struct with the use of a mutex variable.&lt;br /&gt;
## Sleeps after giving up its lock on the mutex so that another thread might have a chance to acquire the lock.&lt;br /&gt;
# After creating the &amp;lt;code&amp;gt;generator&amp;lt;/code&amp;gt; thread the &amp;lt;code&amp;gt;main&amp;lt;/code&amp;gt; thread iteratively creates as many &amp;lt;code&amp;gt;reader&amp;lt;/code&amp;gt; threads as indicated by the single integer argument. Each &amp;lt;code&amp;gt;reader&amp;lt;/code&amp;gt; thread performs the following tasks:&lt;br /&gt;
## Waits for a chance to acquire the mutex &amp;lt;code&amp;gt;lock&amp;lt;/code&amp;gt;. Once the mutex &amp;lt;code&amp;gt;lock&amp;lt;/code&amp;gt; is acquired, it prints the value of the random number &amp;lt;code&amp;gt;generated&amp;lt;/code&amp;gt; by the generator thread in its last run.&lt;br /&gt;
## Increments an integer in the &amp;lt;code&amp;gt;data&amp;lt;/code&amp;gt; struct to indicate that it has completed its task.&lt;br /&gt;
## Gives up its lock on the mutex and exits.&lt;br /&gt;
# After creating the prescribed number of &amp;lt;code&amp;gt;reader&amp;lt;/code&amp;gt; threads, the &amp;lt;code&amp;gt;main&amp;lt;/code&amp;gt; thread then waits for each thread created to exit gracefully. &lt;br /&gt;
# The &amp;lt;code&amp;gt;main&amp;lt;/code&amp;gt; thread exists.&lt;br /&gt;
&lt;br /&gt;
The SDK version of &amp;lt;code&amp;gt;pthread_demo.c&amp;lt;/code&amp;gt; works according to the description above with a &amp;lt;code&amp;gt;MAX_THREAD&amp;lt;/code&amp;gt; value of 100. However, for the purpose of this example debug session it is instructive to use a faulty version of the same program. Replace lines 75-80 in &amp;lt;code&amp;gt;pthread_demo.c&amp;lt;/code&amp;gt; with the code snippet shown in Listing 1 below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
if ((data.num_threads &amp;lt; 1) || (data.num_threads &amp;lt; MAX_THREAD)) {&lt;br /&gt;
        fprintf(stderr,&lt;br /&gt;
                &amp;quot;The number of thread should between 1 and %d\n&amp;quot;,&lt;br /&gt;
                MAX_THREAD);&lt;br /&gt;
        exit(EXIT_FAILURE);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Useful GDB Commands===&lt;br /&gt;
&lt;br /&gt;
The following is a brief description of some essential GDB commands. Each description is followed by a link to the official GDB documentation page that has more specific information about what the command does and how to use it. Please note that the official GDB documentation is targeted for the latest GDB release which at the time of writing this documentation is 7.4. The version of GDB that EMAC distributes with the OE products, however, is version 6.8. Because of this, the links to documentation below may provide slightly different information. The biggest difference between the two version of GDB, however, is in the support for debugging programs with multiple threads. This is reflected in the documentation as well. Because of this, EMAC has set up ftp access to GDB 6.8 documentation on its web server. It is highly recommended that the GDB 6.8 documentation be referenced in cases where the program does not seem to support commands or options specified in the current official documentation. &lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Command !! Description &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;start/run&amp;lt;/code&amp;gt;&lt;br /&gt;
|| These commands are used to start the debugged program with the only difference being that start automatically pauses execution at the beginning of the program's main function whereas run must be told explicitly where to pause using the breakpoint command listed below.&lt;br /&gt;
See also [Debugging with GDB, Section 4.2: Starting your Program]&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;kill&amp;lt;/code&amp;gt;&lt;br /&gt;
|| Used to kill the currently-running instance of target_program.&lt;br /&gt;
See also [Debugging with GDB, Section 4.9: Killing the Child Process]&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;print&amp;lt;/code&amp;gt;&lt;br /&gt;
|| Used to print the value of an expression.&lt;br /&gt;
See also [Debugging with GDB, Section 10: Examining Data]&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;list&amp;lt;/code&amp;gt;&lt;br /&gt;
|| List contents of function or specified line.&lt;br /&gt;
See also [Debugging with GDB, Section 9: Examining Source Files]&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;layout&amp;lt;/code&amp;gt;&lt;br /&gt;
|| This is a TUI (Text User Interface) command that enables the programmer to view multiple debug views at once including source code, assembly, and registers.&lt;br /&gt;
See also [Debugging with GDB, Section 25.4: TUI Commands]&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;disassemble&amp;lt;/code&amp;gt;&lt;br /&gt;
|| This command allows the programmer to see assembler instructions.&lt;br /&gt;
See also [Debugging with GDB, Section 9.6: Source and Machine Code]&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;break&amp;lt;/code&amp;gt;&lt;br /&gt;
|| This command specifies a function name, line number, or instruction at which GDB is to pause execution.&lt;br /&gt;
See also [Debugging with GDB, Section 5.1: Breakpoints]&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;next/nexti, step/stepi&amp;lt;/code&amp;gt;&lt;br /&gt;
|| Allow the programmer to step through a program without specifying breakpoints. The &amp;lt;code&amp;gt;next/nexti&amp;lt;/code&amp;gt; commands step over function calls, stopping on the next line of the same stack frame; &amp;lt;code&amp;gt;step/stepi&amp;lt;/code&amp;gt;, step into function calls, stopping on the first line in the next stack frame. The difference between &amp;lt;code&amp;gt;step/next&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;stepi/nexti&amp;lt;/code&amp;gt; is that the &amp;lt;code&amp;gt;i&amp;lt;/code&amp;gt; indicates instruction-by-instruction stepping at the assembly language level.&lt;br /&gt;
See also [Debugging with GDB, Section 5.2: Continuing and Stepping]&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;continue&amp;lt;/code&amp;gt;&lt;br /&gt;
|| Used to continue program execution from the address where it was last stopped.&lt;br /&gt;
See the Debugging with GDB link for &amp;lt;code&amp;gt;next/step&amp;lt;/code&amp;gt; for more information about the &amp;lt;code&amp;gt;continue&amp;lt;/code&amp;gt; command.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;bt&amp;lt;/code&amp;gt;&lt;br /&gt;
|| Short for &amp;quot;backtrace,&amp;quot; which displays to the programmer a brief summary of execution up to the current point in the program. This is useful because it shows a nested list of stack frames starting with the current one.&lt;br /&gt;
See also [Debugging with GDB, Section 8.2: Backtrace]&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;quit&amp;lt;/code&amp;gt;&lt;br /&gt;
||  This will quit the debugging session, and return you to the shell. The Control-D key combination is another way to accomplish this.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Session Walk-through===&lt;br /&gt;
&lt;br /&gt;
This debug session walk-through assumes that the program has been compiled using the modified source code above and that both the target machine and the development machine have been set up according to the above Setup section. The walk-through is divided into multiple “lessons” with the intent of first introducing the use of the commands described above and then actually running GDB to debug a known programming problem. Each lesson may be run independently of the others, but it is recommended that each be run in order starting from Lesson 1 for the first time through.&lt;br /&gt;
&lt;br /&gt;
====Lesson 1: Navigation and Code Display====&lt;br /&gt;
&lt;br /&gt;
This lesson assumes that &amp;lt;code&amp;gt;gdbserver&amp;lt;/code&amp;gt; has been run as in the [Target Machine Setup] section above with an ARG value of 3. Other values are fine so long as they fall within the range of 1 to 100. The number '3' was arbitrarily chosen to avoid having to use a symbolic variable in the explanations below.&lt;br /&gt;
&lt;br /&gt;
# Type &amp;lt;code&amp;gt;b main&amp;lt;/code&amp;gt; to set a breakpoint at the main function in the source code.&lt;br /&gt;
# Type &amp;lt;code&amp;gt;continue&amp;lt;/code&amp;gt;. This will cause the program to continue from the breakpoint set by GDB at startup. The program was passed an argument of 3, indicating that three threads should be created. &lt;br /&gt;
# Type &amp;lt;code&amp;gt;b 73&amp;lt;/code&amp;gt; to set a breakpoint at line 73 in the source code, which should be the line containing &amp;lt;code&amp;gt;data.num_threads = atoi(argv[1]);&amp;lt;/code&amp;gt;&lt;br /&gt;
# Type &amp;lt;code&amp;gt;continue&amp;lt;/code&amp;gt;. The program will continue execution up until line 73 in the source code. At this point, type layout split to view a split screen containing both the source code and the assembly-level machine instructions. Both screens show the program's current location in execution. The assembly-level display shows what the target's processor is actually executing at that point in the source code as shown in the source-level display. To view either of these without the other type layout &amp;lt;code&amp;gt;asm&amp;lt;/code&amp;gt; for just assembly-level and &amp;lt;code&amp;gt;layout src&amp;lt;/code&amp;gt; for just source-level.&lt;br /&gt;
# Type &amp;lt;code&amp;gt;nexti&amp;lt;/code&amp;gt;. This will cause the program to execute the next instruction in the current stack frame which is a mov instruction beginning to prepare the current stack for a call to the library function &amp;lt;code&amp;gt;atoi()&amp;lt;/code&amp;gt;. The details of this process are beyond the scope of this tutorial; essentially, the program needs to store information about the current execution location in the stack for when the &amp;lt;code&amp;gt;atoi()&amp;lt;/code&amp;gt; function finishes. Type &amp;lt;code&amp;gt;ni&amp;lt;/code&amp;gt; (alias for nexti) three more times. You should end up on a &amp;lt;code&amp;gt;bl&amp;lt;/code&amp;gt; instruction in the assembly view as shown in Listing 2 below. The source layout should still show the program on line 73.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;asm&amp;quot;&amp;gt;&lt;br /&gt;
B+ |0x887c &amp;lt;main+112&amp;gt;       ldr    r3, [r11, #-84]                   │&lt;br /&gt;
   |0x8880 &amp;lt;main+116&amp;gt;       add    r3, r3, #4      ; 0x4             │&lt;br /&gt;
   |0x8884 &amp;lt;main+120&amp;gt;       ldr    r3, [r3]                          │&lt;br /&gt;
   |0x8888 &amp;lt;main+124&amp;gt;       mov    r0, r3                            │&lt;br /&gt;
  &amp;gt;|0x888c &amp;lt;main+128&amp;gt;       bl     0x86e0 &amp;lt;atoi&amp;gt;                     │&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
'''Listing 2. GDB Assembly Layout''' - ''Note that the assembly may look different depending on the target architecture.''&lt;br /&gt;
# Type &amp;lt;code&amp;gt;stepi&amp;lt;/code&amp;gt;. This will cause the program to move into the next stack frame and GDB to show the assembly-level instructions of the &amp;lt;code&amp;gt;atoi()&amp;lt;/code&amp;gt; call. Since the library containing &amp;lt;code&amp;gt;atoi()&amp;lt;/code&amp;gt; was likely not compiled with debug symbols, the source-level layout will show the message &amp;lt;code&amp;gt;[ No Source Available ]&amp;lt;/code&amp;gt;.&lt;br /&gt;
# Type &amp;lt;code&amp;gt;bt&amp;lt;/code&amp;gt;. This will cause the program to display a human-readable version of the current stack. Each stack “frame” is represented by the name of the function call it represents with that function's location in memory. Type &amp;lt;code&amp;gt;bt full&amp;lt;/code&amp;gt; to get a list of the variables local to each stack frame.&lt;br /&gt;
# Type &amp;lt;code&amp;gt;finish&amp;lt;/code&amp;gt;. This will cause the current stack frame to return and execution to pause on the next instruction of the previous stack frame.&lt;br /&gt;
# Type &amp;lt;code&amp;gt;kill&amp;lt;/code&amp;gt;. This will cause the current process to be killed by &amp;lt;code&amp;gt;gdbserver&amp;lt;/code&amp;gt; at the target machine. &amp;lt;code&amp;gt;gdbserver&amp;lt;/code&amp;gt; will also terminate at this point. In order to start a new remote debug session, start gdbserver as described in the Target Machine Setup section and re-run step 3 of the [Development Machine Setup] section.&lt;br /&gt;
&lt;br /&gt;
{{mbox | type = warning | text = '''Note:''' &amp;lt;code&amp;gt;b&amp;lt;/code&amp;gt; is an alias for the &amp;lt;code&amp;gt;break&amp;lt;/code&amp;gt; command. &lt;br /&gt;
&amp;lt;code&amp;gt;ni&amp;lt;/code&amp;gt; is an alias for &amp;lt;code&amp;gt;nexti&amp;lt;/code&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
====Lesson 2: Finding the Bug====&lt;br /&gt;
&lt;br /&gt;
Though this sample is contrived, it is still useful to demonstrate how to find a design mistake in an otherwise well-written (no errors or warnings) program. These types of mistakes typically have to do with the array boundary miscalculations, logic and comparison operator mistakes, or other simple mistakes. For the sake of demonstration, assume that the actual mistake is unknown. This lesson assumes that gdbserver has just been started as in the [Target Machine] Setup above with an &amp;lt;code&amp;gt;ARG&amp;lt;/code&amp;gt; value of 5.&lt;br /&gt;
&lt;br /&gt;
# Before starting the program in the debugger again, run it by itself on the target machine to see what the actual program output is: &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@emac-oe:~# /tmp/pthread_demo 5&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
The number of threads should be between 1 and 100&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The program was given an input of '5' yet the output message seems to indicate that this is out of range which is obviously not true.&lt;br /&gt;
# Start the debugger again and connect to the target machine as described in the Setup section.&lt;br /&gt;
# Type &amp;lt;code&amp;gt;b main&amp;lt;/code&amp;gt; to set a breakpoint at the main function in the source code.&lt;br /&gt;
# Type &amp;lt;code&amp;gt;continue&amp;lt;/code&amp;gt;. This will cause the program to continue from the breakpoint set by GDB at startup. &lt;br /&gt;
# Type &amp;lt;code&amp;gt;n&amp;lt;/code&amp;gt;. This will cause the program to step over the next line of source code. The reason for using &amp;lt;code&amp;gt;n&amp;lt;/code&amp;gt; rather than &amp;lt;code&amp;gt;s&amp;lt;/code&amp;gt; or one of the instruction stepping commands is because the erroneous output indicates that the coding mistake is in the programmer's source code rather than the c library functions &amp;lt;code&amp;gt;atoi()&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;fprintf()&amp;lt;/code&amp;gt;. Stepping over the function will save all the time required to step through every detail of what the library functions are doing. Later passes through the code can be used to step into functions called from within that stack frame if the first pass proves unsuccessful.&lt;br /&gt;
# Continue to type &amp;lt;code&amp;gt;n&amp;lt;/code&amp;gt; until one of the program's &amp;lt;code&amp;gt;exit()&amp;lt;/code&amp;gt; calls is reached, but do not actually step into that &amp;lt;code&amp;gt;exit()&amp;lt;/code&amp;gt; call. Judging by the program's output above, this should bring you to the conditional block that checks the value of the local variable n used to store the output of &amp;lt;code&amp;gt;atoi()&amp;lt;/code&amp;gt; as shown in Listing 3. Note that once execution reaches line 79 of the source code, GDB will display the output of the &amp;lt;code&amp;gt;fprintf()&amp;lt;/code&amp;gt; function from line 76. This may cause display problems within the text-based UI library that GDB uses which will require the command refresh to fix.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;gdb&amp;quot;&amp;gt;&lt;br /&gt;
B+ |75              if ((data.num_threads &amp;lt; 1) || (data.num_threads &amp;lt; MAX_THREAD)) {       |&lt;br /&gt;
   |76                      fprintf(stderr,                                                |&lt;br /&gt;
   |77                              &amp;quot;The number of thread should between 1 and %d\n&amp;quot;,      |&lt;br /&gt;
   |78                              MAX_THREAD);                                           |&lt;br /&gt;
  &amp;gt;|79                      exit(EXIT_FAILURE);                                            |&lt;br /&gt;
   |80              }                                                                      |&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
# Type &amp;lt;code&amp;gt;p/d data→num_threads&amp;lt;/code&amp;gt;. &amp;lt;code&amp;gt;p&amp;lt;/code&amp;gt; is an alias for &amp;lt;code&amp;gt;print&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;/d&amp;lt;/code&amp;gt; tells GDB to treat the expression requested as an integer in signed decimal, and &amp;lt;code&amp;gt;data→num&amp;lt;/code&amp;gt;_threads is the element &amp;lt;code&amp;gt;num_threads&amp;lt;/code&amp;gt; within &amp;lt;code&amp;gt;struct thread_data&amp;lt;/code&amp;gt;. This should provide the following output:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;gdb&amp;quot;&amp;gt;&lt;br /&gt;
(gdb) p/d data-&amp;gt;num_threads&lt;br /&gt;
$6 = 5&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Note that the integer part of &amp;lt;code&amp;gt;$6&amp;lt;/code&amp;gt; will increment with each call to the gdb command &amp;lt;code&amp;gt;print&amp;lt;/code&amp;gt;. The above output confirms that the argument '5' was successfully passed to the program and read into a variable to be tested, indicating that one of the logical tests for the current conditional block contains a mistake. This merits a closer look at line 75:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;gdb&amp;quot;&amp;gt;&lt;br /&gt;
B+ |75              if ((data.num_threads &amp;lt; 1) || (data.num_threads &amp;lt; MAX_THREAD)) {       |&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Line 75 consists of a conditional test which is the logical OR of two arithmetic tests involving the values of &amp;lt;code&amp;gt;data.num_threads&amp;lt;/code&amp;gt;, '1', and &amp;lt;code&amp;gt;MAX_THREAD&amp;lt;/code&amp;gt;. The first test is true the input integer is less than &amp;lt;code&amp;gt;1–(data.num_threads &amp;amp;lt; 1)&amp;lt;/code&amp;gt;. The second tests whether the input integer is less than the symbolic constant, &amp;lt;code&amp;gt;MAX_THREAD–(data.num_threads &amp;amp;lt; MAX_THREAD)&amp;lt;/code&amp;gt;. Judging by the name of this constant and the result of the test (we know it resolves to true because the value of &amp;lt;code&amp;gt;data.num_threads&amp;lt;/code&amp;gt; in this case is not less than one), we can see that the comparison operator used is the culprit. The correct interpretation is that it should be '&amp;amp;gt;' rather than '&amp;amp;lt;'.&lt;br /&gt;
# Type &amp;lt;code&amp;gt;kill&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
This was a simple problem to solve but the method used above could apply in any situation where source code compiles and runs without errors yet provides varied or unexpected output.&lt;br /&gt;
&lt;br /&gt;
# test&lt;br /&gt;
# test 2&lt;br /&gt;
# test 3&lt;br /&gt;
test 3 &lt;br /&gt;
test 3&lt;br /&gt;
test 3&lt;br /&gt;
&amp;lt;code&amp;gt;test 3&amp;lt;/code&amp;gt;&lt;br /&gt;
# test 4&lt;br /&gt;
# test 5&lt;/div&gt;</summary>
		<author><name>Mcoleman</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.emacinc.com/index.php?title=Remote_Debugging_EMAC_OE_SDK_Projects_with_gdbserver&amp;diff=426</id>
		<title>Remote Debugging EMAC OE SDK Projects with gdbserver</title>
		<link rel="alternate" type="text/html" href="https://wiki.emacinc.com/index.php?title=Remote_Debugging_EMAC_OE_SDK_Projects_with_gdbserver&amp;diff=426"/>
		<updated>2013-05-10T21:48:27Z</updated>

		<summary type="html">&lt;p&gt;Mcoleman: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{| class=&amp;quot;wikitable conventions&amp;quot;&lt;br /&gt;
!colspan=&amp;quot;2&amp;quot;|Table 1: Conventions&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;target_program&amp;lt;/code&amp;gt; || The name of the application being debugged. This is the result of the Makefile build process. &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;target_machine&amp;lt;/code&amp;gt; || Connection information for the target machine. This can either be a serial port (ie. &amp;lt;code&amp;gt;/dev/ttyS2&amp;lt;/code&amp;gt;) or a TCP connection in the form of HOST:PORT.  &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;/path/to/sdk/&amp;lt;/code&amp;gt; ||  Represents the development system path to the EMAC OE SDK. &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
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 binary resulting from the compile 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 while running the debugger.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
This guide is intended to build a basic understanding of how to use gdbserver with EMAC products. It is not intended as a general guide to debugging computer programs. For help with that, see the GDB man pages on the development system or read [this manual] on debugging with GDB.&lt;br /&gt;
&lt;br /&gt;
==Setup==&lt;br /&gt;
&lt;br /&gt;
Using &amp;lt;code&amp;gt;gdbserver&amp;lt;/code&amp;gt; involves setting up both the target machine and the development machine. This requires that the binary application be present on both development and target machines. The development machine copy of the application must be compiled with debug flags whereas this is not strictly necessary for the target machine. See the [Optional &amp;lt;code&amp;gt;global.properties&amp;lt;/code&amp;gt; Modifications Section] on the New EMAC OE SDK Project Guide for more information. See the [[[EMAC OE Getting Started Guide]]] for more information on how to connect to the target EMAC product using a serial port or Ethernet connection.&lt;br /&gt;
&lt;br /&gt;
===Target Machine===&lt;br /&gt;
&lt;br /&gt;
Because EMAC OE builds are distributed with &amp;lt;code&amp;gt;gdbserver&amp;lt;/code&amp;gt;, installation is not a concern. The only setup necessary is to run &amp;lt;code&amp;gt;gdbserver&amp;lt;/code&amp;gt; with &amp;lt;code&amp;gt;target_program&amp;lt;/code&amp;gt;: &lt;br /&gt;
&lt;br /&gt;
# If the target application is already running, use the attachpid option to connect &amp;lt;code&amp;gt;gdbserver&amp;lt;/code&amp;gt; to the application as shown below. The &amp;lt;code&amp;gt;PID&amp;lt;/code&amp;gt; argument can be determined using &amp;lt;code&amp;gt;pidof&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ pidof target_program&lt;br /&gt;
developer@ldc:~$ gdbserver target_machine --attach PID&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
# If the target application is not already running, the name of the binary may be included as an argument to the &amp;lt;code&amp;gt;gdbserver&amp;lt;/code&amp;gt; program call.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;snytaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ gdbserver target_machine target_program [ARGS]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This establishes a &amp;lt;code&amp;gt;gdbserver&amp;lt;/code&amp;gt; port on the target machine that listens for incoming connections from GDB on the development machine. In debug terminology, &amp;lt;code&amp;gt;gdbserver&amp;lt;/code&amp;gt; is “attached” to the process ID of the program being debugged. In reality, though, GDB is attached to the process ID of a proxy which passes the messages to and from the remote device under test. &lt;br /&gt;
&lt;br /&gt;
The next step is to run GDB on the development machine using the &amp;lt;code&amp;gt;target_program&amp;lt;/code&amp;gt;/&lt;br /&gt;
&lt;br /&gt;
===Development Machine===&lt;br /&gt;
&lt;br /&gt;
# First, &amp;lt;code&amp;gt;cd&amp;lt;/code&amp;gt; to the directory where the targe executable is stored.&lt;br /&gt;
# Run the EMAC OE SDK GDB:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ /path/to/sdk/EMAC-OE-arm-linux-gnueabi-SDK_4.0/gcc-4.2.4-arm-linux-gnueabi/bin/arm-linux-gnueabi-gdb target_program&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
# Run the following commands in GDB to prepare for the debug session:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;gdb&amp;quot;&amp;gt;&lt;br /&gt;
(gdb) target remote target_machine&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{mbox | type = warning | text = Note that the location of the GDB in the toolchain may differ from what is shown above depending on which version of the SDK is used.}}&lt;br /&gt;
&lt;br /&gt;
{{mbox | type = notice | text = If the gdb executable, or any other executable you run, is located in a directory which is in the PATH environment variable, you can simply run that command without the long path prefix. Sourcing the environment variables generated by the EMAC script for this will provide you with such a path. The script which creates the file to source also creates a symbolic link for arm-linux-gnueabi-gdb called, simply, gdb. With your shell environment setup this way, you could simply execute: &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ gdb target_program&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
in place of the long command given in step 2, above.&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
==Sample GDB Session==&lt;br /&gt;
&lt;br /&gt;
This example GDB session uses the EMAC OE SDK example project named &amp;lt;code&amp;gt;pthread_demo&amp;lt;/code&amp;gt;. It consists of the single source file &amp;lt;code&amp;gt;pthread_demo.c&amp;lt;/code&amp;gt;. The program is called with a single integer argument indicating how many &amp;lt;code&amp;gt;reader&amp;lt;/code&amp;gt; threads the user wishes to create. The following describes the tasks of the &amp;lt;code&amp;gt;main&amp;lt;/code&amp;gt; thread: &lt;br /&gt;
&lt;br /&gt;
# The &amp;lt;code&amp;gt;main&amp;lt;/code&amp;gt; thread performs user input validation. It prints a usage message according to the argument passed to it on the command line. The function expects the user to pass a number indicating how many threads should be spawned.&lt;br /&gt;
# The &amp;lt;code&amp;gt;main&amp;lt;/code&amp;gt; thread initiates a new thread which uses the &amp;lt;code&amp;gt;generator()&amp;lt;/code&amp;gt; function to perform the following tasks:&lt;br /&gt;
## Checks to see if the number of &amp;lt;code&amp;gt;reader&amp;lt;/code&amp;gt; threads matches the number of times a &amp;lt;code&amp;gt;reader&amp;lt;/code&amp;gt; thread has acquired the mutex lock and performed its task. If the two values do match, then the &amp;lt;code&amp;gt;generator&amp;lt;/code&amp;gt; thread unlocks the mutex, breaks out of the while loop and moves on to line 167 to gracefully exit. If the two values do not match, then the &amp;lt;code&amp;gt;generator&amp;lt;/code&amp;gt; thread continues through the rest of the while loop described in steps 2.2 and 2.3.&lt;br /&gt;
## Generates random data to be stored in the data struct shared by all the threads. To do this, it protects the data struct with the use of a mutex variable.&lt;br /&gt;
## Sleeps after giving up its lock on the mutex so that another thread might have a chance to acquire the lock.&lt;br /&gt;
# After creating the &amp;lt;code&amp;gt;generator&amp;lt;/code&amp;gt; thread the &amp;lt;code&amp;gt;main&amp;lt;/code&amp;gt; thread iteratively creates as many &amp;lt;code&amp;gt;reader&amp;lt;/code&amp;gt; threads as indicated by the single integer argument. Each &amp;lt;code&amp;gt;reader&amp;lt;/code&amp;gt; thread performs the following tasks:&lt;br /&gt;
## Waits for a chance to acquire the mutex &amp;lt;code&amp;gt;lock&amp;lt;/code&amp;gt;. Once the mutex &amp;lt;code&amp;gt;lock&amp;lt;/code&amp;gt; is acquired, it prints the value of the random number &amp;lt;code&amp;gt;generated&amp;lt;/code&amp;gt; by the generator thread in its last run.&lt;br /&gt;
## Increments an integer in the &amp;lt;code&amp;gt;data&amp;lt;/code&amp;gt; struct to indicate that it has completed its task.&lt;br /&gt;
## Gives up its lock on the mutex and exits.&lt;br /&gt;
# After creating the prescribed number of &amp;lt;code&amp;gt;reader&amp;lt;/code&amp;gt; threads, the &amp;lt;code&amp;gt;main&amp;lt;/code&amp;gt; thread then waits for each thread created to exit gracefully. &lt;br /&gt;
# The &amp;lt;code&amp;gt;main&amp;lt;/code&amp;gt; thread exists.&lt;br /&gt;
&lt;br /&gt;
The SDK version of &amp;lt;code&amp;gt;pthread_demo.c&amp;lt;/code&amp;gt; works according to the description above with a &amp;lt;code&amp;gt;MAX_THREAD&amp;lt;/code&amp;gt; value of 100. However, for the purpose of this example debug session it is instructive to use a faulty version of the same program. Replace lines 75-80 in &amp;lt;code&amp;gt;pthread_demo.c&amp;lt;/code&amp;gt; with the code snippet shown in Listing 1 below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
if ((data.num_threads &amp;lt; 1) || (data.num_threads &amp;lt; MAX_THREAD)) {&lt;br /&gt;
        fprintf(stderr,&lt;br /&gt;
                &amp;quot;The number of thread should between 1 and %d\n&amp;quot;,&lt;br /&gt;
                MAX_THREAD);&lt;br /&gt;
        exit(EXIT_FAILURE);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Useful GDB Commands===&lt;br /&gt;
&lt;br /&gt;
The following is a brief description of some essential GDB commands. Each description is followed by a link to the official GDB documentation page that has more specific information about what the command does and how to use it. Please note that the official GDB documentation is targeted for the latest GDB release which at the time of writing this documentation is 7.4. The version of GDB that EMAC distributes with the OE products, however, is version 6.8. Because of this, the links to documentation below may provide slightly different information. The biggest difference between the two version of GDB, however, is in the support for debugging programs with multiple threads. This is reflected in the documentation as well. Because of this, EMAC has set up ftp access to GDB 6.8 documentation on its web server. It is highly recommended that the GDB 6.8 documentation be referenced in cases where the program does not seem to support commands or options specified in the current official documentation. &lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Command !! Description &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;start/run&amp;lt;/code&amp;gt;&lt;br /&gt;
|| These commands are used to start the debugged program with the only difference being that start automatically pauses execution at the beginning of the program's main function whereas run must be told explicitly where to pause using the breakpoint command listed below.&lt;br /&gt;
See also [Debugging with GDB, Section 4.2: Starting your Program]&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;kill&amp;lt;/code&amp;gt;&lt;br /&gt;
|| Used to kill the currently-running instance of target_program.&lt;br /&gt;
See also [Debugging with GDB, Section 4.9: Killing the Child Process]&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;print&amp;lt;/code&amp;gt;&lt;br /&gt;
|| Used to print the value of an expression.&lt;br /&gt;
See also [Debugging with GDB, Section 10: Examining Data]&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;list&amp;lt;/code&amp;gt;&lt;br /&gt;
|| List contents of function or specified line.&lt;br /&gt;
See also [Debugging with GDB, Section 9: Examining Source Files]&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;layout&amp;lt;/code&amp;gt;&lt;br /&gt;
|| This is a TUI (Text User Interface) command that enables the programmer to view multiple debug views at once including source code, assembly, and registers.&lt;br /&gt;
See also [Debugging with GDB, Section 25.4: TUI Commands]&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;disassemble&amp;lt;/code&amp;gt;&lt;br /&gt;
|| This command allows the programmer to see assembler instructions.&lt;br /&gt;
See also [Debugging with GDB, Section 9.6: Source and Machine Code]&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;break&amp;lt;/code&amp;gt;&lt;br /&gt;
|| This command specifies a function name, line number, or instruction at which GDB is to pause execution.&lt;br /&gt;
See also [Debugging with GDB, Section 5.1: Breakpoints]&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;next/nexti, step/stepi&amp;lt;/code&amp;gt;&lt;br /&gt;
|| Allow the programmer to step through a program without specifying breakpoints. The &amp;lt;code&amp;gt;next/nexti&amp;lt;/code&amp;gt; commands step over function calls, stopping on the next line of the same stack frame; &amp;lt;code&amp;gt;step/stepi&amp;lt;/code&amp;gt;, step into function calls, stopping on the first line in the next stack frame. The difference between &amp;lt;code&amp;gt;step/next&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;stepi/nexti&amp;lt;/code&amp;gt; is that the &amp;lt;code&amp;gt;i&amp;lt;/code&amp;gt; indicates instruction-by-instruction stepping at the assembly language level.&lt;br /&gt;
See also [Debugging with GDB, Section 5.2: Continuing and Stepping]&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;continue&amp;lt;/code&amp;gt;&lt;br /&gt;
|| Used to continue program execution from the address where it was last stopped.&lt;br /&gt;
See the Debugging with GDB link for &amp;lt;code&amp;gt;next/step&amp;lt;/code&amp;gt; for more information about the &amp;lt;code&amp;gt;continue&amp;lt;/code&amp;gt; command.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;bt&amp;lt;/code&amp;gt;&lt;br /&gt;
|| Short for &amp;quot;backtrace,&amp;quot; which displays to the programmer a brief summary of execution up to the current point in the program. This is useful because it shows a nested list of stack frames starting with the current one.&lt;br /&gt;
See also [Debugging with GDB, Section 8.2: Backtrace]&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;quit&amp;lt;/code&amp;gt;&lt;br /&gt;
||  This will quit the debugging session, and return you to the shell. The Control-D key combination is another way to accomplish this.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Session Walk-through===&lt;br /&gt;
&lt;br /&gt;
This debug session walk-through assumes that the program has been compiled using the modified source code above and that both the target machine and the development machine have been set up according to the above Setup section. The walk-through is divided into multiple “lessons” with the intent of first introducing the use of the commands described above and then actually running GDB to debug a known programming problem. Each lesson may be run independently of the others, but it is recommended that each be run in order starting from Lesson 1 for the first time through.&lt;br /&gt;
&lt;br /&gt;
====Lesson 1: Navigation and Code Display====&lt;br /&gt;
&lt;br /&gt;
This lesson assumes that &amp;lt;code&amp;gt;gdbserver&amp;lt;/code&amp;gt; has been run as in the [Target Machine Setup] section above with an ARG value of 3. Other values are fine so long as they fall within the range of 1 to 100. The number '3' was arbitrarily chosen to avoid having to use a symbolic variable in the explanations below.&lt;br /&gt;
&lt;br /&gt;
# Type &amp;lt;code&amp;gt;b main&amp;lt;/code&amp;gt; to set a breakpoint at the main function in the source code.&lt;br /&gt;
# Type &amp;lt;code&amp;gt;continue&amp;lt;/code&amp;gt;. This will cause the program to continue from the breakpoint set by GDB at startup. The program was passed an argument of 3, indicating that three threads should be created. &lt;br /&gt;
# Type &amp;lt;code&amp;gt;b 73&amp;lt;/code&amp;gt; to set a breakpoint at line 73 in the source code, which should be the line containing &amp;lt;code&amp;gt;data.num_threads = atoi(argv[1]);&amp;lt;/code&amp;gt;&lt;br /&gt;
# Type &amp;lt;code&amp;gt;continue&amp;lt;/code&amp;gt;. The program will continue execution up until line 73 in the source code. At this point, type layout split to view a split screen containing both the source code and the assembly-level machine instructions. Both screens show the program's current location in execution. The assembly-level display shows what the target's processor is actually executing at that point in the source code as shown in the source-level display. To view either of these without the other type layout &amp;lt;code&amp;gt;asm&amp;lt;/code&amp;gt; for just assembly-level and &amp;lt;code&amp;gt;layout src&amp;lt;/code&amp;gt; for just source-level.&lt;br /&gt;
# Type &amp;lt;code&amp;gt;nexti&amp;lt;/code&amp;gt;. This will cause the program to execute the next instruction in the current stack frame which is a mov instruction beginning to prepare the current stack for a call to the library function &amp;lt;code&amp;gt;atoi()&amp;lt;/code&amp;gt;. The details of this process are beyond the scope of this tutorial; essentially, the program needs to store information about the current execution location in the stack for when the &amp;lt;code&amp;gt;atoi()&amp;lt;/code&amp;gt; function finishes. Type &amp;lt;code&amp;gt;ni&amp;lt;/code&amp;gt; (alias for nexti) three more times. You should end up on a &amp;lt;code&amp;gt;bl&amp;lt;/code&amp;gt; instruction in the assembly view as shown in Listing 2 below. The source layout should still show the program on line 73.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;asm&amp;quot;&amp;gt;&lt;br /&gt;
B+ |0x887c &amp;lt;main+112&amp;gt;       ldr    r3, [r11, #-84]                   │&lt;br /&gt;
   |0x8880 &amp;lt;main+116&amp;gt;       add    r3, r3, #4      ; 0x4             │&lt;br /&gt;
   |0x8884 &amp;lt;main+120&amp;gt;       ldr    r3, [r3]                          │&lt;br /&gt;
   |0x8888 &amp;lt;main+124&amp;gt;       mov    r0, r3                            │&lt;br /&gt;
  &amp;gt;|0x888c &amp;lt;main+128&amp;gt;       bl     0x86e0 &amp;lt;atoi&amp;gt;                     │&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
'''Listing 2. GDB Assembly Layout''' - ''Note that the assembly may look different depending on the target architecture.''&lt;br /&gt;
# Type &amp;lt;code&amp;gt;stepi&amp;lt;/code&amp;gt;. This will cause the program to move into the next stack frame and GDB to show the assembly-level instructions of the &amp;lt;code&amp;gt;atoi()&amp;lt;/code&amp;gt; call. Since the library containing &amp;lt;code&amp;gt;atoi()&amp;lt;/code&amp;gt; was likely not compiled with debug symbols, the source-level layout will show the message &amp;lt;code&amp;gt;[ No Source Available ]&amp;lt;/code&amp;gt;.&lt;br /&gt;
# Type &amp;lt;code&amp;gt;bt&amp;lt;/code&amp;gt;. This will cause the program to display a human-readable version of the current stack. Each stack “frame” is represented by the name of the function call it represents with that function's location in memory. Type &amp;lt;code&amp;gt;bt full&amp;lt;/code&amp;gt; to get a list of the variables local to each stack frame.&lt;br /&gt;
# Type &amp;lt;code&amp;gt;finish&amp;lt;/code&amp;gt;. This will cause the current stack frame to return and execution to pause on the next instruction of the previous stack frame.&lt;br /&gt;
# Type &amp;lt;code&amp;gt;kill&amp;lt;/code&amp;gt;. This will cause the current process to be killed by &amp;lt;code&amp;gt;gdbserver&amp;lt;/code&amp;gt; at the target machine. &amp;lt;code&amp;gt;gdbserver&amp;lt;/code&amp;gt; will also terminate at this point. In order to start a new remote debug session, start gdbserver as described in the Target Machine Setup section and re-run step 3 of the [Development Machine Setup] section.&lt;br /&gt;
&lt;br /&gt;
{{mbox | type = warning | text = '''Note:''' &amp;lt;code&amp;gt;b&amp;lt;/code&amp;gt; is an alias for the &amp;lt;code&amp;gt;break&amp;lt;/code&amp;gt; command. &lt;br /&gt;
&amp;lt;code&amp;gt;ni&amp;lt;/code&amp;gt; is an alias for &amp;lt;code&amp;gt;nexti&amp;lt;/code&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
====Lesson 2: Finding the Bug====&lt;br /&gt;
&lt;br /&gt;
Though this sample is contrived, it is still useful to demonstrate how to find a design mistake in an otherwise well-written (no errors or warnings) program. These types of mistakes typically have to do with the array boundary miscalculations, logic and comparison operator mistakes, or other simple mistakes. For the sake of demonstration, assume that the actual mistake is unknown. This lesson assumes that gdbserver has just been started as in the [Target Machine] Setup above with an &amp;lt;code&amp;gt;ARG&amp;lt;/code&amp;gt; value of 5.&lt;br /&gt;
&lt;br /&gt;
# Before starting the program in the debugger again, run it by itself on the target machine to see what the actual program output is: &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@emac-oe:~# /tmp/pthread_demo 5&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
The number of threads should be between 1 and 100&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The program was given an input of '5' yet the output message seems to indicate that this is out of range which is obviously not true.&lt;br /&gt;
# Start the debugger again and connect to the target machine as described in the Setup section.&lt;br /&gt;
# Type &amp;lt;code&amp;gt;b main&amp;lt;/code&amp;gt; to set a breakpoint at the main function in the source code.&lt;br /&gt;
# Type &amp;lt;code&amp;gt;continue&amp;lt;/code&amp;gt;. This will cause the program to continue from the breakpoint set by GDB at startup. &lt;br /&gt;
# Type &amp;lt;code&amp;gt;n&amp;lt;/code&amp;gt;. This will cause the program to step over the next line of source code. The reason for using &amp;lt;code&amp;gt;n&amp;lt;/code&amp;gt; rather than &amp;lt;code&amp;gt;s&amp;lt;/code&amp;gt; or one of the instruction stepping commands is because the erroneous output indicates that the coding mistake is in the programmer's source code rather than the c library functions &amp;lt;code&amp;gt;atoi()&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;fprintf()&amp;lt;/code&amp;gt;. Stepping over the function will save all the time required to step through every detail of what the library functions are doing. Later passes through the code can be used to step into functions called from within that stack frame if the first pass proves unsuccessful.&lt;br /&gt;
# Continue to type &amp;lt;code&amp;gt;n&amp;lt;/code&amp;gt; until one of the program's &amp;lt;code&amp;gt;exit()&amp;lt;/code&amp;gt; calls is reached, but do not actually step into that &amp;lt;code&amp;gt;exit()&amp;lt;/code&amp;gt; call. Judging by the program's output above, this should bring you to the conditional block that checks the value of the local variable n used to store the output of &amp;lt;code&amp;gt;atoi()&amp;lt;/code&amp;gt; as shown in Listing 3. Note that once execution reaches line 79 of the source code, GDB will display the output of the &amp;lt;code&amp;gt;fprintf()&amp;lt;/code&amp;gt; function from line 76. This may cause display problems within the text-based UI library that GDB uses which will require the command refresh to fix.&lt;br /&gt;
#;&amp;lt;syntaxhighlight lang=&amp;quot;gdb&amp;quot;&amp;gt;&lt;br /&gt;
#;B+ |75              if ((data.num_threads &amp;lt; 1) || (data.num_threads &amp;lt; MAX_THREAD)) {       |&lt;br /&gt;
#;   |76                      fprintf(stderr,                                                |&lt;br /&gt;
#;   |77                              &amp;quot;The number of thread should between 1 and %d\n&amp;quot;,      |&lt;br /&gt;
#;   |78                              MAX_THREAD);                                           |&lt;br /&gt;
#;  &amp;gt;|79                      exit(EXIT_FAILURE);                                            |&lt;br /&gt;
#;   |80              }                                                                      |&lt;br /&gt;
#;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
# Type &amp;lt;code&amp;gt;p/d data→num_threads&amp;lt;/code&amp;gt;. &amp;lt;code&amp;gt;p&amp;lt;/code&amp;gt; is an alias for &amp;lt;code&amp;gt;print&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;/d&amp;lt;/code&amp;gt; tells GDB to treat the expression requested as an integer in signed decimal, and &amp;lt;code&amp;gt;data→num&amp;lt;/code&amp;gt;_threads is the element &amp;lt;code&amp;gt;num_threads&amp;lt;/code&amp;gt; within &amp;lt;code&amp;gt;struct thread_data&amp;lt;/code&amp;gt;. This should provide the following output:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;gdb&amp;quot;&amp;gt;&lt;br /&gt;
(gdb) p/d data-&amp;gt;num_threads&lt;br /&gt;
$6 = 5&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Note that the integer part of &amp;lt;code&amp;gt;$6&amp;lt;/code&amp;gt; will increment with each call to the gdb command &amp;lt;code&amp;gt;print&amp;lt;/code&amp;gt;. The above output confirms that the argument '5' was successfully passed to the program and read into a variable to be tested, indicating that one of the logical tests for the current conditional block contains a mistake. This merits a closer look at line 75:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;gdb&amp;quot;&amp;gt;&lt;br /&gt;
B+ |75              if ((data.num_threads &amp;lt; 1) || (data.num_threads &amp;lt; MAX_THREAD)) {       |&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Line 75 consists of a conditional test which is the logical OR of two arithmetic tests involving the values of &amp;lt;code&amp;gt;data.num_threads&amp;lt;/code&amp;gt;, '1', and &amp;lt;code&amp;gt;MAX_THREAD&amp;lt;/code&amp;gt;. The first test is true the input integer is less than &amp;lt;code&amp;gt;1–(data.num_threads &amp;amp;lt; 1)&amp;lt;/code&amp;gt;. The second tests whether the input integer is less than the symbolic constant, &amp;lt;code&amp;gt;MAX_THREAD–(data.num_threads &amp;amp;lt; MAX_THREAD)&amp;lt;/code&amp;gt;. Judging by the name of this constant and the result of the test (we know it resolves to true because the value of &amp;lt;code&amp;gt;data.num_threads&amp;lt;/code&amp;gt; in this case is not less than one), we can see that the comparison operator used is the culprit. The correct interpretation is that it should be '&amp;amp;gt;' rather than '&amp;amp;lt;'.&lt;br /&gt;
# Type &amp;lt;code&amp;gt;kill&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
This was a simple problem to solve but the method used above could apply in any situation where source code compiles and runs without errors yet provides varied or unexpected output.&lt;/div&gt;</summary>
		<author><name>Mcoleman</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.emacinc.com/index.php?title=Remote_Debugging_EMAC_OE_SDK_Projects_with_gdbserver&amp;diff=425</id>
		<title>Remote Debugging EMAC OE SDK Projects with gdbserver</title>
		<link rel="alternate" type="text/html" href="https://wiki.emacinc.com/index.php?title=Remote_Debugging_EMAC_OE_SDK_Projects_with_gdbserver&amp;diff=425"/>
		<updated>2013-05-10T00:27:12Z</updated>

		<summary type="html">&lt;p&gt;Mcoleman: Created page with &amp;quot;{| class=&amp;quot;wikitable conventions&amp;quot; !colspan=&amp;quot;2&amp;quot;|Table 1: Conventions |- | &amp;lt;code&amp;gt;target_program&amp;lt;/code&amp;gt; || The name of the application being debugged. This is the result of the Ma...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{| class=&amp;quot;wikitable conventions&amp;quot;&lt;br /&gt;
!colspan=&amp;quot;2&amp;quot;|Table 1: Conventions&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;target_program&amp;lt;/code&amp;gt; || The name of the application being debugged. This is the result of the Makefile build process. &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;target_machine&amp;lt;/code&amp;gt; || Connection information for the target machine. This can either be a serial port (ie. &amp;lt;code&amp;gt;/dev/ttyS2&amp;lt;/code&amp;gt;) or a TCP connection in the form of HOST:PORT.  &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;/path/to/sdk/&amp;lt;/code&amp;gt; ||  Represents the development system path to the EMAC OE SDK. &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
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 binary resulting from the compile 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 while running the debugger.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
This guide is intended to build a basic understanding of how to use gdbserver with EMAC products. It is not intended as a general guide to debugging computer programs. For help with that, see the GDB man pages on the development system or read [this manual] on debugging with GDB.&lt;br /&gt;
&lt;br /&gt;
==Setup==&lt;br /&gt;
&lt;br /&gt;
Using &amp;lt;code&amp;gt;gdbserver&amp;lt;/code&amp;gt; involves setting up both the target machine and the development machine. This requires that the binary application be present on both development and target machines. The development machine copy of the application must be compiled with debug flags whereas this is not strictly necessary for the target machine. See the [Optional &amp;lt;code&amp;gt;global.properties&amp;lt;/code&amp;gt; Modifications Section] on the New EMAC OE SDK Project Guide for more information. See the [[[EMAC OE Getting Started Guide]]] for more information on how to connect to the target EMAC product using a serial port or Ethernet connection.&lt;br /&gt;
&lt;br /&gt;
===Target Machine===&lt;br /&gt;
&lt;br /&gt;
Because EMAC OE builds are distributed with &amp;lt;code&amp;gt;gdbserver&amp;lt;/code&amp;gt;, installation is not a concern. The only setup necessary is to run &amp;lt;code&amp;gt;gdbserver&amp;lt;/code&amp;gt; with &amp;lt;code&amp;gt;target_program&amp;lt;/code&amp;gt;: &lt;br /&gt;
&lt;br /&gt;
# If the target application is already running, use the attachpid option to connect &amp;lt;code&amp;gt;gdbserver&amp;lt;/code&amp;gt; to the application as shown below. The &amp;lt;code&amp;gt;PID&amp;lt;/code&amp;gt; argument can be determined using &amp;lt;code&amp;gt;pidof&amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ pidof target_program&lt;br /&gt;
developer@ldc:~$ gdbserver target_machine --attach PID&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
# If the target application is not already running, the name of the binary may be included as an argument to the &amp;lt;code&amp;gt;gdbserver&amp;lt;/code&amp;gt; program call.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;snytaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ gdbserver target_machine target_program [ARGS]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This establishes a &amp;lt;code&amp;gt;gdbserver&amp;lt;/code&amp;gt; port on the target machine that listens for incoming connections from GDB on the development machine. In debug terminology, &amp;lt;code&amp;gt;gdbserver&amp;lt;/code&amp;gt; is “attached” to the process ID of the program being debugged. In reality, though, GDB is attached to the process ID of a proxy which passes the messages to and from the remote device under test. &lt;br /&gt;
&lt;br /&gt;
The next step is to run GDB on the development machine using the &amp;lt;code&amp;gt;target_program&amp;lt;/code&amp;gt;/&lt;br /&gt;
&lt;br /&gt;
===Development Machine===&lt;br /&gt;
&lt;br /&gt;
# First, &amp;lt;code&amp;gt;cd&amp;lt;/code&amp;gt; to the directory where the targe executable is stored.&lt;br /&gt;
# Run the EMAC OE SDK GDB:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ /path/to/sdk/EMAC-OE-arm-linux-gnueabi-SDK_4.0/gcc-4.2.4-arm-linux-gnueabi/bin/arm-linux-gnueabi-gdb target_program&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
# Run the following commands in GDB to prepare for the debug session:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;gdb&amp;quot;&amp;gt;&lt;br /&gt;
(gdb) target remote target_machine&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{mbox | type = warning | text = Note that the location of the GDB in the toolchain may differ from what is shown above depending on which version of the SDK is used.}}&lt;br /&gt;
&lt;br /&gt;
{{mbox | type = notice | text = If the gdb executable, or any other executable you run, is located in a directory which is in the PATH environment variable, you can simply run that command without the long path prefix. Sourcing the environment variables generated by the EMAC script for this will provide you with such a path. The script which creates the file to source also creates a symbolic link for arm-linux-gnueabi-gdb called, simply, gdb. With your shell environment setup this way, you could simply execute: &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ gdb target_program&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
in place of the long command given in step 2, above.&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
==Sample GDB Session==&lt;br /&gt;
&lt;br /&gt;
This example GDB session uses the EMAC OE SDK example project named &amp;lt;code&amp;gt;pthread_demo&amp;lt;/code&amp;gt;. It consists of the single source file &amp;lt;code&amp;gt;pthread_demo.c&amp;lt;/code&amp;gt;. The program is called with a single integer argument indicating how many &amp;lt;code&amp;gt;reader&amp;lt;/code&amp;gt; threads the user wishes to create. The following describes the tasks of the &amp;lt;code&amp;gt;main&amp;lt;/code&amp;gt; thread: &lt;br /&gt;
&lt;br /&gt;
# The &amp;lt;code&amp;gt;main&amp;lt;/code&amp;gt; thread performs user input validation. It prints a usage message according to the argument passed to it on the command line. The function expects the user to pass a number indicating how many threads should be spawned.&lt;br /&gt;
# The &amp;lt;code&amp;gt;main&amp;lt;/code&amp;gt; thread initiates a new thread which uses the &amp;lt;code&amp;gt;generator()&amp;lt;/code&amp;gt; function to perform the following tasks:&lt;br /&gt;
## Checks to see if the number of &amp;lt;code&amp;gt;reader&amp;lt;/code&amp;gt; threads matches the number of times a &amp;lt;code&amp;gt;reader&amp;lt;/code&amp;gt; thread has acquired the mutex lock and performed its task. If the two values do match, then the &amp;lt;code&amp;gt;generator&amp;lt;/code&amp;gt; thread unlocks the mutex, breaks out of the while loop and moves on to line 167 to gracefully exit. If the two values do not match, then the &amp;lt;code&amp;gt;generator&amp;lt;/code&amp;gt; thread continues through the rest of the while loop described in steps 2.2 and 2.3.&lt;br /&gt;
## Generates random data to be stored in the data struct shared by all the threads. To do this, it protects the data struct with the use of a mutex variable.&lt;br /&gt;
## Sleeps after giving up its lock on the mutex so that another thread might have a chance to acquire the lock.&lt;br /&gt;
# After creating the &amp;lt;code&amp;gt;generator&amp;lt;/code&amp;gt; thread the &amp;lt;code&amp;gt;main&amp;lt;/code&amp;gt; thread iteratively creates as many &amp;lt;code&amp;gt;reader&amp;lt;/code&amp;gt; threads as indicated by the single integer argument. Each &amp;lt;code&amp;gt;reader&amp;lt;/code&amp;gt; thread performs the following tasks:&lt;br /&gt;
## Waits for a chance to acquire the mutex &amp;lt;code&amp;gt;lock&amp;lt;/code&amp;gt;. Once the mutex &amp;lt;code&amp;gt;lock&amp;lt;/code&amp;gt; is acquired, it prints the value of the random number &amp;lt;code&amp;gt;generated&amp;lt;/code&amp;gt; by the generator thread in its last run.&lt;br /&gt;
## Increments an integer in the &amp;lt;code&amp;gt;data&amp;lt;/code&amp;gt; struct to indicate that it has completed its task.&lt;br /&gt;
## Gives up its lock on the mutex and exits.&lt;br /&gt;
# After creating the prescribed number of &amp;lt;code&amp;gt;reader&amp;lt;/code&amp;gt; threads, the &amp;lt;code&amp;gt;main&amp;lt;/code&amp;gt; thread then waits for each thread created to exit gracefully. &lt;br /&gt;
# The &amp;lt;code&amp;gt;main&amp;lt;/code&amp;gt; thread exists.&lt;br /&gt;
&lt;br /&gt;
The SDK version of &amp;lt;code&amp;gt;pthread_demo.c&amp;lt;/code&amp;gt; works according to the description above with a &amp;lt;code&amp;gt;MAX_THREAD&amp;lt;/code&amp;gt; value of 100. However, for the purpose of this example debug session it is instructive to use a faulty version of the same program. Replace lines 75-80 in &amp;lt;code&amp;gt;pthread_demo.c&amp;lt;/code&amp;gt; with the code snippet shown in Listing 1 below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
if ((data.num_threads &amp;lt; 1) || (data.num_threads &amp;lt; MAX_THREAD)) {&lt;br /&gt;
        fprintf(stderr,&lt;br /&gt;
                &amp;quot;The number of thread should between 1 and %d\n&amp;quot;,&lt;br /&gt;
                MAX_THREAD);&lt;br /&gt;
        exit(EXIT_FAILURE);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Useful GDB Commands===&lt;br /&gt;
&lt;br /&gt;
The following is a brief description of some essential GDB commands. Each description is followed by a link to the official GDB documentation page that has more specific information about what the command does and how to use it. Please note that the official GDB documentation is targeted for the latest GDB release which at the time of writing this documentation is 7.4. The version of GDB that EMAC distributes with the OE products, however, is version 6.8. Because of this, the links to documentation below may provide slightly different information. The biggest difference between the two version of GDB, however, is in the support for debugging programs with multiple threads. This is reflected in the documentation as well. Because of this, EMAC has set up ftp access to GDB 6.8 documentation on its web server. It is highly recommended that the GDB 6.8 documentation be referenced in cases where the program does not seem to support commands or options specified in the current official documentation. &lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Command !! Description &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;start/run&amp;lt;/code&amp;gt;&lt;br /&gt;
|| These commands are used to start the debugged program with the only difference being that start automatically pauses execution at the beginning of the program's main function whereas run must be told explicitly where to pause using the breakpoint command listed below.&lt;br /&gt;
See also [Debugging with GDB, Section 4.2: Starting your Program]&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;kill&amp;lt;/code&amp;gt;&lt;br /&gt;
|| Used to kill the currently-running instance of target_program.&lt;br /&gt;
See also [Debugging with GDB, Section 4.9: Killing the Child Process]&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;print&amp;lt;/code&amp;gt;&lt;br /&gt;
|| Used to print the value of an expression.&lt;br /&gt;
See also [Debugging with GDB, Section 10: Examining Data]&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;list&amp;lt;/code&amp;gt;&lt;br /&gt;
|| List contents of function or specified line.&lt;br /&gt;
See also [Debugging with GDB, Section 9: Examining Source Files]&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;layout&amp;lt;/code&amp;gt;&lt;br /&gt;
|| This is a TUI (Text User Interface) command that enables the programmer to view multiple debug views at once including source code, assembly, and registers.&lt;br /&gt;
See also [Debugging with GDB, Section 25.4: TUI Commands]&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;disassemble&amp;lt;/code&amp;gt;&lt;br /&gt;
|| This command allows the programmer to see assembler instructions.&lt;br /&gt;
See also [Debugging with GDB, Section 9.6: Source and Machine Code]&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;break&amp;lt;/code&amp;gt;&lt;br /&gt;
|| This command specifies a function name, line number, or instruction at which GDB is to pause execution.&lt;br /&gt;
See also [Debugging with GDB, Section 5.1: Breakpoints]&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;next/nexti, step/stepi&amp;lt;/code&amp;gt;&lt;br /&gt;
|| Allow the programmer to step through a program without specifying breakpoints. The &amp;lt;code&amp;gt;next/nexti&amp;lt;/code&amp;gt; commands step over function calls, stopping on the next line of the same stack frame; &amp;lt;code&amp;gt;step/stepi&amp;lt;/code&amp;gt;, step into function calls, stopping on the first line in the next stack frame. The difference between &amp;lt;code&amp;gt;step/next&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;stepi/nexti&amp;lt;/code&amp;gt; is that the &amp;lt;code&amp;gt;i&amp;lt;/code&amp;gt; indicates instruction-by-instruction stepping at the assembly language level.&lt;br /&gt;
See also [Debugging with GDB, Section 5.2: Continuing and Stepping]&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;continue&amp;lt;/code&amp;gt;&lt;br /&gt;
|| Used to continue program execution from the address where it was last stopped.&lt;br /&gt;
See the Debugging with GDB link for &amp;lt;code&amp;gt;next/step&amp;lt;/code&amp;gt; for more information about the &amp;lt;code&amp;gt;continue&amp;lt;/code&amp;gt; command.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;bt&amp;lt;/code&amp;gt;&lt;br /&gt;
|| Short for &amp;quot;backtrace,&amp;quot; which displays to the programmer a brief summary of execution up to the current point in the program. This is useful because it shows a nested list of stack frames starting with the current one.&lt;br /&gt;
See also [Debugging with GDB, Section 8.2: Backtrace]&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;quit&amp;lt;/code&amp;gt;&lt;br /&gt;
||  This will quit the debugging session, and return you to the shell. The Control-D key combination is another way to accomplish this.&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Mcoleman</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.emacinc.com/index.php?title=Creating_a_New_EMAC_OE_SDK_Project&amp;diff=424</id>
		<title>Creating a New EMAC OE SDK Project</title>
		<link rel="alternate" type="text/html" href="https://wiki.emacinc.com/index.php?title=Creating_a_New_EMAC_OE_SDK_Project&amp;diff=424"/>
		<updated>2013-05-09T23:53:28Z</updated>

		<summary type="html">&lt;p&gt;Mcoleman: Created page with &amp;quot;{| class=&amp;quot;wikitable conventions&amp;quot; !colspan=&amp;quot;2&amp;quot;|Table 1: Conventions |- | &amp;lt;code&amp;gt;/download/directory/&amp;lt;/code&amp;gt; || Placeholder indicating the directory to which the SDK archive will...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{| class=&amp;quot;wikitable conventions&amp;quot;&lt;br /&gt;
!colspan=&amp;quot;2&amp;quot;|Table 1: Conventions&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;/download/directory/&amp;lt;/code&amp;gt; || Placeholder indicating the directory to which the SDK archive will be downloaded.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;/path/to/sdk/&amp;lt;/code&amp;gt; || Placeholder indicating the directory to which the SDK will be extracted.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;EMAC-OE-arm-linux-gnueabi-SDK_XX.YY.rZZ.tar.bz2&amp;lt;/code&amp;gt;&amp;lt;br /&amp;gt;&amp;lt;code&amp;gt;EMAC-OE-arm-linux-gnueabi-SDK_XX.YY&amp;lt;/code&amp;gt;&lt;br /&gt;
|| '''XX''' is the major version&amp;lt;br /&amp;gt;'''YY''' is the minor version&amp;lt;br /&amp;gt;'''ZZ''' is the current revision&amp;lt;br /&amp;gt;The major and minor version numbers will match the version of OE for which the SDK is created.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The EMAC OE SDK is a complete development kit for creating C/C++ applications for EMAC products. The SDK can be used to compile code anywhere in the development system. This procedure explains the process of creating and building a new project within the SDK.&lt;br /&gt;
&lt;br /&gt;
==New Project Procedure==&lt;br /&gt;
&lt;br /&gt;
This guide assumes that the EMAC OE SDK has been [[installed]] and [[configured]]. It also assumes a basic familiarity with the C programming language and that a basic text editor is available. The example code calculates the perimeter of a right triangle given the length of its longest edge and the angle between that edge and one of the other edges.&lt;br /&gt;
&lt;br /&gt;
===Set Up the Project===&lt;br /&gt;
&lt;br /&gt;
The first step in creating an EMAC OE project is creating a project directory in &amp;lt;code&amp;gt;/path/to/sdk/EMAC-OE-arm-linux-gnueabi-SDK_XX.YY/projects&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ mkdir /path/to/sdk/EMAC-OE-arm-linux-gnueabi-SDK_XX.YY/projects/example&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Creating the project in this directory is necessary in order for the &amp;lt;code&amp;gt;global.properties&amp;lt;/code&amp;gt; include and the path variables in global.properties to be correct. If it is created in any other directory, then the make targets will fail without modifications on the Makefile that go beyond the scope of this guide.&lt;br /&gt;
&lt;br /&gt;
===Write the C Code===&lt;br /&gt;
&lt;br /&gt;
This guide uses the C code from Listing 1 as an example. It is simple enough that the basic familiarity with C expected of those viewing this guide precludes the need for explanation. As a general step in application development using the EMAC OE SDK, the C files in this step should be saved in the project's top-level directory. In this case, &amp;lt;code&amp;gt;example.c&amp;lt;/code&amp;gt; should be saved as &amp;lt;code&amp;gt;/path/to/sdk/EMAC-OE-arm-linux-gnueabi-SDK_XX.YY/projects/example/example.c&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;lt;string.h&amp;gt;&lt;br /&gt;
#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
#include &amp;lt;stdlib.h&amp;gt;&lt;br /&gt;
#include &amp;lt;math.h&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
#define HYP 10.0&lt;br /&gt;
#define DEG 30.0&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
int main(void)&lt;br /&gt;
{&lt;br /&gt;
	float opp, adj;&lt;br /&gt;
 &lt;br /&gt;
	opp = HYP * sin(DEG);&lt;br /&gt;
	adj = HYP * cos(DEG);&lt;br /&gt;
 &lt;br /&gt;
	printf(&amp;quot;Hypotenuse: \t%3.2f\n&amp;quot;, HYP);&lt;br /&gt;
	printf(&amp;quot;Angle: \t\t%3.2f\n&amp;quot;, DEG);&lt;br /&gt;
	printf(&amp;quot;Opposite Side: \t%3.2f\n&amp;quot;, opp);&lt;br /&gt;
	printf(&amp;quot;Adjacent Side: \t%3.2f\n&amp;quot;, adj);&lt;br /&gt;
	printf(&amp;quot;%3.2f + %3.2f + %3.2f = %3.2f \n&amp;quot;, HYP, opp, adj, (HYP + opp + adj));&lt;br /&gt;
 &lt;br /&gt;
	exit(EXIT_SUCCESS);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Modify the Makefile===&lt;br /&gt;
&lt;br /&gt;
====Create the New Makefile====&lt;br /&gt;
&lt;br /&gt;
Now that the C file has been written, it is time to copy a suitable Makefile from one of the example projects. The following command will accomplish this: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ cd /path/to/sdk/EMAC-OE-arm-linux-gnueabi-SDK_XX.YY/projects/example/&lt;br /&gt;
developer@ldc:~$ cp ../hello/Makefile ./&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Tell the Makefile What Files to Compile====&lt;br /&gt;
&lt;br /&gt;
The project is almost ready to be compiled. However, there are a few lines in the Makefile which must be modified before this can happen. First, the &amp;lt;code&amp;gt;CFILES&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;TARGET&amp;lt;/code&amp;gt; variables in the Makefile must be modified to suit this project: &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;CFILES=example.c&amp;lt;/code&amp;gt; instead of &amp;lt;code&amp;gt;CFILES=hello.c&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;TARGET=example&amp;lt;/code&amp;gt; instead of &amp;lt;code&amp;gt;TARGET=hello&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This tells the Makefile that the source file used is &amp;lt;code&amp;gt;example.c&amp;lt;/code&amp;gt;. This variable can be assigned a space-delimited list of C files. In the example there is only one file so this is not a concern. &lt;br /&gt;
&lt;br /&gt;
====Tell the Makefile What Libraries to Link====&lt;br /&gt;
&lt;br /&gt;
The last change that must be made to this Makefile is that we need to modify &amp;lt;code&amp;gt;LIBFLAGS&amp;lt;/code&amp;gt; to reflect the use of the math library for the trigonometric functions in the C file. The math library is &amp;lt;code&amp;gt;libm.so&amp;lt;/code&amp;gt;; therefore, we use &amp;lt;code&amp;gt;-lm&amp;lt;/code&amp;gt; to indicate to the linker to link &amp;lt;code&amp;gt;libm&amp;lt;/code&amp;gt; to the binary. If the library for readline were needed, instead, this would be specified with &amp;lt;code&amp;gt;-lreadline&amp;lt;/code&amp;gt; to link &amp;lt;code&amp;gt;libreadline.so&amp;lt;/code&amp;gt; Add the following line to the Makefile: &lt;br /&gt;
* &amp;lt;code&amp;gt;LIBFLAGS+=-lm&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Where in the Makefile this line is added does not matter, though it makes sense to group it with the other variable declarations. &lt;br /&gt;
&lt;br /&gt;
{{mbox | type = notice | text = Much more detailed information on working with libraries and the linker under Linux can be found at [http://www.yolinux.com/TUTORIALS/LibraryArchives-StaticAndDynamic.html YoLinux - Static, Shared Dynamic and Loadable Linux Libraries]}}&lt;br /&gt;
&lt;br /&gt;
Listing 2 shows the complete modified makefile for the &amp;lt;code&amp;gt;example.c&amp;lt;/code&amp;gt; project.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;Make&amp;quot;&amp;gt;&lt;br /&gt;
include ../global.properties&lt;br /&gt;
 &lt;br /&gt;
TARGET=example&lt;br /&gt;
CFILES=example.c&lt;br /&gt;
 &lt;br /&gt;
LIBFLAGS+=-lm&lt;br /&gt;
 &lt;br /&gt;
OBJS=$(CFILES:.c=.o)&lt;br /&gt;
DEPS=$(OBJS:.o=.d)&lt;br /&gt;
 &lt;br /&gt;
all: $(TARGET)&lt;br /&gt;
 &lt;br /&gt;
$(TARGET): $(OBJS) Makefile&lt;br /&gt;
  $(CC) $(VERBOSE) $(OBJS) $(OFLAGS) $(LIBFLAGS) $(SLIBS) -o $@&lt;br /&gt;
 &lt;br /&gt;
%.o: %.c&lt;br /&gt;
  $(CC) $(VERBOSE) $(CFLAGS) -o $@ -c $&amp;lt;&lt;br /&gt;
 &lt;br /&gt;
clean:&lt;br /&gt;
  $(RM) *.o *.gdb $(TARGET) $(DEPS)&lt;br /&gt;
 &lt;br /&gt;
upload: all&lt;br /&gt;
  $(WPUT) $(TARGET) ftp://$(LOGIN):$(PASSWORD)@$(TARGET_IP)/../../tmp/$(TARGET)&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
-include $(DEPS)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
'''Listing 2. Modified Example Makefile'''&lt;br /&gt;
&lt;br /&gt;
====Telling ''make'' About Make Targets====&lt;br /&gt;
&lt;br /&gt;
In &amp;lt;code&amp;gt;global.properties&amp;lt;/code&amp;gt; there are also variables which must be modified in order for all the &amp;lt;code&amp;gt;make&amp;lt;/code&amp;gt; targets to accomplish their purpose. For instructions on how to do this, please refer to the [[Remote Upload Set Up Guide]].&lt;br /&gt;
&lt;br /&gt;
===Cross-Compile with the EMAC OE SDK===&lt;br /&gt;
&lt;br /&gt;
Now it is time to use GNU make to compile the example source code into an application that can be run on the target machine. Makefile-based development with the EMAC OE SDK is a powerful tool which enables the customer to compile code for the target EMAC product on the Linux development machine. Once a project has been set up as described above, development can begin using the GNU make targets as described below. &lt;br /&gt;
&lt;br /&gt;
First, set the current directory to the one containing the Makefile, then execute the make targets as shown in Listing 3. For a description of each make target, read the bullet items below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ cd /path/to/sdk/EMAC-OE-arm-linux-gnueabi-SDK_XX.YY/projects/example/&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
#### Target 1 ####&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ make clean &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
rm -f *.o *.gdb example example.d&lt;br /&gt;
&lt;br /&gt;
#### Target 2 ####&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ make all &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
../../gcc-4.2.4-arm-linux-gnueabi/bin/arm-linux-gnueabi-gcc  -Wall -MMD -g -march=armv5te -mtune=arm926ej-s -o example.o -c example.c\&lt;br /&gt;
../../gcc-4.2.4-arm-linux-gnueabi/bin/arm-linux-gnueabi-gcc  example.o  -lm  -o example&lt;br /&gt;
&lt;br /&gt;
#### Target 3 ####&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ make upload &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
wput --reupload --dont-continue sentence ftp://root:emac_inc@10.0.2.41/../../tmp/example&lt;br /&gt;
--16:52:48-- `app_name'&lt;br /&gt;
    =&amp;gt; ftp://root:xxxxx@10.0.2.41:21/../../tmp/example&lt;br /&gt;
Connecting to 10.0.2.41:21... connected!&lt;br /&gt;
Logging in as root ... Logged in!&lt;br /&gt;
Length: 13,774&lt;br /&gt;
 &lt;br /&gt;
16:52:48 (example) - `350.6K/s' [13774]&lt;br /&gt;
 &lt;br /&gt;
FINISHED --16:52:48--&lt;br /&gt;
Transfered 13,774 bytes in 1 file at 107.3K/s&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
'''Listing 3. Example Make Target Invocation'''&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;make clean&amp;lt;/code&amp;gt; removes all object, dependency, and executable files generated by previous invocations of make. It literally “cleans” the directory as shown in Listing 1, Target 1.&lt;br /&gt;
* &amp;lt;code&amp;gt;make all&amp;lt;/code&amp;gt; resolves dependencies for the source code necessary to cross-compile the target file. The &amp;lt;code&amp;gt;gcc&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;g++&amp;lt;/code&amp;gt; binaries used are specified in &amp;lt;code&amp;gt;global.properties&amp;lt;/code&amp;gt; as relative paths to the &amp;lt;code&amp;gt;/path/to/sdk/EMAC-OE-arm-linux-gnueabi-SDK_XX.YY/projects/example/&amp;lt;/code&amp;gt; directory. This is why the source files must be kept in their own directory within &amp;lt;code&amp;gt;/path/to/sdk/EMAC-OE-arm-linux-gnueabi-SDK_XX.YY/projects&amp;lt;/code&amp;gt;. Listing 1, Target 2 demonstrates a successful &amp;lt;code&amp;gt;make all&amp;lt;/code&amp;gt; invocation.&lt;br /&gt;
* &amp;lt;code&amp;gt;make upload&amp;lt;/code&amp;gt; uses &amp;lt;code&amp;gt;wput&amp;lt;/code&amp;gt; to send example to the remote machine. This requires the remote EMAC product have network connection whose IP is available to the development machine. This IP address must be set as the value of the &amp;lt;code&amp;gt;TARGET_IP&amp;lt;/code&amp;gt; variable in &amp;lt;code&amp;gt;global.properties&amp;lt;/code&amp;gt;. Listing 1, Target 3 demonstrates a successful make upload invocation with &amp;lt;code&amp;gt;TARGET_IP&amp;lt;/code&amp;gt; set to 10.0.2.41.&lt;br /&gt;
&lt;br /&gt;
===Optional global.properties Modifications===&lt;br /&gt;
&lt;br /&gt;
In order to debug applications effectively, the &amp;lt;code&amp;gt;-g&amp;lt;/code&amp;gt; debug flag must be specified when running the compiler. This is set up to occur automatically by its inclusion in the &amp;lt;code&amp;gt;global.properties CFLAGS&amp;lt;/code&amp;gt; variable.&lt;br /&gt;
&lt;br /&gt;
For release builds, however, this can be harmful to the application's performance since keeping the debug symbols in the executable bloats its size. In a typical general-purpose computer this may not be noticeable, but for embedded systems there are typically memory and disk limitations. For production or release versions of an application EMAC recommends modifying the &amp;lt;code&amp;gt;global.properties CFLAGS&amp;lt;/code&amp;gt; variable to replace &amp;lt;code&amp;gt;-g&amp;lt;/code&amp;gt; with &amp;lt;code&amp;gt;-g0&amp;lt;/code&amp;gt; which tells the compiler not to include debug information in the executable.&lt;br /&gt;
&lt;br /&gt;
Using the &amp;lt;code&amp;gt;file&amp;lt;/code&amp;gt; command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ file myexecutable&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
myexecutable: ELF 32-bit LSB executable, ARM, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.14, not stripped&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Will tell you if debugging information is available within the executable. If you see, &amp;lt;code&amp;gt;not stripped&amp;lt;/code&amp;gt;, that means debugging symbols are in the binary. If you wish to remove them without using a release target build, you can use the &amp;lt;code&amp;gt;strip&amp;lt;/code&amp;gt; command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ strip myexecutable&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
If you see no output after running that command, you may assume the command succeeded (this is default behavior upon successful completion of an operation for most Unix and Linux tools). In order to make sure it succeeded, you can run the file command on it again: &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ file myexecutable&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
myexecutable: ELF 32-bit LSB executable, ARM, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.14, stripped&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The output above shows, stripped, which tells us the &amp;lt;code&amp;gt;strip&amp;lt;/code&amp;gt; command succeeded in removing debugging symbols from the binary.&lt;br /&gt;
&lt;br /&gt;
==Next Steps==&lt;br /&gt;
&lt;br /&gt;
Once the target binary has been compiled, the project is ready to be debugged. &lt;br /&gt;
&lt;br /&gt;
{{mbox | type = notice | text = Useful tools related to this article:&lt;br /&gt;
* &amp;lt;code&amp;gt;make&amp;lt;/code&amp;gt; - Automates builds&lt;br /&gt;
* &amp;lt;code&amp;gt;ld&amp;lt;/code&amp;gt; - The linker&lt;br /&gt;
* &amp;lt;code&amp;gt;ldd&amp;lt;/code&amp;gt; - Displays shared library dependencies for a binary executable.&lt;br /&gt;
* &amp;lt;code&amp;gt;strip&amp;lt;/code&amp;gt; - Removes debugging symbols from a binary executable.&lt;br /&gt;
* &amp;lt;code&amp;gt;gdb&amp;lt;/code&amp;gt; - The GNU Debugger. Often used indirectly through the Eclipse IDE interface.&lt;br /&gt;
* &amp;lt;code&amp;gt;file&amp;lt;/code&amp;gt; - Command which displays information about a file passed to it as an argument. Useful for determining whether debugging information has been stripped from a binary executable, among other things.&lt;br /&gt;
}} &lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
* [[EMAC Software Development Kit]]&lt;br /&gt;
** [[Install EMAC OE SDK]]&lt;br /&gt;
** [[Configure EMAC OE SDK]]&lt;br /&gt;
** [[Example Projects]]&lt;br /&gt;
** [[New Project]]&lt;br /&gt;
** [[Debugging with gdbserver]]&lt;/div&gt;</summary>
		<author><name>Mcoleman</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.emacinc.com/index.php?title=Using_EMAC_OE_SDK_Example_Projects&amp;diff=423</id>
		<title>Using EMAC OE SDK Example Projects</title>
		<link rel="alternate" type="text/html" href="https://wiki.emacinc.com/index.php?title=Using_EMAC_OE_SDK_Example_Projects&amp;diff=423"/>
		<updated>2013-05-09T23:00:15Z</updated>

		<summary type="html">&lt;p&gt;Mcoleman: Created page with &amp;quot;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 guide demonstrates the process of co...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;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 guide demonstrates the process of compiling one of the example projects and running it on the target machine. NOTE: It is assumed that the procedure in the EMAC OE SDK Configuration Guide has been followed prior to reading this page. &lt;br /&gt;
&lt;br /&gt;
This guide consists of two example files, a C file and a Makefile. They are located within Listing 2 and Listing 3, respectively. &lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable conventions&amp;quot;&lt;br /&gt;
!colspan=&amp;quot;2&amp;quot;|Table 1: Conventions&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;/download/directory/&amp;lt;/code&amp;gt; || Placeholder indicating the directory to which the SDK archive will be downloaded.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;/path/to/sdk/&amp;lt;/code&amp;gt; || Placeholder indicating the directory to which the SDK will be extracted.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;EMAC-OE-arm-linux-gnueabi-SDK_XX.YY.rZZ.tar.bz2&amp;lt;/code&amp;gt;&amp;lt;br /&amp;gt;&amp;lt;code&amp;gt;EMAC-OE-arm-linux-gnueabi-SDK_XX.YY&amp;lt;/code&amp;gt;&lt;br /&gt;
|| '''XX''' is the major version&amp;lt;br /&amp;gt;'''YY''' is the minor version&amp;lt;br /&amp;gt;'''ZZ''' is the current revision&amp;lt;br /&amp;gt;The major and minor version numbers will match the version of OE for which the SDK is created.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Tools==&lt;br /&gt;
&lt;br /&gt;
* GNU &amp;lt;code&amp;gt;make&amp;lt;/code&amp;gt;. Manages project dependencies.&lt;br /&gt;
* EMAC OE SDK. [See the EMAC OE SDK Install Page].&lt;br /&gt;
* &amp;lt;code&amp;gt;wput&amp;lt;/code&amp;gt;, Provides FTP capability to the build process.&lt;br /&gt;
&lt;br /&gt;
==EMAC SDK Example: Compile the &amp;quot;hello&amp;quot; Project==&lt;br /&gt;
&lt;br /&gt;
This procedure provides an overview of how to compile and run C applications for EMAC products. It assumes familiarity with the C programming language and is intended to be used by experienced programmers who are looking to learn the EMAC SDK. The “hello” example project source can be found in the projects/ subdirectory of the EMAC OE SDK root directory. The full path to the source is as follows: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
/path/to/sdk/EMAC-OE-arm-linux-gnueabi-SDK_XX.YY/projects/hello/&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Cross-compile the program using GNU Make.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ cd /path/to/sdk/EMAC-OE-arm-linux-gnueabi-SDK_XX.YY/projects/hello/&lt;br /&gt;
developer@ldc:~$ make all&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;all&amp;lt;/code&amp;gt; is a make target. This command is the equivalent to the commonly seen, Build All command found in most IDE's. The build system will only compile files which have been modified since the last build.&lt;br /&gt;
&lt;br /&gt;
Alternatively, you can simply run: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ make&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When &amp;lt;code&amp;gt;make&amp;lt;/code&amp;gt; is run by itself, it chooses its default make target. In this example, &amp;lt;code&amp;gt;all&amp;lt;/code&amp;gt; is the default make target. In any normal project, the default make target will be the one which builds the project. This allows a programmer to simply run &amp;lt;code&amp;gt;make&amp;lt;/code&amp;gt; most of the time they are doing development work.&lt;br /&gt;
&lt;br /&gt;
The Makefile based build system fully supports incremental builds. Should you desire a full rebuild, two steps will need to be followed instead of one:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ make clean&lt;br /&gt;
developer@ldc:~$ make&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;make clean&amp;lt;/code&amp;gt; command will delete any object files (these have the &amp;lt;code&amp;gt;.o&amp;lt;/code&amp;gt; extension in the gcc on Linux build system), debugger information files (with the &amp;lt;code&amp;gt;.gdb&amp;lt;/code&amp;gt; extension), executable binaries (generally, no extension) and any other files which are generated during the build process. Once this cleaning step is complete, the build system will attempt to rebuild everything.&lt;br /&gt;
&lt;br /&gt;
For a more in-depth explanation on how gcc approaches the incremental build process, see the [http://www.gnu.org/software/make/manual/make.html GNU &amp;quot;make&amp;quot; Manual].&lt;br /&gt;
&lt;br /&gt;
==EMAC SDK Example: Uploading and Running the &amp;quot;hello&amp;quot; Project&amp;quot;==&lt;br /&gt;
&lt;br /&gt;
===Uploading the Program to the Target Machine===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ make upload&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;upload&amp;lt;/code&amp;gt; is another make target. This command will send your freshly compiled binary to the target machine.&lt;br /&gt;
&lt;br /&gt;
This make target uses the development system's &amp;lt;code&amp;gt;wput&amp;lt;/code&amp;gt; program to send the binary to the target machine through FTP. This is accomplished using variables stored in the &amp;lt;code&amp;gt;global.properties&amp;lt;/code&amp;gt; file, which is included in the Makefile using the &amp;lt;code&amp;gt;include&amp;lt;/code&amp;gt; keyword. The &amp;lt;code&amp;gt;global.properties&amp;lt;/code&amp;gt; file also contains variables which &amp;lt;code&amp;gt;make&amp;lt;/code&amp;gt; passes to the compiler to ensure that the executable produced is compatible with the target CPU architecture. &lt;br /&gt;
&lt;br /&gt;
===Running the Program on the Target Machine===&lt;br /&gt;
&lt;br /&gt;
Connect remotely to the target machine. Run the program as shown in Listing 1 using the remote connection.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@emac-oe:~# chmod u+x /tmp/hello&lt;br /&gt;
root@emac-oe:~# /tmp/hello&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
'''Listing 1. Running the Remote Application'''&lt;br /&gt;
&lt;br /&gt;
{{mbox | type = notice | text = &amp;lt;code&amp;gt;chmod u+x&amp;lt;/code&amp;gt; sets the root user's permissions to allow execution of the binary. Note that this assumes that you are logged in as the system root user.}}&lt;br /&gt;
&lt;br /&gt;
{{mbox | type = notice | text = &amp;lt;code&amp;gt;/tmp/hello&amp;lt;/code&amp;gt; runs the program without any arguments.}}&lt;br /&gt;
&lt;br /&gt;
{{mbox | type = notice | text = '''NOTE:''' If you wish to run a program located in your current directory, you must run it as &amp;lt;code&amp;gt;./hello&amp;lt;/code&amp;gt;. Without the &amp;lt;code&amp;gt;./&amp;lt;/code&amp;gt; prefix, the program will not be run by the shell. The shell will only look for a program in the default search &amp;lt;code&amp;gt;PATH&amp;lt;/code&amp;gt;, unless the program's name is prefixed with a specific path. The &amp;lt;code&amp;gt;./&amp;lt;/code&amp;gt; prefix is a relative path. The &amp;lt;code&amp;gt;.&amp;lt;/code&amp;gt; represents the current directory, just as &amp;lt;code&amp;gt;..&amp;lt;/code&amp;gt; represents the previous directory. The &amp;lt;code&amp;gt;/&amp;lt;/code&amp;gt; following the &amp;lt;code&amp;gt;.&amp;lt;/code&amp;gt; indicates to the shell to look inside the current directory. In POSIX systems, such as Linux, filenames can have a &amp;lt;code&amp;gt;.&amp;lt;/code&amp;gt; as their first character, which is why the &amp;lt;code&amp;gt;/&amp;lt;/code&amp;gt; is needed. &lt;br /&gt;
&lt;br /&gt;
Incidentally, a &amp;lt;code&amp;gt;.&amp;lt;/code&amp;gt; as the first character of the filename indicates that the file is hidden. Use the &amp;lt;code&amp;gt;ls -a&amp;lt;/code&amp;gt; command to see such files.}}&lt;br /&gt;
&lt;br /&gt;
If the file compiles without trouble but has runtime bugs, you can remotely debug the application using gdbserver. Read the [[EMAC OE SDK Remote Debugging Guide]] to learn more.&lt;br /&gt;
&lt;br /&gt;
===Example C File===&lt;br /&gt;
&lt;br /&gt;
This C file can be used by programmers as an example to ensure their build configuration for EMAC products is functioning correctly.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
/**&lt;br /&gt;
 * @file hello.c&lt;br /&gt;
 *&lt;br /&gt;
 * Simple Hello World application for EMAC OE.&lt;br /&gt;
 *&lt;br /&gt;
 * @author EMAC, Inc. &amp;lt;support@emacinc.com&amp;gt;&lt;br /&gt;
 */&lt;br /&gt;
/***************************************************************************&lt;br /&gt;
 *                                                                         *&lt;br /&gt;
 *   This program is free software; you can redistribute it and/or modify  *&lt;br /&gt;
 *   it under the terms of the GNU General Public License as published by  *&lt;br /&gt;
 *   the Free Software Foundation; either version 2 of the License, or     *&lt;br /&gt;
 *   (at your option) any later version.                                   *&lt;br /&gt;
 *                                                                         *&lt;br /&gt;
 ***************************************************************************/&lt;br /&gt;
 &lt;br /&gt;
#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
#include &amp;lt;stdlib.h&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
int main(void)&lt;br /&gt;
{&lt;br /&gt;
    printf(&amp;quot;Hello EMAC OE!\n&amp;quot;);&lt;br /&gt;
    exit(EXIT_SUCCESS);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
'''Listing 2. &amp;quot;Hello World&amp;quot; example project&lt;br /&gt;
&lt;br /&gt;
===Example Makefile===&lt;br /&gt;
&lt;br /&gt;
Listing 3 shows the default &amp;lt;code&amp;gt;Makefile&amp;lt;/code&amp;gt; used for the hello example project. This is a necessary component of the EMAC SDK which directs GNU Make in resolving source code dependencies before calling the cross-compiler to create a binary for the target platform. It also provides a convenient upload target which utilizes the development system's &amp;lt;code&amp;gt;wput&amp;lt;/code&amp;gt; command to send the compiled binary to the target system. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;Make&amp;quot;&amp;gt;&lt;br /&gt;
include ../global.properties&lt;br /&gt;
 &lt;br /&gt;
TARGET=hello&lt;br /&gt;
CFILES=hello.c&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
OBJS=$(CFILES:.c=.o)&lt;br /&gt;
DEPS=$(OBJS:.o=.d)&lt;br /&gt;
 &lt;br /&gt;
all: $(TARGET)&lt;br /&gt;
 &lt;br /&gt;
$(TARGET): $(OBJS) Makefile&lt;br /&gt;
  $(CC) $(VERBOSE) $(OBJS) $(OFLAGS) $(LIBFLAGS) $(SLIBS) -o $@&lt;br /&gt;
 &lt;br /&gt;
%.o: %.c&lt;br /&gt;
  $(CC) $(VERBOSE) $(CFLAGS) -o $@ -c $&amp;lt;&lt;br /&gt;
 &lt;br /&gt;
clean:&lt;br /&gt;
  $(RM) *.o *.gdb $(TARGET) $(DEPS)&lt;br /&gt;
 &lt;br /&gt;
upload: all&lt;br /&gt;
  $(WPUT) $(TARGET) ftp://$(LOGIN):$(PASSWORD)@$(TARGET_IP)/../../tmp/$(TARGET)&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
-include $(DEPS)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
'''Listing 3. Example EMAC OE SDK Makefile'''&lt;br /&gt;
&lt;br /&gt;
{{mbox | type = notice | text = '''NOTE:''' Using the documentation for GNU Make will be required to gain a solid understanding of the build system. Here is a brief description of this Makefile to help you get started.&lt;br /&gt;
* The &amp;lt;code&amp;gt;include&amp;lt;/code&amp;gt; command tells &amp;lt;code&amp;gt;make&amp;lt;/code&amp;gt; to pull in the file specified in a way similar to the C/C++ &amp;lt;code&amp;gt;#include&amp;lt;/code&amp;gt; preprocessor directive.&lt;br /&gt;
* The &amp;lt;code&amp;gt;TARGET=&amp;lt;/code&amp;gt; directive tells &amp;lt;code&amp;gt;make&amp;lt;/code&amp;gt; the name and location it should use for any executable binaries or shared object binaries (shared objects are similar to Windows &amp;lt;code&amp;gt;.dlls&amp;lt;/code&amp;gt;) it produces.&lt;br /&gt;
* The &amp;lt;code&amp;gt;CFILES=&amp;lt;/code&amp;gt; directive tells &amp;lt;code&amp;gt;make&amp;lt;/code&amp;gt; the names of the C source files it needs to build.&lt;br /&gt;
* The &amp;lt;code&amp;gt;OBJS=&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;DEPS=&amp;lt;/code&amp;gt; directives tell &amp;lt;code&amp;gt;make&amp;lt;/code&amp;gt; how to produce file names for the object and dependency files it generates. This file specifies a method for these which will work for most projects, and is unlikely to need modification.&lt;br /&gt;
* &amp;lt;code&amp;gt;all:&amp;lt;/code&amp;gt; specifies the make target named “all.” &amp;lt;code&amp;gt;clean:&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;upload:&amp;lt;/code&amp;gt;, similarly, specify the make targets for targets of these names, respectively. New make targets can be given names this way. make will perform all the steps listed after the target name until it encounters another target name.&lt;br /&gt;
* The &amp;lt;code&amp;gt;CC&amp;lt;/code&amp;gt; variable refers to the &amp;lt;code&amp;gt;gcc&amp;lt;/code&amp;gt; command, because &amp;lt;code&amp;gt;CC&amp;lt;/code&amp;gt; is so defined in the &amp;lt;code&amp;gt;global.properties&amp;lt;/code&amp;gt; file included by this Makefile. The &amp;lt;code&amp;gt;$(CC)&amp;lt;/code&amp;gt; syntax tells &amp;lt;code&amp;gt;make&amp;lt;/code&amp;gt; to read the value of the variable, &amp;lt;code&amp;gt;CC&amp;lt;/code&amp;gt;, and replace &amp;lt;code&amp;gt;$(CC)&amp;lt;/code&amp;gt; with the value of &amp;lt;code&amp;gt;CC&amp;lt;/code&amp;gt; prior to attempting to execute the command. This is similar to the way many scripting languages work, and hopefully will feel pretty natural to any developer working with Makefiles for the first time.}}&lt;br /&gt;
&lt;br /&gt;
{{mbox | type = notice | text = '''NOTE:''' This is a simple, basic Makefile which can be extended as needed to support many projects. Should your build requirements become complex, more sophistication may be required. A ''build system builder'' may be the tool you need. If this becomes necessary, options you may wish to consider include: &lt;br /&gt;
* Buy a good book on &amp;lt;code&amp;gt;make&amp;lt;/code&amp;gt; and learn the system thoroughly.&lt;br /&gt;
* Adopt a build system builder tool. ''CMake'' has proven to be popular for many large projects, and is simpler to use than ''autotools''. Buying a book on the build system builder tool chosen may prove wise.&lt;br /&gt;
* The build system builder in Eclipse may be able to handle the complexity of your requirements. This is probably the simplest option.&lt;br /&gt;
''NOTE: '''Build system builder''' refers to a tool which generates a set of scripts and/or Makefiles which are then used to build a project.''&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
==Next Steps==&lt;br /&gt;
&lt;br /&gt;
After compiling and running an example project, the next step is to create a new project. The [[EMAC OE SDK New Project Guide]] details this process from start to finish.&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
* [[EMAC Software Development Kit]]&lt;br /&gt;
** Install EMAC OE SDK&lt;br /&gt;
** Configure EMAC OE SDK&lt;br /&gt;
** Example Projects&lt;br /&gt;
** New Project&lt;br /&gt;
** Debugging with gdbserver&lt;/div&gt;</summary>
		<author><name>Mcoleman</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.emacinc.com/index.php?title=Configuring_EMAC_OE_4.0_SDK&amp;diff=422</id>
		<title>Configuring EMAC OE 4.0 SDK</title>
		<link rel="alternate" type="text/html" href="https://wiki.emacinc.com/index.php?title=Configuring_EMAC_OE_4.0_SDK&amp;diff=422"/>
		<updated>2013-05-07T21:06:28Z</updated>

		<summary type="html">&lt;p&gt;Mcoleman: /* See Also */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{| class=&amp;quot;wikitable conventions&amp;quot;&lt;br /&gt;
!colspan=&amp;quot;2&amp;quot;|Table 1: Conventions&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;/download/directory/&amp;lt;/code&amp;gt; || Placeholder indicating the directory to which the SDK archive will be downloaded.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;/path/to/sdk/&amp;lt;/code&amp;gt; || Placeholder indicating the directory to which the SDK will be extracted.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;EMAC-OE-arm-linux-gnueabi-SDK_XX.YY.rZZ.tar.bz2&amp;lt;/code&amp;gt;&amp;lt;br /&amp;gt;&amp;lt;code&amp;gt;EMAC-OE-arm-linux-gnueabi-SDK_XX.YY&amp;lt;/code&amp;gt;&lt;br /&gt;
|| '''XX''' is the major version&amp;lt;br /&amp;gt;'''YY''' is the minor version&amp;lt;br /&amp;gt;'''ZZ''' is the current revision&amp;lt;br /&amp;gt;The major and minor version numbers will match the version of OE for which the SDK is created.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
When Eclipse generates a Makefile to use for building a project, the generated Makefile includes a file named global.properties before it performs any other steps. This file is located in the projects directory, which is the root directory for Eclipse projects. The projects directory is located within the EMAC SDK directory provided by the EMAC SDK package (or installed on the LDC). &lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;global.properties&amp;lt;/code&amp;gt; file provides information needed to build projects and upload them to the target machine (the board supplied by EMAC). The following information is provided by this file: &lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Configuration variable !! Description &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;SDKBASE&amp;lt;/code&amp;gt; || The base directory for the SDK .&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;CC&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;CXX&amp;lt;/code&amp;gt; || Exectuable binaries to use for compiling for the C and C++ compiler, respectively.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;LD_LIBRARY_PATH&amp;lt;/code&amp;gt; || The path the linker should use to search for shared library files.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;CFLAGS&amp;lt;/code&amp;gt; || The flags passed to the compiler to specify target processor architecture, debugging flags, etc.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;OFLAGS&amp;lt;/code&amp;gt; || The flags passed to the compiler to specify optimization options to use.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;TARGET_IP&amp;lt;/code&amp;gt; || The IP Address of the target machine (needed for uploading the compiled binary to the target machine).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;LOGIN&amp;lt;/code&amp;gt; || The user name to use for logging into the target machine.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;PASSWORD&amp;lt;/code&amp;gt; || The password to use for logging into the target machine.*&lt;br /&gt;
|- &lt;br /&gt;
| &amp;lt;code&amp;gt;WPUT&amp;lt;/code&amp;gt; ||  The location of the &amp;lt;code&amp;gt;wput&amp;lt;/code&amp;gt; command, along with options to pass to &amp;lt;code&amp;gt;wput&amp;lt;/code&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
'''*NOTE''' The password is stored in plain text in this file. However, read permission is required to view this password. In most development environments, this should not be an issue. If development is taking place in a shared environment (such as a University lab) and secrecy of this password is required, simply ensure that only trusted users have read permission for this file.&lt;br /&gt;
&lt;br /&gt;
{{mbox | type = warning | text = Configuring permissions on files is a common source of problems for people new to doing so under Linux. EMAC does not recommend altering the default settings (which should be secure in most environments) unless absolutely necessary. EMAC will only be able to provide very limited support should these settings be manually configured. The standard Linux commands, &amp;lt;code&amp;gt;chmod&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;chgrp&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;chown&amp;lt;/code&amp;gt; are typically used to configure these permissions. Please see the documentation for these commands using the man command, or find a reference with your favorite search engine. '''Caveat''': This will require any user wishing to build this software to have such permission, since programs run by a user can only read files the user is permitted to use.}}&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;global.properties&amp;lt;/code&amp;gt; file is actually a type of virtual file, called a softlink. This softlink acts as a pointer which points to another file. The file it points to is chosen when the CPU architecture is chosen. To see why it works this way, see the above information about the flags specified for the processor architecture, and note that different library and compiler paths may be required to support different hardware. The softlink is updated when the hardware to use for the development project is selected.&lt;br /&gt;
&lt;br /&gt;
{{mbox | type = notice | text = Should problems relating to this part of the build system show up during the development process, these files or softlinks may have been accidentally modified. Inspecting these files and softlinks, and/or rerunning the hardware selection script, may provide the fix for the problems. The &amp;lt;code&amp;gt;ln&amp;lt;/code&amp;gt; command with the &amp;lt;code&amp;gt;-s&amp;lt;/code&amp;gt; option (see &amp;lt;code&amp;gt;man ln&amp;lt;/code&amp;gt;) is the command used to create softlinks.}}&lt;br /&gt;
&lt;br /&gt;
==Configuration Steps==&lt;br /&gt;
&lt;br /&gt;
The following configuration steps are necessary to begin using the EMAC OE SDK. &lt;br /&gt;
&lt;br /&gt;
Before cross-compiling source code on the development machine for the target machine: &lt;br /&gt;
&lt;br /&gt;
* A [[set up script]] linking &amp;lt;code&amp;gt;global.properties&amp;lt;/code&amp;gt; to an architecture-specific &amp;lt;code&amp;gt;global.properties&amp;lt;/code&amp;gt; file must be run.&lt;br /&gt;
* The &amp;lt;code&amp;gt;TARGET_IP&amp;lt;/code&amp;gt; variable in the [[global.properties]] file must be changed to the IP address or hostname belonging to the target board.&lt;br /&gt;
&lt;br /&gt;
{{mbox | type = notice | text = These configurations assume that the [[EMAC OE SDK]] is installed.}}&lt;br /&gt;
&lt;br /&gt;
==SDK Set Up Script==&lt;br /&gt;
&lt;br /&gt;
Before compiling source code for the target machine, toolchain libraries for the target machine must be specified by running &amp;lt;code&amp;gt;setmachine.sh&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
===Procedure===&lt;br /&gt;
&lt;br /&gt;
# Navigate to the SDK directory.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ cd /path/to/sdk/EMAC-OE-arm-linux-gnueabi-SDK_XX.YY/&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
# Run the script using the command shown below to produce a menu as shown in Figure 1 with options for the target machine for which the source will be compiled.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ ./setmachine.sh&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
[[File:Emac_oe_sdk_setup-2.png]]&lt;br /&gt;
&lt;br /&gt;
==Remote Upload Set-up==&lt;br /&gt;
&lt;br /&gt;
In the &amp;lt;code&amp;gt;global.properties&amp;lt;/code&amp;gt; file there is a variable, &amp;lt;code&amp;gt;IP&amp;lt;/code&amp;gt; which must be set to the target board IP address as shown in Listing 1 below. This step is necessary to ensure that the Make target, &amp;lt;code&amp;gt;'upload'&amp;lt;/code&amp;gt; will work as expected.&lt;br /&gt;
&lt;br /&gt;
===Procedure===&lt;br /&gt;
&lt;br /&gt;
# Navigate to the projects directory within the SDK.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ cd /path/to/sdk/EMAC-OE-arm-linux-gnueabi-SDK_XX.YY/projects&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
# The &amp;lt;code&amp;gt;global.properties&amp;lt;/code&amp;gt; file should be listed in the current directory. The relevant lines from &amp;lt;code&amp;gt;global.properties&amp;lt;/code&amp;gt; are shown in Listing 1 below.&lt;br /&gt;
'''Listing 1. &amp;lt;code&amp;gt;global.properties&amp;lt;/code&amp;gt; snippet'''&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
TARGET_IP=&lt;br /&gt;
LOGIN=root&lt;br /&gt;
PASSWORD=emac_inc_90210&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
# Change the value of &amp;lt;code&amp;gt;TARGET_IP&amp;lt;/code&amp;gt; to the target system's IP address.&lt;br /&gt;
This can be found using the following command from a shell on the target system:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@emac-oe:~# /sbin/ifconfig eth0 | grep inet&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
For more information on how to connect to the remote system, see the [[initial connections section]] of the [[EMAC OE Getting Started Guide|EMAC OE getting started guide]].&lt;br /&gt;
# Change the value of &amp;lt;code&amp;gt;PASSWORD&amp;lt;/code&amp;gt; to whatever value was set in the [[System Login section]] of the [[EMAC OE Getting Started Guide|EMAC OE getting started guide]]. Listing 1 shows the default user name and password.&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
* [[EMAC Software Development Kit]]&lt;br /&gt;
** [[Install EMAC OE SDK]]&lt;br /&gt;
** [[Configure EMAC OE SDK]]&lt;br /&gt;
** [[Example Projects]]&lt;br /&gt;
** [[New Project]]&lt;br /&gt;
** [[Debugging with gdbserver]]&lt;/div&gt;</summary>
		<author><name>Mcoleman</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.emacinc.com/index.php?title=Configuring_EMAC_OE_4.0_SDK&amp;diff=421</id>
		<title>Configuring EMAC OE 4.0 SDK</title>
		<link rel="alternate" type="text/html" href="https://wiki.emacinc.com/index.php?title=Configuring_EMAC_OE_4.0_SDK&amp;diff=421"/>
		<updated>2013-05-07T21:05:57Z</updated>

		<summary type="html">&lt;p&gt;Mcoleman: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{| class=&amp;quot;wikitable conventions&amp;quot;&lt;br /&gt;
!colspan=&amp;quot;2&amp;quot;|Table 1: Conventions&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;/download/directory/&amp;lt;/code&amp;gt; || Placeholder indicating the directory to which the SDK archive will be downloaded.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;/path/to/sdk/&amp;lt;/code&amp;gt; || Placeholder indicating the directory to which the SDK will be extracted.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;EMAC-OE-arm-linux-gnueabi-SDK_XX.YY.rZZ.tar.bz2&amp;lt;/code&amp;gt;&amp;lt;br /&amp;gt;&amp;lt;code&amp;gt;EMAC-OE-arm-linux-gnueabi-SDK_XX.YY&amp;lt;/code&amp;gt;&lt;br /&gt;
|| '''XX''' is the major version&amp;lt;br /&amp;gt;'''YY''' is the minor version&amp;lt;br /&amp;gt;'''ZZ''' is the current revision&amp;lt;br /&amp;gt;The major and minor version numbers will match the version of OE for which the SDK is created.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
When Eclipse generates a Makefile to use for building a project, the generated Makefile includes a file named global.properties before it performs any other steps. This file is located in the projects directory, which is the root directory for Eclipse projects. The projects directory is located within the EMAC SDK directory provided by the EMAC SDK package (or installed on the LDC). &lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;global.properties&amp;lt;/code&amp;gt; file provides information needed to build projects and upload them to the target machine (the board supplied by EMAC). The following information is provided by this file: &lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Configuration variable !! Description &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;SDKBASE&amp;lt;/code&amp;gt; || The base directory for the SDK .&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;CC&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;CXX&amp;lt;/code&amp;gt; || Exectuable binaries to use for compiling for the C and C++ compiler, respectively.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;LD_LIBRARY_PATH&amp;lt;/code&amp;gt; || The path the linker should use to search for shared library files.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;CFLAGS&amp;lt;/code&amp;gt; || The flags passed to the compiler to specify target processor architecture, debugging flags, etc.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;OFLAGS&amp;lt;/code&amp;gt; || The flags passed to the compiler to specify optimization options to use.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;TARGET_IP&amp;lt;/code&amp;gt; || The IP Address of the target machine (needed for uploading the compiled binary to the target machine).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;LOGIN&amp;lt;/code&amp;gt; || The user name to use for logging into the target machine.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;PASSWORD&amp;lt;/code&amp;gt; || The password to use for logging into the target machine.*&lt;br /&gt;
|- &lt;br /&gt;
| &amp;lt;code&amp;gt;WPUT&amp;lt;/code&amp;gt; ||  The location of the &amp;lt;code&amp;gt;wput&amp;lt;/code&amp;gt; command, along with options to pass to &amp;lt;code&amp;gt;wput&amp;lt;/code&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
'''*NOTE''' The password is stored in plain text in this file. However, read permission is required to view this password. In most development environments, this should not be an issue. If development is taking place in a shared environment (such as a University lab) and secrecy of this password is required, simply ensure that only trusted users have read permission for this file.&lt;br /&gt;
&lt;br /&gt;
{{mbox | type = warning | text = Configuring permissions on files is a common source of problems for people new to doing so under Linux. EMAC does not recommend altering the default settings (which should be secure in most environments) unless absolutely necessary. EMAC will only be able to provide very limited support should these settings be manually configured. The standard Linux commands, &amp;lt;code&amp;gt;chmod&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;chgrp&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;chown&amp;lt;/code&amp;gt; are typically used to configure these permissions. Please see the documentation for these commands using the man command, or find a reference with your favorite search engine. '''Caveat''': This will require any user wishing to build this software to have such permission, since programs run by a user can only read files the user is permitted to use.}}&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;global.properties&amp;lt;/code&amp;gt; file is actually a type of virtual file, called a softlink. This softlink acts as a pointer which points to another file. The file it points to is chosen when the CPU architecture is chosen. To see why it works this way, see the above information about the flags specified for the processor architecture, and note that different library and compiler paths may be required to support different hardware. The softlink is updated when the hardware to use for the development project is selected.&lt;br /&gt;
&lt;br /&gt;
{{mbox | type = notice | text = Should problems relating to this part of the build system show up during the development process, these files or softlinks may have been accidentally modified. Inspecting these files and softlinks, and/or rerunning the hardware selection script, may provide the fix for the problems. The &amp;lt;code&amp;gt;ln&amp;lt;/code&amp;gt; command with the &amp;lt;code&amp;gt;-s&amp;lt;/code&amp;gt; option (see &amp;lt;code&amp;gt;man ln&amp;lt;/code&amp;gt;) is the command used to create softlinks.}}&lt;br /&gt;
&lt;br /&gt;
==Configuration Steps==&lt;br /&gt;
&lt;br /&gt;
The following configuration steps are necessary to begin using the EMAC OE SDK. &lt;br /&gt;
&lt;br /&gt;
Before cross-compiling source code on the development machine for the target machine: &lt;br /&gt;
&lt;br /&gt;
* A [[set up script]] linking &amp;lt;code&amp;gt;global.properties&amp;lt;/code&amp;gt; to an architecture-specific &amp;lt;code&amp;gt;global.properties&amp;lt;/code&amp;gt; file must be run.&lt;br /&gt;
* The &amp;lt;code&amp;gt;TARGET_IP&amp;lt;/code&amp;gt; variable in the [[global.properties]] file must be changed to the IP address or hostname belonging to the target board.&lt;br /&gt;
&lt;br /&gt;
{{mbox | type = notice | text = These configurations assume that the [[EMAC OE SDK]] is installed.}}&lt;br /&gt;
&lt;br /&gt;
==SDK Set Up Script==&lt;br /&gt;
&lt;br /&gt;
Before compiling source code for the target machine, toolchain libraries for the target machine must be specified by running &amp;lt;code&amp;gt;setmachine.sh&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
===Procedure===&lt;br /&gt;
&lt;br /&gt;
# Navigate to the SDK directory.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ cd /path/to/sdk/EMAC-OE-arm-linux-gnueabi-SDK_XX.YY/&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
# Run the script using the command shown below to produce a menu as shown in Figure 1 with options for the target machine for which the source will be compiled.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ ./setmachine.sh&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
[[File:Emac_oe_sdk_setup-2.png]]&lt;br /&gt;
&lt;br /&gt;
==Remote Upload Set-up==&lt;br /&gt;
&lt;br /&gt;
In the &amp;lt;code&amp;gt;global.properties&amp;lt;/code&amp;gt; file there is a variable, &amp;lt;code&amp;gt;IP&amp;lt;/code&amp;gt; which must be set to the target board IP address as shown in Listing 1 below. This step is necessary to ensure that the Make target, &amp;lt;code&amp;gt;'upload'&amp;lt;/code&amp;gt; will work as expected.&lt;br /&gt;
&lt;br /&gt;
===Procedure===&lt;br /&gt;
&lt;br /&gt;
# Navigate to the projects directory within the SDK.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ cd /path/to/sdk/EMAC-OE-arm-linux-gnueabi-SDK_XX.YY/projects&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
# The &amp;lt;code&amp;gt;global.properties&amp;lt;/code&amp;gt; file should be listed in the current directory. The relevant lines from &amp;lt;code&amp;gt;global.properties&amp;lt;/code&amp;gt; are shown in Listing 1 below.&lt;br /&gt;
'''Listing 1. &amp;lt;code&amp;gt;global.properties&amp;lt;/code&amp;gt; snippet'''&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
TARGET_IP=&lt;br /&gt;
LOGIN=root&lt;br /&gt;
PASSWORD=emac_inc_90210&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
# Change the value of &amp;lt;code&amp;gt;TARGET_IP&amp;lt;/code&amp;gt; to the target system's IP address.&lt;br /&gt;
This can be found using the following command from a shell on the target system:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@emac-oe:~# /sbin/ifconfig eth0 | grep inet&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
For more information on how to connect to the remote system, see the [[initial connections section]] of the [[EMAC OE Getting Started Guide|EMAC OE getting started guide]].&lt;br /&gt;
# Change the value of &amp;lt;code&amp;gt;PASSWORD&amp;lt;/code&amp;gt; to whatever value was set in the [[System Login section]] of the [[EMAC OE Getting Started Guide|EMAC OE getting started guide]]. Listing 1 shows the default user name and password.&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
* [[EMAC Software Development Kit]]&lt;br /&gt;
** Install EMAC OE SDK&lt;br /&gt;
** Configure EMAC OE SDK&lt;br /&gt;
** Example Projects&lt;br /&gt;
** New Project&lt;br /&gt;
** Debugging with gdbserver&lt;/div&gt;</summary>
		<author><name>Mcoleman</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.emacinc.com/index.php?title=Configuring_EMAC_OE_4.0_SDK&amp;diff=420</id>
		<title>Configuring EMAC OE 4.0 SDK</title>
		<link rel="alternate" type="text/html" href="https://wiki.emacinc.com/index.php?title=Configuring_EMAC_OE_4.0_SDK&amp;diff=420"/>
		<updated>2013-05-07T21:04:18Z</updated>

		<summary type="html">&lt;p&gt;Mcoleman: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{| class=&amp;quot;wikitable conventions&amp;quot;&lt;br /&gt;
!colspan=&amp;quot;2&amp;quot;|Table 1: Conventions&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;/download/directory/&amp;lt;/code&amp;gt; || Placeholder indicating the directory to which the SDK archive will be downloaded.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;/path/to/sdk/&amp;lt;/code&amp;gt; || Placeholder indicating the directory to which the SDK will be extracted.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;EMAC-OE-arm-linux-gnueabi-SDK_XX.YY.rZZ.tar.bz2&amp;lt;/code&amp;gt;&amp;lt;br /&amp;gt;&amp;lt;code&amp;gt;EMAC-OE-arm-linux-gnueabi-SDK_XX.YY&amp;lt;/code&amp;gt;&lt;br /&gt;
|| '''XX''' is the major version&amp;lt;br /&amp;gt;'''YY''' is the minor version&amp;lt;br /&amp;gt;'''ZZ''' is the current revision&amp;lt;br /&amp;gt;The major and minor version numbers will match the version of OE for which the SDK is created.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
When Eclipse generates a Makefile to use for building a project, the generated Makefile includes a file named global.properties before it performs any other steps. This file is located in the projects directory, which is the root directory for Eclipse projects. The projects directory is located within the EMAC SDK directory provided by the EMAC SDK package (or installed on the LDC). &lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;global.properties&amp;lt;/code&amp;gt; file provides information needed to build projects and upload them to the target machine (the board supplied by EMAC). The following information is provided by this file: &lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Configuration variable !! Description &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;SDKBASE&amp;lt;/code&amp;gt; || The base directory for the SDK .&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;CC&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;CXX&amp;lt;/code&amp;gt; || Exectuable binaries to use for compiling for the C and C++ compiler, respectively.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;LD_LIBRARY_PATH&amp;lt;/code&amp;gt; || The path the linker should use to search for shared library files.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;CFLAGS&amp;lt;/code&amp;gt; || The flags passed to the compiler to specify target processor architecture, debugging flags, etc.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;OFLAGS&amp;lt;/code&amp;gt; || The flags passed to the compiler to specify optimization options to use.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;TARGET_IP&amp;lt;/code&amp;gt; || The IP Address of the target machine (needed for uploading the compiled binary to the target machine).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;LOGIN&amp;lt;/code&amp;gt; || The user name to use for logging into the target machine.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;PASSWORD&amp;lt;/code&amp;gt; || The password to use for logging into the target machine.*&lt;br /&gt;
|- &lt;br /&gt;
| &amp;lt;code&amp;gt;WPUT&amp;lt;/code&amp;gt; ||  The location of the &amp;lt;code&amp;gt;wput&amp;lt;/code&amp;gt; command, along with options to pass to &amp;lt;code&amp;gt;wput&amp;lt;/code&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
'''*NOTE''' The password is stored in plain text in this file. However, read permission is required to view this password. In most development environments, this should not be an issue. If development is taking place in a shared environment (such as a University lab) and secrecy of this password is required, simply ensure that only trusted users have read permission for this file.&lt;br /&gt;
&lt;br /&gt;
{{mbox | type = warning | text = Configuring permissions on files is a common source of problems for people new to doing so under Linux. EMAC does not recommend altering the default settings (which should be secure in most environments) unless absolutely necessary. EMAC will only be able to provide very limited support should these settings be manually configured. The standard Linux commands, &amp;lt;code&amp;gt;chmod&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;chgrp&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;chown&amp;lt;/code&amp;gt; are typically used to configure these permissions. Please see the documentation for these commands using the man command, or find a reference with your favorite search engine. '''Caveat''': This will require any user wishing to build this software to have such permission, since programs run by a user can only read files the user is permitted to use.}}&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;global.properties&amp;lt;/code&amp;gt; file is actually a type of virtual file, called a softlink. This softlink acts as a pointer which points to another file. The file it points to is chosen when the CPU architecture is chosen. To see why it works this way, see the above information about the flags specified for the processor architecture, and note that different library and compiler paths may be required to support different hardware. The softlink is updated when the hardware to use for the development project is selected.&lt;br /&gt;
&lt;br /&gt;
{{mbox | type = notice | text = Should problems relating to this part of the build system show up during the development process, these files or softlinks may have been accidentally modified. Inspecting these files and softlinks, and/or rerunning the hardware selection script, may provide the fix for the problems. The &amp;lt;code&amp;gt;ln&amp;lt;/code&amp;gt; command with the &amp;lt;code&amp;gt;-s&amp;lt;/code&amp;gt; option (see &amp;lt;code&amp;gt;man ln&amp;lt;/code&amp;gt;) is the command used to create softlinks.}}&lt;br /&gt;
&lt;br /&gt;
==Configuration Steps==&lt;br /&gt;
&lt;br /&gt;
The following configuration steps are necessary to begin using the EMAC OE SDK. &lt;br /&gt;
&lt;br /&gt;
Before cross-compiling source code on the development machine for the target machine: &lt;br /&gt;
&lt;br /&gt;
* A [[set up script]] linking &amp;lt;code&amp;gt;global.properties&amp;lt;/code&amp;gt; to an architecture-specific &amp;lt;code&amp;gt;global.properties&amp;lt;/code&amp;gt; file must be run.&lt;br /&gt;
* The &amp;lt;code&amp;gt;TARGET_IP&amp;lt;/code&amp;gt; variable in the [[global.properties]] file must be changed to the IP address or hostname belonging to the target board.&lt;br /&gt;
&lt;br /&gt;
{{mbox | type = notice | text = These configurations assume that the [[EMAC OE SDK]] is installed.}}&lt;br /&gt;
&lt;br /&gt;
==SDK Set Up Script==&lt;br /&gt;
&lt;br /&gt;
Before compiling source code for the target machine, toolchain libraries for the target machine must be specified by running &amp;lt;code&amp;gt;setmachine.sh&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
===Procedure===&lt;br /&gt;
&lt;br /&gt;
# Navigate to the SDK directory.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ cd /path/to/sdk/EMAC-OE-arm-linux-gnueabi-SDK_XX.YY/&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
# Run the script using the command shown below to produce a menu as shown in Figure 1 with options for the target machine for which the source will be compiled.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ ./setmachine.sh&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
[[File:Emac_oe_sdk_setup-2.png]]&lt;br /&gt;
&lt;br /&gt;
==Remote Upload Set-up==&lt;br /&gt;
&lt;br /&gt;
In the &amp;lt;code&amp;gt;global.properties&amp;lt;/code&amp;gt; file there is a variable, &amp;lt;code&amp;gt;IP&amp;lt;/code&amp;gt; which must be set to the target board IP address as shown in Listing 1 below. This step is necessary to ensure that the Make target, &amp;lt;code&amp;gt;'upload'&amp;lt;/code&amp;gt; will work as expected.&lt;br /&gt;
&lt;br /&gt;
===Procedure===&lt;br /&gt;
&lt;br /&gt;
# Navigate to the projects directory within the SDK.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ cd /path/to/sdk/EMAC-OE-arm-linux-gnueabi-SDK_XX.YY/projects&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
# The &amp;lt;code&amp;gt;global.properties&amp;lt;/code&amp;gt; file should be listed in the current directory. The relevant lines from &amp;lt;code&amp;gt;global.properties&amp;lt;/code&amp;gt; are shown in Listing 1 below.&lt;br /&gt;
'''Listing 1. &amp;lt;code&amp;gt;global.properties&amp;lt;/code&amp;gt; snippet'''&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
TARGET_IP=&lt;br /&gt;
LOGIN=root&lt;br /&gt;
PASSWORD=emac_inc_90210&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
# Change the value of &amp;lt;code&amp;gt;TARGET_IP&amp;lt;/code&amp;gt; to the target system's IP address.&lt;br /&gt;
This can be found using the following command from a shell on the target system:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@emac-oe:~# /sbin/ifconfig eth0 | grep inet&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
For more information on how to connect to the remote system, see the [[initial connections section]] of the [[EMAC OE Getting Started Guide|EMAC OE getting started guide]].&lt;br /&gt;
# Change the value of &amp;lt;code&amp;gt;PASSWORD&amp;lt;/code&amp;gt; to whatever value was set in the [[System Login section]] of the [[EMAC OE Getting Started Guide|EMAC OE getting started guide]]. Listing 1 shows the default user name and password.&lt;/div&gt;</summary>
		<author><name>Mcoleman</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.emacinc.com/index.php?title=File:Emac_oe_sdk_setup-2.png&amp;diff=419</id>
		<title>File:Emac oe sdk setup-2.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.emacinc.com/index.php?title=File:Emac_oe_sdk_setup-2.png&amp;diff=419"/>
		<updated>2013-05-07T20:56:44Z</updated>

		<summary type="html">&lt;p&gt;Mcoleman: Target architecture dialog window&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Target architecture dialog window&lt;/div&gt;</summary>
		<author><name>Mcoleman</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.emacinc.com/index.php?title=Configuring_EMAC_OE_4.0_SDK&amp;diff=418</id>
		<title>Configuring EMAC OE 4.0 SDK</title>
		<link rel="alternate" type="text/html" href="https://wiki.emacinc.com/index.php?title=Configuring_EMAC_OE_4.0_SDK&amp;diff=418"/>
		<updated>2013-05-07T20:49:57Z</updated>

		<summary type="html">&lt;p&gt;Mcoleman: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{| class=&amp;quot;wikitable conventions&amp;quot;&lt;br /&gt;
!colspan=&amp;quot;2&amp;quot;|Table 1: Conventions&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;/download/directory/&amp;lt;/code&amp;gt; || Placeholder indicating the directory to which the SDK archive will be downloaded.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;/path/to/sdk/&amp;lt;/code&amp;gt; || Placeholder indicating the directory to which the SDK will be extracted.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;EMAC-OE-arm-linux-gnueabi-SDK_XX.YY.rZZ.tar.bz2&amp;lt;/code&amp;gt;&amp;lt;br /&amp;gt;&amp;lt;code&amp;gt;EMAC-OE-arm-linux-gnueabi-SDK_XX.YY&amp;lt;/code&amp;gt;&lt;br /&gt;
|| '''XX''' is the major version&amp;lt;br /&amp;gt;'''YY''' is the minor version&amp;lt;br /&amp;gt;'''ZZ''' is the current revision&amp;lt;br /&amp;gt;The major and minor version numbers will match the version of OE for which the SDK is created.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
When Eclipse generates a Makefile to use for building a project, the generated Makefile includes a file named global.properties before it performs any other steps. This file is located in the projects directory, which is the root directory for Eclipse projects. The projects directory is located within the EMAC SDK directory provided by the EMAC SDK package (or installed on the LDC). &lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;global.properties&amp;lt;/code&amp;gt; file provides information needed to build projects and upload them to the target machine (the board supplied by EMAC). The following information is provided by this file: &lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Configuration variable !! Description &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;SDKBASE&amp;lt;/code&amp;gt; || The base directory for the SDK .&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;CC&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;CXX&amp;lt;/code&amp;gt; || Exectuable binaries to use for compiling for the C and C++ compiler, respectively.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;LD_LIBRARY_PATH&amp;lt;/code&amp;gt; || The path the linker should use to search for shared library files.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;CFLAGS&amp;lt;/code&amp;gt; || The flags passed to the compiler to specify target processor architecture, debugging flags, etc.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;OFLAGS&amp;lt;/code&amp;gt; || The flags passed to the compiler to specify optimization options to use.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;TARGET_IP&amp;lt;/code&amp;gt; || The IP Address of the target machine (needed for uploading the compiled binary to the target machine).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;LOGIN&amp;lt;/code&amp;gt; || The user name to use for logging into the target machine.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;PASSWORD&amp;lt;/code&amp;gt; || The password to use for logging into the target machine.*&lt;br /&gt;
|- &lt;br /&gt;
| &amp;lt;code&amp;gt;WPUT&amp;lt;/code&amp;gt; ||  The location of the &amp;lt;code&amp;gt;wput&amp;lt;/code&amp;gt; command, along with options to pass to &amp;lt;code&amp;gt;wput&amp;lt;/code&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
'''*NOTE''' The password is stored in plain text in this file. However, read permission is required to view this password. In most development environments, this should not be an issue. If development is taking place in a shared environment (such as a University lab) and secrecy of this password is required, simply ensure that only trusted users have read permission for this file.&lt;br /&gt;
&lt;br /&gt;
{{mbox | type = warning | text = Configuring permissions on files is a common source of problems for people new to doing so under Linux. EMAC does not recommend altering the default settings (which should be secure in most environments) unless absolutely necessary. EMAC will only be able to provide very limited support should these settings be manually configured. The standard Linux commands, &amp;lt;code&amp;gt;chmod&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;chgrp&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;chown&amp;lt;/code&amp;gt; are typically used to configure these permissions. Please see the documentation for these commands using the man command, or find a reference with your favorite search engine. '''Caveat''': This will require any user wishing to build this software to have such permission, since programs run by a user can only read files the user is permitted to use.}}&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;global.properties&amp;lt;/code&amp;gt; file is actually a type of virtual file, called a softlink. This softlink acts as a pointer which points to another file. The file it points to is chosen when the CPU architecture is chosen. To see why it works this way, see the above information about the flags specified for the processor architecture, and note that different library and compiler paths may be required to support different hardware. The softlink is updated when the hardware to use for the development project is selected.&lt;br /&gt;
&lt;br /&gt;
{{mbox | type = notice | text = Should problems relating to this part of the build system show up during the development process, these files or softlinks may have been accidentally modified. Inspecting these files and softlinks, and/or rerunning the hardware selection script, may provide the fix for the problems. The &amp;lt;code&amp;gt;ln&amp;lt;/code&amp;gt; command with the &amp;lt;code&amp;gt;-s&amp;lt;/code&amp;gt; option (see &amp;lt;code&amp;gt;man ln&amp;lt;/code&amp;gt;) is the command used to create softlinks.}}&lt;br /&gt;
&lt;br /&gt;
==Configuration Steps==&lt;br /&gt;
&lt;br /&gt;
The following configuration steps are necessary to begin using the EMAC OE SDK. &lt;br /&gt;
&lt;br /&gt;
Before cross-compiling source code on the development machine for the target machine: &lt;br /&gt;
&lt;br /&gt;
* A [[set up script]] linking &amp;lt;code&amp;gt;global.properties&amp;lt;/code&amp;gt; to an architecture-specific &amp;lt;code&amp;gt;global.properties&amp;lt;/code&amp;gt; file must be run.&lt;br /&gt;
* The &amp;lt;code&amp;gt;TARGET_IP&amp;lt;/code&amp;gt; variable in the [[global.properties]] file must be changed to the IP address or hostname belonging to the target board.&lt;br /&gt;
&lt;br /&gt;
{{mbox | type = notice | text = These configurations assume that the [[EMAC OE SDK]] is installed.}}&lt;/div&gt;</summary>
		<author><name>Mcoleman</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.emacinc.com/index.php?title=Configuring_EMAC_OE_4.0_SDK&amp;diff=417</id>
		<title>Configuring EMAC OE 4.0 SDK</title>
		<link rel="alternate" type="text/html" href="https://wiki.emacinc.com/index.php?title=Configuring_EMAC_OE_4.0_SDK&amp;diff=417"/>
		<updated>2013-05-07T20:49:06Z</updated>

		<summary type="html">&lt;p&gt;Mcoleman: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;When Eclipse generates a Makefile to use for building a project, the generated Makefile includes a file named global.properties before it performs any other steps. This file is located in the projects directory, which is the root directory for Eclipse projects. The projects directory is located within the EMAC SDK directory provided by the EMAC SDK package (or installed on the LDC). &lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;global.properties&amp;lt;/code&amp;gt; file provides information needed to build projects and upload them to the target machine (the board supplied by EMAC). The following information is provided by this file: &lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Configuration variable !! Description &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;SDKBASE&amp;lt;/code&amp;gt; || The base directory for the SDK .&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;CC&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;CXX&amp;lt;/code&amp;gt; || Exectuable binaries to use for compiling for the C and C++ compiler, respectively.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;LD_LIBRARY_PATH&amp;lt;/code&amp;gt; || The path the linker should use to search for shared library files.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;CFLAGS&amp;lt;/code&amp;gt; || The flags passed to the compiler to specify target processor architecture, debugging flags, etc.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;OFLAGS&amp;lt;/code&amp;gt; || The flags passed to the compiler to specify optimization options to use.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;TARGET_IP&amp;lt;/code&amp;gt; || The IP Address of the target machine (needed for uploading the compiled binary to the target machine).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;LOGIN&amp;lt;/code&amp;gt; || The user name to use for logging into the target machine.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;PASSWORD&amp;lt;/code&amp;gt; || The password to use for logging into the target machine.*&lt;br /&gt;
|- &lt;br /&gt;
| &amp;lt;code&amp;gt;WPUT&amp;lt;/code&amp;gt; ||  The location of the &amp;lt;code&amp;gt;wput&amp;lt;/code&amp;gt; command, along with options to pass to &amp;lt;code&amp;gt;wput&amp;lt;/code&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
'''*NOTE''' The password is stored in plain text in this file. However, read permission is required to view this password. In most development environments, this should not be an issue. If development is taking place in a shared environment (such as a University lab) and secrecy of this password is required, simply ensure that only trusted users have read permission for this file.&lt;br /&gt;
&lt;br /&gt;
{{mbox | type = warning | text = Configuring permissions on files is a common source of problems for people new to doing so under Linux. EMAC does not recommend altering the default settings (which should be secure in most environments) unless absolutely necessary. EMAC will only be able to provide very limited support should these settings be manually configured. The standard Linux commands, &amp;lt;code&amp;gt;chmod&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;chgrp&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;chown&amp;lt;/code&amp;gt; are typically used to configure these permissions. Please see the documentation for these commands using the man command, or find a reference with your favorite search engine. '''Caveat''': This will require any user wishing to build this software to have such permission, since programs run by a user can only read files the user is permitted to use.}}&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;global.properties&amp;lt;/code&amp;gt; file is actually a type of virtual file, called a softlink. This softlink acts as a pointer which points to another file. The file it points to is chosen when the CPU architecture is chosen. To see why it works this way, see the above information about the flags specified for the processor architecture, and note that different library and compiler paths may be required to support different hardware. The softlink is updated when the hardware to use for the development project is selected.&lt;br /&gt;
&lt;br /&gt;
{{mbox | type = notice | text = Should problems relating to this part of the build system show up during the development process, these files or softlinks may have been accidentally modified. Inspecting these files and softlinks, and/or rerunning the hardware selection script, may provide the fix for the problems. The &amp;lt;code&amp;gt;ln&amp;lt;/code&amp;gt; command with the &amp;lt;code&amp;gt;-s&amp;lt;/code&amp;gt; option (see &amp;lt;code&amp;gt;man ln&amp;lt;/code&amp;gt;) is the command used to create softlinks.}}&lt;br /&gt;
&lt;br /&gt;
==Configuration Steps==&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable conventions&amp;quot;&lt;br /&gt;
!colspan=&amp;quot;2&amp;quot;|Table 1: Conventions&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;/download/directory/&amp;lt;/code&amp;gt; || Placeholder indicating the directory to which the SDK archive will be downloaded.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;/path/to/sdk/&amp;lt;/code&amp;gt; || Placeholder indicating the directory to which the SDK will be extracted.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;EMAC-OE-arm-linux-gnueabi-SDK_XX.YY.rZZ.tar.bz2&amp;lt;/code&amp;gt;&amp;lt;br /&amp;gt;&amp;lt;code&amp;gt;EMAC-OE-arm-linux-gnueabi-SDK_XX.YY&amp;lt;/code&amp;gt;&lt;br /&gt;
|| '''XX''' is the major version&amp;lt;br /&amp;gt;'''YY''' is the minor version&amp;lt;br /&amp;gt;'''ZZ''' is the current revision&amp;lt;br /&amp;gt;The major and minor version numbers will match the version of OE for which the SDK is created.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The following configuration steps are necessary to begin using the EMAC OE SDK. &lt;br /&gt;
&lt;br /&gt;
Before cross-compiling source code on the development machine for the target machine: &lt;br /&gt;
&lt;br /&gt;
* A [[set up script]] linking &amp;lt;code&amp;gt;global.properties&amp;lt;/code&amp;gt; to an architecture-specific &amp;lt;code&amp;gt;global.properties&amp;lt;/code&amp;gt; file must be run.&lt;br /&gt;
* The &amp;lt;code&amp;gt;TARGET_IP&amp;lt;/code&amp;gt; variable in the [[global.properties]] file must be changed to the IP address or hostname belonging to the target board.&lt;br /&gt;
&lt;br /&gt;
{{mbox | type = notice | text = These configurations assume that the [[EMAC OE SDK]] is installed.}}&lt;/div&gt;</summary>
		<author><name>Mcoleman</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.emacinc.com/index.php?title=Installing_EMAC_OE_4.0_SDK&amp;diff=416</id>
		<title>Installing EMAC OE 4.0 SDK</title>
		<link rel="alternate" type="text/html" href="https://wiki.emacinc.com/index.php?title=Installing_EMAC_OE_4.0_SDK&amp;diff=416"/>
		<updated>2013-05-07T20:48:04Z</updated>

		<summary type="html">&lt;p&gt;Mcoleman: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Before beginning installation of the SDK, it is important to prepare the development system with the tools necessary to get the job done. These tools can either be command line interface (CLI) or graphical utilities. Both options are described in this guide.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable conventions&amp;quot;&lt;br /&gt;
!colspan=&amp;quot;2&amp;quot;|Table 1: Conventions&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;/download/directory/&amp;lt;/code&amp;gt; || Placeholder indicating the directory to which the SDK archive will be downloaded.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;/path/to/sdk/&amp;lt;/code&amp;gt; || Placeholder indicating the directory to which the SDK will be extracted.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;EMAC-OE-arm-linux-gnueabi-SDK_XX.YY.rZZ.tar.bz2&amp;lt;/code&amp;gt;&amp;lt;br /&amp;gt;&amp;lt;code&amp;gt;EMAC-OE-arm-linux-gnueabi-SDK_XX.YY&amp;lt;/code&amp;gt;&lt;br /&gt;
|| '''XX''' is the major version&amp;lt;br /&amp;gt;'''YY''' is the minor version&amp;lt;br /&amp;gt;'''ZZ''' is the current revision&amp;lt;br /&amp;gt;The major and minor version numbers will match the version of OE for which the SDK is created.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{{mbox | type = notice | style = margin-left: 0; margin-bottom: 1em; | text = The SDK archive and directory names will differ based on which SDK is being installed. For example, the toolchain binary names will reflect the target CPU architecture. What is shown in this guide is for demonstration's sake.}}&lt;br /&gt;
&lt;br /&gt;
== Required tools ==&lt;br /&gt;
* Web browser (recommended [https://www.mozilla.org/en-US/firefox/new/ Mozilla Firefox], [https://www.gnu.org/software/gnuzilla/ Gnuzilla Icecat], [http://www.konqueror.org/download/ KDE Konqueror])&lt;br /&gt;
* Archiving tool. There are two options available:&lt;br /&gt;
** Graphical tools ([[Ark]] for KDE, [[File Roller]] for GNOME)&lt;br /&gt;
** CLI tool ([[tar]] is standard)&lt;br /&gt;
* &amp;lt;code&amp;gt;dialog&amp;lt;/code&amp;gt; required for CLI use of SDK ([[see the developer's website]]).&lt;br /&gt;
&lt;br /&gt;
== Recommendations ==&lt;br /&gt;
The following are some recommended install opations&lt;br /&gt;
* The SDK should be kept in the user's home directory. For example, &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# /path/to/sdk/ might expand to something like &lt;br /&gt;
/home/user_name/cust_software/&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
To clarify, this is the location where &amp;lt;code&amp;gt;EMAC-OE-arm-linux-gnueabi-SDK_XX.YY/&amp;lt;/code&amp;gt; will end up.&lt;br /&gt;
* The default SDK root folder name should be kept at its default name since this preserves the version information for the EMAC OE SDK.&lt;br /&gt;
&lt;br /&gt;
== Procedure ==&lt;br /&gt;
# Download the SDK. The latest version can be found on the public EMAC FTP site. Be sure to download the SDK that matches the architecture of your target system. Contact EMAC if unsure.&lt;br /&gt;
# Uncompress the SDK.&lt;br /&gt;
** Using a graphical archiving tool, uncompress the archive files to the chosen development directory. If you need assistance with this, please see the documentation for your graphical archiving tool.&lt;br /&gt;
** Alternatively, you can uncompress the archive from the CLI using tar: &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ cd /target/directory&lt;br /&gt;
developer@ldc:~$ bzip2 -cd /download/directory/EMAC-OE-arm-linux-gnuabi-SDK_XX.YY.rZZ.tar.bz2 | tar xvf -&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
This will produce a subdirectory within the target directory:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ ls&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
EMAC-OE-arm-linux-gnueabi-SDK_XX.YY/&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Next Steps ==&lt;br /&gt;
Once the EMAC SDK is installed, the next step is to [[configure it]].&lt;/div&gt;</summary>
		<author><name>Mcoleman</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.emacinc.com/index.php?title=MediaWiki:Common.css&amp;diff=415</id>
		<title>MediaWiki:Common.css</title>
		<link rel="alternate" type="text/html" href="https://wiki.emacinc.com/index.php?title=MediaWiki:Common.css&amp;diff=415"/>
		<updated>2013-05-07T20:47:36Z</updated>

		<summary type="html">&lt;p&gt;Mcoleman: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;/* CSS placed here will be applied to all skins */&lt;br /&gt;
&lt;br /&gt;
/* Change tag size over logo to fit size of EMAC logo */&lt;br /&gt;
#p-logo a,&lt;br /&gt;
#p-logo a:hover {        &lt;br /&gt;
    display: block;&lt;br /&gt;
    height: 100px;&lt;br /&gt;
    width: 12.2em;&lt;br /&gt;
    background-repeat: no-repeat;&lt;br /&gt;
    background-position: 35% 50% !important;&lt;br /&gt;
    text-decoration: none;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/* conventions table */&lt;br /&gt;
&lt;br /&gt;
table.conventions {&lt;br /&gt;
  float: right;&lt;br /&gt;
  padding: 5px;&lt;br /&gt;
  margin: 10px;&lt;br /&gt;
  margin-left: 20px;&lt;br /&gt;
  width: 500px;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/* GeSHi overrides */&lt;br /&gt;
&lt;br /&gt;
.mw-geshi {&lt;br /&gt;
 font-size: 1.2em;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
.geshi-joined-top {&lt;br /&gt;
 border-bottom: none !important;&lt;br /&gt;
 margin-bottom: 0 !important;&lt;br /&gt;
 padding-bottom: 1em !important;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
.geshi-joined-bottom {&lt;br /&gt;
 border-top: none !important;&lt;br /&gt;
 padding-top: 0 !important;&lt;br /&gt;
 margin-top: 0 !important;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/* CSS Copied from MediaWiki.org */&lt;br /&gt;
&lt;br /&gt;
/* Cell sizes for ambox/tmbox/imbox/cmbox/ombox/fmbox/dmbox message boxes */&lt;br /&gt;
th.mbox-text, td.mbox-text {   /* The message body cell(s) */&lt;br /&gt;
    border: none; &lt;br /&gt;
    padding: 0.25em 0.9em;     /* 0.9em left/right */&lt;br /&gt;
    width: 100%;               /* Make all mboxes the same width regardless of text length */&lt;br /&gt;
}&lt;br /&gt;
td.mbox-image {                /* The left image cell */&lt;br /&gt;
    border: none; &lt;br /&gt;
    padding: 2px 0 2px 0.9em;  /* 0.9em left, 0px right */&lt;br /&gt;
    text-align: center; &lt;br /&gt;
}&lt;br /&gt;
td.mbox-imageright {           /* The right image cell */&lt;br /&gt;
    border: none;&lt;br /&gt;
    padding: 2px 0.9em 2px 0;  /* 0px left, 0.9em right */&lt;br /&gt;
    text-align: center; &lt;br /&gt;
}&lt;br /&gt;
td.mbox-empty-cell {           /* An empty narrow cell */&lt;br /&gt;
    border: none;&lt;br /&gt;
    padding: 0px;&lt;br /&gt;
    width: 1px;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/* Article message box styles */&lt;br /&gt;
table.ambox {&lt;br /&gt;
    margin: 0px 10%;                  /* 10% = Will not overlap with other elements */&lt;br /&gt;
    border: 1px solid #aaa; &lt;br /&gt;
    border-left: 10px solid #1e90ff;  /* Default &amp;quot;notice&amp;quot; blue */&lt;br /&gt;
    background: #fbfbfb; &lt;br /&gt;
}&lt;br /&gt;
table.ambox + table.ambox {      /* Single border between stacked boxes. */&lt;br /&gt;
    margin-top: -1px;&lt;br /&gt;
}&lt;br /&gt;
.ambox th.mbox-text, &lt;br /&gt;
.ambox td.mbox-text {            /* The message body cell(s) */&lt;br /&gt;
    padding: 0.25em 0.5em;       /* 0.5em left/right */&lt;br /&gt;
}&lt;br /&gt;
.ambox td.mbox-image {           /* The left image cell */&lt;br /&gt;
    padding: 2px 0 2px 0.5em;    /* 0.5em left, 0px right */&lt;br /&gt;
}&lt;br /&gt;
.ambox td.mbox-imageright {      /* The right image cell */&lt;br /&gt;
    padding: 2px 0.5em 2px 0;    /* 0px left, 0.5em right */&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
table.ambox-notice {&lt;br /&gt;
    border-left: 10px solid #1e90ff;    /* Blue */&lt;br /&gt;
}&lt;br /&gt;
table.ambox-speedy {&lt;br /&gt;
    border-left: 10px solid #b22222;    /* Red */&lt;br /&gt;
    background: #fee;                   /* Pink */&lt;br /&gt;
}&lt;br /&gt;
table.ambox-delete {&lt;br /&gt;
    border-left: 10px solid #b22222;    /* Red */&lt;br /&gt;
}&lt;br /&gt;
table.ambox-content {&lt;br /&gt;
    border-left: 10px solid #f28500;    /* Orange */&lt;br /&gt;
}&lt;br /&gt;
table.ambox-style {&lt;br /&gt;
    border-left: 10px solid #f4c430;    /* Yellow */&lt;br /&gt;
}&lt;br /&gt;
table.ambox-move {&lt;br /&gt;
    border-left: 10px solid #9932cc;    /* Purple */&lt;br /&gt;
}&lt;br /&gt;
table.ambox-protection {&lt;br /&gt;
    border-left: 10px solid #bba;       /* Gray-gold */&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/* Image message box styles */&lt;br /&gt;
table.imbox {&lt;br /&gt;
    margin: 4px 10%; &lt;br /&gt;
    border-collapse: collapse; &lt;br /&gt;
    border: 3px solid #1e90ff;    /* Default &amp;quot;notice&amp;quot; blue */&lt;br /&gt;
    background: #fbfbfb;&lt;br /&gt;
}&lt;br /&gt;
.imbox .mbox-text .imbox {  /* For imboxes inside imbox-text cells. */&lt;br /&gt;
    margin: 0 -0.5em;       /* 0.9 - 0.5 = 0.4em left/right.        */&lt;br /&gt;
    display: block;         /* Fix for webkit to force 100% width.  */&lt;br /&gt;
}&lt;br /&gt;
.mbox-inside .imbox {       /* For imboxes inside other templates.  */&lt;br /&gt;
    margin: 4px;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
table.imbox-notice {&lt;br /&gt;
    border: 3px solid #1e90ff;    /* Blue */&lt;br /&gt;
}&lt;br /&gt;
table.imbox-speedy {&lt;br /&gt;
    border: 3px solid #b22222;    /* Red */&lt;br /&gt;
    background: #fee;             /* Pink */&lt;br /&gt;
}&lt;br /&gt;
table.imbox-delete {&lt;br /&gt;
    border: 3px solid #b22222;    /* Red */&lt;br /&gt;
}&lt;br /&gt;
table.imbox-content {&lt;br /&gt;
    border: 3px solid #f28500;    /* Orange */&lt;br /&gt;
}&lt;br /&gt;
table.imbox-style {&lt;br /&gt;
    border: 3px solid #f4c430;    /* Yellow */&lt;br /&gt;
}&lt;br /&gt;
table.imbox-move {&lt;br /&gt;
    border: 3px solid #9932cc;    /* Purple */&lt;br /&gt;
}&lt;br /&gt;
table.imbox-protection {&lt;br /&gt;
    border: 3px solid #bba;       /* Gray-gold */&lt;br /&gt;
}&lt;br /&gt;
table.imbox-license {&lt;br /&gt;
    border: 3px solid #88a;       /* Dark gray */&lt;br /&gt;
    background: #f7f8ff;          /* Light gray */&lt;br /&gt;
}&lt;br /&gt;
table.imbox-featured {&lt;br /&gt;
    border: 3px solid #cba135;    /* Brown-gold */&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/* Category message box styles */&lt;br /&gt;
table.cmbox {&lt;br /&gt;
    margin: 3px 10%;&lt;br /&gt;
    border-collapse: collapse;&lt;br /&gt;
    border: 1px solid #aaa; &lt;br /&gt;
    background: #DFE8FF;    /* Default &amp;quot;notice&amp;quot; blue */&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
table.cmbox-notice {&lt;br /&gt;
    background: #D8E8FF;    /* Blue */&lt;br /&gt;
}&lt;br /&gt;
table.cmbox-speedy {&lt;br /&gt;
    margin-top: 4px;&lt;br /&gt;
    margin-bottom: 4px;&lt;br /&gt;
    border: 4px solid #b22222;    /* Red */&lt;br /&gt;
    background: #FFDBDB;          /* Pink */&lt;br /&gt;
}&lt;br /&gt;
table.cmbox-delete {&lt;br /&gt;
    background: #FFDBDB;    /* Red */&lt;br /&gt;
}&lt;br /&gt;
table.cmbox-content {&lt;br /&gt;
    background: #FFE7CE;    /* Orange */&lt;br /&gt;
}&lt;br /&gt;
table.cmbox-style {&lt;br /&gt;
    background: #FFF9DB;    /* Yellow */&lt;br /&gt;
}&lt;br /&gt;
table.cmbox-move {&lt;br /&gt;
    background: #E4D8FF;    /* Purple */&lt;br /&gt;
}&lt;br /&gt;
table.cmbox-protection {&lt;br /&gt;
    background: #EFEFE1;    /* Gray-gold */&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/* Other pages message box styles */&lt;br /&gt;
table.ombox {&lt;br /&gt;
    margin: 4px 10%; &lt;br /&gt;
    border-collapse: collapse; &lt;br /&gt;
    border: 1px solid #aaa;       /* Default &amp;quot;notice&amp;quot; gray */&lt;br /&gt;
    background: #f9f9f9;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
table.ombox-notice {&lt;br /&gt;
    border: 1px solid #aaa;       /* Gray */&lt;br /&gt;
}&lt;br /&gt;
table.ombox-speedy {&lt;br /&gt;
    border: 2px solid #b22222;    /* Red */&lt;br /&gt;
    background: #fee;             /* Pink */&lt;br /&gt;
}&lt;br /&gt;
table.ombox-delete {&lt;br /&gt;
    border: 2px solid #b22222;    /* Red */&lt;br /&gt;
}&lt;br /&gt;
table.ombox-content {&lt;br /&gt;
    border: 1px solid #f28500;    /* Orange */&lt;br /&gt;
}&lt;br /&gt;
table.ombox-style {&lt;br /&gt;
    border: 1px solid #f4c430;    /* Yellow */&lt;br /&gt;
}&lt;br /&gt;
table.ombox-move {&lt;br /&gt;
    border: 1px solid #9932cc;    /* Purple */&lt;br /&gt;
}&lt;br /&gt;
table.ombox-protection {&lt;br /&gt;
    border: 2px solid #bba;       /* Gray-gold */&lt;br /&gt;
}&lt;br /&gt;
 &lt;br /&gt;
/* Talk page message box styles */&lt;br /&gt;
table.tmbox {&lt;br /&gt;
    margin: 4px 10%;&lt;br /&gt;
    border-collapse: collapse;&lt;br /&gt;
    border: 1px solid #c0c090;    /* Default &amp;quot;notice&amp;quot; gray-brown */&lt;br /&gt;
    background: #f8eaba;&lt;br /&gt;
}&lt;br /&gt;
.mediawiki .mbox-inside .tmbox { /* For tmboxes inside other templates. The &amp;quot;mediawiki&amp;quot; class ensures that */&lt;br /&gt;
    margin: 2px 0;               /* this declaration overrides other styles (including mbox-small above)   */&lt;br /&gt;
    width: 100%;                 /* For Safari and Opera */&lt;br /&gt;
}&lt;br /&gt;
.mbox-inside .tmbox.mbox-small { /* &amp;quot;small&amp;quot; tmboxes should not be small when  */&lt;br /&gt;
    line-height: 1.5em;          /* also &amp;quot;nested&amp;quot;, so reset styles that are   */   &lt;br /&gt;
    font-size: 100%;             /* set in &amp;quot;mbox-small&amp;quot; above.                */&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
table.tmbox-speedy {&lt;br /&gt;
    border: 2px solid #b22222;    /* Red */&lt;br /&gt;
    background: #fee;             /* Pink */&lt;br /&gt;
}&lt;br /&gt;
table.tmbox-delete {&lt;br /&gt;
    border: 2px solid #b22222;    /* Red */&lt;br /&gt;
}&lt;br /&gt;
table.tmbox-content {&lt;br /&gt;
    border: 2px solid #f28500;    /* Orange */&lt;br /&gt;
}&lt;br /&gt;
table.tmbox-style {&lt;br /&gt;
    border: 2px solid #f4c430;    /* Yellow */&lt;br /&gt;
}&lt;br /&gt;
table.tmbox-move {&lt;br /&gt;
    border: 2px solid #9932cc;    /* Purple */&lt;br /&gt;
}&lt;br /&gt;
table.tmbox-protection,&lt;br /&gt;
table.tmbox-notice {&lt;br /&gt;
    border: 1px solid #c0c090;    /* Gray-brown */&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/* Disambig and set index box styles */&lt;br /&gt;
table.dmbox {&lt;br /&gt;
    clear: both; &lt;br /&gt;
    margin: 0.9em 1em; &lt;br /&gt;
    border-top: 1px solid #ccc; &lt;br /&gt;
    border-bottom: 1px solid #ccc; &lt;br /&gt;
    background: transparent;&lt;br /&gt;
}&lt;br /&gt;
 &lt;br /&gt;
/* Footer and header message box styles */&lt;br /&gt;
table.fmbox {&lt;br /&gt;
    clear: both;&lt;br /&gt;
    margin: 0.2em 0;&lt;br /&gt;
    width: 100%;&lt;br /&gt;
    border: 1px solid #aaa;&lt;br /&gt;
    background: #f9f9f9;     /* Default &amp;quot;system&amp;quot; gray */&lt;br /&gt;
}&lt;br /&gt;
table.fmbox-system {&lt;br /&gt;
    background: #f9f9f9;&lt;br /&gt;
}&lt;br /&gt;
table.fmbox-warning {&lt;br /&gt;
    border: 1px solid #bb7070;  /* Dark pink */&lt;br /&gt;
    background: #ffdbdb;        /* Pink */&lt;br /&gt;
}&lt;br /&gt;
table.fmbox-editnotice {&lt;br /&gt;
    background: transparent;&lt;br /&gt;
}&lt;br /&gt;
/* Div based &amp;quot;warning&amp;quot; style fmbox messages. */&lt;br /&gt;
div.mw-warning-with-logexcerpt,&lt;br /&gt;
div.mw-lag-warn-high,&lt;br /&gt;
div.mw-cascadeprotectedwarning,&lt;br /&gt;
div#mw-protect-cascadeon {&lt;br /&gt;
    clear: both;&lt;br /&gt;
    margin: 0.2em 0;&lt;br /&gt;
    border: 1px solid #bb7070;&lt;br /&gt;
    background: #ffdbdb;&lt;br /&gt;
    padding: 0.25em 0.9em;&lt;br /&gt;
}&lt;br /&gt;
/* Div based &amp;quot;system&amp;quot; style fmbox messages. &lt;br /&gt;
   Used in [[MediaWiki:Readonly lag]]. */&lt;br /&gt;
div.mw-lag-warn-normal,&lt;br /&gt;
div.fmbox-system {&lt;br /&gt;
    clear: both;&lt;br /&gt;
    margin: 0.2em 0;&lt;br /&gt;
    border: 1px solid #aaa;&lt;br /&gt;
    background: #f9f9f9;&lt;br /&gt;
    padding: 0.25em 0.9em;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/* These mbox-small classes must be placed after all other &lt;br /&gt;
   ambox/tmbox/ombox etc classes. &amp;quot;body.mediawiki&amp;quot; is so &lt;br /&gt;
   they override &amp;quot;table.ambox + table.ambox&amp;quot; above. */&lt;br /&gt;
body.mediawiki table.mbox-small {   /* For the &amp;quot;small=yes&amp;quot; option. */&lt;br /&gt;
    clear: right;&lt;br /&gt;
    float: right;&lt;br /&gt;
    margin: 4px 0 4px 1em;&lt;br /&gt;
    width: 238px;&lt;br /&gt;
    font-size: 88%;&lt;br /&gt;
    line-height: 1.25em;&lt;br /&gt;
}&lt;br /&gt;
body.mediawiki table.mbox-small-left {   /* For the &amp;quot;small=left&amp;quot; option. */&lt;br /&gt;
    margin: 4px 1em 4px 0;&lt;br /&gt;
    width: 238px;&lt;br /&gt;
    border-collapse: collapse;&lt;br /&gt;
    font-size: 88%;&lt;br /&gt;
    line-height: 1.25em;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/******* [[Main Page|MAIN PAGE]] STYLING **********/&lt;br /&gt;
&lt;br /&gt;
body.page-Main_Page h1.firstHeading { display:none; }&lt;br /&gt;
&lt;br /&gt;
#mainpage_topbox {&lt;br /&gt;
  background: #f9f9f9; &lt;br /&gt;
  padding: 0px; &lt;br /&gt;
  border: 1px solid #aaaaaa; &lt;br /&gt;
  margin: 0.2em 10px 10px;&lt;br /&gt;
}&lt;br /&gt;
 &lt;br /&gt;
.mainpage_boxtitle, .mainpage_hubtitle, #mainpage_pagetitle {&lt;br /&gt;
  font-size: 105%; &lt;br /&gt;
  padding: 0.4em; &lt;br /&gt;
  background-color: #eeeeee; &lt;br /&gt;
  border-bottom: 1px solid #aaaaaa; &lt;br /&gt;
 &lt;br /&gt;
}&lt;br /&gt;
 &lt;br /&gt;
.mainpage_boxtitle {&lt;br /&gt;
  line-height: 120%;&lt;br /&gt;
}&lt;br /&gt;
 &lt;br /&gt;
#mainpage_pagetitle {&lt;br /&gt;
  color: #44661F; &lt;br /&gt;
  font-size: 200% !important;&lt;br /&gt;
}&lt;br /&gt;
 &lt;br /&gt;
#mainpage_sitelinks {&lt;br /&gt;
  padding: 0.2em; &lt;br /&gt;
  text-align: center;&lt;br /&gt;
  background-color: white;&lt;br /&gt;
}&lt;br /&gt;
.mainpage_hubtitle {&lt;br /&gt;
  text-align: center;&lt;br /&gt;
}&lt;br /&gt;
 &lt;br /&gt;
.mainpage_boxcontents, .mainpage_boxcontents_small {&lt;br /&gt;
  background: #ffffff;&lt;br /&gt;
  padding: 0.4em 1em;&lt;br /&gt;
}&lt;br /&gt;
 &lt;br /&gt;
.mainpage_boxcontents_small {&lt;br /&gt;
  font-size: 95%;&lt;br /&gt;
}&lt;br /&gt;
 &lt;br /&gt;
.mainpage_hubbox, #mainpage_newscell, #mainpage_downloadcell {&lt;br /&gt;
  padding: 0;&lt;br /&gt;
  border: 1px solid #aaaaaa;&lt;br /&gt;
}&lt;br /&gt;
 &lt;br /&gt;
.mainpage_hubbox {&lt;br /&gt;
  margin-bottom: 0;&lt;br /&gt;
}&lt;br /&gt;
 &lt;br /&gt;
#mainpage_newscell {&lt;br /&gt;
  margin-bottom: 15px;&lt;br /&gt;
  margin-top: 0 !important;&lt;br /&gt;
}&lt;br /&gt;
 &lt;br /&gt;
#mainpage_newscell .mainpage_boxtitle {&lt;br /&gt;
    background-image: url(http://upload.wikimedia.org/wikipedia/commons/thumb/8/89/Exquisite-khelpcenter.png/20px-Exquisite-khelpcenter.png);&lt;br /&gt;
    background-repeat: no-repeat;&lt;br /&gt;
    background-position: 99% 0.3em;&lt;br /&gt;
    padding-right: 25px;&lt;br /&gt;
}&lt;br /&gt;
 &lt;br /&gt;
#mainpage_downloadcell {&lt;br /&gt;
  width: 17em; &lt;br /&gt;
  margin-bottom: 5px; &lt;br /&gt;
}&lt;br /&gt;
 &lt;br /&gt;
#mainpage_downloadcell .mainpage_boxtitle {&lt;br /&gt;
    background-image: url(http://upload.wikimedia.org/wikipedia/commons/thumb/5/5d/Crystal_Clear_action_build.png/18px-Crystal_Clear_action_build.png);&lt;br /&gt;
    background-repeat: no-repeat;&lt;br /&gt;
    background-position: 96% 0.33em;&lt;br /&gt;
    padding-right: 25px;&lt;br /&gt;
}&lt;br /&gt;
 &lt;br /&gt;
/* The words 'MediaWiki.org' in the title.*/&lt;br /&gt;
#mainpage_mwtitle {&lt;br /&gt;
  color: #005288;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/*** masonry ***/&lt;br /&gt;
&lt;br /&gt;
.header_box {&lt;br /&gt;
 border: 1px solid #aaa;&lt;br /&gt;
 padding: 20px;&lt;br /&gt;
 margin-bottom: 20px;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
.masonry_item {&lt;br /&gt;
 border: 1px solid #aaa;&lt;br /&gt;
 margin-bottom: 20px;&lt;br /&gt;
 width: 520px; /* 3 col */&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
.masonry_item &amp;gt; * {&lt;br /&gt;
 padding:20px;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
.masonry_item h2 {&lt;br /&gt;
 text-align:center;&lt;br /&gt;
 background-color: #eee;&lt;br /&gt;
 font-size: 105%;&lt;br /&gt;
 font-weight: bold;&lt;br /&gt;
 padding: 0.4em;&lt;br /&gt;
}&lt;/div&gt;</summary>
		<author><name>Mcoleman</name></author>
		
	</entry>
</feed>