Difference between revisions of "Loading Linux Images to a Compact Flash Disk"

From wiki.emacinc.com
Jump to: navigation, search
(Begin Porting)
(Finish porting)
Line 1: Line 1:
{{todo|Port in progress|Klint Youngmeyer|project=oe 4,oe 5,ky}}
+
{{todo|Polish|Klint Youngmeyer|project=oe 4,oe 5,ky}}
  
 
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.
 
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.
 
  
 
==Necessary Tools==
 
==Necessary Tools==
 
  
 
To perform this procedure, you will need to have the following items:
 
To perform this procedure, you will need to have the following items:
Line 16: Line 14:
 
* The EMAC package which provides the <code>put-image</code> script.  The <code>README.TXT</code> file in the package details out the steps needed to install the script properly.
 
* The EMAC package which provides the <code>put-image</code> script.  The <code>README.TXT</code> file in the package details out the steps needed to install the script properly.
  
The <code>put-image</code> script, and its associated tools, can be downloaded from [[https://svn.emacinc.com/listing.php?repname=EMAC+Public+Repository&path=%2FEMAC-OE-2009.03-STABLE%2Ftrunk%2Fcontrib%2Fput-image%2F&rev=0&sc=0|EMAC's Subversion Repository]].
+
The <code>put-image</code> script, and its associated tools, can be downloaded from [https://svn.emacinc.com/listing.php?repname=EMAC+Public+Repository&path=%2FEMAC-OE-2009.03-STABLE%2Ftrunk%2Fcontrib%2Fput-image%2F&rev=0&sc=0| EMAC's Subversion Repository].
  
 
The script and its tools can be downloaded, if you have ''svn'' (Subversion) installed, by running the following command in a terminal:
 
The script and its tools can be downloaded, if you have ''svn'' (Subversion) installed, by running the following command in a terminal:
Line 22: Line 20:
 
svn co https://svn.emacinc.com/public/EMAC-OE-2009.03-STABLE/trunk/contrib/put-image/
 
svn co https://svn.emacinc.com/public/EMAC-OE-2009.03-STABLE/trunk/contrib/put-image/
 
</syntaxhighlight>
 
</syntaxhighlight>
 
 
 
When you run the above command, you should see something like this:
 
When you run the above command, you should see something like this:
<syntaxhighlight lang="bash">$ svn co https://svn.emacinc.com/public/EMAC-OE-2009.03-STABLE/trunk/contrib/put-image/
+
<syntaxhighlight lang="bash">developer@ldc:~$ svn co https://svn.emacinc.com/public/EMAC-OE-2009.03-STABLE/trunk/contrib/put-image/
 
</syntaxhighlight><syntaxhighlight lang="console">
 
</syntaxhighlight><syntaxhighlight lang="console">
 
A    put-image/date2stamp
 
A    put-image/date2stamp
Line 34: Line 30:
 
A    put-image/README.TXT
 
A    put-image/README.TXT
 
Checked out revision 175.
 
Checked out revision 175.
</syntaxhighlight><syntaxhighlight lang="bash">$</syntaxhighlight>
+
</syntaxhighlight><syntaxhighlight lang="bash">developer@ldc:~$</syntaxhighlight>
 
<br />
 
<br />
 
{{mbox | type=warning | text= '''WARNING''': Performing the following procedure incorrectly can cause a catastrophic loss of data.  The following procedure should be carefully studied prior to attempting it for the first time.<br /><br /> EMAC cannot be responsible for the loss of data which may result from incorrectly following this procedure.  EMAC strongly recommends having a current backup of the data on your computer before attempting this procedure.  Use it at your own risk.}}
 
{{mbox | type=warning | text= '''WARNING''': Performing the following procedure incorrectly can cause a catastrophic loss of data.  The following procedure should be carefully studied prior to attempting it for the first time.<br /><br /> EMAC cannot be responsible for the loss of data which may result from incorrectly following this procedure.  EMAC strongly recommends having a current backup of the data on your computer before attempting this procedure.  Use it at your own risk.}}
 
  
 
==Procedure==
 
==Procedure==
 
  
 
Perform the following steps to load the firmware onto your Compact Flash card:
 
Perform the following steps to load the firmware onto your Compact Flash card:
Line 48: Line 42:
 
* Determine where the Compact Flash card was mounted:  
 
* Determine where the Compact Flash card was mounted:  
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
$ dmesg | tail -n 10
+
developer@ldc:~$ dmesg | tail -n 10
 
</syntaxhighlight><syntaxhighlight lang="console">
 
</syntaxhighlight><syntaxhighlight lang="console">
 
[23236.042944] sdc: detected capacity change from 4110188544 to 0
 
[23236.042944] sdc: detected capacity change from 4110188544 to 0
Line 60: Line 54:
 
[23244.293651] EXT3-fs (sdc1): mounted filesystem with ordered data mode
 
[23244.293651] EXT3-fs (sdc1): mounted filesystem with ordered data mode
 
</syntaxhighlight><syntaxhighlight lang="bash">
 
</syntaxhighlight><syntaxhighlight lang="bash">
$
+
developer@ldc:~$
 
</syntaxhighlight>
 
</syntaxhighlight>
  
 
The output of the <code>dmesg</code> command tells us that the Compact Flash card, in this case, was mounted on <code>/dev/sdc1</code>, and that its device node is <code>/dev/sdc</code>.  Inspect the output shown above to see where this information came from.  The <code>/dev/</code> prefix will go before the device name, but is not shown in the output.  The letters you are looking to see will start with either <code>sd</code> or <code>hd</code>.  The third letter will specify which of these devices is assigned to the CF Card.
 
The output of the <code>dmesg</code> command tells us that the Compact Flash card, in this case, was mounted on <code>/dev/sdc1</code>, and that its device node is <code>/dev/sdc</code>.  Inspect the output shown above to see where this information came from.  The <code>/dev/</code> prefix will go before the device name, but is not shown in the output.  The letters you are looking to see will start with either <code>sd</code> or <code>hd</code>.  The third letter will specify which of these devices is assigned to the CF Card.
 
* At this point, it is wise to double check to ensure you have the correct device node for the Compact Flash card.  Specifying the wrong device node could cause a complete loss of data on your hard drive.  It is very important to be extremely careful when specifying the device node for the Compact Flash.<br /><br /> Continuing with <code>/dev/sdc1</code> as our example device node, type the following command:<syntaxhighlight lang="bash">
 
* At this point, it is wise to double check to ensure you have the correct device node for the Compact Flash card.  Specifying the wrong device node could cause a complete loss of data on your hard drive.  It is very important to be extremely careful when specifying the device node for the Compact Flash.<br /><br /> Continuing with <code>/dev/sdc1</code> as our example device node, type the following command:<syntaxhighlight lang="bash">
$ mount | grep sdc1</syntaxhighlight><syntaxhighlight lang="console">
+
developer@ldc:~$ mount | grep sdc1</syntaxhighlight><syntaxhighlight lang="console">
 
/dev/sdc1 on /media/EMAC-OE type ext3 (rw,nosuid,nodev,uhelper=udisks)</syntaxhighlight>This shows us that the device node, <code>/dev/sdc1</code>, is in fact our Compact Flash card.  We know this because:
 
/dev/sdc1 on /media/EMAC-OE type ext3 (rw,nosuid,nodev,uhelper=udisks)</syntaxhighlight>This shows us that the device node, <code>/dev/sdc1</code>, is in fact our Compact Flash card.  We know this because:
 
** It is not mounted on one of the standard Linux filesystem mountpoints, such as <code>/</code>, <code>/boot</code>, <code>/usr</code>, or <code>/home</code>.
 
** It is not mounted on one of the standard Linux filesystem mountpoints, such as <code>/</code>, <code>/boot</code>, <code>/usr</code>, or <code>/home</code>.
 
** It '''is''' mounted in the <code>/media</code> directory, where we expect it.  We may alternatively expect to see it mounted in <code>/mnt</code>, depending upon the configuration of the Linux distribution in use.
 
** It '''is''' mounted in the <code>/media</code> directory, where we expect it.  We may alternatively expect to see it mounted in <code>/mnt</code>, depending upon the configuration of the Linux distribution in use.
  
<br />{{mbox | type=notice | text='''NOTE''': Not all Linux distributions will have <code>automount</code> enabled.  If <code>automount</code> is not enabled, the device will not automatically be mounted when it is inserted into a card reader.<br /><br /> For those unfamiliar with the term <code>mount</code>, <code>mount</code>ing a device means the operating system associates one or more file paths with the filesystem(s) contained within the partition(s) of the <code>mount</code>ed device.}}
+
<br />{{mbox | type=notice | text='''NOTE''': Not all Linux distributions will have <code>automount</code> enabled.  If <code>automount</code> is not enabled, the device will not automatically be mounted when it is inserted into a card reader.<br /><br /> For those unfamiliar with the term <code>mount</code>, <code>mount</code>ing a device means the operating system associates one or more file paths with the filesystem(s) contained within the partition(s) of the <code>mount</code>ed device.}}<br />
 +
 
 +
* Use <code>fdisk -l</code> to inspect the device node:
 +
 
 +
<syntaxhighlight lang="bash">
 +
developer@ldc:~$ sudo fdisk -l /dev/sdc
 +
</syntaxhighlight><syntaxhighlight lang="console">
 +
Disk /dev/sdc: 4009 MB, 4009549824 bytes
 +
77 heads, 56 sectors/track, 1816 cylinders, total 7831152 sectors
 +
Units = sectors of 1 * 512 = 512 bytes
 +
Sector size (logical/physical): 512 bytes / 512 bytes
 +
I/O size (minimum/optimal): 512 bytes / 512 bytes
 +
Disk identifier: 0x00090707
 +
 
 +
Device Boot      Start        End      Blocks  Id  System
 +
/dev/sdc1              62    7831151    3915545  83  Linux
 +
</syntaxhighlight><syntaxhighlight lang="bash">
 +
developer@ldc:~$
 +
</syntaxhighlight>
 +
 
 +
{{mbox | type=info | text='''NOTE''': The <code>sudo</code> command is needed to run the <code>fdisk</code> command as <code>root</code>.  If you are running as the <code>root</code> user, then you will not need to use the <code>sudo</code> command.}}
 +
<br />
 +
{{mbox | type= | image=none | text='''TIP''': As can be seen from the output of the <code>fdisk -l</code> command above, the disk is 4009 MB in size, which corresponds with the size the 4 GB Compact Flash being used in this example.}}
 +
 
 +
 
 +
* The device to specify for the boot argument must also be determined prior to putting the image onto the Compact Flash card.  If you downloaded the firmware image from EMAC, there should be a text file associated with the image which tells you which device to specify for this.  If you have built your own custom image, you should use the same boot device as you used with firmware from EMAC.  In this example, we're using hardware which specifies ''/dev/hdc'' for the boot device.
 +
* Now, run the ''put-image'' script:
 +
 
 +
<syntaxhighlight lang="bash">
 +
developer@ldc:~$ /path/to/put-image --root=/dev/sdc --boot=/dev/hdc emac-firmware-image.tar.gz
 +
</syntaxhighlight>
 +
 
 +
== See Also ==
 +
 
 +
* [[EMAC_OE_Boot_Process_Customization|Linux Boot Process Customization]]
  
  
* Use ''fdisk -l'' to inspect the device node:
+
[[Category:Filesystems]]

Revision as of 16:55, 28 October 2013

TODO: {{#todo:Polish|Klint Youngmeyer|oe 4,oe 5,ky}}

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.

Necessary Tools

To perform this procedure, you will need to have the following items:

  • The Compact Flash card you wish to use to hold the firmware.
  • A Compact Flash card reader attached to your computer.
  • The firmware image.
  • A fully functional Linux desktop.
  • The package management tools installed: tar, and either gzip or bzip2 (depending on the image).
  • The EMAC package which provides the put-image script. The README.TXT file in the package details out the steps needed to install the script properly.

The put-image script, and its associated tools, can be downloaded from EMAC's Subversion Repository.

The script and its tools can be downloaded, if you have svn (Subversion) installed, by running the following command in a terminal:

svn co https://svn.emacinc.com/public/EMAC-OE-2009.03-STABLE/trunk/contrib/put-image/

When you run the above command, you should see something like this:

developer@ldc:~$ svn co https://svn.emacinc.com/public/EMAC-OE-2009.03-STABLE/trunk/contrib/put-image/
A    put-image/date2stamp
A    put-image/stamp2date
A    put-image/datediff
A    put-image/put-image
A    put-image/lilo-22.8.sbin.static.tgz
A    put-image/README.TXT
Checked out revision 175.
developer@ldc:~$


Procedure

Perform the following steps to load the firmware onto your Compact Flash card:

  • Insert the Compact Flash card into your card reader.
  • Navigate (from within the shell) to the directory which contains the firmware image you wish to use.
  • Determine where the Compact Flash card was mounted:
developer@ldc:~$ dmesg | tail -n 10
[23236.042944] sdc: detected capacity change from 4110188544 to 0
[23243.783467] sd 12:0:0:0: [sdc] 8027712 512-byte logical blocks: (4.11 GB/3.82 GiB)
[23243.785199] sd 12:0:0:0: [sdc] No Caching mode page present
[23243.785204] sd 12:0:0:0: [sdc] Assuming drive cache: write through
[23243.787314] sd 12:0:0:0: [sdc] No Caching mode page present
[23243.787326] sd 12:0:0:0: [sdc] Assuming drive cache: write through
[23243.790625]  sdc: sdc1[23244.290093] kjournald starting.  Commit interval 5 seconds
[23244.293646] EXT3-fs (sdc1): using internal journal
[23244.293651] EXT3-fs (sdc1): mounted filesystem with ordered data mode
developer@ldc:~$

The output of the dmesg command tells us that the Compact Flash card, in this case, was mounted on /dev/sdc1, and that its device node is /dev/sdc. Inspect the output shown above to see where this information came from. The /dev/ prefix will go before the device name, but is not shown in the output. The letters you are looking to see will start with either sd or hd. The third letter will specify which of these devices is assigned to the CF Card.

  • At this point, it is wise to double check to ensure you have the correct device node for the Compact Flash card. Specifying the wrong device node could cause a complete loss of data on your hard drive. It is very important to be extremely careful when specifying the device node for the Compact Flash.

    Continuing with /dev/sdc1 as our example device node, type the following command:
    developer@ldc:~$ mount | grep sdc1
    
    /dev/sdc1 on /media/EMAC-OE type ext3 (rw,nosuid,nodev,uhelper=udisks)
    
    This shows us that the device node, /dev/sdc1, is in fact our Compact Flash card. We know this because:
    • It is not mounted on one of the standard Linux filesystem mountpoints, such as /, /boot, /usr, or /home.
    • It is mounted in the /media directory, where we expect it. We may alternatively expect to see it mounted in /mnt, depending upon the configuration of the Linux distribution in use.



  • Use fdisk -l to inspect the device node:
developer@ldc:~$ sudo fdisk -l /dev/sdc
Disk /dev/sdc: 4009 MB, 4009549824 bytes
77 heads, 56 sectors/track, 1816 cylinders, total 7831152 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00090707 
  
 Device Boot      Start         End      Blocks   Id  System
/dev/sdc1              62     7831151     3915545   83  Linux
developer@ldc:~$



  • The device to specify for the boot argument must also be determined prior to putting the image onto the Compact Flash card. If you downloaded the firmware image from EMAC, there should be a text file associated with the image which tells you which device to specify for this. If you have built your own custom image, you should use the same boot device as you used with firmware from EMAC. In this example, we're using hardware which specifies /dev/hdc for the boot device.
  • Now, run the put-image script:
developer@ldc:~$ /path/to/put-image --root=/dev/sdc --boot=/dev/hdc emac-firmware-image.tar.gz

See Also