<?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=Mgloff</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=Mgloff"/>
	<link rel="alternate" type="text/html" href="https://wiki.emacinc.com/wiki/Special:Contributions/Mgloff"/>
	<updated>2026-05-24T11:07:52Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.31.6</generator>
	<entry>
		<id>https://wiki.emacinc.com/index.php?title=Installing_EMAC_OE_5.0_SDK&amp;diff=15012</id>
		<title>Installing EMAC OE 5.0 SDK</title>
		<link rel="alternate" type="text/html" href="https://wiki.emacinc.com/index.php?title=Installing_EMAC_OE_5.0_SDK&amp;diff=15012"/>
		<updated>2021-07-28T15:53:01Z</updated>

		<summary type="html">&lt;p&gt;Mgloff: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Prerequisites==&lt;br /&gt;
If you are installing the SDK using the ADT Installer (Automatic Install), dependencies will be automatically installed for the supported distributions: Debian/Ubuntu, Fedora, CentOS, openSUSE. EMAC also provides a [ftp://ftp.emacinc.com/EMAC_Linux/Virtual_LDCs/EMAC_Virtual_LDC.ova pre-configured virtual machine image.]&lt;br /&gt;
{{note | Currently the version of Qt Creator installed during the automatic installation does not work on Debian 8}} &lt;br /&gt;
&lt;br /&gt;
If you are installing the SDK manually or using a non-supported distribution, you will have to install the dependencies manually.&lt;br /&gt;
==Procedure (Automatic Install)==&lt;br /&gt;
&amp;lt;cl&amp;gt;&lt;br /&gt;
1. Download the ADT Installer. (Right click, save link as)&lt;br /&gt;
 * [http://ftp.emacinc.com/EMAC_Linux/SDK/emac_adt_installer EMAC ADT Installer].&lt;br /&gt;
&lt;br /&gt;
* Change to the directory where the ADT Installer was downloaded from the command line:&lt;br /&gt;
{{cli | username=developer | hostname=ldc |cd ~/Downloads }}&lt;br /&gt;
&lt;br /&gt;
* Make the file executable:&lt;br /&gt;
{{cli | username=developer | hostname=ldc | chmod +x emac_adt_installer }}&lt;br /&gt;
&lt;br /&gt;
* Run ADT Installer script:&lt;br /&gt;
{{cli | username=developer | hostname=ldc |./emac_adt_installer }}&lt;br /&gt;
The installer will start.&lt;br /&gt;
&lt;br /&gt;
* Watch for errors:&lt;br /&gt;
{{clo}}#########################################################################&amp;lt;br /&amp;gt;# Met Errors when installing EMAC ADT! Please check log file for details.&amp;lt;br /&amp;gt;#########################################################################&amp;lt;br /&amp;gt;{{clos}}&lt;br /&gt;
&lt;br /&gt;
* Enter the development user's password if prompted. Allow the installer to install dependencies.&lt;br /&gt;
&lt;br /&gt;
* Select your board's architecture. Enter '1' for Arm or '2' for x86.&lt;br /&gt;
{{clo}}&lt;br /&gt;
Please enter the target architecture:&amp;lt;br /&amp;gt;&lt;br /&gt;
1. Arm&amp;lt;br /&amp;gt;&lt;br /&gt;
2. x86&amp;lt;br /&amp;gt;&lt;br /&gt;
board: &amp;lt;br /&amp;gt;&lt;br /&gt;
{{clos}}&lt;br /&gt;
&lt;br /&gt;
* The ADT Installer will then display what is to be installed. You may now choose to exit the installation, or continue if the displayed information is correct.&lt;br /&gt;
&lt;br /&gt;
* Once the installation of the sdk completes, the ADT Installer will ask whether or not to install Qt Creator.&lt;br /&gt;
&lt;br /&gt;
{{clo}}&lt;br /&gt;
&lt;br /&gt;
Would you like to install Qt Creator? [y/N]?&lt;br /&gt;
{{clos}}&lt;br /&gt;
 * Qt Creator is the IDE that EMAC provides with our SDK to allow users to easily cross compile projects and upload them to their boards.&lt;br /&gt;
 * If you chose to install Qt creator, the installer will then ask you whether or not you would like to place the icon on the desktop.&lt;br /&gt;
&lt;br /&gt;
* If the installation finishes, status text will appear:{{clo}}#############################################################&amp;lt;br /&amp;gt;# EMAC ADT has been successfully installed.&amp;lt;br /&amp;gt;#############################################################&amp;lt;br /&amp;gt; {{clos}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/cl&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Procedure (Manual Install)==&lt;br /&gt;
&amp;lt;cl&amp;gt;&lt;br /&gt;
1. Download the SDK. The latest version can be found on the EMAC FTP site. Download the SDK that matches the architecture of your target system. (Right click, save link as)&lt;br /&gt;
&lt;br /&gt;
 * SDK for x86: [http://ftp.emacinc.com/EMAC_Linux/SDK/emac-x86-toolchain.sh emac-x86-toolchain.sh]&lt;br /&gt;
 * SDK for ARM: [http://ftp.emacinc.com/EMAC_Linux/SDK/emac-arm-toolchain.sh emac-arm-toolchain.sh]&lt;br /&gt;
&lt;br /&gt;
* Change to the directory where the SDK was downloaded from the command line:&lt;br /&gt;
{{cli | username=developer | hostname=ldc |cd ~/Downloads }}&lt;br /&gt;
* Run SDK installer script:&lt;br /&gt;
{{cli | username=developer | hostname=ldc |./emac-ARCH-toolchain.sh }}&lt;br /&gt;
The installer will start. It is recommended to select the default target directory for the SDK: &amp;lt;code&amp;gt;/opt/emac/5.X&amp;lt;/code&amp;gt;&lt;br /&gt;
* Press enter to proceed.&lt;br /&gt;
* Enter your password if prompted.&lt;br /&gt;
* Status text will appear:&lt;br /&gt;
{{clo}}&lt;br /&gt;
Extracting SDK...done&amp;lt;br /&amp;gt;&lt;br /&gt;
Setting it up...done&amp;lt;br /&amp;gt;&lt;br /&gt;
SDK has been successfully set up and is ready to be used.&amp;lt;br /&amp;gt;&lt;br /&gt;
{{clos}}&lt;br /&gt;
&amp;lt;/cl&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Next Steps ==&lt;br /&gt;
&lt;br /&gt;
* [[Getting_Started_with_the_EMAC_OE_SDK | Getting Started with the EMAC OE SDK ]]&lt;br /&gt;
* [[Getting_Started_With_Qt_Creator |Getting Started With Qt Creator]]&lt;/div&gt;</summary>
		<author><name>Mgloff</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.emacinc.com/index.php?title=Getting_Started_with_the_EMAC_OE_SDK&amp;diff=15007</id>
		<title>Getting Started with the EMAC OE SDK</title>
		<link rel="alternate" type="text/html" href="https://wiki.emacinc.com/index.php?title=Getting_Started_with_the_EMAC_OE_SDK&amp;diff=15007"/>
		<updated>2021-07-23T15:28:31Z</updated>

		<summary type="html">&lt;p&gt;Mgloff: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{todo| Complete (03.31.2015-13:42-&amp;gt;BS+);(04.08.2015-15:00-&amp;gt;BS+);(04.09.15-14:00-&amp;gt;MD+);(04.21.2015-10:15-&amp;gt;BS+);(04.24.2015-20:00-&amp;gt;MD-);(04.28.2015-12:20-&amp;gt;MD+);(04.29.2015-16:00-&amp;gt;BS+);(04.29.2015-17:30-&amp;gt;MD+);(04.30.2015-15:30-&amp;gt;KY+); (07.22.2015-11:00-&amp;gt;BS+)(10.07.2015-16:32-&amp;gt;KY+)|Brian Serrano| project=OE 5.0,BS,MD,Complete,KY}}&lt;br /&gt;
{{#seo:&lt;br /&gt;
|title=Getting Started with the EMAC OE SDK&lt;br /&gt;
|titlemode=append&lt;br /&gt;
|keywords=EMAC SDK,Cross compiling, ARM Target Compiling, CMake Build System, CMake Cross Compiling, CMake, CMake Arm&lt;br /&gt;
|description=A basic tutorial for using the EMAC OE SDK.&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /****************************************  Page Description Text  ****************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span style=&amp;quot;background:#00FF00;color:#FF0000;font-size:300%&amp;quot;&amp;gt;&amp;lt;/span&amp;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 page demonstrates the process of compiling an example project and running it on the target machine. Also, it provides a straightforward guide to the essential steps you need to follow to get started with cross compiling a simple program with gcc and running the program on your embedded machine.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /*****************************************  Using/Working With  ******************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
{{:Templateimpl:using | initials=BS | title=Getting Started with the EMAC OE SDK | desc=Basic tutorial for using the EMAC OE SDK. | project=OE 5.0 }} &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Installing EMAC SDK ===&lt;br /&gt;
A Linux developer system is required to install the EMAC software development kit.&lt;br /&gt;
&lt;br /&gt;
For those without a Linux developer system we recommend downloading Oracle VM VirtualBox and installing EMAC's pre-configured Linux Ubuntu virtual machine. All steps involved can be found here: &amp;lt;br /&amp;gt;&lt;br /&gt;
[[Getting_Started_With_EMAC_Virtual_LDC | Set up virtual machine with EMAC_OE_SDK pre-installed ]] &amp;lt;br /&amp;gt;&lt;br /&gt;
'''OR''' &amp;lt;br /&amp;gt;&lt;br /&gt;
Those with a Linux developer system already configured can follow the below steps: &amp;lt;br /&amp;gt;&lt;br /&gt;
[[Installing_EMAC_OE_5.0_SDK | SDK Install]] &amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{note|The most current EMAC_OE_SDK release is version 5.1, all higher versions should be disregarded.}}&lt;br /&gt;
=== Connecting to a Target Board ===&lt;br /&gt;
&lt;br /&gt;
Primarily a board is connected to through it's debug serial port. If it also connected to a network and the IP address is known, ssh can be used to connect as well. More information on establishing a physical connection to a board is available on the [[Serial_Connections |Serial Connections]] and [[Network_Connections |Network Connections]] page.&lt;br /&gt;
&lt;br /&gt;
The next step after establishing a physical connection to the board is logging in.  For more information visit the [[System_Log_In | System Log In]] page.&lt;br /&gt;
&lt;br /&gt;
=== Setting the Filesystem to Read-Write ===&lt;br /&gt;
The root filesystem on a machine running EMAC OE Linux is mounted read-only by default. In order to put files on the board, you may need to make the filesystem read-write. The [[Linux_Filesystem_Organization|Linux Filesystem Organization page]] has more information regarding which parts of the filesystem are mounted read-only by default versus which parts are always writeable.  Note that EMAC recommends installing your program into a read-only portion of the filesystem (according to the guide) to safeguard it from filesystem corruption (such as may be caused by removing power from the board without shutting down the operating system first, which is normal in embedded systems).&lt;br /&gt;
&lt;br /&gt;
To remount the root filesytem in read-write mode, enter the following into the terminal: &lt;br /&gt;
{{cli | oemntrw | hostname=ipac9x25}}&lt;br /&gt;
&lt;br /&gt;
{{note|This will only change the root filesystem to read-write for the current boot.  When the system is rebooted, the root filesystem will once again be mounted read-only.}}&lt;br /&gt;
&lt;br /&gt;
=== Transferring Files ===&lt;br /&gt;
The command line syntax for transferring a file using the SSH protocol is &amp;lt;code&amp;gt;scp file user@host:/directory&amp;lt;/code&amp;gt;. SCP, or Secure Copy, is a way of securely transferring files between a local and remote host. For example, to send the file ''example.text'' to the &amp;lt;code&amp;gt;/usr/bin&amp;lt;/code&amp;gt; directory of a system with the IP address 10.0.6.221, enter the following command:&lt;br /&gt;
{{cli | username=developer | hostname=ldc | scp example.text root@10.0.6.221:/usr/bin/ }}&lt;br /&gt;
&lt;br /&gt;
Alternatively, you can leave off the path after the colon if you want the file to go directly into the root user's home directory.&lt;br /&gt;
&lt;br /&gt;
{{cli | username=developer | hostname=ldc | scp example.text root@10.0.6.221: }}&lt;br /&gt;
&lt;br /&gt;
=== Remote Execution ===&lt;br /&gt;
SSH can also be used to execute programs on remote systems without logging in. The syntax for SSH remote execution is &amp;lt;code&amp;gt;ssh user@host &amp;quot;my_command -args file&amp;quot;&amp;lt;/code&amp;gt;. The following is an example of a command to run a program on a board with the IP address ''10.0.6.221''.&lt;br /&gt;
&lt;br /&gt;
{{cli | username=developer | hostname=ldc | ssh root@10.0.6.221 &amp;quot;/path/to/executable -args&amp;quot; }}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Basic Compiling ===&lt;br /&gt;
The two subsections below show the two common options for how to compile source code. The first subsection demonstrates how to use the EMAC [[ #CMake_Compiling| CMake ]] tool, while the second subsection demonstrates how to compile c code [[ #Manual_Compiling | manually ]]. Another helpful link if you are looking to create a new project with CMake: [[ Creating_a_New_EMAC_OE_SDK_Project_with_CMake | Creating a New EMAC OE SDK Project with CMake ]]&lt;br /&gt;
&lt;br /&gt;
==== CMake Compiling ====&lt;br /&gt;
===== Host Machine Compiling =====&lt;br /&gt;
&lt;br /&gt;
This section demonstrates how to use the EMAC CMake tool to generate CMake files automatically for a project. When using the EMAC SDK there are currently two options for cross compiling:&lt;br /&gt;
* arm&lt;br /&gt;
* x86&lt;br /&gt;
For the purposes of this guide, the &amp;lt;tt&amp;gt;arm&amp;lt;/tt&amp;gt; option will be used for the listed examples.&lt;br /&gt;
&lt;br /&gt;
Navigate to the directory where the project will be located. Then run the CMake new project script.&lt;br /&gt;
{{clo}}&lt;br /&gt;
{{clio | username=developer | hostname=ldc | pwd=~ |cd projects }}&lt;br /&gt;
{{clio | username=developer | hostname=ldc | pwd=~/projects | 1 = export PATH=/opt/emac/5.1/bin:$PATH}}&lt;br /&gt;
{{clio | username=developer | hostname=ldc | pwd=~/projects |oe_init_project -n hello.c }}&lt;br /&gt;
If desired, please enter a name for this project, otherwise press Enter to use the default: hello_emac &amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
-- Creating new project directory... &amp;lt;br /&amp;gt;&lt;br /&gt;
-- Creating new source file... &amp;lt;br /&amp;gt;&lt;br /&gt;
-- Building custom CMakeLists.txt file... &amp;lt;br /&amp;gt;&lt;br /&gt;
-- Done. &amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Do you want to create a build directory for this project? (y/n) y &amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
-- Creating build directory... &amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Do you want to run cmake for this project? (y/n) y &amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
-- Using system compiler &amp;lt;br /&amp;gt;&lt;br /&gt;
-- The C compiler identification is GNU 4.8.2 &amp;lt;br /&amp;gt;&lt;br /&gt;
-- The CXX compiler identification is GNU 4.8.2 &amp;lt;br /&amp;gt;&lt;br /&gt;
-- Check for working C compiler: /usr/bin/cc &amp;lt;br /&amp;gt;&lt;br /&gt;
-- Check for working C compiler: /usr/bin/cc -- works &amp;lt;br /&amp;gt;&lt;br /&gt;
-- Detecting C compiler ABI info &amp;lt;br /&amp;gt;&lt;br /&gt;
-- Detecting C compiler ABI info - done &amp;lt;br /&amp;gt;&lt;br /&gt;
-- Check for working CXX compiler: /usr/bin/c++ &amp;lt;br /&amp;gt;&lt;br /&gt;
-- Check for working CXX compiler: /usr/bin/c++ -- works &amp;lt;br /&amp;gt;&lt;br /&gt;
-- Detecting CXX compiler ABI info &amp;lt;br /&amp;gt;&lt;br /&gt;
-- Detecting CXX compiler ABI info - done &amp;lt;br /&amp;gt;&lt;br /&gt;
-- Configuring done &amp;lt;br /&amp;gt;&lt;br /&gt;
-- Generating done &amp;lt;br /&amp;gt;&lt;br /&gt;
-- Build files have been written to: /home/developer/projects/hello_emac/hello_emac-build &amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Do you want to compile this project? (y/n) y&lt;br /&gt;
&lt;br /&gt;
Scanning dependencies of target hello_emac &amp;lt;br /&amp;gt;&lt;br /&gt;
[100%] Building C object CMakeFiles/hello_emac.dir/hello.c.o &amp;lt;br /&amp;gt;&lt;br /&gt;
Linking C executable hello_emac &amp;lt;br /&amp;gt;&lt;br /&gt;
[100%] Built target hello_emac &amp;lt;br /&amp;gt;&lt;br /&gt;
{{clos}}&lt;br /&gt;
&lt;br /&gt;
The executable, in this case,  is now inside the &amp;lt;code&amp;gt; hello_emac/hello_emac-build &amp;lt;/code&amp;gt; directory.&lt;br /&gt;
&lt;br /&gt;
===== Target Machine Compiling =====&lt;br /&gt;
&lt;br /&gt;
The CMake project script has now made a project directory that contains the following:&lt;br /&gt;
* CMakeLists.txt&lt;br /&gt;
* Source code file (''hello.c'' in this case)&lt;br /&gt;
* ''README'' file&lt;br /&gt;
* Desktop Build Directory (''hello_emac-build'' in this case)&lt;br /&gt;
&lt;br /&gt;
The ''CMakeLists.txt'' contains the required information to automatically create a ''Makefile'' for a given architecture.  This was created by the EMAC &amp;lt;tt&amp;gt;oe_init_project&amp;lt;/tt&amp;gt; script, and will need to be modified over time as a project grows.  The comments in the file generated by the EMAC tool will provide a good starting point for how to add additional source files and how to perform other common tasks related to maintaining your CMake build system as your project grows.  The CMake project provides extensive documentation on how to work with these files.&lt;br /&gt;
&lt;br /&gt;
The source code file generated by the script (''hello.c'') contains a basic Hello World style program.&lt;br /&gt;
&lt;br /&gt;
The ''README'' file contains more information on using ''CMake'' with the EMAC 5.X SDK.&lt;br /&gt;
&lt;br /&gt;
The Desktop Build Directory (''hello_emac-build'') contains the executable ''hello_emac'', the ''Makefile'', and various cache files.  These were automatically created by CMake and by the build system, and can be recreated at any time.&lt;br /&gt;
&lt;br /&gt;
It is useful to have a Desktop Build Directory because it is easier (in the beginning) to use the desktop to verify all code changes before cross-compiling for a target board. This will be useful until the application under development depends upon resources which are only available on the target hardware, such as certain devices drivers or the touchscreen (if so equipped).&lt;br /&gt;
&lt;br /&gt;
Use the following steps to cross-compile the project and send it to a target board.&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;lt;cl&amp;gt;&lt;br /&gt;
1. In a terminal, navigate to the base directory of the project.&lt;br /&gt;
{{note | If the target board being used is &amp;lt;tt&amp;gt;x86&amp;lt;/tt&amp;gt;, then change all occurrences of &amp;lt;tt&amp;gt;arm&amp;lt;/tt&amp;gt; in the following sections below to &amp;lt;tt&amp;gt;x86&amp;lt;/tt&amp;gt;.}}&lt;br /&gt;
* Create a build directory for cross compiling. &lt;br /&gt;
{{cli | username=developer | hostname=ldc | pwd=~/projects/hello_emac | mkdir hello_emac-build-arm }} &lt;br /&gt;
* Change directories into the newly created directory.&lt;br /&gt;
{{cli | username=developer | hostname=ldc | pwd=~/projects/hello_emac | cd hello_emac-build-arm }} &lt;br /&gt;
* Run cmake using the target architecture.&lt;br /&gt;
{{cli | username=developer | hostname=ldc | pwd=~/projects/hello_emac/hello_emac-build-arm | 1 = cmake .. -DARCH:STRING=arm }} &lt;br /&gt;
* Compile the code using make.&lt;br /&gt;
{{cli | username=developer | hostname=ldc | pwd=~/projects/hello_emac/hello_emac-build-arm | make }} &lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt; make &amp;lt;/code&amp;gt; command creates the target executable in the &amp;lt;code&amp;gt; hello_emac-build-arm &amp;lt;/code&amp;gt; directory.&lt;br /&gt;
* Now copy the executable to the target board. Use any of the options listed under the [[ #Transferring_Files | Transferring Files ]] section.&lt;br /&gt;
&lt;br /&gt;
The executable is now located on the target device at the designated transfer directory. It now can be run remotely (covered [[#Remote_Execution | here]]) OR from the target device by navigating to the transfer directory and issuing the run command (./executable_name).&lt;br /&gt;
&amp;lt;/cl&amp;gt;&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Manual Compiling ====&lt;br /&gt;
===== Host Machine Compiling =====&lt;br /&gt;
&amp;lt;br /&amp;gt;{{note|In these examples we are using the Ipac-9x25 board. Your board's processor's architecture will determine which file needs to be sourced. These files come from the EMAC SDK toolchain.}}&lt;br /&gt;
&lt;br /&gt;
Create a file called hello.c using a text editor such as vi, nano, or gedit. Then copy and paste the source code from the [[ #Hello_World_System_Log_Example | Hello World System Log Example ]] section in the text editor of your choice.&lt;br /&gt;
&lt;br /&gt;
Once you've created and saved the file with the source code, use the following syntax to compile the program called hello.c:&lt;br /&gt;
{{cli | username=developer | hostname=ldc | gcc -o hello hello.c }}&lt;br /&gt;
&lt;br /&gt;
If there is no error in your code then the compiler will successfully create an executable file called hello in the current directory.&lt;br /&gt;
&lt;br /&gt;
To verify this, enter the following command:&lt;br /&gt;
{{clo}}&lt;br /&gt;
{{clio | username=developer | hostname=ldc | ls -l hello* }}&lt;br /&gt;
-rwxrwxr-x 1 bserrano bserrano 9583 Apr  6 12:45 hello &amp;lt;br /&amp;gt;&lt;br /&gt;
-rwxr-xr-x 1 bserrano bserrano  129 Apr  6 12:28 hello.c &lt;br /&gt;
{{clos}}&lt;br /&gt;
&lt;br /&gt;
To run the program, enter the following command:&lt;br /&gt;
{{clo}}&lt;br /&gt;
{{clio | username=developer | hostname=ldc | ./hello }}&lt;br /&gt;
Hello EMAC OE!&lt;br /&gt;
{{clos}}&lt;br /&gt;
&lt;br /&gt;
OR&lt;br /&gt;
{{clo}}&lt;br /&gt;
{{clio | username=developer | hostname=ldc | /path/to/hello }}&lt;br /&gt;
Hello EMAC OE!&lt;br /&gt;
{{clos}}&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Target Board Compiling =====&lt;br /&gt;
&lt;br /&gt;
To compile for the target board, you must &amp;lt;code&amp;gt;source&amp;lt;/code&amp;gt; the &amp;lt;code&amp;gt;environment-setup-armv5e-emac-linux-gnueabi&amp;lt;/code&amp;gt; file in /opt/emac/5.X where 5.X is the SDK version.&lt;br /&gt;
{{cli | username=developer | hostname=ldc | source /opt/emac/5.X/environment-setup-armv5e-emac-linux-gnueabi }}&lt;br /&gt;
&lt;br /&gt;
Once you are in the directory with the source file, enter the following command:&lt;br /&gt;
{{cli | username=developer | hostname=ldc | $CC -o hello hello.c }}&lt;br /&gt;
&lt;br /&gt;
{{note|Once you source the file in your current terminal, you can only use it to cross-compile your program for the target board. You can no longer compile it for your host machine. To compile it to your host machine, simply open a new terminal.}}&lt;br /&gt;
&lt;br /&gt;
After sourcing the file, copy the program over to the target board using &amp;lt;code&amp;gt;scp&amp;lt;/code&amp;gt;. Enter the following command:&lt;br /&gt;
{{clo}}&lt;br /&gt;
{{clio | username=developer | hostname=ldc | scp hello root@10.0.6.221: }}&lt;br /&gt;
root@10.0.6.221's password: &lt;br /&gt;
&lt;br /&gt;
hello                                         100% 9583     9.4KB/s   00:00    &lt;br /&gt;
{{clos}}&lt;br /&gt;
&lt;br /&gt;
After copying the program, you can now execute the program on the target board. Enter the following command:&lt;br /&gt;
{{clo}}&lt;br /&gt;
{{clio | username=developer | hostname=ldc | ssh root@10.0.6.221 ./hello}}&lt;br /&gt;
root@10.0.6.221's password: &amp;lt;br /&amp;gt; &lt;br /&gt;
Hello EMAC OE!&lt;br /&gt;
{{clos}}&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Remote Debugging ===&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 (&amp;lt;tt&amp;gt;gdb&amp;lt;/tt&amp;gt;) on the development machine to remotely debug the target machine provided it has a flavor-matched version of a program named &amp;lt;tt&amp;gt;gdbserver&amp;lt;/tt&amp;gt;. All EMAC OE builds are packaged with a flavor-matched &amp;lt;tt&amp;gt;gdbserver&amp;lt;/tt&amp;gt; to simplify the setup process for developers.&lt;br /&gt;
&lt;br /&gt;
{{note | A flavor-matched &amp;lt;tt&amp;gt;gdbserver&amp;lt;/tt&amp;gt; is one which is built against the same source code revision as the &amp;lt;tt&amp;gt;gdb&amp;lt;/tt&amp;gt; client for your desktop, because &amp;lt;tt&amp;gt;gdb&amp;lt;/tt&amp;gt; does not have a stable interface for attaching to the &amp;lt;tt&amp;gt;gdbserver&amp;lt;/tt&amp;gt;.  In fact, the interface changes slightly with almost every release, so if you find yourself having difficulty getting &amp;lt;tt&amp;gt;gdb&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;gdbserver&amp;lt;/tt&amp;gt; to communicate with each other, make sure they're the exact same version before trying any other debugging steps.}}&lt;br /&gt;
&lt;br /&gt;
For more information visit the [[Remote_Debugging_EMAC_OE_SDK_Projects_with_gdbserver | Remote Debugging EMAC OE SDK Projects with gdbserver]] page.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /*****************************************       Examples        *****************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
{{:Templateimpl:examples | initials=BS | title=Getting Started with the EMAC OE SDK | desc=Basic tutorial for using the EMAC OE SDK. | project=OE 5.0 }}&lt;br /&gt;
&lt;br /&gt;
=== Hello World System Log Example ===&lt;br /&gt;
This example will print &amp;lt;code&amp;gt;Hello EMAC OE!&amp;lt;/code&amp;gt; to the syslog facility as well as the console. This will allow you to log, debug, and send status messages to the system logger.&lt;br /&gt;
&lt;br /&gt;
To compile and run this program, see the sections above.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&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;unistd.h&amp;gt;&lt;br /&gt;
#include &amp;lt;syslog.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
int main(int argc, char** argv)&lt;br /&gt;
{    &lt;br /&gt;
    char message[] = &amp;quot;Hello EMAC OE!&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
    openlog(&amp;quot;slog&amp;quot;, LOG_PID|LOG_CONS, LOG_USER);&lt;br /&gt;
    syslog(LOG_INFO, &amp;quot;%s&amp;quot;, message);&lt;br /&gt;
    closelog();    &lt;br /&gt;
&lt;br /&gt;
    printf(&amp;quot;%s\n&amp;quot;, message);&lt;br /&gt;
&lt;br /&gt;
    return 0;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is extremely useful because it allows you to save a record of the output that you might not see first hand.&lt;br /&gt;
&lt;br /&gt;
To verify the output of the program went into syslog, enter the following command:&lt;br /&gt;
{{clo}}&lt;br /&gt;
{{clio | username=developer | hostname=ldc | tail /var/log/syslog}}&lt;br /&gt;
Apr  7 14:10:06 ENG-26-LX dhclient: DHCPACK of 10.0.6.237 from 10.0.2.1&amp;lt;br /&amp;gt;&lt;br /&gt;
Apr  7 14:10:06 ENG-26-LX dhclient: bound to 10.0.6.237 -- renewal in 3306 seconds.&amp;lt;br /&amp;gt;&lt;br /&gt;
Apr  7 14:17:01 ENG-26-LX CRON[21193]: (root) CMD (   cd / &amp;amp;&amp;amp; run-parts --report /etc/cron.hourly)&amp;lt;br /&amp;gt;&lt;br /&gt;
Apr  7 14:54:41 ENG-26-LX hpcups[21266]: prnt/hpcups/HPCupsFilter.cpp 689: First raster data plane..&amp;lt;br /&amp;gt;&lt;br /&gt;
Apr  7 14:55:31  hpcups[21266]: last message repeated 3 times&amp;lt;br /&amp;gt;&lt;br /&gt;
Apr  7 15:05:12 ENG-26-LX dhclient: DHCPREQUEST of 10.0.6.237 on eth0 to 10.0.2.1 port 67&amp;lt;br /&amp;gt;&lt;br /&gt;
Apr  7 15:05:12 ENG-26-LX dhclient: DHCPACK of 10.0.6.237 from 10.0.2.1&amp;lt;br /&amp;gt;&lt;br /&gt;
Apr  7 15:05:12 ENG-26-LX dhclient: bound to 10.0.6.237 -- renewal in 3559 seconds.&amp;lt;br /&amp;gt;&lt;br /&gt;
Apr  7 15:17:01 ENG-26-LX CRON[21302]: (root) CMD (   cd / &amp;amp;&amp;amp; run-parts --report /etc/cron.hourly)&amp;lt;br /&amp;gt;&lt;br /&gt;
Apr  7 15:27:08 ENG-26-LX slog[21375]: Hello EMAC OE!&lt;br /&gt;
{{clos}}&lt;br /&gt;
&lt;br /&gt;
As you can see on the bottom line, your program output has been recorded and date stamped in syslog.&lt;br /&gt;
&lt;br /&gt;
For more information on system logging visit the [[System_Logging| System Logging ]] page.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /******************************************   More Information   *****************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
{{:Templateimpl:moreinfo | initials=BS | title=Getting Started with the EMAC OE SDK | desc=Basic tutorial for using the EMAC OE SDK. | project=OE 5.0 }}&lt;br /&gt;
* [[Getting_Started_With_Qt_Creator |Getting Started With Qt Creator]]&lt;br /&gt;
&lt;br /&gt;
{{:Templateimpl:whatnext | initials=BS | title=Getting Started with the EMAC OE SDK | desc=Basic tutorial for using the EMAC OE SDK. | project=OE 5.0 }}&lt;br /&gt;
* [[ Creating_a_New_EMAC_OE_SDK_Project_with_CMake | Creating a New EMAC OE SDK Project with CMake ]]&lt;br /&gt;
* [[EMAC_Example_Projects | EMAC Example Projects]]&lt;br /&gt;
* [[Serial_Connections | Serial Connections ]]&lt;br /&gt;
* [[Network_Connections | Network_Connections ]]&lt;br /&gt;
* [[Remote_Debugging_EMAC_OE_SDK_Projects_with_gdbserver | Remote Debugging EMAC OE SDK Projects with gdbserver ]]&lt;br /&gt;
* [[Linux_Filesystem_Organization | Linux Filesystem Organization]]&lt;br /&gt;
* [[System_Log_In | System Log In]]&lt;br /&gt;
* [[System_Logging | System Logging ]]&lt;/div&gt;</summary>
		<author><name>Mgloff</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.emacinc.com/index.php?title=Loading_Images_with_U-Boot&amp;diff=14914</id>
		<title>Loading Images with U-Boot</title>
		<link rel="alternate" type="text/html" href="https://wiki.emacinc.com/index.php?title=Loading_Images_with_U-Boot&amp;diff=14914"/>
		<updated>2021-04-15T18:32:15Z</updated>

		<summary type="html">&lt;p&gt;Mgloff: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{#seo:&lt;br /&gt;
|title=Loading Images with U-Boot&lt;br /&gt;
|titlemode=append&lt;br /&gt;
|keywords=U-Boot,OS Image,TFTP Server&lt;br /&gt;
|description=This page describes the process of using U-Boot to load Linux kernel and filesystem images from a TFTP server and save them to the local flash for use during the boot process. &lt;br /&gt;
}}&lt;br /&gt;
While U-Boot is used to load and execute the OS after initial programming, it can also be used to program the OS images to the local flash. This page describes the process of using U-Boot to load Linux kernel and filesystem images from a TFTP server and save them to the local flash for use during the boot process. Review the [[U-Boot Overview]] page for an introduction to U-Boot before continuing.&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
A TFTP server must be accessible on the local network. The specific details of TFTP server setup and configuration can be found on the [[Installing TFTP server]] page. Alternatively, NFS can be used in place of TFTP but will require an NFS server.  Information on how to set up an NFS server [[Setting_up_an_NFS_File_Server | can be found here]].  Please contact EMAC if you need details on how to use NFS instead of TFTP to load images.&lt;br /&gt;
&lt;br /&gt;
== Configuration ==&lt;br /&gt;
In order to load a file using TFTP, U-Boot must be configured to access the local network. Static networking configuration or DHCP can be used on some systems (requires DHCP server). Typically, the IP address of the board and the IP address of the TFTP server are the only settings that need to be defined. The network mask and broadcast address will be determined automatically from these settings, and no default gateway setting is required if the server is on the same subnetwork as the board. Before continuing, determine a valid static network address for your local network; contact your IT department for more information on what address to use if required. The example below shows the use of DHCP and setting the TFTP server IP address to 192.168.2.1&lt;br /&gt;
{{clop}}&amp;lt;nowiki&amp;gt;U-Boot&amp;gt; dhcp&lt;br /&gt;
BOOTP broadcast 1&lt;br /&gt;
BOOTP broadcast 2&lt;br /&gt;
BOOTP broadcast 3&lt;br /&gt;
BOOTP broadcast 4&lt;br /&gt;
DHCP client bound to address 192.168.2.2 (3007 ms)&lt;br /&gt;
U-Boot&amp;gt; setenv serverip 192.168.2.1&amp;lt;/nowiki&amp;gt;{{closp}}&lt;br /&gt;
&lt;br /&gt;
The example below shows how to set a static IP address of the board to 192.168.2.2 and the TFTP server IP address to 192.168.2.1:&lt;br /&gt;
{{clop}}&amp;lt;nowiki&amp;gt;U-Boot&amp;gt; setenv ipaddr 192.168.2.2&lt;br /&gt;
U-Boot&amp;gt; setenv serverip 192.168.2.1&amp;lt;/nowiki&amp;gt;{{closp}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Once the network settings have been configured, attempt to ping the TFTP server to test the network connection as illustrated below:&lt;br /&gt;
{{clop}}&amp;lt;nowiki&amp;gt;U-Boot&amp;gt; ping 192.168.2.1&lt;br /&gt;
macb0: link up, 100Mbps full-duplex (lpa: 0x45e1)&lt;br /&gt;
Using macb0 device&lt;br /&gt;
host 192.168.2.1 is alive&amp;lt;/nowiki&amp;gt;{{closp}}&lt;br /&gt;
&lt;br /&gt;
== Loading Images to RAM ==&lt;br /&gt;
Files are loaded directly into RAM through TFTP. In order to load the image, you must know the physical address of the RAM device on the system. Refer to the documentation for your target board if you are unsure what value to use. The U-Boot environment variable &amp;lt;code&amp;gt;loadaddr&amp;lt;/code&amp;gt; should already be set and can be used in place of the hex addresses below. The standard addresses for some common EMAC systems are shown in Table 1 below.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot;|Table 1: Physical RAM Addresses&lt;br /&gt;
|-&lt;br /&gt;
! Product !! RAM Start Address&lt;br /&gt;
|-&lt;br /&gt;
| SoM-9260M || 0x20000000&lt;br /&gt;
|-&lt;br /&gt;
| SoM-9G20M || 0x20000000&lt;br /&gt;
|-&lt;br /&gt;
| SoM-9G45M || 0x70000000&lt;br /&gt;
|-&lt;br /&gt;
| SoM-3517M || 0x82000000&lt;br /&gt;
|-&lt;br /&gt;
| SoM-9x25M || 0x22000000&lt;br /&gt;
|-&lt;br /&gt;
| Ipac-9x25M || 0x22000000&lt;br /&gt;
|-&lt;br /&gt;
| SoM-9G25M || 0x22000000&lt;br /&gt;
|-&lt;br /&gt;
| SoM-A5D35M || 0x22000000&lt;br /&gt;
|-&lt;br /&gt;
| SoM-A5D36M || 0x22000000&lt;br /&gt;
|-&lt;br /&gt;
| SoM-3354M || 0x82000000&lt;br /&gt;
|-&lt;br /&gt;
| SoM-iMX6M || 0x12000000&lt;br /&gt;
|-&lt;br /&gt;
| SoM-iMX6UL || 0x82000000&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{{ warning | Before transferring a file to the system, make sure that it does not exceed the size of the available RAM. }}&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;tftp&amp;lt;/code&amp;gt; U-Boot command is used to transfer files to the system. The command requires two arguments: the address to load the file into and the filename of the image on the TFTP server. The example below demonstrates loading a kernel image named &amp;lt;code&amp;gt;uImage-2.6.30&amp;lt;/code&amp;gt; to RAM on an SoM-9G45M.&lt;br /&gt;
{{clop}}&amp;lt;nowiki&amp;gt;U-Boot&amp;gt; tftp ${loadaddr} uImage-2.6.30&lt;br /&gt;
macb0: link up, 100Mbps full-duplex (lpa: 0x45e1)&lt;br /&gt;
Using macb0 device&lt;br /&gt;
TFTP from server 192.168.2.1; our IP address is 192.168.2.2&lt;br /&gt;
Filename 'uImage-2.6.30'.&lt;br /&gt;
Load address: 0x70000000&lt;br /&gt;
Loading: #################################################################&lt;br /&gt;
         #################################################################&lt;br /&gt;
         #################################################################&lt;br /&gt;
         #################################################################&lt;br /&gt;
         ############################&lt;br /&gt;
done&lt;br /&gt;
Bytes transferred = 1472456 (1677c8 hex)&lt;br /&gt;
U-Boot&amp;gt; printenv filesize&lt;br /&gt;
filesize=1677C8&amp;lt;/nowiki&amp;gt;{{closp}}&lt;br /&gt;
&lt;br /&gt;
{{ note | Note that the &amp;lt;code&amp;gt;filesize&amp;lt;/code&amp;gt; variable has been automatically updated to the size of the file that was loaded.}}&lt;br /&gt;
&lt;br /&gt;
== Executing kernel from RAM ==&lt;br /&gt;
In some situations, it is advantageous to execute the image directly from RAM after loading with TFTP rather than saving to flash. This is especially helpful when testing new Linux kernel images. Furthermore, the boot command can be set such that the image is automatically downloaded and executed on each boot, making testing more efficient.&lt;br /&gt;
&lt;br /&gt;
After loading a bootable image to RAM, you can execute it directly using the &amp;lt;code&amp;gt;bootm&amp;lt;/code&amp;gt; command for a uImage kernel or &amp;lt;code&amp;gt;bootz&amp;lt;/code&amp;gt; for a zImage kernel. For example, after loading the kernel image above, running &amp;lt;code&amp;gt;bootm 0x70000000&amp;lt;/code&amp;gt; would boot the board using the new image without making any changes to the images stored on the flash.&lt;br /&gt;
&lt;br /&gt;
To update the &amp;lt;code&amp;gt;bootcmd&amp;lt;/code&amp;gt; variable to download the image on each boot, simply replace the command used to load the image from flash with the TFTP download command. The following example illustrates this process on an SoM-9G45M module.&lt;br /&gt;
{{clop}}&amp;lt;nowiki&amp;gt;U-Boot&amp;gt; printenv bootcmd&lt;br /&gt;
bootcmd=cp.b 0xC0042000 0x70000000 0x210000; bootm 0x70000000&lt;br /&gt;
U-Boot&amp;gt; setenv bootcmd 'tftp 0x70000000 uImage-2.6.30; bootm 0x70000000'&lt;br /&gt;
U-Boot&amp;gt; saveenv&lt;br /&gt;
Saving Environment to dataflash...&amp;lt;/nowiki&amp;gt;{{closp}}&lt;br /&gt;
&lt;br /&gt;
== Copying to Flash ==&lt;br /&gt;
The process of copying an image from RAM to flash memory differs depending on what type of flash storage devices are available on the system. Many systems have more than one device, such as serial DataFlash and NAND flash. This section explains the process of storing an image to non-volatile storage.&lt;br /&gt;
&lt;br /&gt;
=== NOR Flash ===&lt;br /&gt;
A combination of the &amp;lt;code&amp;gt;erase&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;cp&amp;lt;/code&amp;gt; commands are used to program an image to a NOR flash device. NOR flash is directly memory-mapped to the system at a physical address. Also, each image (U-Boot, bootstrap, kernel, filesystem) must be stored at the correct offset for the system to operate correctly. Refer to the documentation for your hardware for more information on the correct address ranges to use. The &amp;lt;code&amp;gt;flinfo&amp;lt;/code&amp;gt; command can be used to display the addressing of available flash devices on the system.&lt;br /&gt;
&lt;br /&gt;
After loading the image to RAM, the flash device should be erased followed by copying the image to the appropriate offset in the flash. The example below illustrates the commands used to program a new kernel image to a SoM-9260M module. Note the use of the &amp;lt;code&amp;gt;protect off all&amp;lt;/code&amp;gt; command, which is required to unlock the flash on some systems.&lt;br /&gt;
{{clop}}&amp;lt;nowiki&amp;gt;U-Boot&amp;gt; protect off all&lt;br /&gt;
U-Boot&amp;gt; tftp 0x20000000 ${kernel_name}&lt;br /&gt;
U-Boot&amp;gt; erase 0x10100000 0x103fffff&lt;br /&gt;
U-Boot&amp;gt; cp.b 0x20000000 0x10100000 ${filesize}&amp;lt;/nowiki&amp;gt;{{closp}}&lt;br /&gt;
&lt;br /&gt;
{{ note | Note that NOR flash can take a significant amount of time to program if the image size is large.}}&lt;br /&gt;
&lt;br /&gt;
=== Serial DataFlash ===&lt;br /&gt;
Serial DataFlash is an SPI-based NOR flash device that is used on many systems that employ NAND flash as the primary storage device. On these systems, low-level boot code such as the bootstrap, U-Boot, and OS kernel are typically stored on the DataFlash device. As with NOR flash, the &amp;lt;code&amp;gt;flinfo&amp;lt;/code&amp;gt; command can be used to determine the memory addressing layout of the DataFlash device. The &amp;lt;code&amp;gt;erase&amp;lt;/code&amp;gt; command does not support the DataFlash devices and should not be used before programming an image. The &amp;lt;code&amp;gt;cp&amp;lt;/code&amp;gt; command is capable of copying an image from RAM to DataFlash.&lt;br /&gt;
&lt;br /&gt;
The example below illustrates the commands used to copy a kernel image to the DataFlash device on a SoM-9G45M module.&lt;br /&gt;
{{clop}}&amp;lt;nowiki&amp;gt;U-Boot&amp;gt; tftpboot 0x70000000 ${kernel_name}&lt;br /&gt;
U-Boot&amp;gt; cp.b 0x70000000 0xC0042000 ${filesize}&amp;lt;/nowiki&amp;gt;{{closp}}&lt;br /&gt;
&lt;br /&gt;
=== NAND Flash ===&lt;br /&gt;
Generally, NAND flash is used to store only the root filesystem and auxiliary storage partitions of the OS. Storing an image to NAND flash under U-Boot uses a different set of commands than NOR or DataFlash devices. See &amp;lt;code&amp;gt;help nand&amp;lt;/code&amp;gt; for more information on the available commands for examining and manipulating NAND flash devices. To gain information on what NAND devices are available on the system, use the command &amp;lt;code&amp;gt;nand info&amp;lt;/code&amp;gt;. In general, programming a NAND flash device is much faster than programming NOR or DataFlash devices.&lt;br /&gt;
&lt;br /&gt;
The example below illustrates the process of loading the root JFFS2 filesystem onto an SoM-9G45M device. Note that the device is erased prior to programming it.&lt;br /&gt;
{{clop}}&amp;lt;nowiki&amp;gt;U-Boot&amp;gt; nand erase&lt;br /&gt;
U-Boot&amp;gt; tftp 0x70000000 ${rootfs_name}&lt;br /&gt;
U-Boot&amp;gt; nand write.jffs2 0x70000000 0x0 ${filesize}&amp;lt;/nowiki&amp;gt;{{closp}}&lt;br /&gt;
&lt;br /&gt;
=== SPI NOR/eMMC Flash ===&lt;br /&gt;
Most of EMAC's newer SoM offerings utilize an eMMC flash for filesystem and auxiliary storage partitions of the OS and an SPI flash to store the bootloader and kernel. To reprogram the eMMC, see [[Loading_Images_onto_eMMC_Devices|Loading Images onto eMMC Devices]]. Be sure that the &amp;lt;code&amp;gt;loadaddr&amp;lt;/code&amp;gt; variable is set and matches the table above. The example below illustrates the commands used to program a new kernel image to a SoM-9x25M module. &lt;br /&gt;
{{clop}}&amp;lt;nowiki&amp;gt;U-Boot&amp;gt; pri loadaddr&lt;br /&gt;
U-Boot&amp;gt; tftp ${loadaddr} zImage&lt;br /&gt;
U-Boot&amp;gt; sf probe;sf erase 0x100000 +${filesize};sf write ${loadaddr} 0x100000 ${filesize}&lt;br /&gt;
U-Boot&amp;gt; setenv kernelsize ${filesize};saveenv&amp;lt;/nowiki&amp;gt;{{closp}}&lt;br /&gt;
&lt;br /&gt;
Note: the &amp;quot;pri loadaddr&amp;quot; step above is not required it is just entered to make sure the variable is set.&lt;br /&gt;
&lt;br /&gt;
== Scripting ==&lt;br /&gt;
U-Boot also includes a scripting feature that allows a script file with U-Boot commands to be loaded and executed. This can make the task of programming multiple systems much more efficient. The &amp;lt;code&amp;gt;mkimage&amp;lt;/code&amp;gt; utility is required on a Linux development system in order to create a valid U-Boot image from a script. This section gives a brief example of a U-Boot script for programming a Linux kernel and filesystem.&lt;br /&gt;
&lt;br /&gt;
Creating a text file with all of the desired commands is the first step in creating a U-Boot script. The example below is a script file used by EMAC to program SoM-9260M modules:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=php&amp;gt;&lt;br /&gt;
echo ===== Setting Environment =====&lt;br /&gt;
setenv bootdelay 1&lt;br /&gt;
setenv rev sl013-aon-30010&lt;br /&gt;
setenv bootargs 'console=ttyS3,115200 root=/dev/mtdblock3 rootfstype=jffs2'&lt;br /&gt;
setenv kernel_name ${rev}-uImage&lt;br /&gt;
setenv rootfs_name sl013-aon-emac-image-SOM9260M.jffs2&lt;br /&gt;
saveenv&lt;br /&gt;
echo ===== Loading Kernel =====&lt;br /&gt;
protect off all&lt;br /&gt;
tftpboot 0x20000000 ${kernel_name}&lt;br /&gt;
erase 0x10100000 0x103fffff&lt;br /&gt;
cp.b 0x20000000 0x10100000 ${filesize}&lt;br /&gt;
setenv kernelsize ${filesize}&lt;br /&gt;
echo ===== Loading Root Filesystem =====&lt;br /&gt;
tftpboot 0x20000000 ${rootfs_name}&lt;br /&gt;
erase 0x10400000 0x11ffffff&lt;br /&gt;
cp.b 0x20000000 0x10400000 ${filesize}&lt;br /&gt;
setenv bootcmd 'protect off all;cp.b 0x10100000 0x20000000 ${kernelsize};bootm 0x20000000'&lt;br /&gt;
saveenv&lt;br /&gt;
echo ===== DONE! =====&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Once the file has been created and saved, the &amp;lt;code&amp;gt;mkimage&amp;lt;/code&amp;gt; utility must be used to create a U-Boot script image. A shell script such as the one shown below may be used to aid in this process:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/sh&lt;br /&gt;
 &lt;br /&gt;
if [ ! -f &amp;quot;$1&amp;quot; ] || [ $# -lt 2 ]&lt;br /&gt;
then&lt;br /&gt;
        echo &amp;quot;Usage: $0 SCRIPTNAME OUTPUTNAME&amp;quot;&lt;br /&gt;
        exit 1&lt;br /&gt;
fi&lt;br /&gt;
 &lt;br /&gt;
mkimage -T script -C none -A arm -n 'SoM9260 Load Script' -d $1 $2&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that the script assumes that &amp;lt;code&amp;gt;mkimage&amp;lt;/code&amp;gt; is installed in the user's PATH. The script should be run with the name of the existing file as the first argument and the desired output filename as the second argument:&lt;br /&gt;
{{cli|username=developer|hostname=ldc|./script_mkimage.sh sl013-aon-30010-flash-script sl013-aon-30010-flash-script.img}}&lt;br /&gt;
&lt;br /&gt;
Once an image file has been created, it should be copied to the TFTP server root directory, in this example &amp;lt;code&amp;gt;/srv/tftp&amp;lt;/code&amp;gt; is used.&lt;br /&gt;
{{cli|username=developer|hostname=ldc|sudo cp sl013-aon-30010-flash-script.img /srv/tftp/}}&lt;br /&gt;
&lt;br /&gt;
The image file can now be transferred to the board and executed as illustrated below:&lt;br /&gt;
{{clop}}&amp;lt;nowiki&amp;gt;U-Boot&amp;gt; tftp 0x20000000 sl013-aon-30010-flash-script.img&lt;br /&gt;
U-Boot&amp;gt; source 0x20000000&amp;lt;/nowiki&amp;gt;{{closp}}&lt;br /&gt;
&lt;br /&gt;
{{ note | Note that the U-Boot command &amp;lt;code&amp;gt;source&amp;lt;/code&amp;gt; was not available on older versions of U-Boot. If the command is not recognized, use &amp;lt;code&amp;gt;autoscr&amp;lt;/code&amp;gt; instead.}}&lt;br /&gt;
&lt;br /&gt;
U-Boot will execute all commands in the script line-by-line until the script has finished, at which point the U-boot prompt will be returned to the user.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /******************************************     Conclusion      ******************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
{{:Templateimpl:conclusion | initials=MD | title=System Logging | desc=The page describes how to system log. | project=OE 5.0 }}&lt;br /&gt;
In this article, you have seen how to load an image into RAM using U-Boot.  You have seen how to execute an image from RAM.  You have also seen how to copy an image from RAM to flash; how to configure your system to boot from an image once it has been saved to flash is documented elsewhere (see Related Information, below).  You have also seen a brief description of how to create scripts for U-Boot.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
With the information provided by this document, you are set to begin loading alternate kernels and filesystems onto EMAC hardware.  These kernels and filesystems could be alternatives provided to you by EMAC, or they could be ones you create yourself.  This provides you with a great deal of flexibility for your development work.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /******************************************   More Information   *****************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
{{:Templateimpl:moreinfo | initials=MD | title=System Logging | desc=The page describes how to system log. | project=OE 5.0 }}&lt;br /&gt;
* [[Loading_Linux_Kernels_Onto_a_Board | Loading Linux Kernels Onto a Board]]&lt;br /&gt;
* [[Loading_JFFS2_Images_Onto_a_Board | Loading JFFS2 Images Onto a Board]]&lt;br /&gt;
* [[Archiving_JFFS2_Images | Archiving JFFS2 Images]]&lt;br /&gt;
&lt;br /&gt;
{{:Templateimpl:whatnext | initials=MD | title=System Logging | desc=The page describes how to system log. | project=OE 5.0 }}&lt;br /&gt;
* [[U-Boot_Overview | U-Boot Overview]]&lt;br /&gt;
* [[Creating_JFFS2_Images | Creating JFFS2 Images]]&lt;br /&gt;
* [[Mounting_JFFS2_Images_on_a_Linux_PC | Mounting JFFS2 Images on a Linux PC]]&lt;br /&gt;
* [[Repartitioning_NAND_Flash_with_JFFS2_for_Linux | Repartitioning NAND Flash with JFFS2 for Linux]]&lt;br /&gt;
* [[Loading_Images_onto_eMMC_Devices | Loading Images onto eMMC Devices]]&lt;br /&gt;
* [[Booting_with_an_NFS_Root_Filesystem | Booting with an NFS Root Filesystem]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--[[Category:Bootloaders]]--&amp;gt;&lt;/div&gt;</summary>
		<author><name>Mgloff</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.emacinc.com/index.php?title=Loading_Images_onto_eMMC_Devices&amp;diff=14907</id>
		<title>Loading Images onto eMMC Devices</title>
		<link rel="alternate" type="text/html" href="https://wiki.emacinc.com/index.php?title=Loading_Images_onto_eMMC_Devices&amp;diff=14907"/>
		<updated>2021-04-15T18:13:36Z</updated>

		<summary type="html">&lt;p&gt;Mgloff: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{todo|SEOKWREV (12.31.13-13:15-&amp;gt;MD-);(12.31.13-14:50-&amp;gt;MW+);(12.31.13-18:10-&amp;gt;MD+);(12.31.13-18:45-&amp;gt;MG+);(03.06.14-15:35-&amp;gt;BS-);(04.11.14-15:55-&amp;gt;BS+);(05.01.15-12:12-&amp;gt;MG+);(11.05.15-17:50-&amp;gt;MD+)|Michael Welling|project=oe 4,oe 5,mw,md,mg,bs,SEOKWREV}}&lt;br /&gt;
&lt;br /&gt;
{{#seo:&lt;br /&gt;
|title=Loading Images onto eMMC Devices&lt;br /&gt;
|titlemode=append&lt;br /&gt;
|keywords=eMMC,EXT3 Partition,FAT32 Partition,Root File System&lt;br /&gt;
|description=Some EMAC products use eMMC in place of NAND flash. eMMC is an embedded MMC compliant memory that takes the form of an integrated circuit instead of a media card. &lt;br /&gt;
}}&lt;br /&gt;
== Background ==&lt;br /&gt;
Some EMAC products use eMMC in place of NAND flash. eMMC is an embedded MMC compliant memory that takes the form of an integrated circuit instead of a media card. &lt;br /&gt;
&lt;br /&gt;
U-Boot does not support writing to file systems in eMMC. To overcome this issue, the embedded target needs to boot into an alternate media such as a network file system or USB flash drive. Once the board has booted into Linux, the eMMC can be partitioned and formatted, and the root file system can be extracted. The SoM-3517M requires a special FAT formatted partition that contains the bootloader and Linux kernel images. This article explains the general process of writing the eMMC from Linux as well as some specifics related to programming the SoM-3517M, SoM-9X25, SoM-A5D35/6, SoM-3354, SoM-iMX6M, SoM-iMX6UL and IPAC-9X25.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{note | The procedures below require that you have a TFTP and NFS server setup on a host computer or a USB thumb drive created using [[Booting_with_a_USB_Root_Filesystem | Booting with a USB Root Filesystem]]. }}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* Instructions on setting up a TFTP server: [[Installing TFTP server]]&lt;br /&gt;
* Installation of an NFS Server with Linux: [[Setting up an NFS File Server]]&lt;br /&gt;
* Instruction for booting into NFS with U-Boot: [[Booting with an NFS Root Filesystem]]&lt;br /&gt;
* Instruction for booting into a filesystem on a USB drive: [[Booting with a USB Root Filesystem]]&lt;br /&gt;
* More information about MMC: http://en.wikipedia.org/wiki/MultiMediaCard&lt;br /&gt;
&lt;br /&gt;
== Creating partitions and formatting eMMC ==&lt;br /&gt;
&lt;br /&gt;
Once the Linux command prompt is reached, Linux utilities can be used to create and format partitions on the eMMC. By partitioning the eMMC, the partitions can be accessed individually and formatted differently as required. The &amp;lt;code&amp;gt;fdisk&amp;lt;/code&amp;gt; utility can be used to create these partitions on the eMMC.&lt;br /&gt;
&lt;br /&gt;
For example here is the procedure for creating a 128 MB primary partition:&lt;br /&gt;
&lt;br /&gt;
{{clop}}&lt;br /&gt;
{{cliop | hostname=emac-oe |fdisk /dev/mmcblk0}}&amp;lt;nowiki&amp;gt;&lt;br /&gt;
The number of cylinders for this disk is set to 57024.&lt;br /&gt;
There is nothing wrong with that, but this is larger than 1024,&lt;br /&gt;
and could in certain setups cause problems with:&lt;br /&gt;
1) software that runs at boot time (e.g., old versions of LILO)&lt;br /&gt;
2) booting and partitioning software from other OSs&lt;br /&gt;
   (e.g., DOS FDISK, OS/2 FDISK)&lt;br /&gt;
Command (m for help): n&lt;br /&gt;
Command action&lt;br /&gt;
   e   extended&lt;br /&gt;
   p   primary partition (1-4)&lt;br /&gt;
p&lt;br /&gt;
Partition number (1-4): 1&lt;br /&gt;
First cylinder (1-57024, default 1): Using default value 1&lt;br /&gt;
Last cylinder or +size or +sizeM or +sizeK (1-57024, default 57024): +128M&lt;br /&gt;
 &lt;br /&gt;
Command (m for help): p&lt;br /&gt;
 &lt;br /&gt;
Disk /dev/mmcblk0: 1868 MB, 1868562432 bytes&lt;br /&gt;
4 heads, 16 sectors/track, 57024 cylinders&lt;br /&gt;
Units = cylinders of 64 * 512 = 32768 bytes&lt;br /&gt;
&lt;br /&gt;
        Device Boot      Start         End      Blocks  Id System&lt;br /&gt;
/dev/mmcblk0p1               1        3907      125016  83 Linux&lt;br /&gt;
&lt;br /&gt;
Command (m for help): w&lt;br /&gt;
The partition table has been altered!&lt;br /&gt;
&lt;br /&gt;
Calling ioctl() to re-read partition table&lt;br /&gt;
[  566.062896]  mmcblk0: p1&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
{{cliop | hostname=emac-oe|}}&lt;br /&gt;
{{closp}}&lt;br /&gt;
&lt;br /&gt;
For more information about &amp;lt;code&amp;gt;fdisk&amp;lt;/code&amp;gt;, see:&lt;br /&gt;
http://tldp.org/HOWTO/Partition/fdisk_partitioning.html&lt;br /&gt;
&lt;br /&gt;
After creating the partitions, they can formatted with the various &amp;lt;code&amp;gt;mkfs&amp;lt;/code&amp;gt; utilities. The formatting used is dependent on how the partition is to be accessed. For eMMC root filesystems EMAC currently uses EXT4 (http://en.wikipedia.org/wiki/Ext3). Other formatting options are available (EXT2, EXT3, etc) and can be used. It should be noted that the kernel must be configured to support the chosen filesystem and the bootargs need to specify the correct type. &lt;br /&gt;
&lt;br /&gt;
{{note | For additional information on configuring and compiling the Linux kernel see the following page: [[Building the Linux Kernel]] }}&lt;br /&gt;
&lt;br /&gt;
As described above, the &amp;lt;code&amp;gt;bootargs&amp;lt;/code&amp;gt; is used for signalling to the Linux kernel the location of the root filesystem partition, and its formatting. The &amp;lt;code&amp;gt;root&amp;lt;/code&amp;gt; parameter is used to specify the partition to use while the &amp;lt;code&amp;gt;rootfstype&amp;lt;/code&amp;gt; parameter is used to specify the formatting of the partition.&lt;br /&gt;
&lt;br /&gt;
{{note | For more information about the &amp;lt;code&amp;gt;bootargs&amp;lt;/code&amp;gt; variable see this page: [[U-Boot Overview]] }}&lt;br /&gt;
&lt;br /&gt;
Partitions accessed by processor boot ROM or U-Boot typically need to be formatted with FAT32 formatting. The SoM-3517M, for instance, requires a FAT32 formatted partition for the bootloader and kernel in order to boot properly from eMMC. For more specifics about the SoM-3517M, see the quick reference section below.&lt;br /&gt;
&lt;br /&gt;
===Formatting a partition with EXT4===&lt;br /&gt;
&lt;br /&gt;
{{clop}}&lt;br /&gt;
{{cliop | hostname=emac-oe |mkfs.ext4 /dev/mmcblk0p1}}&amp;lt;nowiki&amp;gt;&lt;br /&gt;
mke2fs 1.41.14 (22-Dec-2010)&lt;br /&gt;
Filesystem label=&lt;br /&gt;
OS type: Linux&lt;br /&gt;
Block size=1024 (log=0)&lt;br /&gt;
Fragment size=1024 (log=0)&lt;br /&gt;
Stride=0 blocks, Stripe width=0 blocks&lt;br /&gt;
31360 inodes, 125016 blocks&lt;br /&gt;
6250 blocks (5.00%) reserved for the super user&lt;br /&gt;
First data block=1&lt;br /&gt;
Maximum filesystem blocks=67371008&lt;br /&gt;
16 block groups&lt;br /&gt;
8192 blocks per group, 8192 fragments per group&lt;br /&gt;
1960 inodes per group&lt;br /&gt;
Superblock backups stored on blocks: &lt;br /&gt;
        8193, 24577, 40961, 57345, 73729&lt;br /&gt;
&lt;br /&gt;
Writing inode tables: done      &lt;br /&gt;
Creating journal (4096 blocks): done&lt;br /&gt;
Writing superblocks and filesystem accounting information: done&lt;br /&gt;
 &lt;br /&gt;
This filesystem will be automatically checked every 39 mounts or&lt;br /&gt;
180 days, whichever comes first.  Use tune2fs -c or -i to override.&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
{{cliop| hostname=emac-oe |}}&lt;br /&gt;
{{closp}}&lt;br /&gt;
&lt;br /&gt;
===Formatting a partition with FAT32===&lt;br /&gt;
&lt;br /&gt;
{{clop}}&lt;br /&gt;
{{cliop | hostname=emac-oe |mkdosfs -F 32 /dev/mmcblk0p1}}&lt;br /&gt;
mkdosfs 2.11 (12 Mar 2005)&lt;br /&gt;
{{cliop | hostname=emac-oe |}}&lt;br /&gt;
{{closp}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Extracting filesystems to eMMC ==&lt;br /&gt;
After formatting a partition correctly, the partition can be mounted and files can be loaded to the eMMC.&lt;br /&gt;
&lt;br /&gt;
For example, here is the procedure for writing a root filesystem to the first partition of an eMMC card:&lt;br /&gt;
&lt;br /&gt;
{{clo}}&lt;br /&gt;
{{clio | hostname=emac-oe |mkdir -p /mnt/card}}&lt;br /&gt;
{{clio | hostname=emac-oe |mount /dev/mmcblk0p1 /mnt/card}}&lt;br /&gt;
{{clio | hostname=emac-oe |cd /mnt/card}}&lt;br /&gt;
{{clio | hostname=emac-oe |tar xzvf /images/emac-image.rootfs.tar.gz}}&lt;br /&gt;
&amp;lt;nowiki&amp;gt;    ⋮&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
{{clos}}&lt;br /&gt;
&lt;br /&gt;
In the above example the &amp;lt;code&amp;gt;/mnt/card&amp;lt;/code&amp;gt; directory is called the mount point. The &amp;lt;code&amp;gt;mkdir -p&amp;lt;/code&amp;gt; command creates the directory if it does not already exist. The &amp;lt;code&amp;gt;mount&amp;lt;/code&amp;gt; command attaches the specified partition to the directory. Any files written to the mounted directory will go to the partition on the eMMC. After the mount is complete, files can be extracted as shown using the &amp;lt;code&amp;gt;tar&amp;lt;/code&amp;gt; command.&lt;br /&gt;
&lt;br /&gt;
It should be noted that the &amp;lt;code&amp;gt;/etc/fstab&amp;lt;/code&amp;gt; file can be used to specify mount points for partitions upon boot. See http://en.wikipedia.org/wiki/Fstab for additional information.&lt;br /&gt;
&lt;br /&gt;
== Quick Reference (by Target Type) ==&lt;br /&gt;
This section is used to provide specifics for programming eMMC on various targets.&lt;br /&gt;
&lt;br /&gt;
For the partitioning sections, the information in the parenthesis denotes a keyboard input sequence. The (n,p,1,default,+64M) creates a new primary partition. Each input is followed a carriage return and the default is selected by pressing carriage return with no entry. See the expanded example in the above '''Creating partitions and formatting eMMC''' section for an idea of how the interface looks when commands are executed correctly.&lt;br /&gt;
&lt;br /&gt;
=== SoM-3517M ===&lt;br /&gt;
==== Partitioning the eMMC ====&lt;br /&gt;
&lt;br /&gt;
{{cli | hostname=emac-oe |fdisk -H 255 -S 63 /dev/mmcblk0}}&lt;br /&gt;
&lt;br /&gt;
The partitioning steps are as follows:&lt;br /&gt;
# Create 1st partition (n,p,1,default,+64M)&lt;br /&gt;
# Create 2nd partition (n,p,2,default,default)&lt;br /&gt;
# Change 1st partition type to FAT32 (t,1,c)&lt;br /&gt;
# Make 1st partition ACTIVE (a,1)&lt;br /&gt;
# Write (w)&lt;br /&gt;
&lt;br /&gt;
==== Formatting the eMMC ====&lt;br /&gt;
&lt;br /&gt;
{{clo}}&lt;br /&gt;
{{clio | hostname=emac-oe |mkfs.ext3 /dev/mmcblk0p2}}&lt;br /&gt;
{{clio | hostname=emac-oe |mkdosfs -F 32 /dev/mmcblk0p1}}&lt;br /&gt;
{{clos}}&lt;br /&gt;
&lt;br /&gt;
The first command formats the second partition as ext3. The &amp;lt;code&amp;gt;mkfs.ext3&amp;lt;/code&amp;gt; command can take further configuration parameters. See the &amp;lt;code&amp;gt;mkfs.ext3&amp;lt;/code&amp;gt; man page for more information.&lt;br /&gt;
&lt;br /&gt;
The second command formats the first partition as FAT32 for use with the AM3517's boot ROM. This is a requirement to boot from the eMMC.&lt;br /&gt;
&lt;br /&gt;
==== Adding Kernel and Bootloader ====&lt;br /&gt;
&lt;br /&gt;
{{clo}}&lt;br /&gt;
{{clio | hostname=emac-oe |mkdir -p /mnt/card}}&lt;br /&gt;
{{clio | hostname=emac-oe |mount /dev/mmcblk0p1 /mnt/card}}&lt;br /&gt;
{{clio | hostname=emac-oe |cd /images}}&lt;br /&gt;
{{clio | hostname=emac-oe | pwd=images |cp MLO uImage u-boot.bin /mnt/card/}}&lt;br /&gt;
{{clio | hostname=emac-oe | pwd=images |sync}}&lt;br /&gt;
{{clio | hostname=emac-oe | pwd=images |umount /dev/mmcblk0p1}}&lt;br /&gt;
{{clos}}&lt;br /&gt;
&lt;br /&gt;
{{ note | The first partition '''must''' be formatted FAT32 and the MLO binary '''must''' be in the first sector for the eMMC boot sequence to work properly.  }}&lt;br /&gt;
&lt;br /&gt;
==== Extracting Root Filesystem ====&lt;br /&gt;
{{clo}}&lt;br /&gt;
{{clio | hostname=emac-oe | pwd=images |mount /dev/mmcblk0p2 /mnt/card}}&lt;br /&gt;
{{clio | hostname=emac-oe | pwd=images |cd /mnt/card}}&lt;br /&gt;
{{clio | hostname=emac-oe | pwd=/mnt/card |tar xzvf /emac-image.rootfs.tar.gz}}&lt;br /&gt;
{{clio | hostname=emac-oe | pwd=/mnt/card |cd ..}}&lt;br /&gt;
{{clio | hostname=emac-oe | pwd=/mnt |sync}}&lt;br /&gt;
{{clio | hostname=emac-oe | pwd=/mnt |umount /dev/mmcblk0p2}}&lt;br /&gt;
{{clos}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== SoM-9X25M / IPAC-9X25 / SoM-A5D35/6 / SoM-3354 / SoM-iMX6M / SoM-iMX6UL ===&lt;br /&gt;
&lt;br /&gt;
Unlike the SoM-3517, these SoMs store U-Boot and the Linux kernel in a separate serial flash instead of the eMMC. Typically, two partitions are created. The first partition contains the complete filesystem and is mounted read-only while the second partition contains the /home directory and is mounted read-write.&lt;br /&gt;
&lt;br /&gt;
=== Unmount partitions ===&lt;br /&gt;
&lt;br /&gt;
{{cli | hostname=emac-oe |umount /dev/mmcblk0p1}}&lt;br /&gt;
{{cli | hostname=emac-oe |umount /dev/mmcblk0p2}}&lt;br /&gt;
&lt;br /&gt;
==== Partitioning the eMMC ====&lt;br /&gt;
&lt;br /&gt;
{{cli | hostname=emac-oe |fdisk /dev/mmcblk0}}&lt;br /&gt;
&lt;br /&gt;
{{ note | For the SoM-9x25M revisions 7 and above, the eMMC block device is /dev/sdb }}&lt;br /&gt;
&lt;br /&gt;
The partitioning steps are as follows:&lt;br /&gt;
&lt;br /&gt;
# Create 1st partition (n,p,1,default,+1G)&lt;br /&gt;
# Create 2nd partition (n,p,2,default,default)&lt;br /&gt;
# Write (w)&lt;br /&gt;
&lt;br /&gt;
==== Formatting the eMMC ====&lt;br /&gt;
{{clo}}&lt;br /&gt;
{{clio | hostname=emac-oe |mkfs.ext4 /dev/mmcblk0p1}}&lt;br /&gt;
{{clio | hostname=emac-oe |mkfs.ext4 /dev/mmcblk0p2}}&lt;br /&gt;
{{clos}}&lt;br /&gt;
&lt;br /&gt;
==== Extracting Root Filesystem ====&lt;br /&gt;
{{clo}}&lt;br /&gt;
{{clio | hostname=emac-oe |mkdir -p /mnt/card}}&lt;br /&gt;
{{clio | hostname=emac-oe |mount /dev/mmcblk0p1 /mnt/card}}&lt;br /&gt;
{{clio | hostname=emac-oe |cd /mnt/card}}&lt;br /&gt;
{{clio | hostname=emac-oe | pwd=/mnt/card |tar xzvf /emac-image.rootfs.tar.gz}}&lt;br /&gt;
{{clio | hostname=emac-oe | pwd=/mnt/card |cd ..}}&lt;br /&gt;
{{clio | hostname=emac-oe | pwd=/mnt |sync}}&lt;br /&gt;
{{clio | hostname=emac-oe | pwd=/mnt |umount /dev/mmcblk0p1}}&lt;br /&gt;
{{clos}}&lt;/div&gt;</summary>
		<author><name>Mgloff</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.emacinc.com/index.php?title=ARM_SOM&amp;diff=14786</id>
		<title>ARM SOM</title>
		<link rel="alternate" type="text/html" href="https://wiki.emacinc.com/index.php?title=ARM_SOM&amp;diff=14786"/>
		<updated>2021-03-05T18:36:23Z</updated>

		<summary type="html">&lt;p&gt;Mgloff: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{todo| Review (02.15.2016-12:26-&amp;gt;AW+)|Andrew Wichmann| project=OE 5.0,AW,Review }}&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /****************************************  Page Description Text  ****************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
{{:Templateimpl:navpgtable | initials=AW | title=ARM System on Module (SoM) Products | desc=A collection of pages for all SoM products}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /*******************************************  ARM 144 Pin SoMs  *******************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
System on module (SoM) is an ideal alternative to custom engineering. With an SoM approach you get the best of aspects of both buying an Off-The-Shelf Single Board Computer (SBC) and of a Custom Engineered solution. With Off-The-Shelf standard components such as a generic carrier board and SOM module, it is possible to start development on your software applications before the custom carrier board is complete; thus offering a reduced time to market for your system. A System on Module (SoM) is comprised of a small processor module with CPU bus accessibility and standard I/O functionality. The SoM module does not have any connectorization and is designed to be plugged into a Carrier Board.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /************************************************  ARM 144 Pin SoMs  ***********************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
{{:Templateimpl:navtableentry | title=ARM-144 Pin SoMs }}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{:Templateimpl:Navti | [[SOM-9260 | SOM-9260 (Atmel ARM9 AT91SAM9260)]] }}&lt;br /&gt;
{{:Templateimpl:Navti | [[SOM-9G20 | SOM-9G20 (Atmel ARM9 AT91SAM9G20)]] }}&lt;br /&gt;
{{:Templateimpl:Navti | [[SOM-9G25 | SOM-9G25 (Atmel ARM9 AT91SAM9G25)]] }}&lt;br /&gt;
{{:Templateimpl:Navti | [[SOM-9X25 | SOM-9X25 (Atmel ARM9 AT91SAM9G25)]] }}&lt;br /&gt;
{{:Templateimpl:Navti | [[SOM-A5D35 | SOM-A5D35 (Atmel Cortex A5 ATSAMA5D35)]] }}&lt;br /&gt;
{{:Templateimpl:Navti | [[SOM-iMX6UL | SOM-iMX6UL (Freescale Cortex A9 iMX6UL)]] }}&lt;br /&gt;
&lt;br /&gt;
{{:Templateimpl:navtend}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /************************************************  ARM 200 Pin SoMs  ***********************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
{{:Templateimpl:navtableentry | title=ARM-200 Pin SoMs }}&lt;br /&gt;
&lt;br /&gt;
{{:Templateimpl:Navti | [[SOM-9G45 | SOM-9G45 (Atmel ARM9 AT91SAM9G45)]] }}&lt;br /&gt;
{{:Templateimpl:Navti | [[SOM-9M10 | SOM-9M10 (Atmel ARM9 AT91SAM9M10)]] }}&lt;br /&gt;
{{:Templateimpl:Navti | [[SOM-3517 | SOM-3517 (TI Cortex A8 AM3517)]] }}&lt;br /&gt;
{{:Templateimpl:Navti | [[SOM-3354 | SOM-3354 (TI Cortex A8 AM3354)]] }}&lt;br /&gt;
{{:Templateimpl:Navti | [[SOM-A5D36 | SOM-A5D36 (Atmel Cortex A5 ATSAMA5D36)]] }}&lt;br /&gt;
&lt;br /&gt;
{{:Templateimpl:navtend}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /************************************************  New Row  ***********************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
{{:Templateimpl:navtablenewrow}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /********************************************  ARM 314 Pin SoMs  ********************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
{{:Templateimpl:navtableentry | title=ARM 314 Pin SoMs }}&lt;br /&gt;
&lt;br /&gt;
{{:Templateimpl:Navti | [[SOM-IMX6 | SOM-IMX6 (Freescale Cortex A9 iMX6)]] }}&lt;br /&gt;
&lt;br /&gt;
{{:Templateimpl:navtend}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /********************************************  ARM SoM Carrier Boards  ********************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
{{:Templateimpl:navtableentry | title=ARM-Carrier Boards }}&lt;br /&gt;
&lt;br /&gt;
{{:Templateimpl:Navti | [[SOM-150 | SOM-150 (144-Pin Carrier, Text LCD)]] }}&lt;br /&gt;
{{:Templateimpl:Navti | [[SOM-200 | SOM-200 (200-Pin Carrier, 4.3&amp;quot; LCD)]] }}&lt;br /&gt;
{{:Templateimpl:Navti | [[SOM-210 | SOM-210 (200-Pin Carrier, 4.3&amp;quot; LCD)]] }}&lt;br /&gt;
{{:Templateimpl:Navti | [[SOM-212 | SOM-212 (200-Pin Carrier, 4.3&amp;quot; LCD)]] }}&lt;br /&gt;
{{:Templateimpl:Navti | [[SOM-250 | SOM-250 (200-Pin Carrier, 7 &amp;amp; 10&amp;quot; LCDs)]] }}&lt;br /&gt;
{{:Templateimpl:Navti | [[SOM-350 | SOM-350 (314-Pin Carrier, 7 &amp;amp; 10&amp;quot; LCDs)]] }}&lt;br /&gt;
&lt;br /&gt;
{{:Templateimpl:navtend}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--__TOC__--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /***************************************** Background Information ****************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- {{:Templateimpl:bg | initials=MD | title=Page Title | desc=Description for SEO | project=OE 5 }} --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /*****************************************  General Information  *****************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- {{:Templateimpl:geninfo | initials=MD | title=Page Title | desc=Description for SEO | project=OE 5 }} --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /*****************************************  Using/Working With  ******************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--{{:Templateimpl:using | initials=MD | title=Page Title | desc=Description for SEO | project=OE 5 }}--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /*****************************************       Examples        *****************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--{{:Templateimpl:examples | initials=MD | title=Page Title | desc=Description for SEO | project=OE 5 }}--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /******************************************     Conclusion      ******************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--{{:Templateimpl:conclusion | initials=MD | title=Page Title | desc=Description for SEO | project=OE 5 }}--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /******************************************   More Information   *****************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- {{:Templateimpl:moreinfo | initials=MD | title=Page Title | desc=Description for SEO | project=OE 5 }} --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- {{:Templateimpl:whatnext | initials=MD | title=Page Title | desc=Description for SEO | project=OE 5 }} --&amp;gt;&lt;/div&gt;</summary>
		<author><name>Mgloff</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.emacinc.com/index.php?title=Serial_Connections&amp;diff=14777</id>
		<title>Serial Connections</title>
		<link rel="alternate" type="text/html" href="https://wiki.emacinc.com/index.php?title=Serial_Connections&amp;diff=14777"/>
		<updated>2021-03-05T18:31:03Z</updated>

		<summary type="html">&lt;p&gt;Mgloff: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{todo|SEOKWREV (11.25.13-13:05-&amp;gt;KY+);(11.25.13-18:45-&amp;gt;MD+);(11.26.13-21:40-&amp;gt;MD+);(12.20.13-11:12-&amp;gt;MW+);(03.04.14-15:20-&amp;gt;BS-);(03.14.14-15:55-&amp;gt;BS+)(03.14.14-15:55-&amp;gt;BS+)(10.26.15-18:25-&amp;gt;MG+)|Klint Youngmeyer|project=oe 4,oe 5,ky,SEOKWREV,md,mw,bs}}&lt;br /&gt;
&lt;br /&gt;
{{#seo:&lt;br /&gt;
|title=Serial Connections&lt;br /&gt;
|titlemode=append&lt;br /&gt;
|keywords=Serial Connections,Serial Terminal,PuTTY,Serial Communication Parameters&lt;br /&gt;
|description=Serial Connections to EMAC boards.&lt;br /&gt;
}}&lt;br /&gt;
&amp;lt;!--'''THIS PAGE NEEDS: 1. To be split into two pages: &amp;quot;Serial Connections&amp;quot;  and  &amp;quot;Network Connections&amp;quot;.  This is because the table listing serial connection information is very important, but has been very difficult to find.  We need the page to have the most obvious name possible for this.  We also should try to find other pages which mention using a serial connection, and refer them to this page to find out the connection information they need for their board.'''--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
There are several ways to connect to a system running EMAC OE Linux. The preferred connection method depends on the capabilities of the hardware. For example, headless systems (those without a graphical interface) will most likely use a serial port console, while systems with a video connection may be accessed using a keyboard and LCD or monitor.  When an LCD or monitor is available, a serial connection can occasionally still be needed; usually, this need arises after a user has accidentally misconfigured the display.  Other times, it may be useful to be able to use a serial console on a board that's running remotely but has had its network connection drop out.  The serial console can be a very useful tool for diagnosing and debugging issues even after development has finished.&lt;br /&gt;
&lt;br /&gt;
== Serial Terminal ==&lt;br /&gt;
A serial terminal connection is most commonly the first connection that will be made to a system in its default configuration. A serial terminal application such as [[Getting_Started_With_Minicom | Minicom]] for Linux or [[PuTTY]] under Windows is required for this connection. The serial cable type, port, and communication parameters for each system type are listed in Table 1 below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&amp;lt;div align=center&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align: center;&amp;quot; |Table 1: Serial Communication Parameters&lt;br /&gt;
|-&lt;br /&gt;
! SoM !! Port !! Cable Type !! Baud Rate !! Data Bits !! Parity !! Stop Bits !! Flow Control&lt;br /&gt;
|-&lt;br /&gt;
| [[ ARM_SOM | 314 Pin SoM's ]] || COMA  || NULL Modem || 115200 || 8 || None || 1 || None&lt;br /&gt;
|-&lt;br /&gt;
| [[ ARM_SOM | 200 Pin SoM's ]] || COMB  || NULL Modem || 115200 || 8 || None || 1 || None&lt;br /&gt;
|-&lt;br /&gt;
| [[ ARM_SOM | 144 Pin SoM's ]] || COME  || NULL Modem || 115200 || 8 || None || 1 || None&lt;br /&gt;
|-&lt;br /&gt;
| [[ SOM-9260 ]] || COMA  || NULL Modem || 115200 || 8 || None || 1 || None&lt;br /&gt;
|-&lt;br /&gt;
| [[ SOM-9G20 ]] || COMA  || NULL Modem || 115200 || 8 || None || 1 || None&lt;br /&gt;
|-&lt;br /&gt;
| [[ iPac-9x25 ]] || COM1  || NULL Modem || 115200 || 8 || None || 1 || None&lt;br /&gt;
|-&lt;br /&gt;
| x86 Boards      || COM1*     ||  NULL Modem*          || 115200      || 8 || None || 1 || None&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{note | '''*''' : These settings vary among x86 systems. Refer to the system manual for the target board for more information. Not all x86 systems have a serial terminal connection enabled by default.}}&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Follow the steps below to establish a serial connection:&lt;br /&gt;
# Connect a NULL Modem serial cable between the serial port on the workstation and target board and start a terminal application.&lt;br /&gt;
# Setup the communication parameters for your board according to Table 1.&lt;br /&gt;
# Connect power to the target board; boot messages will begin to print within a few seconds.&lt;br /&gt;
# When the board has finished booting a login prompt will appear.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Next Steps ==&lt;br /&gt;
After you have established a connection with your device running EMAC OE Linux, you will need to [[System_Log_In | log into the system.]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- [[Category:Linux]]&lt;br /&gt;
[[Category:OpenEmbedded]]&lt;br /&gt;
--&amp;gt;&lt;/div&gt;</summary>
		<author><name>Mgloff</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.emacinc.com/index.php?title=Building_the_Linux_Kernel&amp;diff=14547</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=14547"/>
		<updated>2020-09-26T17:32:52Z</updated>

		<summary type="html">&lt;p&gt;Mgloff: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{#seo:&lt;br /&gt;
|title=Building the Linux Kernel &lt;br /&gt;
|titlemode=append&lt;br /&gt;
|keywords=Building Linux Kernel,Configuring Kernel,Loading Kernel Modules&lt;br /&gt;
|description=Process of configuring and compiling the Linux kernel using the EMAC kernel build script.&lt;br /&gt;
}}&lt;br /&gt;
This page covers the process of configuring and compiling the Linux kernel using the EMAC kernel build script. This process assumes that you have already acquired the following software: &lt;br /&gt;
&lt;br /&gt;
# EMAC Software Development Kit [[ Installing_EMAC_OE_4.0_SDK | OE 4 ]] or [[Installing_EMAC_OE_5.0_SDK | OE 5 ]]&lt;br /&gt;
# Linux kernel source for target hardware (provided via EMAC public [http://git.emacinc.com/Linux-Kernel GIT server] )&lt;br /&gt;
# [ftp://ftp.emacinc.com/EMAC_Linux/SDK/kernel-build-cross.tar.gz Kernel build script]&lt;br /&gt;
&lt;br /&gt;
The example below will assume that a kernel image for the SoM-9x25 module will be created, although 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 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 &amp;lt;code&amp;gt;environment.cfg.sh&amp;lt;/code&amp;gt; script for the correct &lt;br /&gt;
architecture and EMAC OE version.&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. It is recommended to start with the kernel configuration file used by EMAC to build the kernel for the target device. Starting with EMAC OE 5.0, the kernel configuration can be &lt;br /&gt;
obtained on a running board from /proc/config.gz. Please contact [http://www.emacinc.com/support EMAC support] &lt;br /&gt;
for earlier EMAC OE versions. &lt;br /&gt;
&amp;lt;br &amp;gt;&lt;br /&gt;
The following are steps to configure the kernel:&lt;br /&gt;
&amp;lt;cl&amp;gt;&lt;br /&gt;
1. Copy the default configuration file to the same directory as the kernel source tree and kernel-build-cross.sh and rename it defconfig. &lt;br /&gt;
&lt;br /&gt;
* The kernel-build-cross script accepts the SOURCE_TREE as the first argument and either config or build as the second argument. Optionally, a third argument, BUILD_SUFFIX may be supplied as a suffix to add to the build directory. BUILD_SUFFIX is commonly used to add a tag or machine name to a build.&lt;br /&gt;
&lt;br /&gt;
{{cli | username=developer | hostname=ldc |./kernel-build-cross.sh linux-emac config som9x25}}&lt;br /&gt;
&lt;br /&gt;
* The kernel menu-driven configuration utility will be displayed. Features can be selected/deselected to be built into the kernel. Some features can be built as a loadable module, denoted by &amp;lt; &amp;gt;, and not built directly into the kernel. &lt;br /&gt;
{{ warning | Disabling  or modularizing some kernel features may prevent the kernel from starting correctly or at all. }}&lt;br /&gt;
&lt;br /&gt;
Use the space bar to select an option or the 'm' key to configure the selected option as a module. Select &amp;lt;code&amp;gt;Exit&amp;lt;/code&amp;gt; to close the kernel configuration menu and save the configuration to the newly created build directory. When the same build-suffix is used for subsequent builds, this configuration will be used. &lt;br /&gt;
&amp;lt;/cl&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Building the Kernel==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;cl&amp;gt;&lt;br /&gt;
1. Run the kernel-build-cross script again with the build option, this time using the same build-suffix used in the configuration step. &lt;br /&gt;
&lt;br /&gt;
{{cli | username=developer | hostname=ldc |./kernel-build-cross.sh linux-emac build som9x25}}&lt;br /&gt;
&lt;br /&gt;
* The kernel will begin compiling now. This will take several minutes to complete depending on the kernel configuration and the speed of the development machine. Only move on to the next step if the build completes with no errors.&lt;br /&gt;
&lt;br /&gt;
* The new kernel image will be in the &amp;lt;code&amp;gt;build-4.9.224-som9x25/Install/boot&amp;lt;/code&amp;gt; directory. For the 3.10 and later device tree enabled ARM kernels, the image name will be a zImage. Also, the desired device tree blob (*.dtb) needs to be appended to the kernel. For earlier versions of the kernel, a uImage will be generated that can be loaded directly from U-Boot. X86 boards use a bzImage.&lt;br /&gt;
&lt;br /&gt;
{{clo}}&lt;br /&gt;
{{clio | username=developer | hostname=ldc |cd build-4.9.224-som9x25/Install/boot}}&lt;br /&gt;
{{clio | username=developer | hostname=ldc |cat zImage-4.9.224 som-9x25-150es.dtb &amp;gt; zImage-som9x25}}&lt;br /&gt;
{{clos}}&lt;br /&gt;
&lt;br /&gt;
This is the image that will get loaded onto the board and executed by the bootloader. To load the new kernel onto the target machine, see the [[Loading Linux Kernels Onto a Board]] page.&lt;br /&gt;
&lt;br /&gt;
The build script will also create an archive of all of the modules created during the build process and place it in the &amp;lt;code&amp;gt;build-4.9.225-som9x25/Install/&amp;lt;/code&amp;gt; directory. The archive will be called &amp;lt;code&amp;gt;modules.tar.gz&amp;lt;/code&amp;gt;.&lt;br /&gt;
&amp;lt;/cl&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Loading Kernel Modules==&lt;br /&gt;
&lt;br /&gt;
After re-compiling the kernel, it is recommended to load the corresponding kernel modules.&lt;br /&gt;
&lt;br /&gt;
To reload the modules:&lt;br /&gt;
&amp;lt;cl&amp;gt;&lt;br /&gt;
1. Make sure that the root flash is mounted read/write before copying the modules to the target.&lt;br /&gt;
&lt;br /&gt;
* Copy the archive to the root of the filesystem of the target machine&lt;br /&gt;
&lt;br /&gt;
{{cli | username=developer | hostname=ldc |scp build-4.9.224-som9x25/Install/modules.tar.gz root@1IP_ADDRESS:/ }}&lt;br /&gt;
&lt;br /&gt;
* Log onto the target machine&lt;br /&gt;
&lt;br /&gt;
{{cli | username=developer | hostname=ldc |ssh root@IP_ADDRESS}}&lt;br /&gt;
&lt;br /&gt;
* Extract the kernel modules archive and force the kernel to reload the modules.&lt;br /&gt;
&lt;br /&gt;
{{clo}}&lt;br /&gt;
{{clio |cd /}}&lt;br /&gt;
{{clio |tar xzvf modules.tar.gz}}&lt;br /&gt;
{{clio |depmod -a}}&lt;br /&gt;
{{clio |reboot}}&lt;br /&gt;
{{clos}}&lt;br /&gt;
&amp;lt;/cl&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{:Templateimpl:moreinfo | initials=MG | title=System Logging | desc=The page describes how to build the linux kernel. | project=OE 5.0 }}&lt;br /&gt;
* [[Loading_Linux_Kernels_Onto_a_Board | Loading Linux Kernels Onto a Board]]&lt;/div&gt;</summary>
		<author><name>Mgloff</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.emacinc.com/index.php?title=OE50:Packages&amp;diff=11943</id>
		<title>OE50:Packages</title>
		<link rel="alternate" type="text/html" href="https://wiki.emacinc.com/index.php?title=OE50:Packages&amp;diff=11943"/>
		<updated>2020-03-04T20:10:42Z</updated>

		<summary type="html">&lt;p&gt;Mgloff: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{todo|(1-12-15-12:30-&amp;gt;MG+)(1.12.15-18:05-&amp;gt;MD+)(11.10.15-16:05-&amp;gt;KY+)|Michael Gloff|project=oe 5,mg,Complete}}&lt;br /&gt;
&lt;br /&gt;
{{#seo:&lt;br /&gt;
|title=EMAC OE 5.X Release information&lt;br /&gt;
|titlemode=append&lt;br /&gt;
|keywords=OE 5.X Standard Packages,Release information&lt;br /&gt;
|description=Information about EMAC OE 5.X Release.&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{DISPLAYTITLE:EMAC OE 5.X Release Information}}&lt;br /&gt;
&lt;br /&gt;
The OE 5.''X'' releases represent the next generation of EMAC's embedded Linux distribution. The new crop of embedded machines on the market have become powerful enough to justify bringing some of the best parts of Linux distributions that are targeted towards servers and desktops into the embedded realm. OE 5.X is designed to make developing software for embedded Linux easier than ever before.&lt;br /&gt;
&lt;br /&gt;
===New Features===&lt;br /&gt;
&lt;br /&gt;
Quite a few new features are being introduced with OE 5.X to support the goal of streamlining the development process and improving the embedded Linux software development experience. These features can be broken down into the following categories.&lt;br /&gt;
&lt;br /&gt;
====Operating System====&lt;br /&gt;
&lt;br /&gt;
The underlying operating system, Linux, has seen a refresh to the much more modern 4.9 kernel on ARM and x86 systems.  This updated kernel provides improved support for the ARM architecture, new drivers for new hardware, and the Device Tree File System for ARM hardware.  Device Tree is a new way of specifying hardware parameters which pulls memory offset specifications (and similar) out of the kernel binary and puts them into a separate file which can be maintained independently of the kernel.&lt;br /&gt;
&lt;br /&gt;
====Filesystem====&lt;br /&gt;
&lt;br /&gt;
OE 5.X uses more modern filesystems to enable faster access to files, larger maximum filesystem sizes, and improved wear leveling on the underlying flash devices.  The following filesystems are now a part of OE 5.X:&lt;br /&gt;
&lt;br /&gt;
* '''ext4''' - for eMMC/mSATA/SD/CF devices&lt;br /&gt;
* '''JFFS2''' - for NAND flash devices&lt;br /&gt;
&lt;br /&gt;
The filesystem is now generated using the Yocto build system, which enables a more streamlined and simpler process for generating custom filesystems based on our available base images.  The Yocto Project is hosted by engineers at Intel, and is built upon the time tested OpenEmbedded project.&lt;br /&gt;
&lt;br /&gt;
====SDK====&lt;br /&gt;
&lt;br /&gt;
EMAC OE 5.X includes a new SDK with an updated GNU gcc compiler which brings enhanced optimization capabilities, advanced code generation, and improved support for C++11 features.  The gcc cross compilers come bundled with support for the CMake build system which greatly eases the work involved in creating a build system for today's complex software. EMAC OE 5.X provides tools for generating the base CMake files from the commandline or from the IDE, allowing you to get started quickly whether you choose to use the commandline or an IDE for your development work.&lt;br /&gt;
&lt;br /&gt;
====IDE====&lt;br /&gt;
&lt;br /&gt;
EMAC OE 5.X now includes the Qt Creator IDE as the standard development environment. This IDE provides a polished, sophisticated development environment which can be used for developing any type of application in C or C++. For Qt, it provides a sophisticated GUI editor and code generation wizards to enable RAD.  The integrated help system is of use whether the issue with the application under development is related to Qt, Linux, or just standard C/C++.&lt;br /&gt;
&lt;br /&gt;
====Tools====&lt;br /&gt;
&lt;br /&gt;
EMAC OE 5.X now includes tools to enable development to ease common tasks.&lt;br /&gt;
&lt;br /&gt;
Some of the development work in a typical project requires performing complex tasks which are done so infrequently that most developers need to look them up each time they're performed.  These tasks typically have eaten into a project's time by taking much longer than anticipated to perform.  EMAC OE 5.X includes tools to make these tasks quick, simple, and intuitive.  These tasks include:&lt;br /&gt;
&lt;br /&gt;
* Timezone Configuration.&lt;br /&gt;
* Splashscreen Configuration.&lt;br /&gt;
* Touchscreen Calibration.&lt;br /&gt;
* Configuring software to automatically start on boot.&lt;br /&gt;
* Configuring a system to log messages to a remote syslog server.&lt;br /&gt;
&lt;br /&gt;
==== Easy SDK Installation ====&lt;br /&gt;
&lt;br /&gt;
The EMAC OE 5.X SDK, IDE, tools and examples can be installed on most common Linux distributions, though only Ubuntu 16.04 is currently tested and therefore recommended.&lt;br /&gt;
&lt;br /&gt;
See [[ Installing_EMAC_OE_5.0_SDK | Installing EMAC OE 5.0 SDK  ]]&lt;br /&gt;
&lt;br /&gt;
===Release Testing===&lt;br /&gt;
&lt;br /&gt;
EMAC has completely revamped its release testing for the EMAC OE 5.X release series.  The new testing process provides a far more comprehensive and exhaustive method of testing our software and hardware together to ensure the highest quality experience possible.  Throughout the 5.X release series, we will continue to improve and refine this testing process to ensure that each release is even better than the previous.&lt;br /&gt;
&lt;br /&gt;
==Provided Software==&lt;br /&gt;
&lt;br /&gt;
EMAC OE 5.X provides a number of software packages which weren't provided with previous versions of EMAC OE.  These new packages provide additional capabilities and extend existing capabilities.  These packages were carefully chosen to ensure that the best available tools are provided across the full range of tasks which need to be performed on EMAC OE machines.&lt;br /&gt;
&lt;br /&gt;
The following list shows the new tools which have been added or updated, and what you will gain from each one.&lt;br /&gt;
&lt;br /&gt;
* '''ethtool''' - This tool will allow you to inspect the network interfaces at the hardware level, allowing you to see if the physical link is good and, if so, what speed it's running at.  No more guessing as to whether your networking issue is a hardware or software issue.  If this shows your hardware is working correctly, you know it's a software configuration issue.&lt;br /&gt;
* '''lighttpd''' - This is a much more sophisticated web server than the one provided by Busybox.  It was a very popular custom package for the 4.0 series, so it is now included by default in 5.X.&lt;br /&gt;
* '''vim''' - The real vim, not the Busybox version of vi.  This provides syntax highlighting, undo, redo, macros, last position memory, and all of the other powerful features of vim that are missing from Busybox vi.&lt;br /&gt;
* '''wget''' and '''ftpput''' - These provide a simple way to retrieve files from a webserver and to push them to a webserver.  This can make retrieving updated files much simpler.&lt;br /&gt;
* '''strace''' - Shows the system calls made by any executable which is run through it.  This is a very powerful tool for debugging.&lt;br /&gt;
* '''ntp''' and '''ntpdate''' - These tools provide a method to update the system clock to the time provided by the atomic clocks which share their time over the Internet. &amp;amp;nbsp;These full versions are more reliable and more sophisticated than the Busybox version.&lt;br /&gt;
* '''minicom''' - Much more sophisticated than microcom, this tool provides the same powerful terminal client you use on your desktop.&lt;br /&gt;
* '''htop''' - This tool provides a sophisticated view into what's running on your system.&lt;br /&gt;
* '''sudo''' - This tool allows for execution of a program with the elevated privileges of the superuser.&lt;br /&gt;
* '''rsync''' - This tool allows for easy remote file synchronization between two computers.&lt;br /&gt;
* '''file''' - This tool lets you inspect files to determine what type they are and various properties of them.&lt;br /&gt;
* '''evtest''' - This tool provides a way to diagnose issues with input events.&lt;br /&gt;
* '''bash''' - The real bash shell.  Much more powerful than the Busybox shell, and much better for scripting.&lt;br /&gt;
* '''procps''' - The full suite of process utilities, such as ps, kill, watch, uptime, free, pgrep, sysctl, and top, the full versions of these tools provide the useful functionality which was missing from the Busybox versions.&lt;br /&gt;
* '''inotify-tools''' - These tools provide filesystem notifications which enable scripts and programs to only perform events after a file or directory has been modified/created/deleted/etc.  No polling required.&lt;br /&gt;
* '''tftp client''' - Easily download files from a tftp server with the integrated tftp client.&lt;br /&gt;
* '''iptables''' - The standard tool for configuring firewalls on Linux.&lt;br /&gt;
* '''tcpdump''' - An invaluable tool for debugging firewalls and TCP/UDP/IP connections of any kind.&lt;br /&gt;
&lt;br /&gt;
This partial list shows just the highlights of the new software that's part of EMAC OE 5.X. &amp;amp;nbsp;All of the software previously provided in OE4 is available in 5.X as well.&lt;br /&gt;
&lt;br /&gt;
Other software provided by OE 5.X includes:&lt;br /&gt;
&lt;br /&gt;
* '''nano''' - Basic text editor.&lt;br /&gt;
* '''amidi/aplaymidi/arecordmidi''' - Simple MIDI music player/recorder/controller.&lt;br /&gt;
* '''candump/canecho/cansend/cansequence''' - Tools for working with a CAN bus (included only on systems which have CAN support).&lt;br /&gt;
* Tools for working with flash memory.&lt;br /&gt;
* '''opkg''' - Package management tools.&lt;br /&gt;
* '''mpg123''' - MPEG Audio Decoder/Player&lt;br /&gt;
* Memory testing tools.&lt;br /&gt;
* '''Busybox''' - The embedded &amp;quot;Swiss Army Knife&amp;quot;&lt;br /&gt;
* '''Openssh sshd''' - SSH server (and client).&lt;br /&gt;
* '''OpenSSL''' - standard ssl security libraries.&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
&lt;br /&gt;
* [[ EMAC_OE_50_Add-on_Packages | EMAC OE 5.X Add-on Packages ]]&lt;/div&gt;</summary>
		<author><name>Mgloff</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.emacinc.com/index.php?title=Loading_Linux_Kernels_Onto_a_Board&amp;diff=5868</id>
		<title>Loading Linux Kernels Onto a Board</title>
		<link rel="alternate" type="text/html" href="https://wiki.emacinc.com/index.php?title=Loading_Linux_Kernels_Onto_a_Board&amp;diff=5868"/>
		<updated>2019-11-04T22:24:54Z</updated>

		<summary type="html">&lt;p&gt;Mgloff: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{todo|SEOKWRev (11.06.13-08:47-&amp;gt;MW+); (11.06.13-18:05-&amp;gt;MD+); (12.12.13-11:10-&amp;gt;MW+); (12.16.13-01:20-&amp;gt;MD-); (12.16.13-10:42-&amp;gt;MW+);(12.17.13-13:15-&amp;gt;KY+);(03.06.14-15:30-&amp;gt;BS-);(04.11.14-15:45-&amp;gt;BS+);(11.06.15-16:45-&amp;gt;MG+)|Michael Welling|project=oe 4,oe 5,mw,md,reorganize,ky,bs,mg}}&lt;br /&gt;
&lt;br /&gt;
{{#seo:&lt;br /&gt;
|title=Loading Linux Kernels Onto a Board&lt;br /&gt;
|titlemode=append&lt;br /&gt;
|keywords=Linux Kernels,TFTP Server,Serial Connection,U-Boot&lt;br /&gt;
|description=For EMAC's ARM Linux builds, the kernel is loaded onto boards separately from file systems, while on others the kernel is loaded with the filesystem.&lt;br /&gt;
}}&lt;br /&gt;
=== Background Information ===&lt;br /&gt;
&lt;br /&gt;
The Linux kernel is at the core of EMAC's OE operating system. The kernel provides essential I/O interfaces, task management, and memory management to the user simplifying the development environment. Each embedded target has a Linux kernel image that is tailored to its specific hardware needs. For more information about the Linux kernel see the links in the [[About Linux]] page.&lt;br /&gt;
&lt;br /&gt;
For EMAC's ARM Linux builds, the kernel is loaded onto boards separately from file systems, while on others the kernel is loaded with the filesystem. It should be noted that, regardless of how the kernel is loaded, many of the kernel's drivers can be compiled as modules which have to be included in the file system in the &amp;lt;code&amp;gt;/lib/modules&amp;lt;/code&amp;gt; directory. [[Building the Linux Kernel]] explains how to compile the Linux kernel and how to load the kernel modules onto an existing file system.&lt;br /&gt;
&lt;br /&gt;
''See [[Installing LILO]] for more information on updating the kernel with X86 targets.''&lt;br /&gt;
&lt;br /&gt;
''See the [[Loading Images with U-Boot]] page for more information on updating the kernel on ARM targets.''&lt;br /&gt;
&lt;br /&gt;
=== General Information ===&lt;br /&gt;
&lt;br /&gt;
As with the loading the JFFS2 file system, the kernel is loaded using TFTP and a serial connection to the boot loader. Once the boot loader and TFTP server are accessible the kernel is loaded into SDRAM and relocated to the target's embedded flash.&lt;br /&gt;
&lt;br /&gt;
For instructions on installing a TFTP server on a development PC, see&lt;br /&gt;
[[Installing TFTP server]].&lt;br /&gt;
&lt;br /&gt;
For details on connecting to the serial port for an embedded target, see&lt;br /&gt;
[[Serial Connections]].&lt;br /&gt;
&lt;br /&gt;
The [[Loading Images with U-Boot]] page explains how to load a kernel onto a target. It is important to note the offset in SDRAM and Flash as setting them incorrectly could adversely affect the operation of the system. The current page details the utilization of U-Boot more specifically; for more information about Redboot see the [[Loading Images with RedBoot]] page.&lt;br /&gt;
&lt;br /&gt;
Here is an example of configuring the networking for TFTP transfer and loading the kernel into the resident SDRAM on a SoM-9G45:&lt;br /&gt;
 U-Boot&amp;gt; set autoload no&lt;br /&gt;
 U-Boot&amp;gt; dhcp&lt;br /&gt;
 U-Boot&amp;gt; set serverip 192.168.0.100&lt;br /&gt;
 U-Boot&amp;gt; tftp 0x74000000 uImage-2.6.30-9g45&lt;br /&gt;
&lt;br /&gt;
Once the kernel is loaded into SDRAM, the kernel image can be either booted directly or loaded into the board's flash memory for deployment. Booting directly into the kernel can be especially useful during development as it allows for testing and debugging without committing the kernel to flash. To boot the kernel directly, use the &amp;lt;code&amp;gt;bootm&amp;lt;/code&amp;gt; command as follows:&lt;br /&gt;
 U-Boot&amp;gt; bootm&lt;br /&gt;
&lt;br /&gt;
The procedure for writing to the flash differs from board to board because of the different flash types that are used. For instance, the SoM-9G45 and SoM-9G20 use serial Dataflash to store the kernel, whereas the SoM-9260 uses NOR flash.&lt;br /&gt;
&lt;br /&gt;
Here is an example for copying the the kernel image into the Dataflash on the SoM-9G45 using &amp;lt;code&amp;gt;cp.b&amp;lt;/code&amp;gt;:&lt;br /&gt;
 U-Boot&amp;gt; cp.b 0x74000000 0xC0042000 ${filesize}&lt;br /&gt;
&lt;br /&gt;
{{imbox | type=notice | text = The $filesize variable is automatically set based on the size of the file loaded with the previous tftp load command. }}&lt;br /&gt;
&lt;br /&gt;
Here is an example of writing the kernel to the NOR flash on the SoM-9260:&lt;br /&gt;
 U-Boot&amp;gt; protect off all&lt;br /&gt;
 U-Boot&amp;gt; erase 0x10100000 0x103fffff&lt;br /&gt;
 U-Boot&amp;gt; cp.b 0x20000000 0x10100000 ${filesize}&lt;br /&gt;
 U-Boot&amp;gt; set kernelsize $filesize&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;protect off all&amp;lt;/code&amp;gt; command unlocks NOR flash erasing and writing. NOR flash needs to be specifically erased before programming using the &amp;lt;code&amp;gt;erase&amp;lt;/code&amp;gt; command. Once the erase is complete the kernel image can be written to the flash. The &amp;lt;code&amp;gt;kernelsize&amp;lt;/code&amp;gt; variable is used in the boot script for the SoM-9260. To see the boot command sequence for a particular board, run the &amp;lt;code&amp;gt;printenv&amp;lt;/code&amp;gt; command on the system and note the &amp;lt;code&amp;gt;bootcmd&amp;lt;/code&amp;gt; variable.&lt;br /&gt;
{{imbox | type=notice | text = The 0x numbers represent the hexadecimal value of the offset from the top of specific memories. These values vary from system to system. See the quick reference below for examples on the various EMAC ARM based systems.}}&lt;br /&gt;
&lt;br /&gt;
=== Quick Reference (By Target Type) ===&lt;br /&gt;
This section provides a quick reference for programming various targets with a kernel images. &lt;br /&gt;
==== SoM-9260M ====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
U-Boot&amp;gt; tftp 0x20000000 uImage-som-9260m&lt;br /&gt;
U-Boot&amp;gt; protect off all&lt;br /&gt;
U-Boot&amp;gt; erase 0x10100000 0x103fffff&lt;br /&gt;
U-Boot&amp;gt; cp.b 0x20000000 0x10100000 ${filesize}&lt;br /&gt;
U-Boot&amp;gt; set kernelsize $filesize&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== SoM-9G20M ====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
U-Boot&amp;gt; tftp 0x20000000 uImage-som-9g20m&lt;br /&gt;
U-Boot&amp;gt; cp.b 0x20000000 0xD0042000 ${filesize}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== SoM-9G45M/9M10M ====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
U-Boot&amp;gt; tftp 0x74000000 uImage-som-9g45m&lt;br /&gt;
U-Boot&amp;gt; cp.b 0x74000000 0xC0042000 ${filesize}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== SoM-9x25 iPac-9x25 SoM-9G25 SoM-A5D3X ====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
U-Boot&amp;gt; tftp 0x22000000 zImage&lt;br /&gt;
U-Boot&amp;gt; sf probe;sf erase 0x100000 +${filesize};sf write 0x22000000 0x100000 ${filesize}&lt;br /&gt;
U-Boot&amp;gt; set kernelsize ${filesize};saveenv&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== SoM-3354 ====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
U-Boot&amp;gt; tftp 0x82000000 zImage&lt;br /&gt;
U-Boot&amp;gt; sf probe;sf erase 0x100000 +${filesize};sf write 0x82000000 0x100000 ${filesize}&lt;br /&gt;
U-Boot&amp;gt; set kernelsize ${filesize};saveenv&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Mgloff</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.emacinc.com/index.php?title=Loading_Images_onto_eMMC_Devices&amp;diff=5842</id>
		<title>Loading Images onto eMMC Devices</title>
		<link rel="alternate" type="text/html" href="https://wiki.emacinc.com/index.php?title=Loading_Images_onto_eMMC_Devices&amp;diff=5842"/>
		<updated>2019-09-17T14:29:54Z</updated>

		<summary type="html">&lt;p&gt;Mgloff: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{todo|SEOKWREV (12.31.13-13:15-&amp;gt;MD-);(12.31.13-14:50-&amp;gt;MW+);(12.31.13-18:10-&amp;gt;MD+);(12.31.13-18:45-&amp;gt;MG+);(03.06.14-15:35-&amp;gt;BS-);(04.11.14-15:55-&amp;gt;BS+);(05.01.15-12:12-&amp;gt;MG+);(11.05.15-17:50-&amp;gt;MD+)|Michael Welling|project=oe 4,oe 5,mw,md,mg,bs,SEOKWREV}}&lt;br /&gt;
&lt;br /&gt;
{{#seo:&lt;br /&gt;
|title=Loading Images onto eMMC Devices&lt;br /&gt;
|titlemode=append&lt;br /&gt;
|keywords=eMMC,EXT3 Partition,FAT32 Partition,Root File System&lt;br /&gt;
|description=Some EMAC products use eMMC in place of NAND flash. eMMC is an embedded MMC compliant memory that takes the form of an integrated circuit instead of a media card. &lt;br /&gt;
}}&lt;br /&gt;
== Background ==&lt;br /&gt;
Some EMAC products use eMMC in place of NAND flash. eMMC is an embedded MMC compliant memory that takes the form of an integrated circuit instead of a media card. &lt;br /&gt;
&lt;br /&gt;
U-Boot does not support writing to file systems in eMMC. To overcome this issue, the embedded target needs to boot into an alternate media such as a network file system or USB flash drive. Once the board has booted into Linux, the eMMC can be partitioned and formatted, and the root file system can be extracted. The SoM-3517M requires a special FAT formatted partition that contains the bootloader and Linux kernel images. This article explains the general process of writing the eMMC from Linux as well as some specifics related to programming the SoM-3517M, SoM-9X25, SoM-A5D35/6, SoM-3354, SoM-iMX6M, SoM-iMX6UL and IPAC-9X25.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{note | The procedures below require that you have a TFTP and NFS server setup on a host computer or a USB thumb drive created using [[Booting_with_a_USB_Root_Filesystem | Booting with a USB Root Filesystem]]. }}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* Instructions on setting up a TFTP server: [[Installing TFTP server]]&lt;br /&gt;
* Installation of an NFS Server with Linux: [[Setting up an NFS File Server]]&lt;br /&gt;
* Instruction for booting into NFS with U-Boot: [[Booting with an NFS Root Filesystem]]&lt;br /&gt;
* More information about MMC: http://en.wikipedia.org/wiki/MultiMediaCard&lt;br /&gt;
&lt;br /&gt;
== Creating partitions and formatting eMMC ==&lt;br /&gt;
&lt;br /&gt;
Once the Linux command prompt is reached, Linux utilities can be used to create and format partitions on the eMMC. By partitioning the eMMC, the partitions can be accessed individually and formatted differently as required. The &amp;lt;code&amp;gt;fdisk&amp;lt;/code&amp;gt; utility can be used to create these partitions on the eMMC.&lt;br /&gt;
&lt;br /&gt;
For example here is the procedure for creating a 128 MB primary partition:&lt;br /&gt;
&lt;br /&gt;
{{clop}}&lt;br /&gt;
{{cliop | hostname=emac-oe |fdisk /dev/mmcblk0}}&amp;lt;nowiki&amp;gt;&lt;br /&gt;
The number of cylinders for this disk is set to 57024.&lt;br /&gt;
There is nothing wrong with that, but this is larger than 1024,&lt;br /&gt;
and could in certain setups cause problems with:&lt;br /&gt;
1) software that runs at boot time (e.g., old versions of LILO)&lt;br /&gt;
2) booting and partitioning software from other OSs&lt;br /&gt;
   (e.g., DOS FDISK, OS/2 FDISK)&lt;br /&gt;
Command (m for help): n&lt;br /&gt;
Command action&lt;br /&gt;
   e   extended&lt;br /&gt;
   p   primary partition (1-4)&lt;br /&gt;
p&lt;br /&gt;
Partition number (1-4): 1&lt;br /&gt;
First cylinder (1-57024, default 1): Using default value 1&lt;br /&gt;
Last cylinder or +size or +sizeM or +sizeK (1-57024, default 57024): +128M&lt;br /&gt;
 &lt;br /&gt;
Command (m for help): p&lt;br /&gt;
 &lt;br /&gt;
Disk /dev/mmcblk0: 1868 MB, 1868562432 bytes&lt;br /&gt;
4 heads, 16 sectors/track, 57024 cylinders&lt;br /&gt;
Units = cylinders of 64 * 512 = 32768 bytes&lt;br /&gt;
&lt;br /&gt;
        Device Boot      Start         End      Blocks  Id System&lt;br /&gt;
/dev/mmcblk0p1               1        3907      125016  83 Linux&lt;br /&gt;
&lt;br /&gt;
Command (m for help): w&lt;br /&gt;
The partition table has been altered!&lt;br /&gt;
&lt;br /&gt;
Calling ioctl() to re-read partition table&lt;br /&gt;
[  566.062896]  mmcblk0: p1&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
{{cliop | hostname=emac-oe|}}&lt;br /&gt;
{{closp}}&lt;br /&gt;
&lt;br /&gt;
For more information about &amp;lt;code&amp;gt;fdisk&amp;lt;/code&amp;gt;, see:&lt;br /&gt;
http://tldp.org/HOWTO/Partition/fdisk_partitioning.html&lt;br /&gt;
&lt;br /&gt;
After creating the partitions, they can formatted with the various &amp;lt;code&amp;gt;mkfs&amp;lt;/code&amp;gt; utilities. The formatting used is dependent on how the partition is to be accessed. For eMMC root filesystems EMAC currently uses EXT4 (http://en.wikipedia.org/wiki/Ext3). Other formatting options are available (EXT2, EXT3, etc) and can be used. It should be noted that the kernel must be configured to support the chosen filesystem and the bootargs need to specify the correct type. &lt;br /&gt;
&lt;br /&gt;
{{note | For additional information on configuring and compiling the Linux kernel see the following page: [[Building the Linux Kernel]] }}&lt;br /&gt;
&lt;br /&gt;
As described above, the &amp;lt;code&amp;gt;bootargs&amp;lt;/code&amp;gt; is used for signalling to the Linux kernel the location of the root filesystem partition, and its formatting. The &amp;lt;code&amp;gt;root&amp;lt;/code&amp;gt; parameter is used to specify the partition to use while the &amp;lt;code&amp;gt;rootfstype&amp;lt;/code&amp;gt; parameter is used to specify the formatting of the partition.&lt;br /&gt;
&lt;br /&gt;
{{note | For more information about the &amp;lt;code&amp;gt;bootargs&amp;lt;/code&amp;gt; variable see this page: [[U-Boot Overview]] }}&lt;br /&gt;
&lt;br /&gt;
Partitions accessed by processor boot ROM or U-Boot typically need to be formatted with FAT32 formatting. The SoM-3517M, for instance, requires a FAT32 formatted partition for the bootloader and kernel in order to boot properly from eMMC. For more specifics about the SoM-3517M, see the quick reference section below.&lt;br /&gt;
&lt;br /&gt;
===Formatting a partition with EXT4===&lt;br /&gt;
&lt;br /&gt;
{{clop}}&lt;br /&gt;
{{cliop | hostname=emac-oe |mkfs.ext4 /dev/mmcblk0p1}}&amp;lt;nowiki&amp;gt;&lt;br /&gt;
mke2fs 1.41.14 (22-Dec-2010)&lt;br /&gt;
Filesystem label=&lt;br /&gt;
OS type: Linux&lt;br /&gt;
Block size=1024 (log=0)&lt;br /&gt;
Fragment size=1024 (log=0)&lt;br /&gt;
Stride=0 blocks, Stripe width=0 blocks&lt;br /&gt;
31360 inodes, 125016 blocks&lt;br /&gt;
6250 blocks (5.00%) reserved for the super user&lt;br /&gt;
First data block=1&lt;br /&gt;
Maximum filesystem blocks=67371008&lt;br /&gt;
16 block groups&lt;br /&gt;
8192 blocks per group, 8192 fragments per group&lt;br /&gt;
1960 inodes per group&lt;br /&gt;
Superblock backups stored on blocks: &lt;br /&gt;
        8193, 24577, 40961, 57345, 73729&lt;br /&gt;
&lt;br /&gt;
Writing inode tables: done      &lt;br /&gt;
Creating journal (4096 blocks): done&lt;br /&gt;
Writing superblocks and filesystem accounting information: done&lt;br /&gt;
 &lt;br /&gt;
This filesystem will be automatically checked every 39 mounts or&lt;br /&gt;
180 days, whichever comes first.  Use tune2fs -c or -i to override.&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
{{cliop| hostname=emac-oe |}}&lt;br /&gt;
{{closp}}&lt;br /&gt;
&lt;br /&gt;
===Formatting a partition with FAT32===&lt;br /&gt;
&lt;br /&gt;
{{clop}}&lt;br /&gt;
{{cliop | hostname=emac-oe |mkdosfs -F 32 /dev/mmcblk0p1}}&lt;br /&gt;
mkdosfs 2.11 (12 Mar 2005)&lt;br /&gt;
{{cliop | hostname=emac-oe |}}&lt;br /&gt;
{{closp}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Extracting filesystems to eMMC ==&lt;br /&gt;
After formatting a partition correctly, the partition can be mounted and files can be loaded to the eMMC.&lt;br /&gt;
&lt;br /&gt;
For example, here is the procedure for writing a root filesystem to the first partition of an eMMC card:&lt;br /&gt;
&lt;br /&gt;
{{clo}}&lt;br /&gt;
{{clio | hostname=emac-oe |mkdir -p /mnt/card}}&lt;br /&gt;
{{clio | hostname=emac-oe |mount /dev/mmcblk0p1 /mnt/card}}&lt;br /&gt;
{{clio | hostname=emac-oe |cd /mnt/card}}&lt;br /&gt;
{{clio | hostname=emac-oe |tar xzvf /images/emac-image.rootfs.tar.gz}}&lt;br /&gt;
&amp;lt;nowiki&amp;gt;    ⋮&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
{{clos}}&lt;br /&gt;
&lt;br /&gt;
In the above example the &amp;lt;code&amp;gt;/mnt/card&amp;lt;/code&amp;gt; directory is called the mount point. The &amp;lt;code&amp;gt;mkdir -p&amp;lt;/code&amp;gt; command creates the directory if it does not already exist. The &amp;lt;code&amp;gt;mount&amp;lt;/code&amp;gt; command attaches the specified partition to the directory. Any files written to the mounted directory will go to the partition on the eMMC. After the mount is complete, files can be extracted as shown using the &amp;lt;code&amp;gt;tar&amp;lt;/code&amp;gt; command.&lt;br /&gt;
&lt;br /&gt;
It should be noted that the &amp;lt;code&amp;gt;/etc/fstab&amp;lt;/code&amp;gt; file can be used to specify mount points for partitions upon boot. See http://en.wikipedia.org/wiki/Fstab for additional information.&lt;br /&gt;
&lt;br /&gt;
== Quick Reference (by Target Type) ==&lt;br /&gt;
This section is used to provide specifics for programming eMMC on various targets.&lt;br /&gt;
&lt;br /&gt;
For the partitioning sections, the information in the parenthesis denotes a keyboard input sequence. The (n,p,1,default,+64M) creates a new primary partition. Each input is followed a carriage return and the default is selected by pressing carriage return with no entry. See the expanded example in the above '''Creating partitions and formatting eMMC''' section for an idea of how the interface looks when commands are executed correctly.&lt;br /&gt;
&lt;br /&gt;
=== SoM-3517M ===&lt;br /&gt;
==== Partitioning the eMMC ====&lt;br /&gt;
&lt;br /&gt;
{{cli | hostname=emac-oe |fdisk -H 255 -S 63 /dev/mmcblk0}}&lt;br /&gt;
&lt;br /&gt;
The partitioning steps are as follows:&lt;br /&gt;
# Create 1st partition (n,p,1,default,+64M)&lt;br /&gt;
# Create 2nd partition (n,p,2,default,default)&lt;br /&gt;
# Change 1st partition type to FAT32 (t,1,c)&lt;br /&gt;
# Make 1st partition ACTIVE (a,1)&lt;br /&gt;
# Write (w)&lt;br /&gt;
&lt;br /&gt;
==== Formatting the eMMC ====&lt;br /&gt;
&lt;br /&gt;
{{clo}}&lt;br /&gt;
{{clio | hostname=emac-oe |mkfs.ext3 /dev/mmcblk0p2}}&lt;br /&gt;
{{clio | hostname=emac-oe |mkdosfs -F 32 /dev/mmcblk0p1}}&lt;br /&gt;
{{clos}}&lt;br /&gt;
&lt;br /&gt;
The first command formats the second partition as ext3. The &amp;lt;code&amp;gt;mkfs.ext3&amp;lt;/code&amp;gt; command can take further configuration parameters. See the &amp;lt;code&amp;gt;mkfs.ext3&amp;lt;/code&amp;gt; man page for more information.&lt;br /&gt;
&lt;br /&gt;
The second command formats the first partition as FAT32 for use with the AM3517's boot ROM. This is a requirement to boot from the eMMC.&lt;br /&gt;
&lt;br /&gt;
==== Adding Kernel and Bootloader ====&lt;br /&gt;
&lt;br /&gt;
{{clo}}&lt;br /&gt;
{{clio | hostname=emac-oe |mkdir -p /mnt/card}}&lt;br /&gt;
{{clio | hostname=emac-oe |mount /dev/mmcblk0p1 /mnt/card}}&lt;br /&gt;
{{clio | hostname=emac-oe |cd /images}}&lt;br /&gt;
{{clio | hostname=emac-oe | pwd=images |cp MLO uImage u-boot.bin /mnt/card/}}&lt;br /&gt;
{{clio | hostname=emac-oe | pwd=images |sync}}&lt;br /&gt;
{{clio | hostname=emac-oe | pwd=images |umount /dev/mmcblk0p1}}&lt;br /&gt;
{{clos}}&lt;br /&gt;
&lt;br /&gt;
{{ note | The first partition '''must''' be formatted FAT32 and the MLO binary '''must''' be in the first sector for the eMMC boot sequence to work properly.  }}&lt;br /&gt;
&lt;br /&gt;
==== Extracting Root Filesystem ====&lt;br /&gt;
{{clo}}&lt;br /&gt;
{{clio | hostname=emac-oe | pwd=images |mount /dev/mmcblk0p2 /mnt/card}}&lt;br /&gt;
{{clio | hostname=emac-oe | pwd=images |cd /mnt/card}}&lt;br /&gt;
{{clio | hostname=emac-oe | pwd=/mnt/card |tar xzvf /emac-image.rootfs.tar.gz}}&lt;br /&gt;
{{clio | hostname=emac-oe | pwd=/mnt/card |cd ..}}&lt;br /&gt;
{{clio | hostname=emac-oe | pwd=/mnt |sync}}&lt;br /&gt;
{{clio | hostname=emac-oe | pwd=/mnt |umount /dev/mmcblk0p2}}&lt;br /&gt;
{{clos}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== SoM-9X25M / IPAC-9X25 / SoM-A5D35/6 / SoM-3354 / SoM-iMX6M / SoM-iMX6UL ===&lt;br /&gt;
&lt;br /&gt;
Unlike the SoM-3517, these SoMs store U-Boot and the Linux kernel in a separate serial flash instead of the eMMC. Typically, two partitions are created. The first partition contains the complete filesystem and is mounted read-only while the second partition contains the /home directory and is mounted read-write.&lt;br /&gt;
&lt;br /&gt;
=== Unmount partitions ===&lt;br /&gt;
&lt;br /&gt;
{{cli | hostname=emac-oe |umount /dev/mmcblk0p1}}&lt;br /&gt;
{{cli | hostname=emac-oe |umount /dev/mmcblk0p2}}&lt;br /&gt;
&lt;br /&gt;
==== Partitioning the eMMC ====&lt;br /&gt;
&lt;br /&gt;
{{cli | hostname=emac-oe |fdisk /dev/mmcblk0}}&lt;br /&gt;
&lt;br /&gt;
{{ note | For the SoM-9x25M revisions 7 and above, the eMMC block device is /dev/sdb }}&lt;br /&gt;
&lt;br /&gt;
The partitioning steps are as follows:&lt;br /&gt;
&lt;br /&gt;
# Create 1st partition (n,p,1,default,+1G)&lt;br /&gt;
# Create 2nd partition (n,p,2,default,default)&lt;br /&gt;
# Write (w)&lt;br /&gt;
&lt;br /&gt;
==== Formatting the eMMC ====&lt;br /&gt;
{{clo}}&lt;br /&gt;
{{clio | hostname=emac-oe |mkfs.ext4 /dev/mmcblk0p1}}&lt;br /&gt;
{{clio | hostname=emac-oe |mkfs.ext4 /dev/mmcblk0p2}}&lt;br /&gt;
{{clos}}&lt;br /&gt;
&lt;br /&gt;
==== Extracting Root Filesystem ====&lt;br /&gt;
{{clo}}&lt;br /&gt;
{{clio | hostname=emac-oe |mkdir -p /mnt/card}}&lt;br /&gt;
{{clio | hostname=emac-oe |mount /dev/mmcblk0p1 /mnt/card}}&lt;br /&gt;
{{clio | hostname=emac-oe |cd /mnt/card}}&lt;br /&gt;
{{clio | hostname=emac-oe | pwd=/mnt/card |tar xzvf /emac-image.rootfs.tar.gz}}&lt;br /&gt;
{{clio | hostname=emac-oe | pwd=/mnt/card |cd ..}}&lt;br /&gt;
{{clio | hostname=emac-oe | pwd=/mnt |sync}}&lt;br /&gt;
{{clio | hostname=emac-oe | pwd=/mnt |umount /dev/mmcblk0p1}}&lt;br /&gt;
{{clos}}&lt;/div&gt;</summary>
		<author><name>Mgloff</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.emacinc.com/index.php?title=SOM-IMX6&amp;diff=5841</id>
		<title>SOM-IMX6</title>
		<link rel="alternate" type="text/html" href="https://wiki.emacinc.com/index.php?title=SOM-IMX6&amp;diff=5841"/>
		<updated>2019-09-09T19:19:31Z</updated>

		<summary type="html">&lt;p&gt;Mgloff: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{todo| Review (02.15.2016-12:55-&amp;gt;AW+)|Andrew Wichmann| project=OE 5.0,AW,Review }}&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /****************************************  Page Description Text  ****************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
{{:Templateimpl:navpgtable | initials=AW | title=SOM-iMX6 | desc=A collection of pages for the SOM-iMX6 | project=OE 5.0 }} &amp;lt;!-- is this OE 5.0? --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /*******************************************  SOM-iMX6 ARM 314-Pin SoM  *******************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
The SoM-iMX6 is a System on Module (SoM) based on the Freescale iMX.6 Cortex A9 Single, Dual or Quad Core processor. Designed and manufactured in the USA, this wide temperature, fanless ARM 1GHz SoM has 10/100/1000 BaseT Ethernet included along with 4 serial ports.  It utilizes up to 4GB of eMMC Flash, up to 16MB of serial data flash, and up to 1GB of LP DDR2 RAM. A SoM is a small embedded module that contains the core of a microprocessor system.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /*******************************************  SOM-iMX6 ARM 314-Pin Web Link  *******************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
{{:Templateimpl:navtableentry | title=SoM-iMX6 Web Link }}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{:Templateimpl:Navti | [http://www.emacinc.com/products/system_on_module/SoM-iMX6M SoM-iMX6 Web Link] }}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{:Templateimpl:navtend}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /************************************************  SoM-iMX6 Downloads  ***********************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{:Templateimpl:navtableentry | title=SOM-iMX6 Downloads }}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{:Templateimpl:Navti | [ftp://ftp.emacinc.com/SoM/SoM-IMX6M/Manual/SoM-iMX6M_User_Manual.pdf User Manual] }}&lt;br /&gt;
{{:Templateimpl:Navti | [ftp://ftp.emacinc.com/SoM/SoM-IMX6M/DataSheets/SoM-iMX6M_Datasheet.pdf Datasheet] }}&lt;br /&gt;
&lt;br /&gt;
{{:Templateimpl:navtend}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /************************************************  New Row  ***********************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
{{:Templateimpl:navtablenewrow}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /********************************************  SoM-iMX6 Carrier Boards  ********************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
{{:Templateimpl:navtableentry | title=SoM-iMX6 Carrier Boards }}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*'''SoM-350ES'''&lt;br /&gt;
:{{:Templateimpl:Navti | [http://emacinc.com/products/system_on_module/SoM-350ES SoM-350ES Web Link] }}&lt;br /&gt;
:{{:Templateimpl:Navti | [ftp://ftp.emacinc.com/SoM/SoM-350ES/ SoM-350ES Downloads] }}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{:Templateimpl:navtend}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /********************************************  SoM-iMX6 Wiki Links  ********************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{:Templateimpl:navtableentry | title=SoM-iMX6 Wiki Links }}&lt;br /&gt;
&lt;br /&gt;
{{:Templateimpl:Navti | [[SoM-iMX6_Getting_Started | SoM-iMX6 Getting Started]] }}&lt;br /&gt;
&lt;br /&gt;
{{:Templateimpl:navtend}}&lt;/div&gt;</summary>
		<author><name>Mgloff</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.emacinc.com/index.php?title=Example_io_demo&amp;diff=5640</id>
		<title>Example io demo</title>
		<link rel="alternate" type="text/html" href="https://wiki.emacinc.com/index.php?title=Example_io_demo&amp;diff=5640"/>
		<updated>2019-06-14T18:46:04Z</updated>

		<summary type="html">&lt;p&gt;Mgloff: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{todo|SEOKWREV (01.03.14-16:47-&amp;gt;JG+);(01.03.14-17:35-&amp;gt;MD+);(04.07.14-09:45-&amp;gt;BS+);(04.09.14-16:15-&amp;gt;BS+)|Jgreene|project=oe 4,oe 5,jg,md,SEOKWREV,ky,bs}}&lt;br /&gt;
&lt;br /&gt;
{{#seo:&lt;br /&gt;
|title=io demo&lt;br /&gt;
|titlemode=append&lt;br /&gt;
|keywords=ADC example,Ring Counter,Binary Counter&lt;br /&gt;
|description=This is a guide to the &amp;lt;code&amp;gt;io_demo&amp;lt;/code&amp;gt; C example project included in the EMAC OE SDK.&lt;br /&gt;
}}&lt;br /&gt;
This is a guide to the &amp;lt;code&amp;gt;[http://git.emacinc.com/OE/qt-creator-example-projects/tree/master/io_demo io_demo]&amp;lt;/code&amp;gt; C example project included in the EMAC OE SDK.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;io_demo&amp;lt;/code&amp;gt; project provides four examples using SOM-150ES carrier board I/O:&amp;lt;br /&amp;gt;&lt;br /&gt;
* An analog-to-digital converter demo.&lt;br /&gt;
* A counter demo.    &lt;br /&gt;
* An input-to-output demo.&lt;br /&gt;
* A ring demo.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;io_demo&amp;lt;/code&amp;gt; project builds one executable: &amp;lt;code&amp;gt;io_demo&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Opening, Building and Uploading the Project Files ==&lt;br /&gt;
&lt;br /&gt;
For information on opening the project from within Eclipse, please see [[Importing the EMAC OE SDK Projects with Eclipse]].  Then, follow [[Using the EMAC OE SDK Projects with Eclipse]] for information on how to build, upload and execute the example.&lt;br /&gt;
&lt;br /&gt;
Alternatively, the &amp;lt;code&amp;gt;Makefile&amp;lt;/code&amp;gt; can be used with the &amp;lt;code&amp;gt;make&amp;lt;/code&amp;gt; command from the commandline to build and upload the example.  For more information on this method, please see [[Using EMAC OE SDK Example Projects]].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Usage and Behavior ==&lt;br /&gt;
&lt;br /&gt;
===Hardware Requirements===&lt;br /&gt;
&lt;br /&gt;
To use the '''io demo''' program you will need the following hardware.&lt;br /&gt;
&lt;br /&gt;
* An EMAC [http://www.emacinc.com/som/som150es.htm SOM-150ES] carrier board. &amp;lt;br /&amp;gt;&lt;br /&gt;
* A compatible EMAC SoM for that carrier board ([http://www.emacinc.com/products/system_on_module/SoM-9260M SOM-9260M], [http://www.emacinc.com/products/system_on_module/som-9G20m SOM-9G20M] and [http://www.emacinc.com/products/system_on_module/som-9x25 SOM-9X25] are all compatible).&amp;lt;br /&amp;gt;&lt;br /&gt;
* A multimeter or oscilloscope. See [[Example_io_demo#Input_to_Output_Demo_Usage | Input to Output Demo]] and  [[Example_io_demo#Count_Demo_Usage | Count Demo]] for details.&amp;lt;br /&amp;gt;&lt;br /&gt;
* A cable long enough to reach from GPIO Port B to GPIO Port C. See [[Example_io_demo#Input_to_Output_Demo_Usage | Input to Output Demo]] for details.&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Carrier Board====&lt;br /&gt;
&lt;br /&gt;
[[File:know_your_som_150.jpg|frame|left|SOM-150ES carrier board with GPIO, LEDs and analog IO indicated.]]&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is a detail of the '''HDR1 PLD &amp;amp; BUFFERED GPIO''' header. Pin 49 is Vcc. The bottom pins: 2, 4, 6...46, 48, 50; are all ground. Port A is pins 1, 3, 5, 7, 9, 11, 13, 15. Port B is pins 17, 19, 21, 23, 25, 27, 29, 31. Port C is pins 33, 35, 37, 39, 41, 43, 45, 47. &lt;br /&gt;
&lt;br /&gt;
[[File:gpio_header_detail.png]]&lt;br /&gt;
&lt;br /&gt;
===io_demo Usage===&lt;br /&gt;
&lt;br /&gt;
Run '''io demo''' from the console. It takes no parameters.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
 ./io_demo&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This brings up a menu of demos.&amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
****************************&lt;br /&gt;
     Demo Menu              &lt;br /&gt;
                            &lt;br /&gt;
A/D Demo             - a    &lt;br /&gt;
Count Demo           - c    &lt;br /&gt;
Input to Output Demo - i    &lt;br /&gt;
Ring Demo            - r    &lt;br /&gt;
                            &lt;br /&gt;
Exit                 - x    &lt;br /&gt;
                            &lt;br /&gt;
Enter Selection: &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, press '''a''', '''c''', '''i''' or '''r''' to run a demo; otherwise, press '''x''' to exit.&lt;br /&gt;
&lt;br /&gt;
===A/D Demo Usage===&lt;br /&gt;
&lt;br /&gt;
From the demo menu press '''a'''.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
****************************&lt;br /&gt;
     Demo Menu              &lt;br /&gt;
                            &lt;br /&gt;
A/D Demo             - a    &lt;br /&gt;
Count Demo           - c    &lt;br /&gt;
Input to Output Demo - i    &lt;br /&gt;
Ring Demo            - r    &lt;br /&gt;
                            &lt;br /&gt;
Exit                 - x    &lt;br /&gt;
                            &lt;br /&gt;
Enter Selection: a&lt;br /&gt;
&lt;br /&gt;
A/D Demo&lt;br /&gt;
[0]=126 [1]=11B [2]=12C [3]=12B &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The output shows the stray charge on the inputs being read by the analog-to-digital converter on pins 11, 12, 13, 14. Press '''a''' a few times to watch the values change. &lt;br /&gt;
&lt;br /&gt;
This is the HDR8 ANALOG IO header.&lt;br /&gt;
&lt;br /&gt;
[[File:analog_io_header_detail.jpg]]&lt;br /&gt;
&lt;br /&gt;
Let's do a couple of experiments on our analog in pins. &lt;br /&gt;
&lt;br /&gt;
Connect pin 20 to pin 11 and hit '''a'''. Note that the first value is higher than the others. It should read approximately '''3FF'''. This means that the first analog-in pin has 2.5V on it.&lt;br /&gt;
&lt;br /&gt;
Connect pin 1 to pin 11. Hit '''a'''. Note that the first value is lower than the others. It's the vicinity of 0. That means that the first analog-in pin is pulled down to ground.&lt;br /&gt;
&lt;br /&gt;
===Count Demo Usage===&lt;br /&gt;
&lt;br /&gt;
From the demo menu press '''c'''.&lt;br /&gt;
&lt;br /&gt;
The system counts from 0 to 255 in binary. It takes about 15 seconds to complete.&amp;lt;br /&amp;gt;&lt;br /&gt;
The steps of this process are reflected in the GPIO PortC header pins (see [[Example_io_demo#Carrier_Board | Carrier Board]], above). As each bit in our 8-bit register is set to 1, the corresponding pin in the PortC header momentarily registers 5 volts (easily detected with a multimeter or oscilloscope).&lt;br /&gt;
&lt;br /&gt;
More visibly, the counting process is also reflected in the strip of 8 LEDs on the board LD1-LD8. (see [[Example_io_demo#Carrier_Board | Carrier Board]], above). A lit LED indicates a 1 in our 8-bit register and an unlit LED indicates a 0. When the counting process is finished, all 8 LEDs are lit (255).&lt;br /&gt;
&lt;br /&gt;
===Input to Output Demo Usage===&lt;br /&gt;
&lt;br /&gt;
In this usage example the carrier board talks to itself. We send an 8-bit data stream directly from Port B to Port C via a short piece of cable. See [[Example_io_demo#Carrier_Board | Carrier Board]], above, for details.&lt;br /&gt;
&lt;br /&gt;
This is the ribbon cable for the input-to-output demo. Note that we connect PortC:pin0 to PortB:pin0; PortC:pin1 to PortB:pin1; etc.&amp;lt;br /&amp;gt;&lt;br /&gt;
[[File:iodemo_homemaderibboncable.jpg|500px|border|]]&lt;br /&gt;
&lt;br /&gt;
Here's the cable plugged into the GPIO header. You see that PortC:pin0 outputs to PortB:pin0; PortC:pin1 outputs to PortB:pin1; etc.&lt;br /&gt;
[[File:iodemo_homemaderibboncable_closeup.jpg|500px|border|]]&lt;br /&gt;
&lt;br /&gt;
The data stream for each pin is 1, 0, 1, 0, 1, 0... That is to say: all pins are set to 1, then they are all set to 0, then to 1 again, etc. We observe our data stream in the strip of 8 LEDs on the carrier board. They blink in unison.&lt;br /&gt;
&lt;br /&gt;
'''Note''' The blinking may get a little out of sync after a few seconds. This is normal.&lt;br /&gt;
&lt;br /&gt;
===Usage Example. Ring Demo===&lt;br /&gt;
&lt;br /&gt;
From the demo menu press '''r'''.&lt;br /&gt;
&lt;br /&gt;
The system sets a bit on Port C to 1, then sets it to 0, then sets the bit after that to 1, then sets that pin to 0, and so on, sequentially. This shows a ring counter on the LED strip (see [[Example_io_demo#Carrier_Board | Carrier Board]], above).&lt;br /&gt;
&lt;br /&gt;
The steps of this process are reflected in the GPIO PortC header pins. As each bit in the 8-bit register is set to 1, the corresponding pin in the PortC header momentarily registers 5 volts (easily detected with a multimeter or oscilloscope).&lt;/div&gt;</summary>
		<author><name>Mgloff</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.emacinc.com/index.php?title=Example_io_demo&amp;diff=5639</id>
		<title>Example io demo</title>
		<link rel="alternate" type="text/html" href="https://wiki.emacinc.com/index.php?title=Example_io_demo&amp;diff=5639"/>
		<updated>2019-06-14T18:42:27Z</updated>

		<summary type="html">&lt;p&gt;Mgloff: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{todo|SEOKWREV (01.03.14-16:47-&amp;gt;JG+);(01.03.14-17:35-&amp;gt;MD+);(04.07.14-09:45-&amp;gt;BS+);(04.09.14-16:15-&amp;gt;BS+)|Jgreene|project=oe 4,oe 5,jg,md,SEOKWREV,ky,bs}}&lt;br /&gt;
&lt;br /&gt;
{{#seo:&lt;br /&gt;
|title=io demo&lt;br /&gt;
|titlemode=append&lt;br /&gt;
|keywords=ADC example,Ring Counter,Binary Counter&lt;br /&gt;
|description=This is a guide to the &amp;lt;code&amp;gt;io_demo&amp;lt;/code&amp;gt; C example project included in the EMAC OE SDK.&lt;br /&gt;
}}&lt;br /&gt;
This is a guide to the &amp;lt;code&amp;gt;io_demo&amp;lt;/code&amp;gt; C example project included in the EMAC OE SDK.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;io_demo&amp;lt;/code&amp;gt; project provides four examples using SOM-150ES carrier board I/O:&amp;lt;br /&amp;gt;&lt;br /&gt;
* An analog-to-digital converter demo.&lt;br /&gt;
* A counter demo.    &lt;br /&gt;
* An input-to-output demo.&lt;br /&gt;
* A ring demo.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;io_demo&amp;lt;/code&amp;gt; project builds one executable: &amp;lt;code&amp;gt;io_demo&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Opening, Building and Uploading the Project Files ==&lt;br /&gt;
&lt;br /&gt;
For information on opening the project from within Eclipse, please see [[Importing the EMAC OE SDK Projects with Eclipse]].  Then, follow [[Using the EMAC OE SDK Projects with Eclipse]] for information on how to build, upload and execute the example.&lt;br /&gt;
&lt;br /&gt;
Alternatively, the &amp;lt;code&amp;gt;Makefile&amp;lt;/code&amp;gt; can be used with the &amp;lt;code&amp;gt;make&amp;lt;/code&amp;gt; command from the commandline to build and upload the example.  For more information on this method, please see [[Using EMAC OE SDK Example Projects]].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Usage and Behavior ==&lt;br /&gt;
&lt;br /&gt;
===Hardware Requirements===&lt;br /&gt;
&lt;br /&gt;
To use the '''io demo''' program you will need the following hardware.&lt;br /&gt;
&lt;br /&gt;
* An EMAC [http://www.emacinc.com/som/som150es.htm SOM-150ES] carrier board. &amp;lt;br /&amp;gt;&lt;br /&gt;
* A compatible EMAC SoM for that carrier board ([http://www.emacinc.com/products/system_on_module/SoM-9260M SOM-9260M], [http://www.emacinc.com/products/system_on_module/som-9G20m SOM-9G20M] and [http://www.emacinc.com/products/system_on_module/som-9x25 SOM-9X25] are all compatible).&amp;lt;br /&amp;gt;&lt;br /&gt;
* A multimeter or oscilloscope. See [[Example_io_demo#Input_to_Output_Demo_Usage | Input to Output Demo]] and  [[Example_io_demo#Count_Demo_Usage | Count Demo]] for details.&amp;lt;br /&amp;gt;&lt;br /&gt;
* A cable long enough to reach from GPIO Port B to GPIO Port C. See [[Example_io_demo#Input_to_Output_Demo_Usage | Input to Output Demo]] for details.&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Carrier Board====&lt;br /&gt;
&lt;br /&gt;
[[File:know_your_som_150.jpg|frame|left|SOM-150ES carrier board with GPIO, LEDs and analog IO indicated.]]&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is a detail of the '''HDR1 PLD &amp;amp; BUFFERED GPIO''' header. Pin 49 is Vcc. The bottom pins: 2, 4, 6...46, 48, 50; are all ground. Port A is pins 1, 3, 5, 7, 9, 11, 13, 15. Port B is pins 17, 19, 21, 23, 25, 27, 29, 31. Port C is pins 33, 35, 37, 39, 41, 43, 45, 47. &lt;br /&gt;
&lt;br /&gt;
[[File:gpio_header_detail.png]]&lt;br /&gt;
&lt;br /&gt;
===io_demo Usage===&lt;br /&gt;
&lt;br /&gt;
Run '''io demo''' from the console. It takes no parameters.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
 ./io_demo&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This brings up a menu of demos.&amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
****************************&lt;br /&gt;
     Demo Menu              &lt;br /&gt;
                            &lt;br /&gt;
A/D Demo             - a    &lt;br /&gt;
Count Demo           - c    &lt;br /&gt;
Input to Output Demo - i    &lt;br /&gt;
Ring Demo            - r    &lt;br /&gt;
                            &lt;br /&gt;
Exit                 - x    &lt;br /&gt;
                            &lt;br /&gt;
Enter Selection: &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, press '''a''', '''c''', '''i''' or '''r''' to run a demo; otherwise, press '''x''' to exit.&lt;br /&gt;
&lt;br /&gt;
===A/D Demo Usage===&lt;br /&gt;
&lt;br /&gt;
From the demo menu press '''a'''.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
****************************&lt;br /&gt;
     Demo Menu              &lt;br /&gt;
                            &lt;br /&gt;
A/D Demo             - a    &lt;br /&gt;
Count Demo           - c    &lt;br /&gt;
Input to Output Demo - i    &lt;br /&gt;
Ring Demo            - r    &lt;br /&gt;
                            &lt;br /&gt;
Exit                 - x    &lt;br /&gt;
                            &lt;br /&gt;
Enter Selection: a&lt;br /&gt;
&lt;br /&gt;
A/D Demo&lt;br /&gt;
[0]=126 [1]=11B [2]=12C [3]=12B &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The output shows the stray charge on the inputs being read by the analog-to-digital converter on pins 11, 12, 13, 14. Press '''a''' a few times to watch the values change. &lt;br /&gt;
&lt;br /&gt;
This is the HDR8 ANALOG IO header.&lt;br /&gt;
&lt;br /&gt;
[[File:analog_io_header_detail.jpg]]&lt;br /&gt;
&lt;br /&gt;
Let's do a couple of experiments on our analog in pins. &lt;br /&gt;
&lt;br /&gt;
Connect pin 20 to pin 11 and hit '''a'''. Note that the first value is higher than the others. It should read approximately '''3FF'''. This means that the first analog-in pin has 2.5V on it.&lt;br /&gt;
&lt;br /&gt;
Connect pin 1 to pin 11. Hit '''a'''. Note that the first value is lower than the others. It's the vicinity of 0. That means that the first analog-in pin is pulled down to ground.&lt;br /&gt;
&lt;br /&gt;
===Count Demo Usage===&lt;br /&gt;
&lt;br /&gt;
From the demo menu press '''c'''.&lt;br /&gt;
&lt;br /&gt;
The system counts from 0 to 255 in binary. It takes about 15 seconds to complete.&amp;lt;br /&amp;gt;&lt;br /&gt;
The steps of this process are reflected in the GPIO PortC header pins (see [[Example_io_demo#Carrier_Board | Carrier Board]], above). As each bit in our 8-bit register is set to 1, the corresponding pin in the PortC header momentarily registers 5 volts (easily detected with a multimeter or oscilloscope).&lt;br /&gt;
&lt;br /&gt;
More visibly, the counting process is also reflected in the strip of 8 LEDs on the board LD1-LD8. (see [[Example_io_demo#Carrier_Board | Carrier Board]], above). A lit LED indicates a 1 in our 8-bit register and an unlit LED indicates a 0. When the counting process is finished, all 8 LEDs are lit (255).&lt;br /&gt;
&lt;br /&gt;
===Input to Output Demo Usage===&lt;br /&gt;
&lt;br /&gt;
In this usage example the carrier board talks to itself. We send an 8-bit data stream directly from Port B to Port C via a short piece of cable. See [[Example_io_demo#Carrier_Board | Carrier Board]], above, for details.&lt;br /&gt;
&lt;br /&gt;
This is the ribbon cable for the input-to-output demo. Note that we connect PortC:pin0 to PortB:pin0; PortC:pin1 to PortB:pin1; etc.&amp;lt;br /&amp;gt;&lt;br /&gt;
[[File:iodemo_homemaderibboncable.jpg|500px|border|]]&lt;br /&gt;
&lt;br /&gt;
Here's the cable plugged into the GPIO header. You see that PortC:pin0 outputs to PortB:pin0; PortC:pin1 outputs to PortB:pin1; etc.&lt;br /&gt;
[[File:iodemo_homemaderibboncable_closeup.jpg|500px|border|]]&lt;br /&gt;
&lt;br /&gt;
The data stream for each pin is 1, 0, 1, 0, 1, 0... That is to say: all pins are set to 1, then they are all set to 0, then to 1 again, etc. We observe our data stream in the strip of 8 LEDs on the carrier board. They blink in unison.&lt;br /&gt;
&lt;br /&gt;
'''Note''' The blinking may get a little out of sync after a few seconds. This is normal.&lt;br /&gt;
&lt;br /&gt;
===Usage Example. Ring Demo===&lt;br /&gt;
&lt;br /&gt;
From the demo menu press '''r'''.&lt;br /&gt;
&lt;br /&gt;
The system sets a bit on Port C to 1, then sets it to 0, then sets the bit after that to 1, then sets that pin to 0, and so on, sequentially. This shows a ring counter on the LED strip (see [[Example_io_demo#Carrier_Board | Carrier Board]], above).&lt;br /&gt;
&lt;br /&gt;
The steps of this process are reflected in the GPIO PortC header pins. As each bit in the 8-bit register is set to 1, the corresponding pin in the PortC header momentarily registers 5 volts (easily detected with a multimeter or oscilloscope).&lt;/div&gt;</summary>
		<author><name>Mgloff</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.emacinc.com/index.php?title=Example_io_demo&amp;diff=5638</id>
		<title>Example io demo</title>
		<link rel="alternate" type="text/html" href="https://wiki.emacinc.com/index.php?title=Example_io_demo&amp;diff=5638"/>
		<updated>2019-06-14T18:30:32Z</updated>

		<summary type="html">&lt;p&gt;Mgloff: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{todo|SEOKWREV (01.03.14-16:47-&amp;gt;JG+);(01.03.14-17:35-&amp;gt;MD+);(04.07.14-09:45-&amp;gt;BS+);(04.09.14-16:15-&amp;gt;BS+)|Jgreene|project=oe 4,oe 5,jg,md,SEOKWREV,ky,bs}}&lt;br /&gt;
&lt;br /&gt;
{{#seo:&lt;br /&gt;
|title=io demo&lt;br /&gt;
|titlemode=append&lt;br /&gt;
|keywords=ADC example,Ring Counter,Binary Counter&lt;br /&gt;
|description=This is a guide to the &amp;lt;code&amp;gt;io_demo&amp;lt;/code&amp;gt; C example project included in the EMAC OE SDK.&lt;br /&gt;
}}&lt;br /&gt;
This is a guide to the &amp;lt;code&amp;gt;io_demo&amp;lt;/code&amp;gt; C example project included in the EMAC OE SDK.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;io_demo&amp;lt;/code&amp;gt; project provides four examples using SOM-150ES carrier board I/O:&amp;lt;br /&amp;gt;&lt;br /&gt;
* An analog-to-digital converter demo.&lt;br /&gt;
* A counter demo.    &lt;br /&gt;
* An input-to-output demo.&lt;br /&gt;
* A ring demo.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;io_demo&amp;lt;/code&amp;gt; project builds one executable: &amp;lt;code&amp;gt;io_demo&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Opening, Building and Uploading the Project Files ==&lt;br /&gt;
&lt;br /&gt;
For information on opening the project from within Eclipse, please see [[Importing the EMAC OE SDK Projects with Eclipse]].  Then, follow [[Using the EMAC OE SDK Projects with Eclipse]] for information on how to build, upload and execute the example.&lt;br /&gt;
&lt;br /&gt;
Alternatively, the &amp;lt;code&amp;gt;Makefile&amp;lt;/code&amp;gt; can be used with the &amp;lt;code&amp;gt;make&amp;lt;/code&amp;gt; command from the commandline to build and upload the example.  For more information on this method, please see [[Using EMAC OE SDK Example Projects]].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Usage and Behavior ==&lt;br /&gt;
&lt;br /&gt;
===Hardware Requirements===&lt;br /&gt;
&lt;br /&gt;
To use the '''io demo''' program you will need the following hardware.&lt;br /&gt;
&lt;br /&gt;
* An EMAC [http://www.emacinc.com/som/som150es.htm SOM-150ES] carrier board. &amp;lt;br /&amp;gt;&lt;br /&gt;
* A compatible EMAC SoM for that carrier board ([http://www.emacinc.com/products/system_on_module/SoM-9260M SOM-9260M], [http://www.emacinc.com/products/system_on_module/som-9G20m SOM-9G20M] and [http://www.emacinc.com/products/system_on_module/som-9x25 SOM-9X25] are all compatible).&amp;lt;br /&amp;gt;&lt;br /&gt;
* A multimeter or oscilloscope. See [http://wikidev.emacinc.com/wiki/Example_io_demo#Input_to_Output_Demo_Usage Usage Example. Input to Output Demo] and  [http://wikidev.emacinc.com/wiki/Example_io_demo#Count_Demo_Usage Usage Example. Count Demo] for details.&amp;lt;br /&amp;gt;&lt;br /&gt;
* A cable long enough to reach from GPIO Port B to GPIO Port C. See [http://wikidev.emacinc.com/wiki/Example_io_demo#Input_to_Output_Demo_Usage Usage Example. Input to Output Demo] for details.&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Carrier Board====&lt;br /&gt;
&lt;br /&gt;
[[File:know_your_som_150.jpg|frame|left|SOM-150ES carrier board with GPIO, LEDs and analog IO indicated.]]&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is a detail of the '''HDR1 PLD &amp;amp; BUFFERED GPIO''' header. Pin 49 is Vcc. The bottom pins: 2, 4, 6...46, 48, 50; are all ground. Port A is pins 1, 3, 5, 7, 9, 11, 13, 15. Port B is pins 17, 19, 21, 23, 25, 27, 29, 31. Port C is pins 33, 35, 37, 39, 41, 43, 45, 47. &lt;br /&gt;
&lt;br /&gt;
[[File:gpio_header_detail.png]]&lt;br /&gt;
&lt;br /&gt;
===io_demo Usage===&lt;br /&gt;
&lt;br /&gt;
Run '''io demo''' from the console. It takes no parameters.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
 ./io_demo&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This brings up a menu of demos.&amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
****************************&lt;br /&gt;
     Demo Menu              &lt;br /&gt;
                            &lt;br /&gt;
A/D Demo             - a    &lt;br /&gt;
Count Demo           - c    &lt;br /&gt;
Input to Output Demo - i    &lt;br /&gt;
Ring Demo            - r    &lt;br /&gt;
                            &lt;br /&gt;
Exit                 - x    &lt;br /&gt;
                            &lt;br /&gt;
Enter Selection: &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, press '''a''', '''c''', '''i''' or '''r''' to run a demo; otherwise, press '''x''' to exit.&lt;br /&gt;
&lt;br /&gt;
===A/D Demo Usage===&lt;br /&gt;
&lt;br /&gt;
From the demo menu press '''a'''.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
****************************&lt;br /&gt;
     Demo Menu              &lt;br /&gt;
                            &lt;br /&gt;
A/D Demo             - a    &lt;br /&gt;
Count Demo           - c    &lt;br /&gt;
Input to Output Demo - i    &lt;br /&gt;
Ring Demo            - r    &lt;br /&gt;
                            &lt;br /&gt;
Exit                 - x    &lt;br /&gt;
                            &lt;br /&gt;
Enter Selection: a&lt;br /&gt;
&lt;br /&gt;
A/D Demo&lt;br /&gt;
[0]=126 [1]=11B [2]=12C [3]=12B &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The output shows the stray charge on the inputs being read by the analog-to-digital converter on pins 11, 12, 13, 14. Press '''a''' a few times to watch the values change. &lt;br /&gt;
&lt;br /&gt;
This is the HDR8 ANALOG IO header.&lt;br /&gt;
&lt;br /&gt;
[[File:analog_io_header_detail.jpg]]&lt;br /&gt;
&lt;br /&gt;
Let's do a couple of experiments on our analog in pins. &lt;br /&gt;
&lt;br /&gt;
Connect pin 20 to pin 11 and hit '''a'''. Note that the first value is higher than the others. It should read approximately '''3FF'''. This means that the first analog-in pin has 2.5V on it.&lt;br /&gt;
&lt;br /&gt;
Connect pin 1 to pin 11. Hit '''a'''. Note that the first value is lower than the others. It's the vicinity of 0. That means that the first analog-in pin is pulled down to ground.&lt;br /&gt;
&lt;br /&gt;
===Count Demo Usage===&lt;br /&gt;
&lt;br /&gt;
From the demo menu press '''c'''.&lt;br /&gt;
&lt;br /&gt;
The system counts from 0 to 255 in binary. It takes about 15 seconds to complete.&amp;lt;br /&amp;gt;&lt;br /&gt;
The steps of this process are reflected in the GPIO PortC header pins (see [http://wikidev.emacinc.com/wiki/Example_io_demo#Know_Your_Carrier_Board Know Your Carrier Board], above). As each bit in our 8-bit register is set to 1, the corresponding pin in the PortC header momentarily registers 5 volts (easily detected with a multimeter or oscilloscope).&lt;br /&gt;
&lt;br /&gt;
More visibly, the counting process is also reflected in the strip of 8 LEDs on the board LD1-LD8. (see [http://wikidev.emacinc.com/wiki/Example_io_demo#Know_Your_Carrier_Board Know Your Carrier Board], above). A lit LED indicates a 1 in our 8-bit register and an unlit LED indicates a 0. When the counting process is finished, all 8 LEDs are lit (255).&lt;br /&gt;
&lt;br /&gt;
===Input to Output Demo Usage===&lt;br /&gt;
&lt;br /&gt;
In this usage example the carrier board talks to itself. We send an 8-bit data stream directly from Port B to Port C via a short piece of ribbon cable. See [[http://wikidev.emacinc.com/wiki/Example_io_demo#Know_Your_Carrier_Board Know Your Carrier Board]], above, for details.&lt;br /&gt;
&lt;br /&gt;
This is the ribbon cable for the input-to-output demo. Note that we connect PortC:pin0 to PortB:pin0; PortC:pin1 to PortB:pin1; etc.&amp;lt;br /&amp;gt;&lt;br /&gt;
[[File:iodemo_homemaderibboncable.jpg|500px|border|]]&lt;br /&gt;
&lt;br /&gt;
Here's the cable plugged into the GPIO header. You see that PortC:pin0 outputs to PortB:pin0; PortC:pin1 outputs to PortB:pin1; etc.&lt;br /&gt;
[[File:iodemo_homemaderibboncable_closeup.jpg|500px|border|]]&lt;br /&gt;
&lt;br /&gt;
The data stream for each pin is 1, 0, 1, 0, 1, 0... That is to say: all pins are set to 1, then they are all set to 0, then to 1 again, etc. We observe our data stream in the strip of 8 LEDs on the carrier board. They blink in unison.&lt;br /&gt;
&lt;br /&gt;
'''Note''' The blinking may get a little out of sync after a few seconds. This is normal.&lt;br /&gt;
&lt;br /&gt;
===Usage Example. Ring Demo===&lt;br /&gt;
&lt;br /&gt;
From the demo menu press '''r'''.&lt;br /&gt;
&lt;br /&gt;
The system sets a bit on Port C to 1, then sets it to 0, then sets the bit after that to 1, then sets that pin to 0, and so on, sequentially. This shows a ring counter on the LED strip (see [http://wikidev.emacinc.com/wiki/Example_io_demo#Know_Your_Carrier_Board Know Your Carrier Board], above).&lt;br /&gt;
&lt;br /&gt;
The steps of this process are reflected in the GPIO PortC header pins. As each bit in the 8-bit register is set to 1, the corresponding pin in the PortC header momentarily registers 5 volts (easily detected with a multimeter or oscilloscope).&lt;/div&gt;</summary>
		<author><name>Mgloff</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.emacinc.com/index.php?title=System_Logging&amp;diff=5637</id>
		<title>System Logging</title>
		<link rel="alternate" type="text/html" href="https://wiki.emacinc.com/index.php?title=System_Logging&amp;diff=5637"/>
		<updated>2019-06-11T22:40:42Z</updated>

		<summary type="html">&lt;p&gt;Mgloff: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{todo| Complete (04.13.2015-14:44-&amp;gt;BS+)(11.10.2015-18:00-&amp;gt;MD+)(11.11.2015-10:30-&amp;gt;MD+)(11.17.2015-18:10-&amp;gt;MD+);(11.18.2015-12:55-&amp;gt;MD+)(11.18.2015-14:50-&amp;gt;MD+)(11.18.2015-15:10-&amp;gt;KY+);(11.18.2015-15:50-&amp;gt;ER+)|Mike Dean| project=OE 5.0,MD,Complete}}&lt;br /&gt;
{{#seo:&lt;br /&gt;
|title=System Logging&lt;br /&gt;
|titlemode=append&lt;br /&gt;
|keywords=syslogd,syslog-ng,busybox&lt;br /&gt;
|description=The page describes how to work with syslog.&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /****************************************  Page Description Text  ****************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
This document provides an overview of how system logging works in Linux, and provides guidance on how to work with and configure system logging so that it meets your needs.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /***************************************** Background Information ****************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
{{:Templateimpl:bg | initials=MD | title=System Logging | desc=The page describes how to system log. | project=OE 5.0 }}&lt;br /&gt;
System Logging services exist on Linux systems to provide a central logging facility.  This central logging service can store logged messages in files on the local machine, can forward the log messages to a remote machine for remote storage and display, and can output the log messages as they arrive to a terminal.  &lt;br /&gt;
&lt;br /&gt;
The syslog facility is standardized by POSIX and, as a result, there is a great deal of support for the syslog facility.  There are APIs for logging to the syslog facility from C, C++, Python, Java, PHP, Perl, Bash, the commandline, and many other languages.  Using the commandline tool, it is even possible to write to the syslog facility from the commandline.&lt;br /&gt;
&lt;br /&gt;
==== Facilities ====&lt;br /&gt;
&lt;br /&gt;
In syslog terminology, a facility is a category for log messages.  There are generally at least seven standard syslog facilities on any Linux syslog system.  The following list shows the standard seven, as well as some which are rarely used anymore (especially in embedded systems).  The name of the facility is followed, in parenthesis, by the integer facility code associated with the facility, which is then followed by a description of the facility.  The ones you should not expect to find on an embedded system are demarcated with an asterisk (*):&lt;br /&gt;
&lt;br /&gt;
;kern(0)&lt;br /&gt;
: Kernel messages&lt;br /&gt;
;user(1)&lt;br /&gt;
: User Level Messages&lt;br /&gt;
;mail(2)*&lt;br /&gt;
: Mail System Messages&lt;br /&gt;
;daemon(3)&lt;br /&gt;
: System Daemon Messages&lt;br /&gt;
;auth(4)&lt;br /&gt;
: Security/Authentication Messages&lt;br /&gt;
;syslog(5)&lt;br /&gt;
: Internally Generated Syslog Messages&lt;br /&gt;
;lpr(6)*&lt;br /&gt;
: Line Printer Subsystem Messages&lt;br /&gt;
;news(7)*&lt;br /&gt;
: Network News Subsystem Messages&lt;br /&gt;
;uucp(8)*&lt;br /&gt;
: UUCP Subsystem Messages&lt;br /&gt;
;cron(15)&lt;br /&gt;
: Cron Scheduling Daemon Messages&lt;br /&gt;
;local(16-23)&lt;br /&gt;
: Locally Defined Usage, Messages&lt;br /&gt;
&lt;br /&gt;
==== Severity ====&lt;br /&gt;
&lt;br /&gt;
Each of these facilities accepts messages which will have an associated severity level.  The severity level is important for filtering messages.  The following list shows the eight available severity levels:&lt;br /&gt;
&lt;br /&gt;
;emerg(0)&lt;br /&gt;
: Emergency - System is now unusable&lt;br /&gt;
;alert(1)&lt;br /&gt;
: Alert - Immediate Attention is Required&lt;br /&gt;
;crit(2)&lt;br /&gt;
: Critical - The System is in a Critical Condition, which may be caused by a failure in the primary appliction.&lt;br /&gt;
;err(3)&lt;br /&gt;
: Error - An Error has occurred.&lt;br /&gt;
;warning(4)&lt;br /&gt;
: Warning - An unusual, but not erroneous, event has occurred.  For example: &amp;quot;Warning: Could not check for updates.&amp;quot;&lt;br /&gt;
;notice(5)&lt;br /&gt;
: Notice - Uncommon but generally expected messages.  For example: &amp;quot;Network Interface eth0 received IP address of 192.168.0.100 from DHCP server.&amp;quot;&lt;br /&gt;
;info(6)&lt;br /&gt;
: Informational - Common, expected events generate these messages.  For example: &amp;quot;Application XYZ started successfully.&amp;quot;&lt;br /&gt;
;debug(7)&lt;br /&gt;
: Debug - Debugging messages belong at this level.&lt;br /&gt;
&lt;br /&gt;
==== Storage ====&lt;br /&gt;
&lt;br /&gt;
By default, the log messages on an EMAC OE Linux machine are stored in a local ramdisk.  This type of storage prevents excessive wear of the flash, and works when all of the flash partitions are mounted read-only.  However, by storing the messages in a ramdisk, all messages in the ramdisk will be lost as soon as the machine resets, powers off, or reboots for any reason.&lt;br /&gt;
&lt;br /&gt;
===== Alternate Logging Locations =====&lt;br /&gt;
&lt;br /&gt;
The syslog server can be configured to log to alternate locations.  This is useful for configuring the server to log to persistent storage, such as a writable partition on the local flash or a partition on an SD card.  The alternate logging locations can even be remote machines.&lt;br /&gt;
&lt;br /&gt;
===== Remote Logging =====&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;/var/log&amp;lt;/code&amp;gt; directory is the standard location for holding local log messages.  This directory usually contains either one file per facility or one directory per facility.  If a facility has a directory, it may contain different files which all belong to the facility.  The system logging facility directs messages to these files based on rules set in its configuration.  The configured rules use the facility level and the severity level to direct the syslogger's filters regarding to which file to send any particular message.  There are several different implementations of the syslogger facility, each with its own configuration mechanisms and level of flexibility.&lt;br /&gt;
&lt;br /&gt;
The system logger is also able to send messages to a remote syslog server over a network.  The remote syslog server will be able to filter the messages using all of the same criteria as above, but also by source.  A remote syslog server configuration can be very useful for remotely debugging deployed machines.  While an embedded machine stores its logs on a ramdisk, the remote machine may store them to a traditional hard disk or SSD, allowing them to be preserved through power cycles.&lt;br /&gt;
&lt;br /&gt;
The remote syslog server can be on any normal server, it can be on a developer's desktop, or it can be on another embedded machine.  Sending debug messages to a central syslog server ensures the debug messages will be available even if the machine of interest freezes or resets.  The use of a remote syslog server can also assist with looking for trends and outliers among a group of deployed machines since the log messages for the entire group of machines can be located in one place.&lt;br /&gt;
&lt;br /&gt;
===== Log Rotation =====&lt;br /&gt;
&lt;br /&gt;
Syslog servers incorporate a feature called log rotation.  Log rotation is a process which prevents log files from growing beyond a certain size while preserving log messages for later reference.  The syslog server (or logrotate system) can be configured with a maximum file size and a maximum number of rotated logs to keep.  When the maximum file size is reached, the file will be &amp;quot;rotated.&amp;quot;  When the maximum number of logs to keep is exceeded, the oldest one will be deleted.  There is more information on how this process works below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /*****************************************  General Information  *****************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
{{:Templateimpl:geninfo | initials=MD | title=System Logging | desc=The page describes how to system log. | project=OE 5.0 }}&lt;br /&gt;
&lt;br /&gt;
====Your Daemons====&lt;br /&gt;
&lt;br /&gt;
When developing a software daemon, syslog is a very useful tool for monitoring and debugging your software.  The syslog daemon is highly configurable, allowing filters to be altered to suit the current needs of a developer without recompiling software.  This capability allows developers to deploy software which sends ample debugging messages to the syslog server without fear of overwhelming the system with debug messages.  Using the eight &amp;lt;code&amp;gt;local&amp;lt;/code&amp;gt; facilities syslog recognizes, these debug messages can be categorized by developers to allow them to selectively choose the amount of log information they store from each of up to eight different subsystems.  This is extremely useful when a system in the field is experiencing intermittent issues.  By enabling maximum debugging output for only the subsystem responsible for the feature which is misbehaving, the developers have the greatest chance of seeing the messages they need to diagnose the source of the problem without overwhelming the system (or the storage) with messages.  If eight facilities is not enough, the developers can always repurpose dedicated facilities which aren't in use by their intended systems.  For instance, the line printing facility is rarely used on an embedded system, and may be safely repurposed by developers.&lt;br /&gt;
&lt;br /&gt;
====Web Development====&lt;br /&gt;
&lt;br /&gt;
When providing a web interface for an embedded system, the syslog daemon is often the only way to debug a variety of issues with the web server.  When links don't work, certain browsers have issues, pages load slowly, or any of a myriad of other issues crop up, the logs are generally the first place people turn for answers.  This is just as true on embedded systems as it is on any large scale web server or server farm.  On embedded systems, however, the configuration for the logging system may need to be altered due to the volatile nature of the logs in the default configuration.  This document provides information on how to solve the issues which may be encountered as a result of this.&lt;br /&gt;
&lt;br /&gt;
====Machine Startup====&lt;br /&gt;
&lt;br /&gt;
When configuring a machine to start up all the necessary services in the correct sequential order, when the machine is powered on, the syslog server is very helpful in performing the following tasks:&lt;br /&gt;
* Ensuring that process X really did start before process Y.&lt;br /&gt;
* Checking to see if any errors or warnings were reported by processes starting up.&lt;br /&gt;
* Ensuring that processes really did start, at all.&lt;br /&gt;
* Checking to see what configuration was chosen by a process which is capable of choosing its configuration dynamically.&lt;br /&gt;
* Checking the messages reported by device drivers as they start up.&lt;br /&gt;
* Determining the IP address used by a system which gets its network configuration via DHCP.&lt;br /&gt;
Startup scripts log their activity to the syslog daemon.  Any daemon process launched by these startup scripts should also log startup messages to indicate that they're starting, how they're configured, and that they've finished the startup sequence and are now running.  The system logs enable the engineer to assure that a machine has started as intended.&lt;br /&gt;
&lt;br /&gt;
====Malfunctioning Systems====&lt;br /&gt;
&lt;br /&gt;
When a proven system is malfunctioning, the system logs can be essential in determining the cause of the malfunction.  In cases such as this, the system logs are helpful for:&lt;br /&gt;
* Looking to see who logged into a machine, and when.&lt;br /&gt;
* Looking for signs of attacks directed at the machine.&lt;br /&gt;
* Looking for signs of failing hardware.&lt;br /&gt;
* Looking for error and warning messages coming from system processes, daemons, and/or your custom application.&lt;br /&gt;
Without these logs, it may be nearly impossible to diagnose these malfunctions.&lt;br /&gt;
&lt;br /&gt;
====In Brief====&lt;br /&gt;
&lt;br /&gt;
This guide provides enough background information to enable you to handle any of the situations described above.  Using the information contain herein, you will be able to approach any of the above listed problems with the tools you need to solve the problems you are facing.&lt;br /&gt;
&lt;br /&gt;
{{note | To make best use of the log files, a working knowledge of &amp;lt;code&amp;gt;grep&amp;lt;/code&amp;gt; is highly beneficial.  Experience with crafting and using regular expressions with &amp;lt;code&amp;gt;grep&amp;lt;/code&amp;gt; prior to writing system logging messages in your application and init scripts can make the diagnosis process simpler, since a little forethought into a syntax for the messages can make filtering the messages through &amp;lt;code&amp;gt;grep&amp;lt;/code&amp;gt; much easier to accomplish correctly.}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /*****************************************  Using/Working With  ******************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
{{:Templateimpl:using | initials=MD | title=System Logging | desc=The page describes how to system log. | project=OE 5.0 }}&lt;br /&gt;
EMAC OE Linux 5.X uses Busybox's built-in version of syslog daemon, &amp;lt;code&amp;gt;syslogd&amp;lt;/code&amp;gt;, by default.  However, the &amp;lt;code&amp;gt;syslog-ng&amp;lt;/code&amp;gt; package can be installed to provide a much more capable system logging daemon, when needed.&lt;br /&gt;
&lt;br /&gt;
====About====&lt;br /&gt;
&lt;br /&gt;
The standard syslog daemon supports the following configuration capabilities:&lt;br /&gt;
* Maximum size limit for log files.&lt;br /&gt;
* Maximum number of log files to keep, when rotated.&lt;br /&gt;
* Minimum priority level for messages to log.&lt;br /&gt;
* Duplicate dropping (not usually recommended).&lt;br /&gt;
* Log to remote and local files simultaneously, just to local files, or to a memory buffer which needs to be read by a special utility.&lt;br /&gt;
&lt;br /&gt;
====Working With====&lt;br /&gt;
&lt;br /&gt;
The syslog daemon is configured, by default, to log to a shared memory buffer. The messages are displayed with the &amp;lt;code&amp;gt;logread&amp;lt;/code&amp;gt; utility.  &lt;br /&gt;
&lt;br /&gt;
The standard &amp;lt;code&amp;gt;/etc/syslog-startup.conf&amp;lt;/code&amp;gt; configuration is shown below:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=bash&amp;gt;&lt;br /&gt;
# This configuration file is used by the busybox syslog init script,&lt;br /&gt;
# /etc/init.d/syslog[.busybox] to set syslog configuration at start time.&lt;br /&gt;
&lt;br /&gt;
DESTINATION=buffer                # log destinations (buffer file remote)&lt;br /&gt;
LOGFILE=/var/log/messages       # where to log (file)&lt;br /&gt;
REMOTE=loghost:514              # where to log (syslog remote)&lt;br /&gt;
REDUCE=no                       # reduce-size logging&lt;br /&gt;
DROPDUPLICATES=no               # whether to drop duplicate log entries&lt;br /&gt;
#ROTATESIZE=0                   # rotate log if grown beyond X [kByte]&lt;br /&gt;
#ROTATEGENS=3                   # keep X generations of rotated logs&lt;br /&gt;
BUFFERSIZE=64                   # size of circular buffer [kByte]&lt;br /&gt;
FOREGROUND=no                   # run in foreground (don't use!)&lt;br /&gt;
#LOGLEVEL=5                     # local log level (between 1 and 8)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
;DESTINATION&lt;br /&gt;
: This configures where the syslog messages will be sent.  &lt;br /&gt;
:;buffer&lt;br /&gt;
:: The &amp;lt;code&amp;gt;buffer&amp;lt;/code&amp;gt; option will cause the messages to be stored in an internal circular buffer, in RAM.  This buffer must be read with &amp;lt;code&amp;gt;logread&amp;lt;/code&amp;gt;.&lt;br /&gt;
:;file&lt;br /&gt;
:: The &amp;lt;code&amp;gt;file&amp;lt;/code&amp;gt; option will cause the messages to be stored in a file in the location specified by the &amp;lt;code&amp;gt;LOGFILE&amp;lt;/code&amp;gt; parameter, listed below.&lt;br /&gt;
:;remote&lt;br /&gt;
:: The &amp;lt;code&amp;gt;remote&amp;lt;/code&amp;gt; option will cause syslog messages to be sent to a remote syslog daemon.&lt;br /&gt;
;LOGFILE&lt;br /&gt;
: The &amp;lt;code&amp;gt;LOGFILE&amp;lt;/code&amp;gt; parameter specifies the location of the logfile which should be used with the &amp;lt;code&amp;gt;file&amp;lt;/code&amp;gt; destination.&lt;br /&gt;
;REMOTE&lt;br /&gt;
: The &amp;lt;code&amp;gt;REMOTE&amp;lt;/code&amp;gt; parameter specifies the host and port to which to send remote log messages.  The two part format for this variable provides the destination host followed by the destination port number, with a colon as the delimiter between the two.  The destination may be specified as a hostname, or as an IP address.  The destination port number should be the port on which the remote syslog server listens. Port 514 is the default syslog port. A syslog collector server will need to be installed and set up in order to log remotely.&lt;br /&gt;
&lt;br /&gt;
{{note | If the destination is specified as a hostname, it is best to create an entry in &amp;lt;code&amp;gt;/etc/hosts&amp;lt;/code&amp;gt; for the hostname so that it will resolve to an IP address even if there is a problem with the DNS servers.}}&lt;br /&gt;
&lt;br /&gt;
;REDUCE&lt;br /&gt;
: The &amp;lt;code&amp;gt;REDUCE&amp;lt;/code&amp;gt; option takes a &amp;lt;code&amp;gt;yes&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;no&amp;lt;/code&amp;gt; argument.  When set to &amp;lt;code&amp;gt;yes&amp;lt;/code&amp;gt;, the syslog server will neglect to log the hostname, facility, and severity level with each log message.  This is only recommended for severely resource constrained systems, since the facility and severity level are often used for filtering messages through &amp;lt;code&amp;gt;grep&amp;lt;/code&amp;gt;.&lt;br /&gt;
;DROPDUPLICATES&lt;br /&gt;
: The &amp;lt;code&amp;gt;DROPDUPLICATES&amp;lt;/code&amp;gt; option takes a &amp;lt;code&amp;gt;yes&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;no&amp;lt;/code&amp;gt; argument.  When set to &amp;lt;code&amp;gt;yes&amp;lt;/code&amp;gt;, the syslog server will ignore messages which duplicate the preceeding message.  This can be useful when an errant process keeps sending the same message over and over again, and swamps out the other messages as a result (due to the maximum size setting for the log files).  It is best to keep this option off unless it is absolutely needed for a situation like the one just described, because having it turned on can cause other problems to be hidden (generally leading to frustration and/or embarrassment).&lt;br /&gt;
;ROTATESIZE&lt;br /&gt;
: The &amp;lt;code&amp;gt;ROTATESIZE&amp;lt;/code&amp;gt; option takes a numeric argument.  This argument is the maximum desired size for a log file, specified in kibibytes.  When a log file has grown to the point where it exceeds this high water mark, it will be rotated.&lt;br /&gt;
;ROTATEGENS&lt;br /&gt;
: The &amp;lt;code&amp;gt;ROTATEGENS&amp;lt;/code&amp;gt; option takes a numeric argument.  This argument specifies the number of older generations of log files to keep in existence.  By generations, it means the number of log files which have already been renamed with a sequencing number as a postfix.  See the note below for more information.&lt;br /&gt;
{{note | Logfile rotation is a process which renames log files sequentially, to preserve older log messages while keeping incoming messages writing to the same location.  For instance, for the &amp;lt;code&amp;gt;/var/log/messages&amp;lt;/code&amp;gt; file, this might look like:&amp;lt;code&amp;gt;&lt;br /&gt;
messages -&amp;gt; messages.0&lt;br /&gt;
+messages&amp;lt;/code&amp;gt;&lt;br /&gt;
Or, if one were to perform this rotation manually at a terminal, it may look like:&lt;br /&gt;
{{clo}}&lt;br /&gt;
{{clio | pwd=/var/log |mv messages messages.0}}&lt;br /&gt;
{{clio | pwd=/var/log |touch messages}}&lt;br /&gt;
{{clos}}&lt;br /&gt;
If there already is a &amp;lt;code&amp;gt;messages.0&amp;lt;/code&amp;gt; file, and the number of generations to keep is set to 2, then a manual version of the rotation might look something like this:&lt;br /&gt;
{{clo}}&lt;br /&gt;
{{clio | pwd=/var/log |rm -f messages.2}}&lt;br /&gt;
{{clio | pwd=/var/log |mv messages.1 messages.2}}&lt;br /&gt;
{{clio | pwd=/var/log |mv messages.0 messages.1}}&lt;br /&gt;
{{clio | pwd=/var/log |mv messages messages.0}}&lt;br /&gt;
{{clio | pwd=/var/log |touch messages}}&lt;br /&gt;
{{clos}}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
;BUFFERSIZE&lt;br /&gt;
: The &amp;lt;code&amp;gt;BUFFERSIZE&amp;lt;/code&amp;gt; option takes a numeric argument.  This argument specifies the size of the internal circular buffer to use for holding log messages in an internal RAM buffer.  This argument only matters when the &amp;lt;code&amp;gt;DESTINATION&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;buffer&amp;lt;/code&amp;gt;.  The size is specified in kibibytes.&lt;br /&gt;
;FOREGROUND&lt;br /&gt;
: The &amp;lt;code&amp;gt;FOREGROUND&amp;lt;/code&amp;gt; option takes a &amp;lt;code&amp;gt;yes&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;no&amp;lt;/code&amp;gt; argument.  This argument specifies whether the &amp;lt;code&amp;gt;syslogd&amp;lt;/code&amp;gt; process should run in the foreground or as a daemon.  It is strongly recommended for this option to always be set to, &amp;lt;code&amp;gt;no&amp;lt;/code&amp;gt;, to run &amp;lt;code&amp;gt;syslogd&amp;lt;/code&amp;gt; as a daemon.  This option mostly exists for the developers of Busybox to debug their &amp;lt;code&amp;gt;syslogd&amp;lt;/code&amp;gt; implementation.&lt;br /&gt;
;LOGLEVEL&lt;br /&gt;
: The &amp;lt;code&amp;gt;LOGLEVEL&amp;lt;/code&amp;gt; option takes a numeric argument.  This argument specifies the highest numbered severity level which should be logged (see [[System_Logging#Severity | severity]] above).  By default, this is set such that messages with a severity of '''notice''', or more severe, will be logged.&lt;br /&gt;
&lt;br /&gt;
===Optional &amp;lt;code&amp;gt;syslog-ng&amp;lt;/code&amp;gt; With &amp;lt;code&amp;gt;logrotate&amp;lt;/code&amp;gt;===&lt;br /&gt;
&lt;br /&gt;
The optional &amp;lt;code&amp;gt;syslog-ng&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;logrotate&amp;lt;/code&amp;gt; option provides everything that's provided by the Busybox syslog daemon, plus:&lt;br /&gt;
* Sophisticated filters for directing log traffic.&lt;br /&gt;
* The ability to act as a central syslog server which receives log messages from remote syslog machines.&lt;br /&gt;
* Enhanced control over the destination(s) for log messages, allowing (for example) messages to be logged to a local RAMDISK, a local SD card (if available), and to a remote syslog server (if available) simultaneously.&lt;br /&gt;
* The ability to configure logrotate to automatically e-mail log files when they're rotated.&lt;br /&gt;
&lt;br /&gt;
* Same syslog server software is readily available for Linux desktops and servers.&lt;br /&gt;
As can be expected, the potential drawback of &amp;lt;code&amp;gt;syslog-ng&amp;lt;/code&amp;gt; is the steeper learning curve required to make use of its more sophisticated features.  However, those already familiar with &amp;lt;code&amp;gt;syslog-ng&amp;lt;/code&amp;gt; will be able to benefit from its extra sophistication immediately.&lt;br /&gt;
&lt;br /&gt;
The official manual page for &amp;lt;code&amp;gt;syslog-ng&amp;lt;/code&amp;gt; has more details: http://www.syslog.org/syslog-ng/v1/&lt;br /&gt;
&lt;br /&gt;
Please contact EMAC for details on how to install &amp;lt;code&amp;gt;syslog-ng&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;logrotate&amp;lt;/code&amp;gt; if you have trouble finding and installing them with &amp;lt;code&amp;gt;opkg&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /*****************************************       Examples        *****************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
{{:Templateimpl:examples | initials=MD | title=System Logging | desc=The page describes how to system log. | project=OE 5.0 }}&lt;br /&gt;
&lt;br /&gt;
===Evaluating Log Messages===&lt;br /&gt;
&lt;br /&gt;
Log messages are stored in &amp;lt;code&amp;gt;/var/log/&amp;lt;/code&amp;gt; by default.  This directory contains at least one log file, &amp;lt;code&amp;gt;messages&amp;lt;/code&amp;gt;.  There are usually (at least) a few other small log files which where generated by the kernel before &amp;lt;code&amp;gt;syslogd&amp;lt;/code&amp;gt; started.  When &amp;lt;code&amp;gt;syslog-ng&amp;lt;/code&amp;gt; is used, you may have several log files which are continually growing, depending on how you configured it.&lt;br /&gt;
&lt;br /&gt;
====Showing All the Messages====&lt;br /&gt;
&lt;br /&gt;
When the log is rotated, a sequence of additional files will be generated from it, such as &amp;lt;code&amp;gt;messages.0&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;messages.1&amp;lt;/code&amp;gt;, etc.  The highest numbered file is the oldest.  If you wish to look for messages through as much of the log history as possible, you will need to look through all of the available log files.  Fortunately, this is simple.  Say you have two rotated versions of the &amp;lt;code&amp;gt;messages&amp;lt;/code&amp;gt; file, &amp;lt;code&amp;gt;messages.0&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;messages.1&amp;lt;/code&amp;gt;.  You can output all of the messages from these three files, in order, with the following command:&lt;br /&gt;
&lt;br /&gt;
{{clop}}&lt;br /&gt;
{{cliop | pwd=/var/log |cat messages.1 messages.0 messages}}&lt;br /&gt;
Nov 17 19:00:21 ipac9x25 user.notice kernel: klogd started: BusyBox v1.23.1 (2015-07-02 12:53:54 CDT)&lt;br /&gt;
Nov 17 19:00:21 ipac9x25 user.notice kernel: Linux version 3.10.0-emac-standard+23f12b107c (developer@OEBuilder) (gcc &lt;br /&gt;
ersion 4.9.2 (GCC) ) #1 Tue Jul 21 21:46:40 CDT 2015&lt;br /&gt;
Nov 17 19:00:21 ipac9x25 user.warn kernel: CPU: ARM926EJ-S [41069265] revision 5 (ARMv5TEJ), cr=00053177&lt;br /&gt;
Nov 17 19:00:21 ipac9x25 user.warn kernel: CPU: VIVT data cache, VIVT instruction cache&lt;br /&gt;
Nov 17 19:00:21 ipac9x25 user.warn kernel: Memory policy: ECC disabled, Data cache writeback&lt;br /&gt;
''etc.''&lt;br /&gt;
{{cliop | pwd=/var/log |}}&lt;br /&gt;
{{closp}}&lt;br /&gt;
&lt;br /&gt;
You can combine this with &amp;lt;code&amp;gt;grep&amp;lt;/code&amp;gt; to see only what you're interested in:&lt;br /&gt;
&lt;br /&gt;
{{clop}}&lt;br /&gt;
{{cliop | pwd=/var/log |cat messages.1 messages.0 messages {{!}} grep authpriv}}&lt;br /&gt;
Nov 17 19:01:11 ipac9x25 authpriv.notice login[1046]: ROOT LOGIN  on '/dev/ttyS5'&lt;br /&gt;
{{cliop | pwd=/var/log |}}&lt;br /&gt;
{{closp}}&lt;br /&gt;
&lt;br /&gt;
Here, we can see that someone logged into the machine as the &amp;lt;code&amp;gt;root&amp;lt;/code&amp;gt; user on November 17 at 7:01pm, on the serial console (&amp;lt;code&amp;gt;/dev/ttyS5&amp;lt;/code&amp;gt;).  This is the only login on the machine since it booted.  Had there been other logins, they would also have been shown.&lt;br /&gt;
&lt;br /&gt;
Say you want to see a certain type of message, but there are a lot of results.  You can add &amp;lt;code&amp;gt;less&amp;lt;/code&amp;gt; to make it easier to read through them:&lt;br /&gt;
&lt;br /&gt;
{{clop}}&lt;br /&gt;
{{cliop | pwd=/var/log |cat messages.1 messages.0 messages {{!}} grep user.notice {{!}} less}}&amp;lt;nowiki&amp;gt;&lt;br /&gt;
Nov 17 19:00:21 ipac9x25 user.notice kernel: klogd started: BusyBox v1.23.1 (2015-07-02 12:53:54 CDT)&lt;br /&gt;
Nov 17 19:00:21 ipac9x25 user.notice kernel: Linux version 3.10.0-emac-standard+23f12b107c (developer@OEBuilder) (gcc version 4.9.2 (GCC) ) #1 Tue Jul 21 21:46:40 CDT 2015&lt;br /&gt;
Nov 17 19:00:21 ipac9x25 user.warn kernel: CPU: ARM926EJ-S [41069265] revision 5 (ARMv5TEJ), cr=00053177&lt;br /&gt;
Nov 17 19:00:21 ipac9x25 user.warn kernel: CPU: VIVT data cache, VIVT instruction cache&lt;br /&gt;
Nov 17 19:00:21 ipac9x25 user.warn kernel: Memory policy: ECC disabled, Data cache writeback&lt;br /&gt;
Nov 17 19:00:21 ipac9x25 user.warn kernel: Clocks: CPU 400 MHz, master 133 MHz, main 12.000 MHz&lt;br /&gt;
Nov 17 19:00:21 ipac9x25 user.warn kernel: Built 1 zonelists in Zone order, mobility grouping on.  Total pages: 32512&lt;br /&gt;
Nov 17 19:00:21 ipac9x25 user.notice kernel: Kernel command line: console=ttyS5,115200 root=/dev/mmcblk0p1 rootfstype=ext4 &lt;br /&gt;
w rootwait&lt;br /&gt;
Nov 17 19:00:21 ipac9x25 user.notice kernel: Memory: 124820k/124820k available, 6252k reserved, 0K highmem&lt;br /&gt;
Nov 17 19:00:21 ipac9x25 user.notice kernel: klogd started: BusyBox v1.23.1 (2015-07-02 12:53:54 CDT)&lt;br /&gt;
Nov 17 19:00:21 ipac9x25 user.notice kernel: Linux version 3.10.0-emac-standard+23f12b107c (developer@OEBuilder) (gcc &lt;br /&gt;
ersion 4.9.2 (GCC) ) #1 Tue Jul 21 21:46:40 CDT 2015&lt;br /&gt;
Nov 17 19:00:21 ipac9x25 user.notice kernel: Kernel command line: console=ttyS5,115200 root=/dev/mmcblk0p1 rootfstype=ext4 rw rootwait&lt;br /&gt;
Nov 17 19:00:21 ipac9x25 user.notice kernel: Memory: 124820k/124820k available, 6252k reserved, 0K highmem&lt;br /&gt;
Nov 17 19:00:21 ipac9x25 user.notice kernel: Virtual kernel memory layout:&lt;br /&gt;
Nov 17 19:00:21 ipac9x25 user.notice kernel:     vector  : 0xffff0000 - 0xffff1000   (   4 kB)&lt;br /&gt;
Nov 17 19:00:21 ipac9x25 user.notice kernel:     fixmap  : 0xfff00000 - 0xfffe0000   ( 896 kB)&lt;br /&gt;
Nov 17 19:00:21 ipac9x25 user.notice kernel:     vmalloc : 0xc8800000 - 0xff000000   ( 872 MB)&lt;br /&gt;
Nov 17 19:00:21 ipac9x25 user.notice kernel:     lowmem  : 0xc0000000 - 0xc8000000   ( 128 MB)&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
{{closp}}&lt;br /&gt;
&lt;br /&gt;
====Helper Functions====&lt;br /&gt;
&lt;br /&gt;
When it gets to the point where there are several rotated log files, the command to cat them all can be a lot to type.  Let's create a couple of helper functions to make our lives easier.  We can enter these at the shell, as shown here.  To save them permanently, put them in your &amp;lt;code&amp;gt;~/.bashrc&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;/etc/profile&amp;lt;/code&amp;gt; file.&lt;br /&gt;
&lt;br /&gt;
{{clop}}&lt;br /&gt;
{{cliop | pwd=/var/log |&amp;lt;nowiki&amp;gt;function genseq() { logfn=$1; max=$2; for i in $(seq $max -1 0); do printf &amp;quot;${logfn}.${i} &amp;quot;; done; printf &amp;quot;$logfn\n&amp;quot;; }&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
{{closp}}&lt;br /&gt;
&lt;br /&gt;
This function generates a sequence of log file names for us to use, like this:&lt;br /&gt;
&lt;br /&gt;
{{clop}}&lt;br /&gt;
{{cliop | pwd=/var/log |genseq messages 5}}&lt;br /&gt;
messages.5 messages.4 messages.3 messages.2 messages.1 messages.0 messages&lt;br /&gt;
{{cliop | pwd=/var/log |}}&lt;br /&gt;
{{closp}}&lt;br /&gt;
&lt;br /&gt;
While we could use this list directly, it's still a bit awkward to type:&lt;br /&gt;
&lt;br /&gt;
{{cli | pwd=/var/log |cat $(genseq messages 5)}}&lt;br /&gt;
&lt;br /&gt;
Especially when piping to &amp;lt;code&amp;gt;grep&amp;lt;/code&amp;gt; and maybe &amp;lt;code&amp;gt;less&amp;lt;/code&amp;gt;, so let's make a helper function:&lt;br /&gt;
&lt;br /&gt;
{{cli | pwd=/var/log |&amp;lt;nowiki&amp;gt;function catseq() { cat $(genseq $1 $2); }&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
Okay, now we can just type:&lt;br /&gt;
&lt;br /&gt;
{{cli | pwd=/var/log |catseq messages 5}}&lt;br /&gt;
&lt;br /&gt;
Much easier to type.  We'll use this function from here on.&lt;br /&gt;
&lt;br /&gt;
====Sifting Through Messages====&lt;br /&gt;
&lt;br /&gt;
Here are a few ways you may wish to sift through messages.&lt;br /&gt;
&lt;br /&gt;
=====Checking for Errors, Only=====&lt;br /&gt;
&lt;br /&gt;
If you only want to look for error messages, you might type something like:&lt;br /&gt;
&lt;br /&gt;
{{cli | pwd=/var/log |catseq messages 3 {{!}} grep '\.err '}}&lt;br /&gt;
&lt;br /&gt;
The regular expression used here is to avoid false positives.  Note the trailing space in the regular expression.&lt;br /&gt;
&lt;br /&gt;
=====Checking for Errors and Worse=====&lt;br /&gt;
&lt;br /&gt;
If you want to scan for messages which are of these categories (only):&lt;br /&gt;
* Emergency&lt;br /&gt;
* Alert&lt;br /&gt;
* Critical&lt;br /&gt;
* Error&lt;br /&gt;
You might do the following:&lt;br /&gt;
&lt;br /&gt;
{{cli | pwd=/var/log |catseq messages 3 {{!}} egrep '\.(emerg{{!}}alert{{!}}crit{{!}}err) '}}&lt;br /&gt;
&lt;br /&gt;
Note the use of &amp;lt;code&amp;gt;egrep&amp;lt;/code&amp;gt; here; it is required for this extended regular expression to work.&lt;br /&gt;
&lt;br /&gt;
=====Looking for Certain &amp;lt;code&amp;gt;local&amp;lt;/code&amp;gt; Facility Messages=====&lt;br /&gt;
&lt;br /&gt;
Perhaps you're making use of several of the &amp;lt;code&amp;gt;local&amp;lt;/code&amp;gt; log facilities, and you wish to see all of the messages from just a few of them.  In this example, we'll filter out all but two local facilities: &amp;lt;code&amp;gt;local3&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;local5&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
{{cli | pwd=/var/log |catseq messages 3 {{!}} grep ' local[35]\.'}}&lt;br /&gt;
&lt;br /&gt;
Note the leading space in the regular expression.  The 3 and 5 are listed in between square brackets.  You can list numbers you're interested in individually and/or use ranges.  If you wanted to list all &amp;lt;code&amp;gt;local&amp;lt;/code&amp;gt; facility messages except for &amp;lt;code&amp;gt;local4&amp;lt;/code&amp;gt;, you could write:&lt;br /&gt;
&lt;br /&gt;
{{cli | pwd=/var/log |catseq messages 3 {{!}} grep ' local[0-35-7]\.}}&lt;br /&gt;
&lt;br /&gt;
=====Looking for &amp;lt;code&amp;gt;local&amp;lt;/code&amp;gt; Facility Messages of a Certain Priority=====&lt;br /&gt;
&lt;br /&gt;
While you're debugging your application, you find that you need to see all events from certain &amp;lt;code&amp;gt;local&amp;lt;/code&amp;gt; facilities which are of a subset of priority levels, because you're sure you'll figure out what's going wrong if you can get these specific messages.  So, you ignore the mumblings of your coworkers about, &amp;quot;famous last words,&amp;quot; and such, and you type:&lt;br /&gt;
&lt;br /&gt;
{{cli | pwd=/var/log |catseq messages 3 {{!}} egrep ' local([0-246]\.(err{{!}}notice{{!}}warn){{!}}[357]\.(emerg{{!}}alert)) '}}&lt;br /&gt;
&lt;br /&gt;
By cleverly crafting this complex regular expression, you were able to filter out exactly the right messages you needed to see the sequence of events leading up to the catastrophic failure you were experiencing and save the day.  Your coworkers cheer and hoist you on their shoulders, singing your praises.  &lt;br /&gt;
&lt;br /&gt;
Okay, so in reality, nobody notices and you go to lunch happily, knowing that you're not going to get yelled at for a major fault.  You treat yourself to some dessert (because, hey, why should Fido be the only one who gets a treat for doing something right?), and everyone's happy.&lt;br /&gt;
&lt;br /&gt;
Of course, you wouldn't have been able to properly diagnose what went wrong without having generated good log messages from your software in the first place.  The next section shows you how to generate the messages; you'll have to figure out how to make them good messages on your own, though.&lt;br /&gt;
&lt;br /&gt;
===Writing to Syslog from Programs and Scripts===&lt;br /&gt;
As mentioned previously, many languages support writing to the Linux system logging daemon.  There are many handy libraries and functions which provide this capability.  Some of the most commonly used ones are shown here.&lt;br /&gt;
&lt;br /&gt;
====Shell Utility: &amp;lt;code&amp;gt;logger&amp;lt;/code&amp;gt;====&lt;br /&gt;
Whether you are writing a shell script, or simply wishing to enter something into the system logs from the commandline, the &amp;lt;code&amp;gt;logger&amp;lt;/code&amp;gt; utility will give you the capability you need.  This simple command takes a few options, but it can also be run with the only argument being the message to log.&lt;br /&gt;
&lt;br /&gt;
=====Arguments to &amp;lt;code&amp;gt;logger&amp;lt;/code&amp;gt;=====&lt;br /&gt;
&lt;br /&gt;
The following options are available for &amp;lt;code&amp;gt;logger&amp;lt;/code&amp;gt;:&lt;br /&gt;
;&amp;lt;code&amp;gt;-t&amp;lt;/code&amp;gt; ''TAG''&lt;br /&gt;
: Takes a ''TAG'' as an argument.  This option specifies a tag to use for labeling the message.  Tags are useful for sorting through logs later on.&lt;br /&gt;
;&amp;lt;code&amp;gt;-p&amp;lt;/code&amp;gt; ''Priority''&lt;br /&gt;
: Takes a ''Priority'' as an argument.  The priority may be specified as just a numeric priority level, identifying the severity of the message, or it can be specified as a tuple containing a facility name and a priority level, delimited by a dot (&amp;lt;code&amp;gt;.&amp;lt;/code&amp;gt;).  If no facility is specified, the facility defaults to, &amp;lt;code&amp;gt;user&amp;lt;/code&amp;gt;.  The severity levels are specified in [[System_Logging#Severity | severity]] above.  The facility names are specified in [[System_Logging#Facilities | facilities]] above.&lt;br /&gt;
;&amp;lt;code&amp;gt;-s&amp;lt;/code&amp;gt;&lt;br /&gt;
: This option sets a boolean which enables logging messages to &amp;lt;code&amp;gt;stdout&amp;lt;/code&amp;gt; as well as to the system logger.  This is especially useful in interactive shell scripts, since it allows the developer to use one function to output a message to the screen and to the system logs simultaneously.&lt;br /&gt;
&lt;br /&gt;
=====Examples of Using &amp;lt;code&amp;gt;logger&amp;lt;/code&amp;gt;=====&lt;br /&gt;
&lt;br /&gt;
To send a message to the system log as simply as possible:&lt;br /&gt;
{{clo}}&lt;br /&gt;
{{clio |logger &amp;quot;Default settings message example&amp;quot;}}&lt;br /&gt;
{{clio |tail -n 1 /var/log/messages}}&lt;br /&gt;
Nov 17 19:20:23 ipac9x25 user.notice root: Default settings message example&lt;br /&gt;
{{clos}}&lt;br /&gt;
&lt;br /&gt;
To send a message to the system log with severity 3 (err):&lt;br /&gt;
{{clo}}&lt;br /&gt;
{{clio |logger -p 3 &amp;quot;This is an example error message&amp;quot;}}&lt;br /&gt;
{{clio |tail -n 1 /var/log/messages}}&lt;br /&gt;
Nov 17 19:22:06 ipac9x25 user.err root: This is an example error message&lt;br /&gt;
{{clos}}&lt;br /&gt;
&lt;br /&gt;
To send a message with the facility, &amp;lt;code&amp;gt;local5&amp;lt;/code&amp;gt;, and the severity 4 (warn):&lt;br /&gt;
{{clo}}&lt;br /&gt;
{{clio |logger -p local5.4 &amp;quot;This is a local5 facility warning message example.&amp;quot;}}&lt;br /&gt;
{{clio |tail -n 1 /var/log/messages}}&lt;br /&gt;
Nov 17 19:23:51 ipac9x25 local5.warn root: This is a local5 facility warning message example.{{clos}}&lt;br /&gt;
To add a tag (highly recommended) to the above, use &amp;lt;code&amp;gt;-t&amp;lt;/code&amp;gt;.  Here, we use the tag, &amp;lt;code&amp;gt;EXAMPLE&amp;lt;/code&amp;gt;:&lt;br /&gt;
{{clo}}&lt;br /&gt;
{{clio |logger -t EXAMPLE -p local5.4 &amp;quot;This is a local5 facility warning message example.&amp;quot;}}&lt;br /&gt;
{{clio |tail -n 1 /var/log/messages}}&lt;br /&gt;
Nov 17 19:25:19 ipac9x25 local5.warn EXAMPLE: This is a local5 facility warning message example.&lt;br /&gt;
{{clos}}&lt;br /&gt;
Notice that the username (&amp;lt;code&amp;gt;root&amp;lt;/code&amp;gt;) was replaced by the tag (&amp;lt;code&amp;gt;EXAMPLE&amp;lt;/code&amp;gt;).  When using tags in a script or program, it is best to come up with a unique tag and create a function for sending messages to the system log with this tag.  That way, you can easily find all messages from just your program/script.  If you have a complex program or set of scripts to debug, you could use multiple tags, but this will be more difficult to search for unless you use the optional &amp;lt;code&amp;gt;syslog-ng&amp;lt;/code&amp;gt; to redirect the messages from your software to distinct files.&lt;br /&gt;
In an interactive script, you might use &amp;lt;code&amp;gt;logger&amp;lt;/code&amp;gt; like this:&lt;br /&gt;
{{clo}}&lt;br /&gt;
{{clio|logger -t EXAMPLE -p local3.6 -s &amp;quot;Successfully wrote new configuration file.&amp;quot;}}&lt;br /&gt;
EXAMPLE: Successfully wrote new configuration file.&lt;br /&gt;
{{clio |tail -n 1 /var/log/messages}}&lt;br /&gt;
Nov 17 19:25:19 ipac9x25 local5.warn EXAMPLE: This is a local5 facility warning message example.&lt;br /&gt;
{{clos}}&lt;br /&gt;
Notice that the message isn't visible in the system log?  This is because the &amp;lt;code&amp;gt;syslogd&amp;lt;/code&amp;gt; daemon on this machine is only configured to log messages which have a severity of 5 or lower.  We might modify the example so that it will be logged, like this:&lt;br /&gt;
{{clo}}&lt;br /&gt;
{{clio|logger -t EXAMPLE -p local3.5 -s &amp;quot;Successfully wrote new configuration file.&amp;quot;}}&lt;br /&gt;
EXAMPLE: Successfully wrote new configuration file.&lt;br /&gt;
{{clio |tail -n 1 /var/log/messages}}&lt;br /&gt;
Nov 17 19:31:37 ipac9x25 local3.notice EXAMPLE: Successfully wrote new configuration file.&lt;br /&gt;
{{clos}}&lt;br /&gt;
&lt;br /&gt;
Now the message has been saved to the system logs as well as displayed on &amp;lt;code&amp;gt;stdout&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
====Writing to Syslog from a C Program====&lt;br /&gt;
There is a standard C function call on Linux for writing to the system logger.  This function, &amp;lt;code&amp;gt;syslog()&amp;lt;/code&amp;gt;, uses a persistent connection to the log facility which can be opened and closed using the associated &amp;lt;code&amp;gt;openlog()&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;closelog()&amp;lt;/code&amp;gt; functions.  However, if the &amp;lt;code&amp;gt;syslog()&amp;lt;/code&amp;gt; function is called without first calling &amp;lt;code&amp;gt;openlog()&amp;lt;/code&amp;gt;, the &amp;lt;code&amp;gt;syslog()&amp;lt;/code&amp;gt; function will open the connection implicitly.&lt;br /&gt;
&lt;br /&gt;
=====Essential Elements=====&lt;br /&gt;
The header file required for these functions is &amp;lt;code&amp;gt;syslog.h&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The relevant functions are:&lt;br /&gt;
&lt;br /&gt;
{{function | name=openlog |&lt;br /&gt;
&amp;lt;code&amp;gt;'''void openlog( const char * ident, int option, int facility )'''&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;The &amp;lt;code&amp;gt;openlog()&amp;lt;/code&amp;gt; function is used to (optionally) open a connection to the log daemon before writing log messages.  If the &amp;lt;code&amp;gt;openlog()&amp;lt;/code&amp;gt; function is called, the &amp;lt;code&amp;gt;closelog()&amp;lt;/code&amp;gt; function must also be called before exiting.  &amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;The following parameters are accepted by this function:&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
:;&amp;lt;code&amp;gt;'''ident'''&amp;lt;/code&amp;gt;&lt;br /&gt;
:: The &amp;lt;code&amp;gt;ident&amp;lt;/code&amp;gt; parameter is an identification string to use for log messages.  This is just like the tag option to the &amp;lt;code&amp;gt;logger&amp;lt;/code&amp;gt; command available from the shell.  If this parameter is &amp;lt;code&amp;gt;null&amp;lt;/code&amp;gt;, the identification string defaults to the name of the process sending the messages.&lt;br /&gt;
:;&amp;lt;code&amp;gt;'''option'''&amp;lt;/code&amp;gt;&lt;br /&gt;
:: The &amp;lt;code&amp;gt;option&amp;lt;/code&amp;gt; parameter is a bit string which accepts the following single bit masks:&lt;br /&gt;
::;&amp;lt;code&amp;gt;'''LOG_PERROR'''&amp;lt;/code&amp;gt;&lt;br /&gt;
::: If on, any log messages sent will also go to the &amp;lt;code&amp;gt;stderr&amp;lt;/code&amp;gt; stream associated with the current process.&lt;br /&gt;
::;&amp;lt;code&amp;gt;'''LOG_CONS'''&amp;lt;/code&amp;gt;&lt;br /&gt;
::: This useful flag causes any messages which were unable to be sent to the system logger (due to any kind of failure) will be sent to the system console instead.&lt;br /&gt;
::;&amp;lt;code&amp;gt;'''LOG_PID'''&amp;lt;/code&amp;gt;&lt;br /&gt;
::: When on, the process ID of the current process will be printed with each log message.  This is especially useful for programs which call &amp;lt;code&amp;gt;fork()&amp;lt;/code&amp;gt; at some point in their lifetime.&lt;br /&gt;
::;&amp;lt;code&amp;gt;'''LOG_NDELAY'''&amp;lt;/code&amp;gt;&lt;br /&gt;
::: This option forces the connection to be established immediately, rather than deferred to a later point (such as at the beginning of the first call to the &amp;lt;code&amp;gt;syslog()&amp;lt;/code&amp;gt; function.)&lt;br /&gt;
:;&amp;lt;code&amp;gt;'''facility'''&amp;lt;/code&amp;gt;&lt;br /&gt;
:: This is the facility to which the log messages should be directed.  The available facilities were described earlier in this document; see [[System_Logging#Facilities | facilities]].&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{function | name=syslog | &lt;br /&gt;
&amp;lt;code&amp;gt;'''void syslog( int facility_priority, const char * format, ... )'''&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;The &amp;lt;code&amp;gt;syslog()&amp;lt;/code&amp;gt; function is the core function for writing messages to the system log.  This function may be called in between calls to &amp;lt;code&amp;gt;openlog()&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;closelog()&amp;lt;/code&amp;gt;, or standalone.  Using this function is very similar to using the standard &amp;lt;code&amp;gt;printf()&amp;lt;/code&amp;gt; function, or is (perhaps) even more similar to the standard &amp;lt;code&amp;gt;fprintf()&amp;lt;/code&amp;gt; function.&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;The following parameters are accepted by this function:&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
:;&amp;lt;code&amp;gt;'''facility_priority'''&amp;lt;/code&amp;gt;&lt;br /&gt;
:: The &amp;lt;code&amp;gt;facility_priority&amp;lt;/code&amp;gt; argument is an integer which will accept any of the following predefined macros: &lt;br /&gt;
::* LOG_USER&lt;br /&gt;
::* LOG_MAIL&lt;br /&gt;
::* LOG_DAEMON&lt;br /&gt;
::* LOG_AUTH&lt;br /&gt;
::* LOG_SYSLOG&lt;br /&gt;
::* LOG_LPR&lt;br /&gt;
::* LOG_NEWS&lt;br /&gt;
::* LOG_UUCP&lt;br /&gt;
::* LOG_CRON&lt;br /&gt;
::* LOG_AUTHPRIV&lt;br /&gt;
::* LOG_FTP&lt;br /&gt;
::* LOG_LOCAL0&lt;br /&gt;
::* LOG_LOCAL1&lt;br /&gt;
::* LOG_LOCAL''2 through 7''...&lt;br /&gt;
:: These facility priorities correspond to the facilities discussed earlier in [[System_Logging#Facilities | facilities]].&lt;br /&gt;
:;&amp;lt;br /&amp;gt;&amp;lt;code&amp;gt;'''format'''&amp;lt;/code&amp;gt;&lt;br /&gt;
:: The &amp;lt;code&amp;gt;format&amp;lt;/code&amp;gt; parameter accepts a string with formatting parameters identical to the kind used for the standard &amp;lt;code&amp;gt;printf()&amp;lt;/code&amp;gt; function.  For information on how to craft such formatting strings, see the &amp;lt;code&amp;gt;printf()&amp;lt;/code&amp;gt; documentation.&lt;br /&gt;
:;&amp;lt;br /&amp;gt;&amp;lt;code&amp;gt;'''...'''&amp;lt;/code&amp;gt; ''(ellipsis operator)''&lt;br /&gt;
:: Any arguments needed for the formatting string are passed here, just like with the standard &amp;lt;code&amp;gt;printf()&amp;lt;/code&amp;gt; function.&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{function | name=closelog |&lt;br /&gt;
&amp;lt;code&amp;gt;'''void closelog( void )'''&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;The &amp;lt;code&amp;gt;closelog()&amp;lt;/code&amp;gt; function must be called before exiting the program, but only if the &amp;lt;code&amp;gt;openlog()&amp;lt;/code&amp;gt; function was called earlier.  The &amp;lt;code&amp;gt;openlog()&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;closelog()&amp;lt;/code&amp;gt; functions should be treated the same as &amp;lt;code&amp;gt;fopen()&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;fclose()&amp;lt;/code&amp;gt;, or &amp;lt;code&amp;gt;malloc()&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;free()&amp;lt;/code&amp;gt;.&lt;br /&gt;
&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
This function takes no arguments.&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{function | name=setlogmask |&lt;br /&gt;
&amp;lt;code&amp;gt;'''int setlogmask( int mask )'''&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;The &amp;lt;code&amp;gt;setlogmask()&amp;lt;/code&amp;gt; function controls what messages get sent to the &amp;lt;code&amp;gt;syslog&amp;lt;/code&amp;gt; server.  While the &amp;lt;code&amp;gt;syslog&amp;lt;/code&amp;gt; server does message filtering of its own, this function prevents the messages from ever reaching the &amp;lt;code&amp;gt;syslog&amp;lt;/code&amp;gt; server.  This type of filtering is good to use in conjunction with debug macros in order to reduce the overhead caused by having ample log messages spread throughout your software.&lt;br /&gt;
&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
Each bit set in the &amp;lt;code&amp;gt;mask&amp;lt;/code&amp;gt; represents a priority level.  If the bit is set, a message of the corresponding priority level will be sent to syslog; otherwise, it won't.  The &amp;lt;code&amp;gt;LOG_MASK&amp;lt;/code&amp;gt; macro is used to translate priority levels into appropriate bits, such as &amp;lt;code&amp;gt;LOG_MASK( LOG_ERROR )&amp;lt;/code&amp;gt;.&lt;br /&gt;
&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
Using the &amp;lt;code&amp;gt;LOG_UPTO&amp;lt;/code&amp;gt; macro is the easiest way to set the mask.  Since the most critical error message has a value of zero, and every less critical message has a value greater than zero, the &amp;lt;code&amp;gt;LOG_UPTO&amp;lt;/code&amp;gt; macro will create a mask which passes the given priority level and anything more severe.  For example, to pass messages which have a severity of Warning or worse, you may use: &amp;lt;code&amp;gt;LOG_UPTO( LOG_WARN )&amp;lt;/code&amp;gt;.&lt;br /&gt;
:;&amp;lt;code&amp;gt;mask&amp;lt;/code&amp;gt;&lt;br /&gt;
:: The &amp;lt;code&amp;gt;mask&amp;lt;/code&amp;gt; parameter is used to determine what messages to pass to &amp;lt;code&amp;gt;syslog&amp;lt;/code&amp;gt;, as described above.&lt;br /&gt;
:;''Returns'': &amp;lt;code&amp;gt;int&amp;lt;/code&amp;gt;&lt;br /&gt;
:: The previously set log mask is returned by the function.  You may safely discard it if you don't intend to restore it later.&lt;br /&gt;
For example:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=C&amp;gt;&lt;br /&gt;
#include &amp;lt;syslog.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
int main( int argc, char ** argv )&lt;br /&gt;
{&lt;br /&gt;
    setlogmask( LOG_UPTO( LOG_WARN ) );&lt;br /&gt;
    syslog( LOG_INFO, &amp;quot;You'll never see me!&amp;quot; );&lt;br /&gt;
    syslog( LOG_WARN, &amp;quot;Now you see me.&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
    return 0;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=====Examples of Using the C &amp;lt;code&amp;gt;syslog()&amp;lt;/code&amp;gt; Function (and Friends)=====&lt;br /&gt;
&lt;br /&gt;
The most simple use of this function is found in the following &amp;lt;code&amp;gt;Hello, World&amp;lt;/code&amp;gt; style program:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=C&amp;gt;&lt;br /&gt;
#include &amp;lt;syslog.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
int main( int argc, char ** argv )&lt;br /&gt;
{&lt;br /&gt;
    syslog( LOG_INFO, &amp;quot;Hello, World from syslog()!&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
    return 0;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note the lack of a newline character.  You should not pass newlines to syslog.  If you do, they will be stripped off.&lt;br /&gt;
&lt;br /&gt;
A slightly more sophisticated use of syslog follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=C&amp;gt;&lt;br /&gt;
#include &amp;lt;syslog.h&amp;gt;&lt;br /&gt;
#include &amp;lt;unistd.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
int main( int argc, char ** argv )&lt;br /&gt;
{&lt;br /&gt;
    int i;&lt;br /&gt;
    // Use &amp;quot;MyEXAMPLE&amp;quot; as the &amp;quot;tag&amp;quot; for messages.  Log output to stderr and to the system log, and include my PID.&lt;br /&gt;
    openlog( &amp;quot;MyEXAMPLE&amp;quot;, LOG_PERROR | LOG_PID );&lt;br /&gt;
    // Let's generate some output.&lt;br /&gt;
    syslog( LOG_WARN, &amp;quot;You have until the count of ten, Mr...&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
    for( i = 10; i &amp;gt; 0; --i )&lt;br /&gt;
    {&lt;br /&gt;
        syslog( LOG_WARN, &amp;quot;%d&amp;quot;, i );&lt;br /&gt;
        sleep( 1 );&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    syslog( LOG_ERR, &amp;quot;I warned you, sir and/or madam.  You almost made an error.  If you'd broken out of this with&amp;quot; );&lt;br /&gt;
    syslog( LOG_ERR, &amp;quot;Control-C, the closelog() call never would have been made.  Whew.  That was a close one.  Next&amp;quot; );&lt;br /&gt;
    syslog( LOG_ERR, &amp;quot;time make sure to catch the SIGINT signal (at the least) and call the closelog() function in&amp;quot; );&lt;br /&gt;
    syslog( LOG_ERR, &amp;quot;your signal handler to such avoid wasteful behavior.&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
    closelog();&lt;br /&gt;
&lt;br /&gt;
    return 0;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /******************************************     Conclusion      ******************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
{{:Templateimpl:conclusion | initials=MD | title=System Logging | desc=The page describes how to system log. | project=OE 5.0 }}&lt;br /&gt;
This article covered quite a bit of territory.  You were given an overview of how logging works on Linux systems.  We then talked about a variety of ways in which people make use of these logs to solve real world problems.  We covered the basics of the standard &amp;lt;code&amp;gt;syslog&amp;lt;/code&amp;gt; system for EMAC OE Linux as well as the alternative, &amp;lt;code&amp;gt;syslog-ng&amp;lt;/code&amp;gt;, and gave an overview of what extras you can gain by installing &amp;lt;code&amp;gt;syslog-ng&amp;lt;/code&amp;gt;.  Next, we went through several examples of searching through messages to find the ones which are relevant to your current needs.  Finally, we covered ways to send messages to the syslog service from software, and from the commandline as well.  We didn't cover all programming languages, but the information presented here should provide a solid enough foundation for you to perform a search on the Internet for a syslog client library for other programming languages, and to make use of what you find quickly and easily.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /******************************************   More Information   *****************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
{{:Templateimpl:moreinfo | initials=MD | title=System Logging | desc=The page describes how to system log. | project=OE 5.0 }}&lt;br /&gt;
* [[Installing_EMAC_OE_5.0_SDK | Installing the EMAC SDK]]&lt;br /&gt;
&lt;br /&gt;
{{:Templateimpl:whatnext | initials=MD | title=System Logging | desc=The page describes how to system log. | project=OE 5.0 }}&lt;br /&gt;
* [[Opkg | Working With the OPKG Package Manager]]&lt;/div&gt;</summary>
		<author><name>Mgloff</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.emacinc.com/index.php?title=Loading_Images_with_U-Boot&amp;diff=5636</id>
		<title>Loading Images with U-Boot</title>
		<link rel="alternate" type="text/html" href="https://wiki.emacinc.com/index.php?title=Loading_Images_with_U-Boot&amp;diff=5636"/>
		<updated>2019-04-15T19:26:35Z</updated>

		<summary type="html">&lt;p&gt;Mgloff: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{#seo:&lt;br /&gt;
|title=Loading Images with U-Boot&lt;br /&gt;
|titlemode=append&lt;br /&gt;
|keywords=U-Boot,OS Image,TFTP Server&lt;br /&gt;
|description=This page describes the process of using U-Boot to load Linux kernel and filesystem images from a TFTP server and save them to the local flash for use during the boot process. &lt;br /&gt;
}}&lt;br /&gt;
While U-Boot is used to load and execute the OS after initial programming, it can also be used to program the OS images to the local flash. This page describes the process of using U-Boot to load Linux kernel and filesystem images from a TFTP server and save them to the local flash for use during the boot process. Review the [[U-Boot Overview]] page for an introduction to U-Boot before continuing.&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
A TFTP server must be accessible on the local network. The specific details of TFTP server setup and configuration can be found on the [[Installing TFTP server]] page. Alternatively, NFS can be used in place of TFTP but will require an NFS server.  Information on how to set up an NFS server [[Setting_up_an_NFS_File_Server | can be found here]].  Please contact EMAC if you need details on how to use NFS instead of TFTP to load images.&lt;br /&gt;
&lt;br /&gt;
== Configuration ==&lt;br /&gt;
In order to load a file using TFTP, U-Boot must be configured to access the local network. Static networking configuration or DHCP can be used on some systems (requires DHCP server). Typically, the IP address of the board and the IP address of the TFTP server are the only settings that need to be defined. The network mask and broadcast address will be determined automatically from these settings, and no default gateway setting is required if the server is on the same subnetwork as the board. Before continuing, determine a valid static network address for your local network; contact your IT department for more information on what address to use if required. The example below shows how to set the IP address of the board to 192.168.2.2 and the TFTP server IP address to 192.168.2.1:&lt;br /&gt;
{{clop}}&amp;lt;nowiki&amp;gt;U-Boot&amp;gt; setenv ipaddr 192.168.2.2&lt;br /&gt;
U-Boot&amp;gt; setenv serverip 192.168.2.1&lt;br /&gt;
U-Boot&amp;gt; saveenv&lt;br /&gt;
Saving Environment to dataflash...&lt;br /&gt;
U-Boot&amp;gt; reset&amp;lt;/nowiki&amp;gt;{{closp}}&lt;br /&gt;
&lt;br /&gt;
Once the network settings have been configured, attempt to ping the TFTP server to test the network connection as illustrated below:&lt;br /&gt;
{{clop}}&amp;lt;nowiki&amp;gt;U-Boot&amp;gt; ping 192.168.2.1&lt;br /&gt;
macb0: link up, 100Mbps full-duplex (lpa: 0x45e1)&lt;br /&gt;
Using macb0 device&lt;br /&gt;
host 192.168.2.1 is alive&amp;lt;/nowiki&amp;gt;{{closp}}&lt;br /&gt;
&lt;br /&gt;
== Loading Images to RAM ==&lt;br /&gt;
Files are loaded directly into RAM through TFTP. In order to load the image, you must know the physical address of the RAM device on the system. Refer to the documentation for your target board if you are unsure what value to use. The U-Boot environment variable &amp;lt;code&amp;gt;loadaddr&amp;lt;/code&amp;gt; should already be set and can be used in place of the hex addresses below. The standard addresses for some common EMAC systems are shown in Table 1 below.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot;|Table 1: Physical RAM Addresses&lt;br /&gt;
|-&lt;br /&gt;
! Product !! RAM Start Address&lt;br /&gt;
|-&lt;br /&gt;
| SoM-9260M || 0x20000000&lt;br /&gt;
|-&lt;br /&gt;
| SoM-9G20M || 0x20000000&lt;br /&gt;
|-&lt;br /&gt;
| SoM-9G45M || 0x70000000&lt;br /&gt;
|-&lt;br /&gt;
| SoM-3517M || 0x82000000&lt;br /&gt;
|-&lt;br /&gt;
| SoM-9x25M || 0x22000000&lt;br /&gt;
|-&lt;br /&gt;
| Ipac-9x25M || 0x22000000&lt;br /&gt;
|-&lt;br /&gt;
| SoM-9G25M || 0x22000000&lt;br /&gt;
|-&lt;br /&gt;
| SoM-A5D35M || 0x22000000&lt;br /&gt;
|-&lt;br /&gt;
| SoM-A5D36M || 0x22000000&lt;br /&gt;
|-&lt;br /&gt;
| SoM-3354M || 0x82000000&lt;br /&gt;
|-&lt;br /&gt;
| SoM-iMX6M || 0x12000000&lt;br /&gt;
|-&lt;br /&gt;
| SoM-iMX6UL || 0x82000000&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{{ warning | Before transferring a file to the system, make sure that it does not exceed the size of the available RAM. }}&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;tftp&amp;lt;/code&amp;gt; U-Boot command is used to transfer files to the system. The command requires two arguments: the address to load the file into and the filename of the image on the TFTP server. The example below demonstrates loading a kernel image named &amp;lt;code&amp;gt;uImage-2.6.30&amp;lt;/code&amp;gt; to RAM on an SoM-9G45M.&lt;br /&gt;
{{clop}}&amp;lt;nowiki&amp;gt;U-Boot&amp;gt; tftp ${loadaddr} uImage-2.6.30&lt;br /&gt;
macb0: link up, 100Mbps full-duplex (lpa: 0x45e1)&lt;br /&gt;
Using macb0 device&lt;br /&gt;
TFTP from server 192.168.2.1; our IP address is 192.168.2.2&lt;br /&gt;
Filename 'uImage-2.6.30'.&lt;br /&gt;
Load address: 0x70000000&lt;br /&gt;
Loading: #################################################################&lt;br /&gt;
         #################################################################&lt;br /&gt;
         #################################################################&lt;br /&gt;
         #################################################################&lt;br /&gt;
         ############################&lt;br /&gt;
done&lt;br /&gt;
Bytes transferred = 1472456 (1677c8 hex)&lt;br /&gt;
U-Boot&amp;gt; printenv filesize&lt;br /&gt;
filesize=1677C8&amp;lt;/nowiki&amp;gt;{{closp}}&lt;br /&gt;
&lt;br /&gt;
{{ note | Note that the &amp;lt;code&amp;gt;filesize&amp;lt;/code&amp;gt; variable has been automatically updated to the size of the file that was loaded.}}&lt;br /&gt;
&lt;br /&gt;
== Executing kernel from RAM ==&lt;br /&gt;
In some situations, it is advantageous to execute the image directly from RAM after loading with TFTP rather than saving to flash. This is especially helpful when testing new Linux kernel images. Furthermore, the boot command can be set such that the image is automatically downloaded and executed on each boot, making testing more efficient.&lt;br /&gt;
&lt;br /&gt;
After loading a bootable image to RAM, you can execute it directly using the &amp;lt;code&amp;gt;bootm&amp;lt;/code&amp;gt; command for a uImage kernel or &amp;lt;code&amp;gt;bootz&amp;lt;/code&amp;gt; for a zImage kernel. For example, after loading the kernel image above, running &amp;lt;code&amp;gt;bootm 0x70000000&amp;lt;/code&amp;gt; would boot the board using the new image without making any changes to the images stored on the flash.&lt;br /&gt;
&lt;br /&gt;
To update the &amp;lt;code&amp;gt;bootcmd&amp;lt;/code&amp;gt; variable to download the image on each boot, simply replace the command used to load the image from flash with the TFTP download command. The following example illustrates this process on an SoM-9G45M module.&lt;br /&gt;
{{clop}}&amp;lt;nowiki&amp;gt;U-Boot&amp;gt; printenv bootcmd&lt;br /&gt;
bootcmd=cp.b 0xC0042000 0x70000000 0x210000; bootm 0x70000000&lt;br /&gt;
U-Boot&amp;gt; setenv bootcmd 'tftp 0x70000000 uImage-2.6.30; bootm 0x70000000'&lt;br /&gt;
U-Boot&amp;gt; saveenv&lt;br /&gt;
Saving Environment to dataflash...&amp;lt;/nowiki&amp;gt;{{closp}}&lt;br /&gt;
&lt;br /&gt;
== Copying to Flash ==&lt;br /&gt;
The process of copying an image from RAM to flash memory differs depending on what type of flash storage devices are available on the system. Many systems have more than one device, such as serial DataFlash and NAND flash. This section explains the process of storing an image to non-volatile storage.&lt;br /&gt;
&lt;br /&gt;
=== NOR Flash ===&lt;br /&gt;
A combination of the &amp;lt;code&amp;gt;erase&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;cp&amp;lt;/code&amp;gt; commands are used to program an image to a NOR flash device. NOR flash is directly memory-mapped to the system at a physical address. Also, each image (U-Boot, bootstrap, kernel, filesystem) must be stored at the correct offset for the system to operate correctly. Refer to the documentation for your hardware for more information on the correct address ranges to use. The &amp;lt;code&amp;gt;flinfo&amp;lt;/code&amp;gt; command can be used to display the addressing of available flash devices on the system.&lt;br /&gt;
&lt;br /&gt;
After loading the image to RAM, the flash device should be erased followed by copying the image to the appropriate offset in the flash. The example below illustrates the commands used to program a new kernel image to a SoM-9260M module. Note the use of the &amp;lt;code&amp;gt;protect off all&amp;lt;/code&amp;gt; command, which is required to unlock the flash on some systems.&lt;br /&gt;
{{clop}}&amp;lt;nowiki&amp;gt;U-Boot&amp;gt; protect off all&lt;br /&gt;
U-Boot&amp;gt; tftp 0x20000000 ${kernel_name}&lt;br /&gt;
U-Boot&amp;gt; erase 0x10100000 0x103fffff&lt;br /&gt;
U-Boot&amp;gt; cp.b 0x20000000 0x10100000 ${filesize}&amp;lt;/nowiki&amp;gt;{{closp}}&lt;br /&gt;
&lt;br /&gt;
{{ note | Note that NOR flash can take a significant amount of time to program if the image size is large.}}&lt;br /&gt;
&lt;br /&gt;
=== Serial DataFlash ===&lt;br /&gt;
Serial DataFlash is an SPI-based NOR flash device that is used on many systems that employ NAND flash as the primary storage device. On these systems, low-level boot code such as the bootstrap, U-Boot, and OS kernel are typically stored on the DataFlash device. As with NOR flash, the &amp;lt;code&amp;gt;flinfo&amp;lt;/code&amp;gt; command can be used to determine the memory addressing layout of the DataFlash device. The &amp;lt;code&amp;gt;erase&amp;lt;/code&amp;gt; command does not support the DataFlash devices and should not be used before programming an image. The &amp;lt;code&amp;gt;cp&amp;lt;/code&amp;gt; command is capable of copying an image from RAM to DataFlash.&lt;br /&gt;
&lt;br /&gt;
The example below illustrates the commands used to copy a kernel image to the DataFlash device on a SoM-9G45M module.&lt;br /&gt;
{{clop}}&amp;lt;nowiki&amp;gt;U-Boot&amp;gt; tftpboot 0x70000000 ${kernel_name}&lt;br /&gt;
U-Boot&amp;gt; cp.b 0x70000000 0xC0042000 ${filesize}&amp;lt;/nowiki&amp;gt;{{closp}}&lt;br /&gt;
&lt;br /&gt;
=== NAND Flash ===&lt;br /&gt;
Generally, NAND flash is used to store only the root filesystem and auxiliary storage partitions of the OS. Storing an image to NAND flash under U-Boot uses a different set of commands than NOR or DataFlash devices. See &amp;lt;code&amp;gt;help nand&amp;lt;/code&amp;gt; for more information on the available commands for examining and manipulating NAND flash devices. To gain information on what NAND devices are available on the system, use the command &amp;lt;code&amp;gt;nand info&amp;lt;/code&amp;gt;. In general, programming a NAND flash device is much faster than programming NOR or DataFlash devices.&lt;br /&gt;
&lt;br /&gt;
The example below illustrates the process of loading the root JFFS2 filesystem onto an SoM-9G45M device. Note that the device is erased prior to programming it.&lt;br /&gt;
{{clop}}&amp;lt;nowiki&amp;gt;U-Boot&amp;gt; nand erase&lt;br /&gt;
U-Boot&amp;gt; tftp 0x70000000 ${rootfs_name}&lt;br /&gt;
U-Boot&amp;gt; nand write.jffs2 0x70000000 0x0 ${filesize}&amp;lt;/nowiki&amp;gt;{{closp}}&lt;br /&gt;
&lt;br /&gt;
=== SPI NOR/eMMC Flash ===&lt;br /&gt;
Most of EMAC's newer SoM offerings utilize an eMMC flash for filesystem and auxiliary storage partitions of the OS and an SPI flash to store the bootloader and kernel. To reprogram the eMMC, see [[Loading_Images_onto_eMMC_Devices|Loading Images onto eMMC Devices]]. Be sure that the &amp;lt;code&amp;gt;loadaddr&amp;lt;/code&amp;gt; variable is set and matches the table above. The example below illustrates the commands used to program a new kernel image to a SoM-9x25M module. &lt;br /&gt;
{{clop}}&amp;lt;nowiki&amp;gt;U-Boot&amp;gt; pri loadaddr&lt;br /&gt;
U-Boot&amp;gt; tftp ${loadaddr} zImage&lt;br /&gt;
U-Boot&amp;gt; sf probe;sf erase 0x100000 +${filesize};sf write ${loadaddr} 0x100000 ${filesize}&lt;br /&gt;
U-Boot&amp;gt; setenv kernelsize ${filesize};saveenv&amp;lt;/nowiki&amp;gt;{{closp}}&lt;br /&gt;
&lt;br /&gt;
Note: the &amp;quot;pri loadaddr&amp;quot; step above is not required it is just entered to make sure the variable is set.&lt;br /&gt;
&lt;br /&gt;
== Scripting ==&lt;br /&gt;
U-Boot also includes a scripting feature that allows a script file with U-Boot commands to be loaded and executed. This can make the task of programming multiple systems much more efficient. The &amp;lt;code&amp;gt;mkimage&amp;lt;/code&amp;gt; utility is required on a Linux development system in order to create a valid U-Boot image from a script. This section gives a brief example of a U-Boot script for programming a Linux kernel and filesystem.&lt;br /&gt;
&lt;br /&gt;
Creating a text file with all of the desired commands is the first step in creating a U-Boot script. The example below is a script file used by EMAC to program SoM-9260M modules:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=php&amp;gt;&lt;br /&gt;
echo ===== Setting Environment =====&lt;br /&gt;
setenv bootdelay 1&lt;br /&gt;
setenv rev sl013-aon-30010&lt;br /&gt;
setenv bootargs 'console=ttyS3,115200 root=/dev/mtdblock3 rootfstype=jffs2'&lt;br /&gt;
setenv kernel_name ${rev}-uImage&lt;br /&gt;
setenv rootfs_name sl013-aon-emac-image-SOM9260M.jffs2&lt;br /&gt;
saveenv&lt;br /&gt;
echo ===== Loading Kernel =====&lt;br /&gt;
protect off all&lt;br /&gt;
tftpboot 0x20000000 ${kernel_name}&lt;br /&gt;
erase 0x10100000 0x103fffff&lt;br /&gt;
cp.b 0x20000000 0x10100000 ${filesize}&lt;br /&gt;
setenv kernelsize ${filesize}&lt;br /&gt;
echo ===== Loading Root Filesystem =====&lt;br /&gt;
tftpboot 0x20000000 ${rootfs_name}&lt;br /&gt;
erase 0x10400000 0x11ffffff&lt;br /&gt;
cp.b 0x20000000 0x10400000 ${filesize}&lt;br /&gt;
setenv bootcmd 'protect off all;cp.b 0x10100000 0x20000000 ${kernelsize};bootm 0x20000000'&lt;br /&gt;
saveenv&lt;br /&gt;
echo ===== DONE! =====&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Once the file has been created and saved, the &amp;lt;code&amp;gt;mkimage&amp;lt;/code&amp;gt; utility must be used to create a U-Boot script image. A shell script such as the one shown below may be used to aid in this process:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/sh&lt;br /&gt;
 &lt;br /&gt;
if [ ! -f &amp;quot;$1&amp;quot; ] || [ $# -lt 2 ]&lt;br /&gt;
then&lt;br /&gt;
        echo &amp;quot;Usage: $0 SCRIPTNAME OUTPUTNAME&amp;quot;&lt;br /&gt;
        exit 1&lt;br /&gt;
fi&lt;br /&gt;
 &lt;br /&gt;
mkimage -T script -C none -A arm -n 'SoM9260 Load Script' -d $1 $2&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that the script assumes that &amp;lt;code&amp;gt;mkimage&amp;lt;/code&amp;gt; is installed in the user's PATH. The script should be run with the name of the existing file as the first argument and the desired output filename as the second argument:&lt;br /&gt;
{{cli|username=developer|hostname=ldc|./script_mkimage.sh sl013-aon-30010-flash-script sl013-aon-30010-flash-script.img}}&lt;br /&gt;
&lt;br /&gt;
Once an image file has been created, it should be copied to the TFTP server root directory, in this example &amp;lt;code&amp;gt;/srv/tftp&amp;lt;/code&amp;gt; is used.&lt;br /&gt;
{{cli|username=developer|hostname=ldc|sudo cp sl013-aon-30010-flash-script.img /srv/tftp/}}&lt;br /&gt;
&lt;br /&gt;
The image file can now be transferred to the board and executed as illustrated below:&lt;br /&gt;
{{clop}}&amp;lt;nowiki&amp;gt;U-Boot&amp;gt; tftp 0x20000000 sl013-aon-30010-flash-script.img&lt;br /&gt;
U-Boot&amp;gt; source 0x20000000&amp;lt;/nowiki&amp;gt;{{closp}}&lt;br /&gt;
&lt;br /&gt;
{{ note | Note that the U-Boot command &amp;lt;code&amp;gt;source&amp;lt;/code&amp;gt; was not available on older versions of U-Boot. If the command is not recognized, use &amp;lt;code&amp;gt;autoscr&amp;lt;/code&amp;gt; instead.}}&lt;br /&gt;
&lt;br /&gt;
U-Boot will execute all commands in the script line-by-line until the script has finished, at which point the U-boot prompt will be returned to the user.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /******************************************     Conclusion      ******************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
{{:Templateimpl:conclusion | initials=MD | title=System Logging | desc=The page describes how to system log. | project=OE 5.0 }}&lt;br /&gt;
In this article, you have seen how to load an image into RAM using U-Boot.  You have seen how to execute an image from RAM.  You have also seen how to copy an image from RAM to flash; how to configure your system to boot from an image once it has been saved to flash is documented elsewhere (see Related Information, below).  You have also seen a brief description of how to create scripts for U-Boot.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
With the information provided by this document, you are set to begin loading alternate kernels and filesystems onto EMAC hardware.  These kernels and filesystems could be alternatives provided to you by EMAC, or they could be ones you create yourself.  This provides you with a great deal of flexibility for your development work.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /******************************************   More Information   *****************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
{{:Templateimpl:moreinfo | initials=MD | title=System Logging | desc=The page describes how to system log. | project=OE 5.0 }}&lt;br /&gt;
* [[Loading_Linux_Kernels_Onto_a_Board | Loading Linux Kernels Onto a Board]]&lt;br /&gt;
* [[Loading_JFFS2_Images_Onto_a_Board | Loading JFFS2 Images Onto a Board]]&lt;br /&gt;
* [[Archiving_JFFS2_Images | Archiving JFFS2 Images]]&lt;br /&gt;
&lt;br /&gt;
{{:Templateimpl:whatnext | initials=MD | title=System Logging | desc=The page describes how to system log. | project=OE 5.0 }}&lt;br /&gt;
* [[U-Boot_Overview | U-Boot Overview]]&lt;br /&gt;
* [[Creating_JFFS2_Images | Creating JFFS2 Images]]&lt;br /&gt;
* [[Mounting_JFFS2_Images_on_a_Linux_PC | Mounting JFFS2 Images on a Linux PC]]&lt;br /&gt;
* [[Repartitioning_NAND_Flash_with_JFFS2_for_Linux | Repartitioning NAND Flash with JFFS2 for Linux]]&lt;br /&gt;
* [[Loading_Images_onto_eMMC_Devices | Loading Images onto eMMC Devices]]&lt;br /&gt;
* [[Booting_with_an_NFS_Root_Filesystem | Booting with an NFS Root Filesystem]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--[[Category:Bootloaders]]--&amp;gt;&lt;/div&gt;</summary>
		<author><name>Mgloff</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.emacinc.com/index.php?title=Loading_Images_with_U-Boot&amp;diff=5635</id>
		<title>Loading Images with U-Boot</title>
		<link rel="alternate" type="text/html" href="https://wiki.emacinc.com/index.php?title=Loading_Images_with_U-Boot&amp;diff=5635"/>
		<updated>2019-04-15T17:39:17Z</updated>

		<summary type="html">&lt;p&gt;Mgloff: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{todo|Complete (12.16.13-01:25-&amp;gt;MD-);(12.31.13-11:02-&amp;gt;MW+);(12.31.13-11:30-&amp;gt;KY+);(12.31.13-11:35-&amp;gt;MG+);(03.06.14-15:30-&amp;gt;BS-);(04.11.14-15:55-&amp;gt;BS+)(11.06.15-12:45-&amp;gt;MG+)(11.13.2015-13:25-&amp;gt;MD-);(11.13.2015-16:39-&amp;gt;ER+);(11.13.2015-17:30-&amp;gt;MD+);(11.17.2015-13:50-&amp;gt;KY+);(11.17.2015-14:30-&amp;gt;MG+)|Michael Welling|project=oe 4,oe 5,mw,md,ky,mg,bs,er,Complete}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- NOTE: WE ARE STILL MISSING THE FOLLOWING CONTENT:&lt;br /&gt;
&lt;br /&gt;
* How to configure a machine to load a kernel/filesystem from flash&lt;br /&gt;
* How to save a kernel from flash&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{#seo:&lt;br /&gt;
|title=Loading Images with U-Boot&lt;br /&gt;
|titlemode=append&lt;br /&gt;
|keywords=U-Boot,OS Image,TFTP Server&lt;br /&gt;
|description=This page describes the process of using U-Boot to load Linux kernel and filesystem images from a TFTP server and save them to the local flash for use during the boot process. &lt;br /&gt;
}}&lt;br /&gt;
While U-Boot is used to load and execute the OS after initial programming, it can also be used to program the OS images to the local flash. This page describes the process of using U-Boot to load Linux kernel and filesystem images from a TFTP server and save them to the local flash for use during the boot process. Review the [[U-Boot Overview]] page for an introduction to U-Boot before continuing.&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
A TFTP server must be accessible on the local network. The specific details of TFTP server setup and configuration can be found on the [[Installing TFTP server]] page. Alternatively, NFS can be used in place of TFTP but will require an NFS server.  Information on how to set up an NFS server [[Setting_up_an_NFS_File_Server | can be found here]].  Please contact EMAC if you need details on how to use NFS instead of TFTP to load images.&lt;br /&gt;
&lt;br /&gt;
== Configuration ==&lt;br /&gt;
In order to load a file using TFTP, U-Boot must be configured to access the local network. Static networking configuration or DHCP can be used on some systems (requires DHCP server). Typically, the IP address of the board and the IP address of the TFTP server are the only settings that need to be defined. The network mask and broadcast address will be determined automatically from these settings, and no default gateway setting is required if the server is on the same subnetwork as the board. Before continuing, determine a valid static network address for your local network; contact your IT department for more information on what address to use if required. The example below shows how to set the IP address of the board to 192.168.2.2 and the TFTP server IP address to 192.168.2.1:&lt;br /&gt;
{{clop}}&amp;lt;nowiki&amp;gt;U-Boot&amp;gt; setenv ipaddr 192.168.2.2&lt;br /&gt;
U-Boot&amp;gt; setenv serverip 192.168.2.1&lt;br /&gt;
U-Boot&amp;gt; saveenv&lt;br /&gt;
Saving Environment to dataflash...&lt;br /&gt;
U-Boot&amp;gt; reset&amp;lt;/nowiki&amp;gt;{{closp}}&lt;br /&gt;
&lt;br /&gt;
Once the network settings have been configured, attempt to ping the TFTP server to test the network connection as illustrated below:&lt;br /&gt;
{{clop}}&amp;lt;nowiki&amp;gt;U-Boot&amp;gt; ping 192.168.2.1&lt;br /&gt;
macb0: link up, 100Mbps full-duplex (lpa: 0x45e1)&lt;br /&gt;
Using macb0 device&lt;br /&gt;
host 192.168.2.1 is alive&amp;lt;/nowiki&amp;gt;{{closp}}&lt;br /&gt;
&lt;br /&gt;
== Loading Images to RAM ==&lt;br /&gt;
Files are loaded directly into RAM through TFTP. In order to load the image, you must know the physical address of the RAM device on the system. Refer to the documentation for your target board if you are unsure what value to use. The standard addresses for some common EMAC systems are shown in Table 1 below.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot;|Table 1: Physical RAM Addresses&lt;br /&gt;
|-&lt;br /&gt;
! Product !! RAM Start Address&lt;br /&gt;
|-&lt;br /&gt;
| SoM-9260M || 0x20000000&lt;br /&gt;
|-&lt;br /&gt;
| SoM-9G20M || 0x20000000&lt;br /&gt;
|-&lt;br /&gt;
| SoM-9G45M || 0x70000000&lt;br /&gt;
|-&lt;br /&gt;
| SoM-3517M || 0x82000000&lt;br /&gt;
|-&lt;br /&gt;
| SoM-9x25M || 0x22000000&lt;br /&gt;
|-&lt;br /&gt;
| Ipac-9x25M || 0x22000000&lt;br /&gt;
|-&lt;br /&gt;
| SoM-9G25M || 0x22000000&lt;br /&gt;
|-&lt;br /&gt;
| SoM-A5D35M || 0x22000000&lt;br /&gt;
|-&lt;br /&gt;
| SoM-A5D36M || 0x22000000&lt;br /&gt;
|-&lt;br /&gt;
| SoM-3354M || 0x82000000&lt;br /&gt;
|-&lt;br /&gt;
| SoM-iMX6M || 0x12000000&lt;br /&gt;
|-&lt;br /&gt;
| SoM-iMX6UL || 0x82000000&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{{ warning | Before transferring a file to the system, make sure that it does not exceed the size of the available RAM. }}&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;tftp&amp;lt;/code&amp;gt; U-Boot command is used to transfer files to the system. The command requires two arguments: the address to load the file into and the filename of the image on the TFTP server. The example below demonstrates loading a kernel image named &amp;lt;code&amp;gt;uImage-2.6.30&amp;lt;/code&amp;gt; to RAM on an SoM-9G45M.&lt;br /&gt;
{{clop}}&amp;lt;nowiki&amp;gt;U-Boot&amp;gt; tftp 0x70000000 uImage-2.6.30&lt;br /&gt;
macb0: link up, 100Mbps full-duplex (lpa: 0x45e1)&lt;br /&gt;
Using macb0 device&lt;br /&gt;
TFTP from server 192.168.2.1; our IP address is 192.168.2.2&lt;br /&gt;
Filename 'uImage-2.6.30'.&lt;br /&gt;
Load address: 0x70000000&lt;br /&gt;
Loading: #################################################################&lt;br /&gt;
         #################################################################&lt;br /&gt;
         #################################################################&lt;br /&gt;
         #################################################################&lt;br /&gt;
         ############################&lt;br /&gt;
done&lt;br /&gt;
Bytes transferred = 1472456 (1677c8 hex)&lt;br /&gt;
U-Boot&amp;gt; printenv filesize&lt;br /&gt;
filesize=1677C8&amp;lt;/nowiki&amp;gt;{{closp}}&lt;br /&gt;
&lt;br /&gt;
{{ note | Note that the &amp;lt;code&amp;gt;filesize&amp;lt;/code&amp;gt; variable has been automatically updated to the size of the file that was loaded.}}&lt;br /&gt;
&lt;br /&gt;
== Executing kernel from RAM ==&lt;br /&gt;
In some situations, it is advantageous to execute the image directly from RAM after loading with TFTP rather than saving to flash. This is especially helpful when testing new Linux kernel images. Furthermore, the boot command can be set such that the image is automatically downloaded and executed on each boot, making testing more efficient.&lt;br /&gt;
&lt;br /&gt;
After loading a bootable image to RAM, you can execute it directly using the &amp;lt;code&amp;gt;bootm&amp;lt;/code&amp;gt; command for a uImage kernel or &amp;lt;code&amp;gt;bootz&amp;lt;/code&amp;gt; for a zImage kernel. For example, after loading the kernel image above, running &amp;lt;code&amp;gt;bootm 0x70000000&amp;lt;/code&amp;gt; would boot the board using the new image without making any changes to the images stored on the flash.&lt;br /&gt;
&lt;br /&gt;
To update the &amp;lt;code&amp;gt;bootcmd&amp;lt;/code&amp;gt; variable to download the image on each boot, simply replace the command used to load the image from flash with the TFTP download command. The following example illustrates this process on an SoM-9G45M module.&lt;br /&gt;
{{clop}}&amp;lt;nowiki&amp;gt;U-Boot&amp;gt; printenv bootcmd&lt;br /&gt;
bootcmd=cp.b 0xC0042000 0x70000000 0x210000; bootm 0x70000000&lt;br /&gt;
U-Boot&amp;gt; setenv bootcmd 'tftp 0x70000000 uImage-2.6.30; bootm 0x70000000'&lt;br /&gt;
U-Boot&amp;gt; saveenv&lt;br /&gt;
Saving Environment to dataflash...&amp;lt;/nowiki&amp;gt;{{closp}}&lt;br /&gt;
&lt;br /&gt;
== Copying to Flash ==&lt;br /&gt;
The process of copying an image from RAM to flash memory differs depending on what type of flash storage devices are available on the system. Many systems have more than one device, such as serial DataFlash and NAND flash. This section explains the process of storing an image to non-volatile storage.&lt;br /&gt;
&lt;br /&gt;
=== NOR Flash ===&lt;br /&gt;
A combination of the &amp;lt;code&amp;gt;erase&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;cp&amp;lt;/code&amp;gt; commands are used to program an image to a NOR flash device. NOR flash is directly memory-mapped to the system at a physical address. Also, each image (U-Boot, bootstrap, kernel, filesystem) must be stored at the correct offset for the system to operate correctly. Refer to the documentation for your hardware for more information on the correct address ranges to use. The &amp;lt;code&amp;gt;flinfo&amp;lt;/code&amp;gt; command can be used to display the addressing of available flash devices on the system.&lt;br /&gt;
&lt;br /&gt;
After loading the image to RAM, the flash device should be erased followed by copying the image to the appropriate offset in the flash. The example below illustrates the commands used to program a new kernel image to a SoM-9260M module. Note the use of the &amp;lt;code&amp;gt;protect off all&amp;lt;/code&amp;gt; command, which is required to unlock the flash on some systems.&lt;br /&gt;
{{clop}}&amp;lt;nowiki&amp;gt;U-Boot&amp;gt; protect off all&lt;br /&gt;
U-Boot&amp;gt; tftp 0x20000000 ${kernel_name}&lt;br /&gt;
U-Boot&amp;gt; erase 0x10100000 0x103fffff&lt;br /&gt;
U-Boot&amp;gt; cp.b 0x20000000 0x10100000 ${filesize}&amp;lt;/nowiki&amp;gt;{{closp}}&lt;br /&gt;
&lt;br /&gt;
{{ note | Note that NOR flash can take a significant amount of time to program if the image size is large.}}&lt;br /&gt;
&lt;br /&gt;
=== Serial DataFlash ===&lt;br /&gt;
Serial DataFlash is an SPI-based NOR flash device that is used on many systems that employ NAND flash as the primary storage device. On these systems, low-level boot code such as the bootstrap, U-Boot, and OS kernel are typically stored on the DataFlash device. As with NOR flash, the &amp;lt;code&amp;gt;flinfo&amp;lt;/code&amp;gt; command can be used to determine the memory addressing layout of the DataFlash device. The &amp;lt;code&amp;gt;erase&amp;lt;/code&amp;gt; command does not support the DataFlash devices and should not be used before programming an image. The &amp;lt;code&amp;gt;cp&amp;lt;/code&amp;gt; command is capable of copying an image from RAM to DataFlash.&lt;br /&gt;
&lt;br /&gt;
The example below illustrates the commands used to copy a kernel image to the DataFlash device on a SoM-9G45M module.&lt;br /&gt;
{{clop}}&amp;lt;nowiki&amp;gt;U-Boot&amp;gt; tftpboot 0x70000000 ${kernel_name}&lt;br /&gt;
U-Boot&amp;gt; cp.b 0x70000000 0xC0042000 ${filesize}&amp;lt;/nowiki&amp;gt;{{closp}}&lt;br /&gt;
&lt;br /&gt;
=== NAND Flash ===&lt;br /&gt;
Generally, NAND flash is used to store only the root filesystem and auxiliary storage partitions of the OS. Storing an image to NAND flash under U-Boot uses a different set of commands than NOR or DataFlash devices. See &amp;lt;code&amp;gt;help nand&amp;lt;/code&amp;gt; for more information on the available commands for examining and manipulating NAND flash devices. To gain information on what NAND devices are available on the system, use the command &amp;lt;code&amp;gt;nand info&amp;lt;/code&amp;gt;. In general, programming a NAND flash device is much faster than programming NOR or DataFlash devices.&lt;br /&gt;
&lt;br /&gt;
The example below illustrates the process of loading the root JFFS2 filesystem onto an SoM-9G45M device. Note that the device is erased prior to programming it.&lt;br /&gt;
{{clop}}&amp;lt;nowiki&amp;gt;U-Boot&amp;gt; nand erase&lt;br /&gt;
U-Boot&amp;gt; tftp 0x70000000 ${rootfs_name}&lt;br /&gt;
U-Boot&amp;gt; nand write.jffs2 0x70000000 0x0 ${filesize}&amp;lt;/nowiki&amp;gt;{{closp}}&lt;br /&gt;
&lt;br /&gt;
=== SPI NOR/eMMC Flash ===&lt;br /&gt;
Most of EMAC's newer SoM offerings utilize an eMMC flash for filesystem and auxiliary storage partitions of the OS and an SPI flash to store the bootloader and kernel. To reprogram the eMMC, see [[Loading_Images_onto_eMMC_Devices|Loading Images onto eMMC Devices]]. Be sure that the &amp;lt;code&amp;gt;loadaddr&amp;lt;/code&amp;gt; variable is set and matches the table above. The example below illustrates the commands used to program a new kernel image to a SoM-9x25M module. &lt;br /&gt;
{{clop}}&amp;lt;nowiki&amp;gt;U-Boot&amp;gt; pri loadaddr&lt;br /&gt;
U-Boot&amp;gt; tftp ${loadaddr} zImage&lt;br /&gt;
U-Boot&amp;gt; sf probe;sf erase 0x100000 +${filesize};sf write ${loadaddr} 0x100000 ${filesize}&lt;br /&gt;
U-Boot&amp;gt; setenv kernelsize ${filesize};saveenv&amp;lt;/nowiki&amp;gt;{{closp}}&lt;br /&gt;
&lt;br /&gt;
Note: the &amp;quot;pri loadaddr&amp;quot; step above is not required it is just entered to make sure the variable is set.&lt;br /&gt;
&lt;br /&gt;
== Scripting ==&lt;br /&gt;
U-Boot also includes a scripting feature that allows a script file with U-Boot commands to be loaded and executed. This can make the task of programming multiple systems much more efficient. The &amp;lt;code&amp;gt;mkimage&amp;lt;/code&amp;gt; utility is required on a Linux development system in order to create a valid U-Boot image from a script. This section gives a brief example of a U-Boot script for programming a Linux kernel and filesystem.&lt;br /&gt;
&lt;br /&gt;
Creating a text file with all of the desired commands is the first step in creating a U-Boot script. The example below is a script file used by EMAC to program SoM-9260M modules:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=php&amp;gt;&lt;br /&gt;
echo ===== Setting Environment =====&lt;br /&gt;
setenv bootdelay 1&lt;br /&gt;
setenv rev sl013-aon-30010&lt;br /&gt;
setenv bootargs 'console=ttyS3,115200 root=/dev/mtdblock3 rootfstype=jffs2'&lt;br /&gt;
setenv kernel_name ${rev}-uImage&lt;br /&gt;
setenv rootfs_name sl013-aon-emac-image-SOM9260M.jffs2&lt;br /&gt;
saveenv&lt;br /&gt;
echo ===== Loading Kernel =====&lt;br /&gt;
protect off all&lt;br /&gt;
tftpboot 0x20000000 ${kernel_name}&lt;br /&gt;
erase 0x10100000 0x103fffff&lt;br /&gt;
cp.b 0x20000000 0x10100000 ${filesize}&lt;br /&gt;
setenv kernelsize ${filesize}&lt;br /&gt;
echo ===== Loading Root Filesystem =====&lt;br /&gt;
tftpboot 0x20000000 ${rootfs_name}&lt;br /&gt;
erase 0x10400000 0x11ffffff&lt;br /&gt;
cp.b 0x20000000 0x10400000 ${filesize}&lt;br /&gt;
setenv bootcmd 'protect off all;cp.b 0x10100000 0x20000000 ${kernelsize};bootm 0x20000000'&lt;br /&gt;
saveenv&lt;br /&gt;
echo ===== DONE! =====&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Once the file has been created and saved, the &amp;lt;code&amp;gt;mkimage&amp;lt;/code&amp;gt; utility must be used to create a U-Boot script image. A shell script such as the one shown below may be used to aid in this process:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/sh&lt;br /&gt;
 &lt;br /&gt;
if [ ! -f &amp;quot;$1&amp;quot; ] || [ $# -lt 2 ]&lt;br /&gt;
then&lt;br /&gt;
        echo &amp;quot;Usage: $0 SCRIPTNAME OUTPUTNAME&amp;quot;&lt;br /&gt;
        exit 1&lt;br /&gt;
fi&lt;br /&gt;
 &lt;br /&gt;
mkimage -T script -C none -A arm -n 'SoM9260 Load Script' -d $1 $2&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that the script assumes that &amp;lt;code&amp;gt;mkimage&amp;lt;/code&amp;gt; is installed in the user's PATH. The script should be run with the name of the existing file as the first argument and the desired output filename as the second argument:&lt;br /&gt;
{{cli|username=developer|hostname=ldc|./script_mkimage.sh sl013-aon-30010-flash-script sl013-aon-30010-flash-script.img}}&lt;br /&gt;
&lt;br /&gt;
Once an image file has been created, it should be copied to the TFTP server root directory, in this example &amp;lt;code&amp;gt;/srv/tftp&amp;lt;/code&amp;gt; is used.&lt;br /&gt;
{{cli|username=developer|hostname=ldc|sudo cp sl013-aon-30010-flash-script.img /srv/tftp/}}&lt;br /&gt;
&lt;br /&gt;
The image file can now be transferred to the board and executed as illustrated below:&lt;br /&gt;
{{clop}}&amp;lt;nowiki&amp;gt;U-Boot&amp;gt; tftp 0x20000000 sl013-aon-30010-flash-script.img&lt;br /&gt;
U-Boot&amp;gt; source 0x20000000&amp;lt;/nowiki&amp;gt;{{closp}}&lt;br /&gt;
&lt;br /&gt;
{{ note | Note that the U-Boot command &amp;lt;code&amp;gt;source&amp;lt;/code&amp;gt; was not available on older versions of U-Boot. If the command is not recognized, use &amp;lt;code&amp;gt;autoscr&amp;lt;/code&amp;gt; instead.}}&lt;br /&gt;
&lt;br /&gt;
U-Boot will execute all commands in the script line-by-line until the script has finished, at which point the U-boot prompt will be returned to the user.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /******************************************     Conclusion      ******************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
{{:Templateimpl:conclusion | initials=MD | title=System Logging | desc=The page describes how to system log. | project=OE 5.0 }}&lt;br /&gt;
In this article, you have seen how to load an image into RAM using U-Boot.  You have seen how to execute an image from RAM.  You have also seen how to copy an image from RAM to flash; how to configure your system to boot from an image once it has been saved to flash is documented elsewhere (see Related Information, below).  You have also seen a brief description of how to create scripts for U-Boot.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
With the information provided by this document, you are set to begin loading alternate kernels and filesystems onto EMAC hardware.  These kernels and filesystems could be alternatives provided to you by EMAC, or they could be ones you create yourself.  This provides you with a great deal of flexibility for your development work.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /******************************************   More Information   *****************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
{{:Templateimpl:moreinfo | initials=MD | title=System Logging | desc=The page describes how to system log. | project=OE 5.0 }}&lt;br /&gt;
* [[Loading_Linux_Kernels_Onto_a_Board | Loading Linux Kernels Onto a Board]]&lt;br /&gt;
* [[Loading_JFFS2_Images_Onto_a_Board | Loading JFFS2 Images Onto a Board]]&lt;br /&gt;
* [[Archiving_JFFS2_Images | Archiving JFFS2 Images]]&lt;br /&gt;
&lt;br /&gt;
{{:Templateimpl:whatnext | initials=MD | title=System Logging | desc=The page describes how to system log. | project=OE 5.0 }}&lt;br /&gt;
* [[U-Boot_Overview | U-Boot Overview]]&lt;br /&gt;
* [[Creating_JFFS2_Images | Creating JFFS2 Images]]&lt;br /&gt;
* [[Mounting_JFFS2_Images_on_a_Linux_PC | Mounting JFFS2 Images on a Linux PC]]&lt;br /&gt;
* [[Repartitioning_NAND_Flash_with_JFFS2_for_Linux | Repartitioning NAND Flash with JFFS2 for Linux]]&lt;br /&gt;
* [[Loading_Images_onto_eMMC_Devices | Loading Images onto eMMC Devices]]&lt;br /&gt;
* [[Booting_with_an_NFS_Root_Filesystem | Booting with an NFS Root Filesystem]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--[[Category:Bootloaders]]--&amp;gt;&lt;/div&gt;</summary>
		<author><name>Mgloff</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.emacinc.com/index.php?title=Loading_Images_with_U-Boot&amp;diff=5634</id>
		<title>Loading Images with U-Boot</title>
		<link rel="alternate" type="text/html" href="https://wiki.emacinc.com/index.php?title=Loading_Images_with_U-Boot&amp;diff=5634"/>
		<updated>2019-04-15T17:33:24Z</updated>

		<summary type="html">&lt;p&gt;Mgloff: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{todo|Complete (12.16.13-01:25-&amp;gt;MD-);(12.31.13-11:02-&amp;gt;MW+);(12.31.13-11:30-&amp;gt;KY+);(12.31.13-11:35-&amp;gt;MG+);(03.06.14-15:30-&amp;gt;BS-);(04.11.14-15:55-&amp;gt;BS+)(11.06.15-12:45-&amp;gt;MG+)(11.13.2015-13:25-&amp;gt;MD-);(11.13.2015-16:39-&amp;gt;ER+);(11.13.2015-17:30-&amp;gt;MD+);(11.17.2015-13:50-&amp;gt;KY+);(11.17.2015-14:30-&amp;gt;MG+)|Michael Welling|project=oe 4,oe 5,mw,md,ky,mg,bs,er,Complete}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- NOTE: WE ARE STILL MISSING THE FOLLOWING CONTENT:&lt;br /&gt;
&lt;br /&gt;
* How to configure a machine to load a kernel/filesystem from flash&lt;br /&gt;
* How to save a kernel from flash&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{#seo:&lt;br /&gt;
|title=Loading Images with U-Boot&lt;br /&gt;
|titlemode=append&lt;br /&gt;
|keywords=U-Boot,OS Image,TFTP Server&lt;br /&gt;
|description=This page describes the process of using U-Boot to load Linux kernel and filesystem images from a TFTP server and save them to the local flash for use during the boot process. &lt;br /&gt;
}}&lt;br /&gt;
While U-Boot is used to load and execute the OS after initial programming, it can also be used to program the OS images to the local flash. This page describes the process of using U-Boot to load Linux kernel and filesystem images from a TFTP server and save them to the local flash for use during the boot process. Review the [[U-Boot Overview]] page for an introduction to U-Boot before continuing.&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
A TFTP server must be accessible on the local network. The specific details of TFTP server setup and configuration can be found on the [[Installing TFTP server]] page. Alternatively, NFS can be used in place of TFTP but will require an NFS server.  Information on how to set up an NFS server [[Setting_up_an_NFS_File_Server | can be found here]].  Please contact EMAC if you need details on how to use NFS instead of TFTP to load images.&lt;br /&gt;
&lt;br /&gt;
== Configuration ==&lt;br /&gt;
In order to load a file using TFTP, U-Boot must be configured to access the local network. Static networking configuration or DHCP can be used on some systems (requires DHCP server). Typically, the IP address of the board and the IP address of the TFTP server are the only settings that need to be defined. The network mask and broadcast address will be determined automatically from these settings, and no default gateway setting is required if the server is on the same subnetwork as the board. Before continuing, determine a valid static network address for your local network; contact your IT department for more information on what address to use if required. The example below shows how to set the IP address of the board to 192.168.2.2 and the TFTP server IP address to 192.168.2.1:&lt;br /&gt;
{{clop}}&amp;lt;nowiki&amp;gt;U-Boot&amp;gt; setenv ipaddr 192.168.2.2&lt;br /&gt;
U-Boot&amp;gt; setenv serverip 192.168.2.1&lt;br /&gt;
U-Boot&amp;gt; saveenv&lt;br /&gt;
Saving Environment to dataflash...&lt;br /&gt;
U-Boot&amp;gt; reset&amp;lt;/nowiki&amp;gt;{{closp}}&lt;br /&gt;
&lt;br /&gt;
Once the network settings have been configured, attempt to ping the TFTP server to test the network connection as illustrated below:&lt;br /&gt;
{{clop}}&amp;lt;nowiki&amp;gt;U-Boot&amp;gt; ping 192.168.2.1&lt;br /&gt;
macb0: link up, 100Mbps full-duplex (lpa: 0x45e1)&lt;br /&gt;
Using macb0 device&lt;br /&gt;
host 192.168.2.1 is alive&amp;lt;/nowiki&amp;gt;{{closp}}&lt;br /&gt;
&lt;br /&gt;
== Loading Images to RAM ==&lt;br /&gt;
Files are loaded directly into RAM through TFTP. In order to load the image, you must know the physical address of the RAM device on the system. Refer to the documentation for your target board if you are unsure what value to use. The standard addresses for some common EMAC systems are shown in Table 1 below.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot;|Table 1: Physical RAM Addresses&lt;br /&gt;
|-&lt;br /&gt;
! Product !! RAM Start Address&lt;br /&gt;
|-&lt;br /&gt;
| SoM-9260M || 0x20000000&lt;br /&gt;
|-&lt;br /&gt;
| SoM-9G20M || 0x20000000&lt;br /&gt;
|-&lt;br /&gt;
| SoM-9G45M || 0x70000000&lt;br /&gt;
|-&lt;br /&gt;
| SoM-3517M || 0x82000000&lt;br /&gt;
|-&lt;br /&gt;
| SoM-9x25M || 0x22000000&lt;br /&gt;
|-&lt;br /&gt;
| Ipac-9x25M || 0x22000000&lt;br /&gt;
|-&lt;br /&gt;
| SoM-9G25M || 0x22000000&lt;br /&gt;
|-&lt;br /&gt;
| SoM-A5D35M || 0x22000000&lt;br /&gt;
|-&lt;br /&gt;
| SoM-A5D36M || 0x22000000&lt;br /&gt;
|-&lt;br /&gt;
| SoM-3354M || 0x82000000&lt;br /&gt;
|-&lt;br /&gt;
| SoM-iMX6M || 0x12000000&lt;br /&gt;
|-&lt;br /&gt;
| SoM-iMX6UL || 0x82000000&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{{ warning | Before transferring a file to the system, make sure that it does not exceed the size of the available RAM. }}&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;tftp&amp;lt;/code&amp;gt; U-Boot command is used to transfer files to the system. The command requires two arguments: the address to load the file into and the filename of the image on the TFTP server. The example below demonstrates loading a kernel image named &amp;lt;code&amp;gt;uImage-2.6.30&amp;lt;/code&amp;gt; to RAM on an SoM-9G45M.&lt;br /&gt;
{{clop}}&amp;lt;nowiki&amp;gt;U-Boot&amp;gt; tftp 0x70000000 uImage-2.6.30&lt;br /&gt;
macb0: link up, 100Mbps full-duplex (lpa: 0x45e1)&lt;br /&gt;
Using macb0 device&lt;br /&gt;
TFTP from server 192.168.2.1; our IP address is 192.168.2.2&lt;br /&gt;
Filename 'uImage-2.6.30'.&lt;br /&gt;
Load address: 0x70000000&lt;br /&gt;
Loading: #################################################################&lt;br /&gt;
         #################################################################&lt;br /&gt;
         #################################################################&lt;br /&gt;
         #################################################################&lt;br /&gt;
         ############################&lt;br /&gt;
done&lt;br /&gt;
Bytes transferred = 1472456 (1677c8 hex)&lt;br /&gt;
U-Boot&amp;gt; printenv filesize&lt;br /&gt;
filesize=1677C8&amp;lt;/nowiki&amp;gt;{{closp}}&lt;br /&gt;
&lt;br /&gt;
{{ note | Note that the &amp;lt;code&amp;gt;filesize&amp;lt;/code&amp;gt; variable has been automatically updated to the size of the file that was loaded.}}&lt;br /&gt;
&lt;br /&gt;
== Executing kernel from RAM ==&lt;br /&gt;
In some situations, it is advantageous to execute the image directly from RAM after loading with TFTP rather than saving to flash. This is especially helpful when testing new Linux kernel images. Furthermore, the boot command can be set such that the image is automatically downloaded and executed on each boot, making testing more efficient.&lt;br /&gt;
&lt;br /&gt;
After loading a bootable image to RAM, you can execute it directly using the &amp;lt;code&amp;gt;bootm&amp;lt;/code&amp;gt; command. For example, after loading the kernel image above, running &amp;lt;code&amp;gt;bootm 0x70000000&amp;lt;/code&amp;gt; would boot the board using the new image without making any changes to the images stored on the flash.&lt;br /&gt;
&lt;br /&gt;
To update the &amp;lt;code&amp;gt;bootcmd&amp;lt;/code&amp;gt; variable to download the image on each boot, simply replace the command used to load the image from flash with the TFTP download command. The following example illustrates this process on an SoM-9G45M module.&lt;br /&gt;
{{clop}}&amp;lt;nowiki&amp;gt;U-Boot&amp;gt; printenv bootcmd&lt;br /&gt;
bootcmd=cp.b 0xC0042000 0x70000000 0x210000; bootm 0x70000000&lt;br /&gt;
U-Boot&amp;gt; setenv bootcmd 'tftp 0x70000000 uImage-2.6.30; bootm 0x70000000'&lt;br /&gt;
U-Boot&amp;gt; saveenv&lt;br /&gt;
Saving Environment to dataflash...&amp;lt;/nowiki&amp;gt;{{closp}}&lt;br /&gt;
&lt;br /&gt;
== Copying to Flash ==&lt;br /&gt;
The process of copying an image from RAM to flash memory differs depending on what type of flash storage devices are available on the system. Many systems have more than one device, such as serial DataFlash and NAND flash. This section explains the process of storing an image to non-volatile storage.&lt;br /&gt;
&lt;br /&gt;
=== NOR Flash ===&lt;br /&gt;
A combination of the &amp;lt;code&amp;gt;erase&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;cp&amp;lt;/code&amp;gt; commands are used to program an image to a NOR flash device. NOR flash is directly memory-mapped to the system at a physical address. Also, each image (U-Boot, bootstrap, kernel, filesystem) must be stored at the correct offset for the system to operate correctly. Refer to the documentation for your hardware for more information on the correct address ranges to use. The &amp;lt;code&amp;gt;flinfo&amp;lt;/code&amp;gt; command can be used to display the addressing of available flash devices on the system.&lt;br /&gt;
&lt;br /&gt;
After loading the image to RAM, the flash device should be erased followed by copying the image to the appropriate offset in the flash. The example below illustrates the commands used to program a new kernel image to a SoM-9260M module. Note the use of the &amp;lt;code&amp;gt;protect off all&amp;lt;/code&amp;gt; command, which is required to unlock the flash on some systems.&lt;br /&gt;
{{clop}}&amp;lt;nowiki&amp;gt;U-Boot&amp;gt; protect off all&lt;br /&gt;
U-Boot&amp;gt; tftp 0x20000000 ${kernel_name}&lt;br /&gt;
U-Boot&amp;gt; erase 0x10100000 0x103fffff&lt;br /&gt;
U-Boot&amp;gt; cp.b 0x20000000 0x10100000 ${filesize}&amp;lt;/nowiki&amp;gt;{{closp}}&lt;br /&gt;
&lt;br /&gt;
{{ note | Note that NOR flash can take a significant amount of time to program if the image size is large.}}&lt;br /&gt;
&lt;br /&gt;
=== Serial DataFlash ===&lt;br /&gt;
Serial DataFlash is an SPI-based NOR flash device that is used on many systems that employ NAND flash as the primary storage device. On these systems, low-level boot code such as the bootstrap, U-Boot, and OS kernel are typically stored on the DataFlash device. As with NOR flash, the &amp;lt;code&amp;gt;flinfo&amp;lt;/code&amp;gt; command can be used to determine the memory addressing layout of the DataFlash device. The &amp;lt;code&amp;gt;erase&amp;lt;/code&amp;gt; command does not support the DataFlash devices and should not be used before programming an image. The &amp;lt;code&amp;gt;cp&amp;lt;/code&amp;gt; command is capable of copying an image from RAM to DataFlash.&lt;br /&gt;
&lt;br /&gt;
The example below illustrates the commands used to copy a kernel image to the DataFlash device on a SoM-9G45M module.&lt;br /&gt;
{{clop}}&amp;lt;nowiki&amp;gt;U-Boot&amp;gt; tftpboot 0x70000000 ${kernel_name}&lt;br /&gt;
U-Boot&amp;gt; cp.b 0x70000000 0xC0042000 ${filesize}&amp;lt;/nowiki&amp;gt;{{closp}}&lt;br /&gt;
&lt;br /&gt;
=== NAND Flash ===&lt;br /&gt;
Generally, NAND flash is used to store only the root filesystem and auxiliary storage partitions of the OS. Storing an image to NAND flash under U-Boot uses a different set of commands than NOR or DataFlash devices. See &amp;lt;code&amp;gt;help nand&amp;lt;/code&amp;gt; for more information on the available commands for examining and manipulating NAND flash devices. To gain information on what NAND devices are available on the system, use the command &amp;lt;code&amp;gt;nand info&amp;lt;/code&amp;gt;. In general, programming a NAND flash device is much faster than programming NOR or DataFlash devices.&lt;br /&gt;
&lt;br /&gt;
The example below illustrates the process of loading the root JFFS2 filesystem onto an SoM-9G45M device. Note that the device is erased prior to programming it.&lt;br /&gt;
{{clop}}&amp;lt;nowiki&amp;gt;U-Boot&amp;gt; nand erase&lt;br /&gt;
U-Boot&amp;gt; tftp 0x70000000 ${rootfs_name}&lt;br /&gt;
U-Boot&amp;gt; nand write.jffs2 0x70000000 0x0 ${filesize}&amp;lt;/nowiki&amp;gt;{{closp}}&lt;br /&gt;
&lt;br /&gt;
=== SPI NOR/eMMC Flash ===&lt;br /&gt;
Most of EMAC's newer SoM offerings utilize an eMMC flash for filesystem and auxiliary storage partitions of the OS and an SPI flash to store the bootloader and kernel. To reprogram the eMMC, see [[Loading_Images_onto_eMMC_Devices|Loading Images onto eMMC Devices]]. Be sure that the &amp;lt;code&amp;gt;loadaddr&amp;lt;/code&amp;gt; variable is set and matches the table above. The example below illustrates the commands used to program a new kernel image to a SoM-9x25M module. &lt;br /&gt;
{{clop}}&amp;lt;nowiki&amp;gt;U-Boot&amp;gt; pri loadaddr&lt;br /&gt;
U-Boot&amp;gt; tftp ${loadaddr} zImage&lt;br /&gt;
U-Boot&amp;gt; sf probe;sf erase 0x100000 +${filesize};sf write ${loadaddr} 0x100000 ${filesize}&lt;br /&gt;
U-Boot&amp;gt; setenv kernelsize ${filesize};saveenv&amp;lt;/nowiki&amp;gt;{{closp}}&lt;br /&gt;
&lt;br /&gt;
Note: the &amp;quot;pri loadaddr&amp;quot; step above is not required it is just entered to make sure the variable is set.&lt;br /&gt;
&lt;br /&gt;
== Scripting ==&lt;br /&gt;
U-Boot also includes a scripting feature that allows a script file with U-Boot commands to be loaded and executed. This can make the task of programming multiple systems much more efficient. The &amp;lt;code&amp;gt;mkimage&amp;lt;/code&amp;gt; utility is required on a Linux development system in order to create a valid U-Boot image from a script. This section gives a brief example of a U-Boot script for programming a Linux kernel and filesystem.&lt;br /&gt;
&lt;br /&gt;
Creating a text file with all of the desired commands is the first step in creating a U-Boot script. The example below is a script file used by EMAC to program SoM-9260M modules:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=php&amp;gt;&lt;br /&gt;
echo ===== Setting Environment =====&lt;br /&gt;
setenv bootdelay 1&lt;br /&gt;
setenv rev sl013-aon-30010&lt;br /&gt;
setenv bootargs 'console=ttyS3,115200 root=/dev/mtdblock3 rootfstype=jffs2'&lt;br /&gt;
setenv kernel_name ${rev}-uImage&lt;br /&gt;
setenv rootfs_name sl013-aon-emac-image-SOM9260M.jffs2&lt;br /&gt;
saveenv&lt;br /&gt;
echo ===== Loading Kernel =====&lt;br /&gt;
protect off all&lt;br /&gt;
tftpboot 0x20000000 ${kernel_name}&lt;br /&gt;
erase 0x10100000 0x103fffff&lt;br /&gt;
cp.b 0x20000000 0x10100000 ${filesize}&lt;br /&gt;
setenv kernelsize ${filesize}&lt;br /&gt;
echo ===== Loading Root Filesystem =====&lt;br /&gt;
tftpboot 0x20000000 ${rootfs_name}&lt;br /&gt;
erase 0x10400000 0x11ffffff&lt;br /&gt;
cp.b 0x20000000 0x10400000 ${filesize}&lt;br /&gt;
setenv bootcmd 'protect off all;cp.b 0x10100000 0x20000000 ${kernelsize};bootm 0x20000000'&lt;br /&gt;
saveenv&lt;br /&gt;
echo ===== DONE! =====&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Once the file has been created and saved, the &amp;lt;code&amp;gt;mkimage&amp;lt;/code&amp;gt; utility must be used to create a U-Boot script image. A shell script such as the one shown below may be used to aid in this process:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/sh&lt;br /&gt;
 &lt;br /&gt;
if [ ! -f &amp;quot;$1&amp;quot; ] || [ $# -lt 2 ]&lt;br /&gt;
then&lt;br /&gt;
        echo &amp;quot;Usage: $0 SCRIPTNAME OUTPUTNAME&amp;quot;&lt;br /&gt;
        exit 1&lt;br /&gt;
fi&lt;br /&gt;
 &lt;br /&gt;
mkimage -T script -C none -A arm -n 'SoM9260 Load Script' -d $1 $2&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that the script assumes that &amp;lt;code&amp;gt;mkimage&amp;lt;/code&amp;gt; is installed in the user's PATH. The script should be run with the name of the existing file as the first argument and the desired output filename as the second argument:&lt;br /&gt;
{{cli|username=developer|hostname=ldc|./script_mkimage.sh sl013-aon-30010-flash-script sl013-aon-30010-flash-script.img}}&lt;br /&gt;
&lt;br /&gt;
Once an image file has been created, it should be copied to the TFTP server root directory, in this example &amp;lt;code&amp;gt;/srv/tftp&amp;lt;/code&amp;gt; is used.&lt;br /&gt;
{{cli|username=developer|hostname=ldc|sudo cp sl013-aon-30010-flash-script.img /srv/tftp/}}&lt;br /&gt;
&lt;br /&gt;
The image file can now be transferred to the board and executed as illustrated below:&lt;br /&gt;
{{clop}}&amp;lt;nowiki&amp;gt;U-Boot&amp;gt; tftp 0x20000000 sl013-aon-30010-flash-script.img&lt;br /&gt;
U-Boot&amp;gt; source 0x20000000&amp;lt;/nowiki&amp;gt;{{closp}}&lt;br /&gt;
&lt;br /&gt;
{{ note | Note that the U-Boot command &amp;lt;code&amp;gt;source&amp;lt;/code&amp;gt; was not available on older versions of U-Boot. If the command is not recognized, use &amp;lt;code&amp;gt;autoscr&amp;lt;/code&amp;gt; instead.}}&lt;br /&gt;
&lt;br /&gt;
U-Boot will execute all commands in the script line-by-line until the script has finished, at which point the U-boot prompt will be returned to the user.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /******************************************     Conclusion      ******************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
{{:Templateimpl:conclusion | initials=MD | title=System Logging | desc=The page describes how to system log. | project=OE 5.0 }}&lt;br /&gt;
In this article, you have seen how to load an image into RAM using U-Boot.  You have seen how to execute an image from RAM.  You have also seen how to copy an image from RAM to flash; how to configure your system to boot from an image once it has been saved to flash is documented elsewhere (see Related Information, below).  You have also seen a brief description of how to create scripts for U-Boot.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
With the information provided by this document, you are set to begin loading alternate kernels and filesystems onto EMAC hardware.  These kernels and filesystems could be alternatives provided to you by EMAC, or they could be ones you create yourself.  This provides you with a great deal of flexibility for your development work.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /******************************************   More Information   *****************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
{{:Templateimpl:moreinfo | initials=MD | title=System Logging | desc=The page describes how to system log. | project=OE 5.0 }}&lt;br /&gt;
* [[Loading_Linux_Kernels_Onto_a_Board | Loading Linux Kernels Onto a Board]]&lt;br /&gt;
* [[Loading_JFFS2_Images_Onto_a_Board | Loading JFFS2 Images Onto a Board]]&lt;br /&gt;
* [[Archiving_JFFS2_Images | Archiving JFFS2 Images]]&lt;br /&gt;
&lt;br /&gt;
{{:Templateimpl:whatnext | initials=MD | title=System Logging | desc=The page describes how to system log. | project=OE 5.0 }}&lt;br /&gt;
* [[U-Boot_Overview | U-Boot Overview]]&lt;br /&gt;
* [[Creating_JFFS2_Images | Creating JFFS2 Images]]&lt;br /&gt;
* [[Mounting_JFFS2_Images_on_a_Linux_PC | Mounting JFFS2 Images on a Linux PC]]&lt;br /&gt;
* [[Repartitioning_NAND_Flash_with_JFFS2_for_Linux | Repartitioning NAND Flash with JFFS2 for Linux]]&lt;br /&gt;
* [[Loading_Images_onto_eMMC_Devices | Loading Images onto eMMC Devices]]&lt;br /&gt;
* [[Booting_with_an_NFS_Root_Filesystem | Booting with an NFS Root Filesystem]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--[[Category:Bootloaders]]--&amp;gt;&lt;/div&gt;</summary>
		<author><name>Mgloff</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.emacinc.com/index.php?title=Loading_Images_with_U-Boot&amp;diff=5633</id>
		<title>Loading Images with U-Boot</title>
		<link rel="alternate" type="text/html" href="https://wiki.emacinc.com/index.php?title=Loading_Images_with_U-Boot&amp;diff=5633"/>
		<updated>2019-04-15T17:27:27Z</updated>

		<summary type="html">&lt;p&gt;Mgloff: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{todo|Complete (12.16.13-01:25-&amp;gt;MD-);(12.31.13-11:02-&amp;gt;MW+);(12.31.13-11:30-&amp;gt;KY+);(12.31.13-11:35-&amp;gt;MG+);(03.06.14-15:30-&amp;gt;BS-);(04.11.14-15:55-&amp;gt;BS+)(11.06.15-12:45-&amp;gt;MG+)(11.13.2015-13:25-&amp;gt;MD-);(11.13.2015-16:39-&amp;gt;ER+);(11.13.2015-17:30-&amp;gt;MD+);(11.17.2015-13:50-&amp;gt;KY+);(11.17.2015-14:30-&amp;gt;MG+)|Michael Welling|project=oe 4,oe 5,mw,md,ky,mg,bs,er,Complete}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- NOTE: WE ARE STILL MISSING THE FOLLOWING CONTENT:&lt;br /&gt;
&lt;br /&gt;
* How to configure a machine to load a kernel/filesystem from flash&lt;br /&gt;
* How to save a kernel from flash&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{#seo:&lt;br /&gt;
|title=Loading Images with U-Boot&lt;br /&gt;
|titlemode=append&lt;br /&gt;
|keywords=U-Boot,OS Image,TFTP Server&lt;br /&gt;
|description=This page describes the process of using U-Boot to load Linux kernel and filesystem images from a TFTP server and save them to the local flash for use during the boot process. &lt;br /&gt;
}}&lt;br /&gt;
While U-Boot is used to load and execute the OS after initial programming, it can also be used to program the OS images to the local flash. This page describes the process of using U-Boot to load Linux kernel and filesystem images from a TFTP server and save them to the local flash for use during the boot process. Review the [[U-Boot Overview]] page for an introduction to U-Boot before continuing.&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
A TFTP server must be accessible on the local network. The specific details of TFTP server setup and configuration can be found on the [[Installing TFTP server]] page. Alternatively, NFS can be used in place of TFTP but will require an NFS server.  Information on how to set up an NFS server [[Setting_up_an_NFS_File_Server | can be found here]].  Please contact EMAC if you need details on how to use NFS instead of TFTP to load images.&lt;br /&gt;
&lt;br /&gt;
== Configuration ==&lt;br /&gt;
In order to load a file using TFTP, U-Boot must be configured to access the local network. Static networking configuration or DHCP can be used on some systems (requires DHCP server). Typically, the IP address of the board and the IP address of the TFTP server are the only settings that need to be defined. The network mask and broadcast address will be determined automatically from these settings, and no default gateway setting is required if the server is on the same subnetwork as the board. Before continuing, determine a valid static network address for your local network; contact your IT department for more information on what address to use if required. The example below shows how to set the IP address of the board to 192.168.2.2 and the TFTP server IP address to 192.168.2.1:&lt;br /&gt;
{{clop}}&amp;lt;nowiki&amp;gt;U-Boot&amp;gt; setenv ipaddr 192.168.2.2&lt;br /&gt;
U-Boot&amp;gt; setenv serverip 192.168.2.1&lt;br /&gt;
U-Boot&amp;gt; saveenv&lt;br /&gt;
Saving Environment to dataflash...&lt;br /&gt;
U-Boot&amp;gt; reset&amp;lt;/nowiki&amp;gt;{{closp}}&lt;br /&gt;
&lt;br /&gt;
Once the network settings have been configured, attempt to ping the TFTP server to test the network connection as illustrated below:&lt;br /&gt;
{{clop}}&amp;lt;nowiki&amp;gt;U-Boot&amp;gt; ping 192.168.2.1&lt;br /&gt;
macb0: link up, 100Mbps full-duplex (lpa: 0x45e1)&lt;br /&gt;
Using macb0 device&lt;br /&gt;
host 192.168.2.1 is alive&amp;lt;/nowiki&amp;gt;{{closp}}&lt;br /&gt;
&lt;br /&gt;
== Loading Images to RAM ==&lt;br /&gt;
Files are loaded directly into RAM through TFTP. In order to load the image, you must know the physical address of the RAM device on the system. Refer to the documentation for your target board if you are unsure what value to use. The standard addresses for some common EMAC systems are shown in Table 1 below.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot;|Table 1: Physical RAM Addresses&lt;br /&gt;
|-&lt;br /&gt;
! Product !! RAM Start Address&lt;br /&gt;
|-&lt;br /&gt;
| SoM-9260M || 0x20000000&lt;br /&gt;
|-&lt;br /&gt;
| SoM-9G20M || 0x20000000&lt;br /&gt;
|-&lt;br /&gt;
| SoM-9G45M || 0x70000000&lt;br /&gt;
|-&lt;br /&gt;
| SoM-3517M || 0x82000000&lt;br /&gt;
|-&lt;br /&gt;
| SoM-9x25M || 0x22000000&lt;br /&gt;
|-&lt;br /&gt;
| Ipac-9x25M || 0x22000000&lt;br /&gt;
|-&lt;br /&gt;
| SoM-9G25M || 0x22000000&lt;br /&gt;
|-&lt;br /&gt;
| SoM-A5D35M || 0x22000000&lt;br /&gt;
|-&lt;br /&gt;
| SoM-A5D36M || 0x22000000&lt;br /&gt;
|-&lt;br /&gt;
| SoM-3354M || 0x82000000&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{{ warning | Before transferring a file to the system, make sure that it does not exceed the size of the available RAM. }}&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;tftp&amp;lt;/code&amp;gt; U-Boot command is used to transfer files to the system. The command requires two arguments: the address to load the file into and the filename of the image on the TFTP server. The example below demonstrates loading a kernel image named &amp;lt;code&amp;gt;uImage-2.6.30&amp;lt;/code&amp;gt; to RAM on an SoM-9G45M.&lt;br /&gt;
{{clop}}&amp;lt;nowiki&amp;gt;U-Boot&amp;gt; tftp 0x70000000 uImage-2.6.30&lt;br /&gt;
macb0: link up, 100Mbps full-duplex (lpa: 0x45e1)&lt;br /&gt;
Using macb0 device&lt;br /&gt;
TFTP from server 192.168.2.1; our IP address is 192.168.2.2&lt;br /&gt;
Filename 'uImage-2.6.30'.&lt;br /&gt;
Load address: 0x70000000&lt;br /&gt;
Loading: #################################################################&lt;br /&gt;
         #################################################################&lt;br /&gt;
         #################################################################&lt;br /&gt;
         #################################################################&lt;br /&gt;
         ############################&lt;br /&gt;
done&lt;br /&gt;
Bytes transferred = 1472456 (1677c8 hex)&lt;br /&gt;
U-Boot&amp;gt; printenv filesize&lt;br /&gt;
filesize=1677C8&amp;lt;/nowiki&amp;gt;{{closp}}&lt;br /&gt;
&lt;br /&gt;
{{ note | Note that the &amp;lt;code&amp;gt;filesize&amp;lt;/code&amp;gt; variable has been automatically updated to the size of the file that was loaded.}}&lt;br /&gt;
&lt;br /&gt;
== Executing kernel from RAM ==&lt;br /&gt;
In some situations, it is advantageous to execute the image directly from RAM after loading with TFTP rather than saving to flash. This is especially helpful when testing new Linux kernel images. Furthermore, the boot command can be set such that the image is automatically downloaded and executed on each boot, making testing more efficient.&lt;br /&gt;
&lt;br /&gt;
After loading a bootable image to RAM, you can execute it directly using the &amp;lt;code&amp;gt;bootm&amp;lt;/code&amp;gt; command. For example, after loading the kernel image above, running &amp;lt;code&amp;gt;bootm 0x70000000&amp;lt;/code&amp;gt; would boot the board using the new image without making any changes to the images stored on the flash.&lt;br /&gt;
&lt;br /&gt;
To update the &amp;lt;code&amp;gt;bootcmd&amp;lt;/code&amp;gt; variable to download the image on each boot, simply replace the command used to load the image from flash with the TFTP download command. The following example illustrates this process on an SoM-9G45M module.&lt;br /&gt;
{{clop}}&amp;lt;nowiki&amp;gt;U-Boot&amp;gt; printenv bootcmd&lt;br /&gt;
bootcmd=cp.b 0xC0042000 0x70000000 0x210000; bootm 0x70000000&lt;br /&gt;
U-Boot&amp;gt; setenv bootcmd 'tftp 0x70000000 uImage-2.6.30; bootm 0x70000000'&lt;br /&gt;
U-Boot&amp;gt; saveenv&lt;br /&gt;
Saving Environment to dataflash...&amp;lt;/nowiki&amp;gt;{{closp}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- ***************************************************************************************************&lt;br /&gt;
{{ warning | All these hard coded addresses don't contribute much to the reader's understanding of what each address is for...  especially 0xC0042000, since it's not mentioned elsewhere, and ones that may happen to be the same number for different reasons.}}&lt;br /&gt;
********************************************************************************************************* --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Copying to Flash ==&lt;br /&gt;
The process of copying an image from RAM to flash memory differs depending on what type of flash storage devices are available on the system. Many systems have more than one device, such as serial DataFlash and NAND flash. This section explains the process of storing an image to non-volatile storage.&lt;br /&gt;
&lt;br /&gt;
=== NOR Flash ===&lt;br /&gt;
A combination of the &amp;lt;code&amp;gt;erase&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;cp&amp;lt;/code&amp;gt; commands are used to program an image to a NOR flash device. NOR flash is directly memory-mapped to the system at a physical address. Also, each image (U-Boot, bootstrap, kernel, filesystem) must be stored at the correct offset for the system to operate correctly. Refer to the documentation for your hardware for more information on the correct address ranges to use. The &amp;lt;code&amp;gt;flinfo&amp;lt;/code&amp;gt; command can be used to display the addressing of available flash devices on the system.&lt;br /&gt;
&lt;br /&gt;
After loading the image to RAM, the flash device should be erased followed by copying the image to the appropriate offset in the flash. The example below illustrates the commands used to program a new kernel image to a SoM-9260M module. Note the use of the &amp;lt;code&amp;gt;protect off all&amp;lt;/code&amp;gt; command, which is required to unlock the flash on some systems.&lt;br /&gt;
{{clop}}&amp;lt;nowiki&amp;gt;U-Boot&amp;gt; protect off all&lt;br /&gt;
U-Boot&amp;gt; tftp 0x20000000 ${kernel_name}&lt;br /&gt;
U-Boot&amp;gt; erase 0x10100000 0x103fffff&lt;br /&gt;
U-Boot&amp;gt; cp.b 0x20000000 0x10100000 ${filesize}&amp;lt;/nowiki&amp;gt;{{closp}}&lt;br /&gt;
&lt;br /&gt;
{{ note | Note that NOR flash can take a significant amount of time to program if the image size is large.}}&lt;br /&gt;
&lt;br /&gt;
=== Serial DataFlash ===&lt;br /&gt;
Serial DataFlash is an SPI-based NOR flash device that is used on many systems that employ NAND flash as the primary storage device. On these systems, low-level boot code such as the bootstrap, U-Boot, and OS kernel are typically stored on the DataFlash device. As with NOR flash, the &amp;lt;code&amp;gt;flinfo&amp;lt;/code&amp;gt; command can be used to determine the memory addressing layout of the DataFlash device. The &amp;lt;code&amp;gt;erase&amp;lt;/code&amp;gt; command does not support the DataFlash devices and should not be used before programming an image. The &amp;lt;code&amp;gt;cp&amp;lt;/code&amp;gt; command is capable of copying an image from RAM to DataFlash.&lt;br /&gt;
&lt;br /&gt;
The example below illustrates the commands used to copy a kernel image to the DataFlash device on a SoM-9G45M module.&lt;br /&gt;
{{clop}}&amp;lt;nowiki&amp;gt;U-Boot&amp;gt; tftpboot 0x70000000 ${kernel_name}&lt;br /&gt;
U-Boot&amp;gt; cp.b 0x70000000 0xC0042000 ${filesize}&amp;lt;/nowiki&amp;gt;{{closp}}&lt;br /&gt;
&lt;br /&gt;
=== NAND Flash ===&lt;br /&gt;
Generally, NAND flash is used to store only the root filesystem and auxiliary storage partitions of the OS. Storing an image to NAND flash under U-Boot uses a different set of commands than NOR or DataFlash devices. See &amp;lt;code&amp;gt;help nand&amp;lt;/code&amp;gt; for more information on the available commands for examining and manipulating NAND flash devices. To gain information on what NAND devices are available on the system, use the command &amp;lt;code&amp;gt;nand info&amp;lt;/code&amp;gt;. In general, programming a NAND flash device is much faster than programming NOR or DataFlash devices.&lt;br /&gt;
&lt;br /&gt;
The example below illustrates the process of loading the root JFFS2 filesystem onto an SoM-9G45M device. Note that the device is erased prior to programming it.&lt;br /&gt;
{{clop}}&amp;lt;nowiki&amp;gt;U-Boot&amp;gt; nand erase&lt;br /&gt;
U-Boot&amp;gt; tftp 0x70000000 ${rootfs_name}&lt;br /&gt;
U-Boot&amp;gt; nand write.jffs2 0x70000000 0x0 ${filesize}&amp;lt;/nowiki&amp;gt;{{closp}}&lt;br /&gt;
&lt;br /&gt;
=== SPI NOR/eMMC Flash ===&lt;br /&gt;
Most of EMAC's newer SoM offerings utilize an eMMC flash for filesystem and auxiliary storage partitions of the OS and an SPI flash to store the bootloader and kernel. To reprogram the eMMC, see [[Loading_Images_onto_eMMC_Devices|Loading Images onto eMMC Devices]]. Be sure that the &amp;lt;code&amp;gt;loadaddr&amp;lt;/code&amp;gt; variable is set and matches the table above. The example below illustrates the commands used to program a new kernel image to a SoM-9x25M module. &lt;br /&gt;
{{clop}}&amp;lt;nowiki&amp;gt;U-Boot&amp;gt; pri loadaddr&lt;br /&gt;
U-Boot&amp;gt; tftp ${loadaddr} zImage&lt;br /&gt;
U-Boot&amp;gt; sf probe;sf erase 0x100000 +${filesize};sf write ${loadaddr} 0x100000 ${filesize}&lt;br /&gt;
U-Boot&amp;gt; setenv kernelsize ${filesize};saveenv&amp;lt;/nowiki&amp;gt;{{closp}}&lt;br /&gt;
&lt;br /&gt;
Note: the &amp;quot;pri loadaddr&amp;quot; step above is not required it is just entered to make sure the variable is set.&lt;br /&gt;
&lt;br /&gt;
== Scripting ==&lt;br /&gt;
U-Boot also includes a scripting feature that allows a script file with U-Boot commands to be loaded and executed. This can make the task of programming multiple systems much more efficient. The &amp;lt;code&amp;gt;mkimage&amp;lt;/code&amp;gt; utility is required on a Linux development system in order to create a valid U-Boot image from a script. This section gives a brief example of a U-Boot script for programming a Linux kernel and filesystem.&lt;br /&gt;
&lt;br /&gt;
Creating a text file with all of the desired commands is the first step in creating a U-Boot script. The example below is a script file used by EMAC to program SoM-9260M modules:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=php&amp;gt;&lt;br /&gt;
echo ===== Setting Environment =====&lt;br /&gt;
setenv bootdelay 1&lt;br /&gt;
setenv rev sl013-aon-30010&lt;br /&gt;
setenv bootargs 'console=ttyS3,115200 root=/dev/mtdblock3 rootfstype=jffs2'&lt;br /&gt;
setenv kernel_name ${rev}-uImage&lt;br /&gt;
setenv rootfs_name sl013-aon-emac-image-SOM9260M.jffs2&lt;br /&gt;
saveenv&lt;br /&gt;
echo ===== Loading Kernel =====&lt;br /&gt;
protect off all&lt;br /&gt;
tftpboot 0x20000000 ${kernel_name}&lt;br /&gt;
erase 0x10100000 0x103fffff&lt;br /&gt;
cp.b 0x20000000 0x10100000 ${filesize}&lt;br /&gt;
setenv kernelsize ${filesize}&lt;br /&gt;
echo ===== Loading Root Filesystem =====&lt;br /&gt;
tftpboot 0x20000000 ${rootfs_name}&lt;br /&gt;
erase 0x10400000 0x11ffffff&lt;br /&gt;
cp.b 0x20000000 0x10400000 ${filesize}&lt;br /&gt;
setenv bootcmd 'protect off all;cp.b 0x10100000 0x20000000 ${kernelsize};bootm 0x20000000'&lt;br /&gt;
saveenv&lt;br /&gt;
echo ===== DONE! =====&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Once the file has been created and saved, the &amp;lt;code&amp;gt;mkimage&amp;lt;/code&amp;gt; utility must be used to create a U-Boot script image. A shell script such as the one shown below may be used to aid in this process:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/sh&lt;br /&gt;
 &lt;br /&gt;
if [ ! -f &amp;quot;$1&amp;quot; ] || [ $# -lt 2 ]&lt;br /&gt;
then&lt;br /&gt;
        echo &amp;quot;Usage: $0 SCRIPTNAME OUTPUTNAME&amp;quot;&lt;br /&gt;
        exit 1&lt;br /&gt;
fi&lt;br /&gt;
 &lt;br /&gt;
mkimage -T script -C none -A arm -n 'SoM9260 Load Script' -d $1 $2&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that the script assumes that &amp;lt;code&amp;gt;mkimage&amp;lt;/code&amp;gt; is installed in the user's PATH. The script should be run with the name of the existing file as the first argument and the desired output filename as the second argument:&lt;br /&gt;
{{cli|username=developer|hostname=ldc|./script_mkimage.sh sl013-aon-30010-flash-script sl013-aon-30010-flash-script.img}}&lt;br /&gt;
&lt;br /&gt;
Once an image file has been created, it should be copied to the TFTP server root directory, in this example &amp;lt;code&amp;gt;/srv/tftp&amp;lt;/code&amp;gt; is used.&lt;br /&gt;
{{cli|username=developer|hostname=ldc|sudo cp sl013-aon-30010-flash-script.img /srv/tftp/}}&lt;br /&gt;
&lt;br /&gt;
The image file can now be transferred to the board and executed as illustrated below:&lt;br /&gt;
{{clop}}&amp;lt;nowiki&amp;gt;U-Boot&amp;gt; tftp 0x20000000 sl013-aon-30010-flash-script.img&lt;br /&gt;
U-Boot&amp;gt; source 0x20000000&amp;lt;/nowiki&amp;gt;{{closp}}&lt;br /&gt;
&lt;br /&gt;
{{ note | Note that the U-Boot command &amp;lt;code&amp;gt;source&amp;lt;/code&amp;gt; was not available on older versions of U-Boot. If the command is not recognized, use &amp;lt;code&amp;gt;autoscr&amp;lt;/code&amp;gt; instead.}}&lt;br /&gt;
&lt;br /&gt;
U-Boot will execute all commands in the script line-by-line until the script has finished, at which point the U-boot prompt will be returned to the user.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /******************************************     Conclusion      ******************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
{{:Templateimpl:conclusion | initials=MD | title=System Logging | desc=The page describes how to system log. | project=OE 5.0 }}&lt;br /&gt;
In this article, you have seen how to load an image into RAM using U-Boot.  You have seen how to execute an image from RAM.  You have also seen how to copy an image from RAM to flash; how to configure your system to boot from an image once it has been saved to flash is documented elsewhere (see Related Information, below).  You have also seen a brief description of how to create scripts for U-Boot.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
With the information provided by this document, you are set to begin loading alternate kernels and filesystems onto EMAC hardware.  These kernels and filesystems could be alternatives provided to you by EMAC, or they could be ones you create yourself.  This provides you with a great deal of flexibility for your development work.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /******************************************   More Information   *****************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
{{:Templateimpl:moreinfo | initials=MD | title=System Logging | desc=The page describes how to system log. | project=OE 5.0 }}&lt;br /&gt;
* [[Loading_Linux_Kernels_Onto_a_Board | Loading Linux Kernels Onto a Board]]&lt;br /&gt;
* [[Loading_JFFS2_Images_Onto_a_Board | Loading JFFS2 Images Onto a Board]]&lt;br /&gt;
* [[Archiving_JFFS2_Images | Archiving JFFS2 Images]]&lt;br /&gt;
&lt;br /&gt;
{{:Templateimpl:whatnext | initials=MD | title=System Logging | desc=The page describes how to system log. | project=OE 5.0 }}&lt;br /&gt;
* [[U-Boot_Overview | U-Boot Overview]]&lt;br /&gt;
* [[Creating_JFFS2_Images | Creating JFFS2 Images]]&lt;br /&gt;
* [[Mounting_JFFS2_Images_on_a_Linux_PC | Mounting JFFS2 Images on a Linux PC]]&lt;br /&gt;
* [[Repartitioning_NAND_Flash_with_JFFS2_for_Linux | Repartitioning NAND Flash with JFFS2 for Linux]]&lt;br /&gt;
* [[Loading_Images_onto_eMMC_Devices | Loading Images onto eMMC Devices]]&lt;br /&gt;
* [[Booting_with_an_NFS_Root_Filesystem | Booting with an NFS Root Filesystem]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--[[Category:Bootloaders]]--&amp;gt;&lt;/div&gt;</summary>
		<author><name>Mgloff</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.emacinc.com/index.php?title=Booting_with_a_USB_Root_Filesystem&amp;diff=5632</id>
		<title>Booting with a USB Root Filesystem</title>
		<link rel="alternate" type="text/html" href="https://wiki.emacinc.com/index.php?title=Booting_with_a_USB_Root_Filesystem&amp;diff=5632"/>
		<updated>2019-04-12T18:26:25Z</updated>

		<summary type="html">&lt;p&gt;Mgloff: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;It is possible to boot most EMAC OE systems using a USB thumb drive as the root filesystem and to optionally load a kernel from. This method can be especially useful for updating or recovering the root filesystem when a network connection or a network file server is not available. This page describes the steps required to boot into a root filesystem residing on a USB thumb drive.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==Prerequisites==&lt;br /&gt;
&lt;br /&gt;
Some prerequisites must be met prior to being able to boot a root filesystem from a USB drive.&lt;br /&gt;
&lt;br /&gt;
===USB Thumb Drive===&lt;br /&gt;
&lt;br /&gt;
Any blank USB drive. If it is not blank, this process will completely wipe the data that exists on the USB drive.&lt;br /&gt;
&lt;br /&gt;
===Root Filesystem===&lt;br /&gt;
&lt;br /&gt;
A complete root filesystem for the EMAC OE system to boot from must be stored on the USB drive.&lt;br /&gt;
&lt;br /&gt;
===Linux Host Computer===&lt;br /&gt;
&lt;br /&gt;
Either a native Linux host or Windows host running a Linux virtual machine.&lt;br /&gt;
&lt;br /&gt;
==Configuring the USB Thumb Drive==&lt;br /&gt;
&lt;br /&gt;
In a terminal window, start the dmesg log with the follow option to watch for new devices.&lt;br /&gt;
&lt;br /&gt;
{{cli | username=developer | hostname=ldc | pwd=~ | dmesg -w }}&lt;br /&gt;
&lt;br /&gt;
Insert the USB drive and watch for the device to be announced.&lt;br /&gt;
&lt;br /&gt;
{{clo}}&lt;br /&gt;
[ 2796.940110] scsi host6: usb-storage 1-1.2:1.0 &amp;lt;br /&amp;gt;&lt;br /&gt;
[ 2797.963442] scsi 6:0:0:0: Direct-Access     Generic  STORAGE DEVICE   0272 PQ: 0 ANSI: 0 &amp;lt;br /&amp;gt;&lt;br /&gt;
[ 2797.963905] sd 6:0:0:0: Attached scsi generic sg4 type 0 &amp;lt;br /&amp;gt;&lt;br /&gt;
[ 2798.269544] sd 6:0:0:0: [sdd] 7774208 512-byte logical blocks: (3.98 GB/3.71 GiB) &amp;lt;br /&amp;gt;&lt;br /&gt;
[ 2798.271027] sd 6:0:0:0: [sdd] Write Protect is off &amp;lt;br /&amp;gt;&lt;br /&gt;
[ 2798.271030] sd 6:0:0:0: [sdd] Mode Sense: 0b 00 00 08 &amp;lt;br /&amp;gt;&lt;br /&gt;
[ 2798.272502] sd 6:0:0:0: [sdd] No Caching mode page found &amp;lt;br /&amp;gt;&lt;br /&gt;
[ 2798.272508] sd 6:0:0:0: [sdd] Assuming drive cache: write through &amp;lt;br /&amp;gt;&lt;br /&gt;
[ 2798.279486]  sdd: &amp;lt;br /&amp;gt;&lt;br /&gt;
[ 2798.283834] sd 6:0:0:0: [sdd] Attached SCSI removable disk &amp;lt;br /&amp;gt;&lt;br /&gt;
{{clos}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
{{ imbox | type=notice | text=If using a virtual machine, wait for Windows to install the Virtualbox USB driver. Then make the virtual machine aware of the USB drive by going into the Devices menu option in virtualbox, then sub-option USB and select your USB device.}}&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The output of the &amp;lt;code&amp;gt;dmesg&amp;lt;/code&amp;gt; command shows that the root device node for the USB drive in this case is &amp;lt;code&amp;gt;sdd&amp;lt;/code&amp;gt; and no partitions. Partitions on the drive would be listed as &amp;lt;code&amp;gt;sdd1&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;sdd2&amp;lt;/code&amp;gt;, etc.  Inspect the output shown above to see the particular device node on the development PC where the USB drive is mounted. This will be different depending on the configuration of the development PC. The &amp;lt;code&amp;gt;/dev/&amp;lt;/code&amp;gt; prefix will go before the device name, but is not shown in the output of &amp;lt;code&amp;gt;dmesg&amp;lt;/code&amp;gt;. The device node will start with &amp;lt;code&amp;gt;sd&amp;lt;/code&amp;gt;. The third letter will specify which of these devices is assigned to the USB drive. The number will indicate the partitions, if any. Press Ctrl and 'c' to exit dmesg.&lt;br /&gt;
&lt;br /&gt;
* At this point, it is wise to double check that device node is actually the USB drive and not a hard drive in the system. Specifying the wrong device node could cause a complete loss of data on a hard drive.  &amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt; Continuing with &amp;lt;code&amp;gt;/dev/sdd&amp;lt;/code&amp;gt; as the example device node, type the following command:&lt;br /&gt;
&lt;br /&gt;
{{clo}}&lt;br /&gt;
{{clio | username=developer | hostname=ldc | pwd=~ | mount {{!}} grep sdd }}&lt;br /&gt;
/dev/sdd on /media/developer/FBF6-1988 type vfat&lt;br /&gt;
{{clos}}&lt;br /&gt;
&lt;br /&gt;
This shows that the device node, &amp;lt;code&amp;gt;/dev/sdd&amp;lt;/code&amp;gt;, is in fact the USB drive.  This is because:&lt;br /&gt;
* It is not mounted on one of the standard Linux filesystem mountpoints, such as &amp;lt;code&amp;gt;/&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;/boot&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;/usr&amp;lt;/code&amp;gt;, or &amp;lt;code&amp;gt;/home&amp;lt;/code&amp;gt;.&lt;br /&gt;
* It '''is''' mounted in the &amp;lt;code&amp;gt;/media&amp;lt;/code&amp;gt; directory, where it is expected.  It may alternatively get mounted in &amp;lt;code&amp;gt;/mnt&amp;lt;/code&amp;gt;, depending upon the configuration of the Linux distribution in use.&lt;br /&gt;
&lt;br /&gt;
If nothing is returned, then the USB drive did not get automatically mounted. Proceed to the next step.&lt;br /&gt;
&lt;br /&gt;
Use &amp;lt;code&amp;gt;fdisk -l&amp;lt;/code&amp;gt; to inspect the device node. Use &amp;lt;code&amp;gt;sudo&amp;lt;/code&amp;gt; with &amp;lt;code&amp;gt;fdisk&amp;lt;/code&amp;gt; to gain the required &amp;lt;code&amp;gt;root&amp;lt;/code&amp;gt; privileges to run &amp;lt;code&amp;gt;fdisk&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{clop}}&lt;br /&gt;
{{cliop | username=developer | hostname=ldc | pwd=~ | sudo fdisk -l /dev/sdd }}&amp;lt;nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Disk /dev/sdd: 3.7 GiB, 3980394496 bytes, 7774208 sectors&lt;br /&gt;
Disk model: STORAGE DEVICE  &lt;br /&gt;
Units: sectors of 1 * 512 = 512 bytes&lt;br /&gt;
Sector size (logical/physical): 512 bytes / 512 bytes&lt;br /&gt;
I/O size (minimum/optimal): 512 bytes / 512 bytes&lt;br /&gt;
Disklabel type: dos&lt;br /&gt;
Disk identifier: 0x4fcf5773&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
{{closp}}&lt;br /&gt;
&lt;br /&gt;
The output of fdisk will also show information about any partitions that may exist on the USB drive. For example, another drive with a single FAT32 formatted partition will look like:&lt;br /&gt;
{{clop}}&lt;br /&gt;
{{cliop | username=developer | hostname=ldc | pwd=~ | sudo fdisk -l /dev/sdd }}&amp;lt;nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Disk /dev/sdd: 3.7 GiB, 3980394496 bytes, 7774208 sectors&lt;br /&gt;
Disk model: STORAGE DEVICE  &lt;br /&gt;
Units: sectors of 1 * 512 = 512 bytes&lt;br /&gt;
Sector size (logical/physical): 512 bytes / 512 bytes&lt;br /&gt;
I/O size (minimum/optimal): 512 bytes / 512 bytes&lt;br /&gt;
Disklabel type: dos&lt;br /&gt;
Disk identifier: 0xe6077d37&lt;br /&gt;
&lt;br /&gt;
Device     Boot Start     End Sectors  Size Id Type&lt;br /&gt;
/dev/sdh1        2048 7774207 7772160  3.7G  c W95 FAT32 (LBA)&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
{{closp}}&lt;br /&gt;
&lt;br /&gt;
* As can be seen from the output of the &amp;lt;code&amp;gt;fdisk -l&amp;lt;/code&amp;gt; command above, the disk is 3.7 GB in size, which corresponds with the size of the 4 GB USB drive being used in this example.&lt;br /&gt;
&lt;br /&gt;
Unmount all of the USB drives partitions that were listed from the &amp;lt;code&amp;gt;mount&amp;lt;/code&amp;gt; command above.&lt;br /&gt;
&lt;br /&gt;
{{cli | username=developer | hostname=ldc | pwd=~ | sudo umount /dev/sdd }}&lt;br /&gt;
&lt;br /&gt;
If there is a partition listed:&lt;br /&gt;
&lt;br /&gt;
{{cli | username=developer | hostname=ldc | pwd=~ | sudo umount /dev/sdd1 }}&lt;br /&gt;
&lt;br /&gt;
==Repartition the USB Drive==&lt;br /&gt;
&lt;br /&gt;
Once the correct drive letter is determined, we will create a new Linux partition.&lt;br /&gt;
&lt;br /&gt;
{{clop}}&lt;br /&gt;
{{cliop | username=developer | hostname=ldc | pwd=~ | sudo fdisk /dev/sdd }}&amp;lt;nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Welcome to fdisk (util-linux 2.33.1).&lt;br /&gt;
Changes will remain in memory only, until you decide to write them.&lt;br /&gt;
Be careful before using the write command.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Command (m for help): o&lt;br /&gt;
Created a new DOS disklabel with disk identifier 0x05d5e983.&lt;br /&gt;
&lt;br /&gt;
Command (m for help): n&lt;br /&gt;
Partition type&lt;br /&gt;
   p   primary (0 primary, 0 extended, 4 free)&lt;br /&gt;
   e   extended (container for logical partitions)&lt;br /&gt;
Select (default p): p&lt;br /&gt;
Partition number (1-4, default 1): 1&lt;br /&gt;
First sector (2048-7774207, default 2048): &lt;br /&gt;
Last sector, +/-sectors or +/-size{K,M,G,T,P} (2048-7774207, default 7774207): &lt;br /&gt;
&lt;br /&gt;
Created a new partition 1 of type 'Linux' and of size 3.7 GiB.&lt;br /&gt;
&lt;br /&gt;
Command (m for help): p&lt;br /&gt;
Disk /dev/sdd: 3.7 GiB, 3980394496 bytes, 7774208 sectors&lt;br /&gt;
Disk model: STORAGE DEVICE  &lt;br /&gt;
Units: sectors of 1 * 512 = 512 bytes&lt;br /&gt;
Sector size (logical/physical): 512 bytes / 512 bytes&lt;br /&gt;
I/O size (minimum/optimal): 512 bytes / 512 bytes&lt;br /&gt;
Disklabel type: dos&lt;br /&gt;
Disk identifier: 0x05d5e983&lt;br /&gt;
&lt;br /&gt;
Device     Boot Start     End Sectors  Size Id Type&lt;br /&gt;
/dev/sdd1        2048 7774207 7772160  3.7G 83 Linux&lt;br /&gt;
&lt;br /&gt;
Command (m for help): w&lt;br /&gt;
The partition table has been altered.&lt;br /&gt;
Calling ioctl() to re-read partition table.&lt;br /&gt;
Syncing disks.&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
{{closp}}&lt;br /&gt;
&lt;br /&gt;
The fdisk commands are:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;o&amp;lt;/code&amp;gt; - Create a new empty partition table&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;n&amp;lt;/code&amp;gt; - Create a new partition&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;p&amp;lt;/code&amp;gt; - The type of partition is a primary partition&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;1&amp;lt;/code&amp;gt; - Create the first partition&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;ENTER&amp;gt;&amp;lt;/code&amp;gt; - Accept default start&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;ENTER&amp;gt;&amp;lt;/code&amp;gt; - Accept default end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;p&amp;lt;/code&amp;gt; - Print the new partition layout&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;w&amp;lt;/code&amp;gt; - Write the new partition layout and exit&lt;br /&gt;
&lt;br /&gt;
==Format the Partition==&lt;br /&gt;
&lt;br /&gt;
The first partition will be formatted with the ext4 filesystem.&lt;br /&gt;
&lt;br /&gt;
{{cli | username=developer | hostname=ldc | pwd=~ | yes {{!}} sudo mkfs.ext4 /dev/sdd1 }}&lt;br /&gt;
&lt;br /&gt;
==Mount the Partition==&lt;br /&gt;
&lt;br /&gt;
The first partition of the USB drive will be mounted so that it is accessible to write to.&lt;br /&gt;
&lt;br /&gt;
{{clop}}&lt;br /&gt;
{{clio | username=developer | hostname=ldc | pwd=~ | sudo mkdir -p /media/card }}&lt;br /&gt;
{{clio | username=developer | hostname=ldc | pwd=~ | sudo mount /dev/sdd1 /media/card }}&lt;br /&gt;
{{closp}}&lt;br /&gt;
&lt;br /&gt;
The USB drive is now accessible through the &amp;lt;code&amp;gt;/media/card&amp;lt;/code&amp;gt; directory.&lt;br /&gt;
&lt;br /&gt;
==Extract Filesystem Archive==&lt;br /&gt;
&lt;br /&gt;
Locate where the filesystem archive has been downloaded. If the archive is called rootfs.tar.gz and is in the users Downloads directory:&lt;br /&gt;
&lt;br /&gt;
{{clop}}&lt;br /&gt;
{{clio | username=developer | hostname=ldc | pwd=~ | cd /media/card }}&lt;br /&gt;
{{clio | username=developer | hostname=ldc | pwd=/media/card | sudo tar zxf ~/Downloads/rootfs.tar.gz }}&lt;br /&gt;
{{clio | username=developer | hostname=ldc | pwd=/media/card | sync }}&lt;br /&gt;
{{clio | username=developer | hostname=ldc | pwd=/media/card | cd }}&lt;br /&gt;
{{clio | username=developer | hostname=ldc | pwd=~ | sudo umount /media/card }}&lt;br /&gt;
{{closp}}&lt;br /&gt;
&lt;br /&gt;
It is now safe to remove the USB drive from the host computer.&lt;br /&gt;
&lt;br /&gt;
==Configuring the Client to Boot from USB==&lt;br /&gt;
&lt;br /&gt;
===Configuring U-Boot===&lt;br /&gt;
&lt;br /&gt;
Insert the USB drive into an available port on the target board.&lt;br /&gt;
Set the bootargs variable to tell the kernel to boot into the USB filesystem:&lt;br /&gt;
&lt;br /&gt;
 U-Boot&amp;gt; setenv bootargs console=${console} root=/dev/sda1 rootfstype=ext4 rootwait&lt;br /&gt;
 U-Boot&amp;gt; run bootargs&lt;br /&gt;
&lt;br /&gt;
This line sets up the environment needed to boot from the USB drive.  These options will be passed to the Linux kernel when booting it.  The &amp;lt;code&amp;gt;console=${console}&amp;lt;/code&amp;gt; part tells Linux to use the console setting from the U-Boot environment variable; this will usually be something along the lines of &amp;lt;code&amp;gt;console=ttyS0,115200n8&amp;lt;/code&amp;gt;.  The &amp;lt;code&amp;gt;root=/dev/sda1&amp;lt;/code&amp;gt; directive tells Linux to instantiate with the USB block device, &amp;lt;code&amp;gt;/dev/sda1&amp;lt;/code&amp;gt;, as the root filesystem. The &amp;lt;code&amp;gt;rootfstype=ext4&amp;lt;/code&amp;gt; directive tells Linux that the root filesystem is of the EXT4 variety.  &lt;br /&gt;
&lt;br /&gt;
If the kernel is already programmed into the flash, it can be used in most cases to boot into the USB root filesystem. Execute the next line to load and run the default kernel.&lt;br /&gt;
&lt;br /&gt;
 U-Boot&amp;gt; boot&lt;br /&gt;
&lt;br /&gt;
The machine should now boot, and show output on its console as it does so.&lt;br /&gt;
&lt;br /&gt;
===Alternate Kernel Load===&lt;br /&gt;
&lt;br /&gt;
An alternate kernel can be loaded into memory temporarily and booted if the kernel is not already programmed in the flash or a development kernel is to be tested. The below example assumes a kernel named zImage-test was placed in the /boot directory of the USB drive. Also see [[ Loading_Images_with_U-Boot#Executing_kernel_from_RAM  | Executing kernel from RAM ]]&lt;br /&gt;
&lt;br /&gt;
 U-Boot&amp;gt; usb start&lt;br /&gt;
 U-Boot&amp;gt; usb storage&lt;br /&gt;
 U-Boot&amp;gt; ext2load usb 0:1 ${loadaddr} /boot/zImage-test&lt;br /&gt;
 U-Boot&amp;gt; bootz ${loadaddr}&lt;br /&gt;
&lt;br /&gt;
The first two commands initialize the USB storage system in U-Boot. The &amp;lt;code&amp;gt;ext2load&amp;lt;/code&amp;gt; line says to use the USB device 0 partition 1 and load into RAM at ${loadaddr} the file /boot/zImage-test from the USB drive. The last line boots the kernel that has been loaded into memory.&lt;br /&gt;
&lt;br /&gt;
==Conclusion==&lt;br /&gt;
&lt;br /&gt;
Using a USB thumb drive for the root filesystem allows boards to boot quickly into a rescue or known good version of a filesystem and provides a method for remotely backing up the filesystem installed on an embedded machine.  Setting up a machine to boot to a root filesystem via USB requires little work; most of the work is in setting up the USB thumb drive.&lt;br /&gt;
&lt;br /&gt;
{{:Templateimpl:moreinfo | initials=MG | title=System Logging | desc=The page describes how to USB boot. | project=OE 5.0 }}&lt;br /&gt;
* [[Loading_Images_onto_eMMC_Devices | Loading Images onto eMMC Devices]]&lt;br /&gt;
* [[Loading_Images_with_U-Boot | Loading Images with U-Boot]]&lt;br /&gt;
* [[Loading_Linux_Kernels_Onto_a_Board | Loading Linux Kernels Onto a Board]]&lt;/div&gt;</summary>
		<author><name>Mgloff</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.emacinc.com/index.php?title=Opkg&amp;diff=5631</id>
		<title>Opkg</title>
		<link rel="alternate" type="text/html" href="https://wiki.emacinc.com/index.php?title=Opkg&amp;diff=5631"/>
		<updated>2019-03-11T16:02:10Z</updated>

		<summary type="html">&lt;p&gt;Mgloff: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{todo| Complete (11.12.2014-18:38-&amp;gt;MD+);(11.05.2015-19:20-&amp;gt;MD+);(11.06.2015-16:10-&amp;gt;MD+);(11.06.2015-17:25-&amp;gt;MD+);(11.13.2015-16:15-&amp;gt;KY+);(11.13.2015-16:24-&amp;gt;ER+)|Mike Dean| project=OE 5,MD,KY,ER,Complete}}&lt;br /&gt;
{{#seo:&lt;br /&gt;
|title=OPKG&lt;br /&gt;
|titlemode=append&lt;br /&gt;
|keywords=opkg,yocto,openembedded&lt;br /&gt;
|description=Package Management with OPKG&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span class=&amp;quot;pagedesc&amp;quot;&amp;gt;&lt;br /&gt;
Every modern operating system is expected to host a variety of software applications and libraries.  Managing their installation, upgrade, and removal has become more complex as software has become more sophisticated.  Additionally, the pervasive presence of the Internet has driven an expectation by users of an ability to perform OS updates and upgrades via the Internet.  This page describes the tool used by EMAC OE to cater to these needs and expectations.&lt;br /&gt;
&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
{{:Templateimpl:bg | initials=MD | title=OPKG | desc=Package Management with OPKG | project=OE 5 }}&lt;br /&gt;
There are many package managers used for Linux systems.  You may already be familiar with the ones most popularly used in desktop and server distributions of Linux: &amp;lt;code&amp;gt;apt&amp;lt;/code&amp;gt; (&amp;lt;code&amp;gt;apt-get&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;aptitude&amp;lt;/code&amp;gt;, etc), &amp;lt;code&amp;gt;rpm&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;yum&amp;lt;/code&amp;gt;.  You may even be familiar with some of the less popular ones, such as &amp;lt;code&amp;gt;emerge&amp;lt;/code&amp;gt; (from gentoo's &amp;lt;code&amp;gt;portage&amp;lt;/code&amp;gt;), the Mac OS X GNU tools package manager &amp;lt;code&amp;gt;brew&amp;lt;/code&amp;gt;, and the BSD package manager, &amp;lt;code&amp;gt;ports&amp;lt;/code&amp;gt;.  The package manager used by EMAC OE is similar to these tools, but is the popular choice for embedded Linux: &amp;lt;code&amp;gt;opkg&amp;lt;/code&amp;gt;.  If you're already familiar with any of the desktop/server package managers listed here, &amp;lt;code&amp;gt;opkg&amp;lt;/code&amp;gt; should be very easy to learn since it is quite similar to all of those tools.  If not, it should still be easy to learn because it has a well designed interface.&lt;br /&gt;
&lt;br /&gt;
{{:Templateimpl:geninfo | initials=MD | title=OPKG | desc=Package Management with OPKG | project=OE 5 }}&lt;br /&gt;
The basic capabilities of &amp;lt;code&amp;gt;opkg&amp;lt;/code&amp;gt; are available in OE 4.0 and earlier, but no packages are available online for these older versions.  EMAC OE 5.X adds an online package repository complete with important updates for packages during the support window for each release.  EMAC creates and hosts packages for all of our standard offerings, and may add updated packages as needed.  EMAC recommends checking for and installing any updates available for your OE 5.X system prior to creating the final image which will be used to deploy your systems to ensure your image contains the latest bug fixes and security patches.  It is important to remember to retest your application after an update to ensure that everything still works as expected, just as you would have to do for a desktop application.&lt;br /&gt;
&lt;br /&gt;
Should your application require the ability to be updated/upgraded remotely, EMAC is able to provide assistance and services for creating custom packages for your application and hosting these packages for a modest fee.  We will also assist you with configuring the systems to check for and install these updates.  Please contact EMAC support should you need more information about this extra level of support.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;opkg&amp;lt;/code&amp;gt; tool is used to work with the OPKG package management system.  This tool provides the user with many different capabilities.  In this document, only the basic capabilities are described.  More information can be found in the last section of this page.&lt;br /&gt;
{{:Templateimpl:using | initials=MD | title=OPKG | desc=Package Management with OPKG | project=OE 5 }}&lt;br /&gt;
The following basic capabilities are shown in this document:&lt;br /&gt;
&lt;br /&gt;
* Updating the list of available packages.&lt;br /&gt;
* Upgrading the system.&lt;br /&gt;
* Finding packages to install.&lt;br /&gt;
* Installing new packages.&lt;br /&gt;
* Removing packages.&lt;br /&gt;
&lt;br /&gt;
=== Updating the List of Available Packages ===&lt;br /&gt;
&lt;br /&gt;
The OPKG Package Manager keeps a local cache of the list of available packages so that it doesn't have to reach out to the Internet every time the user wishes to use this list in any way.  This list is updated on demand, rather than periodically, so it's important to update this list before attempting to search for or install any new packages, or attempting to upgrade the system.&lt;br /&gt;
&lt;br /&gt;
To update the cached list of available packages, run:&lt;br /&gt;
&lt;br /&gt;
{{cli|opkg update}}&lt;br /&gt;
&lt;br /&gt;
Note that you must be root in order to update this list.&lt;br /&gt;
&lt;br /&gt;
=== Upgrading the System ===&lt;br /&gt;
&lt;br /&gt;
You can use &amp;lt;code&amp;gt;opkg&amp;lt;/code&amp;gt; to upgrade the system by selectively telling it which packages to upgrade.  You first need to obtain a list of available packages to upgrade with the following command:&lt;br /&gt;
&lt;br /&gt;
{{cli|opkg list-upgradable}}&lt;br /&gt;
&lt;br /&gt;
You can then upgrade a package with this command:&lt;br /&gt;
&lt;br /&gt;
{{cli|opkg upgrade ''packagename''}}&lt;br /&gt;
&lt;br /&gt;
=== Finding Packages to Install ===&lt;br /&gt;
&lt;br /&gt;
==== Listing Packages ====&lt;br /&gt;
&lt;br /&gt;
There is more than one way to look through packages to see what's available to be installed.  The first is the &amp;lt;code&amp;gt;list&amp;lt;/code&amp;gt; command by itself:&lt;br /&gt;
&lt;br /&gt;
{{cli|opkg list}}&lt;br /&gt;
&lt;br /&gt;
This provides a complete list of all available packages.  ''If you're already comfortable with the Linux command line, you may now wish to skip to the section entitled, &amp;quot;Installing New Pacakges.&amp;quot;  If not, the following content shows how to more easily work with this output.''&lt;br /&gt;
&lt;br /&gt;
==== Browsing the Package List ====&lt;br /&gt;
&lt;br /&gt;
As usual on the Linux command line, this long list can be made much easier to peruse by piping the output of the &amp;lt;code&amp;gt;opkg list&amp;lt;/code&amp;gt; command into the &amp;lt;code&amp;gt;less&amp;lt;/code&amp;gt; command, like so:&lt;br /&gt;
&lt;br /&gt;
{{cli|opkg list {{!}} less}}&lt;br /&gt;
&lt;br /&gt;
{{note|Unlike the &amp;lt;code&amp;gt;more&amp;lt;/code&amp;gt; command, the &amp;lt;code&amp;gt;less&amp;lt;/code&amp;gt; command allows you to scroll bidirectionally through a text file.  It also allows you to search through a document using regular expressions; press the &amp;lt;code&amp;gt;/&amp;lt;/code&amp;gt; key followed by some text (or a basic regular expression) for which you would like to search.  This can be used to directly read a text file as well: {{icli|less some_text_file}}}}&lt;br /&gt;
&lt;br /&gt;
==== Filtering the Package List ====&lt;br /&gt;
&lt;br /&gt;
Often times, you will wish to search for something more specific.  The &amp;lt;code&amp;gt;grep&amp;lt;/code&amp;gt; command is very useful for this task.  The most basic use of grep looks like this:&lt;br /&gt;
&lt;br /&gt;
{{cli|opkg list {{!}} grep ''packagename''}}&lt;br /&gt;
&lt;br /&gt;
If you're not sure of the full package name, you can put in just a part of the name, since grep doesn't match against whole words by default.&lt;br /&gt;
&lt;br /&gt;
===== Matching Whole Words =====&lt;br /&gt;
&lt;br /&gt;
If, on the other hand, you want it to match against a whole word, you can enclose the word with escaped angle brackets:&lt;br /&gt;
&lt;br /&gt;
{{cli|opkg list {{!}} grep \&amp;lt;''packagename''\&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
This tells &amp;lt;code&amp;gt;grep&amp;lt;/code&amp;gt; to only match against the full word represented by ''packagename''.  Use only the opening angle bracket if you only want it to look for a word that starts with ''packagename'', and likewise, only use the closing angle bracket at the end if you only want it to search for a word that ends with ''packagename''.&lt;br /&gt;
&lt;br /&gt;
===== More Stringent Filtering =====&lt;br /&gt;
&lt;br /&gt;
If the search is returning too many results because the word you're looking for is found in package descriptions, you may want to try using the beginning of line glob character, the caret:&lt;br /&gt;
&lt;br /&gt;
{{cli|opkg list{{!}} grep ^''packagename''}}&lt;br /&gt;
&lt;br /&gt;
This will cause only lines which begin with ''packagename'' to be displayed.&lt;br /&gt;
&lt;br /&gt;
===== More Information about Filtering the Package List =====&lt;br /&gt;
&lt;br /&gt;
There are many more advanced regular expressions which can be used with grep.  These will allow you to do things like match wildcards from the beginning of the line up to the characters you specify after the wildcard (which you might do if you know the package name contains a word, but doesn't start with that word, yet the word is too common to allow it to search through all of the text), but this should be enough to get you started.  There are many in depth resources for the usage of &amp;lt;code&amp;gt;grep&amp;lt;/code&amp;gt; available online.&lt;br /&gt;
&lt;br /&gt;
=== Installing New Packages ===&lt;br /&gt;
&lt;br /&gt;
Once you have found a package or list of packages you wish to install, the &amp;lt;code&amp;gt;opkg&amp;lt;/code&amp;gt; command makes installation simple:&lt;br /&gt;
&lt;br /&gt;
{{cli|opkg install ''packagename''}}&lt;br /&gt;
&lt;br /&gt;
This will download and install ''packagename'' and all of its dependencies for you.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If you would like to install more than one at a time, you can do so by specifying them as a space-separated list:&lt;br /&gt;
&lt;br /&gt;
{{cli|opkg install ''package1'' ''package2'' ''package3'' ''etc''}}&lt;br /&gt;
&lt;br /&gt;
As before, all of the dependencies for the packages specified will be automatically downloaded and installed by &amp;lt;code&amp;gt;opkg&amp;lt;/code&amp;gt; as well.&lt;br /&gt;
&lt;br /&gt;
=== Removing Packages ===&lt;br /&gt;
&lt;br /&gt;
When you have installed a package that you no longer want to have on your system, &amp;lt;code&amp;gt;opkg&amp;lt;/code&amp;gt; provides the &amp;lt;code&amp;gt;remove&amp;lt;/code&amp;gt; command for removal of the package:&lt;br /&gt;
&lt;br /&gt;
{{cli|opkg remove ''packagename''}}&lt;br /&gt;
&lt;br /&gt;
If there is anything that depends on it, &amp;lt;code&amp;gt;opkg&amp;lt;/code&amp;gt; will output an error message indicating that packages depend on it.&lt;br /&gt;
&lt;br /&gt;
You can add the &amp;lt;code&amp;gt;--force-removal-of-dependent-packages&amp;lt;/code&amp;gt; to force it to remove the package and everything that depends on it:&lt;br /&gt;
&lt;br /&gt;
{{cli|opkg remove --force-removal-of-dependent-packages ''packagename''}}&lt;br /&gt;
&lt;br /&gt;
{{Caution|The very verbose argument name is required because this can be a dangerous way to remove packages.  The length of the argument's name (&amp;lt;code&amp;gt;--force-removal-of-dependent-packages&amp;lt;/code&amp;gt;)is intended to remind you of the danger.  You may find yourself with an unbootable system if you uninstall a package which was depended upon by important system packages.  It's generally wiser to use the less heavy handed version, &amp;lt;code&amp;gt;--force-depends&amp;lt;/code&amp;gt;, which will only remove the package and the dependencies which are one layer deep:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{cli|opkg remove --force-depends ''packagename''}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If more than one layer of dependencies needs to be removed, you should use the &amp;lt;code&amp;gt;remove&amp;lt;/code&amp;gt; command without either of these options.  Use it on each dependency layer to see what depends upon those dependencies, and continue this procedure recursively to ensure that nothing important will be removed before you attempt to remove a package with the heavy handed variant.&lt;br /&gt;
&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
If you do render your system unbootable, you may contact EMAC, and we will help you get your system back into a usable state for a small fee.  If you would prefer to avoid this fee, please be very careful about what you remove since damage to the filesystem caused by misuse of the above commands is not covered under the EMAC warranty.&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /*****************************************       Examples        *****************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
{{:Templateimpl:examples | initials=MD | title=OPKG | desc=Package Management with OPKG | project=OE 5 }}&lt;br /&gt;
{{example|Removing a Package which has Dependencies}}&lt;br /&gt;
&lt;br /&gt;
{{clo}}&lt;br /&gt;
{{clio|opkg remove alsa-conf-base}}&lt;br /&gt;
No packages removed.&amp;lt;br /&amp;gt;&lt;br /&gt;
Collected errors:&amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;amp;nbsp;* print_dependents_warning: Package alsa-conf-base is depended upon by packages:&amp;lt;BR&amp;gt;&lt;br /&gt;
&amp;amp;nbsp;* print_dependents_warning: 	libasound2&amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;amp;nbsp;* print_dependents_warning: These might cease to work if package alsa-conf-base is removed.&amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;amp;nbsp;* print_dependents_warning: Force removal of this package with --force-depends.&amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;amp;nbsp;* print_dependents_warning: Force removal of this package and its dependents&amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;amp;nbsp;* print_dependents_warning: with --force-removal-of-dependent-packages.&amp;lt;br /&amp;gt;&lt;br /&gt;
{{clio|opkg remove --force-depends alsa-conf-base}}&lt;br /&gt;
Removing package alsa-conf-base from root...&lt;br /&gt;
{{clio|}}&lt;br /&gt;
{{clos}}&lt;br /&gt;
&lt;br /&gt;
{{example|Updating a Package}}&lt;br /&gt;
&lt;br /&gt;
{{clop}}&lt;br /&gt;
{{cliop|opkg update}}&amp;lt;nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Downloading ftp://oe50@ftp.emacinc.com/all/Packages.gz.&lt;br /&gt;
Inflating ftp://oe50@ftp.emacinc.com/all/Packages.gz.&lt;br /&gt;
Downloading ftp://oe50@ftp.emacinc.com/ipac9x25/Packages.gz.&lt;br /&gt;
Inflating ftp://oe50@ftp.emacinc.com/ipac9x25/Packages.gz.&lt;br /&gt;
Downloading ftp://oe50@ftp.emacinc.com/armv5e/Packages.gz.&lt;br /&gt;
Inflating ftp://oe50@ftp.emacinc.com/armv5e/Packages.gz.&lt;br /&gt;
Collected errors:&lt;br /&gt;
 * opkg_update_cmd: Not able to update list of packages in /var/lib/opkg/all.&lt;br /&gt;
 * opkg_update_cmd: Not able to update list of packages in /var/lib/opkg/ipac9x25.&lt;br /&gt;
 * opkg_update_cmd: Not able to update list of packages in /var/lib/opkg/armv5e.&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;{{closp}}&lt;br /&gt;
&lt;br /&gt;
If you've forgotten to remount your root filesystem as rw, you'll see output similar to that shown above.  Remount the filesystem rw and try again:&lt;br /&gt;
&lt;br /&gt;
{{cli|oemntrw}}&lt;br /&gt;
&lt;br /&gt;
{{clop}}&lt;br /&gt;
{{cliop|opkg update}}&amp;lt;nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Downloading ftp://oe50@ftp.emacinc.com/all/Packages.gz.&lt;br /&gt;
Inflating ftp://oe50@ftp.emacinc.com/all/Packages.gz.&lt;br /&gt;
Updated list of available packages in /var/lib/opkg/all.&lt;br /&gt;
Downloading ftp://oe50@ftp.emacinc.com/ipac9x25/Packages.gz.&lt;br /&gt;
Inflating ftp://oe50@ftp.emacinc.com/ipac9x25/Packages.gz.&lt;br /&gt;
Updated list of available packages in /var/lib/opkg/ipac9x25.&lt;br /&gt;
Downloading ftp://oe50@ftp.emacinc.com/armv5e/Packages.gz.&lt;br /&gt;
Inflating ftp://oe50@ftp.emacinc.com/armv5e/Packages.gz.&lt;br /&gt;
Updated list of available packages in /var/lib/opkg/armv5e.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{cliop|opkg list-upgradable}}&amp;lt;nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
u-boot-fw-utils - v2014.07+git0+91fbeacdf3-r0 - v2015.04+git0+5feae908fd-r0&lt;br /&gt;
libssl1.0.0 - 1.0.2a-r0 - 1.0.2d-r0&lt;br /&gt;
tzdata-pacific - 2015b-r0 - 2015d-r0&lt;br /&gt;
tzdata - 2015b-r0 - 2015d-r0&lt;br /&gt;
openssl-conf - 1.0.2a-r0 - 1.0.2d-r0&lt;br /&gt;
libcrypto1.0.0 - 1.0.2a-r0 - 1.0.2d-r0&lt;br /&gt;
tzdata-arctic - 2015b-r0 - 2015d-r0&lt;br /&gt;
tzdata-africa - 2015b-r0 - 2015d-r0&lt;br /&gt;
tzdata-europe - 2015b-r0 - 2015d-r0&lt;br /&gt;
tzdata-americas - 2015b-r0 - 2015d-r0&lt;br /&gt;
tzdata-atlantic - 2015b-r0 - 2015d-r0&lt;br /&gt;
tzdata-australia - 2015b-r0 - 2015d-r0&lt;br /&gt;
tzdata-antarctica - 2015b-r0 - 2015d-r0&lt;br /&gt;
tzdata-asia - 2015b-r0 - 2015d-r0&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{cliop|opkg upgrade libssl1.0.0 openssl-conf}}&amp;lt;nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Upgrading libssl1.0.0 from 1.0.2a-r0 to 1.0.2d-r0 on root.&lt;br /&gt;
Downloading ftp://oe50opkg:opkgoe50123@ftp.emacinc.com/armv5e/libssl1.0.0_1.0.2d-r0_armv5e.ipk.&lt;br /&gt;
Upgrading libcrypto1.0.0 from 1.0.2a-r0 to 1.0.2d-r0 on root.&lt;br /&gt;
Downloading ftp://oe50opkg:opkgoe50123@ftp.emacinc.com/armv5e/libcrypto1.0.0_1.0.2d-r0_armv5e.ipk.&lt;br /&gt;
Upgrading openssl-conf from 1.0.2a-r0 to 1.0.2d-r0 on root.&lt;br /&gt;
Downloading ftp://oe50opkg:opkgoe50123@ftp.emacinc.com/armv5e/openssl-conf_1.0.2d-r0_armv5e.ipk.&lt;br /&gt;
Configuring openssl-conf.&lt;br /&gt;
Configuring libcrypto1.0.0.&lt;br /&gt;
Configuring libssl1.0.0.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
{{cliop|}}&lt;br /&gt;
{{closp}}&lt;br /&gt;
&lt;br /&gt;
Here, the &amp;lt;code&amp;gt;libssl1.0.0&amp;lt;/code&amp;gt; package and the &amp;lt;code&amp;gt;openssl-conf&amp;lt;/code&amp;gt; package were both upgraded simultaneously by specifying them to &amp;lt;code&amp;gt;opkg upgrade&amp;lt;/code&amp;gt; as a space delimited list.&lt;br /&gt;
&lt;br /&gt;
{{example|Installing a New Package}}&lt;br /&gt;
&lt;br /&gt;
{{clop}}&lt;br /&gt;
{{cliop|opkg update}}&amp;lt;nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Downloading ftp://oe50@ftp.emacinc.com/all/Packages.gz.&lt;br /&gt;
Inflating ftp://oe50@ftp.emacinc.com/all/Packages.gz.&lt;br /&gt;
Updated list of available packages in /var/lib/opkg/all.&lt;br /&gt;
Downloading ftp://oe50@ftp.emacinc.com/ipac9x25/Packages.gz.&lt;br /&gt;
Inflating ftp://oe50@ftp.emacinc.com/ipac9x25/Packages.gz.&lt;br /&gt;
Updated list of available packages in /var/lib/opkg/ipac9x25.&lt;br /&gt;
Downloading ftp://oe50@ftp.emacinc.com/armv5e/Packages.gz.&lt;br /&gt;
Inflating ftp://oe50@ftp.emacinc.com/armv5e/Packages.gz.&lt;br /&gt;
Updated list of available packages in /var/lib/opkg/armv5e.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
{{cliop|opkg list {{!}} grep iptables -A 2}}&amp;lt;nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
iptables - 1.4.21-r0 - Tools for managing kernel packet filtering capabilities  iptables is the&lt;br /&gt;
 userspace command line program used to configure and   control network&lt;br /&gt;
 packet filtering code in Linux.&lt;br /&gt;
iptables-dbg - 1.4.21-r0 - Tools for managing kernel packet filtering capabilities - Debugging files&lt;br /&gt;
 iptables is the userspace command line program used to configure and&lt;br /&gt;
 control network packet filtering code in Linux.  This package contains&lt;br /&gt;
 ELF symbols and related sources for debugging purposes.&lt;br /&gt;
iptables-dev - 1.4.21-r0 - Tools for managing kernel packet filtering capabilities - Development&lt;br /&gt;
 files  iptables is the userspace command line program used to configure&lt;br /&gt;
 and   control network packet filtering code in Linux.  This package&lt;br /&gt;
 contains   symbolic links, header files, and related items necessary for&lt;br /&gt;
--&lt;br /&gt;
iptables-doc - 1.4.21-r0 - Tools for managing kernel packet filtering capabilities - Documentation&lt;br /&gt;
 files  iptables is the userspace command line program used to configure&lt;br /&gt;
 and   control network packet filtering code in Linux.  This package&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
{{cliop|opkg install iptables-doc}}&amp;lt;nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Installing iptables-doc (1.4.21-r0) on root.&lt;br /&gt;
Downloading ftp://oe50@ftp.emacinc.com/armv5e/iptables-doc_1.4.21-r0_armv5e.ipk.&lt;br /&gt;
Configuring iptables-doc.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
{{cliop|}}&lt;br /&gt;
{{closp}}&lt;br /&gt;
&lt;br /&gt;
If you try to install a package which is already installed, it will check to see if it's up to date:&lt;br /&gt;
&lt;br /&gt;
{{clop}}&lt;br /&gt;
{{cliop |opkg install iptables}}&amp;lt;nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Package iptables (1.4.21-r0) installed in root is up to date.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
{{cliop|}}&lt;br /&gt;
{{closp}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{:Templateimpl:conclusion | initials=MD | title=OPKG | desc=Package Management with OPKG | project=OE 5 }}&lt;br /&gt;
This article demonstrated the basic usage of &amp;lt;code&amp;gt;opkg&amp;lt;/code&amp;gt;, but did not cover any of the more advanced topics.  Topics covered in this article include installing software, updating software, removing software, and searching for available packages.&lt;br /&gt;
&lt;br /&gt;
More advanced topics are covered in other articles, such as configuring &amp;lt;code&amp;gt;opkg&amp;lt;/code&amp;gt;, inspecting package metadata and package contents, and creating packages.  Look to the last section of this article if you need more information on these topics.&lt;br /&gt;
&lt;br /&gt;
The EMAC opkg package repository contains a wealth of software you can install to customize and enhance the environment of your EMAC OE Linux machine.  While a great deal of additional functionality is provided with the standard EMAC opkg repository, you may not be able to find a particular package you need.  If you encounter this situation, you may contact EMAC support to request the creation of a custom package for you.  EMAC is able to provide custom packages for most opensource software, and can recommend good alternatives in cases where a specific software package has been found to work or perform poorly (or not at all) in an embedded environment.  EMAC charges a nominal fee to provide this package, but this fee includes support for the package as well.&lt;br /&gt;
&lt;br /&gt;
The EMAC opkg repository is a great source of additional functionality for your machine, but even more importantly, the EMAC opkg repository is a source of updates for the software installed on your machine.  Taking advantage of the EMAC opkg repository to update your systems helps to ensure that your systems will be protected from the latest threats, such as the Heartbleed OpenSSL vulnerability that made a big splash in the recent past.&lt;br /&gt;
&lt;br /&gt;
{{:Templateimpl:moreinfo | initials=MD | title=OPKG | desc=Package Management with OPKG | project=OE 5 }}&lt;br /&gt;
* [[opkg:installedPkgs|Working with Installed Packages]]&lt;br /&gt;
* [[opkg:configuration|Configuring the Package Manager]]&lt;br /&gt;
* [[opkg::advanced|Advanced Package Management]]&lt;/div&gt;</summary>
		<author><name>Mgloff</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.emacinc.com/index.php?title=Booting_with_a_USB_Root_Filesystem&amp;diff=5630</id>
		<title>Booting with a USB Root Filesystem</title>
		<link rel="alternate" type="text/html" href="https://wiki.emacinc.com/index.php?title=Booting_with_a_USB_Root_Filesystem&amp;diff=5630"/>
		<updated>2019-03-05T23:51:01Z</updated>

		<summary type="html">&lt;p&gt;Mgloff: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;It is possible to boot most EMAC OE systems using a USB thumb drive as the root filesystem and to optionally load a kernel from. This method can be especially useful for updating or recovering the root filesystem when a network connection or a network file server is not available. This page describes the steps required to boot into a root filesystem residing on a USB thumb drive.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==Prerequisites==&lt;br /&gt;
&lt;br /&gt;
Some prerequisites must be met prior to being able to boot a root filesystem from a USB drive.&lt;br /&gt;
&lt;br /&gt;
===USB Thumb Drive===&lt;br /&gt;
&lt;br /&gt;
Any blank USB drive. If it is not blank, this process will completely wipe the data that exists on the USB drive.&lt;br /&gt;
&lt;br /&gt;
===Root Filesystem===&lt;br /&gt;
&lt;br /&gt;
A complete root filesystem for the EMAC OE system to boot from must be stored on the USB drive.&lt;br /&gt;
&lt;br /&gt;
===Linux Host Computer===&lt;br /&gt;
&lt;br /&gt;
Either a native Linux host or Windows host running a Linux virtual machine.&lt;br /&gt;
&lt;br /&gt;
==Configuring the USB Thumb Drive==&lt;br /&gt;
&lt;br /&gt;
In a terminal window, start the dmesg log with the follow option to watch for new devices.&lt;br /&gt;
&lt;br /&gt;
{{cli | username=developer | hostname=ldc | pwd=~ | dmesg -w }}&lt;br /&gt;
&lt;br /&gt;
Insert the USB drive and watch for the device to be announced.&lt;br /&gt;
&lt;br /&gt;
{{clo}}&lt;br /&gt;
[ 2796.940110] scsi host6: usb-storage 1-1.2:1.0 &amp;lt;br /&amp;gt;&lt;br /&gt;
[ 2797.963442] scsi 6:0:0:0: Direct-Access     Generic  STORAGE DEVICE   0272 PQ: 0 ANSI: 0 &amp;lt;br /&amp;gt;&lt;br /&gt;
[ 2797.963905] sd 6:0:0:0: Attached scsi generic sg4 type 0 &amp;lt;br /&amp;gt;&lt;br /&gt;
[ 2798.269544] sd 6:0:0:0: [sdd] 7774208 512-byte logical blocks: (3.98 GB/3.71 GiB) &amp;lt;br /&amp;gt;&lt;br /&gt;
[ 2798.271027] sd 6:0:0:0: [sdd] Write Protect is off &amp;lt;br /&amp;gt;&lt;br /&gt;
[ 2798.271030] sd 6:0:0:0: [sdd] Mode Sense: 0b 00 00 08 &amp;lt;br /&amp;gt;&lt;br /&gt;
[ 2798.272502] sd 6:0:0:0: [sdd] No Caching mode page found &amp;lt;br /&amp;gt;&lt;br /&gt;
[ 2798.272508] sd 6:0:0:0: [sdd] Assuming drive cache: write through &amp;lt;br /&amp;gt;&lt;br /&gt;
[ 2798.279486]  sdd: &amp;lt;br /&amp;gt;&lt;br /&gt;
[ 2798.283834] sd 6:0:0:0: [sdd] Attached SCSI removable disk &amp;lt;br /&amp;gt;&lt;br /&gt;
{{clos}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
{{ imbox | type=notice | text=If using a virtual machine, wait for Windows to install the Virtualbox USB driver. Then make the virtual machine aware of the USB drive by going into the Devices menu option in virtualbox, then sub-option USB and select your USB device.}}&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The output of the &amp;lt;code&amp;gt;dmesg&amp;lt;/code&amp;gt; command shows that the root device node for the USB drive in this case is &amp;lt;code&amp;gt;sdd&amp;lt;/code&amp;gt; and no partitions. Partitions on the drive would be listed as &amp;lt;code&amp;gt;sdd1&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;sdd2&amp;lt;/code&amp;gt;, etc.  Inspect the output shown above to see the particular device node on the development PC where the USB drive is mounted. This will be different depending on the configuration of the development PC. The &amp;lt;code&amp;gt;/dev/&amp;lt;/code&amp;gt; prefix will go before the device name, but is not shown in the output of &amp;lt;code&amp;gt;dmesg&amp;lt;/code&amp;gt;. The device node will start with &amp;lt;code&amp;gt;sd&amp;lt;/code&amp;gt;. The third letter will specify which of these devices is assigned to the USB drive. The number will indicate the partitions, if any. Press Ctrl and 'c' to exit dmesg.&lt;br /&gt;
&lt;br /&gt;
* At this point, it is wise to double check that device node is actually the USB drive and not a hard drive in the system. Specifying the wrong device node could cause a complete loss of data on a hard drive.  &amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt; Continuing with &amp;lt;code&amp;gt;/dev/sdd&amp;lt;/code&amp;gt; as the example device node, type the following command:&lt;br /&gt;
&lt;br /&gt;
{{clo}}&lt;br /&gt;
{{clio | username=developer | hostname=ldc | pwd=~ | mount {{!}} grep sdd }}&lt;br /&gt;
/dev/sdd on /media/developer/FBF6-1988 type vfat&lt;br /&gt;
{{clos}}&lt;br /&gt;
&lt;br /&gt;
This shows that the device node, &amp;lt;code&amp;gt;/dev/sdd&amp;lt;/code&amp;gt;, is in fact the USB drive.  This is because:&lt;br /&gt;
* It is not mounted on one of the standard Linux filesystem mountpoints, such as &amp;lt;code&amp;gt;/&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;/boot&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;/usr&amp;lt;/code&amp;gt;, or &amp;lt;code&amp;gt;/home&amp;lt;/code&amp;gt;.&lt;br /&gt;
* It '''is''' mounted in the &amp;lt;code&amp;gt;/media&amp;lt;/code&amp;gt; directory, where it is expected.  It may alternatively get mounted in &amp;lt;code&amp;gt;/mnt&amp;lt;/code&amp;gt;, depending upon the configuration of the Linux distribution in use.&lt;br /&gt;
&lt;br /&gt;
If nothing is returned, then the USB drive did not get automatically mounted. Proceed to the next step.&lt;br /&gt;
&lt;br /&gt;
Use &amp;lt;code&amp;gt;fdisk -l&amp;lt;/code&amp;gt; to inspect the device node. Use &amp;lt;code&amp;gt;sudo&amp;lt;/code&amp;gt; with &amp;lt;code&amp;gt;fdisk&amp;lt;/code&amp;gt; to gain the required &amp;lt;code&amp;gt;root&amp;lt;/code&amp;gt; privileges to run &amp;lt;code&amp;gt;fdisk&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{clop}}&lt;br /&gt;
{{cliop | username=developer | hostname=ldc | pwd=~ | sudo fdisk -l /dev/sdd }}&amp;lt;nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Disk /dev/sdd: 3.7 GiB, 3980394496 bytes, 7774208 sectors&lt;br /&gt;
Disk model: STORAGE DEVICE  &lt;br /&gt;
Units: sectors of 1 * 512 = 512 bytes&lt;br /&gt;
Sector size (logical/physical): 512 bytes / 512 bytes&lt;br /&gt;
I/O size (minimum/optimal): 512 bytes / 512 bytes&lt;br /&gt;
Disklabel type: dos&lt;br /&gt;
Disk identifier: 0x4fcf5773&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
{{closp}}&lt;br /&gt;
&lt;br /&gt;
The output of fdisk will also show information about any partitions that may exist on the USB drive. For example, another drive with a single FAT32 formatted partition will look like:&lt;br /&gt;
{{clop}}&lt;br /&gt;
{{cliop | username=developer | hostname=ldc | pwd=~ | sudo fdisk -l /dev/sdd }}&amp;lt;nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Disk /dev/sdd: 3.7 GiB, 3980394496 bytes, 7774208 sectors&lt;br /&gt;
Disk model: STORAGE DEVICE  &lt;br /&gt;
Units: sectors of 1 * 512 = 512 bytes&lt;br /&gt;
Sector size (logical/physical): 512 bytes / 512 bytes&lt;br /&gt;
I/O size (minimum/optimal): 512 bytes / 512 bytes&lt;br /&gt;
Disklabel type: dos&lt;br /&gt;
Disk identifier: 0xe6077d37&lt;br /&gt;
&lt;br /&gt;
Device     Boot Start     End Sectors  Size Id Type&lt;br /&gt;
/dev/sdh1        2048 7774207 7772160  3.7G  c W95 FAT32 (LBA)&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
{{closp}}&lt;br /&gt;
&lt;br /&gt;
* As can be seen from the output of the &amp;lt;code&amp;gt;fdisk -l&amp;lt;/code&amp;gt; command above, the disk is 3.7 GB in size, which corresponds with the size of the 4 GB USB drive being used in this example.&lt;br /&gt;
&lt;br /&gt;
Unmount all of the USB drives partitions that were listed from the &amp;lt;code&amp;gt;mount&amp;lt;/code&amp;gt; command above.&lt;br /&gt;
&lt;br /&gt;
{{cli | username=developer | hostname=ldc | pwd=~ | sudo umount /dev/sdd }}&lt;br /&gt;
&lt;br /&gt;
If there is a partition listed:&lt;br /&gt;
&lt;br /&gt;
{{cli | username=developer | hostname=ldc | pwd=~ | sudo umount /dev/sdd1 }}&lt;br /&gt;
&lt;br /&gt;
==Repartition the USB Drive==&lt;br /&gt;
&lt;br /&gt;
Once the correct drive letter is determined, we will create a new Linux partition.&lt;br /&gt;
&lt;br /&gt;
{{clop}}&lt;br /&gt;
{{cliop | username=developer | hostname=ldc | pwd=~ | sudo fdisk /dev/sdd }}&amp;lt;nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Welcome to fdisk (util-linux 2.33.1).&lt;br /&gt;
Changes will remain in memory only, until you decide to write them.&lt;br /&gt;
Be careful before using the write command.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Command (m for help): o&lt;br /&gt;
Created a new DOS disklabel with disk identifier 0x05d5e983.&lt;br /&gt;
&lt;br /&gt;
Command (m for help): n&lt;br /&gt;
Partition type&lt;br /&gt;
   p   primary (0 primary, 0 extended, 4 free)&lt;br /&gt;
   e   extended (container for logical partitions)&lt;br /&gt;
Select (default p): p&lt;br /&gt;
Partition number (1-4, default 1): 1&lt;br /&gt;
First sector (2048-7774207, default 2048): &lt;br /&gt;
Last sector, +/-sectors or +/-size{K,M,G,T,P} (2048-7774207, default 7774207): &lt;br /&gt;
&lt;br /&gt;
Created a new partition 1 of type 'Linux' and of size 3.7 GiB.&lt;br /&gt;
&lt;br /&gt;
Command (m for help): p&lt;br /&gt;
Disk /dev/sdd: 3.7 GiB, 3980394496 bytes, 7774208 sectors&lt;br /&gt;
Disk model: STORAGE DEVICE  &lt;br /&gt;
Units: sectors of 1 * 512 = 512 bytes&lt;br /&gt;
Sector size (logical/physical): 512 bytes / 512 bytes&lt;br /&gt;
I/O size (minimum/optimal): 512 bytes / 512 bytes&lt;br /&gt;
Disklabel type: dos&lt;br /&gt;
Disk identifier: 0x05d5e983&lt;br /&gt;
&lt;br /&gt;
Device     Boot Start     End Sectors  Size Id Type&lt;br /&gt;
/dev/sdd1        2048 7774207 7772160  3.7G 83 Linux&lt;br /&gt;
&lt;br /&gt;
Command (m for help): w&lt;br /&gt;
The partition table has been altered.&lt;br /&gt;
Calling ioctl() to re-read partition table.&lt;br /&gt;
Syncing disks.&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
{{closp}}&lt;br /&gt;
&lt;br /&gt;
The fdisk commands are:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;o&amp;lt;/code&amp;gt; - Create a new empty partition table&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;n&amp;lt;/code&amp;gt; - Create a new partition&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;p&amp;lt;/code&amp;gt; - The type of partition is a primary partition&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;1&amp;lt;/code&amp;gt; - Create the first partition&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;ENTER&amp;gt;&amp;lt;/code&amp;gt; - Accept default start&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;ENTER&amp;gt;&amp;lt;/code&amp;gt; - Accept default end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;p&amp;lt;/code&amp;gt; - Print the new partition layout&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;w&amp;lt;/code&amp;gt; - Write the new partition layout and exit&lt;br /&gt;
&lt;br /&gt;
==Format the Partition==&lt;br /&gt;
&lt;br /&gt;
The first partition will be formatted with the ext4 filesystem.&lt;br /&gt;
&lt;br /&gt;
{{cli | username=developer | hostname=ldc | pwd=~ | yes {{!}} sudo mkfs.ext4 /dev/sdd1 }}&lt;br /&gt;
&lt;br /&gt;
==Mount the Partition==&lt;br /&gt;
&lt;br /&gt;
The first partition of the USB drive will be mounted so that it is accessible to write to.&lt;br /&gt;
&lt;br /&gt;
{{cli | username=developer | hostname=ldc | pwd=~ | sudo mkdir -p /media/card }}&lt;br /&gt;
{{cli | username=developer | hostname=ldc | pwd=~ | sudo mount /dev/sdd1 /media/card }}&lt;br /&gt;
&lt;br /&gt;
The USB drive is now accessible through the &amp;lt;code&amp;gt;/media/card&amp;lt;/code&amp;gt; directory.&lt;br /&gt;
&lt;br /&gt;
==Extract Filesystem Archive==&lt;br /&gt;
&lt;br /&gt;
Locate where the filesystem archive has been downloaded. If the archive is called rootfs.tar.gz and is in the users Downloads directory:&lt;br /&gt;
&lt;br /&gt;
{{cli | username=developer | hostname=ldc | pwd=~ | cd /media/card }}&lt;br /&gt;
{{cli | username=developer | hostname=ldc | pwd=/media/card | sudo tar zxf ~/Downloads/rootfs.tar.gz }}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Configuring the Client to Boot from USB==&lt;br /&gt;
&lt;br /&gt;
===Configuring U-Boot===&lt;br /&gt;
&lt;br /&gt;
Insert the USB drive into an available port on the target board.&lt;br /&gt;
Set the bootargs variable to tell the kernel to boot into the USB filesystem:&lt;br /&gt;
&lt;br /&gt;
 U-Boot&amp;gt; setenv bootargs console=${console} root=/dev/sda1 rootfstype=ext4&lt;br /&gt;
 U-Boot&amp;gt; run bootargs&lt;br /&gt;
&lt;br /&gt;
This line sets up the environment needed to boot from the USB drive.  These options will be passed to the Linux kernel when booting it.  The &amp;lt;code&amp;gt;console=${console}&amp;lt;/code&amp;gt; part tells Linux to use the console setting from the U-Boot environment variable; this will usually be something along the lines of &amp;lt;code&amp;gt;console=ttyS0,115200n8&amp;lt;/code&amp;gt;.  The &amp;lt;code&amp;gt;root=/dev/sda1&amp;lt;/code&amp;gt; directive tells Linux to instantiate with the USB block device, &amp;lt;code&amp;gt;/dev/sda1&amp;lt;/code&amp;gt;, as the root filesystem. The &amp;lt;code&amp;gt;rootfstype=ext4&amp;lt;/code&amp;gt; directive tells Linux that the root filesystem is of the EXT4 variety.  &lt;br /&gt;
&lt;br /&gt;
If the kernel is already programmed into the flash, it can be used in most cases to boot into the USB root filesystem. Execute the next line to load and run the default kernel.&lt;br /&gt;
&lt;br /&gt;
 U-Boot&amp;gt; boot&lt;br /&gt;
&lt;br /&gt;
The machine should now boot, and show output on its console as it does so.&lt;br /&gt;
&lt;br /&gt;
===Alternate Kernel Load===&lt;br /&gt;
&lt;br /&gt;
An alternate kernel can be loaded into memory temporarily and booted if the kernel is not already programmed in the flash or a development kernel is to be tested. The below example assumes a kernel named zImage-test was placed in the /boot directory of the USB drive. Also see [[ Loading_Images_with_U-Boot#Executing_kernel_from_RAM  | Executing kernel from RAM ]]&lt;br /&gt;
&lt;br /&gt;
 U-Boot&amp;gt; usb start&lt;br /&gt;
 U-Boot&amp;gt; usb storage&lt;br /&gt;
 U-Boot&amp;gt; ext2load usb 0:1 ${loadaddr} /boot/zImage-test&lt;br /&gt;
 U-Boot&amp;gt; bootz ${loadaddr}&lt;br /&gt;
&lt;br /&gt;
The first two commands initialize the USB storage system in U-Boot. The &amp;lt;code&amp;gt;ext2load&amp;lt;/code&amp;gt; line says to use the USB device 0 partition 1 and load into RAM at ${loadaddr} the file /boot/zImage-test from the USB drive. The last line boots the kernel that has been loaded into memory.&lt;br /&gt;
&lt;br /&gt;
==Conclusion==&lt;br /&gt;
&lt;br /&gt;
Using a USB thumb drive for the root filesystem allows boards to boot quickly into a rescue or known good version of a filesystem and provides a method for remotely backing up the filesystem installed on an embedded machine.  Setting up a machine to boot to a root filesystem via USB requires little work; most of the work is in setting up the USB thumb drive.&lt;br /&gt;
&lt;br /&gt;
{{:Templateimpl:moreinfo | initials=MG | title=System Logging | desc=The page describes how to USB boot. | project=OE 5.0 }}&lt;br /&gt;
* [[Loading_Images_onto_eMMC_Devices | Loading Images onto eMMC Devices]]&lt;br /&gt;
* [[Loading_Images_with_U-Boot | Loading Images with U-Boot]]&lt;br /&gt;
* [[Loading_Linux_Kernels_Onto_a_Board | Loading Linux Kernels Onto a Board]]&lt;/div&gt;</summary>
		<author><name>Mgloff</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.emacinc.com/index.php?title=Loading_Images_onto_eMMC_Devices&amp;diff=5629</id>
		<title>Loading Images onto eMMC Devices</title>
		<link rel="alternate" type="text/html" href="https://wiki.emacinc.com/index.php?title=Loading_Images_onto_eMMC_Devices&amp;diff=5629"/>
		<updated>2019-03-05T23:44:50Z</updated>

		<summary type="html">&lt;p&gt;Mgloff: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{todo|SEOKWREV (12.31.13-13:15-&amp;gt;MD-);(12.31.13-14:50-&amp;gt;MW+);(12.31.13-18:10-&amp;gt;MD+);(12.31.13-18:45-&amp;gt;MG+);(03.06.14-15:35-&amp;gt;BS-);(04.11.14-15:55-&amp;gt;BS+);(05.01.15-12:12-&amp;gt;MG+);(11.05.15-17:50-&amp;gt;MD+)|Michael Welling|project=oe 4,oe 5,mw,md,mg,bs,SEOKWREV}}&lt;br /&gt;
&lt;br /&gt;
{{#seo:&lt;br /&gt;
|title=Loading Images onto eMMC Devices&lt;br /&gt;
|titlemode=append&lt;br /&gt;
|keywords=eMMC,EXT3 Partition,FAT32 Partition,Root File System&lt;br /&gt;
|description=Some EMAC products use eMMC in place of NAND flash. eMMC is an embedded MMC compliant memory that takes the form of an integrated circuit instead of a media card. &lt;br /&gt;
}}&lt;br /&gt;
== Background ==&lt;br /&gt;
Some EMAC products use eMMC in place of NAND flash. eMMC is an embedded MMC compliant memory that takes the form of an integrated circuit instead of a media card. &lt;br /&gt;
&lt;br /&gt;
U-Boot does not support writing to file systems in eMMC. To overcome this issue, the embedded target needs to boot into an alternate media such as a network file system or USB flash drive. Once the board has booted into Linux, the eMMC can be partitioned and formatted, and the root file system can be extracted. The SoM-3517M requires a special FAT formatted partition that contains the bootloader and Linux kernel images. This article explains the general process of writing the eMMC from Linux as well as some specifics related to programming the SoM-3517M, SoM-9X25, SoM-A5D35/6, SoM-3354, SoM-iMX6M and IPAC-9X25.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{note | The procedures below require that you have a TFTP and NFS server setup on a host computer or a USB thumb drive created using [[Booting_with_a_USB_Root_Filesystem | Booting with a USB Root Filesystem]]. }}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* Instructions on setting up a TFTP server: [[Installing TFTP server]]&lt;br /&gt;
* Installation of an NFS Server with Linux: [[Setting up an NFS File Server]]&lt;br /&gt;
* Instruction for booting into NFS with U-Boot: [[Booting with an NFS Root Filesystem]]&lt;br /&gt;
* More information about MMC: http://en.wikipedia.org/wiki/MultiMediaCard&lt;br /&gt;
&lt;br /&gt;
== Creating partitions and formatting eMMC ==&lt;br /&gt;
&lt;br /&gt;
Once the Linux command prompt is reached, Linux utilities can be used to create and format partitions on the eMMC. By partitioning the eMMC, the partitions can be accessed individually and formatted differently as required. The &amp;lt;code&amp;gt;fdisk&amp;lt;/code&amp;gt; utility can be used to create these partitions on the eMMC.&lt;br /&gt;
&lt;br /&gt;
For example here is the procedure for creating a 128 MB primary partition:&lt;br /&gt;
&lt;br /&gt;
{{clop}}&lt;br /&gt;
{{cliop | hostname=emac-oe |fdisk /dev/mmcblk0}}&amp;lt;nowiki&amp;gt;&lt;br /&gt;
The number of cylinders for this disk is set to 57024.&lt;br /&gt;
There is nothing wrong with that, but this is larger than 1024,&lt;br /&gt;
and could in certain setups cause problems with:&lt;br /&gt;
1) software that runs at boot time (e.g., old versions of LILO)&lt;br /&gt;
2) booting and partitioning software from other OSs&lt;br /&gt;
   (e.g., DOS FDISK, OS/2 FDISK)&lt;br /&gt;
Command (m for help): n&lt;br /&gt;
Command action&lt;br /&gt;
   e   extended&lt;br /&gt;
   p   primary partition (1-4)&lt;br /&gt;
p&lt;br /&gt;
Partition number (1-4): 1&lt;br /&gt;
First cylinder (1-57024, default 1): Using default value 1&lt;br /&gt;
Last cylinder or +size or +sizeM or +sizeK (1-57024, default 57024): +128M&lt;br /&gt;
 &lt;br /&gt;
Command (m for help): p&lt;br /&gt;
 &lt;br /&gt;
Disk /dev/mmcblk0: 1868 MB, 1868562432 bytes&lt;br /&gt;
4 heads, 16 sectors/track, 57024 cylinders&lt;br /&gt;
Units = cylinders of 64 * 512 = 32768 bytes&lt;br /&gt;
&lt;br /&gt;
        Device Boot      Start         End      Blocks  Id System&lt;br /&gt;
/dev/mmcblk0p1               1        3907      125016  83 Linux&lt;br /&gt;
&lt;br /&gt;
Command (m for help): w&lt;br /&gt;
The partition table has been altered!&lt;br /&gt;
&lt;br /&gt;
Calling ioctl() to re-read partition table&lt;br /&gt;
[  566.062896]  mmcblk0: p1&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
{{cliop | hostname=emac-oe|}}&lt;br /&gt;
{{closp}}&lt;br /&gt;
&lt;br /&gt;
For more information about &amp;lt;code&amp;gt;fdisk&amp;lt;/code&amp;gt;, see:&lt;br /&gt;
http://tldp.org/HOWTO/Partition/fdisk_partitioning.html&lt;br /&gt;
&lt;br /&gt;
After creating the partitions, they can formatted with the various &amp;lt;code&amp;gt;mkfs&amp;lt;/code&amp;gt; utilities. The formatting used is dependent on how the partition is to be accessed. For eMMC root filesystems EMAC currently uses EXT4 (http://en.wikipedia.org/wiki/Ext3). Other formatting options are available (EXT2, EXT3, etc) and can be used. It should be noted that the kernel must be configured to support the chosen filesystem and the bootargs need to specify the correct type. &lt;br /&gt;
&lt;br /&gt;
{{note | For additional information on configuring and compiling the Linux kernel see the following page: [[Building the Linux Kernel]] }}&lt;br /&gt;
&lt;br /&gt;
As described above, the &amp;lt;code&amp;gt;bootargs&amp;lt;/code&amp;gt; is used for signalling to the Linux kernel the location of the root filesystem partition, and its formatting. The &amp;lt;code&amp;gt;root&amp;lt;/code&amp;gt; parameter is used to specify the partition to use while the &amp;lt;code&amp;gt;rootfstype&amp;lt;/code&amp;gt; parameter is used to specify the formatting of the partition.&lt;br /&gt;
&lt;br /&gt;
{{note | For more information about the &amp;lt;code&amp;gt;bootargs&amp;lt;/code&amp;gt; variable see this page: [[U-Boot Overview]] }}&lt;br /&gt;
&lt;br /&gt;
Partitions accessed by processor boot ROM or U-Boot typically need to be formatted with FAT32 formatting. The SoM-3517M, for instance, requires a FAT32 formatted partition for the bootloader and kernel in order to boot properly from eMMC. For more specifics about the SoM-3517M, see the quick reference section below.&lt;br /&gt;
&lt;br /&gt;
===Formatting a partition with EXT4===&lt;br /&gt;
&lt;br /&gt;
{{clop}}&lt;br /&gt;
{{cliop | hostname=emac-oe |mkfs.ext4 /dev/mmcblk0p1}}&amp;lt;nowiki&amp;gt;&lt;br /&gt;
mke2fs 1.41.14 (22-Dec-2010)&lt;br /&gt;
Filesystem label=&lt;br /&gt;
OS type: Linux&lt;br /&gt;
Block size=1024 (log=0)&lt;br /&gt;
Fragment size=1024 (log=0)&lt;br /&gt;
Stride=0 blocks, Stripe width=0 blocks&lt;br /&gt;
31360 inodes, 125016 blocks&lt;br /&gt;
6250 blocks (5.00%) reserved for the super user&lt;br /&gt;
First data block=1&lt;br /&gt;
Maximum filesystem blocks=67371008&lt;br /&gt;
16 block groups&lt;br /&gt;
8192 blocks per group, 8192 fragments per group&lt;br /&gt;
1960 inodes per group&lt;br /&gt;
Superblock backups stored on blocks: &lt;br /&gt;
        8193, 24577, 40961, 57345, 73729&lt;br /&gt;
&lt;br /&gt;
Writing inode tables: done      &lt;br /&gt;
Creating journal (4096 blocks): done&lt;br /&gt;
Writing superblocks and filesystem accounting information: done&lt;br /&gt;
 &lt;br /&gt;
This filesystem will be automatically checked every 39 mounts or&lt;br /&gt;
180 days, whichever comes first.  Use tune2fs -c or -i to override.&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
{{cliop| hostname=emac-oe |}}&lt;br /&gt;
{{closp}}&lt;br /&gt;
&lt;br /&gt;
===Formatting a partition with FAT32===&lt;br /&gt;
&lt;br /&gt;
{{clop}}&lt;br /&gt;
{{cliop | hostname=emac-oe |mkdosfs -F 32 /dev/mmcblk0p1}}&lt;br /&gt;
mkdosfs 2.11 (12 Mar 2005)&lt;br /&gt;
{{cliop | hostname=emac-oe |}}&lt;br /&gt;
{{closp}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Extracting filesystems to eMMC ==&lt;br /&gt;
After formatting a partition correctly, the partition can be mounted and files can be loaded to the eMMC.&lt;br /&gt;
&lt;br /&gt;
For example, here is the procedure for writing a root filesystem to the first partition of an eMMC card:&lt;br /&gt;
&lt;br /&gt;
{{clo}}&lt;br /&gt;
{{clio | hostname=emac-oe |mkdir -p /mnt/card}}&lt;br /&gt;
{{clio | hostname=emac-oe |mount /dev/mmcblk0p1 /mnt/card}}&lt;br /&gt;
{{clio | hostname=emac-oe |cd /mnt/card}}&lt;br /&gt;
{{clio | hostname=emac-oe |tar xzvf /images/emac-image.rootfs.tar.gz}}&lt;br /&gt;
&amp;lt;nowiki&amp;gt;    ⋮&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
{{clos}}&lt;br /&gt;
&lt;br /&gt;
In the above example the &amp;lt;code&amp;gt;/mnt/card&amp;lt;/code&amp;gt; directory is called the mount point. The &amp;lt;code&amp;gt;mkdir -p&amp;lt;/code&amp;gt; command creates the directory if it does not already exist. The &amp;lt;code&amp;gt;mount&amp;lt;/code&amp;gt; command attaches the specified partition to the directory. Any files written to the mounted directory will go to the partition on the eMMC. After the mount is complete, files can be extracted as shown using the &amp;lt;code&amp;gt;tar&amp;lt;/code&amp;gt; command.&lt;br /&gt;
&lt;br /&gt;
It should be noted that the &amp;lt;code&amp;gt;/etc/fstab&amp;lt;/code&amp;gt; file can be used to specify mount points for partitions upon boot. See http://en.wikipedia.org/wiki/Fstab for additional information.&lt;br /&gt;
&lt;br /&gt;
== Quick Reference (by Target Type) ==&lt;br /&gt;
This section is used to provide specifics for programming eMMC on various targets.&lt;br /&gt;
&lt;br /&gt;
For the partitioning sections, the information in the parenthesis denotes a keyboard input sequence. The (n,p,1,default,+64M) creates a new primary partition. Each input is followed a carriage return and the default is selected by pressing carriage return with no entry. See the expanded example in the above '''Creating partitions and formatting eMMC''' section for an idea of how the interface looks when commands are executed correctly.&lt;br /&gt;
&lt;br /&gt;
=== SoM-3517M ===&lt;br /&gt;
==== Partitioning the eMMC ====&lt;br /&gt;
&lt;br /&gt;
{{cli | hostname=emac-oe |fdisk -H 255 -S 63 /dev/mmcblk0}}&lt;br /&gt;
&lt;br /&gt;
The partitioning steps are as follows:&lt;br /&gt;
# Create 1st partition (n,p,1,default,+64M)&lt;br /&gt;
# Create 2nd partition (n,p,2,default,default)&lt;br /&gt;
# Change 1st partition type to FAT32 (t,1,c)&lt;br /&gt;
# Make 1st partition ACTIVE (a,1)&lt;br /&gt;
# Write (w)&lt;br /&gt;
&lt;br /&gt;
==== Formatting the eMMC ====&lt;br /&gt;
&lt;br /&gt;
{{clo}}&lt;br /&gt;
{{clio | hostname=emac-oe |mkfs.ext3 /dev/mmcblk0p2}}&lt;br /&gt;
{{clio | hostname=emac-oe |mkdosfs -F 32 /dev/mmcblk0p1}}&lt;br /&gt;
{{clos}}&lt;br /&gt;
&lt;br /&gt;
The first command formats the second partition as ext3. The &amp;lt;code&amp;gt;mkfs.ext3&amp;lt;/code&amp;gt; command can take further configuration parameters. See the &amp;lt;code&amp;gt;mkfs.ext3&amp;lt;/code&amp;gt; man page for more information.&lt;br /&gt;
&lt;br /&gt;
The second command formats the first partition as FAT32 for use with the AM3517's boot ROM. This is a requirement to boot from the eMMC.&lt;br /&gt;
&lt;br /&gt;
==== Adding Kernel and Bootloader ====&lt;br /&gt;
&lt;br /&gt;
{{clo}}&lt;br /&gt;
{{clio | hostname=emac-oe |mkdir -p /mnt/card}}&lt;br /&gt;
{{clio | hostname=emac-oe |mount /dev/mmcblk0p1 /mnt/card}}&lt;br /&gt;
{{clio | hostname=emac-oe |cd /images}}&lt;br /&gt;
{{clio | hostname=emac-oe | pwd=images |cp MLO uImage u-boot.bin /mnt/card/}}&lt;br /&gt;
{{clio | hostname=emac-oe | pwd=images |sync}}&lt;br /&gt;
{{clio | hostname=emac-oe | pwd=images |umount /dev/mmcblk0p1}}&lt;br /&gt;
{{clos}}&lt;br /&gt;
&lt;br /&gt;
{{ note | The first partition '''must''' be formatted FAT32 and the MLO binary '''must''' be in the first sector for the eMMC boot sequence to work properly.  }}&lt;br /&gt;
&lt;br /&gt;
==== Extracting Root Filesystem ====&lt;br /&gt;
{{clo}}&lt;br /&gt;
{{clio | hostname=emac-oe | pwd=images |mount /dev/mmcblk0p2 /mnt/card}}&lt;br /&gt;
{{clio | hostname=emac-oe | pwd=images |cd /mnt/card}}&lt;br /&gt;
{{clio | hostname=emac-oe | pwd=/mnt/card |tar xzvf /emac-image.rootfs.tar.gz}}&lt;br /&gt;
{{clio | hostname=emac-oe | pwd=/mnt/card |cd ..}}&lt;br /&gt;
{{clio | hostname=emac-oe | pwd=/mnt |sync}}&lt;br /&gt;
{{clio | hostname=emac-oe | pwd=/mnt |umount /dev/mmcblk0p2}}&lt;br /&gt;
{{clos}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== SoM-9X25M / IPAC-9X25 / SoM-A5D35/6 / SoM-3354 / SoM-iMX6M ===&lt;br /&gt;
&lt;br /&gt;
Unlike the SoM-3517, these SoMs store U-Boot and the Linux kernel in a separate serial flash instead of the eMMC. Typically, two partitions are created. The first partition contains the complete filesystem and is mounted read-only while the second partition contains the /home directory and is mounted read-write.&lt;br /&gt;
&lt;br /&gt;
=== Unmount partitions ===&lt;br /&gt;
&lt;br /&gt;
{{cli | hostname=emac-oe |umount /dev/mmcblk0p1}}&lt;br /&gt;
{{cli | hostname=emac-oe |umount /dev/mmcblk0p2}}&lt;br /&gt;
&lt;br /&gt;
==== Partitioning the eMMC ====&lt;br /&gt;
&lt;br /&gt;
{{cli | hostname=emac-oe |fdisk /dev/mmcblk0}}&lt;br /&gt;
&lt;br /&gt;
{{ note | For the SoM-9x25M revisions 7 and above, the eMMC block device is /dev/sdb }}&lt;br /&gt;
&lt;br /&gt;
The partitioning steps are as follows:&lt;br /&gt;
&lt;br /&gt;
# Create 1st partition (n,p,1,default,+1G)&lt;br /&gt;
# Create 2nd partition (n,p,2,default,default)&lt;br /&gt;
# Write (w)&lt;br /&gt;
&lt;br /&gt;
==== Formatting the eMMC ====&lt;br /&gt;
{{clo}}&lt;br /&gt;
{{clio | hostname=emac-oe |mkfs.ext4 /dev/mmcblk0p1}}&lt;br /&gt;
{{clio | hostname=emac-oe |mkfs.ext4 /dev/mmcblk0p2}}&lt;br /&gt;
{{clos}}&lt;br /&gt;
&lt;br /&gt;
==== Extracting Root Filesystem ====&lt;br /&gt;
{{clo}}&lt;br /&gt;
{{clio | hostname=emac-oe |mkdir -p /mnt/card}}&lt;br /&gt;
{{clio | hostname=emac-oe |mount /dev/mmcblk0p1 /mnt/card}}&lt;br /&gt;
{{clio | hostname=emac-oe |cd /mnt/card}}&lt;br /&gt;
{{clio | hostname=emac-oe | pwd=/mnt/card |tar xzvf /emac-image.rootfs.tar.gz}}&lt;br /&gt;
{{clio | hostname=emac-oe | pwd=/mnt/card |cd ..}}&lt;br /&gt;
{{clio | hostname=emac-oe | pwd=/mnt |sync}}&lt;br /&gt;
{{clio | hostname=emac-oe | pwd=/mnt |umount /dev/mmcblk0p1}}&lt;br /&gt;
{{clos}}&lt;/div&gt;</summary>
		<author><name>Mgloff</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.emacinc.com/index.php?title=Booting_with_a_USB_Root_Filesystem&amp;diff=5628</id>
		<title>Booting with a USB Root Filesystem</title>
		<link rel="alternate" type="text/html" href="https://wiki.emacinc.com/index.php?title=Booting_with_a_USB_Root_Filesystem&amp;diff=5628"/>
		<updated>2019-03-05T23:40:33Z</updated>

		<summary type="html">&lt;p&gt;Mgloff: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;It is possible to boot most EMAC OE systems using a USB thumb drive as the root filesystem and to optionally load a kernel from. This method can be especially useful for updating or recovering the root filesystem when a network connection or a network file server is not available. This page describes the steps required to boot into a root filesystem residing on a USB thumb drive.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==Prerequisites==&lt;br /&gt;
&lt;br /&gt;
Some prerequisites must be met prior to being able to boot a root filesystem from a USB drive.&lt;br /&gt;
&lt;br /&gt;
===USB Thumb Drive===&lt;br /&gt;
&lt;br /&gt;
Any blank USB drive. If it is not blank, this process will completely wipe the data that exists on the USB drive.&lt;br /&gt;
&lt;br /&gt;
===Root Filesystem===&lt;br /&gt;
&lt;br /&gt;
A complete root filesystem for the EMAC OE system to boot from must be stored on the USB drive.&lt;br /&gt;
&lt;br /&gt;
===Linux Host Computer===&lt;br /&gt;
&lt;br /&gt;
Either a native Linux host or Windows host running a Linux virtual machine.&lt;br /&gt;
&lt;br /&gt;
==Configuring the USB Thumb Drive==&lt;br /&gt;
&lt;br /&gt;
In a terminal window, start the dmesg log with the follow option to watch for new devices.&lt;br /&gt;
&lt;br /&gt;
{{cli | username=developer | hostname=ldc | pwd=~ | dmesg -w }}&lt;br /&gt;
&lt;br /&gt;
Insert the USB drive and watch for the device to be announced.&lt;br /&gt;
&lt;br /&gt;
{{clo}}&lt;br /&gt;
[ 2796.940110] scsi host6: usb-storage 1-1.2:1.0 &amp;lt;br /&amp;gt;&lt;br /&gt;
[ 2797.963442] scsi 6:0:0:0: Direct-Access     Generic  STORAGE DEVICE   0272 PQ: 0 ANSI: 0 &amp;lt;br /&amp;gt;&lt;br /&gt;
[ 2797.963905] sd 6:0:0:0: Attached scsi generic sg4 type 0 &amp;lt;br /&amp;gt;&lt;br /&gt;
[ 2798.269544] sd 6:0:0:0: [sdd] 7774208 512-byte logical blocks: (3.98 GB/3.71 GiB) &amp;lt;br /&amp;gt;&lt;br /&gt;
[ 2798.271027] sd 6:0:0:0: [sdd] Write Protect is off &amp;lt;br /&amp;gt;&lt;br /&gt;
[ 2798.271030] sd 6:0:0:0: [sdd] Mode Sense: 0b 00 00 08 &amp;lt;br /&amp;gt;&lt;br /&gt;
[ 2798.272502] sd 6:0:0:0: [sdd] No Caching mode page found &amp;lt;br /&amp;gt;&lt;br /&gt;
[ 2798.272508] sd 6:0:0:0: [sdd] Assuming drive cache: write through &amp;lt;br /&amp;gt;&lt;br /&gt;
[ 2798.279486]  sdd: &amp;lt;br /&amp;gt;&lt;br /&gt;
[ 2798.283834] sd 6:0:0:0: [sdd] Attached SCSI removable disk &amp;lt;br /&amp;gt;&lt;br /&gt;
{{clos}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
{{ imbox | type=notice | text=If using a virtual machine, wait for Windows to install the Virtualbox USB driver. Then make the virtual machine aware of the USB drive by going into the Devices menu option in virtualbox, then sub-option USB and select your USB device.}}&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The output of the &amp;lt;code&amp;gt;dmesg&amp;lt;/code&amp;gt; command shows that the root device node for the USB drive in this case is &amp;lt;code&amp;gt;sdd&amp;lt;/code&amp;gt; and no partitions. Partitions on the drive would be listed as &amp;lt;code&amp;gt;sdd1&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;sdd2&amp;lt;/code&amp;gt;, etc.  Inspect the output shown above to see the particular device node on the development PC where the USB drive is mounted. This will be different depending on the configuration of the development PC. The &amp;lt;code&amp;gt;/dev/&amp;lt;/code&amp;gt; prefix will go before the device name, but is not shown in the output of &amp;lt;code&amp;gt;dmesg&amp;lt;/code&amp;gt;. The device node will start with &amp;lt;code&amp;gt;sd&amp;lt;/code&amp;gt;. The third letter will specify which of these devices is assigned to the USB drive. The number will indicate the partitions, if any. Press Ctrl and 'c' to exit dmesg.&lt;br /&gt;
&lt;br /&gt;
* At this point, it is wise to double check that device node is actually the USB drive and not a hard drive in the system. Specifying the wrong device node could cause a complete loss of data on a hard drive.  &amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt; Continuing with &amp;lt;code&amp;gt;/dev/sdd&amp;lt;/code&amp;gt; as the example device node, type the following command:&lt;br /&gt;
&lt;br /&gt;
{{clo}}&lt;br /&gt;
{{clio | username=developer | hostname=ldc | pwd=~ | mount {{!}} grep sdd }}&lt;br /&gt;
/dev/sdd on /media/developer/FBF6-1988 type vfat&lt;br /&gt;
{{clos}}&lt;br /&gt;
&lt;br /&gt;
This shows that the device node, &amp;lt;code&amp;gt;/dev/sdd&amp;lt;/code&amp;gt;, is in fact the USB drive.  This is because:&lt;br /&gt;
* It is not mounted on one of the standard Linux filesystem mountpoints, such as &amp;lt;code&amp;gt;/&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;/boot&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;/usr&amp;lt;/code&amp;gt;, or &amp;lt;code&amp;gt;/home&amp;lt;/code&amp;gt;.&lt;br /&gt;
* It '''is''' mounted in the &amp;lt;code&amp;gt;/media&amp;lt;/code&amp;gt; directory, where it is expected.  It may alternatively get mounted in &amp;lt;code&amp;gt;/mnt&amp;lt;/code&amp;gt;, depending upon the configuration of the Linux distribution in use.&lt;br /&gt;
&lt;br /&gt;
Use &amp;lt;code&amp;gt;fdisk -l&amp;lt;/code&amp;gt; to inspect the device node. Use &amp;lt;code&amp;gt;sudo&amp;lt;/code&amp;gt; with &amp;lt;code&amp;gt;fdisk&amp;lt;/code&amp;gt; to gain the required &amp;lt;code&amp;gt;root&amp;lt;/code&amp;gt; privileges to run &amp;lt;code&amp;gt;fdisk&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{clop}}&lt;br /&gt;
{{cliop | username=developer | hostname=ldc | pwd=~ | sudo fdisk -l /dev/sdd }}&amp;lt;nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Disk /dev/sdd: 3.7 GiB, 3980394496 bytes, 7774208 sectors&lt;br /&gt;
Disk model: STORAGE DEVICE  &lt;br /&gt;
Units: sectors of 1 * 512 = 512 bytes&lt;br /&gt;
Sector size (logical/physical): 512 bytes / 512 bytes&lt;br /&gt;
I/O size (minimum/optimal): 512 bytes / 512 bytes&lt;br /&gt;
Disklabel type: dos&lt;br /&gt;
Disk identifier: 0x4fcf5773&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
{{closp}}&lt;br /&gt;
&lt;br /&gt;
The output of fdisk will also show information about any partitions that may exist on the USB drive. For example, another drive with a single FAT32 formatted partition will look like:&lt;br /&gt;
{{clop}}&lt;br /&gt;
{{cliop | username=developer | hostname=ldc | pwd=~ | sudo fdisk -l /dev/sdd }}&amp;lt;nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Disk /dev/sdd: 3.7 GiB, 3980394496 bytes, 7774208 sectors&lt;br /&gt;
Disk model: STORAGE DEVICE  &lt;br /&gt;
Units: sectors of 1 * 512 = 512 bytes&lt;br /&gt;
Sector size (logical/physical): 512 bytes / 512 bytes&lt;br /&gt;
I/O size (minimum/optimal): 512 bytes / 512 bytes&lt;br /&gt;
Disklabel type: dos&lt;br /&gt;
Disk identifier: 0xe6077d37&lt;br /&gt;
&lt;br /&gt;
Device     Boot Start     End Sectors  Size Id Type&lt;br /&gt;
/dev/sdh1        2048 7774207 7772160  3.7G  c W95 FAT32 (LBA)&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
{{closp}}&lt;br /&gt;
&lt;br /&gt;
* As can be seen from the output of the &amp;lt;code&amp;gt;fdisk -l&amp;lt;/code&amp;gt; command above, the disk is 3.7 GB in size, which corresponds with the size of the 4 GB USB drive being used in this example.&lt;br /&gt;
&lt;br /&gt;
Unmount all of the USB drives partitions that were listed from the &amp;lt;code&amp;gt;mount&amp;lt;/code&amp;gt; command above.&lt;br /&gt;
&lt;br /&gt;
{{cli | username=developer | hostname=ldc | pwd=~ | sudo umount /dev/sdd }}&lt;br /&gt;
&lt;br /&gt;
If there is a partition listed:&lt;br /&gt;
&lt;br /&gt;
{{cli | username=developer | hostname=ldc | pwd=~ | sudo umount /dev/sdd1 }}&lt;br /&gt;
&lt;br /&gt;
==Repartition the USB Drive==&lt;br /&gt;
&lt;br /&gt;
Once the correct drive letter is determined, we will create a new Linux partition.&lt;br /&gt;
&lt;br /&gt;
{{clop}}&lt;br /&gt;
{{cliop | username=developer | hostname=ldc | pwd=~ | sudo fdisk /dev/sdd }}&amp;lt;nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Welcome to fdisk (util-linux 2.33.1).&lt;br /&gt;
Changes will remain in memory only, until you decide to write them.&lt;br /&gt;
Be careful before using the write command.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Command (m for help): o&lt;br /&gt;
Created a new DOS disklabel with disk identifier 0x05d5e983.&lt;br /&gt;
&lt;br /&gt;
Command (m for help): n&lt;br /&gt;
Partition type&lt;br /&gt;
   p   primary (0 primary, 0 extended, 4 free)&lt;br /&gt;
   e   extended (container for logical partitions)&lt;br /&gt;
Select (default p): p&lt;br /&gt;
Partition number (1-4, default 1): 1&lt;br /&gt;
First sector (2048-7774207, default 2048): &lt;br /&gt;
Last sector, +/-sectors or +/-size{K,M,G,T,P} (2048-7774207, default 7774207): &lt;br /&gt;
&lt;br /&gt;
Created a new partition 1 of type 'Linux' and of size 3.7 GiB.&lt;br /&gt;
&lt;br /&gt;
Command (m for help): p&lt;br /&gt;
Disk /dev/sdd: 3.7 GiB, 3980394496 bytes, 7774208 sectors&lt;br /&gt;
Disk model: STORAGE DEVICE  &lt;br /&gt;
Units: sectors of 1 * 512 = 512 bytes&lt;br /&gt;
Sector size (logical/physical): 512 bytes / 512 bytes&lt;br /&gt;
I/O size (minimum/optimal): 512 bytes / 512 bytes&lt;br /&gt;
Disklabel type: dos&lt;br /&gt;
Disk identifier: 0x05d5e983&lt;br /&gt;
&lt;br /&gt;
Device     Boot Start     End Sectors  Size Id Type&lt;br /&gt;
/dev/sdd1        2048 7774207 7772160  3.7G 83 Linux&lt;br /&gt;
&lt;br /&gt;
Command (m for help): w&lt;br /&gt;
The partition table has been altered.&lt;br /&gt;
Calling ioctl() to re-read partition table.&lt;br /&gt;
Syncing disks.&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
{{closp}}&lt;br /&gt;
&lt;br /&gt;
The fdisk commands are:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;o&amp;lt;/code&amp;gt; - Create a new empty partition table&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;n&amp;lt;/code&amp;gt; - Create a new partition&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;p&amp;lt;/code&amp;gt; - The type of partition is a primary partition&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;1&amp;lt;/code&amp;gt; - Create the first partition&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;ENTER&amp;gt;&amp;lt;/code&amp;gt; - Accept default start&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;ENTER&amp;gt;&amp;lt;/code&amp;gt; - Accept default end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;p&amp;lt;/code&amp;gt; - Print the new partition layout&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;w&amp;lt;/code&amp;gt; - Write the new partition layout and exit&lt;br /&gt;
&lt;br /&gt;
==Format the Partition==&lt;br /&gt;
&lt;br /&gt;
The first partition will be formatted with the ext4 filesystem.&lt;br /&gt;
&lt;br /&gt;
{{cli | username=developer | hostname=ldc | pwd=~ | yes {{!}} sudo mkfs.ext4 /dev/sdd1 }}&lt;br /&gt;
&lt;br /&gt;
==Mount the Partition==&lt;br /&gt;
&lt;br /&gt;
The first partition of the USB drive will be mounted so that it is accessible to write to.&lt;br /&gt;
&lt;br /&gt;
{{cli | username=developer | hostname=ldc | pwd=~ | sudo mkdir -p /media/card }}&lt;br /&gt;
{{cli | username=developer | hostname=ldc | pwd=~ | sudo mount /dev/sdd1 /media/card }}&lt;br /&gt;
&lt;br /&gt;
The USB drive is now accessible through the &amp;lt;code&amp;gt;/media/card&amp;lt;/code&amp;gt; directory.&lt;br /&gt;
&lt;br /&gt;
==Extract Filesystem Archive==&lt;br /&gt;
&lt;br /&gt;
Locate where the filesystem archive has been downloaded. If the archive is called rootfs.tar.gz and is in the users Downloads directory:&lt;br /&gt;
&lt;br /&gt;
{{cli | username=developer | hostname=ldc | pwd=~ | cd /media/card }}&lt;br /&gt;
{{cli | username=developer | hostname=ldc | pwd=/media/card | sudo tar zxf ~/Downloads/rootfs.tar.gz }}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Configuring the Client to Boot from USB==&lt;br /&gt;
&lt;br /&gt;
===Configuring U-Boot===&lt;br /&gt;
&lt;br /&gt;
Insert the USB drive into an available port on the target board.&lt;br /&gt;
Set the bootargs variable to tell the kernel to boot into the USB filesystem:&lt;br /&gt;
&lt;br /&gt;
 U-Boot&amp;gt; setenv bootargs console=${console} root=/dev/sda1 rootfstype=ext4&lt;br /&gt;
 U-Boot&amp;gt; run bootargs&lt;br /&gt;
&lt;br /&gt;
This line sets up the environment needed to boot from the USB drive.  These options will be passed to the Linux kernel when booting it.  The &amp;lt;code&amp;gt;console=${console}&amp;lt;/code&amp;gt; part tells Linux to use the console setting from the U-Boot environment variable; this will usually be something along the lines of &amp;lt;code&amp;gt;console=ttyS0,115200n8&amp;lt;/code&amp;gt;.  The &amp;lt;code&amp;gt;root=/dev/sda1&amp;lt;/code&amp;gt; directive tells Linux to instantiate with the USB block device, &amp;lt;code&amp;gt;/dev/sda1&amp;lt;/code&amp;gt;, as the root filesystem. The &amp;lt;code&amp;gt;rootfstype=ext4&amp;lt;/code&amp;gt; directive tells Linux that the root filesystem is of the EXT4 variety.  &lt;br /&gt;
&lt;br /&gt;
If the kernel is already programmed into the flash, it can be used in most cases to boot into the USB root filesystem. Execute the next line to load and run the default kernel.&lt;br /&gt;
&lt;br /&gt;
 U-Boot&amp;gt; boot&lt;br /&gt;
&lt;br /&gt;
The machine should now boot, and show output on its console as it does so.&lt;br /&gt;
&lt;br /&gt;
===Alternate Kernel Load===&lt;br /&gt;
&lt;br /&gt;
An alternate kernel can be loaded into memory temporarily and booted if the kernel is not already programmed in the flash or a development kernel is to be tested. The below example assumes a kernel named zImage-test was placed in the /boot directory of the USB drive. Also see [[ Loading_Images_with_U-Boot#Executing_kernel_from_RAM  | Executing kernel from RAM ]]&lt;br /&gt;
&lt;br /&gt;
 U-Boot&amp;gt; usb start&lt;br /&gt;
 U-Boot&amp;gt; usb storage&lt;br /&gt;
 U-Boot&amp;gt; ext2load usb 0:1 ${loadaddr} /boot/zImage-test&lt;br /&gt;
 U-Boot&amp;gt; bootz ${loadaddr}&lt;br /&gt;
&lt;br /&gt;
The first two commands initialize the USB storage system in U-Boot. The &amp;lt;code&amp;gt;ext2load&amp;lt;/code&amp;gt; line says to use the USB device 0 partition 1 and load into RAM at ${loadaddr} the file /boot/zImage-test from the USB drive. The last line boots the kernel that has been loaded into memory.&lt;br /&gt;
&lt;br /&gt;
==Conclusion==&lt;br /&gt;
&lt;br /&gt;
Using a USB thumb drive for the root filesystem allows boards to boot quickly into a rescue or known good version of a filesystem and provides a method for remotely backing up the filesystem installed on an embedded machine.  Setting up a machine to boot to a root filesystem via USB requires little work; most of the work is in setting up the USB thumb drive.&lt;br /&gt;
&lt;br /&gt;
{{:Templateimpl:moreinfo | initials=MG | title=System Logging | desc=The page describes how to USB boot. | project=OE 5.0 }}&lt;br /&gt;
* [[Loading_Images_onto_eMMC_Devices | Loading Images onto eMMC Devices]]&lt;br /&gt;
* [[Loading_Images_with_U-Boot | Loading Images with U-Boot]]&lt;br /&gt;
* [[Loading_Linux_Kernels_Onto_a_Board | Loading Linux Kernels Onto a Board]]&lt;/div&gt;</summary>
		<author><name>Mgloff</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.emacinc.com/index.php?title=Booting_with_a_USB_Root_Filesystem&amp;diff=5627</id>
		<title>Booting with a USB Root Filesystem</title>
		<link rel="alternate" type="text/html" href="https://wiki.emacinc.com/index.php?title=Booting_with_a_USB_Root_Filesystem&amp;diff=5627"/>
		<updated>2019-03-05T23:31:51Z</updated>

		<summary type="html">&lt;p&gt;Mgloff: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;It is possible to boot most EMAC OE systems using a USB thumb drive as the root filesystem and to optionally load a kernel from. This method can be especially useful for updating or recovering the root filesystem when a network connection or a network file server is not available. This page describes the steps required to boot into a root filesystem residing on a USB thumb drive.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==Prerequisites==&lt;br /&gt;
&lt;br /&gt;
Some prerequisites must be met prior to being able to boot a root filesystem from a USB drive.&lt;br /&gt;
&lt;br /&gt;
===USB Thumb Drive===&lt;br /&gt;
&lt;br /&gt;
Any blank USB drive. If it is not blank, this process will completely wipe the data that exists on the USB drive.&lt;br /&gt;
&lt;br /&gt;
===Root Filesystem===&lt;br /&gt;
&lt;br /&gt;
A complete root filesystem for the EMAC OE system to boot from must be stored on the USB drive.&lt;br /&gt;
&lt;br /&gt;
===Linux Host Computer===&lt;br /&gt;
&lt;br /&gt;
Either a native Linux host or Windows host running a Linux virtual machine.&lt;br /&gt;
&lt;br /&gt;
==Configuring the USB Thumb Drive==&lt;br /&gt;
&lt;br /&gt;
In a terminal window, start the dmesg log with the follow option to watch for new devices.&lt;br /&gt;
&lt;br /&gt;
{{cli | username=developer | hostname=ldc | pwd=~ | dmesg -w }}&lt;br /&gt;
&lt;br /&gt;
Insert the USB drive and watch for the device to be announced.&lt;br /&gt;
&lt;br /&gt;
{{clo}}&lt;br /&gt;
[ 2796.940110] scsi host6: usb-storage 1-1.2:1.0 &amp;lt;br /&amp;gt;&lt;br /&gt;
[ 2797.963442] scsi 6:0:0:0: Direct-Access     Generic  STORAGE DEVICE   0272 PQ: 0 ANSI: 0 &amp;lt;br /&amp;gt;&lt;br /&gt;
[ 2797.963905] sd 6:0:0:0: Attached scsi generic sg4 type 0 &amp;lt;br /&amp;gt;&lt;br /&gt;
[ 2798.269544] sd 6:0:0:0: [sdd] 7774208 512-byte logical blocks: (3.98 GB/3.71 GiB) &amp;lt;br /&amp;gt;&lt;br /&gt;
[ 2798.271027] sd 6:0:0:0: [sdd] Write Protect is off &amp;lt;br /&amp;gt;&lt;br /&gt;
[ 2798.271030] sd 6:0:0:0: [sdd] Mode Sense: 0b 00 00 08 &amp;lt;br /&amp;gt;&lt;br /&gt;
[ 2798.272502] sd 6:0:0:0: [sdd] No Caching mode page found &amp;lt;br /&amp;gt;&lt;br /&gt;
[ 2798.272508] sd 6:0:0:0: [sdd] Assuming drive cache: write through &amp;lt;br /&amp;gt;&lt;br /&gt;
[ 2798.279486]  sdd: &amp;lt;br /&amp;gt;&lt;br /&gt;
[ 2798.283834] sd 6:0:0:0: [sdd] Attached SCSI removable disk &amp;lt;br /&amp;gt;&lt;br /&gt;
{{clos}}&lt;br /&gt;
&lt;br /&gt;
The output of the &amp;lt;code&amp;gt;dmesg&amp;lt;/code&amp;gt; command shows that the root device node for the USB drive in this case is &amp;lt;code&amp;gt;sdd&amp;lt;/code&amp;gt; and no partitions. Partitions on the drive would be listed as &amp;lt;code&amp;gt;sdd1&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;sdd2&amp;lt;/code&amp;gt;, etc.  Inspect the output shown above to see the particular device node on the development PC where the USB drive is mounted. This will be different depending on the configuration of the development PC. The &amp;lt;code&amp;gt;/dev/&amp;lt;/code&amp;gt; prefix will go before the device name, but is not shown in the output of &amp;lt;code&amp;gt;dmesg&amp;lt;/code&amp;gt;. The device node will start with &amp;lt;code&amp;gt;sd&amp;lt;/code&amp;gt;. The third letter will specify which of these devices is assigned to the USB drive. The number will indicate the partitions, if any. Press Ctrl and 'c' to exit dmesg.&lt;br /&gt;
&lt;br /&gt;
* At this point, it is wise to double check that device node is actually the USB drive and not a hard drive in the system. Specifying the wrong device node could cause a complete loss of data on a hard drive.  &amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt; Continuing with &amp;lt;code&amp;gt;/dev/sdd&amp;lt;/code&amp;gt; as the example device node, type the following command:&lt;br /&gt;
&lt;br /&gt;
{{clo}}&lt;br /&gt;
{{clio | username=developer | hostname=ldc | pwd=~ | mount {{!}} grep sdd }}&lt;br /&gt;
/dev/sdd on /media/developer/FBF6-1988 type vfat&lt;br /&gt;
{{clos}}&lt;br /&gt;
&lt;br /&gt;
This shows that the device node, &amp;lt;code&amp;gt;/dev/sdd&amp;lt;/code&amp;gt;, is in fact the USB drive.  This is because:&lt;br /&gt;
* It is not mounted on one of the standard Linux filesystem mountpoints, such as &amp;lt;code&amp;gt;/&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;/boot&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;/usr&amp;lt;/code&amp;gt;, or &amp;lt;code&amp;gt;/home&amp;lt;/code&amp;gt;.&lt;br /&gt;
* It '''is''' mounted in the &amp;lt;code&amp;gt;/media&amp;lt;/code&amp;gt; directory, where it is expected.  It may alternatively get mounted in &amp;lt;code&amp;gt;/mnt&amp;lt;/code&amp;gt;, depending upon the configuration of the Linux distribution in use.&lt;br /&gt;
&lt;br /&gt;
Use &amp;lt;code&amp;gt;fdisk -l&amp;lt;/code&amp;gt; to inspect the device node. Use &amp;lt;code&amp;gt;sudo&amp;lt;/code&amp;gt; with &amp;lt;code&amp;gt;fdisk&amp;lt;/code&amp;gt; to gain the required &amp;lt;code&amp;gt;root&amp;lt;/code&amp;gt; privileges to run &amp;lt;code&amp;gt;fdisk&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{clop}}&lt;br /&gt;
{{cliop | username=developer | hostname=ldc | pwd=~ | sudo fdisk -l /dev/sdd }}&amp;lt;nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Disk /dev/sdd: 3.7 GiB, 3980394496 bytes, 7774208 sectors&lt;br /&gt;
Disk model: STORAGE DEVICE  &lt;br /&gt;
Units: sectors of 1 * 512 = 512 bytes&lt;br /&gt;
Sector size (logical/physical): 512 bytes / 512 bytes&lt;br /&gt;
I/O size (minimum/optimal): 512 bytes / 512 bytes&lt;br /&gt;
Disklabel type: dos&lt;br /&gt;
Disk identifier: 0x4fcf5773&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
{{closp}}&lt;br /&gt;
&lt;br /&gt;
The output of fdisk will also show information about any partitions that may exist on the USB drive. For example, another drive with a single FAT32 formatted partition will look like:&lt;br /&gt;
{{clop}}&lt;br /&gt;
{{cliop | username=developer | hostname=ldc | pwd=~ | sudo fdisk -l /dev/sdd }}&amp;lt;nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Disk /dev/sdd: 3.7 GiB, 3980394496 bytes, 7774208 sectors&lt;br /&gt;
Disk model: STORAGE DEVICE  &lt;br /&gt;
Units: sectors of 1 * 512 = 512 bytes&lt;br /&gt;
Sector size (logical/physical): 512 bytes / 512 bytes&lt;br /&gt;
I/O size (minimum/optimal): 512 bytes / 512 bytes&lt;br /&gt;
Disklabel type: dos&lt;br /&gt;
Disk identifier: 0xe6077d37&lt;br /&gt;
&lt;br /&gt;
Device     Boot Start     End Sectors  Size Id Type&lt;br /&gt;
/dev/sdh1        2048 7774207 7772160  3.7G  c W95 FAT32 (LBA)&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
{{closp}}&lt;br /&gt;
&lt;br /&gt;
* As can be seen from the output of the &amp;lt;code&amp;gt;fdisk -l&amp;lt;/code&amp;gt; command above, the disk is 3.7 GB in size, which corresponds with the size of the 4 GB USB drive being used in this example.&lt;br /&gt;
&lt;br /&gt;
Unmount all of the USB drives partitions that were listed from the &amp;lt;code&amp;gt;mount&amp;lt;/code&amp;gt; command above.&lt;br /&gt;
&lt;br /&gt;
{{cli | username=developer | hostname=ldc | pwd=~ | sudo umount /dev/sdd }}&lt;br /&gt;
&lt;br /&gt;
If there is a partition listed:&lt;br /&gt;
&lt;br /&gt;
{{cli | username=developer | hostname=ldc | pwd=~ | sudo umount /dev/sdd1 }}&lt;br /&gt;
&lt;br /&gt;
==Repartition the USB Drive==&lt;br /&gt;
&lt;br /&gt;
Once the correct drive letter is determined, we will create a new Linux partition.&lt;br /&gt;
&lt;br /&gt;
{{clop}}&lt;br /&gt;
{{cliop | username=developer | hostname=ldc | pwd=~ | sudo fdisk /dev/sdd }}&amp;lt;nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Welcome to fdisk (util-linux 2.33.1).&lt;br /&gt;
Changes will remain in memory only, until you decide to write them.&lt;br /&gt;
Be careful before using the write command.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Command (m for help): o&lt;br /&gt;
Created a new DOS disklabel with disk identifier 0x05d5e983.&lt;br /&gt;
&lt;br /&gt;
Command (m for help): n&lt;br /&gt;
Partition type&lt;br /&gt;
   p   primary (0 primary, 0 extended, 4 free)&lt;br /&gt;
   e   extended (container for logical partitions)&lt;br /&gt;
Select (default p): p&lt;br /&gt;
Partition number (1-4, default 1): 1&lt;br /&gt;
First sector (2048-7774207, default 2048): &lt;br /&gt;
Last sector, +/-sectors or +/-size{K,M,G,T,P} (2048-7774207, default 7774207): &lt;br /&gt;
&lt;br /&gt;
Created a new partition 1 of type 'Linux' and of size 3.7 GiB.&lt;br /&gt;
&lt;br /&gt;
Command (m for help): p&lt;br /&gt;
Disk /dev/sdd: 3.7 GiB, 3980394496 bytes, 7774208 sectors&lt;br /&gt;
Disk model: STORAGE DEVICE  &lt;br /&gt;
Units: sectors of 1 * 512 = 512 bytes&lt;br /&gt;
Sector size (logical/physical): 512 bytes / 512 bytes&lt;br /&gt;
I/O size (minimum/optimal): 512 bytes / 512 bytes&lt;br /&gt;
Disklabel type: dos&lt;br /&gt;
Disk identifier: 0x05d5e983&lt;br /&gt;
&lt;br /&gt;
Device     Boot Start     End Sectors  Size Id Type&lt;br /&gt;
/dev/sdd1        2048 7774207 7772160  3.7G 83 Linux&lt;br /&gt;
&lt;br /&gt;
Command (m for help): w&lt;br /&gt;
The partition table has been altered.&lt;br /&gt;
Calling ioctl() to re-read partition table.&lt;br /&gt;
Syncing disks.&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
{{closp}}&lt;br /&gt;
&lt;br /&gt;
The fdisk commands are:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;o&amp;lt;/code&amp;gt; - Create a new empty partition table&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;n&amp;lt;/code&amp;gt; - Create a new partition&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;p&amp;lt;/code&amp;gt; - The type of partition is a primary partition&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;1&amp;lt;/code&amp;gt; - Create the first partition&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;ENTER&amp;gt;&amp;lt;/code&amp;gt; - Accept default start&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;ENTER&amp;gt;&amp;lt;/code&amp;gt; - Accept default end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;p&amp;lt;/code&amp;gt; - Print the new partition layout&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;w&amp;lt;/code&amp;gt; - Write the new partition layout and exit&lt;br /&gt;
&lt;br /&gt;
==Format the Partition==&lt;br /&gt;
&lt;br /&gt;
The first partition will be formatted with the ext4 filesystem.&lt;br /&gt;
&lt;br /&gt;
{{cli | username=developer | hostname=ldc | pwd=~ | yes {{!}} sudo mkfs.ext4 /dev/sdd1 }}&lt;br /&gt;
&lt;br /&gt;
==Mount the Partition==&lt;br /&gt;
&lt;br /&gt;
The first partition of the USB drive will be mounted so that it is accessible to write to.&lt;br /&gt;
&lt;br /&gt;
{{cli | username=developer | hostname=ldc | pwd=~ | sudo mkdir -p /media/card }}&lt;br /&gt;
{{cli | username=developer | hostname=ldc | pwd=~ | sudo mount /dev/sdd1 /media/card }}&lt;br /&gt;
&lt;br /&gt;
The USB drive is now accessible through the &amp;lt;code&amp;gt;/media/card&amp;lt;/code&amp;gt; directory.&lt;br /&gt;
&lt;br /&gt;
==Extract Filesystem Archive==&lt;br /&gt;
&lt;br /&gt;
Locate where the filesystem archive has been downloaded. If the archive is called rootfs.tar.gz and is in the users Downloads directory:&lt;br /&gt;
&lt;br /&gt;
{{cli | username=developer | hostname=ldc | pwd=~ | cd /media/card }}&lt;br /&gt;
{{cli | username=developer | hostname=ldc | pwd=/media/card | sudo tar zxf ~/Downloads/rootfs.tar.gz }}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Configuring the Client to Boot from USB==&lt;br /&gt;
&lt;br /&gt;
===Configuring U-Boot===&lt;br /&gt;
&lt;br /&gt;
Insert the USB drive into an available port on the target board.&lt;br /&gt;
Set the bootargs variable to tell the kernel to boot into the USB filesystem:&lt;br /&gt;
&lt;br /&gt;
 U-Boot&amp;gt; setenv bootargs console=${console} root=/dev/sda1 rootfstype=ext4&lt;br /&gt;
 U-Boot&amp;gt; run bootargs&lt;br /&gt;
&lt;br /&gt;
This line sets up the environment needed to boot from the USB drive.  These options will be passed to the Linux kernel when booting it.  The &amp;lt;code&amp;gt;console=${console}&amp;lt;/code&amp;gt; part tells Linux to use the console setting from the U-Boot environment variable; this will usually be something along the lines of &amp;lt;code&amp;gt;console=ttyS0,115200n8&amp;lt;/code&amp;gt;.  The &amp;lt;code&amp;gt;root=/dev/sda1&amp;lt;/code&amp;gt; directive tells Linux to instantiate with the USB block device, &amp;lt;code&amp;gt;/dev/sda1&amp;lt;/code&amp;gt;, as the root filesystem. The &amp;lt;code&amp;gt;rootfstype=ext4&amp;lt;/code&amp;gt; directive tells Linux that the root filesystem is of the EXT4 variety.  &lt;br /&gt;
&lt;br /&gt;
If the kernel is already programmed into the flash, it can be used in most cases to boot into the USB root filesystem. Execute the next line to load and run the default kernel.&lt;br /&gt;
&lt;br /&gt;
 U-Boot&amp;gt; boot&lt;br /&gt;
&lt;br /&gt;
The machine should now boot, and show output on its console as it does so.&lt;br /&gt;
&lt;br /&gt;
===Alternate Kernel Load===&lt;br /&gt;
&lt;br /&gt;
An alternate kernel can be loaded into memory temporarily and booted if the kernel is not already programmed in the flash or a development kernel is to be tested. The below example assumes a kernel named zImage-test was placed in the /boot directory of the USB drive. Also see [[ Loading_Images_with_U-Boot#Executing_kernel_from_RAM  | Executing kernel from RAM ]]&lt;br /&gt;
&lt;br /&gt;
 U-Boot&amp;gt; usb start&lt;br /&gt;
 U-Boot&amp;gt; usb storage&lt;br /&gt;
 U-Boot&amp;gt; ext2load usb 0:1 ${loadaddr} /boot/zImage-test&lt;br /&gt;
 U-Boot&amp;gt; bootz ${loadaddr}&lt;br /&gt;
&lt;br /&gt;
The first two commands initialize the USB storage system in U-Boot. The &amp;lt;code&amp;gt;ext2load&amp;lt;/code&amp;gt; line says to use the USB device 0 partition 1 and load into RAM at ${loadaddr} the file /boot/zImage-test from the USB drive. The last line boots the kernel that has been loaded into memory.&lt;br /&gt;
&lt;br /&gt;
==Conclusion==&lt;br /&gt;
&lt;br /&gt;
Using a USB thumb drive for the root filesystem allows boards to boot quickly into a rescue or known good version of a filesystem and provides a method for remotely backing up the filesystem installed on an embedded machine.  Setting up a machine to boot to a root filesystem via USB requires little work; most of the work is in setting up the USB thumb drive.&lt;br /&gt;
&lt;br /&gt;
{{:Templateimpl:moreinfo | initials=MG | title=System Logging | desc=The page describes how to USB boot. | project=OE 5.0 }}&lt;br /&gt;
* [[Loading_Images_onto_eMMC_Devices | Loading Images onto eMMC Devices]]&lt;br /&gt;
* [[Loading_Images_with_U-Boot | Loading Images with U-Boot]]&lt;br /&gt;
* [[Loading_Linux_Kernels_Onto_a_Board | Loading Linux Kernels Onto a Board]]&lt;/div&gt;</summary>
		<author><name>Mgloff</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.emacinc.com/index.php?title=Booting_with_a_USB_Root_Filesystem&amp;diff=5619</id>
		<title>Booting with a USB Root Filesystem</title>
		<link rel="alternate" type="text/html" href="https://wiki.emacinc.com/index.php?title=Booting_with_a_USB_Root_Filesystem&amp;diff=5619"/>
		<updated>2019-03-05T23:13:39Z</updated>

		<summary type="html">&lt;p&gt;Mgloff: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;It is possible to boot most EMAC OE systems using a USB thumb drive as the root filesystem and to optionally load a kernel from. This method can be especially useful for updating or recovering the root filesystem when a network connection or a network file server is not available. This page describes the steps required to boot into a root filesystem residing on a USB thumb drive.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==Prerequisites==&lt;br /&gt;
&lt;br /&gt;
Some prerequisites must be met prior to being able to boot a root filesystem from a USB drive.&lt;br /&gt;
&lt;br /&gt;
===USB Thumb Drive===&lt;br /&gt;
&lt;br /&gt;
Any blank USB drive. If it is not blank, this process will completely wipe the data that exists on the USB drive.&lt;br /&gt;
&lt;br /&gt;
===Root Filesystem===&lt;br /&gt;
&lt;br /&gt;
A complete root filesystem for the EMAC OE system to boot from must be stored on the USB drive.&lt;br /&gt;
&lt;br /&gt;
===Linux Host Computer===&lt;br /&gt;
&lt;br /&gt;
Either a native Linux host or Windows host running a Linux virtual machine.&lt;br /&gt;
&lt;br /&gt;
==Configuring the USB Thumb Drive==&lt;br /&gt;
&lt;br /&gt;
In a terminal window, start the dmesg log with the follow option to watch for new devices.&lt;br /&gt;
&lt;br /&gt;
{{cli | username=developer | hostname=ldc | pwd=~ | dmesg -w }}&lt;br /&gt;
&lt;br /&gt;
Insert the USB drive and watch for the device to be announced.&lt;br /&gt;
&lt;br /&gt;
{{clo}}&lt;br /&gt;
[ 2796.940110] scsi host6: usb-storage 1-1.2:1.0 &amp;lt;br /&amp;gt;&lt;br /&gt;
[ 2797.963442] scsi 6:0:0:0: Direct-Access     Generic  STORAGE DEVICE   0272 PQ: 0 ANSI: 0 &amp;lt;br /&amp;gt;&lt;br /&gt;
[ 2797.963905] sd 6:0:0:0: Attached scsi generic sg4 type 0 &amp;lt;br /&amp;gt;&lt;br /&gt;
[ 2798.269544] sd 6:0:0:0: [sdd] 7774208 512-byte logical blocks: (3.98 GB/3.71 GiB) &amp;lt;br /&amp;gt;&lt;br /&gt;
[ 2798.271027] sd 6:0:0:0: [sdd] Write Protect is off &amp;lt;br /&amp;gt;&lt;br /&gt;
[ 2798.271030] sd 6:0:0:0: [sdd] Mode Sense: 0b 00 00 08 &amp;lt;br /&amp;gt;&lt;br /&gt;
[ 2798.272502] sd 6:0:0:0: [sdd] No Caching mode page found &amp;lt;br /&amp;gt;&lt;br /&gt;
[ 2798.272508] sd 6:0:0:0: [sdd] Assuming drive cache: write through &amp;lt;br /&amp;gt;&lt;br /&gt;
[ 2798.279486]  sdd: &amp;lt;br /&amp;gt;&lt;br /&gt;
[ 2798.283834] sd 6:0:0:0: [sdd] Attached SCSI removable disk &amp;lt;br /&amp;gt;&lt;br /&gt;
{{clos}}&lt;br /&gt;
&lt;br /&gt;
The output of the &amp;lt;code&amp;gt;dmesg&amp;lt;/code&amp;gt; command shows that the root device node for the USB drive in this case is &amp;lt;code&amp;gt;sdd&amp;lt;/code&amp;gt; and no partitions. Partitions on the drive would be listed as &amp;lt;code&amp;gt;sdd1&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;sdd2&amp;lt;/code&amp;gt;, etc.  Inspect the output shown above to see the particular device node on the development PC where the USB drive is mounted. This will be different depending on the configuration of the development PC. The &amp;lt;code&amp;gt;/dev/&amp;lt;/code&amp;gt; prefix will go before the device name, but is not shown in the output of &amp;lt;code&amp;gt;dmesg&amp;lt;/code&amp;gt;. The device node will start with &amp;lt;code&amp;gt;sd&amp;lt;/code&amp;gt;. The third letter will specify which of these devices is assigned to the USB drive. The number will indicate the partitions, if any. Press Ctrl and 'c' to exit dmesg.&lt;br /&gt;
&lt;br /&gt;
* At this point, it is wise to double check that device node is actually the USB drive and not a hard drive in the system. Specifying the wrong device node could cause a complete loss of data on a hard drive.  &amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt; Continuing with &amp;lt;code&amp;gt;/dev/sdd&amp;lt;/code&amp;gt; as the example device node, type the following command:&lt;br /&gt;
&lt;br /&gt;
{{clo}}&lt;br /&gt;
{{clio | username=developer | hostname=ldc | pwd=~ | mount {{!}} grep sdd }}&lt;br /&gt;
/dev/sdd on /media/developer/FBF6-1988 type vfat&lt;br /&gt;
{{clos}}&lt;br /&gt;
&lt;br /&gt;
This shows that the device node, &amp;lt;code&amp;gt;/dev/sdd&amp;lt;/code&amp;gt;, is in fact the USB drive.  This is because:&lt;br /&gt;
* It is not mounted on one of the standard Linux filesystem mountpoints, such as &amp;lt;code&amp;gt;/&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;/boot&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;/usr&amp;lt;/code&amp;gt;, or &amp;lt;code&amp;gt;/home&amp;lt;/code&amp;gt;.&lt;br /&gt;
* It '''is''' mounted in the &amp;lt;code&amp;gt;/media&amp;lt;/code&amp;gt; directory, where it is expected.  It may alternatively get mounted in &amp;lt;code&amp;gt;/mnt&amp;lt;/code&amp;gt;, depending upon the configuration of the Linux distribution in use.&lt;br /&gt;
&lt;br /&gt;
Use &amp;lt;code&amp;gt;fdisk -l&amp;lt;/code&amp;gt; to inspect the device node. Use &amp;lt;code&amp;gt;sudo&amp;lt;/code&amp;gt; with &amp;lt;code&amp;gt;fdisk&amp;lt;/code&amp;gt; to gain the required &amp;lt;code&amp;gt;root&amp;lt;/code&amp;gt; privileges to run &amp;lt;code&amp;gt;fdisk&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{clo}}&lt;br /&gt;
{{clio | username=developer | hostname=ldc | pwd=~ | sudo fdisk -l /dev/sdd }}&lt;br /&gt;
'Disk /dev/sdd: 3.7 GiB, 3980394496 bytes, 7774208 sectors &amp;lt;br /&amp;gt;&lt;br /&gt;
Units: sectors of 1 * 512 = 512 bytes &amp;lt;br /&amp;gt;&lt;br /&gt;
Sector size (logical/physical): 512 bytes / 512 bytes &amp;lt;br /&amp;gt;&lt;br /&gt;
I/O size (minimum/optimal): 512 bytes / 512 bytes &amp;lt;br /&amp;gt;&lt;br /&gt;
Disklabel type: dos &amp;lt;br /&amp;gt;&lt;br /&gt;
Disk identifier 0x00000000 &amp;lt;br /&amp;gt;&lt;br /&gt;
{{clos}}&lt;br /&gt;
&lt;br /&gt;
The output of fdisk will also show information about any partitions that may exist on the USB drive. For example, a drive with a single FAT32 formatted partition will look like:&lt;br /&gt;
{{clo}}&lt;br /&gt;
Disk /dev/sdd: 3.7 GiB, 3980394496 bytes, 7774208 sectors &amp;lt;br /&amp;gt;&lt;br /&gt;
Units: sectors of 1 * 512 = 512 bytes &amp;lt;br /&amp;gt;&lt;br /&gt;
Sector size (logical/physical): 512 bytes / 512 bytes &amp;lt;br /&amp;gt;&lt;br /&gt;
I/O size (minimum/optimal): 512 bytes / 512 bytes &amp;lt;br /&amp;gt;&lt;br /&gt;
Disklabel type: dos &amp;lt;br /&amp;gt;&lt;br /&gt;
Disk identifier 0xb04870e5 &amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
Device     Boot Start      End  Sectors  Size Id Type &amp;lt;br /&amp;gt;&lt;br /&gt;
/dev/sdd1  *     8760 14438399 14429640  3.7G  c W95 FAT32 (LBA) &amp;lt;br /&amp;gt;&lt;br /&gt;
{{clos}}&lt;br /&gt;
&lt;br /&gt;
* As can be seen from the output of the &amp;lt;code&amp;gt;fdisk -l&amp;lt;/code&amp;gt; command above, the disk is 3.7 GB in size, which corresponds with the size of the 4 GB USB drive being used in this example.&lt;br /&gt;
&lt;br /&gt;
Unmount all of the USB drives partitions that were listed from the &amp;lt;code&amp;gt;mount&amp;lt;/code&amp;gt; command above.&lt;br /&gt;
&lt;br /&gt;
{{cli | username=developer | hostname=ldc | pwd=~ | sudo umount /dev/sdd }}&lt;br /&gt;
&lt;br /&gt;
If there is a partition listed:&lt;br /&gt;
&lt;br /&gt;
{{cli | username=developer | hostname=ldc | pwd=~ | sudo umount /dev/sdd1 }}&lt;br /&gt;
&lt;br /&gt;
==Repartition the USB Drive==&lt;br /&gt;
&lt;br /&gt;
Once the correct drive letter is determined, we will create a new Linux partition.&lt;br /&gt;
&lt;br /&gt;
{{clo}}&lt;br /&gt;
{{clio | username=developer | hostname=ldc | pwd=~ | sudo fdisk /dev/sdd }}&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
Welcome to fdisk (util-linux 2.31.1). &amp;lt;br /&amp;gt; &lt;br /&gt;
Changes will remain in memory only, until you decide to write them. &amp;lt;br /&amp;gt;&lt;br /&gt;
Be careful before using the write command. &amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
Command (m for help) o &amp;lt;br /&amp;gt;&lt;br /&gt;
Created a new DOS disklabel with disk identifier 0xe6077d37. &amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
Command (m for help) n &amp;lt;br /&amp;gt;&lt;br /&gt;
Partition type &amp;lt;br /&amp;gt;&lt;br /&gt;
:  p   primary (0 primary, 0 extended, 4 free) &amp;lt;br /&amp;gt;&lt;br /&gt;
:   e   extended (container for logical partitions) &amp;lt;br /&amp;gt;&lt;br /&gt;
Select (default p) p &amp;lt;br /&amp;gt;&lt;br /&gt;
Partition number (1-4, default 1) 1 &amp;lt;br /&amp;gt;&lt;br /&gt;
First sector (2048-7774207, default 2048) &amp;lt;br /&amp;gt;&lt;br /&gt;
Last sector, +sectors or +size{K,M,G,T,P} (2048-7774207, default 7774207) &amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
Created a new partition 1 of type 'Linux' and of size 3.7 GiB. &amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
Command (m for help) p &amp;lt;br /&amp;gt;&lt;br /&gt;
Disk /dev/sdd: 3.7 GiB, 3980394496 bytes, 7774208 sectors &amp;lt;br /&amp;gt;&lt;br /&gt;
Units sectors of 1 * 512 = 512 bytes &amp;lt;br /&amp;gt;&lt;br /&gt;
Sector size (logical/physical) 512 bytes / 512 bytes &amp;lt;br /&amp;gt;&lt;br /&gt;
I/O size (minimum/optimal) 512 bytes / 512 bytes &amp;lt;br /&amp;gt;&lt;br /&gt;
Disklabel type dos &amp;lt;br /&amp;gt;&lt;br /&gt;
Disk identifier 0xe6077d37 &amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
Device     Boot Start     End Sectors  Size Id Type &amp;lt;br /&amp;gt;&lt;br /&gt;
/dev/sdd1        2048 7774207 7772160  3.7G 83 Linux &amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
Command (m for help) w &amp;lt;br /&amp;gt;&lt;br /&gt;
The partition table has been altered. &amp;lt;br /&amp;gt;&lt;br /&gt;
Calling ioctl() to re-read partition table. &amp;lt;br /&amp;gt;&lt;br /&gt;
Syncing disks. &amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
{{clos}}&lt;br /&gt;
&lt;br /&gt;
The fdisk commands are:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;o&amp;lt;/code&amp;gt; - Create a new empty partition table&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;n&amp;lt;/code&amp;gt; - Create a new partition&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;p&amp;lt;/code&amp;gt; - The type of partition is a primary partition&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;1&amp;lt;/code&amp;gt; - Create the first partition&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;ENTER&amp;gt;&amp;lt;/code&amp;gt; - Accept default start&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;ENTER&amp;gt;&amp;lt;/code&amp;gt; - Accept default end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;p&amp;lt;/code&amp;gt; - Print the new partition layout&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;w&amp;lt;/code&amp;gt; - Write the new partition layout and exit&lt;br /&gt;
&lt;br /&gt;
==Format the Partition==&lt;br /&gt;
&lt;br /&gt;
The first partition will be formatted with the ext4 filesystem.&lt;br /&gt;
&lt;br /&gt;
{{cli | username=developer | hostname=ldc | pwd=~ | yes {{!}} sudo mkfs.ext4 /dev/sdd1 }}&lt;br /&gt;
&lt;br /&gt;
==Mount the Partition==&lt;br /&gt;
&lt;br /&gt;
The first partition of the USB drive will be mounted so that it is accessible to write to.&lt;br /&gt;
&lt;br /&gt;
{{cli | username=developer | hostname=ldc | pwd=~ | sudo mkdir -p /media/card }}&lt;br /&gt;
{{cli | username=developer | hostname=ldc | pwd=~ | sudo mount /dev/sdd1 /media/card }}&lt;br /&gt;
&lt;br /&gt;
The USB drive is now accessible through the &amp;lt;code&amp;gt;/media/card&amp;lt;/code&amp;gt; directory.&lt;br /&gt;
&lt;br /&gt;
==Extract Filesystem Archive==&lt;br /&gt;
&lt;br /&gt;
Locate where the filesystem archive has been downloaded. If the archive is called rootfs.tar.gz and is in the users Downloads directory:&lt;br /&gt;
&lt;br /&gt;
{{cli | username=developer | hostname=ldc | pwd=~ | cd /media/card }}&lt;br /&gt;
{{cli | username=developer | hostname=ldc | pwd=/media/card | sudo tar zxf ~/Downloads/rootfs.tar.gz }}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Configuring the Client to Boot from USB==&lt;br /&gt;
&lt;br /&gt;
===Configuring U-Boot===&lt;br /&gt;
&lt;br /&gt;
Insert the USB drive into an available port on the target board.&lt;br /&gt;
Set the bootargs variable to tell the kernel to boot into the USB filesystem:&lt;br /&gt;
&lt;br /&gt;
 U-Boot&amp;gt; setenv bootargs console=${console} root=/dev/sda1 rootfstype=ext4&lt;br /&gt;
 U-Boot&amp;gt; run bootargs&lt;br /&gt;
&lt;br /&gt;
This line sets up the environment needed to boot from the USB drive.  These options will be passed to the Linux kernel when booting it.  The &amp;lt;code&amp;gt;console=${console}&amp;lt;/code&amp;gt; part tells Linux to use the console setting from the U-Boot environment variable; this will usually be something along the lines of &amp;lt;code&amp;gt;console=ttyS0,115200n8&amp;lt;/code&amp;gt;.  The &amp;lt;code&amp;gt;root=/dev/sda1&amp;lt;/code&amp;gt; directive tells Linux to instantiate with the USB block device, &amp;lt;code&amp;gt;/dev/sda1&amp;lt;/code&amp;gt;, as the root filesystem. The &amp;lt;code&amp;gt;rootfstype=ext4&amp;lt;/code&amp;gt; directive tells Linux that the root filesystem is of the EXT4 variety.  &lt;br /&gt;
&lt;br /&gt;
If the kernel is already programmed into the flash, it can be used in most cases to boot into the USB root filesystem. Execute the next line to load and run the default kernel.&lt;br /&gt;
&lt;br /&gt;
 U-Boot&amp;gt; boot&lt;br /&gt;
&lt;br /&gt;
The machine should now boot, and show output on its console as it does so.&lt;br /&gt;
&lt;br /&gt;
===Alternate Kernel Load===&lt;br /&gt;
&lt;br /&gt;
An alternate kernel can be loaded into memory temporarily and booted if the kernel is not already programmed in the flash or a development kernel is to be tested. The below example assumes a kernel named zImage-test was placed in the /boot directory of the USB drive. Also see [[ Loading_Images_with_U-Boot#Executing_kernel_from_RAM  | Executing kernel from RAM ]]&lt;br /&gt;
&lt;br /&gt;
 U-Boot&amp;gt; usb start&lt;br /&gt;
 U-Boot&amp;gt; usb storage&lt;br /&gt;
 U-Boot&amp;gt; ext2load usb 0:1 ${loadaddr} /boot/zImage-test&lt;br /&gt;
 U-Boot&amp;gt; bootz ${loadaddr}&lt;br /&gt;
&lt;br /&gt;
The first two commands initialize the USB storage system in U-Boot. The &amp;lt;code&amp;gt;ext2load&amp;lt;/code&amp;gt; line says to use the USB device 0 partition 1 and load into RAM at ${loadaddr} the file /boot/zImage-test from the USB drive. The last line boots the kernel that has been loaded into memory.&lt;br /&gt;
&lt;br /&gt;
==Conclusion==&lt;br /&gt;
&lt;br /&gt;
Using a USB thumb drive for the root filesystem allows boards to boot quickly into a rescue or known good version of a filesystem and provides a method for remotely backing up the filesystem installed on an embedded machine.  Setting up a machine to boot to a root filesystem via USB requires little work; most of the work is in setting up the USB thumb drive.&lt;br /&gt;
&lt;br /&gt;
{{:Templateimpl:moreinfo | initials=MG | title=System Logging | desc=The page describes how to USB boot. | project=OE 5.0 }}&lt;br /&gt;
* [[Loading_Images_onto_eMMC_Devices | Loading Images onto eMMC Devices]]&lt;br /&gt;
* [[Loading_Images_with_U-Boot | Loading Images with U-Boot]]&lt;br /&gt;
* [[Loading_Linux_Kernels_Onto_a_Board | Loading Linux Kernels Onto a Board]]&lt;/div&gt;</summary>
		<author><name>Mgloff</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.emacinc.com/index.php?title=Booting_with_a_USB_Root_Filesystem&amp;diff=5612</id>
		<title>Booting with a USB Root Filesystem</title>
		<link rel="alternate" type="text/html" href="https://wiki.emacinc.com/index.php?title=Booting_with_a_USB_Root_Filesystem&amp;diff=5612"/>
		<updated>2019-03-05T18:27:43Z</updated>

		<summary type="html">&lt;p&gt;Mgloff: Created page with &amp;quot;It is possible to boot most EMAC OE systems using a USB thumb drive as the root filesystem and to optionally load a kernel from. This method can be especially useful for updat...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;It is possible to boot most EMAC OE systems using a USB thumb drive as the root filesystem and to optionally load a kernel from. This method can be especially useful for updating or recovering the root filesystem when a network connection or a network file server is not available. This page describes the steps required to boot into a root filesystem residing on a USB thumb drive.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==Prerequisites==&lt;br /&gt;
&lt;br /&gt;
Some prerequisites must be met prior to being able to boot a root filesystem from a USB drive.&lt;br /&gt;
&lt;br /&gt;
===USB Thumb Drive===&lt;br /&gt;
&lt;br /&gt;
Any blank USB drive. If it is not blank, this process will completely wipe the data that exists on the USB drive.&lt;br /&gt;
&lt;br /&gt;
===Root Filesystem===&lt;br /&gt;
&lt;br /&gt;
A complete root filesystem for the EMAC OE system to boot from must be stored on the USB drive.&lt;br /&gt;
&lt;br /&gt;
===Linux Host Computer===&lt;br /&gt;
&lt;br /&gt;
Either a native Linux host or Windows host running a Linux virtual machine.&lt;br /&gt;
&lt;br /&gt;
==Configuring the USB Thumb Drive==&lt;br /&gt;
&lt;br /&gt;
In a terminal window, start the dmesg log with the follow option to watch for new devices.&lt;br /&gt;
&lt;br /&gt;
{{cli | username=developer | hostname=ldc | pwd=~ | dmesg -w }}&lt;br /&gt;
&lt;br /&gt;
Insert the USB drive and watch for the device to be announced.&lt;br /&gt;
&lt;br /&gt;
{{clo}}&lt;br /&gt;
[ 2796.940110] scsi host6: usb-storage 1-1.2:1.0 &amp;lt;br /&amp;gt;&lt;br /&gt;
[ 2797.963442] scsi 6:0:0:0: Direct-Access     Generic  STORAGE DEVICE   0272 PQ: 0 ANSI: 0 &amp;lt;br /&amp;gt;&lt;br /&gt;
[ 2797.963905] sd 6:0:0:0: Attached scsi generic sg4 type 0 &amp;lt;br /&amp;gt;&lt;br /&gt;
[ 2798.269544] sd 6:0:0:0: [sdd] 7774208 512-byte logical blocks: (3.98 GB/3.71 GiB) &amp;lt;br /&amp;gt;&lt;br /&gt;
[ 2798.271027] sd 6:0:0:0: [sdd] Write Protect is off &amp;lt;br /&amp;gt;&lt;br /&gt;
[ 2798.271030] sd 6:0:0:0: [sdd] Mode Sense: 0b 00 00 08 &amp;lt;br /&amp;gt;&lt;br /&gt;
[ 2798.272502] sd 6:0:0:0: [sdd] No Caching mode page found &amp;lt;br /&amp;gt;&lt;br /&gt;
[ 2798.272508] sd 6:0:0:0: [sdd] Assuming drive cache: write through &amp;lt;br /&amp;gt;&lt;br /&gt;
[ 2798.279486]  sdd: &amp;lt;br /&amp;gt;&lt;br /&gt;
[ 2798.283834] sd 6:0:0:0: [sdd] Attached SCSI removable disk &amp;lt;br /&amp;gt;&lt;br /&gt;
{{clos}}&lt;br /&gt;
&lt;br /&gt;
The output of the &amp;lt;code&amp;gt;dmesg&amp;lt;/code&amp;gt; command shows that the root device node for the USB drive in this case is &amp;lt;code&amp;gt;sdd&amp;lt;/code&amp;gt; and no partitions. Partitions on the drive would be listed as &amp;lt;code&amp;gt;sdd1&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;sdd2&amp;lt;/code&amp;gt;, etc.  Inspect the output shown above to see the particular device node on the development PC where the USB drive is mounted. This will be different depending on the configuration of the development PC. The &amp;lt;code&amp;gt;/dev/&amp;lt;/code&amp;gt; prefix will go before the device name, but is not shown in the output of &amp;lt;code&amp;gt;dmesg&amp;lt;/code&amp;gt;. The device node will start with &amp;lt;code&amp;gt;sd&amp;lt;/code&amp;gt;. The third letter will specify which of these devices is assigned to the USB drive. The number will indicate the partitions, if any. Press Ctrl and 'c' to exit dmesg.&lt;br /&gt;
&lt;br /&gt;
* At this point, it is wise to double check that device node is actually the USB drive and not a hard drive in the system. Specifying the wrong device node could cause a complete loss of data on a hard drive.  &amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt; Continuing with &amp;lt;code&amp;gt;/dev/sdd&amp;lt;/code&amp;gt; as the example device node, type the following command:&lt;br /&gt;
&lt;br /&gt;
{{clo}}&lt;br /&gt;
{{clio | username=developer | hostname=ldc | pwd=~ | mount {{!}} grep sdd }}&lt;br /&gt;
/dev/sdd on /media/developer/FBF6-1988 type vfat&lt;br /&gt;
{{clos}}&lt;br /&gt;
&lt;br /&gt;
This shows that the device node, &amp;lt;code&amp;gt;/dev/sdd&amp;lt;/code&amp;gt;, is in fact the USB drive.  This is because:&lt;br /&gt;
* It is not mounted on one of the standard Linux filesystem mountpoints, such as &amp;lt;code&amp;gt;/&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;/boot&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;/usr&amp;lt;/code&amp;gt;, or &amp;lt;code&amp;gt;/home&amp;lt;/code&amp;gt;.&lt;br /&gt;
* It '''is''' mounted in the &amp;lt;code&amp;gt;/media&amp;lt;/code&amp;gt; directory, where it is expected.  It may alternatively get mounted in &amp;lt;code&amp;gt;/mnt&amp;lt;/code&amp;gt;, depending upon the configuration of the Linux distribution in use.&lt;br /&gt;
&lt;br /&gt;
Use &amp;lt;code&amp;gt;fdisk -l&amp;lt;/code&amp;gt; to inspect the device node. Use &amp;lt;code&amp;gt;sudo&amp;lt;/code&amp;gt; with &amp;lt;code&amp;gt;fdisk&amp;lt;/code&amp;gt; to gain the required &amp;lt;code&amp;gt;root&amp;lt;/code&amp;gt; privileges to run &amp;lt;code&amp;gt;fdisk&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{clo}}&lt;br /&gt;
{{clio | username=developer | hostname=ldc | pwd=~ | sudo fdisk -l /dev/sdd }}&lt;br /&gt;
'Disk /dev/sdd: 3.7 GiB, 3980394496 bytes, 7774208 sectors &amp;lt;br /&amp;gt;&lt;br /&gt;
Units: sectors of 1 * 512 = 512 bytes &amp;lt;br /&amp;gt;&lt;br /&gt;
Sector size (logical/physical): 512 bytes / 512 bytes &amp;lt;br /&amp;gt;&lt;br /&gt;
I/O size (minimum/optimal): 512 bytes / 512 bytes &amp;lt;br /&amp;gt;&lt;br /&gt;
Disklabel type: dos &amp;lt;br /&amp;gt;&lt;br /&gt;
Disk identifier 0x00000000 &amp;lt;br /&amp;gt;&lt;br /&gt;
{{clos}}&lt;br /&gt;
&lt;br /&gt;
The output of fdisk will also show information about any partitions that may exist on the USB drive. For example, a drive with a single FAT32 formatted partition will look like:&lt;br /&gt;
{{clo}}&lt;br /&gt;
Disk /dev/sdd: 3.7 GiB, 3980394496 bytes, 7774208 sectors &amp;lt;br /&amp;gt;&lt;br /&gt;
Units: sectors of 1 * 512 = 512 bytes &amp;lt;br /&amp;gt;&lt;br /&gt;
Sector size (logical/physical): 512 bytes / 512 bytes &amp;lt;br /&amp;gt;&lt;br /&gt;
I/O size (minimum/optimal): 512 bytes / 512 bytes &amp;lt;br /&amp;gt;&lt;br /&gt;
Disklabel type: dos &amp;lt;br /&amp;gt;&lt;br /&gt;
Disk identifier 0xb04870e5 &amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
Device     Boot Start      End  Sectors  Size Id Type &amp;lt;br /&amp;gt;&lt;br /&gt;
/dev/sdd1  *     8760 14438399 14429640  3.7G  c W95 FAT32 (LBA) &amp;lt;br /&amp;gt;&lt;br /&gt;
{{clos}}&lt;br /&gt;
&lt;br /&gt;
* As can be seen from the output of the &amp;lt;code&amp;gt;fdisk -l&amp;lt;/code&amp;gt; command above, the disk is 3.7 GB in size, which corresponds with the size of the 4 GB USB drive being used in this example.&lt;br /&gt;
&lt;br /&gt;
Unmount all of the USB drives partitions that were listed from the &amp;lt;code&amp;gt;mount&amp;lt;/code&amp;gt; command above.&lt;br /&gt;
&lt;br /&gt;
{{cli | username=developer | hostname=ldc | pwd=~ | sudo umount /dev/sdd }}&lt;br /&gt;
&lt;br /&gt;
If there is a partition listed:&lt;br /&gt;
&lt;br /&gt;
{{cli | username=developer | hostname=ldc | pwd=~ | sudo umount /dev/sdd1 }}&lt;br /&gt;
&lt;br /&gt;
==Repartition the USB Drive==&lt;br /&gt;
&lt;br /&gt;
Once the correct drive letter is determined, we will create a new Linux partition.&lt;br /&gt;
&lt;br /&gt;
{{clo}}&lt;br /&gt;
{{clio | username=developer | hostname=ldc | pwd=~ | sudo fdisk /dev/sdd }}&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
Welcome to fdisk (util-linux 2.31.1). &amp;lt;br /&amp;gt; &lt;br /&gt;
Changes will remain in memory only, until you decide to write them. &amp;lt;br /&amp;gt;&lt;br /&gt;
Be careful before using the write command. &amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
Command (m for help) o &amp;lt;br /&amp;gt;&lt;br /&gt;
Created a new DOS disklabel with disk identifier 0xe6077d37. &amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
Command (m for help) n &amp;lt;br /&amp;gt;&lt;br /&gt;
Partition type &amp;lt;br /&amp;gt;&lt;br /&gt;
:  p   primary (0 primary, 0 extended, 4 free) &amp;lt;br /&amp;gt;&lt;br /&gt;
:   e   extended (container for logical partitions) &amp;lt;br /&amp;gt;&lt;br /&gt;
Select (default p) p &amp;lt;br /&amp;gt;&lt;br /&gt;
Partition number (1-4, default 1) 1 &amp;lt;br /&amp;gt;&lt;br /&gt;
First sector (2048-7774207, default 2048) &amp;lt;br /&amp;gt;&lt;br /&gt;
Last sector, +sectors or +size{K,M,G,T,P} (2048-7774207, default 7774207) &amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
Created a new partition 1 of type 'Linux' and of size 3.7 GiB. &amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
Command (m for help) p &amp;lt;br /&amp;gt;&lt;br /&gt;
Disk /dev/sdd: 3.7 GiB, 3980394496 bytes, 7774208 sectors &amp;lt;br /&amp;gt;&lt;br /&gt;
Units sectors of 1 * 512 = 512 bytes &amp;lt;br /&amp;gt;&lt;br /&gt;
Sector size (logical/physical) 512 bytes / 512 bytes &amp;lt;br /&amp;gt;&lt;br /&gt;
I/O size (minimum/optimal) 512 bytes / 512 bytes &amp;lt;br /&amp;gt;&lt;br /&gt;
Disklabel type dos &amp;lt;br /&amp;gt;&lt;br /&gt;
Disk identifier 0xe6077d37 &amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
Device     Boot Start     End Sectors  Size Id Type &amp;lt;br /&amp;gt;&lt;br /&gt;
/dev/sdd1        2048 7774207 7772160  3.7G 83 Linux &amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
Command (m for help) w &amp;lt;br /&amp;gt;&lt;br /&gt;
The partition table has been altered. &amp;lt;br /&amp;gt;&lt;br /&gt;
Calling ioctl() to re-read partition table. &amp;lt;br /&amp;gt;&lt;br /&gt;
Syncing disks. &amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
{{clos}}&lt;br /&gt;
&lt;br /&gt;
The fdisk commands are:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;o&amp;lt;/code&amp;gt; - Create a new empty partition table&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;n&amp;lt;/code&amp;gt; - Create a new partition&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;p&amp;lt;/code&amp;gt; - The type of partition is a primary partition&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;1&amp;lt;/code&amp;gt; - Create the first partition&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;ENTER&amp;gt;&amp;lt;/code&amp;gt; - Accept default start&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;ENTER&amp;gt;&amp;lt;/code&amp;gt; - Accept default end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;p&amp;lt;/code&amp;gt; - Print the new partition layout&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;w&amp;lt;/code&amp;gt; - Write the new partition layout and exit&lt;br /&gt;
&lt;br /&gt;
==Format the Partition==&lt;br /&gt;
&lt;br /&gt;
The first partition will be formatted with the ext4 filesystem.&lt;br /&gt;
&lt;br /&gt;
{{cli | username=developer | hostname=ldc | pwd=~ | sudo yes {{!}} mkfs.ext4 /dev/sdd1 }}&lt;br /&gt;
&lt;br /&gt;
==Mount the Partition==&lt;br /&gt;
&lt;br /&gt;
The first partition of the USB drive will be mounted so that it is accessible to write to.&lt;br /&gt;
&lt;br /&gt;
{{cli | username=developer | hostname=ldc | pwd=~ | sudo mkdir -p /media/card }}&lt;br /&gt;
{{cli | username=developer | hostname=ldc | pwd=~ | sudo mount /dev/sdd1 /media/card }}&lt;br /&gt;
&lt;br /&gt;
The USB drive is now accessible through the &amp;lt;code&amp;gt;/media/card&amp;lt;/code&amp;gt; directory.&lt;br /&gt;
&lt;br /&gt;
==Extract Filesystem Archive==&lt;br /&gt;
&lt;br /&gt;
Locate where the filesystem archive has been downloaded. If the archive is called rootfs.tar.gz and is in the users Downloads directory:&lt;br /&gt;
&lt;br /&gt;
{{cli | username=developer | hostname=ldc | pwd=~ | cd /media/card }}&lt;br /&gt;
{{cli | username=developer | hostname=ldc | pwd=/media/card | sudo tar zxf ~/Downloads/rootfs.tar.gz }}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Configuring the Client to Boot from USB==&lt;br /&gt;
&lt;br /&gt;
===Configuring U-Boot===&lt;br /&gt;
&lt;br /&gt;
Set the bootargs variable to tell the kernel to boot into the USB filesystem:&lt;br /&gt;
&lt;br /&gt;
 U-Boot&amp;gt; setenv bootargs console=${console} root=/dev/sda1 rootfstype=ext4&lt;br /&gt;
 U-Boot&amp;gt; run bootargs&lt;br /&gt;
&lt;br /&gt;
This line sets up the environment needed to boot from the USB drive.  These options will be passed to the Linux kernel when booting it.  The &amp;lt;code&amp;gt;console=${console}&amp;lt;/code&amp;gt; part tells Linux to use the console setting from the U-Boot environment variable; this will usually be something along the lines of &amp;lt;code&amp;gt;console=ttyS0,115200n8&amp;lt;/code&amp;gt;.  The &amp;lt;code&amp;gt;root=/dev/sda1&amp;lt;/code&amp;gt; directive tells Linux to instantiate with the USB block device, &amp;lt;code&amp;gt;/dev/sda1&amp;lt;/code&amp;gt;, as the root filesystem.  The &amp;lt;code&amp;gt;rootfstype=ext4&amp;lt;/code&amp;gt; directive tells Linux that the root filesystem is of the EXT4 variety.  &lt;br /&gt;
&lt;br /&gt;
If the kernel is already programmed into the flash, it can be used in most cases to boot into the USB root filesystem. Execute the next line to load and run the default kernel.&lt;br /&gt;
&lt;br /&gt;
 U-Boot&amp;gt; boot&lt;br /&gt;
&lt;br /&gt;
The machine should now boot, and show output on its console as it does so.&lt;br /&gt;
&lt;br /&gt;
===Alternate Kernel Load===&lt;br /&gt;
&lt;br /&gt;
An alternate kernel can be loaded into memory temporarily and booted if the kernel is not already programmed in the flash or a development kernel is to be tested. Also see [[ Loading_Images_with_U-Boot#Executing_kernel_from_RAM  | Executing kernel from RAM ]]&lt;br /&gt;
&lt;br /&gt;
 U-Boot&amp;gt; usb start&lt;/div&gt;</summary>
		<author><name>Mgloff</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.emacinc.com/index.php?title=Booting_with_an_NFS_Root_Filesystem&amp;diff=5611</id>
		<title>Booting with an NFS Root Filesystem</title>
		<link rel="alternate" type="text/html" href="https://wiki.emacinc.com/index.php?title=Booting_with_an_NFS_Root_Filesystem&amp;diff=5611"/>
		<updated>2019-03-04T23:24:38Z</updated>

		<summary type="html">&lt;p&gt;Mgloff: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{#seo:&lt;br /&gt;
|title=Booting with an NFS Root Filesystem&lt;br /&gt;
|titlemode=append&lt;br /&gt;
|keywords=TFTP Server,NFS Server,U-Boot,Root File System&lt;br /&gt;
|description=This page describes the steps required to boot over NFS.&lt;br /&gt;
}}&lt;br /&gt;
It is possible to boot most EMAC OE systems using NFS (Network File System) as the root filesystem. This method can be especially useful during development where the root filesystem is changing frequently. This can save time as well as wear on the on-board flash device. This page describes the steps required to boot over NFS.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==Prerequisites==&lt;br /&gt;
&lt;br /&gt;
Some prerequisites must be met prior to being able to boot a root filesystem over NFS.&lt;br /&gt;
&lt;br /&gt;
===TFTP Server===&lt;br /&gt;
&lt;br /&gt;
A TFTP server is required if a kernel image is not already programmed in flash.  For information on installing a TFTP server, see [[Installing TFTP server]].&lt;br /&gt;
&lt;br /&gt;
===NFS Server===&lt;br /&gt;
&lt;br /&gt;
To boot an EMAC OE system over NFS, an NFS server must be available on the local network. This is often the same machine that is being used for software development. EMAC recommends using the &amp;lt;code&amp;gt;nfs-kernel-server&amp;lt;/code&amp;gt; package available on most desktop Linux distributions if setting up a new NFS server. Once the server has been installed, export a directory to use as the root filesystem. This is often done using the &amp;lt;code&amp;gt;/etc/exports&amp;lt;/code&amp;gt; file. This document assumes that the root filesystem for the board will be located at &amp;lt;code&amp;gt;/srv/nfs/rootfs&amp;lt;/code&amp;gt; on the NFS server.&lt;br /&gt;
&lt;br /&gt;
For more information on setting up an NFS server, see [[Setting up an NFS File Server]].&lt;br /&gt;
&lt;br /&gt;
===Root Filesystem===&lt;br /&gt;
&lt;br /&gt;
A complete root filesystem for the EMAC OE system to boot from must be stored on the NFS server.  The NFS server must be configured to allow clients to access this filesystem.  The root filesystem does not have to be the directory shared by the NFS filesystem; it can be in a subdirectory, which means many root filesystems can be shared by one NFS server.&lt;br /&gt;
&lt;br /&gt;
==Configuring the Client to Boot from NFS==&lt;br /&gt;
&lt;br /&gt;
===Configuring U-Boot===&lt;br /&gt;
&lt;br /&gt;
Set the bootargs variable to tell the kernel to boot into the NFS filesystem:&lt;br /&gt;
&lt;br /&gt;
 U-Boot&amp;gt; setenv bootargs console=${console} root=/dev/nfs rootfstype=nfs ip=dhcp nfsroot=10.0.0.20:/srv/nfs/test_fileystem&lt;br /&gt;
 U-Boot&amp;gt; run bootargs&lt;br /&gt;
&lt;br /&gt;
This line sets up the environment needed to boot from the NFS server.  These options will be passed to the Linux kernel when booting it.  The &amp;lt;code&amp;gt;console=${console}&amp;lt;/code&amp;gt; part tells Linux to use the console setting from the U-Boot environment variable; this will usually be something along the lines of &amp;lt;code&amp;gt;console=ttyS0,115200n8&amp;lt;/code&amp;gt;.  The &amp;lt;code&amp;gt;root=/dev/nfs&amp;lt;/code&amp;gt; directive tells Linux to instantiate with the virtual device, &amp;lt;code&amp;gt;/dev/nfs&amp;lt;/code&amp;gt;, as the root filesystem.  The &amp;lt;code&amp;gt;rootfstype=nfs&amp;lt;/code&amp;gt; directive tells Linux that the root filesystem is of the NFS variety.  The &amp;lt;code&amp;gt;ip=dhcp&amp;lt;/code&amp;gt; directive tells Linux to acquire an IP address by requesting one from the DHCP server.  The &amp;lt;code&amp;gt;nfsroot=10.0.0.20:/srv/nfs/test_filesystem&amp;lt;/code&amp;gt; directive tells Linux to look for an NFS server at &amp;lt;code&amp;gt;10.0.0.20&amp;lt;/code&amp;gt; and to mount the &amp;lt;code&amp;gt;/srv/nfs/test_filesystem&amp;lt;/code&amp;gt; directory as the root filesystem for the machine.&lt;br /&gt;
&lt;br /&gt;
If the kernel is already programmed into the flash, it can be used in most cases to boot into the NFS root filesystem. Execute the next line to load and run the default kernel.&lt;br /&gt;
&lt;br /&gt;
 U-Boot&amp;gt; boot&lt;br /&gt;
&lt;br /&gt;
The machine should now boot, and show output on its console as it does so.&lt;br /&gt;
&lt;br /&gt;
===Alternate Kernel Load===&lt;br /&gt;
&lt;br /&gt;
An alternate kernel can be loaded into memory temporarily and booted if the kernel is not already programmed in the flash or a development kernel is to be tested. Also see [[ Loading_Images_with_U-Boot#Executing_kernel_from_RAM  | Executing kernel from RAM ]]&lt;br /&gt;
&lt;br /&gt;
 U-Boot&amp;gt; set autoload no&lt;br /&gt;
 U-Boot&amp;gt; dhcp&lt;br /&gt;
 DHCP client bound to address 10.0.0.100&lt;br /&gt;
&lt;br /&gt;
Here, the first command, &amp;lt;code&amp;gt;set autoload no&amp;lt;/code&amp;gt;, tells U-Boot not to try to load an image after they've gotten an IP address from the DHCP server.  The second command, &amp;lt;code&amp;gt;dhcp&amp;lt;/code&amp;gt;, tells U-Boot to use DHCP to acquire an IP address.  In this example, the DHCP server assigned &amp;lt;code&amp;gt;10.0.0.100&amp;lt;/code&amp;gt; as the IP address for the machine.&lt;br /&gt;
&lt;br /&gt;
 U-Boot&amp;gt; set serverip 10.0.0.20&lt;br /&gt;
&lt;br /&gt;
This line sets the IP address of the TFTP server to &amp;lt;code&amp;gt;10.0.0.20&amp;lt;/code&amp;gt;.  This is the server which hosts the Linux kernel which will be used by the machine.&lt;br /&gt;
&lt;br /&gt;
 U-Boot&amp;gt; tftp ${loadaddr} zImage&lt;br /&gt;
 ...&lt;br /&gt;
 Loading: #################################################################&lt;br /&gt;
          #################################################################&lt;br /&gt;
          #################################################################&lt;br /&gt;
          #################################################################&lt;br /&gt;
          #################################################################&lt;br /&gt;
          #################################################################&lt;br /&gt;
          #################################################################&lt;br /&gt;
          #################################################################&lt;br /&gt;
          #################################################################&lt;br /&gt;
          #####################&lt;br /&gt;
&lt;br /&gt;
This line tells U-Boot to load the kernel from the TFTP server, whose IP address was set earlier with the &amp;lt;code&amp;gt;set serverip 10.0.0.20&amp;lt;/code&amp;gt; command.  The filename U-Boot requests from the TFTP server is &amp;lt;code&amp;gt;zImage&amp;lt;/code&amp;gt;, and it stores it in the memory location pointed to by &amp;lt;code&amp;gt;loadaddr&amp;lt;/code&amp;gt;.  The text which follows displays U-Boot's progress in loading the kernel into RAM.  When the U-Boot prompt returns, the environment is fully setup and ready to boot from an NFS root filesystem.&lt;br /&gt;
&lt;br /&gt;
 U-Boot&amp;gt; bootz ${loadaddr}&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;bootz&amp;lt;/code&amp;gt; command tells U-Boot to boot the kernel from RAM.  This means it boots the kernel which was just loaded into RAM, passing the commandline arguments specified by &amp;lt;code&amp;gt;bootargs&amp;lt;/code&amp;gt; to the Linux kernel as it does so.&lt;br /&gt;
&lt;br /&gt;
The machine should now boot, and show output on its console as it does so.&lt;br /&gt;
&lt;br /&gt;
==Conclusion==&lt;br /&gt;
&lt;br /&gt;
Using NFS for the root filesystem allows boards to boot quickly into test versions of a filesystem, provides a tool for remotely backing up the filesystem installed on an embedded machine, can provide a central filesystem image for many boards which can allow updating one filesystem to update all boards which use it simultaneously, and more.  Setting up a machine to boot to a root filesystem via NFS requires little work; most of the work is in setting up the server.&lt;/div&gt;</summary>
		<author><name>Mgloff</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.emacinc.com/index.php?title=Serial_Connections&amp;diff=5610</id>
		<title>Serial Connections</title>
		<link rel="alternate" type="text/html" href="https://wiki.emacinc.com/index.php?title=Serial_Connections&amp;diff=5610"/>
		<updated>2019-02-13T21:27:41Z</updated>

		<summary type="html">&lt;p&gt;Mgloff: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{todo|SEOKWREV (11.25.13-13:05-&amp;gt;KY+);(11.25.13-18:45-&amp;gt;MD+);(11.26.13-21:40-&amp;gt;MD+);(12.20.13-11:12-&amp;gt;MW+);(03.04.14-15:20-&amp;gt;BS-);(03.14.14-15:55-&amp;gt;BS+)(03.14.14-15:55-&amp;gt;BS+)(10.26.15-18:25-&amp;gt;MG+)|Klint Youngmeyer|project=oe 4,oe 5,ky,SEOKWREV,md,mw,bs}}&lt;br /&gt;
&lt;br /&gt;
{{#seo:&lt;br /&gt;
|title=Serial Connections&lt;br /&gt;
|titlemode=append&lt;br /&gt;
|keywords=Serial Connections,Serial Terminal,PuTTY,Serial Communication Parameters&lt;br /&gt;
|description=Serial Connections to EMAC boards.&lt;br /&gt;
}}&lt;br /&gt;
&amp;lt;!--'''THIS PAGE NEEDS: 1. To be split into two pages: &amp;quot;Serial Connections&amp;quot;  and  &amp;quot;Network Connections&amp;quot;.  This is because the table listing serial connection information is very important, but has been very difficult to find.  We need the page to have the most obvious name possible for this.  We also should try to find other pages which mention using a serial connection, and refer them to this page to find out the connection information they need for their board.'''--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
There are several ways to connect to a system running EMAC OE Linux. The preferred connection method depends on the capabilities of the hardware. For example, headless systems (those without a graphical interface) will most likely use a serial port console, while systems with a video connection may be accessed using a keyboard and LCD or monitor.  When an LCD or monitor is available, a serial connection can occasionally still be needed; usually, this need arises after a user has accidentally misconfigured the display.  Other times, it may be useful to be able to use a serial console on a board that's running remotely but has had its network connection drop out.  The serial console can be a very useful tool for diagnosing and debugging issues even after development has finished.&lt;br /&gt;
&lt;br /&gt;
== Serial Terminal ==&lt;br /&gt;
A serial terminal connection is most commonly the first connection that will be made to a system in its default configuration. A serial terminal application such as [[Getting_Started_With_Minicom | Minicom]] for Linux or [[PuTTY]] under Windows is required for this connection. The serial cable type, port, and communication parameters for each system type are listed in Table 1 below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&amp;lt;div align=center&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align: center;&amp;quot; |Table 1: Serial Communication Parameters&lt;br /&gt;
|-&lt;br /&gt;
! SoM !! Port !! Cable Type !! Baud Rate !! Data Bits !! Parity !! Stop Bits !! Flow Control&lt;br /&gt;
|-&lt;br /&gt;
| [[ ARM_SOM | 200 Pin SoM's ]] || COMB  || NULL Modem || 115200 || 8 || None || 1 || None&lt;br /&gt;
|-&lt;br /&gt;
| [[ ARM_SOM | 144 Pin SoM's ]] || COME  || NULL Modem || 115200 || 8 || None || 1 || None&lt;br /&gt;
|-&lt;br /&gt;
| [[ SOM-9260 ]] || COMA  || NULL Modem || 115200 || 8 || None || 1 || None&lt;br /&gt;
|-&lt;br /&gt;
| [[ SOM-9G20 ]] || COMA  || NULL Modem || 115200 || 8 || None || 1 || None&lt;br /&gt;
|-&lt;br /&gt;
| [[ iPac-9x25 ]] || COM1  || NULL Modem || 115200 || 8 || None || 1 || None&lt;br /&gt;
|-&lt;br /&gt;
| x86 Boards      || COM1*     ||  NULL Modem*          || 115200      || 8 || None || 1 || None&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{note | '''*''' : These settings vary among x86 systems. Refer to the system manual for the target board for more information. Not all x86 systems have a serial terminal connection enabled by default.}}&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Follow the steps below to establish a serial connection:&lt;br /&gt;
# Connect a NULL Modem serial cable between the serial port on the workstation and target board and start a terminal application.&lt;br /&gt;
# Setup the communication parameters for your board according to Table 1.&lt;br /&gt;
# Connect power to the target board; boot messages will begin to print within a few seconds.&lt;br /&gt;
# When the board has finished booting a login prompt will appear.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Next Steps ==&lt;br /&gt;
After you have established a connection with your device running EMAC OE Linux, you will need to [[System_Log_In | log into the system.]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- [[Category:Linux]]&lt;br /&gt;
[[Category:OpenEmbedded]]&lt;br /&gt;
--&amp;gt;&lt;/div&gt;</summary>
		<author><name>Mgloff</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.emacinc.com/index.php?title=Getting_Started_with_the_EMAC_OE_SDK&amp;diff=5609</id>
		<title>Getting Started with the EMAC OE SDK</title>
		<link rel="alternate" type="text/html" href="https://wiki.emacinc.com/index.php?title=Getting_Started_with_the_EMAC_OE_SDK&amp;diff=5609"/>
		<updated>2019-02-11T20:47:31Z</updated>

		<summary type="html">&lt;p&gt;Mgloff: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{todo| Complete (03.31.2015-13:42-&amp;gt;BS+);(04.08.2015-15:00-&amp;gt;BS+);(04.09.15-14:00-&amp;gt;MD+);(04.21.2015-10:15-&amp;gt;BS+);(04.24.2015-20:00-&amp;gt;MD-);(04.28.2015-12:20-&amp;gt;MD+);(04.29.2015-16:00-&amp;gt;BS+);(04.29.2015-17:30-&amp;gt;MD+);(04.30.2015-15:30-&amp;gt;KY+); (07.22.2015-11:00-&amp;gt;BS+)(10.07.2015-16:32-&amp;gt;KY+)|Brian Serrano| project=OE 5.0,BS,MD,Complete,KY}}&lt;br /&gt;
{{#seo:&lt;br /&gt;
|title=Getting Started with the EMAC OE SDK&lt;br /&gt;
|titlemode=append&lt;br /&gt;
|keywords=EMAC SDK,Cross compiling, ARM Target Compiling, CMake Build System, CMake Cross Compiling, CMake, CMake Arm&lt;br /&gt;
|description=A basic tutorial for using the EMAC OE SDK.&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /****************************************  Page Description Text  ****************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span style=&amp;quot;background:#00FF00;color:#FF0000;font-size:300%&amp;quot;&amp;gt;&amp;lt;/span&amp;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 page demonstrates the process of compiling an example project and running it on the target machine. Also, it provides a straightforward guide to the essential steps you need to follow to get started with cross compiling a simple program with gcc and running the program on your embedded machine.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /*****************************************  Using/Working With  ******************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
{{:Templateimpl:using | initials=BS | title=Getting Started with the EMAC OE SDK | desc=Basic tutorial for using the EMAC OE SDK. | project=OE 5.0 }} &lt;br /&gt;
&lt;br /&gt;
=== Video Series ===&lt;br /&gt;
&amp;lt;youtube&amp;gt;https://www.youtube.com/watch?v=v4ajuBPMiO4&amp;amp;list=PLZVpLvdEOZHYPwvOVAYCPS6Sw6I3sQA9w&amp;lt;/youtube&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Installing EMAC SDK ===&lt;br /&gt;
&lt;br /&gt;
[[Installing_EMAC_OE_5.0_SDK | SDK Install]]&lt;br /&gt;
&lt;br /&gt;
=== Connecting to a Target Board ===&lt;br /&gt;
&lt;br /&gt;
Primarily a board is connected to through it's debug serial port. If it also connected to a network and the IP address is known, ssh can be used to connect as well. More information on establishing a physical connection to a board is available on the [[Serial_Connections |Serial Connections]] and [[Network_Connections |Network Connections]] page.&lt;br /&gt;
&lt;br /&gt;
The next step after establishing a physical connection to the board is logging in.  For more information visit the [[System_Log_In | System Log In]] page.&lt;br /&gt;
&lt;br /&gt;
=== Setting the Filesystem to Read-Write ===&lt;br /&gt;
The root filesystem on a machine running EMAC OE Linux is mounted read-only by default. In order to put files on the board, you may need to make the filesystem read-write. The [[Linux_Filesystem_Organization|Linux Filesystem Organization page]] has more information regarding which parts of the filesystem are mounted read-only by default versus which parts are always writeable.  Note that EMAC recommends installing your program into a read-only portion of the filesystem (according to the guide) to safeguard it from filesystem corruption (such as may be caused by removing power from the board without shutting down the operating system first, which is normal in embedded systems).&lt;br /&gt;
&lt;br /&gt;
To remount the root filesytem in read-write mode, enter the following into the terminal: &lt;br /&gt;
{{cli | oemntrw | hostname=ipac9x25}}&lt;br /&gt;
&lt;br /&gt;
{{note|This will only change the root filesystem to read-write for the current boot.  When the system is rebooted, the root filesystem will once again be mounted read-only.}}&lt;br /&gt;
&lt;br /&gt;
=== Transferring Files ===&lt;br /&gt;
The command line syntax for transferring a file using the SSH protocol is &amp;lt;code&amp;gt;scp file user@host:/directory&amp;lt;/code&amp;gt;. SCP, or Secure Copy, is a way of securely transferring files between a local and remote host. For example, to send the file ''example.text'' to the &amp;lt;code&amp;gt;/usr/bin&amp;lt;/code&amp;gt; directory of a system with the IP address 10.0.6.221, enter the following command:&lt;br /&gt;
{{cli | username=developer | hostname=ldc | scp example.text root@10.0.6.221:/usr/bin/ }}&lt;br /&gt;
&lt;br /&gt;
Alternatively, you can leave off the path after the colon if you want the file to go directly into the root user's home directory.&lt;br /&gt;
&lt;br /&gt;
{{cli | username=developer | hostname=ldc | scp example.text root@10.0.6.221: }}&lt;br /&gt;
&lt;br /&gt;
=== Remote Execution ===&lt;br /&gt;
SSH can also be used to execute programs on remote systems without logging in. The syntax for SSH remote execution is &amp;lt;code&amp;gt;ssh user@host &amp;quot;my_command -args file&amp;quot;&amp;lt;/code&amp;gt;. The following is an example of a command to run a program on a board with the IP address ''10.0.6.221''.&lt;br /&gt;
&lt;br /&gt;
{{cli | username=developer | hostname=ldc | ssh root@10.0.6.221 &amp;quot;/path/to/executable -args&amp;quot; }}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Basic Compiling ===&lt;br /&gt;
The two subsections below show the two common options for how to compile source code. The first subsection demonstrates how to use the EMAC [[ #CMake_Compiling| CMake ]] tool, while the second subsection demonstrates how to compile c code [[ #Manual_Compiling | manually ]].&lt;br /&gt;
&lt;br /&gt;
==== CMake Compiling ====&lt;br /&gt;
===== Host Machine Compiling =====&lt;br /&gt;
&lt;br /&gt;
This section demonstrates how to use the EMAC CMake tool to generate CMake files automatically for a project. When using the EMAC SDK there are currently two options for cross compiling:&lt;br /&gt;
* arm&lt;br /&gt;
* x86&lt;br /&gt;
For the purposes of this guide, the &amp;lt;tt&amp;gt;arm&amp;lt;/tt&amp;gt; option will be used for the listed examples.&lt;br /&gt;
&lt;br /&gt;
Navigate to the directory where the project will be located. Then run the CMake new project script.&lt;br /&gt;
{{clo}}&lt;br /&gt;
{{clio | username=developer | hostname=ldc | pwd=~ |cd projects }}&lt;br /&gt;
{{clio | username=developer | hostname=ldc | pwd=~/projects | 1 = export PATH=/opt/emac/5.1/bin:$PATH}}&lt;br /&gt;
{{clio | username=developer | hostname=ldc | pwd=~/projects |oe_init_project -n hello.c }}&lt;br /&gt;
If desired, please enter a name for this project, otherwise press Enter to use the default: hello_emac &amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
-- Creating new project directory... &amp;lt;br /&amp;gt;&lt;br /&gt;
-- Creating new source file... &amp;lt;br /&amp;gt;&lt;br /&gt;
-- Building custom CMakeLists.txt file... &amp;lt;br /&amp;gt;&lt;br /&gt;
-- Done. &amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Do you want to create a build directory for this project? (y/n) y &amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
-- Creating build directory... &amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Do you want to run cmake for this project? (y/n) y &amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
-- Using system compiler &amp;lt;br /&amp;gt;&lt;br /&gt;
-- The C compiler identification is GNU 4.8.2 &amp;lt;br /&amp;gt;&lt;br /&gt;
-- The CXX compiler identification is GNU 4.8.2 &amp;lt;br /&amp;gt;&lt;br /&gt;
-- Check for working C compiler: /usr/bin/cc &amp;lt;br /&amp;gt;&lt;br /&gt;
-- Check for working C compiler: /usr/bin/cc -- works &amp;lt;br /&amp;gt;&lt;br /&gt;
-- Detecting C compiler ABI info &amp;lt;br /&amp;gt;&lt;br /&gt;
-- Detecting C compiler ABI info - done &amp;lt;br /&amp;gt;&lt;br /&gt;
-- Check for working CXX compiler: /usr/bin/c++ &amp;lt;br /&amp;gt;&lt;br /&gt;
-- Check for working CXX compiler: /usr/bin/c++ -- works &amp;lt;br /&amp;gt;&lt;br /&gt;
-- Detecting CXX compiler ABI info &amp;lt;br /&amp;gt;&lt;br /&gt;
-- Detecting CXX compiler ABI info - done &amp;lt;br /&amp;gt;&lt;br /&gt;
-- Configuring done &amp;lt;br /&amp;gt;&lt;br /&gt;
-- Generating done &amp;lt;br /&amp;gt;&lt;br /&gt;
-- Build files have been written to: /home/developer/projects/hello_emac/hello_emac-build &amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Do you want to compile this project? (y/n) y&lt;br /&gt;
&lt;br /&gt;
Scanning dependencies of target hello_emac &amp;lt;br /&amp;gt;&lt;br /&gt;
[100%] Building C object CMakeFiles/hello_emac.dir/hello.c.o &amp;lt;br /&amp;gt;&lt;br /&gt;
Linking C executable hello_emac &amp;lt;br /&amp;gt;&lt;br /&gt;
[100%] Built target hello_emac &amp;lt;br /&amp;gt;&lt;br /&gt;
{{clos}}&lt;br /&gt;
&lt;br /&gt;
The executable, in this case,  is now inside the &amp;lt;code&amp;gt; hello_emac/hello_emac-build &amp;lt;/code&amp;gt; directory.&lt;br /&gt;
&lt;br /&gt;
===== Target Machine Compiling =====&lt;br /&gt;
&lt;br /&gt;
The CMake project script has now made a project directory that contains the following:&lt;br /&gt;
* CMakeLists.txt&lt;br /&gt;
* Source code file (''hello.c'' in this case)&lt;br /&gt;
* ''README'' file&lt;br /&gt;
* Desktop Build Directory (''hello_emac-build'' in this case)&lt;br /&gt;
&lt;br /&gt;
The ''CMakeLists.txt'' contains the required information to automatically create a ''Makefile'' for a given architecture.  This was created by the EMAC &amp;lt;tt&amp;gt;oe_init_project&amp;lt;/tt&amp;gt; script, and will need to be modified over time as a project grows.  The comments in the file generated by the EMAC tool will provide a good starting point for how to add additional source files and how to perform other common tasks related to maintaining your CMake build system as your project grows.  The CMake project provides extensive documentation on how to work with these files.&lt;br /&gt;
&lt;br /&gt;
The source code file generated by the script (''hello.c'') contains a basic Hello World style program.&lt;br /&gt;
&lt;br /&gt;
The ''README'' file contains more information on using ''CMake'' with the EMAC 5.X SDK.&lt;br /&gt;
&lt;br /&gt;
The Desktop Build Directory (''hello_emac-build'') contains the executable ''hello_emac'', the ''Makefile'', and various cache files.  These were automatically created by CMake and by the build system, and can be recreated at any time.&lt;br /&gt;
&lt;br /&gt;
It is useful to have a Desktop Build Directory because it is easier (in the beginning) to use the desktop to verify all code changes before cross-compiling for a target board. This will be useful until the application under development depends upon resources which are only available on the target hardware, such as certain devices drivers or the touchscreen (if so equipped).&lt;br /&gt;
&lt;br /&gt;
Use the following steps to cross-compile the project and send it to a target board.&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;lt;cl&amp;gt;&lt;br /&gt;
1. In a terminal, navigate to the base directory of the project.&lt;br /&gt;
{{note | If the target board being used is &amp;lt;tt&amp;gt;x86&amp;lt;/tt&amp;gt;, then change all occurrences of &amp;lt;tt&amp;gt;arm&amp;lt;/tt&amp;gt; in the following sections below to &amp;lt;tt&amp;gt;x86&amp;lt;/tt&amp;gt;.}}&lt;br /&gt;
* Create a build directory for cross compiling. &lt;br /&gt;
{{cli | username=developer | hostname=ldc | pwd=~/projects/hello_emac | mkdir hello_emac-build-arm }} &lt;br /&gt;
* Change directories into the newly created directory.&lt;br /&gt;
{{cli | username=developer | hostname=ldc | pwd=~/projects/hello_emac | cd hello_emac-build-arm }} &lt;br /&gt;
* Run cmake using the target architecture.&lt;br /&gt;
{{cli | username=developer | hostname=ldc | pwd=~/projects/hello_emac/hello_emac-build-arm | 1 = cmake .. -DARCH:STRING=arm }} &lt;br /&gt;
* Compile the code using make.&lt;br /&gt;
{{cli | username=developer | hostname=ldc | pwd=~/projects/hello_emac/hello_emac-build-arm | make }} &lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt; make &amp;lt;/code&amp;gt; command creates the target executable in the &amp;lt;code&amp;gt; hello_emac-build-arm &amp;lt;/code&amp;gt; directory.&lt;br /&gt;
* Now copy the executable to the target board. For information on copying the executable file, see the [[ #Transferring_Files | Transferring Files ]] section.&lt;br /&gt;
&amp;lt;/cl&amp;gt;&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Manual Compiling ====&lt;br /&gt;
===== Host Machine Compiling =====&lt;br /&gt;
&amp;lt;br /&amp;gt;{{note|In these examples we are using the Ipac-9x25 board. Your board's processor's architecture will determine which file needs to be sourced. These files come from the EMAC SDK toolchain.}}&lt;br /&gt;
&lt;br /&gt;
Create a file called hello.c using a text editor such as vi, nano, or gedit. Then copy and paste the source code from the [[ #Hello_World_System_Log_Example | Hello World System Log Example ]] section in the text editor of your choice.&lt;br /&gt;
&lt;br /&gt;
Once you've created and saved the file with the source code, use the following syntax to compile the program called hello.c:&lt;br /&gt;
{{cli | username=developer | hostname=ldc | gcc -o hello hello.c }}&lt;br /&gt;
&lt;br /&gt;
If there is no error in your code then the compiler will successfully create an executable file called hello in the current directory.&lt;br /&gt;
&lt;br /&gt;
To verify this, enter the following command:&lt;br /&gt;
{{clo}}&lt;br /&gt;
{{clio | username=developer | hostname=ldc | ls -l hello* }}&lt;br /&gt;
-rwxrwxr-x 1 bserrano bserrano 9583 Apr  6 12:45 hello &amp;lt;br /&amp;gt;&lt;br /&gt;
-rwxr-xr-x 1 bserrano bserrano  129 Apr  6 12:28 hello.c &lt;br /&gt;
{{clos}}&lt;br /&gt;
&lt;br /&gt;
To run the program, enter the following command:&lt;br /&gt;
{{clo}}&lt;br /&gt;
{{clio | username=developer | hostname=ldc | ./hello }}&lt;br /&gt;
Hello EMAC OE!&lt;br /&gt;
{{clos}}&lt;br /&gt;
&lt;br /&gt;
OR&lt;br /&gt;
{{clo}}&lt;br /&gt;
{{clio | username=developer | hostname=ldc | /path/to/hello }}&lt;br /&gt;
Hello EMAC OE!&lt;br /&gt;
{{clos}}&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Target Board Compiling =====&lt;br /&gt;
&lt;br /&gt;
To compile for the target board, you must &amp;lt;code&amp;gt;source&amp;lt;/code&amp;gt; the &amp;lt;code&amp;gt;environment-setup-armv5e-emac-linux-gnueabi&amp;lt;/code&amp;gt; file.&lt;br /&gt;
{{cli | username=developer | hostname=ldc | source /opt/emac/5.X/environment-setup-armv5e-emac-linux-gnueabi }}&lt;br /&gt;
&lt;br /&gt;
Once you are in the directory with the source file, enter the following command:&lt;br /&gt;
{{cli | username=developer | hostname=ldc | $CC -o hello hello.c }}&lt;br /&gt;
&lt;br /&gt;
{{note|Once you source the file in your current terminal, you can only use it to cross-compile your program for the target board. You can no longer compile it for your host machine. To compile it to your host machine, simply open a new terminal.}}&lt;br /&gt;
&lt;br /&gt;
After sourcing the file, copy the program over to the target board using &amp;lt;code&amp;gt;scp&amp;lt;/code&amp;gt;. Enter the following command:&lt;br /&gt;
{{clo}}&lt;br /&gt;
{{clio | username=developer | hostname=ldc | scp hello root@10.0.6.221: }}&lt;br /&gt;
root@10.0.6.221's password: &lt;br /&gt;
&lt;br /&gt;
hello                                         100% 9583     9.4KB/s   00:00    &lt;br /&gt;
{{clos}}&lt;br /&gt;
&lt;br /&gt;
After copying the program, you can now execute the program on the target board. Enter the following command:&lt;br /&gt;
{{clo}}&lt;br /&gt;
{{clio | username=developer | hostname=ldc | ssh root@10.0.6.221 ./hello}}&lt;br /&gt;
root@10.0.6.221's password: &amp;lt;br /&amp;gt; &lt;br /&gt;
Hello EMAC OE!&lt;br /&gt;
{{clos}}&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Remote Debugging ===&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 (&amp;lt;tt&amp;gt;gdb&amp;lt;/tt&amp;gt;) on the development machine to remotely debug the target machine provided it has a flavor-matched version of a program named &amp;lt;tt&amp;gt;gdbserver&amp;lt;/tt&amp;gt;. All EMAC OE builds are packaged with a flavor-matched &amp;lt;tt&amp;gt;gdbserver&amp;lt;/tt&amp;gt; to simplify the setup process for developers.&lt;br /&gt;
&lt;br /&gt;
{{note | A flavor-matched &amp;lt;tt&amp;gt;gdbserver&amp;lt;/tt&amp;gt; is one which is built against the same source code revision as the &amp;lt;tt&amp;gt;gdb&amp;lt;/tt&amp;gt; client for your desktop, because &amp;lt;tt&amp;gt;gdb&amp;lt;/tt&amp;gt; does not have a stable interface for attaching to the &amp;lt;tt&amp;gt;gdbserver&amp;lt;/tt&amp;gt;.  In fact, the interface changes slightly with almost every release, so if you find yourself having difficulty getting &amp;lt;tt&amp;gt;gdb&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;gdbserver&amp;lt;/tt&amp;gt; to communicate with each other, make sure they're the exact same version before trying any other debugging steps.}}&lt;br /&gt;
&lt;br /&gt;
For more information visit the [[Remote_Debugging_EMAC_OE_SDK_Projects_with_gdbserver | Remote Debugging EMAC OE SDK Projects with gdbserver]] page.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /*****************************************       Examples        *****************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
{{:Templateimpl:examples | initials=BS | title=Getting Started with the EMAC OE SDK | desc=Basic tutorial for using the EMAC OE SDK. | project=OE 5.0 }}&lt;br /&gt;
&lt;br /&gt;
=== Hello World System Log Example ===&lt;br /&gt;
This example will print &amp;lt;code&amp;gt;Hello EMAC OE!&amp;lt;/code&amp;gt; to the syslog facility as well as the console. This will allow you to log, debug, and send status messages to the system logger.&lt;br /&gt;
&lt;br /&gt;
To compile and run this program, see the sections above.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&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;unistd.h&amp;gt;&lt;br /&gt;
#include &amp;lt;syslog.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
int main(int argc, char** argv)&lt;br /&gt;
{    &lt;br /&gt;
    char message[] = &amp;quot;Hello EMAC OE!&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
    openlog(&amp;quot;slog&amp;quot;, LOG_PID|LOG_CONS, LOG_USER);&lt;br /&gt;
    syslog(LOG_INFO, &amp;quot;%s&amp;quot;, message);&lt;br /&gt;
    closelog();    &lt;br /&gt;
&lt;br /&gt;
    printf(&amp;quot;%s\n&amp;quot;, message);&lt;br /&gt;
&lt;br /&gt;
    return 0;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is extremely useful because it allows you to save a record of the output that you might not see first hand.&lt;br /&gt;
&lt;br /&gt;
To verify the output of the program went into syslog, enter the following command:&lt;br /&gt;
{{clo}}&lt;br /&gt;
{{clio | username=developer | hostname=ldc | tail /var/log/syslog}}&lt;br /&gt;
Apr  7 14:10:06 ENG-26-LX dhclient: DHCPACK of 10.0.6.237 from 10.0.2.1&amp;lt;br /&amp;gt;&lt;br /&gt;
Apr  7 14:10:06 ENG-26-LX dhclient: bound to 10.0.6.237 -- renewal in 3306 seconds.&amp;lt;br /&amp;gt;&lt;br /&gt;
Apr  7 14:17:01 ENG-26-LX CRON[21193]: (root) CMD (   cd / &amp;amp;&amp;amp; run-parts --report /etc/cron.hourly)&amp;lt;br /&amp;gt;&lt;br /&gt;
Apr  7 14:54:41 ENG-26-LX hpcups[21266]: prnt/hpcups/HPCupsFilter.cpp 689: First raster data plane..&amp;lt;br /&amp;gt;&lt;br /&gt;
Apr  7 14:55:31  hpcups[21266]: last message repeated 3 times&amp;lt;br /&amp;gt;&lt;br /&gt;
Apr  7 15:05:12 ENG-26-LX dhclient: DHCPREQUEST of 10.0.6.237 on eth0 to 10.0.2.1 port 67&amp;lt;br /&amp;gt;&lt;br /&gt;
Apr  7 15:05:12 ENG-26-LX dhclient: DHCPACK of 10.0.6.237 from 10.0.2.1&amp;lt;br /&amp;gt;&lt;br /&gt;
Apr  7 15:05:12 ENG-26-LX dhclient: bound to 10.0.6.237 -- renewal in 3559 seconds.&amp;lt;br /&amp;gt;&lt;br /&gt;
Apr  7 15:17:01 ENG-26-LX CRON[21302]: (root) CMD (   cd / &amp;amp;&amp;amp; run-parts --report /etc/cron.hourly)&amp;lt;br /&amp;gt;&lt;br /&gt;
Apr  7 15:27:08 ENG-26-LX slog[21375]: Hello EMAC OE!&lt;br /&gt;
{{clos}}&lt;br /&gt;
&lt;br /&gt;
As you can see on the bottom line, your program output has been recorded and date stamped in syslog.&lt;br /&gt;
&lt;br /&gt;
For more information on system logging visit the [[System_Logging| System Logging ]] page.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /******************************************   More Information   *****************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
{{:Templateimpl:moreinfo | initials=BS | title=Getting Started with the EMAC OE SDK | desc=Basic tutorial for using the EMAC OE SDK. | project=OE 5.0 }}&lt;br /&gt;
* [[Getting_Started_With_Qt_Creator |Getting Started With Qt Creator]]&lt;br /&gt;
&lt;br /&gt;
{{:Templateimpl:whatnext | initials=BS | title=Getting Started with the EMAC OE SDK | desc=Basic tutorial for using the EMAC OE SDK. | project=OE 5.0 }}&lt;br /&gt;
* [[Getting_Started_With_Qt_Creator |Getting Started With Qt Creator]]&lt;br /&gt;
* [[System_Log_In | System Log In]]&lt;br /&gt;
* [[Serial_Connections | Serial Connections ]]&lt;br /&gt;
* [[Network_Connections | Network_Connections ]]&lt;br /&gt;
* [[System_Log_In | System Log In ]]&lt;br /&gt;
* [[Remote_Debugging_EMAC_OE_SDK_Projects_with_gdbserver | Remote Debugging EMAC OE SDK Projects with gdbserver ]]&lt;br /&gt;
* [[Linux_Filesystem_Organization | Linux Filesystem Organization]]&lt;br /&gt;
* [[Creating_a_New_EMAC_OE_SDK_Project_with_CMake | Creating a Project with CMake ]]&lt;br /&gt;
* [[Remote_Debugging_EMAC_OE_SDK_with_gdbserver | Remote Debugging EMAC OE SDK Projects with gdbserver]]&lt;br /&gt;
* [[System_Logging | System Logging ]]&lt;/div&gt;</summary>
		<author><name>Mgloff</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.emacinc.com/index.php?title=Creating_a_New_EMAC_OE_SDK_Project_with_CMake&amp;diff=5608</id>
		<title>Creating a New EMAC OE SDK Project with CMake</title>
		<link rel="alternate" type="text/html" href="https://wiki.emacinc.com/index.php?title=Creating_a_New_EMAC_OE_SDK_Project_with_CMake&amp;diff=5608"/>
		<updated>2019-02-11T20:46:11Z</updated>

		<summary type="html">&lt;p&gt;Mgloff: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{todo| Complete (08.07.2015-12:59-&amp;gt;KY+)(08.17.2015-12:07-&amp;gt;KY+)(08.17.2015-14:25-&amp;gt;KY+)(08.17.2015-17:40-&amp;gt;MD-)(11.03.2015-13:38-&amp;gt;KY+);(11.04.2015-11:20-&amp;gt;MD-)(11.04.2015-13:04-&amp;gt;KY+-);(11.04.2015-13:25-&amp;gt;MD+)(11.04.2015-14:45-&amp;gt;MG+)|Klint Youngmeyer| project=OE 5.0,KY,MD,Complete }}&lt;br /&gt;
{{#seo:&lt;br /&gt;
|title=Creating a New EMAC OE SDK Project with CMake&lt;br /&gt;
|titlemode=append&lt;br /&gt;
|keywords=CMakeLists.txt, CMake cross-compiling, CMake, CMake ARM, oe_init_project&lt;br /&gt;
|description=Creating an EMAC OE SDK project which uses the CMake build system.&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /****************************************  Page Description Text  ****************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
The EMAC OE SDK is distributed with the intent that CMake be used with the EMAC OE toolchain and libraries to build most projects. This page demonstrates the process of creating and compiling a new project with CMake, and running it on the target machine.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /*****************************************  General Information  *****************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
{{:Templateimpl:geninfo | initials=KY | title=Creating a New EMAC OE SDK Project with CMake | desc=Creating an EMAC OE SDK Project which Builds via CMake | project=OE 5.0 }}&lt;br /&gt;
Creating a new EMAC CMake project is accomplished with the use of the &amp;lt;code&amp;gt;oe_init_project&amp;lt;/code&amp;gt; program. This program is included in the [ftp://oe50opkg:opkgoe50123@ftp.emacinc.com/5.1/x86_64-nativesdk/nativesdk-emac-tools_git-r0_x86_64-nativesdk.ipk emac-tools] opkg package, which is part of the ADT EMAC SDK. For instructions on installing the EMAC SDK, please see [[Installing_EMAC_OE_5.0_SDK | SDK Install]].&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /*****************************************  Using/Working With  ******************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
{{:Templateimpl:using | initials=KY | title=Creating a New EMAC OE SDK Project with CMake | desc=Creating an EMAC OE SDK project which Builds with CMake | project=OE 5.0 }}&lt;br /&gt;
&lt;br /&gt;
This section demonstrates how to use the EMAC CMake tool, &amp;lt;code&amp;gt;oe_init_project&amp;lt;/code&amp;gt;, to generate CMake files automatically for a project. When using the EMAC SDK there are currently two options for cross compiling:&lt;br /&gt;
* &amp;lt;code&amp;gt;arm&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;x86&amp;lt;/code&amp;gt;&lt;br /&gt;
For the purposes of this guide, the &amp;lt;code&amp;gt;arm&amp;lt;/code&amp;gt; option will be used for the listed examples.&lt;br /&gt;
=== Host Machine Compiling ===&lt;br /&gt;
Navigate to the directory where the project will be located. Then run the CMake new project tool, &amp;lt;code&amp;gt;/opt/emac/5.x/bin/oe_init_project&amp;lt;/code&amp;gt;.&lt;br /&gt;
{{clo}}&lt;br /&gt;
{{clio | username=developer | hostname=ldc | pwd=~ |cd projects }}&lt;br /&gt;
{{clio | username=developer | hostname=ldc | pwd=~/projects | 1 = export PATH=/opt/emac/5.1/bin:$PATH}}&lt;br /&gt;
{{clio | username=developer | hostname=ldc | pwd=~/projects |oe_init_project -n hello.c }}&lt;br /&gt;
If desired, please enter a name for this project, otherwise press Enter to use the default: hello_emac &amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
-- Creating new project directory... &amp;lt;br /&amp;gt;&lt;br /&gt;
-- Creating new source file... &amp;lt;br /&amp;gt;&lt;br /&gt;
-- Building custom CMakeLists.txt file... &amp;lt;br /&amp;gt;&lt;br /&gt;
-- Done. &amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Do you want to create a build directory for this project? (y/n) y &amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
-- Creating build directory... &amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Do you want to run cmake for this project? (y/n) y &amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
-- Using system compiler &amp;lt;br /&amp;gt;&lt;br /&gt;
-- The C compiler identification is GNU 4.8.2 &amp;lt;br /&amp;gt;&lt;br /&gt;
-- The CXX compiler identification is GNU 4.8.2 &amp;lt;br /&amp;gt;&lt;br /&gt;
-- Check for working C compiler: /usr/bin/cc &amp;lt;br /&amp;gt;&lt;br /&gt;
-- Check for working C compiler: /usr/bin/cc -- works &amp;lt;br /&amp;gt;&lt;br /&gt;
-- Detecting C compiler ABI info &amp;lt;br /&amp;gt;&lt;br /&gt;
-- Detecting C compiler ABI info - done &amp;lt;br /&amp;gt;&lt;br /&gt;
-- Check for working CXX compiler: /usr/bin/c++ &amp;lt;br /&amp;gt;&lt;br /&gt;
-- Check for working CXX compiler: /usr/bin/c++ -- works &amp;lt;br /&amp;gt;&lt;br /&gt;
-- Detecting CXX compiler ABI info &amp;lt;br /&amp;gt;&lt;br /&gt;
-- Detecting CXX compiler ABI info - done &amp;lt;br /&amp;gt;&lt;br /&gt;
-- Configuring done &amp;lt;br /&amp;gt;&lt;br /&gt;
-- Generating done &amp;lt;br /&amp;gt;&lt;br /&gt;
-- Build files have been written to: /home/developer/projects/hello_emac/hello_emac-build &amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Do you want to compile this project? (y/n) y&lt;br /&gt;
&lt;br /&gt;
Scanning dependencies of target hello_emac &amp;lt;br /&amp;gt;&lt;br /&gt;
[100%] Building C object CMakeFiles/hello_emac.dir/hello.c.o &amp;lt;br /&amp;gt;&lt;br /&gt;
Linking C executable hello_emac &amp;lt;br /&amp;gt;&lt;br /&gt;
[100%] Built target hello_emac &amp;lt;br /&amp;gt;&lt;br /&gt;
{{clos}}&lt;br /&gt;
&lt;br /&gt;
The executable, in this case,  is now inside the &amp;lt;code&amp;gt; hello_emac/hello_emac-build &amp;lt;/code&amp;gt; directory and can be executed by the host machine (X86_64).&lt;br /&gt;
&lt;br /&gt;
The CMake project script has now made a project directory that contains the following:&lt;br /&gt;
* &amp;lt;code&amp;gt;CMakeLists.txt&amp;lt;/code&amp;gt;&lt;br /&gt;
* Source code file (&amp;lt;code&amp;gt;hello.c&amp;lt;/code&amp;gt; in this case)&lt;br /&gt;
* &amp;lt;code&amp;gt;README&amp;lt;/code&amp;gt; file&lt;br /&gt;
* Desktop Build Directory (&amp;lt;code&amp;gt;hello_emac-build&amp;lt;/code&amp;gt; in this case)&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;CMakeLists.txt&amp;lt;/code&amp;gt; is a script which contains the required information to automatically create a &amp;lt;code&amp;gt;Makefile&amp;lt;/code&amp;gt; for any supported architecture.  This file was generated by the EMAC &amp;lt;code&amp;gt;oe_init_project&amp;lt;/code&amp;gt; tool, and will need to be modified over time as a project grows.  The comments in the &amp;lt;code&amp;gt;CMakeLists.txt&amp;lt;/code&amp;gt; file generated by the EMAC tool will provide a good starting point for how to add additional source files and how to perform other common tasks related to maintaining your CMake build system as you develop your software project. The [http://cmake.org CMake] project provides extensive documentation on how to work with these files.&lt;br /&gt;
&lt;br /&gt;
The source code file generated by the script (&amp;lt;code&amp;gt;hello.c&amp;lt;/code&amp;gt;) contains a basic Hello World style program.  This can provide a starting point for your application, or can be replaced by another source file with the same name.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;README&amp;lt;/code&amp;gt; file contains more information on using &amp;lt;code&amp;gt;CMake&amp;lt;/code&amp;gt; with the EMAC OE 5.X SDK.  You may refer to this file for quick reference.&lt;br /&gt;
&lt;br /&gt;
The Desktop Build Directory (&amp;lt;code&amp;gt;hello_emac-build&amp;lt;/code&amp;gt;) contains the executable, &amp;lt;code&amp;gt;hello_emac&amp;lt;/code&amp;gt;, the &amp;lt;code&amp;gt;Makefile&amp;lt;/code&amp;gt;, and various cache files.  These were automatically created by CMake and by the build system, and can be recreated at any time.&lt;br /&gt;
&lt;br /&gt;
It is useful to have a Desktop Build Directory because it is easier (in the beginning) to use the desktop to verify all code changes before cross-compiling for a target board. This will be useful until the application under development depends upon resources which are only available on the target hardware, such as certain device drivers or the touchscreen (if so equipped).&lt;br /&gt;
&lt;br /&gt;
=== Target Machine Compiling ===&lt;br /&gt;
&lt;br /&gt;
Use the following steps to cross-compile the project and send it to a target board.&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;lt;cl&amp;gt;&lt;br /&gt;
1. In a terminal, navigate to the base directory of the project. {{note | If the architecture of the target board you're using for your appliction &amp;lt;code&amp;gt;x86&amp;lt;/code&amp;gt;, then you will need to change all occurrences of &amp;lt;code&amp;gt;arm&amp;lt;/code&amp;gt; in the following sections below to &amp;lt;code&amp;gt;x86&amp;lt;/code&amp;gt;.}}&lt;br /&gt;
* Create a build directory for cross compiling. &lt;br /&gt;
{{cli | username=developer | hostname=ldc | pwd=~/projects/hello_emac | mkdir hello_emac-build-arm }} &lt;br /&gt;
* Navigate into the newly created directory.&lt;br /&gt;
{{cli | username=developer | hostname=ldc | pwd=~/projects/hello_emac | cd hello_emac-build-arm }} &lt;br /&gt;
* Run &amp;lt;code&amp;gt;cmake&amp;lt;/code&amp;gt; using the target architecture.&lt;br /&gt;
{{cli | username=developer | hostname=ldc | pwd=~/projects/hello_emac/hello_emac-build-arm | 1 = cmake .. -DARCH:STRING=arm }} &lt;br /&gt;
* Compile the code using &amp;lt;code&amp;gt;make&amp;lt;/code&amp;gt;.&lt;br /&gt;
{{cli | username=developer | hostname=ldc | pwd=~/projects/hello_emac/hello_emac-build-arm | make }} &lt;br /&gt;
The &amp;lt;code&amp;gt; make &amp;lt;/code&amp;gt; command creates the target executable in the &amp;lt;code&amp;gt;hello_emac-build-arm&amp;lt;/code&amp;gt; directory.&lt;br /&gt;
* Now copy the executable to the target board. For information on copying the executable file, see the [[ #Transferring_Files | Transferring Files ]] section.&lt;br /&gt;
&amp;lt;/cl&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /*****************************************       Examples        *****************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
{{:Templateimpl:examples | initials=KY | title=Creating a New EMAC OE SDK Project with CMake | desc=Creating an EMAC OE SDK project for use with CMake | project=OE 5.0 }}&lt;br /&gt;
This section illustrates how to complete various tasks associated with configuring and building a CMake project.&lt;br /&gt;
===Debug Build Types===&lt;br /&gt;
By default, new projects will have the Debug build type. To compile the project with the Release or Minimum Size Release build types, there are two options:&lt;br /&gt;
*Make a secondary (or tertiary) build directory. (Recommended)&lt;br /&gt;
*Clean the current build directory and re-run CMake.&lt;br /&gt;
The different levels of build type correlate to usage of different C Flags. When cross-compiling, these C Flags are located in the &amp;lt;code&amp;gt;toolchain.&amp;lt;architecture&amp;gt;.cmake&amp;lt;/code&amp;gt; files located, by default, in &amp;lt;code&amp;gt;/opt/emac/5.X/&amp;lt;/code&amp;gt;, with ''X'' being the specific version of SDK. The following table will give a brief overview of the different build types.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;lt;table style=&amp;quot;border-style:double; border-width:2px; margin-top:-10%; margin-bottom:-3%;&amp;quot;&amp;gt;&amp;lt;tr style=&amp;quot;border-style:double; border-width:2px;&amp;quot;&amp;gt;&amp;lt;td&amp;gt;'''Name:'''&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;'''Type:'''&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;'''Debugging Features:'''&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;'''Description:'''&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;'''Optimization Level:'''&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;'''C Flags Used:'''&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tr style=&amp;quot;border-style:solid; border-width:2px;&amp;quot;&amp;gt;&amp;lt;td&amp;gt;Release&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Release&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;disabled&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Release targeted build optimized for best performance.&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-O2&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;CMAKE_C_FLAGS_RELEASE&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tr style=&amp;quot;border-style:solid; border-width:2px;&amp;quot;&amp;gt;&amp;lt;td&amp;gt;MinSizeRel&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Release&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;disabled&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Release targeted build with experimental optimizations. (Builds using this should be thoroughly tested.)&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-O3&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;CMAKE_C_FLAGS_MINSIZEREL&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tr style=&amp;quot;border-style:solid; border-width:2px;&amp;quot;&amp;gt;&amp;lt;td&amp;gt;Debug&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Debug&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;enabled&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;A standard debugging oriented build, optimized for improved debugging.&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-O0&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;CMAKE_C_FLAGS_DEBUG&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
If you wish to add any additional flags to a build type, they can be defined in the project's &amp;lt;code&amp;gt;CMakeList.txt&amp;lt;/code&amp;gt; file as shown in the code snippet below.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cmake&amp;quot;&amp;gt;&lt;br /&gt;
project(example)&lt;br /&gt;
&lt;br /&gt;
SET(MAKE_C_FLAGS_DEBUG &amp;quot;${CMAKE_C_FLAGS_DEBUG} -Wall -Wpedantic&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
# This will add the -Wall and -Wpedantic options to the existing debug build flags&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;!--{{warning | This is really useful information for any developer.  Knowing the level of optimization is insightful, so that should be included.  Knowing whether or not the build was stripped of debugging information is important if they ever intend to release binaries to the public (such as for updates) and to ensure small size and max speed.  Knowing what preprocessor defines are #def'd with a target is really useful when writing debugging code.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
I would put all this in a table like the example I made above (but accurate and complete).  The border-radius and shadows will need to be overridden to make it look right.  Can always use css or a template for this.&lt;br /&gt;
}}--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Method 1: Create separate build directory====&lt;br /&gt;
To create a Release build using the 1st (recommended) method, use the following steps. This method is recommended because it allows both the Debug and the Release executable to exist at the same time.&lt;br /&gt;
&amp;lt;cl&amp;gt;&lt;br /&gt;
1. In a terminal, navigate to the base directory of the project.&lt;br /&gt;
* Create a new release build directory&lt;br /&gt;
{{cli | username=developer | hostname=ldc | pwd=~/projects/hello_emac | mkdir hello_emac-build-arm-release }}&lt;br /&gt;
* Change directories into the newly created directory.&lt;br /&gt;
{{cli | username=developer | hostname=ldc | pwd=~/projects/hello_emac | cd hello_emac-build-arm-release }} &lt;br /&gt;
* Run &amp;lt;code&amp;gt;cmake&amp;lt;/code&amp;gt; using the target architecture.&lt;br /&gt;
{{cli | username=developer | hostname=ldc | pwd=~/projects/hello_emac/hello_emac-build-arm | 1 = cmake .. -DARCH:STRING=arm -DCMAKE_BUILD_TYPE:STRING=Release }}{{note | The string 'MinSizeRel' can be used in place of 'Release' for a potentially smaller executable}}&lt;br /&gt;
* Compile the code using &amp;lt;code&amp;gt;make&amp;lt;/code&amp;gt;.&lt;br /&gt;
{{cli | username=developer | hostname=ldc | pwd=~/projects/hello_emac/hello_emac-build-arm | make }} &lt;br /&gt;
&amp;lt;/cl&amp;gt;&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
====Method 2: Re-use build directory====&lt;br /&gt;
Another option for creating a release build is as follows:&lt;br /&gt;
&amp;lt;cl&amp;gt;&lt;br /&gt;
1. In a terminal, navigate to the build directory of the project.&lt;br /&gt;
* Clean the directory with &amp;lt;code&amp;gt;make&amp;lt;/code&amp;gt;&lt;br /&gt;
{{cli | username=developer | hostname=ldc | pwd=~/projects/hello_emac/hello_emac-build-arm | 1 = make clean}}&lt;br /&gt;
* Run &amp;lt;code&amp;gt;cmake&amp;lt;/code&amp;gt; using the target architecture.&lt;br /&gt;
{{cli | username=developer | hostname=ldc | pwd=~/projects/hello_emac/hello_emac-build-arm | 1 = cmake .. -DARCH:STRING=arm -DCMAKE_BUILD_TYPE:STRING=Release }}{{note | The string 'MinSizeRel' can be used in place of 'Release' for a potentially smaller executable}}&lt;br /&gt;
* Compile the code using &amp;lt;code&amp;gt;make&amp;lt;/code&amp;gt;.&lt;br /&gt;
{{cli | username=developer | hostname=ldc | pwd=~/projects/hello_emac/hello_emac-build-arm | make }} &lt;br /&gt;
&amp;lt;/cl&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Renaming the Target Executable===&lt;br /&gt;
To rename the executable, the &amp;lt;code&amp;gt;ADD_EXECUTABLE()&amp;lt;/code&amp;gt; function arguments must be changed. The first argument refers to the name of the executable, and the second refers to the source code file.&lt;br /&gt;
&lt;br /&gt;
To change the name of the executable from &amp;quot;main&amp;quot; to &amp;quot;new_name&amp;quot;, change the &amp;lt;code&amp;gt;ADD_EXECUTABLE()&amp;lt;/code&amp;gt; from the first code box to the second code box.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cmake&amp;quot;&amp;gt;&lt;br /&gt;
ADD_EXECUTABLE(main main.cpp)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cmake&amp;quot;&amp;gt;&lt;br /&gt;
ADD_EXECUTABLE(new_name main.cpp)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Adding Include Files===&lt;br /&gt;
To add an include file and implementation file (in this case, the &amp;lt;code&amp;gt;tools.cpp&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;tools.h&amp;lt;/code&amp;gt; in the &amp;lt;code&amp;gt;util&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;include&amp;lt;/code&amp;gt; directory, respectively) to the CMake project, changes will need to be made to the CMakeLists.txt file. Please refer to the code sample below.&lt;br /&gt;
&lt;br /&gt;
# The directory to be included must be specified by the &amp;lt;code&amp;gt;INCLUDE_DIRECTORIES()&amp;lt;/code&amp;gt; function. The variable &amp;lt;code&amp;gt;${PROJECT_SOURCE_DIR}&amp;lt;/code&amp;gt; refers to the base path of the project which is generally where this &amp;lt;code&amp;gt;README&amp;lt;/code&amp;gt; file is located.&lt;br /&gt;
# The &amp;lt;code&amp;gt;SOURCES&amp;lt;/code&amp;gt; must be set. This list of files should include all of the source files in the project.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cmake&amp;quot;&amp;gt;&lt;br /&gt;
INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}include)&lt;br /&gt;
&lt;br /&gt;
SET(SOURCES&lt;br /&gt;
     ${PROJECT_SOURCE_DIR}main.cpp&lt;br /&gt;
     ${PROJECT_SOURCE_DIR}util/tools.cpp&lt;br /&gt;
     )&lt;br /&gt;
SET(HEADERS&lt;br /&gt;
     ${PROJECT_SOURCE_DIR}include/tools.h&lt;br /&gt;
     )&lt;br /&gt;
&lt;br /&gt;
ADD_EXECUTABLE(main ${SOURCES} ${HEADERS})&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /******************************************   More Information   *****************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
{{:Templateimpl:moreinfo | initials=KY | title=Creating a New EMAC OE SDK Project with CMake | desc=Creating an EMAC OE SDK project for use with CMake | project=OE 5.0 }}&lt;br /&gt;
&amp;lt;!--{{:Templateimpl:whatnext | initials=KY | title=Creating a New EMAC OE SDK Project with CMake | desc=Creating an EMAC OE SDK project for use with CMake | project=OE 5.0 }}--&amp;gt;&lt;br /&gt;
* [[System_Log_In | System Log In]]&lt;br /&gt;
* [[Serial_Connections | Serial Connections ]]&lt;br /&gt;
* [[Network_Connections | Network Connections ]]&lt;br /&gt;
* [[System_Log_In | System Log In ]]&lt;br /&gt;
* [[Remote_Debugging_EMAC_OE_SDK_Projects_with_gdbserver | Remote Debugging EMAC OE SDK Projects with gdbserver ]]&lt;br /&gt;
* [[System_Logging | System Logging ]]&lt;/div&gt;</summary>
		<author><name>Mgloff</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.emacinc.com/index.php?title=Creating_a_New_EMAC_OE_SDK_Project_with_CMake&amp;diff=5559</id>
		<title>Creating a New EMAC OE SDK Project with CMake</title>
		<link rel="alternate" type="text/html" href="https://wiki.emacinc.com/index.php?title=Creating_a_New_EMAC_OE_SDK_Project_with_CMake&amp;diff=5559"/>
		<updated>2018-08-09T23:15:20Z</updated>

		<summary type="html">&lt;p&gt;Mgloff: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{todo| Complete (08.07.2015-12:59-&amp;gt;KY+)(08.17.2015-12:07-&amp;gt;KY+)(08.17.2015-14:25-&amp;gt;KY+)(08.17.2015-17:40-&amp;gt;MD-)(11.03.2015-13:38-&amp;gt;KY+);(11.04.2015-11:20-&amp;gt;MD-)(11.04.2015-13:04-&amp;gt;KY+-);(11.04.2015-13:25-&amp;gt;MD+)(11.04.2015-14:45-&amp;gt;MG+)|Klint Youngmeyer| project=OE 5.0,KY,MD,Complete }}&lt;br /&gt;
{{#seo:&lt;br /&gt;
|title=Creating a New EMAC OE SDK Project with CMake&lt;br /&gt;
|titlemode=append&lt;br /&gt;
|keywords=CMakeLists.txt, CMake cross-compiling, CMake, CMake ARM, oe_init_project&lt;br /&gt;
|description=Creating an EMAC OE SDK project which uses the CMake build system.&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /****************************************  Page Description Text  ****************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
The EMAC OE SDK is distributed with the intent that CMake be used with the EMAC OE toolchain and libraries to build most projects. This page demonstrates the process of creating and compiling a new project with CMake, and running it on the target machine.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /*****************************************  General Information  *****************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
{{:Templateimpl:geninfo | initials=KY | title=Creating a New EMAC OE SDK Project with CMake | desc=Creating an EMAC OE SDK Project which Builds via CMake | project=OE 5.0 }}&lt;br /&gt;
Creating a new EMAC CMake project is accomplished with the use of the &amp;lt;code&amp;gt;oe_init_project&amp;lt;/code&amp;gt; program. This program is included in the [ftp://oe50opkg:opkgoe50123@ftp.emacinc.com/5.1/x86_64-nativesdk/nativesdk-emac-tools_git-r0_x86_64-nativesdk.ipk emac-tools] opkg package, which is part of the ADT EMAC SDK. For instructions on installing the EMAC SDK, please see [[Installing_EMAC_OE_5.0_SDK | SDK Install]].&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /*****************************************  Using/Working With  ******************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
{{:Templateimpl:using | initials=KY | title=Creating a New EMAC OE SDK Project with CMake | desc=Creating an EMAC OE SDK project which Builds with CMake | project=OE 5.0 }}&lt;br /&gt;
&lt;br /&gt;
This section demonstrates how to use the EMAC CMake tool, &amp;lt;code&amp;gt;oe_init_project&amp;lt;/code&amp;gt;, to generate CMake files automatically for a project. When using the EMAC SDK there are currently two options for cross compiling:&lt;br /&gt;
* &amp;lt;code&amp;gt;arm&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;x86&amp;lt;/code&amp;gt;&lt;br /&gt;
For the purposes of this guide, the &amp;lt;code&amp;gt;arm&amp;lt;/code&amp;gt; option will be used for the listed examples.&lt;br /&gt;
=== Host Machine Compiling ===&lt;br /&gt;
Navigate to the directory where the project will be located. Then run the CMake new project tool, &amp;lt;code&amp;gt;/opt/emac/5.x/bin/oe_init_project&amp;lt;/code&amp;gt;.&lt;br /&gt;
{{clo}}&lt;br /&gt;
{{clio | username=developer | hostname=ldc | pwd=~/projects | /opt/emac/5.x/bin/oe_init_project -n hello.c }}&lt;br /&gt;
If desired, please enter a name for this project, otherwise press Enter to use the default: hello_emac &amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
-- Creating new project directory... &amp;lt;br /&amp;gt;&lt;br /&gt;
-- Creating new source file... &amp;lt;br /&amp;gt;&lt;br /&gt;
-- Building custom CMakeLists.txt file... &amp;lt;br /&amp;gt;&lt;br /&gt;
-- Done. &amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Do you want to create a build directory for this project? (y/n) y &amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
-- Creating build directory... &amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Do you want to run cmake for this project? (y/n) y &amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
-- Using system compiler &amp;lt;br /&amp;gt;&lt;br /&gt;
-- The C compiler identification is GNU 4.8.2 &amp;lt;br /&amp;gt;&lt;br /&gt;
-- The CXX compiler identification is GNU 4.8.2 &amp;lt;br /&amp;gt;&lt;br /&gt;
-- Check for working C compiler: /usr/bin/cc &amp;lt;br /&amp;gt;&lt;br /&gt;
-- Check for working C compiler: /usr/bin/cc -- works &amp;lt;br /&amp;gt;&lt;br /&gt;
-- Detecting C compiler ABI info &amp;lt;br /&amp;gt;&lt;br /&gt;
-- Detecting C compiler ABI info - done &amp;lt;br /&amp;gt;&lt;br /&gt;
-- Check for working CXX compiler: /usr/bin/c++ &amp;lt;br /&amp;gt;&lt;br /&gt;
-- Check for working CXX compiler: /usr/bin/c++ -- works &amp;lt;br /&amp;gt;&lt;br /&gt;
-- Detecting CXX compiler ABI info &amp;lt;br /&amp;gt;&lt;br /&gt;
-- Detecting CXX compiler ABI info - done &amp;lt;br /&amp;gt;&lt;br /&gt;
-- Configuring done &amp;lt;br /&amp;gt;&lt;br /&gt;
-- Generating done &amp;lt;br /&amp;gt;&lt;br /&gt;
-- Build files have been written to: /home/developer/projects/hello_emac/hello_emac-build &amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Do you want to compile this project? (y/n) y&lt;br /&gt;
&lt;br /&gt;
Scanning dependencies of target hello_emac &amp;lt;br /&amp;gt;&lt;br /&gt;
[100%] Building C object CMakeFiles/hello_emac.dir/hello.c.o &amp;lt;br /&amp;gt;&lt;br /&gt;
Linking C executable hello_emac &amp;lt;br /&amp;gt;&lt;br /&gt;
[100%] Built target hello_emac &amp;lt;br /&amp;gt;&lt;br /&gt;
{{clos}}&lt;br /&gt;
&lt;br /&gt;
The executable, in this case,  is now inside the &amp;lt;code&amp;gt; hello_emac/hello_emac-build &amp;lt;/code&amp;gt; directory and can be executed by the host machine (X86_64).&lt;br /&gt;
&lt;br /&gt;
The CMake project script has now made a project directory that contains the following:&lt;br /&gt;
* &amp;lt;code&amp;gt;CMakeLists.txt&amp;lt;/code&amp;gt;&lt;br /&gt;
* Source code file (&amp;lt;code&amp;gt;hello.c&amp;lt;/code&amp;gt; in this case)&lt;br /&gt;
* &amp;lt;code&amp;gt;README&amp;lt;/code&amp;gt; file&lt;br /&gt;
* Desktop Build Directory (&amp;lt;code&amp;gt;hello_emac-build&amp;lt;/code&amp;gt; in this case)&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;CMakeLists.txt&amp;lt;/code&amp;gt; is a script which contains the required information to automatically create a &amp;lt;code&amp;gt;Makefile&amp;lt;/code&amp;gt; for any supported architecture.  This file was generated by the EMAC &amp;lt;code&amp;gt;oe_init_project&amp;lt;/code&amp;gt; tool, and will need to be modified over time as a project grows.  The comments in the &amp;lt;code&amp;gt;CMakeLists.txt&amp;lt;/code&amp;gt; file generated by the EMAC tool will provide a good starting point for how to add additional source files and how to perform other common tasks related to maintaining your CMake build system as you develop your software project. The [http://cmake.org CMake] project provides extensive documentation on how to work with these files.&lt;br /&gt;
&lt;br /&gt;
The source code file generated by the script (&amp;lt;code&amp;gt;hello.c&amp;lt;/code&amp;gt;) contains a basic Hello World style program.  This can provide a starting point for your application, or can be replaced by another source file with the same name.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;README&amp;lt;/code&amp;gt; file contains more information on using &amp;lt;code&amp;gt;CMake&amp;lt;/code&amp;gt; with the EMAC OE 5.X SDK.  You may refer to this file for quick reference.&lt;br /&gt;
&lt;br /&gt;
The Desktop Build Directory (&amp;lt;code&amp;gt;hello_emac-build&amp;lt;/code&amp;gt;) contains the executable, &amp;lt;code&amp;gt;hello_emac&amp;lt;/code&amp;gt;, the &amp;lt;code&amp;gt;Makefile&amp;lt;/code&amp;gt;, and various cache files.  These were automatically created by CMake and by the build system, and can be recreated at any time.&lt;br /&gt;
&lt;br /&gt;
It is useful to have a Desktop Build Directory because it is easier (in the beginning) to use the desktop to verify all code changes before cross-compiling for a target board. This will be useful until the application under development depends upon resources which are only available on the target hardware, such as certain device drivers or the touchscreen (if so equipped).&lt;br /&gt;
&lt;br /&gt;
=== Target Machine Compiling ===&lt;br /&gt;
&lt;br /&gt;
Use the following steps to cross-compile the project and send it to a target board.&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;lt;cl&amp;gt;&lt;br /&gt;
1. In a terminal, navigate to the base directory of the project. {{note | If the architecture of the target board you're using for your appliction &amp;lt;code&amp;gt;x86&amp;lt;/code&amp;gt;, then you will need to change all occurrences of &amp;lt;code&amp;gt;arm&amp;lt;/code&amp;gt; in the following sections below to &amp;lt;code&amp;gt;x86&amp;lt;/code&amp;gt;.}}&lt;br /&gt;
* Create a build directory for cross compiling. &lt;br /&gt;
{{cli | username=developer | hostname=ldc | pwd=~/projects/hello_emac | mkdir hello_emac-build-arm }} &lt;br /&gt;
* Navigate into the newly created directory.&lt;br /&gt;
{{cli | username=developer | hostname=ldc | pwd=~/projects/hello_emac | cd hello_emac-build-arm }} &lt;br /&gt;
* Run &amp;lt;code&amp;gt;cmake&amp;lt;/code&amp;gt; using the target architecture.&lt;br /&gt;
{{cli | username=developer | hostname=ldc | pwd=~/projects/hello_emac/hello_emac-build-arm | 1 = cmake .. -DARCH:STRING=arm }} &lt;br /&gt;
* Compile the code using &amp;lt;code&amp;gt;make&amp;lt;/code&amp;gt;.&lt;br /&gt;
{{cli | username=developer | hostname=ldc | pwd=~/projects/hello_emac/hello_emac-build-arm | make }} &lt;br /&gt;
The &amp;lt;code&amp;gt; make &amp;lt;/code&amp;gt; command creates the target executable in the &amp;lt;code&amp;gt;hello_emac-build-arm&amp;lt;/code&amp;gt; directory.&lt;br /&gt;
* Now copy the executable to the target board. For information on copying the executable file, see the [[ #Transferring_Files | Transferring Files ]] section.&lt;br /&gt;
&amp;lt;/cl&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /*****************************************       Examples        *****************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
{{:Templateimpl:examples | initials=KY | title=Creating a New EMAC OE SDK Project with CMake | desc=Creating an EMAC OE SDK project for use with CMake | project=OE 5.0 }}&lt;br /&gt;
This section illustrates how to complete various tasks associated with configuring and building a CMake project.&lt;br /&gt;
===Debug Build Types===&lt;br /&gt;
By default, new projects will have the Debug build type. To compile the project with the Release or Minimum Size Release build types, there are two options:&lt;br /&gt;
*Make a secondary (or tertiary) build directory. (Recommended)&lt;br /&gt;
*Clean the current build directory and re-run CMake.&lt;br /&gt;
The different levels of build type correlate to usage of different C Flags. When cross-compiling, these C Flags are located in the &amp;lt;code&amp;gt;toolchain.&amp;lt;architecture&amp;gt;.cmake&amp;lt;/code&amp;gt; files located, by default, in &amp;lt;code&amp;gt;/opt/emac/5.X/&amp;lt;/code&amp;gt;, with ''X'' being the specific version of SDK. The following table will give a brief overview of the different build types.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;lt;table style=&amp;quot;border-style:double; border-width:2px; margin-top:-10%; margin-bottom:-3%;&amp;quot;&amp;gt;&amp;lt;tr style=&amp;quot;border-style:double; border-width:2px;&amp;quot;&amp;gt;&amp;lt;td&amp;gt;'''Name:'''&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;'''Type:'''&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;'''Debugging Features:'''&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;'''Description:'''&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;'''Optimization Level:'''&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;'''C Flags Used:'''&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tr style=&amp;quot;border-style:solid; border-width:2px;&amp;quot;&amp;gt;&amp;lt;td&amp;gt;Release&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Release&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;disabled&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Release targeted build optimized for best performance.&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-O2&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;CMAKE_C_FLAGS_RELEASE&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tr style=&amp;quot;border-style:solid; border-width:2px;&amp;quot;&amp;gt;&amp;lt;td&amp;gt;MinSizeRel&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Release&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;disabled&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Release targeted build with experimental optimizations. (Builds using this should be thoroughly tested.)&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-O3&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;CMAKE_C_FLAGS_MINSIZEREL&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tr style=&amp;quot;border-style:solid; border-width:2px;&amp;quot;&amp;gt;&amp;lt;td&amp;gt;Debug&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Debug&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;enabled&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;A standard debugging oriented build, optimized for improved debugging.&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-O0&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;CMAKE_C_FLAGS_DEBUG&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
If you wish to add any additional flags to a build type, they can be defined in the project's &amp;lt;code&amp;gt;CMakeList.txt&amp;lt;/code&amp;gt; file as shown in the code snippet below.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cmake&amp;quot;&amp;gt;&lt;br /&gt;
project(example)&lt;br /&gt;
&lt;br /&gt;
SET(MAKE_C_FLAGS_DEBUG &amp;quot;${CMAKE_C_FLAGS_DEBUG} -Wall -Wpedantic&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
# This will add the -Wall and -Wpedantic options to the existing debug build flags&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;!--{{warning | This is really useful information for any developer.  Knowing the level of optimization is insightful, so that should be included.  Knowing whether or not the build was stripped of debugging information is important if they ever intend to release binaries to the public (such as for updates) and to ensure small size and max speed.  Knowing what preprocessor defines are #def'd with a target is really useful when writing debugging code.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
I would put all this in a table like the example I made above (but accurate and complete).  The border-radius and shadows will need to be overridden to make it look right.  Can always use css or a template for this.&lt;br /&gt;
}}--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Method 1: Create separate build directory====&lt;br /&gt;
To create a Release build using the 1st (recommended) method, use the following steps. This method is recommended because it allows both the Debug and the Release executable to exist at the same time.&lt;br /&gt;
&amp;lt;cl&amp;gt;&lt;br /&gt;
1. In a terminal, navigate to the base directory of the project.&lt;br /&gt;
* Create a new release build directory&lt;br /&gt;
{{cli | username=developer | hostname=ldc | pwd=~/projects/hello_emac | mkdir hello_emac-build-arm-release }}&lt;br /&gt;
* Change directories into the newly created directory.&lt;br /&gt;
{{cli | username=developer | hostname=ldc | pwd=~/projects/hello_emac | cd hello_emac-build-arm-release }} &lt;br /&gt;
* Run &amp;lt;code&amp;gt;cmake&amp;lt;/code&amp;gt; using the target architecture.&lt;br /&gt;
{{cli | username=developer | hostname=ldc | pwd=~/projects/hello_emac/hello_emac-build-arm | 1 = cmake .. -DARCH:STRING=arm -DCMAKE_BUILD_TYPE:STRING=Release }}{{note | The string 'MinSizeRel' can be used in place of 'Release' for a potentially smaller executable}}&lt;br /&gt;
* Compile the code using &amp;lt;code&amp;gt;make&amp;lt;/code&amp;gt;.&lt;br /&gt;
{{cli | username=developer | hostname=ldc | pwd=~/projects/hello_emac/hello_emac-build-arm | make }} &lt;br /&gt;
&amp;lt;/cl&amp;gt;&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
====Method 2: Re-use build directory====&lt;br /&gt;
Another option for creating a release build is as follows:&lt;br /&gt;
&amp;lt;cl&amp;gt;&lt;br /&gt;
1. In a terminal, navigate to the build directory of the project.&lt;br /&gt;
* Clean the directory with &amp;lt;code&amp;gt;make&amp;lt;/code&amp;gt;&lt;br /&gt;
{{cli | username=developer | hostname=ldc | pwd=~/projects/hello_emac/hello_emac-build-arm | 1 = make clean}}&lt;br /&gt;
* Run &amp;lt;code&amp;gt;cmake&amp;lt;/code&amp;gt; using the target architecture.&lt;br /&gt;
{{cli | username=developer | hostname=ldc | pwd=~/projects/hello_emac/hello_emac-build-arm | 1 = cmake .. -DARCH:STRING=arm -DCMAKE_BUILD_TYPE:STRING=Release }}{{note | The string 'MinSizeRel' can be used in place of 'Release' for a potentially smaller executable}}&lt;br /&gt;
* Compile the code using &amp;lt;code&amp;gt;make&amp;lt;/code&amp;gt;.&lt;br /&gt;
{{cli | username=developer | hostname=ldc | pwd=~/projects/hello_emac/hello_emac-build-arm | make }} &lt;br /&gt;
&amp;lt;/cl&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Renaming the Target Executable===&lt;br /&gt;
To rename the executable, the &amp;lt;code&amp;gt;ADD_EXECUTABLE()&amp;lt;/code&amp;gt; function arguments must be changed. The first argument refers to the name of the executable, and the second refers to the source code file.&lt;br /&gt;
&lt;br /&gt;
To change the name of the executable from &amp;quot;main&amp;quot; to &amp;quot;new_name&amp;quot;, change the &amp;lt;code&amp;gt;ADD_EXECUTABLE()&amp;lt;/code&amp;gt; from the first code box to the second code box.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cmake&amp;quot;&amp;gt;&lt;br /&gt;
ADD_EXECUTABLE(main main.cpp)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cmake&amp;quot;&amp;gt;&lt;br /&gt;
ADD_EXECUTABLE(new_name main.cpp)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Adding Include Files===&lt;br /&gt;
To add an include file and implementation file (in this case, the &amp;lt;code&amp;gt;tools.cpp&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;tools.h&amp;lt;/code&amp;gt; in the &amp;lt;code&amp;gt;util&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;include&amp;lt;/code&amp;gt; directory, respectively) to the CMake project, changes will need to be made to the CMakeLists.txt file. Please refer to the code sample below.&lt;br /&gt;
&lt;br /&gt;
# The directory to be included must be specified by the &amp;lt;code&amp;gt;INCLUDE_DIRECTORIES()&amp;lt;/code&amp;gt; function. The variable &amp;lt;code&amp;gt;${PROJECT_SOURCE_DIR}&amp;lt;/code&amp;gt; refers to the base path of the project which is generally where this &amp;lt;code&amp;gt;README&amp;lt;/code&amp;gt; file is located.&lt;br /&gt;
# The &amp;lt;code&amp;gt;SOURCES&amp;lt;/code&amp;gt; must be set. This list of files should include all of the source files in the project.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cmake&amp;quot;&amp;gt;&lt;br /&gt;
INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}include)&lt;br /&gt;
&lt;br /&gt;
SET(SOURCES&lt;br /&gt;
     ${PROJECT_SOURCE_DIR}main.cpp&lt;br /&gt;
     ${PROJECT_SOURCE_DIR}util/tools.cpp&lt;br /&gt;
     )&lt;br /&gt;
SET(HEADERS&lt;br /&gt;
     ${PROJECT_SOURCE_DIR}include/tools.h&lt;br /&gt;
     )&lt;br /&gt;
&lt;br /&gt;
ADD_EXECUTABLE(main ${SOURCES} ${HEADERS})&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /******************************************   More Information   *****************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
{{:Templateimpl:moreinfo | initials=KY | title=Creating a New EMAC OE SDK Project with CMake | desc=Creating an EMAC OE SDK project for use with CMake | project=OE 5.0 }}&lt;br /&gt;
&amp;lt;!--{{:Templateimpl:whatnext | initials=KY | title=Creating a New EMAC OE SDK Project with CMake | desc=Creating an EMAC OE SDK project for use with CMake | project=OE 5.0 }}--&amp;gt;&lt;br /&gt;
* [[System_Log_In | System Log In]]&lt;br /&gt;
* [[Serial_Connections | Serial Connections ]]&lt;br /&gt;
* [[Network_Connections | Network Connections ]]&lt;br /&gt;
* [[System_Log_In | System Log In ]]&lt;br /&gt;
* [[Remote_Debugging_EMAC_OE_SDK_Projects_with_gdbserver | Remote Debugging EMAC OE SDK Projects with gdbserver ]]&lt;br /&gt;
* [[System_Logging | System Logging ]]&lt;/div&gt;</summary>
		<author><name>Mgloff</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.emacinc.com/index.php?title=Creating_a_New_EMAC_OE_SDK_Project_with_CMake&amp;diff=5558</id>
		<title>Creating a New EMAC OE SDK Project with CMake</title>
		<link rel="alternate" type="text/html" href="https://wiki.emacinc.com/index.php?title=Creating_a_New_EMAC_OE_SDK_Project_with_CMake&amp;diff=5558"/>
		<updated>2018-08-09T23:13:23Z</updated>

		<summary type="html">&lt;p&gt;Mgloff: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{todo| Complete (08.07.2015-12:59-&amp;gt;KY+)(08.17.2015-12:07-&amp;gt;KY+)(08.17.2015-14:25-&amp;gt;KY+)(08.17.2015-17:40-&amp;gt;MD-)(11.03.2015-13:38-&amp;gt;KY+);(11.04.2015-11:20-&amp;gt;MD-)(11.04.2015-13:04-&amp;gt;KY+-);(11.04.2015-13:25-&amp;gt;MD+)(11.04.2015-14:45-&amp;gt;MG+)|Klint Youngmeyer| project=OE 5.0,KY,MD,Complete }}&lt;br /&gt;
{{#seo:&lt;br /&gt;
|title=Creating a New EMAC OE SDK Project with CMake&lt;br /&gt;
|titlemode=append&lt;br /&gt;
|keywords=CMakeLists.txt, CMake cross-compiling, CMake, CMake ARM, oe_init_project&lt;br /&gt;
|description=Creating an EMAC OE SDK project which uses the CMake build system.&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /****************************************  Page Description Text  ****************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
The EMAC OE SDK is distributed with the intent that CMake be used with the EMAC OE toolchain and libraries to build most projects. This page demonstrates the process of creating and compiling a new project with CMake, and running it on the target machine.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /*****************************************  General Information  *****************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
{{:Templateimpl:geninfo | initials=KY | title=Creating a New EMAC OE SDK Project with CMake | desc=Creating an EMAC OE SDK Project which Builds via CMake | project=OE 5.0 }}&lt;br /&gt;
Creating a new EMAC CMake project is accomplished with the use of the &amp;lt;code&amp;gt;oe_init_project&amp;lt;/code&amp;gt; program. This program is included in the [ftp://oe50opkg:opkgoe50123@ftp.emacinc.com/5.1/x86_64-nativesdk/nativesdk-emac-tools_git-r0_x86_64-nativesdk.ipk emac-tools] opkg package, which is part of the ADT EMAC SDK. For instructions on installing the EMAC SDK, please see [[Getting_Started_with_the_EMAC_OE_SDK#Installing_EMAC_SDK |this section]] in the getting started guide.&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /*****************************************  Using/Working With  ******************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
{{:Templateimpl:using | initials=KY | title=Creating a New EMAC OE SDK Project with CMake | desc=Creating an EMAC OE SDK project which Builds with CMake | project=OE 5.0 }}&lt;br /&gt;
&lt;br /&gt;
This section demonstrates how to use the EMAC CMake tool, &amp;lt;code&amp;gt;oe_init_project&amp;lt;/code&amp;gt;, to generate CMake files automatically for a project. When using the EMAC SDK there are currently two options for cross compiling:&lt;br /&gt;
* &amp;lt;code&amp;gt;arm&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;x86&amp;lt;/code&amp;gt;&lt;br /&gt;
For the purposes of this guide, the &amp;lt;code&amp;gt;arm&amp;lt;/code&amp;gt; option will be used for the listed examples.&lt;br /&gt;
=== Host Machine Compiling ===&lt;br /&gt;
Navigate to the directory where the project will be located. Then run the CMake new project tool, &amp;lt;code&amp;gt;/opt/emac/5.x/bin/oe_init_project&amp;lt;/code&amp;gt;.&lt;br /&gt;
{{clo}}&lt;br /&gt;
{{clio | username=developer | hostname=ldc | pwd=~/projects | /opt/emac/5.x/bin/oe_init_project -n hello.c }}&lt;br /&gt;
If desired, please enter a name for this project, otherwise press Enter to use the default: hello_emac &amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
-- Creating new project directory... &amp;lt;br /&amp;gt;&lt;br /&gt;
-- Creating new source file... &amp;lt;br /&amp;gt;&lt;br /&gt;
-- Building custom CMakeLists.txt file... &amp;lt;br /&amp;gt;&lt;br /&gt;
-- Done. &amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Do you want to create a build directory for this project? (y/n) y &amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
-- Creating build directory... &amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Do you want to run cmake for this project? (y/n) y &amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
-- Using system compiler &amp;lt;br /&amp;gt;&lt;br /&gt;
-- The C compiler identification is GNU 4.8.2 &amp;lt;br /&amp;gt;&lt;br /&gt;
-- The CXX compiler identification is GNU 4.8.2 &amp;lt;br /&amp;gt;&lt;br /&gt;
-- Check for working C compiler: /usr/bin/cc &amp;lt;br /&amp;gt;&lt;br /&gt;
-- Check for working C compiler: /usr/bin/cc -- works &amp;lt;br /&amp;gt;&lt;br /&gt;
-- Detecting C compiler ABI info &amp;lt;br /&amp;gt;&lt;br /&gt;
-- Detecting C compiler ABI info - done &amp;lt;br /&amp;gt;&lt;br /&gt;
-- Check for working CXX compiler: /usr/bin/c++ &amp;lt;br /&amp;gt;&lt;br /&gt;
-- Check for working CXX compiler: /usr/bin/c++ -- works &amp;lt;br /&amp;gt;&lt;br /&gt;
-- Detecting CXX compiler ABI info &amp;lt;br /&amp;gt;&lt;br /&gt;
-- Detecting CXX compiler ABI info - done &amp;lt;br /&amp;gt;&lt;br /&gt;
-- Configuring done &amp;lt;br /&amp;gt;&lt;br /&gt;
-- Generating done &amp;lt;br /&amp;gt;&lt;br /&gt;
-- Build files have been written to: /home/developer/projects/hello_emac/hello_emac-build &amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Do you want to compile this project? (y/n) y&lt;br /&gt;
&lt;br /&gt;
Scanning dependencies of target hello_emac &amp;lt;br /&amp;gt;&lt;br /&gt;
[100%] Building C object CMakeFiles/hello_emac.dir/hello.c.o &amp;lt;br /&amp;gt;&lt;br /&gt;
Linking C executable hello_emac &amp;lt;br /&amp;gt;&lt;br /&gt;
[100%] Built target hello_emac &amp;lt;br /&amp;gt;&lt;br /&gt;
{{clos}}&lt;br /&gt;
&lt;br /&gt;
The executable, in this case,  is now inside the &amp;lt;code&amp;gt; hello_emac/hello_emac-build &amp;lt;/code&amp;gt; directory and can be executed by the host machine (X86_64).&lt;br /&gt;
&lt;br /&gt;
The CMake project script has now made a project directory that contains the following:&lt;br /&gt;
* &amp;lt;code&amp;gt;CMakeLists.txt&amp;lt;/code&amp;gt;&lt;br /&gt;
* Source code file (&amp;lt;code&amp;gt;hello.c&amp;lt;/code&amp;gt; in this case)&lt;br /&gt;
* &amp;lt;code&amp;gt;README&amp;lt;/code&amp;gt; file&lt;br /&gt;
* Desktop Build Directory (&amp;lt;code&amp;gt;hello_emac-build&amp;lt;/code&amp;gt; in this case)&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;CMakeLists.txt&amp;lt;/code&amp;gt; is a script which contains the required information to automatically create a &amp;lt;code&amp;gt;Makefile&amp;lt;/code&amp;gt; for any supported architecture.  This file was generated by the EMAC &amp;lt;code&amp;gt;oe_init_project&amp;lt;/code&amp;gt; tool, and will need to be modified over time as a project grows.  The comments in the &amp;lt;code&amp;gt;CMakeLists.txt&amp;lt;/code&amp;gt; file generated by the EMAC tool will provide a good starting point for how to add additional source files and how to perform other common tasks related to maintaining your CMake build system as you develop your software project. The [http://cmake.org CMake] project provides extensive documentation on how to work with these files.&lt;br /&gt;
&lt;br /&gt;
The source code file generated by the script (&amp;lt;code&amp;gt;hello.c&amp;lt;/code&amp;gt;) contains a basic Hello World style program.  This can provide a starting point for your application, or can be replaced by another source file with the same name.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;README&amp;lt;/code&amp;gt; file contains more information on using &amp;lt;code&amp;gt;CMake&amp;lt;/code&amp;gt; with the EMAC OE 5.X SDK.  You may refer to this file for quick reference.&lt;br /&gt;
&lt;br /&gt;
The Desktop Build Directory (&amp;lt;code&amp;gt;hello_emac-build&amp;lt;/code&amp;gt;) contains the executable, &amp;lt;code&amp;gt;hello_emac&amp;lt;/code&amp;gt;, the &amp;lt;code&amp;gt;Makefile&amp;lt;/code&amp;gt;, and various cache files.  These were automatically created by CMake and by the build system, and can be recreated at any time.&lt;br /&gt;
&lt;br /&gt;
It is useful to have a Desktop Build Directory because it is easier (in the beginning) to use the desktop to verify all code changes before cross-compiling for a target board. This will be useful until the application under development depends upon resources which are only available on the target hardware, such as certain device drivers or the touchscreen (if so equipped).&lt;br /&gt;
&lt;br /&gt;
=== Target Machine Compiling ===&lt;br /&gt;
&lt;br /&gt;
Use the following steps to cross-compile the project and send it to a target board.&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;lt;cl&amp;gt;&lt;br /&gt;
1. In a terminal, navigate to the base directory of the project. {{note | If the architecture of the target board you're using for your appliction &amp;lt;code&amp;gt;x86&amp;lt;/code&amp;gt;, then you will need to change all occurrences of &amp;lt;code&amp;gt;arm&amp;lt;/code&amp;gt; in the following sections below to &amp;lt;code&amp;gt;x86&amp;lt;/code&amp;gt;.}}&lt;br /&gt;
* Create a build directory for cross compiling. &lt;br /&gt;
{{cli | username=developer | hostname=ldc | pwd=~/projects/hello_emac | mkdir hello_emac-build-arm }} &lt;br /&gt;
* Navigate into the newly created directory.&lt;br /&gt;
{{cli | username=developer | hostname=ldc | pwd=~/projects/hello_emac | cd hello_emac-build-arm }} &lt;br /&gt;
* Run &amp;lt;code&amp;gt;cmake&amp;lt;/code&amp;gt; using the target architecture.&lt;br /&gt;
{{cli | username=developer | hostname=ldc | pwd=~/projects/hello_emac/hello_emac-build-arm | 1 = cmake .. -DARCH:STRING=arm }} &lt;br /&gt;
* Compile the code using &amp;lt;code&amp;gt;make&amp;lt;/code&amp;gt;.&lt;br /&gt;
{{cli | username=developer | hostname=ldc | pwd=~/projects/hello_emac/hello_emac-build-arm | make }} &lt;br /&gt;
The &amp;lt;code&amp;gt; make &amp;lt;/code&amp;gt; command creates the target executable in the &amp;lt;code&amp;gt;hello_emac-build-arm&amp;lt;/code&amp;gt; directory.&lt;br /&gt;
* Now copy the executable to the target board. For information on copying the executable file, see the [[ #Transferring_Files | Transferring Files ]] section.&lt;br /&gt;
&amp;lt;/cl&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /*****************************************       Examples        *****************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
{{:Templateimpl:examples | initials=KY | title=Creating a New EMAC OE SDK Project with CMake | desc=Creating an EMAC OE SDK project for use with CMake | project=OE 5.0 }}&lt;br /&gt;
This section illustrates how to complete various tasks associated with configuring and building a CMake project.&lt;br /&gt;
===Debug Build Types===&lt;br /&gt;
By default, new projects will have the Debug build type. To compile the project with the Release or Minimum Size Release build types, there are two options:&lt;br /&gt;
*Make a secondary (or tertiary) build directory. (Recommended)&lt;br /&gt;
*Clean the current build directory and re-run CMake.&lt;br /&gt;
The different levels of build type correlate to usage of different C Flags. When cross-compiling, these C Flags are located in the &amp;lt;code&amp;gt;toolchain.&amp;lt;architecture&amp;gt;.cmake&amp;lt;/code&amp;gt; files located, by default, in &amp;lt;code&amp;gt;/opt/emac/5.X/&amp;lt;/code&amp;gt;, with ''X'' being the specific version of SDK. The following table will give a brief overview of the different build types.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;lt;table style=&amp;quot;border-style:double; border-width:2px; margin-top:-10%; margin-bottom:-3%;&amp;quot;&amp;gt;&amp;lt;tr style=&amp;quot;border-style:double; border-width:2px;&amp;quot;&amp;gt;&amp;lt;td&amp;gt;'''Name:'''&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;'''Type:'''&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;'''Debugging Features:'''&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;'''Description:'''&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;'''Optimization Level:'''&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;'''C Flags Used:'''&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tr style=&amp;quot;border-style:solid; border-width:2px;&amp;quot;&amp;gt;&amp;lt;td&amp;gt;Release&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Release&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;disabled&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Release targeted build optimized for best performance.&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-O2&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;CMAKE_C_FLAGS_RELEASE&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tr style=&amp;quot;border-style:solid; border-width:2px;&amp;quot;&amp;gt;&amp;lt;td&amp;gt;MinSizeRel&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Release&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;disabled&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Release targeted build with experimental optimizations. (Builds using this should be thoroughly tested.)&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-O3&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;CMAKE_C_FLAGS_MINSIZEREL&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tr style=&amp;quot;border-style:solid; border-width:2px;&amp;quot;&amp;gt;&amp;lt;td&amp;gt;Debug&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Debug&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;enabled&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;A standard debugging oriented build, optimized for improved debugging.&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-O0&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;CMAKE_C_FLAGS_DEBUG&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
If you wish to add any additional flags to a build type, they can be defined in the project's &amp;lt;code&amp;gt;CMakeList.txt&amp;lt;/code&amp;gt; file as shown in the code snippet below.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cmake&amp;quot;&amp;gt;&lt;br /&gt;
project(example)&lt;br /&gt;
&lt;br /&gt;
SET(MAKE_C_FLAGS_DEBUG &amp;quot;${CMAKE_C_FLAGS_DEBUG} -Wall -Wpedantic&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
# This will add the -Wall and -Wpedantic options to the existing debug build flags&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;!--{{warning | This is really useful information for any developer.  Knowing the level of optimization is insightful, so that should be included.  Knowing whether or not the build was stripped of debugging information is important if they ever intend to release binaries to the public (such as for updates) and to ensure small size and max speed.  Knowing what preprocessor defines are #def'd with a target is really useful when writing debugging code.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
I would put all this in a table like the example I made above (but accurate and complete).  The border-radius and shadows will need to be overridden to make it look right.  Can always use css or a template for this.&lt;br /&gt;
}}--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Method 1: Create separate build directory====&lt;br /&gt;
To create a Release build using the 1st (recommended) method, use the following steps. This method is recommended because it allows both the Debug and the Release executable to exist at the same time.&lt;br /&gt;
&amp;lt;cl&amp;gt;&lt;br /&gt;
1. In a terminal, navigate to the base directory of the project.&lt;br /&gt;
* Create a new release build directory&lt;br /&gt;
{{cli | username=developer | hostname=ldc | pwd=~/projects/hello_emac | mkdir hello_emac-build-arm-release }}&lt;br /&gt;
* Change directories into the newly created directory.&lt;br /&gt;
{{cli | username=developer | hostname=ldc | pwd=~/projects/hello_emac | cd hello_emac-build-arm-release }} &lt;br /&gt;
* Run &amp;lt;code&amp;gt;cmake&amp;lt;/code&amp;gt; using the target architecture.&lt;br /&gt;
{{cli | username=developer | hostname=ldc | pwd=~/projects/hello_emac/hello_emac-build-arm | 1 = cmake .. -DARCH:STRING=arm -DCMAKE_BUILD_TYPE:STRING=Release }}{{note | The string 'MinSizeRel' can be used in place of 'Release' for a potentially smaller executable}}&lt;br /&gt;
* Compile the code using &amp;lt;code&amp;gt;make&amp;lt;/code&amp;gt;.&lt;br /&gt;
{{cli | username=developer | hostname=ldc | pwd=~/projects/hello_emac/hello_emac-build-arm | make }} &lt;br /&gt;
&amp;lt;/cl&amp;gt;&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
====Method 2: Re-use build directory====&lt;br /&gt;
Another option for creating a release build is as follows:&lt;br /&gt;
&amp;lt;cl&amp;gt;&lt;br /&gt;
1. In a terminal, navigate to the build directory of the project.&lt;br /&gt;
* Clean the directory with &amp;lt;code&amp;gt;make&amp;lt;/code&amp;gt;&lt;br /&gt;
{{cli | username=developer | hostname=ldc | pwd=~/projects/hello_emac/hello_emac-build-arm | 1 = make clean}}&lt;br /&gt;
* Run &amp;lt;code&amp;gt;cmake&amp;lt;/code&amp;gt; using the target architecture.&lt;br /&gt;
{{cli | username=developer | hostname=ldc | pwd=~/projects/hello_emac/hello_emac-build-arm | 1 = cmake .. -DARCH:STRING=arm -DCMAKE_BUILD_TYPE:STRING=Release }}{{note | The string 'MinSizeRel' can be used in place of 'Release' for a potentially smaller executable}}&lt;br /&gt;
* Compile the code using &amp;lt;code&amp;gt;make&amp;lt;/code&amp;gt;.&lt;br /&gt;
{{cli | username=developer | hostname=ldc | pwd=~/projects/hello_emac/hello_emac-build-arm | make }} &lt;br /&gt;
&amp;lt;/cl&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Renaming the Target Executable===&lt;br /&gt;
To rename the executable, the &amp;lt;code&amp;gt;ADD_EXECUTABLE()&amp;lt;/code&amp;gt; function arguments must be changed. The first argument refers to the name of the executable, and the second refers to the source code file.&lt;br /&gt;
&lt;br /&gt;
To change the name of the executable from &amp;quot;main&amp;quot; to &amp;quot;new_name&amp;quot;, change the &amp;lt;code&amp;gt;ADD_EXECUTABLE()&amp;lt;/code&amp;gt; from the first code box to the second code box.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cmake&amp;quot;&amp;gt;&lt;br /&gt;
ADD_EXECUTABLE(main main.cpp)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cmake&amp;quot;&amp;gt;&lt;br /&gt;
ADD_EXECUTABLE(new_name main.cpp)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Adding Include Files===&lt;br /&gt;
To add an include file and implementation file (in this case, the &amp;lt;code&amp;gt;tools.cpp&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;tools.h&amp;lt;/code&amp;gt; in the &amp;lt;code&amp;gt;util&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;include&amp;lt;/code&amp;gt; directory, respectively) to the CMake project, changes will need to be made to the CMakeLists.txt file. Please refer to the code sample below.&lt;br /&gt;
&lt;br /&gt;
# The directory to be included must be specified by the &amp;lt;code&amp;gt;INCLUDE_DIRECTORIES()&amp;lt;/code&amp;gt; function. The variable &amp;lt;code&amp;gt;${PROJECT_SOURCE_DIR}&amp;lt;/code&amp;gt; refers to the base path of the project which is generally where this &amp;lt;code&amp;gt;README&amp;lt;/code&amp;gt; file is located.&lt;br /&gt;
# The &amp;lt;code&amp;gt;SOURCES&amp;lt;/code&amp;gt; must be set. This list of files should include all of the source files in the project.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cmake&amp;quot;&amp;gt;&lt;br /&gt;
INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}include)&lt;br /&gt;
&lt;br /&gt;
SET(SOURCES&lt;br /&gt;
     ${PROJECT_SOURCE_DIR}main.cpp&lt;br /&gt;
     ${PROJECT_SOURCE_DIR}util/tools.cpp&lt;br /&gt;
     )&lt;br /&gt;
SET(HEADERS&lt;br /&gt;
     ${PROJECT_SOURCE_DIR}include/tools.h&lt;br /&gt;
     )&lt;br /&gt;
&lt;br /&gt;
ADD_EXECUTABLE(main ${SOURCES} ${HEADERS})&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /******************************************   More Information   *****************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
{{:Templateimpl:moreinfo | initials=KY | title=Creating a New EMAC OE SDK Project with CMake | desc=Creating an EMAC OE SDK project for use with CMake | project=OE 5.0 }}&lt;br /&gt;
&amp;lt;!--{{:Templateimpl:whatnext | initials=KY | title=Creating a New EMAC OE SDK Project with CMake | desc=Creating an EMAC OE SDK project for use with CMake | project=OE 5.0 }}--&amp;gt;&lt;br /&gt;
* [[System_Log_In | System Log In]]&lt;br /&gt;
* [[Serial_Connections | Serial Connections ]]&lt;br /&gt;
* [[Network_Connections | Network Connections ]]&lt;br /&gt;
* [[System_Log_In | System Log In ]]&lt;br /&gt;
* [[Remote_Debugging_EMAC_OE_SDK_Projects_with_gdbserver | Remote Debugging EMAC OE SDK Projects with gdbserver ]]&lt;br /&gt;
* [[System_Logging | System Logging ]]&lt;/div&gt;</summary>
		<author><name>Mgloff</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.emacinc.com/index.php?title=Loading_JFFS2_Images_Onto_a_Board&amp;diff=5519</id>
		<title>Loading JFFS2 Images Onto a Board</title>
		<link rel="alternate" type="text/html" href="https://wiki.emacinc.com/index.php?title=Loading_JFFS2_Images_Onto_a_Board&amp;diff=5519"/>
		<updated>2018-06-05T16:23:27Z</updated>

		<summary type="html">&lt;p&gt;Mgloff: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{todo|SEOKWREV, held for FTP server update; (11.06.13-08:24-&amp;gt;MW+)(11.06.13-17:55-&amp;gt;MD+)(12.11.13-13:56-&amp;gt;MW+)(12.19.13-18:40-&amp;gt;MD+);(12.20.13-11:30-&amp;gt;KY+);(03.06.14-15:05-&amp;gt;BS-);(04.11.14-11:35-&amp;gt;BS+)|Michael Welling|project=oe 4,oe 5,mw,md,bs,SEOKWREV}}&lt;br /&gt;
&lt;br /&gt;
{{#seo:&lt;br /&gt;
|title=Loading JFFS2 Images Onto a Board&lt;br /&gt;
|titlemode=append&lt;br /&gt;
|keywords=JFFS2,U-Boot,TFTP Server&lt;br /&gt;
|description=The section provides links and useful information for performing JFFS2 programming using U-Boot and Redboot.&lt;br /&gt;
}}&lt;br /&gt;
== Background ==&lt;br /&gt;
&lt;br /&gt;
Journalling Flash File System version 2, or JFFS2, is a log-structured file system used on flash memory devices. JFFS2 images are typically created on a development PC and deployed to an embedded target using TFTP commands from the target's bootloader. Deployment requires both serial and Ethernet connections to the board along with a TFTP server set up on a development machine.&lt;br /&gt;
&lt;br /&gt;
For instructions on installing a TFTP server on a development PC:&lt;br /&gt;
[[Installing TFTP server]]&lt;br /&gt;
&lt;br /&gt;
For details on connecting to the serial port for an embedded target:&lt;br /&gt;
[[Serial Connections]]&lt;br /&gt;
&lt;br /&gt;
JFFS2 file systems are available for download on [ftp://ftp.emacinc.com EMAC's FTP site].&lt;br /&gt;
&lt;br /&gt;
For instructions on creating a JFFS2 file system image see the following page:&lt;br /&gt;
[[Creating JFFS2 Images]]&lt;br /&gt;
&lt;br /&gt;
== General Information ==&lt;br /&gt;
The section below provides links and useful information for performing JFFS2 programming using U-Boot and Redboot. The links provide pages with the generic procedures for programming EMAC modules based on the bootloader type.&lt;br /&gt;
&lt;br /&gt;
=== Using U-Boot ===&lt;br /&gt;
Refer to the following pages for instructions on accessing U-Boot on the serial console: &amp;lt;br /&amp;gt;&lt;br /&gt;
[[U-Boot Overview]]&amp;lt;br /&amp;gt;&lt;br /&gt;
[[Loading Images with U-Boot]]&lt;br /&gt;
&lt;br /&gt;
From the U-Boot prompt it is possible to set the target's IP address dynamically using DHCP:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
U-Boot&amp;gt; set autoload no&lt;br /&gt;
U-Boot&amp;gt; dhcp&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The target's IP can also be manually set using the &amp;lt;code&amp;gt;ipaddr&amp;lt;/code&amp;gt; environment variable as follows:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
U-Boot&amp;gt; set ipaddr 192.168.0.101&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Once the target IP is set, the TFTP server's IP address must be specified:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
U-Boot&amp;gt; set serverip 192.168.0.100&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The configuration of the bootloader environment can be checked at any time using the &amp;lt;code&amp;gt;printenv&amp;lt;/code&amp;gt; command. As described in [[Loading Images with U-Boot]], the JFFS2 image will then be loaded into SDRAM and programmed into flash. A full example for the SoM-9G45 will be provided below.&lt;br /&gt;
&lt;br /&gt;
== Full Example Using U-Boot (SoM-9G45) ==&lt;br /&gt;
This section provides a detailed example of loading a JFFS2 file system onto the SoM-9G45 and shows how U-Boot responds to the various commands when performed successfully.&lt;br /&gt;
 &lt;br /&gt;
 U-Boot 2009.06-rc1-svn1786 (Nov 28 2011 - 17:22:29) &lt;br /&gt;
 &lt;br /&gt;
 EMAC Inc. SOM-9M10/G45M &lt;br /&gt;
 &lt;br /&gt;
 I2C:   ready&lt;br /&gt;
 DRAM:  128 MB&lt;br /&gt;
 NAND:  256 MiB&lt;br /&gt;
 DataFlash:AT45DB321&lt;br /&gt;
 Nb pages:   8192&lt;br /&gt;
 Page Size:    528&lt;br /&gt;
 Size= 4325376 bytes&lt;br /&gt;
 Logical address: 0xC0000000&lt;br /&gt;
 Area 0: C0000000 to C00041FF (RO) Bootstrap&lt;br /&gt;
 Area 1: C0004200 to C00083FF      Environment&lt;br /&gt;
 Area 2: C0008400 to C0041FFF (RO) U-Boot&lt;br /&gt;
 Area 3: C0042000 to C0251FFF      Kernel&lt;br /&gt;
 Area 4: C0252000 to C041FFFF      FS&lt;br /&gt;
 In:    serial&lt;br /&gt;
 Out:   serial&lt;br /&gt;
 Err:   serial&lt;br /&gt;
 Net:   macb0&lt;br /&gt;
 macb0: Starting autonegotiation...&lt;br /&gt;
 macb0: Autonegotiation complete&lt;br /&gt;
 macb0: link up, 100Mbps full-duplex (lpa: 0xcde1)&lt;br /&gt;
 Hit any key to stop autoboot:  0 &lt;br /&gt;
 U-Boot&amp;gt; set autoload no &lt;br /&gt;
 U-Boot&amp;gt; dhcp&lt;br /&gt;
 macb0: link up, 100Mbps full-duplex (lpa: 0xcde1)&lt;br /&gt;
 BOOTP broadcast 1&lt;br /&gt;
 DHCP client bound to address 10.0.2.221&lt;br /&gt;
 U-Boot&amp;gt; set serverip 10.0.2.168&lt;br /&gt;
 U-Boot&amp;gt; tftp 0x74000000 som-9g45m-rootfs.jffs2&lt;br /&gt;
 macb0: link up, 100Mbps full-duplex (lpa: 0xcde1)&lt;br /&gt;
 Using macb0 device&lt;br /&gt;
 TFTP from server 10.0.2.168; our IP address is 10.0.2.221&lt;br /&gt;
 Filename 'som-9g45m-rootfs.jffs2'.&lt;br /&gt;
 Load address: 0x74000000&lt;br /&gt;
 Loading: ################################################################# &lt;br /&gt;
                                   ...&lt;br /&gt;
          ####################################################&lt;br /&gt;
 done&lt;br /&gt;
 Bytes transferred = 27473444 (1a33624 hex)&lt;br /&gt;
 U-Boot&amp;gt; nand erase&lt;br /&gt;
 &lt;br /&gt;
 NAND erase: device 0 whole chip&lt;br /&gt;
 Skipping bad block at  0x03320000                                            &lt;br /&gt;
 Skipping bad block at  0x079e0000                                            &lt;br /&gt;
 Skipping bad block at  0x085e0000                                            &lt;br /&gt;
 Erasing at 0xffe0000 -- 100% complete.&lt;br /&gt;
 OK&lt;br /&gt;
 U-Boot&amp;gt; nand write.jffs2 0x74000000 0x0 ${filesize}&lt;br /&gt;
 &lt;br /&gt;
 NAND write: device 0 offset 0x0, size 0x1a33624&lt;br /&gt;
 NAND write: Padding to page size... &lt;br /&gt;
 27473444 bytes written: OK&lt;br /&gt;
 U-Boot&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Quick Reference (By Target Type) ==&lt;br /&gt;
This section provides a quick reference for programming various targets with a JFFS2 image.&lt;br /&gt;
It is assumed that the Ethernet setup is performed as described above in the General Information section.&lt;br /&gt;
&lt;br /&gt;
=== SoM-9260M ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
U-Boot&amp;gt; tftp 0x20000000 som-9260m-rootfs.jffs2&lt;br /&gt;
U-Boot&amp;gt; protect off all&lt;br /&gt;
U-Boot&amp;gt; erase 0x10400000 0x11ffffff&lt;br /&gt;
U-Boot&amp;gt; cp.b 0x20000000 0x10400000 ${filesize}&lt;br /&gt;
# Erase the second bank for 64Mb modules&lt;br /&gt;
U-Boot&amp;gt; erase 0x12000000 0x13ffffff&lt;br /&gt;
# OE 4 - set filesystem read/write on first boot&lt;br /&gt;
U-Boot&amp;gt; setenv bootargs 'console=ttyS3,115200 root=/dev/mtdblock3 rootfstype=jffs2 rw'&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== SoM-9G20M ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
U-Boot&amp;gt; tftp 0x20000000 som-9g20m-rootfs.jffs2&lt;br /&gt;
U-Boot&amp;gt; nand erase&lt;br /&gt;
U-Boot&amp;gt; nand write.jffs2 0x20000000 0x0 ${filesize}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== SoM-9G45M ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
U-Boot&amp;gt; tftp 0x74000000 som-9g45m-rootfs.jffs2&lt;br /&gt;
U-Boot&amp;gt; nand erase&lt;br /&gt;
U-Boot&amp;gt; nand write.jffs2 0x74000000 0x0 ${filesize}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== SoM-9M10M ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
U-Boot&amp;gt; tftp 0x74000000 som-9m10m-rootfs.jffs2&lt;br /&gt;
U-Boot&amp;gt; nand erase&lt;br /&gt;
U-Boot&amp;gt; nand write.jffs2 0x74000000 0x0 ${filesize}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Mgloff</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.emacinc.com/index.php?title=Loading_JFFS2_Images_Onto_a_Board&amp;diff=5518</id>
		<title>Loading JFFS2 Images Onto a Board</title>
		<link rel="alternate" type="text/html" href="https://wiki.emacinc.com/index.php?title=Loading_JFFS2_Images_Onto_a_Board&amp;diff=5518"/>
		<updated>2018-06-01T18:47:23Z</updated>

		<summary type="html">&lt;p&gt;Mgloff: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{todo|SEOKWREV, held for FTP server update; (11.06.13-08:24-&amp;gt;MW+)(11.06.13-17:55-&amp;gt;MD+)(12.11.13-13:56-&amp;gt;MW+)(12.19.13-18:40-&amp;gt;MD+);(12.20.13-11:30-&amp;gt;KY+);(03.06.14-15:05-&amp;gt;BS-);(04.11.14-11:35-&amp;gt;BS+)|Michael Welling|project=oe 4,oe 5,mw,md,bs,SEOKWREV}}&lt;br /&gt;
&lt;br /&gt;
{{#seo:&lt;br /&gt;
|title=Loading JFFS2 Images Onto a Board&lt;br /&gt;
|titlemode=append&lt;br /&gt;
|keywords=JFFS2,U-Boot,TFTP Server&lt;br /&gt;
|description=The section provides links and useful information for performing JFFS2 programming using U-Boot and Redboot.&lt;br /&gt;
}}&lt;br /&gt;
== Background ==&lt;br /&gt;
&lt;br /&gt;
Journalling Flash File System version 2, or JFFS2, is a log-structured file system used on flash memory devices. JFFS2 images are typically created on a development PC and deployed to an embedded target using TFTP commands from the target's bootloader. Deployment requires both serial and Ethernet connections to the board along with a TFTP server set up on a development machine.&lt;br /&gt;
&lt;br /&gt;
For instructions on installing a TFTP server on a development PC:&lt;br /&gt;
[[Installing TFTP server]]&lt;br /&gt;
&lt;br /&gt;
For details on connecting to the serial port for an embedded target:&lt;br /&gt;
[[Serial Connections]]&lt;br /&gt;
&lt;br /&gt;
JFFS2 file systems are available for download on [ftp://ftp.emacinc.com EMAC's FTP site].&lt;br /&gt;
&lt;br /&gt;
For instructions on creating a JFFS2 file system image see the following page:&lt;br /&gt;
[[Creating JFFS2 Images]]&lt;br /&gt;
&lt;br /&gt;
== General Information ==&lt;br /&gt;
The section below provides links and useful information for performing JFFS2 programming using U-Boot and Redboot. The links provide pages with the generic procedures for programming EMAC modules based on the bootloader type.&lt;br /&gt;
&lt;br /&gt;
=== Using U-Boot ===&lt;br /&gt;
Refer to the following pages for instructions on accessing U-Boot on the serial console: &amp;lt;br /&amp;gt;&lt;br /&gt;
[[U-Boot Overview]]&amp;lt;br /&amp;gt;&lt;br /&gt;
[[Loading Images with U-Boot]]&lt;br /&gt;
&lt;br /&gt;
From the U-Boot prompt it is possible to set the target's IP address dynamically using DHCP:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
U-Boot&amp;gt; set autoload no&lt;br /&gt;
U-Boot&amp;gt; dhcp&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The target's IP can also be manually set using the &amp;lt;code&amp;gt;ipaddr&amp;lt;/code&amp;gt; environment variable as follows:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
U-Boot&amp;gt; set ipaddr 192.168.0.101&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Once the target IP is set, the TFTP server's IP address must be specified:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
U-Boot&amp;gt; set serverip 192.168.0.100&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The configuration of the bootloader environment can be checked at any time using the &amp;lt;code&amp;gt;printenv&amp;lt;/code&amp;gt; command. As described in [[Loading Images with U-Boot]], the JFFS2 image will then be loaded into SDRAM and programmed into flash. A full example for the SoM-9G45 will be provided below.&lt;br /&gt;
&lt;br /&gt;
== Full Example Using U-Boot (SoM-9G45) ==&lt;br /&gt;
This section provides a detailed example of loading a JFFS2 file system onto the SoM-9G45 and shows how U-Boot responds to the various commands when performed successfully.&lt;br /&gt;
 &lt;br /&gt;
 U-Boot 2009.06-rc1-svn1786 (Nov 28 2011 - 17:22:29) &lt;br /&gt;
 &lt;br /&gt;
 EMAC Inc. SOM-9M10/G45M &lt;br /&gt;
 &lt;br /&gt;
 I2C:   ready&lt;br /&gt;
 DRAM:  128 MB&lt;br /&gt;
 NAND:  256 MiB&lt;br /&gt;
 DataFlash:AT45DB321&lt;br /&gt;
 Nb pages:   8192&lt;br /&gt;
 Page Size:    528&lt;br /&gt;
 Size= 4325376 bytes&lt;br /&gt;
 Logical address: 0xC0000000&lt;br /&gt;
 Area 0: C0000000 to C00041FF (RO) Bootstrap&lt;br /&gt;
 Area 1: C0004200 to C00083FF      Environment&lt;br /&gt;
 Area 2: C0008400 to C0041FFF (RO) U-Boot&lt;br /&gt;
 Area 3: C0042000 to C0251FFF      Kernel&lt;br /&gt;
 Area 4: C0252000 to C041FFFF      FS&lt;br /&gt;
 In:    serial&lt;br /&gt;
 Out:   serial&lt;br /&gt;
 Err:   serial&lt;br /&gt;
 Net:   macb0&lt;br /&gt;
 macb0: Starting autonegotiation...&lt;br /&gt;
 macb0: Autonegotiation complete&lt;br /&gt;
 macb0: link up, 100Mbps full-duplex (lpa: 0xcde1)&lt;br /&gt;
 Hit any key to stop autoboot:  0 &lt;br /&gt;
 U-Boot&amp;gt; set autoload no &lt;br /&gt;
 U-Boot&amp;gt; dhcp&lt;br /&gt;
 macb0: link up, 100Mbps full-duplex (lpa: 0xcde1)&lt;br /&gt;
 BOOTP broadcast 1&lt;br /&gt;
 DHCP client bound to address 10.0.2.221&lt;br /&gt;
 U-Boot&amp;gt; set serverip 10.0.2.168&lt;br /&gt;
 U-Boot&amp;gt; tftp 0x74000000 som-9g45m-rootfs.jffs2&lt;br /&gt;
 macb0: link up, 100Mbps full-duplex (lpa: 0xcde1)&lt;br /&gt;
 Using macb0 device&lt;br /&gt;
 TFTP from server 10.0.2.168; our IP address is 10.0.2.221&lt;br /&gt;
 Filename 'som-9g45m-rootfs.jffs2'.&lt;br /&gt;
 Load address: 0x74000000&lt;br /&gt;
 Loading: ################################################################# &lt;br /&gt;
                                   ...&lt;br /&gt;
          ####################################################&lt;br /&gt;
 done&lt;br /&gt;
 Bytes transferred = 27473444 (1a33624 hex)&lt;br /&gt;
 U-Boot&amp;gt; nand erase&lt;br /&gt;
 &lt;br /&gt;
 NAND erase: device 0 whole chip&lt;br /&gt;
 Skipping bad block at  0x03320000                                            &lt;br /&gt;
 Skipping bad block at  0x079e0000                                            &lt;br /&gt;
 Skipping bad block at  0x085e0000                                            &lt;br /&gt;
 Erasing at 0xffe0000 -- 100% complete.&lt;br /&gt;
 OK&lt;br /&gt;
 U-Boot&amp;gt; nand write.jffs2 0x74000000 0x0 ${filesize}&lt;br /&gt;
 &lt;br /&gt;
 NAND write: device 0 offset 0x0, size 0x1a33624&lt;br /&gt;
 NAND write: Padding to page size... &lt;br /&gt;
 27473444 bytes written: OK&lt;br /&gt;
 U-Boot&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Quick Reference (By Target Type) ==&lt;br /&gt;
This section provides a quick reference for programming various targets with a JFFS2 image.&lt;br /&gt;
It is assumed that the Ethernet setup is performed as described above in the General Information section.&lt;br /&gt;
&lt;br /&gt;
=== SoM-9260M ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
U-Boot&amp;gt; tftp 0x20000000 som-9260m-rootfs.jffs2&lt;br /&gt;
U-Boot&amp;gt; protect off all&lt;br /&gt;
U-Boot&amp;gt; erase 0x10400000 0x11ffffff&lt;br /&gt;
U-Boot&amp;gt; cp.b 0x20000000 0x10400000 ${filesize}&lt;br /&gt;
# Erase the second bank for 64Mb modules&lt;br /&gt;
U-Boot&amp;gt; erase 0x12000000 0x13ffffff &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== SoM-9G20M ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
U-Boot&amp;gt; tftp 0x20000000 som-9g20m-rootfs.jffs2&lt;br /&gt;
U-Boot&amp;gt; nand erase&lt;br /&gt;
U-Boot&amp;gt; nand write.jffs2 0x20000000 0x0 ${filesize}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== SoM-9G45M ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
U-Boot&amp;gt; tftp 0x74000000 som-9g45m-rootfs.jffs2&lt;br /&gt;
U-Boot&amp;gt; nand erase&lt;br /&gt;
U-Boot&amp;gt; nand write.jffs2 0x74000000 0x0 ${filesize}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== SoM-9M10M ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
U-Boot&amp;gt; tftp 0x74000000 som-9m10m-rootfs.jffs2&lt;br /&gt;
U-Boot&amp;gt; nand erase&lt;br /&gt;
U-Boot&amp;gt; nand write.jffs2 0x74000000 0x0 ${filesize}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Mgloff</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.emacinc.com/index.php?title=Product_wiki&amp;diff=5479</id>
		<title>Product wiki</title>
		<link rel="alternate" type="text/html" href="https://wiki.emacinc.com/index.php?title=Product_wiki&amp;diff=5479"/>
		<updated>2018-04-23T16:13:04Z</updated>

		<summary type="html">&lt;p&gt;Mgloff: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{todo| Review (11.19.2014-20:52-&amp;gt;MD+)(11.19.2014-13:19-&amp;gt;MD+)(09.04.2014-11:30-&amp;gt;MD+)(11.18.2015-17:10-&amp;gt;MD+)|Mike Dean| project=OE 5,MD }}&lt;br /&gt;
__NOTOC__&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /*****************************************  Navigation Links Table ***************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
{{:Template:Navpgtable | initials={{{initials}}} | title=EMAC Support Wiki | desc={{{desc}}} | project=OE 5 }}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /************************************************  How-To  ***********************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
{{:Templateimpl:navtableentry | title=Getting Started }}&lt;br /&gt;
&lt;br /&gt;
{{:Templateimpl:Navti | [[Getting_Started_with_the_EMAC_OE_SDK | With the EMAC OE SDK]] }}&lt;br /&gt;
{{:Templateimpl:Navti | [[Getting_Started_With_Qt_Creator | With Qt Creator]] }}&lt;br /&gt;
{{:Templateimpl:Navti | [[Quick_Reference | Quick Reference]] }}&lt;br /&gt;
{{:Templateimpl:Navtii | [[OE_50_Getting_Started | More Getting Started Guides]] }}&lt;br /&gt;
&lt;br /&gt;
{{:Templateimpl:navtend}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /************************************************  How-To  ***********************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
{{:Templateimpl:navtableentry | title=How-To }}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{:Templateimpl:Navti | [[Opkg | Work with the EMAC OE Package Manager ]] }}&lt;br /&gt;
{{:Templateimpl:Navti | [[Serial_Connections | Establishing a Serial Connection ]] }}&lt;br /&gt;
{{:Templateimpl:Navti | [[Network_Connections | Connecting to a Network ]] }}&lt;br /&gt;
{{:Templateimpl:Navti | [[System_Log_In | How to Log In to an EMAC OE Linux System ]] }}&lt;br /&gt;
{{:Templateimpl:Navti | [[Installing_EMAC_OE_5.0_SDK | Install the SDK ]] }}&lt;br /&gt;
{{:Templateimpl:Navtii | [[OE_50_How_To | More How To Pages]] }}&lt;br /&gt;
&lt;br /&gt;
{{:Templateimpl:navtend}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /************************************************  New Row  ***********************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{:Templateimpl:navtablenewrow}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /********************************************  EMAC Linux OE  ********************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
{{:Templateimpl:navtableentry | title=EMAC Linux OE }}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{:Templateimpl:Navti | [[EMAC_OpenEmbedded_Fact_Sheet | Information about EMAC OE Linux ]] }}&lt;br /&gt;
{{:Templateimpl:Navti | [[OE:Versions | EMAC OE Linux Versions ]] }}&lt;br /&gt;
{{:Templateimpl:Navti | [[OE50:Packages | What's New ]] }}&lt;br /&gt;
{{:Templateimpl:Navtii | [[OE_50_EMAC_Linux | More On EMAC OE Linux]] }}&lt;br /&gt;
&lt;br /&gt;
{{:Templateimpl:navtend}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /********************************************  EMAC Hardware  ********************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
{{:Templateimpl:navtableentry | title=EMAC Hardware }}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{:Templateimpl:Navti | [http://www.emacinc.com/products/system_on_module System on Module (SoM)] }}&lt;br /&gt;
{{:Templateimpl:Navti | [http://www.emacinc.com/products/panel_pcs_and_lcds Panel PC (PPC)] }}&lt;br /&gt;
{{:Templateimpl:Navti | [http://www.emacinc.com/products/pc_compatible_sbcs Single Board Computer (SBC)] }}&lt;br /&gt;
{{:Templateimpl:Navti | [http://www.emacinc.com/products/embedded_servers Server In a Box (SIB)] }}&lt;br /&gt;
{{:Templateimpl:Navtii | [[EMAC_HW | More EMAC Hardware]] }}&lt;br /&gt;
&lt;br /&gt;
{{:Templateimpl:navtend}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /***************************************  End Navigation Links Table *************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
{{:Templateimpl:navtableend}}&lt;/div&gt;</summary>
		<author><name>Mgloff</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.emacinc.com/index.php?title=Installing_EMAC_OE_5.0_SDK&amp;diff=5478</id>
		<title>Installing EMAC OE 5.0 SDK</title>
		<link rel="alternate" type="text/html" href="https://wiki.emacinc.com/index.php?title=Installing_EMAC_OE_5.0_SDK&amp;diff=5478"/>
		<updated>2018-04-23T16:10:44Z</updated>

		<summary type="html">&lt;p&gt;Mgloff: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Prerequisites==&lt;br /&gt;
If you are installing the SDK using the ADT Installer (Automatic Install), dependencies will be automatically installed for the supported distributions: Debian/Ubuntu, Fedora, CentOS, openSUSE. EMAC also provides a [ftp://ftp.emacinc.com/EMAC_Linux/Virtual_LDCs/EMAC_Virtual_LDC.ova pre-configured virtual machine image.]&lt;br /&gt;
{{note | Currently the version of Qt Creator installed during the automatic installation does not work on Debian 8}} &lt;br /&gt;
&lt;br /&gt;
If you are installing the SDK manually or using a non-supported distribution, you will have to install the dependencies manually.&lt;br /&gt;
==Procedure (Automatic Install)==&lt;br /&gt;
&amp;lt;cl&amp;gt;&lt;br /&gt;
1. Download the ADT Installer. (Right click, save link as)&lt;br /&gt;
 * [ftp://ftp.emacinc.com/EMAC_Linux/SDK/emac_adt_installer EMAC ADT Installer].&lt;br /&gt;
&lt;br /&gt;
* Change to the directory where the ADT Installer was downloaded from the command line:&lt;br /&gt;
{{cli | username=developer | hostname=ldc |cd ~/Downloads }}&lt;br /&gt;
&lt;br /&gt;
* Make the file executable:&lt;br /&gt;
{{cli | username=developer | hostname=ldc | chmod +x emac_adt_installer }}&lt;br /&gt;
&lt;br /&gt;
* Run ADT Installer script:&lt;br /&gt;
{{cli | username=developer | hostname=ldc |./emac_adt_installer }}&lt;br /&gt;
The installer will start.&lt;br /&gt;
&lt;br /&gt;
* Watch for errors:&lt;br /&gt;
{{clo}}#########################################################################&amp;lt;br /&amp;gt;# Met Errors when installing EMAC ADT! Please check log file for details.&amp;lt;br /&amp;gt;#########################################################################&amp;lt;br /&amp;gt;{{clos}}&lt;br /&gt;
&lt;br /&gt;
* Enter the development user's password if prompted. Allow the installer to install dependencies.&lt;br /&gt;
&lt;br /&gt;
* Enter the number for your boards architecture.&lt;br /&gt;
{{clo}}&lt;br /&gt;
Please enter the target architecture:&amp;lt;br /&amp;gt;&lt;br /&gt;
1. Arm&amp;lt;br /&amp;gt;&lt;br /&gt;
2. x86&amp;lt;br /&amp;gt;&lt;br /&gt;
board: &amp;lt;br /&amp;gt;&lt;br /&gt;
{{clos}}&lt;br /&gt;
&lt;br /&gt;
* The ADT Installer will then display what is to be installed. You may now choose to exit the installation, or continue if the displayed information is correct.&lt;br /&gt;
&lt;br /&gt;
* Once the installation of the sdk completes, the ADT Installer will ask whether or not to install Qt Creator.&lt;br /&gt;
&lt;br /&gt;
{{clo}}&lt;br /&gt;
&lt;br /&gt;
Would you like to install Qt Creator? [y/N]?&lt;br /&gt;
{{clos}}&lt;br /&gt;
 * Qt Creator is the IDE that EMAC provides with our SDK to allow users to easily cross compile projects and upload them to their boards.&lt;br /&gt;
 * If you chose to install Qt creator, the installer will then ask you whether or not you would like to place the icon on the desktop.&lt;br /&gt;
&lt;br /&gt;
* If the installation finishes, status text will appear:{{clo}}#############################################################&amp;lt;br /&amp;gt;# EMAC ADT has been successfully installed.&amp;lt;br /&amp;gt;#############################################################&amp;lt;br /&amp;gt; {{clos}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/cl&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Procedure (Manual Install)==&lt;br /&gt;
&amp;lt;cl&amp;gt;&lt;br /&gt;
1. Download the SDK. The latest version can be found on the EMAC FTP site. Download the SDK that matches the architecture of your target system. (Right click, save link as)&lt;br /&gt;
&lt;br /&gt;
 * SDK for x86: [ftp://ftp.emacinc.com/EMAC_Linux/SDK/emac-x86-toolchain.sh emac-x86-toolchain.sh]&lt;br /&gt;
 * SDK for ARM: [ftp://ftp.emacinc.com/EMAC_Linux/SDK/emac-arm-toolchain.sh emac-arm-toolchain.sh]&lt;br /&gt;
&lt;br /&gt;
* Change to the directory where the SDK was downloaded from the command line:&lt;br /&gt;
{{cli | username=developer | hostname=ldc |cd ~/Downloads }}&lt;br /&gt;
* Run SDK installer script:&lt;br /&gt;
{{cli | username=developer | hostname=ldc |./emac-ARCH-toolchain.sh }}&lt;br /&gt;
The installer will start. It is recommended to select the default target directory for the SDK: &amp;lt;code&amp;gt;/opt/emac/5.X&amp;lt;/code&amp;gt;&lt;br /&gt;
* Press enter to proceed.&lt;br /&gt;
* Enter your password if prompted.&lt;br /&gt;
* Status text will appear:&lt;br /&gt;
{{clo}}&lt;br /&gt;
Extracting SDK...done&amp;lt;br /&amp;gt;&lt;br /&gt;
Setting it up...done&amp;lt;br /&amp;gt;&lt;br /&gt;
SDK has been successfully set up and is ready to be used.&amp;lt;br /&amp;gt;&lt;br /&gt;
{{clos}}&lt;br /&gt;
&amp;lt;/cl&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Next Steps ==&lt;br /&gt;
&lt;br /&gt;
* [[Getting_Started_with_the_EMAC_OE_SDK | Getting Started with the EMAC OE SDK ]]&lt;br /&gt;
* [[Getting_Started_With_Qt_Creator |Getting Started With Qt Creator]]&lt;/div&gt;</summary>
		<author><name>Mgloff</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.emacinc.com/index.php?title=Loading_Linux_Images_to_a_Compact_Flash_Disk&amp;diff=5477</id>
		<title>Loading Linux Images to a Compact Flash Disk</title>
		<link rel="alternate" type="text/html" href="https://wiki.emacinc.com/index.php?title=Loading_Linux_Images_to_a_Compact_Flash_Disk&amp;diff=5477"/>
		<updated>2018-03-05T20:33:58Z</updated>

		<summary type="html">&lt;p&gt;Mgloff: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{#seo:&lt;br /&gt;
|title=Loading Linux Images to a Compact Flash Disk&lt;br /&gt;
|titlemode=append&lt;br /&gt;
|keywords=Compact Flash,Linux Image,Firmware Image&lt;br /&gt;
|description=When changing firmware images or creating custom firmware images for your Compact Flash-based machine, it is necessary to perform a few steps to load the firmware image onto the CF card.&lt;br /&gt;
}}&lt;br /&gt;
When changing firmware images or creating custom firmware images for your Compact Flash-based machine, it is necessary to perform a few steps to load the firmware image onto the CF card.&lt;br /&gt;
__TOC__&lt;br /&gt;
==Necessary Tools==&lt;br /&gt;
&lt;br /&gt;
To perform this procedure, the following items are required:&lt;br /&gt;
&lt;br /&gt;
* The Compact Flash card to hold the firmware.&lt;br /&gt;
* A Compact Flash card reader attached to a computer.&lt;br /&gt;
* The filesystem tar.&lt;br /&gt;
* A fully functional Linux desktop.&lt;br /&gt;
* Linux tools installed: &amp;lt;code&amp;gt;tar&amp;lt;/code&amp;gt;, and either &amp;lt;code&amp;gt;gzip&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;bzip2&amp;lt;/code&amp;gt; (depending on the image).&lt;br /&gt;
* The EMAC [ftp://ftp.emacinc.com/EMAC_Linux/SDK/Archive/Linux/put-image.tar.gz put-image] package which provides the &amp;lt;code&amp;gt;put-image&amp;lt;/code&amp;gt; script.  The &amp;lt;code&amp;gt;README.TXT&amp;lt;/code&amp;gt; file in the package details the steps needed to install the script properly.&lt;br /&gt;
&lt;br /&gt;
Unpack the put-image tar after downloading:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ tar zxvf ~/Downloads/put-image.tar.gz&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{mbox | type=warning | text= '''WARNING''': Performing the following procedure incorrectly can cause a catastrophic loss of data.  The individual steps should be carefully studied prior to attempting the procedure for the first time.&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt; EMAC cannot be responsible for the loss of data which may result from following this procedure incorrectly. EMAC strongly recommends having a current backup of the data on the development computer before attempting this procedure.}}&lt;br /&gt;
&lt;br /&gt;
==Procedure==&lt;br /&gt;
&lt;br /&gt;
Perform the following steps to load the firmware onto the Compact Flash card:&lt;br /&gt;
&lt;br /&gt;
* Insert the Compact Flash card into the card reader.&lt;br /&gt;
* Navigate (from within the shell) to the directory which contains the firmware image to be used.&lt;br /&gt;
* Determine where the Compact Flash card was mounted.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ dmesg | tail -n 10&lt;br /&gt;
[23236.042944] sdc: detected capacity change from 4110188544 to 0&lt;br /&gt;
[23243.783467] sd 12:0:0:0: [sdc] 8027712 512-byte logical blocks: (4.11 GB/3.82 GiB)&lt;br /&gt;
[23243.785199] sd 12:0:0:0: [sdc] No Caching mode page present&lt;br /&gt;
[23243.785204] sd 12:0:0:0: [sdc] Assuming drive cache: write through&lt;br /&gt;
[23243.787314] sd 12:0:0:0: [sdc] No Caching mode page present&lt;br /&gt;
[23243.787326] sd 12:0:0:0: [sdc] Assuming drive cache: write through&lt;br /&gt;
[23243.790625]  sdc: sdc1&lt;br /&gt;
[23244.290093] kjournald starting.  Commit interval 5 seconds&lt;br /&gt;
[23244.293646] EXT3-fs (sdc1): using internal journal&lt;br /&gt;
[23244.293651] EXT3-fs (sdc1): mounted filesystem with ordered data mode&lt;br /&gt;
developer@ldc:~$&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The output of the &amp;lt;code&amp;gt;dmesg&amp;lt;/code&amp;gt; command shows that the root device node for the Compact Flash card in this case is &amp;lt;code&amp;gt;sdc&amp;lt;/code&amp;gt;, and that the only partition found is &amp;lt;code&amp;gt;sdc1&amp;lt;/code&amp;gt;.  Inspect the output shown above to see the particular device node on the development PC where the Compact Flash card is mounted. This will be different depending on the configuration of the development PC. The &amp;lt;code&amp;gt;/dev/&amp;lt;/code&amp;gt; prefix will go before the device name, but is not shown in the output of &amp;lt;code&amp;gt;dmesg&amp;lt;/code&amp;gt;. The device node will start with either &amp;lt;code&amp;gt;sd&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;hd&amp;lt;/code&amp;gt;.  The third letter will specify which of these devices is assigned to the CF card.&lt;br /&gt;
&lt;br /&gt;
* At this point, it is wise to double check that device node is actually the CF card and not a hard drive in the system. Specifying the wrong device node could cause a complete loss of data on a hard drive.  &amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt; Continuing with &amp;lt;code&amp;gt;/dev/sdc1&amp;lt;/code&amp;gt; as the example device node, type the following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ mount | grep sdc1&lt;br /&gt;
/dev/sdc1 on /media/EMAC-OE type ext3 (rw,nosuid,nodev,uhelper=udisks)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This shows that the device node, &amp;lt;code&amp;gt;/dev/sdc1&amp;lt;/code&amp;gt;, is in fact the Compact Flash card.  This is because:&lt;br /&gt;
* It is not mounted on one of the standard Linux filesystem mountpoints, such as &amp;lt;code&amp;gt;/&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;/boot&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;/usr&amp;lt;/code&amp;gt;, or &amp;lt;code&amp;gt;/home&amp;lt;/code&amp;gt;.&lt;br /&gt;
* It '''is''' mounted in the &amp;lt;code&amp;gt;/media&amp;lt;/code&amp;gt; directory, where it is expected.  It may alternatively get mounted in &amp;lt;code&amp;gt;/mnt&amp;lt;/code&amp;gt;, depending upon the configuration of the Linux distribution in use.&lt;br /&gt;
&lt;br /&gt;
{{mbox | type=notice | text='''NOTE''': Not all Linux distributions will automatically mount the CF card when it is inserted into the card reader. The CF card must first be mounted in order to be accessible to the operating system. See [http://www.gnu.org/software/libc/manual/html_node/Mount_002dUnmount_002dRemount.html http://www.gnu.org/software/libc/manual/html_node/Mount_002dUnmount_002dRemount.html] for more information about mounting filesystems.}}&lt;br /&gt;
&lt;br /&gt;
* Use &amp;lt;code&amp;gt;fdisk -l&amp;lt;/code&amp;gt; to inspect the device node. Use &amp;lt;code&amp;gt;sudo&amp;lt;/code&amp;gt; with &amp;lt;code&amp;gt;fdisk&amp;lt;/code&amp;gt; to gain the required &amp;lt;code&amp;gt;root&amp;lt;/code&amp;gt; privileges to run &amp;lt;code&amp;gt;fdisk&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ sudo fdisk -l /dev/sdc&lt;br /&gt;
Disk /dev/sdc: 4009 MB, 4009549824 bytes&lt;br /&gt;
77 heads, 56 sectors/track, 1816 cylinders, total 7831152 sectors&lt;br /&gt;
Units = sectors of 1 * 512 = 512 bytes&lt;br /&gt;
Sector size (logical/physical): 512 bytes / 512 bytes&lt;br /&gt;
I/O size (minimum/optimal): 512 bytes / 512 bytes&lt;br /&gt;
Disk identifier: 0x00090707 &lt;br /&gt;
  &lt;br /&gt;
 Device Boot      Start         End      Blocks   Id  System&lt;br /&gt;
/dev/sdc1              62     7831151     3915545   83  Linux&lt;br /&gt;
developer@ldc:~$&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* As can be seen from the output of the &amp;lt;code&amp;gt;fdisk -l&amp;lt;/code&amp;gt; command above, the disk is 4009 MB in size, which corresponds with the size of the 4 GB Compact Flash being used in this example.&lt;br /&gt;
&lt;br /&gt;
* The device to specify for the target boot argument must also be determined prior to installing the image onto the Compact Flash card. Images obtained from EMAC will contain a text file that specifies what boot device node to use. For a custom image, use the &amp;lt;code&amp;gt;fdisk -l&amp;lt;/code&amp;gt; command on the target device to determine the boot device. In this example, the target hardware specifies ''/dev/hdc'' for the boot device.&lt;br /&gt;
&lt;br /&gt;
* Now, run the ''put-image'' script as below. &lt;br /&gt;
** The --target option specifies where the card is mounted.&lt;br /&gt;
** The --boot option specifies the target boot argument.&lt;br /&gt;
** The last option is the file name of the compressed target root filesystem.&lt;br /&gt;
&lt;br /&gt;
After completion, the ''put-image'' script will output a message indicating success or failure.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ /path/to/put-image --target=/dev/sdc --boot=/dev/sda emac-firmware-image.tar.gz&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* The ''put-image'' script should automatically unmount the Compact Flash card after the process completes. It is best to check that the Compact Flash card is actually unmounted before unplugging it. Using the ''/dev/sdc1'' example from above, type the following command.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ mount | grep sdc1&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* If the command does not return anything, the Compact Flash card is not mounted and can be removed and inserted into the target device. However, if the command returns something similar to the following listing, the card will need to be unmounted manually.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
/dev/sdc1 on /media/EMAC-OE type ext3 (rw,nosuid,nodev,uhelper=udisks)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* To unmount the Compact Flash card manually, run the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ umount /dev/sdc1&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
&lt;br /&gt;
* [[EMAC_OE_Boot_Process_Customization|Linux Boot Process Customization]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Filesystems]]&lt;/div&gt;</summary>
		<author><name>Mgloff</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.emacinc.com/index.php?title=Loading_Linux_Images_to_a_Compact_Flash_Disk&amp;diff=5476</id>
		<title>Loading Linux Images to a Compact Flash Disk</title>
		<link rel="alternate" type="text/html" href="https://wiki.emacinc.com/index.php?title=Loading_Linux_Images_to_a_Compact_Flash_Disk&amp;diff=5476"/>
		<updated>2018-03-05T20:29:11Z</updated>

		<summary type="html">&lt;p&gt;Mgloff: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{#seo:&lt;br /&gt;
|title=Loading Linux Images to a Compact Flash Disk&lt;br /&gt;
|titlemode=append&lt;br /&gt;
|keywords=Compact Flash,Linux Image,Firmware Image&lt;br /&gt;
|description=When changing firmware images or creating custom firmware images for your Compact Flash-based machine, it is necessary to perform a few steps to load the firmware image onto the CF card.&lt;br /&gt;
}}&lt;br /&gt;
When changing firmware images or creating custom firmware images for your Compact Flash-based machine, it is necessary to perform a few steps to load the firmware image onto the CF card.&lt;br /&gt;
__TOC__&lt;br /&gt;
==Necessary Tools==&lt;br /&gt;
&lt;br /&gt;
To perform this procedure, the following items are required:&lt;br /&gt;
&lt;br /&gt;
* The Compact Flash card to hold the firmware.&lt;br /&gt;
* A Compact Flash card reader attached to a computer.&lt;br /&gt;
* The filesystem tar.&lt;br /&gt;
* A fully functional Linux desktop.&lt;br /&gt;
* Linux tools installed: &amp;lt;code&amp;gt;tar&amp;lt;/code&amp;gt;, and either &amp;lt;code&amp;gt;gzip&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;bzip2&amp;lt;/code&amp;gt; (depending on the image).&lt;br /&gt;
* The EMAC [ftp://ftp.emacinc.com/EMAC_Linux/SDK/Archive/Linux/put-image.tar.gz| put-image] package which provides the &amp;lt;code&amp;gt;put-image&amp;lt;/code&amp;gt; script.  The &amp;lt;code&amp;gt;README.TXT&amp;lt;/code&amp;gt; file in the package details the steps needed to install the script properly.&lt;br /&gt;
&lt;br /&gt;
Unpack the put-image tar after downloading:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ tar zxvf ~/Downloads/put-image.tar.gz&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{mbox | type=warning | text= '''WARNING''': Performing the following procedure incorrectly can cause a catastrophic loss of data.  The individual steps should be carefully studied prior to attempting the procedure for the first time.&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt; EMAC cannot be responsible for the loss of data which may result from following this procedure incorrectly. EMAC strongly recommends having a current backup of the data on the development computer before attempting this procedure.}}&lt;br /&gt;
&lt;br /&gt;
==Procedure==&lt;br /&gt;
&lt;br /&gt;
Perform the following steps to load the firmware onto the Compact Flash card:&lt;br /&gt;
&lt;br /&gt;
* Insert the Compact Flash card into the card reader.&lt;br /&gt;
* Navigate (from within the shell) to the directory which contains the firmware image to be used.&lt;br /&gt;
* Determine where the Compact Flash card was mounted.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ dmesg | tail -n 10&lt;br /&gt;
[23236.042944] sdc: detected capacity change from 4110188544 to 0&lt;br /&gt;
[23243.783467] sd 12:0:0:0: [sdc] 8027712 512-byte logical blocks: (4.11 GB/3.82 GiB)&lt;br /&gt;
[23243.785199] sd 12:0:0:0: [sdc] No Caching mode page present&lt;br /&gt;
[23243.785204] sd 12:0:0:0: [sdc] Assuming drive cache: write through&lt;br /&gt;
[23243.787314] sd 12:0:0:0: [sdc] No Caching mode page present&lt;br /&gt;
[23243.787326] sd 12:0:0:0: [sdc] Assuming drive cache: write through&lt;br /&gt;
[23243.790625]  sdc: sdc1&lt;br /&gt;
[23244.290093] kjournald starting.  Commit interval 5 seconds&lt;br /&gt;
[23244.293646] EXT3-fs (sdc1): using internal journal&lt;br /&gt;
[23244.293651] EXT3-fs (sdc1): mounted filesystem with ordered data mode&lt;br /&gt;
developer@ldc:~$&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The output of the &amp;lt;code&amp;gt;dmesg&amp;lt;/code&amp;gt; command shows that the root device node for the Compact Flash card in this case is &amp;lt;code&amp;gt;sdc&amp;lt;/code&amp;gt;, and that the only partition found is &amp;lt;code&amp;gt;sdc1&amp;lt;/code&amp;gt;.  Inspect the output shown above to see the particular device node on the development PC where the Compact Flash card is mounted. This will be different depending on the configuration of the development PC. The &amp;lt;code&amp;gt;/dev/&amp;lt;/code&amp;gt; prefix will go before the device name, but is not shown in the output of &amp;lt;code&amp;gt;dmesg&amp;lt;/code&amp;gt;. The device node will start with either &amp;lt;code&amp;gt;sd&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;hd&amp;lt;/code&amp;gt;.  The third letter will specify which of these devices is assigned to the CF card.&lt;br /&gt;
&lt;br /&gt;
* At this point, it is wise to double check that device node is actually the CF card and not a hard drive in the system. Specifying the wrong device node could cause a complete loss of data on a hard drive.  &amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt; Continuing with &amp;lt;code&amp;gt;/dev/sdc1&amp;lt;/code&amp;gt; as the example device node, type the following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ mount | grep sdc1&lt;br /&gt;
/dev/sdc1 on /media/EMAC-OE type ext3 (rw,nosuid,nodev,uhelper=udisks)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This shows that the device node, &amp;lt;code&amp;gt;/dev/sdc1&amp;lt;/code&amp;gt;, is in fact the Compact Flash card.  This is because:&lt;br /&gt;
* It is not mounted on one of the standard Linux filesystem mountpoints, such as &amp;lt;code&amp;gt;/&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;/boot&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;/usr&amp;lt;/code&amp;gt;, or &amp;lt;code&amp;gt;/home&amp;lt;/code&amp;gt;.&lt;br /&gt;
* It '''is''' mounted in the &amp;lt;code&amp;gt;/media&amp;lt;/code&amp;gt; directory, where it is expected.  It may alternatively get mounted in &amp;lt;code&amp;gt;/mnt&amp;lt;/code&amp;gt;, depending upon the configuration of the Linux distribution in use.&lt;br /&gt;
&lt;br /&gt;
{{mbox | type=notice | text='''NOTE''': Not all Linux distributions will automatically mount the CF card when it is inserted into the card reader. The CF card must first be mounted in order to be accessible to the operating system. See [http://www.gnu.org/software/libc/manual/html_node/Mount_002dUnmount_002dRemount.html http://www.gnu.org/software/libc/manual/html_node/Mount_002dUnmount_002dRemount.html] for more information about mounting filesystems.}}&lt;br /&gt;
&lt;br /&gt;
* Use &amp;lt;code&amp;gt;fdisk -l&amp;lt;/code&amp;gt; to inspect the device node. Use &amp;lt;code&amp;gt;sudo&amp;lt;/code&amp;gt; with &amp;lt;code&amp;gt;fdisk&amp;lt;/code&amp;gt; to gain the required &amp;lt;code&amp;gt;root&amp;lt;/code&amp;gt; privileges to run &amp;lt;code&amp;gt;fdisk&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ sudo fdisk -l /dev/sdc&lt;br /&gt;
Disk /dev/sdc: 4009 MB, 4009549824 bytes&lt;br /&gt;
77 heads, 56 sectors/track, 1816 cylinders, total 7831152 sectors&lt;br /&gt;
Units = sectors of 1 * 512 = 512 bytes&lt;br /&gt;
Sector size (logical/physical): 512 bytes / 512 bytes&lt;br /&gt;
I/O size (minimum/optimal): 512 bytes / 512 bytes&lt;br /&gt;
Disk identifier: 0x00090707 &lt;br /&gt;
  &lt;br /&gt;
 Device Boot      Start         End      Blocks   Id  System&lt;br /&gt;
/dev/sdc1              62     7831151     3915545   83  Linux&lt;br /&gt;
developer@ldc:~$&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* As can be seen from the output of the &amp;lt;code&amp;gt;fdisk -l&amp;lt;/code&amp;gt; command above, the disk is 4009 MB in size, which corresponds with the size of the 4 GB Compact Flash being used in this example.&lt;br /&gt;
&lt;br /&gt;
* The device to specify for the target boot argument must also be determined prior to installing the image onto the Compact Flash card. Images obtained from EMAC will contain a text file that specifies what boot device node to use. For a custom image, use the &amp;lt;code&amp;gt;fdisk -l&amp;lt;/code&amp;gt; command on the target device to determine the boot device. In this example, the target hardware specifies ''/dev/hdc'' for the boot device.&lt;br /&gt;
&lt;br /&gt;
* Now, run the ''put-image'' script as below. &lt;br /&gt;
** The --target option specifies where the card is mounted.&lt;br /&gt;
** The --boot option specifies the target boot argument.&lt;br /&gt;
** The last option is the file name of the compressed target root filesystem.&lt;br /&gt;
&lt;br /&gt;
After completion, the ''put-image'' script will output a message indicating success or failure.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ /path/to/put-image --target=/dev/sdc --boot=/dev/sda emac-firmware-image.tar.gz&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* The ''put-image'' script should automatically unmount the Compact Flash card after the process completes. It is best to check that the Compact Flash card is actually unmounted before unplugging it. Using the ''/dev/sdc1'' example from above, type the following command.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ mount | grep sdc1&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* If the command does not return anything, the Compact Flash card is not mounted and can be removed and inserted into the target device. However, if the command returns something similar to the following listing, the card will need to be unmounted manually.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
/dev/sdc1 on /media/EMAC-OE type ext3 (rw,nosuid,nodev,uhelper=udisks)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* To unmount the Compact Flash card manually, run the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
developer@ldc:~$ umount /dev/sdc1&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
&lt;br /&gt;
* [[EMAC_OE_Boot_Process_Customization|Linux Boot Process Customization]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Filesystems]]&lt;/div&gt;</summary>
		<author><name>Mgloff</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.emacinc.com/index.php?title=Xenomai_RTSerial&amp;diff=5475</id>
		<title>Xenomai RTSerial</title>
		<link rel="alternate" type="text/html" href="https://wiki.emacinc.com/index.php?title=Xenomai_RTSerial&amp;diff=5475"/>
		<updated>2018-02-06T22:16:16Z</updated>

		<summary type="html">&lt;p&gt;Mgloff: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{todo| NotStarted (03.03.2016-13:01-&amp;gt;MW+)|Michael Welling| project=OE 5.0,MW,NotStarted }}&lt;br /&gt;
{{#seo:&lt;br /&gt;
|title=Xenomai RTSerial&lt;br /&gt;
|titlemode=append&lt;br /&gt;
|keywords=&lt;br /&gt;
|description=Xenomai RTSerial&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /****************************************  Page Description Text  ****************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /*****************************************  General Information  *****************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
{{:Templateimpl:geninfo | initials=MW | title=Xenomai RTSerial | desc=Xenomai RTSerial | project=OE 5.0 }}&lt;br /&gt;
Xenomai provides a RTDM profile for serial device drivers enabling real-time UART serial communication.&lt;br /&gt;
The RTDM serial driver provides the necessary user-space API to perform serial port configuration and communication.&lt;br /&gt;
The following sections will outline the use of the user-space interface and provide basic examples.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /*****************************************  Using/Working With  ******************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
{{:Templateimpl:using | initials=MW | title=Xenomai RTSerial | desc=Xenomai RTSerial | project=OE 5.0 }}&lt;br /&gt;
Given the RTDM serial port driver exists and is loaded for the target on hand, it will provide device nodes at &amp;lt;code&amp;gt;/dev/rtdm/rtserX&amp;lt;/code&amp;gt; where X is replaced by the number of each port.&lt;br /&gt;
The device nodes are then accessed to configured and communicate the underlying serial ports. The following subsections will outline loading the driver, configuring the port, and performing basic serial transactions.&lt;br /&gt;
&lt;br /&gt;
=== Loading the driver ===&lt;br /&gt;
Typically there will be a Linux kernel driver associated with the serial port by default. If the desired device is associated with a Linux driver the driver must be unloaded or the device must be unbound from the driver. Below are examples of loading the RTDM driver for some supported targets.&lt;br /&gt;
&lt;br /&gt;
==== x86 16550A ====&lt;br /&gt;
&lt;br /&gt;
==== iMX6 rt_imx_uart ====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
root@somimx6-xenomai:~# echo 2020000.serial &amp;gt; /sys/bus/platform/drivers/imx-uart/unbind&lt;br /&gt;
root@somimx6-xenomai:~# echo 21e8000.serial &amp;gt; /sys/bus/platform/drivers/imx-uart/unbind&lt;br /&gt;
root@somimx6-xenomai:~# modprobe xeno_imx_uart&lt;br /&gt;
root@somimx6-xenomai:~# dmesg | tail&lt;br /&gt;
.&lt;br /&gt;
.&lt;br /&gt;
[  462.425158] console [ttymxc1] disabled&lt;br /&gt;
[  528.025034] rtser0 on IMX UART0: membase=0xc0c10000 irq=58 uartclk=80000000&lt;br /&gt;
[  528.025700] rtser1 on IMX UART1: membase=0xc0c18000 irq=59 uartclk=80000000&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== AT91 atmel_rt_serial ====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
COMA&lt;br /&gt;
root@som9x25:~# echo f8040000.serial &amp;gt; /sys/bus/platform/drivers/atmel_usart/unbind&lt;br /&gt;
COMD&lt;br /&gt;
root@som9x25:~# echo f8024000.serial &amp;gt; /sys/bus/platform/drivers/atmel_usart/unbind&lt;br /&gt;
root@som9x25:~# modprobe atmel_rt_serial&lt;br /&gt;
rtser0 on ATMEL UART-1: membase=0xc8dd0000 irq=29 uartclk=133333333&lt;br /&gt;
rtser1 on ATMEL UART-1: membase=0xc8dd2000 irq=30 uartclk=133333333&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Configuring the serial port ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
static const struct rtser_config my_config = {&lt;br /&gt;
	.config_mask       = 0xFFFF,&lt;br /&gt;
	.baud_rate         = 115200,&lt;br /&gt;
	.parity            = RTSER_DEF_PARITY,&lt;br /&gt;
	.data_bits         = RTSER_DEF_BITS,&lt;br /&gt;
	.stop_bits         = RTSER_DEF_STOPB,&lt;br /&gt;
	.handshake         = RTSER_DEF_HAND,&lt;br /&gt;
	.fifo_depth        = RTSER_DEF_FIFO_DEPTH,&lt;br /&gt;
	.rx_timeout        = RTSER_DEF_TIMEOUT,&lt;br /&gt;
	.tx_timeout        = RTSER_DEF_TIMEOUT,&lt;br /&gt;
	.event_timeout     = 1000000000, /* 1 s */&lt;br /&gt;
	.timestamp_history = RTSER_RX_TIMESTAMP_HISTORY,&lt;br /&gt;
	.event_mask        = RTSER_EVENT_RXPEND,&lt;br /&gt;
};&lt;br /&gt;
...&lt;br /&gt;
	int fd;&lt;br /&gt;
	int err;&lt;br /&gt;
...&lt;br /&gt;
	fd = open(&amp;quot;/dev/rtdm/rtser0&amp;quot;, 0);&lt;br /&gt;
&lt;br /&gt;
	if (fd &amp;lt; 0) {&lt;br /&gt;
		printf(&amp;quot;open error %s\n&amp;quot;, strerror(errno));&lt;br /&gt;
		return -errno;&lt;br /&gt;
	}&lt;br /&gt;
...&lt;br /&gt;
	err = ioctl(fd, RTSER_RTIOC_SET_CONFIG, &amp;amp;my_config);&lt;br /&gt;
	if (err) {&lt;br /&gt;
		printf(&amp;quot;ioctl error %s\n&amp;quot;, strerror(errno));&lt;br /&gt;
		goto error;&lt;br /&gt;
	}&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
=== Performing serial transactions ===&lt;br /&gt;
Performing serial transactions is as simple as reading and write to the rtser file descriptor.&lt;br /&gt;
&lt;br /&gt;
Sending the contents of a buffer over the serial port:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
	ret = write(fd, buffer, sizeof(buffer));&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Receiving serial port input data into buffer:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
	ret = read(fd, buffer, sizeof(buffer));&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When reading from the serial it is useful to wait for an event to occur before reading:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
	err = ioctl(read_fd, RTSER_RTIOC_WAIT_EVENT, &amp;amp;rx_event);&lt;br /&gt;
	if (err) {&lt;br /&gt;
		printf(&amp;quot;ioctl error on RTSER_RTIOC_WAIT_EVENT %s\n&amp;quot;,&lt;br /&gt;
		       strerror(errno));&lt;br /&gt;
	}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /*****************************************       Examples        *****************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
{{:Templateimpl:examples | initials=MW | title=Xenomai RTSerial | desc=Xenomai RTSerial | project=OE 5.0 }}&lt;br /&gt;
Xenomai provides an example called cross-link which provides an easy way to test serial ports. Essentially the demo sends data from one serial port and receives it on another. To run the demo make sure the RTDM driver is loaded and connect the first two ports via a NULL modem cable.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
root@somimx6-xenomai:~# /usr/demo/cross-link&lt;br /&gt;
main : write-file opened&lt;br /&gt;
main : write-config written&lt;br /&gt;
main : read-file openedmain : read-config written&lt;br /&gt;
main : write-task createdmain : read-task created&lt;br /&gt;
main : starting write-task&lt;br /&gt;
main : starting read-task&lt;br /&gt;
 Nr |   write-&amp;gt;irq    |    irq-&amp;gt;read    |   write-&amp;gt;read   |&lt;br /&gt;
-----------------------------------------------------------&lt;br /&gt;
  0 |18446744041591572624 |     32118717325 |          738333&lt;br /&gt;
  1 |18446744041591563290 |     32118715326 |          727000&lt;br /&gt;
  2 |18446744041591563957 |     32118716326 |          728667&lt;br /&gt;
  3 |18446744041591561291 |     32118714658 |          724333&lt;br /&gt;
  4 |18446744041591562624 |     32118715992 |          727000&lt;br /&gt;
  5 |18446744041591560290 |     32118715326 |          724000&lt;br /&gt;
.&lt;br /&gt;
.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== External Links ==&lt;br /&gt;
* https://xenomai.org/documentation/xenomai-3/html/xeno3prm/group__rtdm__serial.html&lt;br /&gt;
* https://xenomai.org/documentation/xenomai-3/html/xeno3prm/rtdm_2uapi_2serial_8h.html&lt;br /&gt;
* https://xenomai.org/documentation/xenomai-3/html/xeno3prm/cross-link_8c-example.html&lt;/div&gt;</summary>
		<author><name>Mgloff</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.emacinc.com/index.php?title=OE_50_How_To&amp;diff=5474</id>
		<title>OE 50 How To</title>
		<link rel="alternate" type="text/html" href="https://wiki.emacinc.com/index.php?title=OE_50_How_To&amp;diff=5474"/>
		<updated>2017-12-19T23:43:58Z</updated>

		<summary type="html">&lt;p&gt;Mgloff: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{todo| Review (10.06.2015-14:23-&amp;gt;MD+)(11.18.2015-13:00-&amp;gt;MD+)(11.18.2015-16:30-&amp;gt;MD+)|Mike Dean| project=OE 5.0,MD,Review }}&lt;br /&gt;
{{DISPLAYTITLE:EMAC OE 5.X How To}}&lt;br /&gt;
&amp;lt;!-- No Table of Contents for a navigation page. --&amp;gt;&lt;br /&gt;
__NOTOC__&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /**************************************  Navigation Page Table  ******************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
{{:Templateimpl:navpgtable | initials=MD | title=How To Articles | desc=A collection of How To pages for EMAC OE Linux | project=OE 5.0 }}&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /****************************************  System Administration  ****************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{:Templateimpl:navtableentry | title=System Administration }}&lt;br /&gt;
&lt;br /&gt;
{{:Templateimpl:Navti | [[ Network_Configuration | Configure Networking ]] }}&lt;br /&gt;
{{:Templateimpl:Navti | [[ User_Account_Configuration | Configure User Accounts ]] }}&lt;br /&gt;
{{:Templateimpl:Navti | [[ Setting_the_System_Time | Set the Time ]] }}&lt;br /&gt;
{{:Templateimpl:Navti | [[ System_Logging | Configure the System Logger ]] }}&lt;br /&gt;
&lt;br /&gt;
{{:Templateimpl:Navti | [[ Installing_LILO | Install LILO ]] }}&lt;br /&gt;
{{:Templateimpl:Navti | [[ U-Boot_Overview | Work with U-Boot ]] }}&lt;br /&gt;
&lt;br /&gt;
{{:Templateimpl:Navti | [[ Mounting_a_Flash_Filesystem | Mount a Filesystem ]] }}&lt;br /&gt;
{{:Templateimpl:Navti | [[ Setting_up_an_NFS_File_Server | Set Up an NFS Server ]] }}&lt;br /&gt;
{{:Templateimpl:Navti | [[ Installing_TFTP_server | Install a TFTP Server ]] }}&lt;br /&gt;
&lt;br /&gt;
{{:Templateimpl:Navti | [[ Loading_Images_onto_eMMC_Devices | Load Images onto eMMC Devices ]] }}&lt;br /&gt;
{{:Templateimpl:navtend}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /************************************************  New Row  ***********************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- This section is needed anytime you wish to add another row to the table. --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- {{:Templateimpl:navtablenewrow}} --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /****************************************  Software Development  *****************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{:Templateimpl:navtableentry | title=Software Development }}&lt;br /&gt;
&lt;br /&gt;
{{:Templateimpl:Navti | [[ Installing_EMAC_OE_5.0_SDK | SDK Install]] }}&lt;br /&gt;
{{:Templateimpl:Navti | [[ Creating_a_New_EMAC_OE_SDK_Project_with_CMake | Create a New Project (CMake command line) ]] }}&lt;br /&gt;
{{:Templateimpl:Navti | [[ Advanced_CMake_Features | Utilize Advanced CMake Features ]] }}&lt;br /&gt;
{{:Templateimpl:Navti | [[ Creating_a_New_EMAC_OE_SDK_Project_with_qmake_in_Qt_Creator | Create a New Project (Qt Creator) ]] }}&lt;br /&gt;
{{:Templateimpl:Navti | [[ Building_the_Linux_Kernel | Build the Linux Kernel ]] }}&lt;br /&gt;
{{:Templateimpl:Navti | [[Getting_Started_With_Qt_Creator | Get Started with Qt Creator]] }}&lt;br /&gt;
{{:Templateimpl:Navti | [[ Installing_QtCreator | Install Qt Creator Manually ]] }}&lt;br /&gt;
&lt;br /&gt;
{{:Templateimpl:Navti | [[ System_Logging | Log to &amp;lt;code&amp;gt;syslog&amp;lt;/code&amp;gt; ]] }}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{:Templateimpl:navtend}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /***************************************  End Navigation Links Table *************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- This section must be at the end of your table. --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{:Templateimpl:navtableend}}&lt;/div&gt;</summary>
		<author><name>Mgloff</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.emacinc.com/index.php?title=MediaWiki:Sidebar&amp;diff=5473</id>
		<title>MediaWiki:Sidebar</title>
		<link rel="alternate" type="text/html" href="https://wiki.emacinc.com/index.php?title=MediaWiki:Sidebar&amp;diff=5473"/>
		<updated>2017-12-19T16:29:50Z</updated>

		<summary type="html">&lt;p&gt;Mgloff: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* navigation&lt;br /&gt;
** Main Page|EMAC Wiki&lt;br /&gt;
** http://www.emacinc.com|EMAC Homepage&lt;br /&gt;
** EMAC_HW | Hardware List&lt;br /&gt;
&lt;br /&gt;
* OE 5.0 Wiki&lt;br /&gt;
** OE_50_EMAC_Linux  | Main Page&lt;br /&gt;
** OE_50_Getting_Started | Getting Started&lt;br /&gt;
** OE_50_How_To | How To...&lt;br /&gt;
&lt;br /&gt;
* OE 4.0 Wiki &lt;br /&gt;
** OE40wiki | OE 4.0 Main&lt;br /&gt;
** General_Information | General Information&lt;br /&gt;
** System_Configuration | System Configuration&lt;br /&gt;
** Software_Development | Software Development&lt;br /&gt;
** System_Operation | System Operation&lt;br /&gt;
** Working_with_Filesystem_Images | Filesystem Images&lt;br /&gt;
** Bootloaders | Bootloaders&lt;br /&gt;
&lt;br /&gt;
* SEARCH&lt;br /&gt;
&lt;br /&gt;
* Support&lt;br /&gt;
** http://www.emacinc.com/support|EMAC Support Request&lt;br /&gt;
** mailto:support@emacinc.com|Email EMAC Support&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* Miscellaneous&lt;br /&gt;
** recentchanges-url|recentchanges&lt;br /&gt;
** randompage-url|randompage&lt;/div&gt;</summary>
		<author><name>Mgloff</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.emacinc.com/index.php?title=OE_50_How_To&amp;diff=5472</id>
		<title>OE 50 How To</title>
		<link rel="alternate" type="text/html" href="https://wiki.emacinc.com/index.php?title=OE_50_How_To&amp;diff=5472"/>
		<updated>2017-12-19T16:06:26Z</updated>

		<summary type="html">&lt;p&gt;Mgloff: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{todo| Review (10.06.2015-14:23-&amp;gt;MD+)(11.18.2015-13:00-&amp;gt;MD+)(11.18.2015-16:30-&amp;gt;MD+)|Mike Dean| project=OE 5.0,MD,Review }}&lt;br /&gt;
{{DISPLAYTITLE:EMAC OE 5.X How To}}&lt;br /&gt;
&amp;lt;!-- No Table of Contents for a navigation page. --&amp;gt;&lt;br /&gt;
__NOTOC__&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /**************************************  Navigation Page Table  ******************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
{{:Templateimpl:navpgtable | initials=MD | title=How To Articles | desc=A collection of How To pages for EMAC OE Linux | project=OE 5.0 }}&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /****************************************  System Administration  ****************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{:Templateimpl:navtableentry | title=System Administration }}&lt;br /&gt;
&lt;br /&gt;
{{:Templateimpl:Navti | [[ Network_Configuration | Configure Networking ]] }}&lt;br /&gt;
{{:Templateimpl:Navti | [[ User_Account_Configuration | Configure User Accounts ]] }}&lt;br /&gt;
{{:Templateimpl:Navti | [[ Setting_the_System_Time | Set the Time ]] }}&lt;br /&gt;
{{:Templateimpl:Navti | [[ System_Logging | Configure the System Logger ]] }}&lt;br /&gt;
&lt;br /&gt;
{{:Templateimpl:Navti | [[ Installing_LILO | Install LILO ]] }}&lt;br /&gt;
{{:Templateimpl:Navti | [[ U-Boot_Overview | Work with U-Boot ]] }}&lt;br /&gt;
&lt;br /&gt;
{{:Templateimpl:Navti | [[ Mounting_a_Flash_Filesystem | Mount a Filesystem ]] }}&lt;br /&gt;
{{:Templateimpl:Navti | [[ Setting_up_an_NFS_File_Server | Set Up an NFS Server ]] }}&lt;br /&gt;
{{:Templateimpl:Navti | [[ Installing_TFTP_server | Install a TFTP Server ]] }}&lt;br /&gt;
&lt;br /&gt;
{{:Templateimpl:Navti | [[ Loading_Images_onto_eMMC_Devices | Load Images onto eMMC Devices ]] }}&lt;br /&gt;
{{:Templateimpl:navtend}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /************************************************  New Row  ***********************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- This section is needed anytime you wish to add another row to the table. --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- {{:Templateimpl:navtablenewrow}} --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /****************************************  Software Development  *****************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{:Templateimpl:navtableentry | title=Software Development }}&lt;br /&gt;
&lt;br /&gt;
{{:Templateimpl:Navti | [[Install the_EMAC_OE_5.0_SDK | SDK Install]] }}&lt;br /&gt;
{{:Templateimpl:Navti | [[ Creating_a_New_EMAC_OE_SDK_Project_with_CMake | Create a New Project (CMake command line) ]] }}&lt;br /&gt;
{{:Templateimpl:Navti | [[ Advanced_CMake_Features | Utilize Advanced CMake Features ]] }}&lt;br /&gt;
{{:Templateimpl:Navti | [[ Creating_a_New_EMAC_OE_SDK_Project_with_qmake_in_Qt_Creator | Create a New Project (Qt Creator) ]] }}&lt;br /&gt;
{{:Templateimpl:Navti | [[ Building_the_Linux_Kernel | Build the Linux Kernel ]] }}&lt;br /&gt;
{{:Templateimpl:Navti | [[Getting_Started_With_Qt_Creator | Get Started with Qt Creator]] }}&lt;br /&gt;
{{:Templateimpl:Navti | [[ Installing_QtCreator | Install Qt Creator Manually ]] }}&lt;br /&gt;
&lt;br /&gt;
{{:Templateimpl:Navti | [[ System_Logging | Log to &amp;lt;code&amp;gt;syslog&amp;lt;/code&amp;gt; ]] }}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{:Templateimpl:navtend}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /***************************************  End Navigation Links Table *************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- This section must be at the end of your table. --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{:Templateimpl:navtableend}}&lt;/div&gt;</summary>
		<author><name>Mgloff</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.emacinc.com/index.php?title=OE_50_How_To&amp;diff=5471</id>
		<title>OE 50 How To</title>
		<link rel="alternate" type="text/html" href="https://wiki.emacinc.com/index.php?title=OE_50_How_To&amp;diff=5471"/>
		<updated>2017-12-19T16:05:02Z</updated>

		<summary type="html">&lt;p&gt;Mgloff: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{todo| Review (10.06.2015-14:23-&amp;gt;MD+)(11.18.2015-13:00-&amp;gt;MD+)(11.18.2015-16:30-&amp;gt;MD+)|Mike Dean| project=OE 5.0,MD,Review }}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{DISPLAYTITLE:EMAC OE 5.X How To}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- No Table of Contents for a navigation page. --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
__NOTOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /**************************************  Navigation Page Table  ******************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
{{:Templateimpl:navpgtable | initials=MD | title=How To Articles | desc=A collection of How To pages for EMAC OE Linux | project=OE 5.0 }}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /****************************************  System Administration  ****************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{:Templateimpl:navtableentry | title=System Administration }}&lt;br /&gt;
&lt;br /&gt;
{{:Templateimpl:Navti | [[ Network_Configuration | Configure Networking ]] }}&lt;br /&gt;
{{:Templateimpl:Navti | [[ User_Account_Configuration | Configure User Accounts ]] }}&lt;br /&gt;
{{:Templateimpl:Navti | [[ Setting_the_System_Time | Set the Time ]] }}&lt;br /&gt;
{{:Templateimpl:Navti | [[ System_Logging | Configure the System Logger ]] }}&lt;br /&gt;
&lt;br /&gt;
{{:Templateimpl:Navti | [[ Installing_LILO | Install LILO ]] }}&lt;br /&gt;
{{:Templateimpl:Navti | [[ U-Boot_Overview | Work with U-Boot ]] }}&lt;br /&gt;
&lt;br /&gt;
{{:Templateimpl:Navti | [[ Mounting_a_Flash_Filesystem | Mount a Filesystem ]] }}&lt;br /&gt;
{{:Templateimpl:Navti | [[ Setting_up_an_NFS_File_Server | Set Up an NFS Server ]] }}&lt;br /&gt;
{{:Templateimpl:Navti | [[ Installing_TFTP_server | Install a TFTP Server ]] }}&lt;br /&gt;
&lt;br /&gt;
{{:Templateimpl:Navti | [[ Loading_Images_onto_eMMC_Devices | Load Images onto eMMC Devices ]] }}&lt;br /&gt;
{{:Templateimpl:navtend}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /************************************************  New Row  ***********************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- This section is needed anytime you wish to add another row to the table. --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- {{:Templateimpl:navtablenewrow}} --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /****************************************  Software Development  *****************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{:Templateimpl:navtableentry | title=Software Development }}&lt;br /&gt;
&lt;br /&gt;
{{:Templateimpl:Navti | [[Install the_EMAC_OE_5.0_SDK | SDK Install]] }}&lt;br /&gt;
{{:Templateimpl:Navti | [[ Creating_a_New_EMAC_OE_SDK_Project_with_CMake | Create a New Project (CMake command line) ]] }}&lt;br /&gt;
{{:Templateimpl:Navti | [[ Advanced_CMake_Features | Utilize Advanced CMake Features ]] }}&lt;br /&gt;
{{:Templateimpl:Navti | [[ Creating_a_New_EMAC_OE_SDK_Project_with_qmake_in_Qt_Creator | Create a New Project (Qt Creator) ]] }}&lt;br /&gt;
{{:Templateimpl:Navti | [[ Building_the_Linux_Kernel | Build the Linux Kernel ]] }}&lt;br /&gt;
{{:Templateimpl:Navti | [[Getting_Started_With_Qt_Creator | Get Started with Qt Creator]] }}&lt;br /&gt;
{{:Templateimpl:Navti | [[ Installing_QtCreator | Install Qt Creator Manually ]] }}&lt;br /&gt;
&lt;br /&gt;
{{:Templateimpl:Navti | [[ System_Logging | Log to &amp;lt;code&amp;gt;syslog&amp;lt;/code&amp;gt; ]] }}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{:Templateimpl:navtend}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /***************************************  End Navigation Links Table *************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- This section must be at the end of your table. --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{:Templateimpl:navtableend}}&lt;/div&gt;</summary>
		<author><name>Mgloff</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.emacinc.com/index.php?title=OE_50_How_To&amp;diff=5470</id>
		<title>OE 50 How To</title>
		<link rel="alternate" type="text/html" href="https://wiki.emacinc.com/index.php?title=OE_50_How_To&amp;diff=5470"/>
		<updated>2017-12-19T15:39:32Z</updated>

		<summary type="html">&lt;p&gt;Mgloff: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{todo| Review (10.06.2015-14:23-&amp;gt;MD+)(11.18.2015-13:00-&amp;gt;MD+)(11.18.2015-16:30-&amp;gt;MD+)|Mike Dean| project=OE 5.0,MD,Review }}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- No Table of Contents for a navigation page. --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
__NOTOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /**************************************  Navigation Page Table  ******************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
{{:Templateimpl:navpgtable | initials=MD | title=How To Articles | desc=A collection of How To pages for EMAC OE Linux | project=OE 5.0 }}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /****************************************  System Administration  ****************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{:Templateimpl:navtableentry | title=System Administration }}&lt;br /&gt;
&lt;br /&gt;
{{:Templateimpl:Navti | [[ Network_Configuration | Configure Networking ]] }}&lt;br /&gt;
{{:Templateimpl:Navti | [[ User_Account_Configuration | Configure User Accounts ]] }}&lt;br /&gt;
{{:Templateimpl:Navti | [[ Setting_the_System_Time | Set the Time ]] }}&lt;br /&gt;
{{:Templateimpl:Navti | [[ System_Logging | Configure the System Logger ]] }}&lt;br /&gt;
&lt;br /&gt;
{{:Templateimpl:Navti | [[ Installing_LILO | Install LILO ]] }}&lt;br /&gt;
{{:Templateimpl:Navti | [[ U-Boot_Overview | Work with U-Boot ]] }}&lt;br /&gt;
&lt;br /&gt;
{{:Templateimpl:Navti | [[ Mounting_a_Flash_Filesystem | Mount a Filesystem ]] }}&lt;br /&gt;
{{:Templateimpl:Navti | [[ Setting_up_an_NFS_File_Server | Set Up an NFS Server ]] }}&lt;br /&gt;
{{:Templateimpl:Navti | [[ Installing_TFTP_server | Install a TFTP Server ]] }}&lt;br /&gt;
&lt;br /&gt;
{{:Templateimpl:Navti | [[ Loading_Images_onto_eMMC_Devices | Load Images onto eMMC Devices ]] }}&lt;br /&gt;
{{:Templateimpl:navtend}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /************************************************  New Row  ***********************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- This section is needed anytime you wish to add another row to the table. --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- {{:Templateimpl:navtablenewrow}} --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /****************************************  Software Development  *****************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{:Templateimpl:navtableentry | title=Software Development }}&lt;br /&gt;
&lt;br /&gt;
{{:Templateimpl:Navti | [[Install the_EMAC_OE_5.0_SDK | SDK Install]] }}&lt;br /&gt;
{{:Templateimpl:Navti | [[ Creating_a_New_EMAC_OE_SDK_Project_with_CMake | Create a New Project (CMake command line) ]] }}&lt;br /&gt;
{{:Templateimpl:Navti | [[ Advanced_CMake_Features | Utilize Advanced CMake Features ]] }}&lt;br /&gt;
{{:Templateimpl:Navti | [[ Creating_a_New_EMAC_OE_SDK_Project_with_qmake_in_Qt_Creator | Create a New Project (Qt Creator) ]] }}&lt;br /&gt;
{{:Templateimpl:Navti | [[ Building_the_Linux_Kernel | Build the Linux Kernel ]] }}&lt;br /&gt;
{{:Templateimpl:Navti | [[Getting_Started_With_Qt_Creator | Get Started with Qt Creator]] }}&lt;br /&gt;
{{:Templateimpl:Navti | [[ Installing_QtCreator | Install Qt Creator Manually ]] }}&lt;br /&gt;
&lt;br /&gt;
{{:Templateimpl:Navti | [[ System_Logging | Log to &amp;lt;code&amp;gt;syslog&amp;lt;/code&amp;gt; ]] }}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{:Templateimpl:navtend}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /***************************************  End Navigation Links Table *************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- This section must be at the end of your table. --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{:Templateimpl:navtableend}}&lt;/div&gt;</summary>
		<author><name>Mgloff</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.emacinc.com/index.php?title=Building_the_Linux_Kernel&amp;diff=5465</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=5465"/>
		<updated>2017-08-29T15:24:22Z</updated>

		<summary type="html">&lt;p&gt;Mgloff: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{#seo:&lt;br /&gt;
|title=Building the Linux Kernel &lt;br /&gt;
|titlemode=append&lt;br /&gt;
|keywords=Building Linux Kernel,Configuring Kernel,Loading Kernel Modules&lt;br /&gt;
|description=Process of configuring and compiling the Linux kernel using the EMAC kernel build script.&lt;br /&gt;
}}&lt;br /&gt;
This page covers the process of configuring and compiling the Linux kernel using the EMAC kernel build script. This process assumes that you have already acquired the following software: &lt;br /&gt;
&lt;br /&gt;
# EMAC Software Development Kit [[ Installing_EMAC_OE_4.0_SDK | OE 4 ]] or [[Installing_EMAC_OE_5.0_SDK | OE 5 ]]&lt;br /&gt;
# Linux kernel source for target hardware (provided via EMAC public [http://git.emacinc.com/ GIT server] )&lt;br /&gt;
# [ftp://ftp.emacinc.com/EMAC_Linux/SDK/kernel-build-cross.tar.gz Kernel build script]&lt;br /&gt;
&lt;br /&gt;
The example below will assume that a kernel image for the SoM-9x25 module will be created, although 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 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 &amp;lt;code&amp;gt;environment.cfg.sh&amp;lt;/code&amp;gt; script for the correct &lt;br /&gt;
architecture and EMAC OE version.&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. It is recommended to start with the kernel configuration file used by EMAC to build the kernel for the target device. Starting with EMAC OE 5, the kernel configuration can be &lt;br /&gt;
obtained on a running board from /proc/config.gz. Please contact [http://www.emacinc.com/support EMAC support] &lt;br /&gt;
for earlier EMAC OE versions. &lt;br /&gt;
&amp;lt;br &amp;gt;&lt;br /&gt;
The following are steps to configure the kernel:&lt;br /&gt;
&amp;lt;cl&amp;gt;&lt;br /&gt;
1. Copy the default configuration file to the same directory as the kernel source tree and kernel-build-cross.sh and rename it defconfig. &lt;br /&gt;
&lt;br /&gt;
* The kernel-build-cross script accepts the SOURCE_TREE as the first argument and either config or build as the second argument. Optionally, a third argument, BUILD_SUFFIX may be supplied as a suffix to add to the build directory. BUILD_SUFFIX is commonly used to add a date tag or machine name to a build.&lt;br /&gt;
&lt;br /&gt;
{{cli | username=developer | hostname=ldc |./kernel-build-cross.sh linux-at91 config som9x25}}&lt;br /&gt;
&lt;br /&gt;
* The kernel menu-driven configuration utility will be displayed. Features can be selected/deselected to be built into the kernel. Some features can be built as a loadable module, denoted by &amp;lt; &amp;gt;, and not built directly into the kernel. &lt;br /&gt;
{{ warning | Disabling  or modularizing some kernel features may prevent the kernel from starting correctly or at all. }}&lt;br /&gt;
&lt;br /&gt;
Use the space bar to select an option or the 'm' key to configure the selected option as a module. Select &amp;lt;code&amp;gt;Exit&amp;lt;/code&amp;gt; to close the kernel configuration menu and save the configuration to the newly created build directory. When the same build-suffix is used for subsequent builds, this configuration will be used. &lt;br /&gt;
&amp;lt;/cl&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Building the Kernel==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;cl&amp;gt;&lt;br /&gt;
1. Run the kernel-build-cross script again with the build option, this time using the same build-suffix used in the configuration step. &lt;br /&gt;
&lt;br /&gt;
{{cli | username=developer | hostname=ldc |./kernel-build-cross.sh linux-at91 build som9x25}}&lt;br /&gt;
&lt;br /&gt;
* The kernel will begin compiling now. This will take several minutes to complete depending on the kernel configuration and the speed of the development machine. Only move on to the next step if the build completes with no errors.&lt;br /&gt;
&lt;br /&gt;
* The new kernel image will be in the &amp;lt;code&amp;gt;build-3.10.0-som9x25/Install/boot&amp;lt;/code&amp;gt; directory. For the 3.10 and later device tree enabled ARM kernels, the image name will be a zImage. Also, the desired device tree blob (*.dtb) needs to be appended to the kernel. For earlier versions of the kernel, a uImage will be generated that can be loaded directly from U-Boot. X86 boards use a bzImage.&lt;br /&gt;
&lt;br /&gt;
{{clo}}&lt;br /&gt;
{{clio | username=developer | hostname=ldc |cd build-3.10.0-som9x25/Install/boot}}&lt;br /&gt;
{{clio | username=developer | hostname=ldc |cat zImage-3.10.0 som-9x25-150es.dtb &amp;gt; zImage-boot}}&lt;br /&gt;
{{clos}}&lt;br /&gt;
&lt;br /&gt;
This is the image that will get loaded onto the board and executed by the bootloader. To load the new kernel onto the target machine, see the [[Loading Linux Kernels Onto a Board]] page.&lt;br /&gt;
&lt;br /&gt;
The build script will also create an archive of all of the modules created during the build process and place it in the &amp;lt;code&amp;gt;build-3.10.0-som9x25/Install/&amp;lt;/code&amp;gt; directory. The archive will be called &amp;lt;code&amp;gt;modules.tar.gz&amp;lt;/code&amp;gt;.&lt;br /&gt;
&amp;lt;/cl&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Loading Kernel Modules==&lt;br /&gt;
&lt;br /&gt;
If the kernel is recompiled without changing the configuration or source code for any modules, it is not necessary to reload the modules archive. Alternatively, if a module was modified or added, it is only necessary to reload the modules archive.&lt;br /&gt;
To reload the modules:&lt;br /&gt;
&amp;lt;cl&amp;gt;&lt;br /&gt;
1. Copy the archive to the root of the filesystem of the target machine&lt;br /&gt;
&lt;br /&gt;
{{cli | username=developer | hostname=ldc |scp build-3.10.0-som9x25/Install/modules.tar.gz root@1IP_ADDRESS:/ }}&lt;br /&gt;
&lt;br /&gt;
* Log onto the target machine&lt;br /&gt;
&lt;br /&gt;
{{cli | username=developer | hostname=ldc |ssh root@IP_ADDRESS}}&lt;br /&gt;
&lt;br /&gt;
* Extract the kernel modules archive and force the kernel to reload the modules. Make sure that the root flash is mounted read/write before extracting.&lt;br /&gt;
&lt;br /&gt;
{{clo}}&lt;br /&gt;
{{clio |cd /}}&lt;br /&gt;
{{clio |tar xzvf modules.tar.gz}}&lt;br /&gt;
{{clio |depmod -a}}&lt;br /&gt;
{{clio |reboot}}&lt;br /&gt;
{{clos}}&lt;br /&gt;
&amp;lt;/cl&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{:Templateimpl:moreinfo | initials=MG | title=System Logging | desc=The page describes how to build the linux kernel. | project=OE 5.0 }}&lt;br /&gt;
* [[Loading_Linux_Kernels_Onto_a_Board | Loading Linux Kernels Onto a Board]]&lt;/div&gt;</summary>
		<author><name>Mgloff</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.emacinc.com/index.php?title=Building_the_Linux_Kernel&amp;diff=5464</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=5464"/>
		<updated>2017-08-25T20:53:54Z</updated>

		<summary type="html">&lt;p&gt;Mgloff: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{#seo:&lt;br /&gt;
|title=Building the Linux Kernel &lt;br /&gt;
|titlemode=append&lt;br /&gt;
|keywords=Building Linux Kernel,Configuring Kernel,Loading Kernel Modules&lt;br /&gt;
|description=Process of configuring and compiling the Linux kernel using the EMAC kernel build script.&lt;br /&gt;
}}&lt;br /&gt;
This page covers the process of configuring and compiling the Linux kernel using the EMAC kernel build script. This process assumes that you have already acquired the following software: &lt;br /&gt;
&lt;br /&gt;
# EMAC Software Development Kit [[ Installing_EMAC_OE_4.0_SDK | OE 4 ]] or [[Installing_EMAC_OE_5.0_SDK | OE 5 ]]&lt;br /&gt;
# Linux kernel source for target hardware (provided via EMAC public [http://git.emacinc.com/ GIT server] )&lt;br /&gt;
# [ftp://ftp.emacinc.com/EMAC_Linux/SDK/kernel-build-cross.tar.gz Kernel build script]&lt;br /&gt;
&lt;br /&gt;
The example below will assume that a kernel image for the SoM-9x25 module will be created, although 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 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 &amp;lt;code&amp;gt;environment.cfg.sh&amp;lt;/code&amp;gt; script for the correct &lt;br /&gt;
architecture and EMAC OE version.&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. It is recommended to start with the kernel configuration file used by EMAC to build the kernel for the target device. Starting with EMAC OE 5, the kernel configuration can be &lt;br /&gt;
obtained on a running board from /proc/config.gz. Please contact [http://www.emacinc.com/support EMAC support] &lt;br /&gt;
for earlier EMAC OE versions. &lt;br /&gt;
&amp;lt;br &amp;gt;&lt;br /&gt;
The following are steps to configure the kernel:&lt;br /&gt;
&amp;lt;cl&amp;gt;&lt;br /&gt;
1. Copy the default configuration file to the same directory as the kernel source tree and kernel-build-cross.sh and rename it defconfig. &lt;br /&gt;
&lt;br /&gt;
* The kernel-build-cross script accepts the SOURCE_TREE as the first argument and either config or build as the second argument. Optionally, a third argument, BUILD_SUFFIX may be supplied as a suffix to add to the build directory. BUILD_SUFFIX is commonly used to add a date tag or machine name to a build.&lt;br /&gt;
&lt;br /&gt;
{{cli | username=developer | hostname=ldc |./kernel-build-cross.sh linux-at91 config som9x25}}&lt;br /&gt;
&lt;br /&gt;
* The kernel menu-driven configuration utility will be displayed. Features can be selected/deselected to be built into the kernel. Some features can be built as a loadable module, denoted by &amp;lt; &amp;gt;, and not built directly into the kernel. &lt;br /&gt;
{{ warning | Disabling  or modularizing some kernel features may prevent the kernel from starting correctly or at all. }}&lt;br /&gt;
&lt;br /&gt;
Use the space bar to select an option or the 'm' key to configure the selected option as a module. Select &amp;lt;code&amp;gt;Exit&amp;lt;/code&amp;gt; to close the kernel configuration menu and save the configuration to the newly created build directory. When the same build-suffix is used for subsequent builds, this configuration will be used. &lt;br /&gt;
&amp;lt;/cl&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Building the Kernel==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;cl&amp;gt;&lt;br /&gt;
1. Run the kernel-build-cross script again with the build option, this time using the same build-suffix used in the configuration step. &lt;br /&gt;
&lt;br /&gt;
{{cli | username=developer | hostname=ldc |./kernel-build-cross.sh linux-at91 build som9x25}}&lt;br /&gt;
&lt;br /&gt;
* The kernel will begin compiling now. This will take several minutes to complete depending on the kernel configuration and the speed of the development machine. Only move on to the next step if the build completes with no errors.&lt;br /&gt;
&lt;br /&gt;
* The new kernel image will be in the &amp;lt;code&amp;gt;build-3.10.0-som9x25/Install/boot&amp;lt;/code&amp;gt; directory called zImage. For the 3.10 and later device tree enabled kernels, the desired device tree blob needs to be appended to the kernel. &lt;br /&gt;
&lt;br /&gt;
{{clo}}&lt;br /&gt;
{{clio | username=developer | hostname=ldc |cd build-3.10.0-som9x25/Install/boot}}&lt;br /&gt;
{{clio | username=developer | hostname=ldc |cat zImage-3.10.0 som-9x25-150es.dtb &amp;gt; zImage-boot}}&lt;br /&gt;
{{clos}}&lt;br /&gt;
&lt;br /&gt;
This is the image that will get loaded onto the board and executed by the bootloader. To load the new kernel onto the target machine, see the [[Loading Linux Kernels Onto a Board]] page.&lt;br /&gt;
&lt;br /&gt;
The build script will also create an archive of all of the modules created during the build process and place it in the &amp;lt;code&amp;gt;build-3.10.0-som9x25/Install/&amp;lt;/code&amp;gt; directory. The archive will be called &amp;lt;code&amp;gt;modules.tar.gz&amp;lt;/code&amp;gt;.&lt;br /&gt;
&amp;lt;/cl&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Loading Kernel Modules==&lt;br /&gt;
&lt;br /&gt;
If the kernel is recompiled without changing the configuration or source code for any modules, it is not necessary to reload the modules archive. Alternatively, if a module was modified or added, it is only necessary to reload the modules archive.&lt;br /&gt;
To reload the modules:&lt;br /&gt;
&amp;lt;cl&amp;gt;&lt;br /&gt;
1. Copy the archive to the root of the filesystem of the target machine&lt;br /&gt;
&lt;br /&gt;
{{cli | username=developer | hostname=ldc |scp build-3.10.0-som9x25/Install/modules.tar.gz root@1IP_ADDRESS:/ }}&lt;br /&gt;
&lt;br /&gt;
* Log onto the target machine&lt;br /&gt;
&lt;br /&gt;
{{cli | username=developer | hostname=ldc |ssh root@IP_ADDRESS}}&lt;br /&gt;
&lt;br /&gt;
* Extract the kernel modules archive and force the kernel to reload the modules. Make sure that the root flash is mounted read/write before extracting.&lt;br /&gt;
&lt;br /&gt;
{{clo}}&lt;br /&gt;
{{clio |cd /}}&lt;br /&gt;
{{clio |tar xzvf modules.tar.gz}}&lt;br /&gt;
{{clio |depmod -a}}&lt;br /&gt;
{{clio |reboot}}&lt;br /&gt;
{{clos}}&lt;br /&gt;
&amp;lt;/cl&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{:Templateimpl:moreinfo | initials=MG | title=System Logging | desc=The page describes how to build the linux kernel. | project=OE 5.0 }}&lt;br /&gt;
* [[Loading_Linux_Kernels_Onto_a_Board | Loading Linux Kernels Onto a Board]]&lt;/div&gt;</summary>
		<author><name>Mgloff</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.emacinc.com/index.php?title=Loading_Images_onto_eMMC_Devices&amp;diff=5463</id>
		<title>Loading Images onto eMMC Devices</title>
		<link rel="alternate" type="text/html" href="https://wiki.emacinc.com/index.php?title=Loading_Images_onto_eMMC_Devices&amp;diff=5463"/>
		<updated>2017-08-08T19:39:19Z</updated>

		<summary type="html">&lt;p&gt;Mgloff: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{todo|SEOKWREV (12.31.13-13:15-&amp;gt;MD-);(12.31.13-14:50-&amp;gt;MW+);(12.31.13-18:10-&amp;gt;MD+);(12.31.13-18:45-&amp;gt;MG+);(03.06.14-15:35-&amp;gt;BS-);(04.11.14-15:55-&amp;gt;BS+);(05.01.15-12:12-&amp;gt;MG+);(11.05.15-17:50-&amp;gt;MD+)|Michael Welling|project=oe 4,oe 5,mw,md,mg,bs,SEOKWREV}}&lt;br /&gt;
&lt;br /&gt;
{{#seo:&lt;br /&gt;
|title=Loading Images onto eMMC Devices&lt;br /&gt;
|titlemode=append&lt;br /&gt;
|keywords=eMMC,EXT3 Partition,FAT32 Partition,Root File System&lt;br /&gt;
|description=Some EMAC products use eMMC in place of NAND flash. eMMC is an embedded MMC compliant memory that takes the form of an integrated circuit instead of a media card. &lt;br /&gt;
}}&lt;br /&gt;
== Background ==&lt;br /&gt;
Some EMAC products use eMMC in place of NAND flash. eMMC is an embedded MMC compliant memory that takes the form of an integrated circuit instead of a media card. &lt;br /&gt;
&lt;br /&gt;
U-Boot does not support writing to file systems in eMMC. To overcome this issue, the embedded target needs to boot into an alternate media such as a network file system or USB flash drive. Once the board has booted into Linux, the eMMC can be partitioned and formatted, and the root file system can be extracted. The SoM-3517M requires a special FAT formatted partition that contains the bootloader and Linux kernel images. This article explains the general process of writing the eMMC from Linux as well as some specifics related to programming the SoM-3517M, SoM-9X25, SoM-A5D35/6, SoM-3354 and IPAC-9X25.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{note | The procedures below require that you have a TFTP and NFS server setup on a host computer. }}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* Instructions on setting up a TFTP server: [[Installing TFTP server]]&lt;br /&gt;
* Installation of an NFS Server with Linux: [[Setting up an NFS File Server]]&lt;br /&gt;
* Instruction for booting into NFS with U-Boot: [[Booting with an NFS Root Filesystem]]&lt;br /&gt;
* More information about MMC: http://en.wikipedia.org/wiki/MultiMediaCard&lt;br /&gt;
&lt;br /&gt;
== Creating partitions and formatting eMMC ==&lt;br /&gt;
&lt;br /&gt;
Once the Linux command prompt is reached, Linux utilities can be used to create and format partitions on the eMMC. By partitioning the eMMC, the partitions can be accessed individually and formatted differently as required. The &amp;lt;code&amp;gt;fdisk&amp;lt;/code&amp;gt; utility can be used to create these partitions on the eMMC.&lt;br /&gt;
&lt;br /&gt;
For example here is the procedure for creating a 128 MB primary partition:&lt;br /&gt;
&lt;br /&gt;
{{clop}}&lt;br /&gt;
{{cliop | hostname=emac-oe |fdisk /dev/mmcblk0}}&amp;lt;nowiki&amp;gt;&lt;br /&gt;
The number of cylinders for this disk is set to 57024.&lt;br /&gt;
There is nothing wrong with that, but this is larger than 1024,&lt;br /&gt;
and could in certain setups cause problems with:&lt;br /&gt;
1) software that runs at boot time (e.g., old versions of LILO)&lt;br /&gt;
2) booting and partitioning software from other OSs&lt;br /&gt;
   (e.g., DOS FDISK, OS/2 FDISK)&lt;br /&gt;
Command (m for help): n&lt;br /&gt;
Command action&lt;br /&gt;
   e   extended&lt;br /&gt;
   p   primary partition (1-4)&lt;br /&gt;
p&lt;br /&gt;
Partition number (1-4): 1&lt;br /&gt;
First cylinder (1-57024, default 1): Using default value 1&lt;br /&gt;
Last cylinder or +size or +sizeM or +sizeK (1-57024, default 57024): +128M&lt;br /&gt;
 &lt;br /&gt;
Command (m for help): p&lt;br /&gt;
 &lt;br /&gt;
Disk /dev/mmcblk0: 1868 MB, 1868562432 bytes&lt;br /&gt;
4 heads, 16 sectors/track, 57024 cylinders&lt;br /&gt;
Units = cylinders of 64 * 512 = 32768 bytes&lt;br /&gt;
&lt;br /&gt;
        Device Boot      Start         End      Blocks  Id System&lt;br /&gt;
/dev/mmcblk0p1               1        3907      125016  83 Linux&lt;br /&gt;
&lt;br /&gt;
Command (m for help): w&lt;br /&gt;
The partition table has been altered!&lt;br /&gt;
&lt;br /&gt;
Calling ioctl() to re-read partition table&lt;br /&gt;
[  566.062896]  mmcblk0: p1&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
{{cliop | hostname=emac-oe|}}&lt;br /&gt;
{{closp}}&lt;br /&gt;
&lt;br /&gt;
For more information about &amp;lt;code&amp;gt;fdisk&amp;lt;/code&amp;gt;, see:&lt;br /&gt;
http://tldp.org/HOWTO/Partition/fdisk_partitioning.html&lt;br /&gt;
&lt;br /&gt;
After creating the partitions, they can formatted with the various &amp;lt;code&amp;gt;mkfs&amp;lt;/code&amp;gt; utilities. The formatting used is dependent on how the partition is to be accessed. For eMMC root filesystems EMAC currently uses EXT4 (http://en.wikipedia.org/wiki/Ext3). Other formatting options are available (EXT2, EXT3, etc) and can be used. It should be noted that the kernel must be configured to support the chosen filesystem and the bootargs need to specify the correct type. &lt;br /&gt;
&lt;br /&gt;
{{note | For additional information on configuring and compiling the Linux kernel see the following page: [[Building the Linux Kernel]] }}&lt;br /&gt;
&lt;br /&gt;
As described above, the &amp;lt;code&amp;gt;bootargs&amp;lt;/code&amp;gt; is used for signalling to the Linux kernel the location of the root filesystem partition, and its formatting. The &amp;lt;code&amp;gt;root&amp;lt;/code&amp;gt; parameter is used to specify the partition to use while the &amp;lt;code&amp;gt;rootfstype&amp;lt;/code&amp;gt; parameter is used to specify the formatting of the partition.&lt;br /&gt;
&lt;br /&gt;
{{note | For more information about the &amp;lt;code&amp;gt;bootargs&amp;lt;/code&amp;gt; variable see this page: [[U-Boot Overview]] }}&lt;br /&gt;
&lt;br /&gt;
Partitions accessed by processor boot ROM or U-Boot typically need to be formatted with FAT32 formatting. The SoM-3517M, for instance, requires a FAT32 formatted partition for the bootloader and kernel in order to boot properly from eMMC. For more specifics about the SoM-3517M, see the quick reference section below.&lt;br /&gt;
&lt;br /&gt;
===Formatting a partition with EXT4===&lt;br /&gt;
&lt;br /&gt;
{{clop}}&lt;br /&gt;
{{cliop | hostname=emac-oe |mkfs.ext4 /dev/mmcblk0p1}}&amp;lt;nowiki&amp;gt;&lt;br /&gt;
mke2fs 1.41.14 (22-Dec-2010)&lt;br /&gt;
Filesystem label=&lt;br /&gt;
OS type: Linux&lt;br /&gt;
Block size=1024 (log=0)&lt;br /&gt;
Fragment size=1024 (log=0)&lt;br /&gt;
Stride=0 blocks, Stripe width=0 blocks&lt;br /&gt;
31360 inodes, 125016 blocks&lt;br /&gt;
6250 blocks (5.00%) reserved for the super user&lt;br /&gt;
First data block=1&lt;br /&gt;
Maximum filesystem blocks=67371008&lt;br /&gt;
16 block groups&lt;br /&gt;
8192 blocks per group, 8192 fragments per group&lt;br /&gt;
1960 inodes per group&lt;br /&gt;
Superblock backups stored on blocks: &lt;br /&gt;
        8193, 24577, 40961, 57345, 73729&lt;br /&gt;
&lt;br /&gt;
Writing inode tables: done      &lt;br /&gt;
Creating journal (4096 blocks): done&lt;br /&gt;
Writing superblocks and filesystem accounting information: done&lt;br /&gt;
 &lt;br /&gt;
This filesystem will be automatically checked every 39 mounts or&lt;br /&gt;
180 days, whichever comes first.  Use tune2fs -c or -i to override.&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
{{cliop| hostname=emac-oe |}}&lt;br /&gt;
{{closp}}&lt;br /&gt;
&lt;br /&gt;
===Formatting a partition with FAT32===&lt;br /&gt;
&lt;br /&gt;
{{clop}}&lt;br /&gt;
{{cliop | hostname=emac-oe |mkdosfs -F 32 /dev/mmcblk0p1}}&lt;br /&gt;
mkdosfs 2.11 (12 Mar 2005)&lt;br /&gt;
{{cliop | hostname=emac-oe |}}&lt;br /&gt;
{{closp}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Extracting filesystems to eMMC ==&lt;br /&gt;
After formatting a partition correctly, the partition can be mounted and files can be loaded to the eMMC.&lt;br /&gt;
&lt;br /&gt;
For example, here is the procedure for writing a root filesystem to the first partition of an eMMC card:&lt;br /&gt;
&lt;br /&gt;
{{clo}}&lt;br /&gt;
{{clio | hostname=emac-oe |mkdir -p /mnt/card}}&lt;br /&gt;
{{clio | hostname=emac-oe |mount /dev/mmcblk0p1 /mnt/card}}&lt;br /&gt;
{{clio | hostname=emac-oe |cd /mnt/card}}&lt;br /&gt;
{{clio | hostname=emac-oe |tar xzvf /images/emac-image.rootfs.tar.gz}}&lt;br /&gt;
&amp;lt;nowiki&amp;gt;    ⋮&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
{{clos}}&lt;br /&gt;
&lt;br /&gt;
In the above example the &amp;lt;code&amp;gt;/mnt/card&amp;lt;/code&amp;gt; directory is called the mount point. The &amp;lt;code&amp;gt;mkdir -p&amp;lt;/code&amp;gt; command creates the directory if it does not already exist. The &amp;lt;code&amp;gt;mount&amp;lt;/code&amp;gt; command attaches the specified partition to the directory. Any files written to the mounted directory will go to the partition on the eMMC. After the mount is complete, files can be extracted as shown using the &amp;lt;code&amp;gt;tar&amp;lt;/code&amp;gt; command.&lt;br /&gt;
&lt;br /&gt;
It should be noted that the &amp;lt;code&amp;gt;/etc/fstab&amp;lt;/code&amp;gt; file can be used to specify mount points for partitions upon boot. See http://en.wikipedia.org/wiki/Fstab for additional information.&lt;br /&gt;
&lt;br /&gt;
== Quick Reference (by Target Type) ==&lt;br /&gt;
This section is used to provide specifics for programming eMMC on various targets.&lt;br /&gt;
&lt;br /&gt;
For the partitioning sections, the information in the parenthesis denotes a keyboard input sequence. The (n,p,1,default,+64M) creates a new primary partition. Each input is followed a carriage return and the default is selected by pressing carriage return with no entry. See the expanded example in the above '''Creating partitions and formatting eMMC''' section for an idea of how the interface looks when commands are executed correctly.&lt;br /&gt;
&lt;br /&gt;
=== SoM-3517M ===&lt;br /&gt;
==== Partitioning the eMMC ====&lt;br /&gt;
&lt;br /&gt;
{{cli | hostname=emac-oe |fdisk -H 255 -S 63 /dev/mmcblk0}}&lt;br /&gt;
&lt;br /&gt;
The partitioning steps are as follows:&lt;br /&gt;
# Create 1st partition (n,p,1,default,+64M)&lt;br /&gt;
# Create 2nd partition (n,p,2,default,default)&lt;br /&gt;
# Change 1st partition type to FAT32 (t,1,c)&lt;br /&gt;
# Make 1st partition ACTIVE (a,1)&lt;br /&gt;
# Write (w)&lt;br /&gt;
&lt;br /&gt;
==== Formatting the eMMC ====&lt;br /&gt;
&lt;br /&gt;
{{clo}}&lt;br /&gt;
{{clio | hostname=emac-oe |mkfs.ext3 /dev/mmcblk0p2}}&lt;br /&gt;
{{clio | hostname=emac-oe |mkdosfs -F 32 /dev/mmcblk0p1}}&lt;br /&gt;
{{clos}}&lt;br /&gt;
&lt;br /&gt;
The first command formats the second partition as ext3. The &amp;lt;code&amp;gt;mkfs.ext3&amp;lt;/code&amp;gt; command can take further configuration parameters. See the &amp;lt;code&amp;gt;mkfs.ext3&amp;lt;/code&amp;gt; man page for more information.&lt;br /&gt;
&lt;br /&gt;
The second command formats the first partition as FAT32 for use with the AM3517's boot ROM. This is a requirement to boot from the eMMC.&lt;br /&gt;
&lt;br /&gt;
==== Adding Kernel and Bootloader ====&lt;br /&gt;
&lt;br /&gt;
{{clo}}&lt;br /&gt;
{{clio | hostname=emac-oe |mkdir -p /mnt/card}}&lt;br /&gt;
{{clio | hostname=emac-oe |mount /dev/mmcblk0p1 /mnt/card}}&lt;br /&gt;
{{clio | hostname=emac-oe |cd /images}}&lt;br /&gt;
{{clio | hostname=emac-oe | pwd=images |cp MLO uImage u-boot.bin /mnt/card/}}&lt;br /&gt;
{{clio | hostname=emac-oe | pwd=images |sync}}&lt;br /&gt;
{{clio | hostname=emac-oe | pwd=images |umount /dev/mmcblk0p1}}&lt;br /&gt;
{{clos}}&lt;br /&gt;
&lt;br /&gt;
{{ note | The first partition '''must''' be formatted FAT32 and the MLO binary '''must''' be in the first sector for the eMMC boot sequence to work properly.  }}&lt;br /&gt;
&lt;br /&gt;
==== Extracting Root Filesystem ====&lt;br /&gt;
{{clo}}&lt;br /&gt;
{{clio | hostname=emac-oe | pwd=images |mount /dev/mmcblk0p2 /mnt/card}}&lt;br /&gt;
{{clio | hostname=emac-oe | pwd=images |cd /mnt/card}}&lt;br /&gt;
{{clio | hostname=emac-oe | pwd=/mnt/card |tar xzvf /emac-image.rootfs.tar.gz}}&lt;br /&gt;
{{clio | hostname=emac-oe | pwd=/mnt/card |cd ..}}&lt;br /&gt;
{{clio | hostname=emac-oe | pwd=/mnt |sync}}&lt;br /&gt;
{{clio | hostname=emac-oe | pwd=/mnt |umount /dev/mmcblk0p2}}&lt;br /&gt;
{{clos}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== SoM-9X25M / IPAC-9X25 / SoM-A5D35/6 / SoM-3354 ===&lt;br /&gt;
&lt;br /&gt;
Unlike the SoM-3517, these SoMs store U-Boot and the Linux kernel in a separate serial flash instead of the eMMC. Typically, two partitions are created. The first partition contains the complete filesystem and is mounted read-only while the second partition contains the /home directory and is mounted read-write.&lt;br /&gt;
==== Partitioning the eMMC ====&lt;br /&gt;
&lt;br /&gt;
{{cli | hostname=emac-oe |fdisk /dev/mmcblk0}}&lt;br /&gt;
&lt;br /&gt;
{{ note | For the SoM-9x25M revisions 7 and above, the eMMC block device is /dev/sdb }}&lt;br /&gt;
&lt;br /&gt;
The partitioning steps are as follows:&lt;br /&gt;
&lt;br /&gt;
# Create 1st partition (n,p,1,default,+1G)&lt;br /&gt;
# Create 2nd partition (n,p,2,default,default)&lt;br /&gt;
# Write (w)&lt;br /&gt;
&lt;br /&gt;
==== Formatting the eMMC ====&lt;br /&gt;
{{clo}}&lt;br /&gt;
{{clio | hostname=emac-oe |mkfs.ext4 /dev/mmcblk0p1}}&lt;br /&gt;
{{clio | hostname=emac-oe |mkfs.ext4 /dev/mmcblk0p2}}&lt;br /&gt;
{{clos}}&lt;br /&gt;
&lt;br /&gt;
==== Extracting Root Filesystem ====&lt;br /&gt;
{{clo}}&lt;br /&gt;
{{clio | hostname=emac-oe |mkdir -p /mnt/card}}&lt;br /&gt;
{{clio | hostname=emac-oe |mount /dev/mmcblk0p1 /mnt/card}}&lt;br /&gt;
{{clio | hostname=emac-oe |cd /mnt/card}}&lt;br /&gt;
{{clio | hostname=emac-oe | pwd=/mnt/card |tar xzvf /emac-image.rootfs.tar.gz}}&lt;br /&gt;
{{clio | hostname=emac-oe | pwd=/mnt/card |cd ..}}&lt;br /&gt;
{{clio | hostname=emac-oe | pwd=/mnt |sync}}&lt;br /&gt;
{{clio | hostname=emac-oe | pwd=/mnt |umount /dev/mmcblk0p1}}&lt;br /&gt;
{{clos}}&lt;/div&gt;</summary>
		<author><name>Mgloff</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.emacinc.com/index.php?title=Loading_Images_onto_eMMC_Devices&amp;diff=5462</id>
		<title>Loading Images onto eMMC Devices</title>
		<link rel="alternate" type="text/html" href="https://wiki.emacinc.com/index.php?title=Loading_Images_onto_eMMC_Devices&amp;diff=5462"/>
		<updated>2017-08-08T19:36:07Z</updated>

		<summary type="html">&lt;p&gt;Mgloff: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{todo|SEOKWREV (12.31.13-13:15-&amp;gt;MD-);(12.31.13-14:50-&amp;gt;MW+);(12.31.13-18:10-&amp;gt;MD+);(12.31.13-18:45-&amp;gt;MG+);(03.06.14-15:35-&amp;gt;BS-);(04.11.14-15:55-&amp;gt;BS+);(05.01.15-12:12-&amp;gt;MG+);(11.05.15-17:50-&amp;gt;MD+)|Michael Welling|project=oe 4,oe 5,mw,md,mg,bs,SEOKWREV}}&lt;br /&gt;
&lt;br /&gt;
{{#seo:&lt;br /&gt;
|title=Loading Images onto eMMC Devices&lt;br /&gt;
|titlemode=append&lt;br /&gt;
|keywords=eMMC,EXT3 Partition,FAT32 Partition,Root File System&lt;br /&gt;
|description=Some EMAC products use eMMC in place of NAND flash. eMMC is an embedded MMC compliant memory that takes the form of an integrated circuit instead of a media card. &lt;br /&gt;
}}&lt;br /&gt;
== Background ==&lt;br /&gt;
Some EMAC products use eMMC in place of NAND flash. eMMC is an embedded MMC compliant memory that takes the form of an integrated circuit instead of a media card. &lt;br /&gt;
&lt;br /&gt;
U-Boot does not support writing to file systems in eMMC. To overcome this issue, the embedded target needs to boot into an alternate media such as a network file system or USB flash drive. Once the board has booted into Linux, the eMMC can be partitioned and formatted, and the root file system can be extracted. The SoM-3517M requires a special FAT formatted partition that contains the bootloader and Linux kernel images. This article explains the general process of writing the eMMC from Linux as well as some specifics related to programming the SoM-3517M, SoM-9X25, SoM-A5D35/6, SoM-3354 and IPAC-9X25.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{note | The procedures below require that you have a TFTP and NFS server setup on a host computer. }}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* Instructions on setting up a TFTP server: [[Installing TFTP server]]&lt;br /&gt;
* Installation of an NFS Server with Linux: [[Setting up an NFS File Server]]&lt;br /&gt;
* Instruction for booting into NFS with U-Boot: [[Booting with an NFS Root Filesystem]]&lt;br /&gt;
* More information about MMC: http://en.wikipedia.org/wiki/MultiMediaCard&lt;br /&gt;
&lt;br /&gt;
== Creating partitions and formatting eMMC ==&lt;br /&gt;
&lt;br /&gt;
Once the Linux command prompt is reached, Linux utilities can be used to create and format partitions on the eMMC. By partitioning the eMMC, the partitions can be accessed individually and formatted differently as required. The &amp;lt;code&amp;gt;fdisk&amp;lt;/code&amp;gt; utility can be used to create these partitions on the eMMC.&lt;br /&gt;
&lt;br /&gt;
For example here is the procedure for creating a 128 MB primary partition:&lt;br /&gt;
&lt;br /&gt;
{{clop}}&lt;br /&gt;
{{cliop | hostname=emac-oe |fdisk /dev/mmcblk0}}&amp;lt;nowiki&amp;gt;&lt;br /&gt;
The number of cylinders for this disk is set to 57024.&lt;br /&gt;
There is nothing wrong with that, but this is larger than 1024,&lt;br /&gt;
and could in certain setups cause problems with:&lt;br /&gt;
1) software that runs at boot time (e.g., old versions of LILO)&lt;br /&gt;
2) booting and partitioning software from other OSs&lt;br /&gt;
   (e.g., DOS FDISK, OS/2 FDISK)&lt;br /&gt;
Command (m for help): n&lt;br /&gt;
Command action&lt;br /&gt;
   e   extended&lt;br /&gt;
   p   primary partition (1-4)&lt;br /&gt;
p&lt;br /&gt;
Partition number (1-4): 1&lt;br /&gt;
First cylinder (1-57024, default 1): Using default value 1&lt;br /&gt;
Last cylinder or +size or +sizeM or +sizeK (1-57024, default 57024): +128M&lt;br /&gt;
 &lt;br /&gt;
Command (m for help): p&lt;br /&gt;
 &lt;br /&gt;
Disk /dev/mmcblk0: 1868 MB, 1868562432 bytes&lt;br /&gt;
4 heads, 16 sectors/track, 57024 cylinders&lt;br /&gt;
Units = cylinders of 64 * 512 = 32768 bytes&lt;br /&gt;
&lt;br /&gt;
        Device Boot      Start         End      Blocks  Id System&lt;br /&gt;
/dev/mmcblk0p1               1        3907      125016  83 Linux&lt;br /&gt;
&lt;br /&gt;
Command (m for help): w&lt;br /&gt;
The partition table has been altered!&lt;br /&gt;
&lt;br /&gt;
Calling ioctl() to re-read partition table&lt;br /&gt;
[  566.062896]  mmcblk0: p1&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
{{cliop | hostname=emac-oe|}}&lt;br /&gt;
{{closp}}&lt;br /&gt;
&lt;br /&gt;
For more information about &amp;lt;code&amp;gt;fdisk&amp;lt;/code&amp;gt;, see:&lt;br /&gt;
http://tldp.org/HOWTO/Partition/fdisk_partitioning.html&lt;br /&gt;
&lt;br /&gt;
After creating the partitions, they can formatted with the various &amp;lt;code&amp;gt;mkfs&amp;lt;/code&amp;gt; utilities. The formatting used is dependent on how the partition is to be accessed. For eMMC root filesystems EMAC currently uses EXT4 (http://en.wikipedia.org/wiki/Ext3). Other formatting options are available (EXT2, EXT3, etc) and can be used. It should be noted that the kernel must be configured to support the chosen filesystem and the bootargs need to specify the correct type. &lt;br /&gt;
&lt;br /&gt;
{{note | For additional information on configuring and compiling the Linux kernel see the following page: [[Building the Linux Kernel]] }}&lt;br /&gt;
&lt;br /&gt;
As described above, the &amp;lt;code&amp;gt;bootargs&amp;lt;/code&amp;gt; is used for signalling to the Linux kernel the location of the root filesystem partition, and its formatting. The &amp;lt;code&amp;gt;root&amp;lt;/code&amp;gt; parameter is used to specify the partition to use while the &amp;lt;code&amp;gt;rootfstype&amp;lt;/code&amp;gt; parameter is used to specify the formatting of the partition.&lt;br /&gt;
&lt;br /&gt;
{{note | For more information about the &amp;lt;code&amp;gt;bootargs&amp;lt;/code&amp;gt; variable see this page: [[U-Boot Overview]] }}&lt;br /&gt;
&lt;br /&gt;
Partitions accessed by processor boot ROM or U-Boot typically need to be formatted with FAT32 formatting. The SoM-3517M, for instance, requires a FAT32 formatted partition for the bootloader and kernel in order to boot properly from eMMC. For more specifics about the SoM-3517M, see the quick reference section below.&lt;br /&gt;
&lt;br /&gt;
===Formatting a partition with EXT4===&lt;br /&gt;
&lt;br /&gt;
{{clop}}&lt;br /&gt;
{{cliop | hostname=emac-oe |mkfs.ext4 /dev/mmcblk0p1}}&amp;lt;nowiki&amp;gt;&lt;br /&gt;
mke2fs 1.41.14 (22-Dec-2010)&lt;br /&gt;
Filesystem label=&lt;br /&gt;
OS type: Linux&lt;br /&gt;
Block size=1024 (log=0)&lt;br /&gt;
Fragment size=1024 (log=0)&lt;br /&gt;
Stride=0 blocks, Stripe width=0 blocks&lt;br /&gt;
31360 inodes, 125016 blocks&lt;br /&gt;
6250 blocks (5.00%) reserved for the super user&lt;br /&gt;
First data block=1&lt;br /&gt;
Maximum filesystem blocks=67371008&lt;br /&gt;
16 block groups&lt;br /&gt;
8192 blocks per group, 8192 fragments per group&lt;br /&gt;
1960 inodes per group&lt;br /&gt;
Superblock backups stored on blocks: &lt;br /&gt;
        8193, 24577, 40961, 57345, 73729&lt;br /&gt;
&lt;br /&gt;
Writing inode tables: done      &lt;br /&gt;
Creating journal (4096 blocks): done&lt;br /&gt;
Writing superblocks and filesystem accounting information: done&lt;br /&gt;
 &lt;br /&gt;
This filesystem will be automatically checked every 39 mounts or&lt;br /&gt;
180 days, whichever comes first.  Use tune2fs -c or -i to override.&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
{{cliop| hostname=emac-oe |}}&lt;br /&gt;
{{closp}}&lt;br /&gt;
&lt;br /&gt;
===Formatting a partition with FAT32===&lt;br /&gt;
&lt;br /&gt;
{{clop}}&lt;br /&gt;
{{cliop | hostname=emac-oe |mkdosfs -F 32 /dev/mmcblk0p1}}&lt;br /&gt;
mkdosfs 2.11 (12 Mar 2005)&lt;br /&gt;
{{cliop | hostname=emac-oe |}}&lt;br /&gt;
{{closp}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Extracting filesystems to eMMC ==&lt;br /&gt;
After formatting a partition correctly, the partition can be mounted and files can be loaded to the eMMC.&lt;br /&gt;
&lt;br /&gt;
For example, here is the procedure for writing a root filesystem to the first partition of an eMMC card:&lt;br /&gt;
&lt;br /&gt;
{{clo}}&lt;br /&gt;
{{clio | hostname=emac-oe |mkdir -p /mnt/card}}&lt;br /&gt;
{{clio | hostname=emac-oe |mount /dev/mmcblk0p1 /mnt/card}}&lt;br /&gt;
{{clio | hostname=emac-oe |cd /mnt/card}}&lt;br /&gt;
{{clio | hostname=emac-oe |tar xzvf /images/emac-image.rootfs.tar.gz}}&lt;br /&gt;
&amp;lt;nowiki&amp;gt;    ⋮&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
{{clos}}&lt;br /&gt;
&lt;br /&gt;
In the above example the &amp;lt;code&amp;gt;/mnt/card&amp;lt;/code&amp;gt; directory is called the mount point. The &amp;lt;code&amp;gt;mkdir -p&amp;lt;/code&amp;gt; command creates the directory if it does not already exist. The &amp;lt;code&amp;gt;mount&amp;lt;/code&amp;gt; command attaches the specified partition to the directory. Any files written to the mounted directory will go to the partition on the eMMC. After the mount is complete, files can be extracted as shown using the &amp;lt;code&amp;gt;tar&amp;lt;/code&amp;gt; command.&lt;br /&gt;
&lt;br /&gt;
It should be noted that the &amp;lt;code&amp;gt;/etc/fstab&amp;lt;/code&amp;gt; file can be used to specify mount points for partitions upon boot. See http://en.wikipedia.org/wiki/Fstab for additional information.&lt;br /&gt;
&lt;br /&gt;
== Quick Reference (by Target Type) ==&lt;br /&gt;
This section is used to provide specifics for programming eMMC on various targets.&lt;br /&gt;
&lt;br /&gt;
For the partitioning sections, the information in the parenthesis denotes a keyboard input sequence. The (n,p,1,default,+64M) creates a new primary partition. Each input is followed a carriage return and the default is selected by pressing carriage return with no entry. See the expanded example in the above '''Creating partitions and formatting eMMC''' section for an idea of how the interface looks when commands are executed correctly.&lt;br /&gt;
&lt;br /&gt;
=== SoM-3517M ===&lt;br /&gt;
==== Partitioning the eMMC ====&lt;br /&gt;
&lt;br /&gt;
{{cli | hostname=emac-oe |fdisk -H 255 -S 63 /dev/mmcblk0}}&lt;br /&gt;
&lt;br /&gt;
The partitioning steps are as follows:&lt;br /&gt;
# Create 1st partition (n,p,1,default,+64M)&lt;br /&gt;
# Create 2nd partition (n,p,2,default,default)&lt;br /&gt;
# Change 1st partition type to FAT32 (t,1,c)&lt;br /&gt;
# Make 1st partition ACTIVE (a,1)&lt;br /&gt;
# Write (w)&lt;br /&gt;
&lt;br /&gt;
==== Formatting the eMMC ====&lt;br /&gt;
&lt;br /&gt;
{{clo}}&lt;br /&gt;
{{clio | hostname=emac-oe |mkfs.ext3 /dev/mmcblk0p2}}&lt;br /&gt;
{{clio | hostname=emac-oe |mkdosfs -F 32 /dev/mmcblk0p1}}&lt;br /&gt;
{{clos}}&lt;br /&gt;
&lt;br /&gt;
The first command formats the second partition as ext3. The &amp;lt;code&amp;gt;mkfs.ext3&amp;lt;/code&amp;gt; command can take further configuration parameters. See the &amp;lt;code&amp;gt;mkfs.ext3&amp;lt;/code&amp;gt; man page for more information.&lt;br /&gt;
&lt;br /&gt;
The second command formats the first partition as FAT32 for use with the AM3517's boot ROM. This is a requirement to boot from the eMMC.&lt;br /&gt;
&lt;br /&gt;
==== Adding Kernel and Bootloader ====&lt;br /&gt;
&lt;br /&gt;
{{clo}}&lt;br /&gt;
{{clio | hostname=emac-oe |mkdir -p /mnt/card}}&lt;br /&gt;
{{clio | hostname=emac-oe |mount /dev/mmcblk0p1 /mnt/card}}&lt;br /&gt;
{{clio | hostname=emac-oe |cd /images}}&lt;br /&gt;
{{clio | hostname=emac-oe | pwd=images |cp MLO uImage u-boot.bin /mnt/card/}}&lt;br /&gt;
{{clio | hostname=emac-oe | pwd=images |sync}}&lt;br /&gt;
{{clio | hostname=emac-oe | pwd=images |umount /dev/mmcblk0p1}}&lt;br /&gt;
{{clos}}&lt;br /&gt;
&lt;br /&gt;
{{ note | The first partition '''must''' be formatted FAT32 and the MLO binary '''must''' be in the first sector for the eMMC boot sequence to work properly.  }}&lt;br /&gt;
&lt;br /&gt;
==== Extracting Root Filesystem ====&lt;br /&gt;
{{clo}}&lt;br /&gt;
{{clio | hostname=emac-oe | pwd=images |mount /dev/mmcblk0p2 /mnt/card}}&lt;br /&gt;
{{clio | hostname=emac-oe | pwd=images |cd /mnt/card}}&lt;br /&gt;
{{clio | hostname=emac-oe | pwd=/mnt/card |tar xzvf /emac-image.rootfs.tar.gz}}&lt;br /&gt;
{{clio | hostname=emac-oe | pwd=/mnt/card |cd ..}}&lt;br /&gt;
{{clio | hostname=emac-oe | pwd=/mnt |sync}}&lt;br /&gt;
{{clio | hostname=emac-oe | pwd=/mnt |umount /dev/mmcblk0p2}}&lt;br /&gt;
{{clos}}&lt;br /&gt;
&lt;br /&gt;
=== SoM-9X25M / IPAC-9X25 / SoM-A5D35/6 / SoM-3354 ===&lt;br /&gt;
&lt;br /&gt;
Unlike the SoM-3517, these SoMs store U-Boot and the Linux kernel in a separate serial flash instead of the eMMC.&lt;br /&gt;
==== Partitioning the eMMC ====&lt;br /&gt;
&lt;br /&gt;
{{cli | hostname=emac-oe |fdisk /dev/mmcblk0}}&lt;br /&gt;
&lt;br /&gt;
{{ note | For the SoM-9x25M revisions 7 and above, the eMMC block device is /dev/sdb }}&lt;br /&gt;
&lt;br /&gt;
The partitioning steps are as follows:&lt;br /&gt;
&lt;br /&gt;
# Create 1st partition (n,p,1,default,+1G)&lt;br /&gt;
# Create 2nd partition (n,p,2,default,default)&lt;br /&gt;
# Write (w)&lt;br /&gt;
&lt;br /&gt;
==== Formatting the eMMC ====&lt;br /&gt;
{{clo}}&lt;br /&gt;
{{clio | hostname=emac-oe |mkfs.ext4 /dev/mmcblk0p1}}&lt;br /&gt;
{{clio | hostname=emac-oe |mkfs.ext4 /dev/mmcblk0p2}}&lt;br /&gt;
{{clos}}&lt;br /&gt;
&lt;br /&gt;
==== Extracting Root Filesystem ====&lt;br /&gt;
{{clo}}&lt;br /&gt;
{{clio | hostname=emac-oe |mkdir -p /mnt/card}}&lt;br /&gt;
{{clio | hostname=emac-oe |mount /dev/mmcblk0p1 /mnt/card}}&lt;br /&gt;
{{clio | hostname=emac-oe |cd /mnt/card}}&lt;br /&gt;
{{clio | hostname=emac-oe | pwd=/mnt/card |tar xzvf /emac-image.rootfs.tar.gz}}&lt;br /&gt;
{{clio | hostname=emac-oe | pwd=/mnt/card |cd ..}}&lt;br /&gt;
{{clio | hostname=emac-oe | pwd=/mnt |sync}}&lt;br /&gt;
{{clio | hostname=emac-oe | pwd=/mnt |umount /dev/mmcblk0p1}}&lt;br /&gt;
{{clos}}&lt;/div&gt;</summary>
		<author><name>Mgloff</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.emacinc.com/index.php?title=Getting_Started_With_EMAC_Virtual_LDC&amp;diff=5460</id>
		<title>Getting Started With EMAC Virtual LDC</title>
		<link rel="alternate" type="text/html" href="https://wiki.emacinc.com/index.php?title=Getting_Started_With_EMAC_Virtual_LDC&amp;diff=5460"/>
		<updated>2017-07-19T16:01:13Z</updated>

		<summary type="html">&lt;p&gt;Mgloff: Created page with &amp;quot;{{todo| NotStarted (03.06.2017-12:18-&amp;gt;DS+)|Daniel Sojka| project=OE 5.0,DS,NotStarted }}  {{#seo: |title=Getting Started With EMAC Virtual LDC |titlemode=append |keywords= |de...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{todo| NotStarted (03.06.2017-12:18-&amp;gt;DS+)|Daniel Sojka| project=OE 5.0,DS,NotStarted }}&lt;br /&gt;
&lt;br /&gt;
{{#seo:&lt;br /&gt;
|title=Getting Started With EMAC Virtual LDC&lt;br /&gt;
|titlemode=append&lt;br /&gt;
|keywords=&lt;br /&gt;
|description=This page describes how to get started with the EMAC Virtual LDC in VirtualBox}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /****************************************  Page Description Text  ****************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This page describes how to get started with the EMAC Virtual LDC in VirtualBox&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /***************************************** Background Information ****************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{:Templateimpl:bg | initials=DS | title=Getting Started With EMAC Virtual LDC | desc=This page describes how to get started with the EMAC Virtual LDC in VirtualBox | project=OE 5.0 }}&lt;br /&gt;
VirtualBox is a general-purpose full virtualizer for x86 hardware, targeted at server, desktop and embedded use.&amp;lt;br&amp;gt;&lt;br /&gt;
For more information, visit the Virtual Box website: https://www.virtualbox.org/wiki/VirtualBox&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /*****************************************  General Information  *****************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
{{:Templateimpl:geninfo | initials=DS | title=Getting Started With EMAC Virtual LDC | desc=This page describes how to get started with the EMAC Virtual LDC in VirtualBox | project=OE 5.0 }}&lt;br /&gt;
Before getting started with the EMAC Virtual LDC, ensure that your computer meets the minimum specifications:&amp;lt;br&amp;gt;&lt;br /&gt;
* Intel Core i3 processor (or equivalent)&lt;br /&gt;
* 4GB RAM&lt;br /&gt;
* At least 30GB of free storage space&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /*****************************************  Using/Working With  ******************************************/ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- /*********************************************************************************************************/ --&amp;gt;&lt;br /&gt;
{{:Templateimpl:using | initials=DS | title=Getting Started With EMAC Virtual LDC | desc=This page describes how to get started with the EMAC Virtual LDC in VirtualBox | project=OE 5.0 }}&lt;br /&gt;
1. Download and install VirtualBox.&lt;br /&gt;
* [https://www.virtualbox.org/wiki/Downloads VirtualBox Download]&lt;br /&gt;
&lt;br /&gt;
2. Download the EMAC Virtual LDC .ova file. (Right click, Save link as)&lt;br /&gt;
* [ftp://ftp.emacinc.com/EMAC_Linux/Virtual_LDCs/EMAC_Virtual_LDC.ova EMAC Virtual LDC .ova File]&lt;br /&gt;
&lt;br /&gt;
3. Navigate to the directory you saved the file to, right click it and select &amp;quot;Open with VirtualBox&amp;quot;&lt;br /&gt;
&lt;br /&gt;
4. VirtualBox and an Import Wizard should start. Click &amp;quot;Import&amp;quot;.&lt;br /&gt;
[[File:Importwizard.png|600px|left|thumb|Figure 1: VirtualBox Import Wizard]]&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
5. Once the file is imported, select the EMAC_Virtual_LDC and click &amp;quot;Start&amp;quot;.&lt;br /&gt;
[[File:Ldcstart.png|800px|left|thumb|Figure 2: Starting the virtual machine]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
6. The virtual machine will boot and arrive at the login screen&lt;br /&gt;
* Password: emac_inc&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Ldclogin.png|800px|left|thumb|Figure 3: Logging into the virtual machine]]&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
7. You are now ready to begin developing. The EMAC SDK and Qt Creator IDE are already installed.&lt;br /&gt;
[[File:Ldcdesktop.png|800px|left|thumb|Figure 4: Virtual machine desktop]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{:Templateimpl:using | initials=DS | title=Further Information | desc=This page describes how to get started with the EMAC Virtual LDC in VirtualBox | project=OE 5.0 }}&lt;br /&gt;
Where to go next:&lt;br /&gt;
* [http://wiki.emacinc.com/wiki/Getting_Started_with_the_EMAC_OE_SDK Getting Started with the EMAC OE SDK]&lt;br /&gt;
* [http://wiki.emacinc.com/wiki/Getting_Started_With_Minicom Getting Started with Minicom]&lt;br /&gt;
* [http://wiki.emacinc.com/wiki/Getting_Started_With_Qt_Creator Getting Started with Qt Creator]&lt;/div&gt;</summary>
		<author><name>Mgloff</name></author>
		
	</entry>
</feed>