Difference between revisions of "Quick Reference"

From wiki.emacinc.com
Jump to: navigation, search
m (Undo revision 1707 by Mdean (talk) Marked as buggy due to needed change.)
 
(17 intermediate revisions by 4 users not shown)
Line 1: Line 1:
{{todo|Fix and Add More (11.25.13-17:30->KY+);(11.26.13-21:25->MD+)|Klint Youngmeyer|project=oe 4,oe 5,ky,buggy,md}}
+
{{todo|SEOKWREV (11.25.13-17:30->KY+);(11.26.13-21:25->MD+);(11.27.13-12:15->KY+);(12.05.13-01:00->MD+);(12.05.13-11:35-KY+);(12.19.13-13:45-MG+);(03.04.14-15:15->BS-);(03.07.14-15:35->BS+)|Klint Youngmeyer|project=oe 4,oe 5,ky,md,mg,bs,SEOKWREV}}
  
This page is a quick reference guide or a "cheatsheet" to assist with the initial learning curve. Once full familiarity with the development environment is established, this quick reference will likely no longer be needed.
+
{{#seo:
 +
|title=Quick Reference
 +
|titlemode=append
 +
|keywords=Quick Reference,Terminal,Filesystem,Network Interfaces,Remote Access
 +
|description=A quick reference guide to assist with the initial learning curve.
 +
}}
 +
This page is a quick reference guide to assist with the initial learning curve. Once full familiarity with the development environment is established, this quick reference will likely no longer be needed.
 
== Working With the Terminal ==
 
== Working With the Terminal ==
 
Use <code>minicom</code> to bring up a serial terminal.  To configure the serial console, run <code>sudo minicom -s</code>. The settings needed for configuring <code>minicom</code> can be found [[Serial_Connections|on this page]]. Select, <code>Save as dfl</code>, to save the settings you have configured to be the default settings whenever you run <code>minicom</code>.  Use <code>minicom -o</code> to start <code>minicom</code> more quickly; the <code>-o</code> option tells <code>minicom</code> to start without sending <code>AT</code> commands to initialize a modem.
 
Use <code>minicom</code> to bring up a serial terminal.  To configure the serial console, run <code>sudo minicom -s</code>. The settings needed for configuring <code>minicom</code> can be found [[Serial_Connections|on this page]]. Select, <code>Save as dfl</code>, to save the settings you have configured to be the default settings whenever you run <code>minicom</code>.  Use <code>minicom -o</code> to start <code>minicom</code> more quickly; the <code>-o</code> option tells <code>minicom</code> to start without sending <code>AT</code> commands to initialize a modem.
 +
 +
The <code>dialout</code> group, on many systems, will enable group members to use minicom without having to run it as root (without using sudo).  To add your user account, such as <code>employee</code>, to the group, run this command as the <code>root</code> user:
 +
 +
<syntaxhighlight lang="text">
 +
$ adduser employee dialout
 +
</syntaxhighlight>
  
 
== Editing a File ==
 
== Editing a File ==
Line 31: Line 43:
 
==Mounting a Flash Filesystem==
 
==Mounting a Flash Filesystem==
  
'''SINCE THIS IS A QUICK REFERENCE DOCUMENT, THIS SECTION SHOULD PROBABLY BE SPLIT OFF INTO ITS OWN PAGE.  The gist of how to do this could then be shown here, with a link to the separate document for more in-depth info.'''
+
<!--'''SINCE THIS IS A QUICK REFERENCE DOCUMENT, THIS SECTION SHOULD PROBABLY BE SPLIT OFF INTO ITS OWN PAGE.  The gist of how to do this could then be shown here, with a link to the separate document for more in-depth info.'''-->
  
 
There are four steps to mounting a flash filesystem on our EMAC OE machine:
 
There are four steps to mounting a flash filesystem on our EMAC OE machine:
 
<cl>
 
<cl>
 
1. Determine which device node is assigned to the flash device.
 
1. Determine which device node is assigned to the flash device.
 +
<syntaxhighlight lang=console>root@emac-oe:~# dmesg | tail -n 15</syntaxhighlight>
 
* Determine which partition to mount.
 
* Determine which partition to mount.
 
* Determine where to mount the device.
 
* Determine where to mount the device.
 +
