Difference between revisions of "Loading Linux Images to a Compact Flash Disk"
m (Assigned MG to review this.) |
|||
Line 5: | Line 5: | ||
==Necessary Tools== | ==Necessary Tools== | ||
− | To perform this procedure, | + | To perform this procedure, the following items are required: |
− | * The Compact Flash card | + | * The Compact Flash card to hold the firmware. |
− | * A Compact Flash card reader attached to | + | * A Compact Flash card reader attached to a computer. |
* The firmware image. | * The firmware image. | ||
* A fully functional Linux desktop. | * A fully functional Linux desktop. | ||
* The package management tools installed: <code>tar</code>, and either <code>gzip</code> or <code>bzip2</code> (depending on the image). | * The package management tools installed: <code>tar</code>, and either <code>gzip</code> or <code>bzip2</code> (depending on the image). | ||
− | * The EMAC package which provides the <code>put-image</code> script. The <code>README.TXT</code> file in the package details | + | * The EMAC package which provides the <code>put-image</code> script. The <code>README.TXT</code> file in the package details 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]. | ||
− | + | If ''svn'' (Subversion) is installed on the development PC, run the following command in a terminal: | |
+ | |||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
− | svn co https://svn.emacinc.com/public/EMAC-OE-2009.03-STABLE/trunk/contrib/put-image/ | + | developer@ldc:~$ svn co https://svn.emacinc.com/public/EMAC-OE-2009.03-STABLE/trunk/contrib/put-image/ |
</syntaxhighlight> | </syntaxhighlight> | ||
− | When | + | |
− | + | ||
− | + | When the above command is run, the following will be output: | |
+ | |||
+ | <syntaxhighlight lang="console"> | ||
A put-image/date2stamp | A put-image/date2stamp | ||
A put-image/stamp2date | A put-image/stamp2date | ||
Line 30: | Line 33: | ||
A put-image/README.TXT | A put-image/README.TXT | ||
Checked out revision 175. | Checked out revision 175. | ||
− | </syntaxhighlight><syntaxhighlight lang="bash">developer@ldc:~$</syntaxhighlight> | + | </syntaxhighlight> |
− | + | <syntaxhighlight lang="bash">developer@ldc:~$</syntaxhighlight> | |
− | {{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.<br /><br /> EMAC cannot be responsible for the loss of data which may result from | + | |
+ | |||
+ | {{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.<br /><br /> 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.}} | ||
==Procedure== | ==Procedure== | ||
− | Perform the following steps to load the firmware onto | + | Perform the following steps to load the firmware onto the Compact Flash card: |
+ | |||
+ | * Insert the Compact Flash card into the card reader. | ||
+ | * Navigate (from within the shell) to the directory which contains the firmware image to be used. | ||
+ | * Determine where the Compact Flash card was mounted. | ||
− | |||
− | |||
− | |||
<syntaxhighlight lang="console"> | <syntaxhighlight lang="console"> | ||
developer@ldc:~$ dmesg | tail -n 10 | developer@ldc:~$ dmesg | tail -n 10 | ||
Line 56: | Line 62: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− | The output of the <code>dmesg</code> command | + | |
− | * At this point, it is wise to double check | + | The output of the <code>dmesg</code> command shows that the root device node for the Compact Flash card in this case is <code>sdc</code>, and that the only partition found is <code>sdc1</code>. 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 <code>/dev/</code> prefix will go before the device name, but is not shown in the output of <code>dmesg</code>. The device node 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 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. <br /><br /> Continuing with <code>/dev/sdc1</code> as the example device node, type the following command: | ||
<syntaxhighlight lang="console"> | <syntaxhighlight lang="console"> | ||
Line 64: | Line 72: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− | This shows | + | |
+ | This shows that the device node, <code>/dev/sdc1</code>, is in fact the Compact Flash card. This is 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 | + | * It '''is''' mounted in the <code>/media</code> directory, where it is expected. It may alternatively get 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 | + | <br />{{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.}}<br /> |
− | * Use <code>fdisk -l</code> to inspect the device node | + | * Use <code>fdisk -l</code> to inspect the device node. Use <code>sudo</code> with <code>fdisk</code> to gain the required <code>root</code> privileges to run <code>fdisk</code> |
<syntaxhighlight lang="console"> | <syntaxhighlight lang="console"> | ||
Line 86: | Line 95: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− | |||
− | |||
− | |||
+ | * 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 of the 4 GB Compact Flash being used in this example. | ||
+ | |||
+ | * 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 <code>fdisk -l</code> command on the target device to determine the boot device. In this example, the target hardware specifies ''/dev/hdc'' for the boot device. | ||
+ | |||
+ | * Now, run the ''put-image'' script as below. | ||
+ | ** The --root option specifies where the card is mounted. | ||
+ | ** The --boot option specifies the target boot argument. | ||
+ | ** The last option is the file name of the compressed target root filesystem. | ||
+ | |||
+ | |||
+ | After completion, the ''put-image'' script will output a message indicating success or failure. | ||
− | |||
− | |||
<syntaxhighlight lang="console"> | <syntaxhighlight lang="console"> | ||
developer@ldc:~$ /path/to/put-image --root=/dev/sdc --boot=/dev/hdc emac-firmware-image.tar.gz | developer@ldc:~$ /path/to/put-image --root=/dev/sdc --boot=/dev/hdc emac-firmware-image.tar.gz | ||
</syntaxhighlight> | </syntaxhighlight> | ||
+ | |||
+ | |||
* 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. | * 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. | ||
<syntaxhighlight lang="console"> | <syntaxhighlight lang="console"> | ||
developer@ldc:~$ mount | grep sdc1 | developer@ldc:~$ mount | grep sdc1 | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− | * If the command does not return anything, the Compact Flash card is not mounted. However, if the command returns something similar to the following listing, the card will need to be unmounted manually. | + | |
+ | |||
+ | * 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. | ||
+ | |||
<syntaxhighlight lang="console"> | <syntaxhighlight lang="console"> | ||
/dev/sdc1 on /media/EMAC-OE type ext3 (rw,nosuid,nodev,uhelper=udisks) | /dev/sdc1 on /media/EMAC-OE type ext3 (rw,nosuid,nodev,uhelper=udisks) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
+ | |||
+ | |||
* To unmount the Compact Flash card manually, run the following command: | * To unmount the Compact Flash card manually, run the following command: | ||
<syntaxhighlight lang="console"> | <syntaxhighlight lang="console"> | ||
developer@ldc:~$ umount /dev/sdc1 | developer@ldc:~$ umount /dev/sdc1 | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− | |||
== See Also == | == See Also == |
Revision as of 12:30, 17 December 2013
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.
Contents
Necessary Tools
To perform this procedure, the following items are required:
- The Compact Flash card to hold the firmware.
- A Compact Flash card reader attached to a computer.
- The firmware image.
- A fully functional Linux desktop.
- The package management tools installed:
tar
, and eithergzip
orbzip2
(depending on the image). - The EMAC package which provides the
put-image
script. TheREADME.TXT
file in the package details the steps needed to install the script properly.
The put-image
script, and its associated tools, can be downloaded from EMAC's Subversion Repository.
If svn (Subversion) is installed on the development PC, run the following command in a terminal:
developer@ldc:~$ svn co https://svn.emacinc.com/public/EMAC-OE-2009.03-STABLE/trunk/contrib/put-image/
When the above command is run, the following will be output:
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:~$
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. 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. |
Procedure
Perform the following steps to load the firmware onto the Compact Flash card:
- Insert the Compact Flash card into the card reader.
- Navigate (from within the shell) to the directory which contains the firmware image to be used.
- 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 shows that the root device node for the Compact Flash card in this case is sdc
, and that the only partition found is sdc1
. 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 /dev/
prefix will go before the device name, but is not shown in the output of dmesg
. The device node 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 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.
Continuing with/dev/sdc1
as the 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 that the device node, /dev/sdc1
, is in fact the Compact Flash card. This is 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 it is expected. It may alternatively get mounted in/mnt
, depending upon the configuration of the Linux distribution in use.
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 for more information about mounting filesystems. |
- Use
fdisk -l
to inspect the device node. Usesudo
withfdisk
to gain the requiredroot
privileges to runfdisk
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:~$
- As can be seen from the output of the
fdisk -l
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.
- 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
fdisk -l
command on the target device to determine the boot device. In this example, the target hardware specifies /dev/hdc for the boot device.
- Now, run the put-image script as below.
- The --root option specifies where the card is mounted.
- The --boot option specifies the target boot argument.
- The last option is the file name of the compressed target root filesystem.
After completion, the put-image script will output a message indicating success or failure.
developer@ldc:~$ /path/to/put-image --root=/dev/sdc --boot=/dev/hdc emac-firmware-image.tar.gz
- 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.
developer@ldc:~$ mount | grep sdc1
- 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.
/dev/sdc1 on /media/EMAC-OE type ext3 (rw,nosuid,nodev,uhelper=udisks)
- To unmount the Compact Flash card manually, run the following command:
developer@ldc:~$ umount /dev/sdc1