<syntaxhighlight lang=console>root@emac-oe:~# mkdir /mnt/myflash</syntaxhighlight>
 
* Mount the device.
 
* Mount the device.
 +
<syntaxhighlight lang=console>root@emac-oe:~# mount /dev/sda1 /mnt/myflash</syntaxhighlight>
 
</cl>
 
</cl>
 
<br clear=all>
 
<br clear=all>
 
{{mbox  | type=notice | text='''NOTE''': You '''must''' have <code>root</code> permissions to perform some of the following steps.  Make sure you are logged in as the <code>root</code> user prior to performing the following steps.  The <code>su</code> command can be useful for this.  The filesystem will also need to be mounted read/write in order to create the directory mentioned below.  See the section regarding remounting the root filesystem as read/write (above) to see how to do this.}}
 
{{mbox  | type=notice | text='''NOTE''': You '''must''' have <code>root</code> permissions to perform some of the following steps.  Make sure you are logged in as the <code>root</code> user prior to performing the following steps.  The <code>su</code> command can be useful for this.  The filesystem will also need to be mounted read/write in order to create the directory mentioned below.  See the section regarding remounting the root filesystem as read/write (above) to see how to do this.}}
 
<br clear=all>
 
<br clear=all>
===Determining the Device Node Assigned to the Flash Device===
 
The easiest way to determine which device node is assigned to a particular flash device is to inspect the output of the ''dmesg'' command shortly after the device has been connected to your machine.  Follow these steps to do so:
 
<cl>
 
1. Insert the SD, CF or microSD card or plug in the USB flash device to your EMAC OE machine.
 
* Wait a few seconds for the device to settle and be recognized by the OS.
 
* Run this command at at shell on your EMAC OE machine: <br clear=all> <syntaxhighlight lang=console>root@emac-oe:~# dmesg | tail -n 15</syntaxhighlight>
 
* Inspect the output. The output should look similar to the following:
 
 
<syntaxhighlight lang=console>
 
usb 2-2: new full speed USB device using at91_ohci and address 2
 
usb 2-2: not running at top speed; connect to a high speed hub
 
usb 2-2: configuration #1 chosen from 1 choice
 
scsi0 : SCSI emulation for USB Mass Storage devices
 
usb-storage: device found at 2
 
usb-storage: waiting for device to settle before scanning
 
scsi 0:0:0:0: Direct-Access              Patriot Memory  PMAP PQ: 0 ANSI: 4
 
usb-storage: device scan complete
 
sd 0:0:0:0: [sda] 15634432 512-byte hardware sectors: (8.00 GB/7.45 GiB)
 
sd 0:0:0:0: [sda] Write Protect is off
 
sd 0:0:0:0: [sda] Mode Sense: 23 00 00 00
 
sd 0:0:0:0: [sda] Assuming drive cache: write through
 
sd 0:0:0:0: [sda] Assuming drive cache: write through
 
sda: sda1
 
sd 0:0:0:0: [sda] Attached SCSI removable disk
 
</syntaxhighlight>
 
 
Inside square brackets, we see <code>sda</code>.  This is the root device node assigned to our flash device.
 
</cl>
 
===Determine Which Partition to Mount===
 
On a line by itself, we see:
 
<syntaxhighlight lang=console>sda: sda1</syntaxhighlight>
 
This means one partition was found on our device: ''sda1''.  This is the partition we will use.
 
 
<br clear=all>{{mbox | type=notice | text='''NOTE''': If there is more than one partition, you will need to decide which partition to use based on your knowledge of the paritions on the device.  The partition device node assignment will be listed in order in the output above.  If the first partition is <code>sda1</code>, and the second one is <code>sda5</code>, that is not an error.  Only 4 ''primary partitions'' can exist on a device.  If the second partition is number 5, that means it was created as an ''extended partition''.}}
 
<br clear=all>
 
===Determine Where to Mount the Device===
 
Now that we know what device node we are going to mount, we need to determine where to mount it.  The <code>/mnt</code> directory is typically used for this (<code>mnt</code> is short for ''mount'').
 
 
Create a directory to use for the mountpoint:
 
 
<syntaxhighlight lang=console>root@emac-oe:~# mkdir /mnt/myflash</syntaxhighlight>
 
 
Alternatively, you can pick another place in the filesystem to use.  Just make sure you have permission to create a directory in that location.  If the directory contains files, it will still be used as the mountpoint when the ''mount'' command is issued; however, the files contained in the directory will be hidden for as long as the directory is in use as a mountpoint.  This could create a great deal of confusion, so beware this potential pitfall.
 
 
<br clear=all>{{mbox | type=notice | text='''NOTE''' The ''mountpoint'' (where a device is mounted) is the directory which is used to host the root of the filesystem located on the partition.  In other words, if this were a machine running an operating system from Microsoft, the ''mountpoint'' would be a drive letter such as <code>D:</code> or <code>Z:</code>.  In Linux (and Unix), there are no drive letters.  Directories are used instead.  Beneficially, using directories instead of drive letters makes things more consistent (and therefore simpler) from a programming standpoint.}}<br clear=all>
 
  
===Mount the Device===
+
For detailed instructions, please see the [[Mounting a Flash Filesystem]] page.
Now that ''sda1'' has been determined to be the partition to mount and ''/mnt/myflash'' has been created to be used as the mountpoint, we can mount our flash device with the following command:
 
 
 
<syntaxhighlight lang=console>root@emac-oe:~# mount /dev/sda1 /mnt/myflash</syntaxhighlight>
 
 
 
If no message is returned from the above command, then it succeeded.  To verify this, try the following command
 
 
 
<syntaxhighlight lang=console>root@emac-oe:~# mount | grep sda1</syntaxhighlight>
 
 
 
You should see your device listed in the output of the above command.  If it is listed more than once, it may have been mounted automatically by the OS.  If so, inspection of the output should show you where it was mounted.
 
<br clear=all>{{mbox | type=notice | text='''NOTE''': If the device node was something other than <code>sda1</code>, then replace <code>sda1</code> in the command above with the device node you determine for your flash device in the ''Determine Which Partition to Mount'' section above.}}<br clear=all>
 
 
 
===Unmounting the Filesystem After Use===
 
After you are finished using the flash device, you may wish to unmount it (similar to "Safely Removing" a device on other operating systems).  The ''umount'' command is used for this purpose.
 
 
 
Continuing on with the example above, the device mounted above would be unmounted with the following command:
 
 
 
<syntaxhighlight lang=console>root@emac-oe:~# umount /mnt/myflash</syntaxhighlight>
 
 
 
If it was automounted elsewhere, it will also need to be unmounted from that mountpoint before it will be safe to remove the device.  For instance, if the automounter mounted it on ''/media/sda1'', then issue the following command:
 
<syntaxhighlight lang=console>root@emac-oe:~# umount /media/sda1</syntaxhighlight>
 
 
 
<br clear=all>{{mbox | typ=notice | text='''TIP''': The <code>sync</code> command can also be handy for ensuring data written to a device is flushed to disk prior to performing some other activity with the device.}}<br clear=all>
 
  
 
== Network Interfaces ==
 
== Network Interfaces ==
Line 151: Line 99:
 
developer@ldc:~# scp example.text root@10.0.2.41:/home
 
developer@ldc:~# scp example.text root@10.0.2.41:/home
 
</syntaxhighlight>
 
</syntaxhighlight>
 +
 +
To send the file ''example.txt'' to the home directory of the user account you're using to connect to a remote machine located at machine.example.com, enter the following command:
 +
<syntaxhighlight lang=console>
 +
developer@ldc:~# scp example.txt root@machine.example.com:
 +
</syntaxhighlight>
 +
 +
''Note the colon at the end with nothing following it.  This also works with IP addresses.''
  
 
== Running a User Program ==
 
== Running a User Program ==
Line 168: Line 123:
 
</syntaxhighlight>
 
</syntaxhighlight>
 
</cl>
 
</cl>
 +
 +
 
==See Also==
 
==See Also==
  
Line 174: Line 131:
  
  
[[Category: Support]]
+
<!-- [[Category: Support]] -->

Latest revision as of 14:46, 14 March 2014

TODO: {{#todo:SEOKWREV (11.25.13-17:30->KY+);(11.26.13-21:25->MD+);(11.27.13-12:15->KY+);(12.05.13-01:00->MD+);(12.05.13-11:35-KY+);(12.19.13-13:45-MG+);(03.04.14-15:15->BS-);(03.07.14-15:35->BS+)|Klint Youngmeyer|oe 4,oe 5,ky,md,mg,bs,SEOKWREV}}

This page is a quick reference guide to assist with the initial learning curve. Once full familiarity with the development environment is established, this quick reference will likely no longer be needed.

Working With the Terminal

Use minicom to bring up a serial terminal. To configure the serial console, run sudo minicom -s. The settings needed for configuring minicom can be found on this page. Select, Save as dfl, to save the settings you have configured to be the default settings whenever you run minicom. Use minicom -o to start minicom more quickly; the -o option tells minicom to start without sending AT commands to initialize a modem.

The dialout group, on many systems, will enable group members to use minicom without having to run it as root (without using sudo). To add your user account, such as employee, to the group, run this command as the root user:

$ adduser employee dialout

Editing a File

EMAC OE provides simple text editing capabilities for making changes to configuration files and scripts. Major editing tasks should be performed on a desktop system first, copying the desired files back to the target board. There are two text editors available on standard EMAC OE builds: vi and nano. vi is a very common text editor available on almost every Unix-like OS. nano is a more conventional text editor that can be easier to use for those not familiar with vi.

To edit a file with vi, run the command:

root@emac-oe:~# vi <filename>

To edit a file with nano, run the command:

root@emac-oe:~# nano <filename>

For a more detailed overview, see this page

Making Changes To The Target Machine's Fileystem

By default, the flash filesystem on most EMAC devices is mounted read-only. To make changes to the filesystem, it will have to be remounted as read-write. This can be done with the following command:

root@emac-oe:~# mount -o remount,rw /

To mount the filesystem as read-only again (without rebooting), type:

root@emac-oe:~# mount -o remount,ro /

Mounting a Flash Filesystem

There are four steps to mounting a flash filesystem on our EMAC OE machine:

  1. Determine which device node is assigned to the flash device.

    root@emac-oe:~# dmesg | tail -n 15
    
  2. Determine which partition to mount.

  3. Determine where to mount the device.

    root@emac-oe:~# mkdir /mnt/myflash
    
  4. Mount the device.

    root@emac-oe:~# mount /dev/sda1 /mnt/myflash
    



For detailed instructions, please see the Mounting a Flash Filesystem page.

Network Interfaces

The ifup and ifdown commands may be used to enable (or, respectively, disable) network interfaces based on interface definitions in the file /etc/network/interfaces.

An example of using the ifup command:

root@emac-oe:~# ifup eth0

An example of using the ifdown command:

root@emac-oe:~# ifdown eth0

To temporarily configure the eth0 interface to have a static IP address, 192.168.1.125, to use a DNS server at 192.168.1.25, and to use a gateway at 192.168.1.1:

root@emac-oe:~# ifconfig eth0 up 192.168.1.125 netmask 255.255.255.0
root@emac-oe:~# route add default gw 192.168.1.1
root@emac-oe:~# echo "nameserver 192.168.1.25" > /etc/resolv.conf

Remote Access

To access an EMAC product remotely, it is easiest to use ssh and scp for remote command execution and remote file transfer respectively.

To log into a system with the IP address 10.0.2.41, enter the following command:

developer@ldc:~# ssh root@10.0.2.41

To execute a command on a remote system without opening a shell on the remote system (in this example, ls -la):

developer@ldc:~# ssh root@10.0.2.41 'ls -la'

To send the file example.text to the /home directory of a system with the IP address 10.0.2.41, enter the following command:

developer@ldc:~# scp example.text root@10.0.2.41:/home

To send the file example.txt to the home directory of the user account you're using to connect to a remote machine located at machine.example.com, enter the following command:

developer@ldc:~# scp example.txt root@machine.example.com:

Note the colon at the end with nothing following it. This also works with IP addresses.

Running a User Program

When a user program is uploaded, sometimes it does not have execute permissions. Use the following steps to ensure that your program functions properly.

  1. Navigate to the directory that the application was uploaded to (e.g. /tmp):

    root@emac-oe~:$ cd /tmp
    
  2. Make the application file executable:

    root@emac-oe~:$ chmod u+x <filename>
    
  3. Run the application:

    root@emac-oe~:$ ./<filename>
    


See Also