Compact Flash
October 23, 2004
Introduction
This document describes how to prepare
a compact flash memory for use with the ICON. Three procedures are described:
-
How to take a functional compact flash disk
and copy the image to a Linux PC disk file for backup.
-
How to copy this backup compact flash image
from the Linux PC to a compact flash card.
-
How to build a compact flash image from scratch.
-
Can be used to conserve space since as compact
flash images get larger they waste more PC hard disk space.
-
You can create a compact flash system on any
size compact flash. (So far we have used 32 and 64mB. In the future you
may want to go to 128, 256, 512 or 1024 mB.)
Prepare the compact flash
reader
These procedures all require a USB compact
flash reader.
-
Plug the reader into any available USB connector
on the Linux PC.
-
It will appear as /dev/sda or /dev/sdb.
-
Plug a compact flash card into the compact
flash reader.
-
To verify that you can "see" the flash card
enter: fdisk /dev/sda.
-
It should respond with some information about
an attached removable scsi device and then run fdisk which will give "Command
(m for help):"
-
If it can't find your flash disk it will respond
with "Unable to open /dev/sda".
-
If this occurs try fdisk /dev/sdb.
-
It should find your device at one location
or another.
-
Then type "q" and "Enter" to exit fdisk since
we were simply verifying that we could find the device.
-
Throughout the rest of these directions I
assume sda. Simply change to sdb if that is where your compact flash was
found.
Read a functional compact
flash disk and copy the image to a Linux PC disk file
Let's assume that you have a compact flash
that is operating in an ICON. You can add whatever icon programs (*.icn)
you wish. You can update iconexe to the latest version (currently 0.656).
Now to make an image copy on your Linux PC so you can duplicate this compact
flash over and over proceed as follows:
-
If the compact flash is in a running ICON
you need to stop the ICON. The safest way is to go into program mode, select
the Password/system entry from the "System Parameter Config" drop down
menu at the top right on the "Program View" tab.
-
Make sure "Watchdog type" is set to "Elan520".
If not, set it now and click "Update".
-
Now select "Reset system" from the "Watchdog"
entry on the "System Parameter Config" drop down menu.
-
Click "OK".
-
Your connection to the ICON will immediately
be terminated.
-
This will cause the ICON to reboot in about
20 seconds. It will be completely rebooted by 34 seconds.
-
Therefore, turn the power to the ICON off
about 25 seconds after you do a system reset.
-
With the ICON power off, remove the compact
flash card.
-
Insert the compact flash card into the compact
flash reader connected to the linux PC.
-
Create a sub directory for compact flash images
on your Linux PC.
-
I suggest /home/flash_images or something
similar and change to that directory.
-
Choose a name for your image and it should
include the compact flash size. For example "wtcmaster64.img".
-
Now copy the image from the flash card to
the pc file with Linux command : "dd if=/dev/sda of=wtcmaster64.img".
-
"if" means input file and "of" means output
file.
-
It will take a while for this copy to occur
so be sure and wait till you get a message "XXXX+0 records in" and "XXX+0
records out" and the command prompt # has appeared.
-
You may remove the compact flash. (You do
not need to do a mount or a umount.)
Write a compact flash
image on the Linux PC to a compact flash card
This is the reverse of the previous operation
and allows you to create as many ICON functional compact flash cards as
you wish. It does not matter what is on your flash card to start with.
Everything will be overwritten with the new image.
-
Insert the compact flash card into the compact
flash reader/writer connected to the linux PC.
-
Change to the directory containing the file
with your flash image.
-
The new compact flash must be the same size
as the flash card used to make the image.
-
Now copy this image with the command: "dd
if=wtcmaster64.img of=/dev/sda.
-
It will take even longer to write a compact
flash so be sure and wait till you get a message "XXXX+0 records in" and
"XXX+0 records out" and the command prompt # has appeared.
-
You may remove the flash card. (You do not
need to do a mount or a umount.)
-
You can then insert the flash card into a
new ICON and power up the system.
Build a compact flash image
If you need to create a new image on a
larger compact flash or you want to just store the basic information of
an ICON compact flash image you can execute the following procedure. Remember,
compact flash images as stored in the preceding sections are the full size
of the compact flash even though most of the flash has not been used for
files yet. Therefore there is a huge amount of wasted space on your hard
disk. And as the images get larger, 128mB, 256 mB etc., they waste more
and more space.
This procedure requires the following steps:
-
Partition your flash disk with fdisk.
-
Create a "minix" file system with mkfs.minix.
-
Mount the flash disk so Linux "sees" it as
a normal Linux disk.
-
Copy over a directory structure (the root
file system for the compact flash) from your linux hard disk to the flash
disk. (This file directory structure is originally retrieved from a functional
ICON flash disk.)
-
You run a program called "lilo" to make this
new flash disk "bootable".
-
You umount the flash disk and run it
in an ICON.
The above directory structure that you will
create on your linux PC hard drive (root file system) is the same size
no matter what size the compact flash that you copy it to will be. You
may also manipulate this directory structure directly on the Linux PC adding,
deleting or updating any programs, files or the Linux kernel itself in
any sub directories (not just *.icn and iconexe programs that are located
in /home/icon).
The first step is to create the root file
system on your Linux PC:
-
Obtain an ICON functional compact flash.
-
Insert into your compact flash reader connected
to the Linux PC.
-
Make sure you have a sub directory under /mnt
called sda. Therefore /mnt/sda will exist.
-
Mount the flash disk with: mount /dev/sda1
/mnt/sda. (Notice this time its sda1 and not sda. sda1 means mount partition
1 on device sda.)
-
Go to the flash disk root directory with:
"cd /mnt/sda".
-
You may do an "ls" to look at the contents
of the root of your flash disk.
-
Next create a sub directory to contain your
root directory on your Linux PC hard disk. A good choice would be under
your images sub directory (for instance /home/flash_images/icon_root).
-
Now change to this sub directory with "cd
/home/flash_images/icon_root".
-
Next copy the entire directory structure from
your flash card to this location with: "cp /mnt/sda/* . -R". This means
copy everything from the flash card where the root is at /mnt/sda/ to the
current directory "." and the -R means recursively (do all sub directories
under the root).
-
You now have a copy of the entire directory
structure with contents on your Linux PC hard disk.
-
Unmount the flash disk with: "umount /dev/sda1".
(Warning, you must not be in any sub directories on the flash disk or you
can't unmount it. You can do a "cd /" to ensure you are not in a flash
disk directory.)
-
Remove the compact flash and insert your new
one (which might be of larger capacity).
-
Partition the new flash disk with: "fdisk
/dev/sda"
-
Enter command "p" to view current partitions.
If it is a newly purchased flash card it probably has a DOS partition (fat).
-
Enter command "d" to delete the partition.
Then enter 1 to delete the first partition. Repeat if there are other partitions.
-
Do a "p" command to make sure there are no
partitions.
-
Enter command "n" to create your new partition.
-
Enter "p" for primary partition.
-
Enter "1" to create partition 1.
-
Press "Enter" for first and last cylinders
to default to using the entire flash disk.
-
Enter "t" to change the partition type.
-
Enter "1" for partition 1.
-
Enter "81" to select a "Minix" file system.
-
Enter "a" to make it bootable.
-
Enter "1" to select partition 1.
-
Enter "p" to verify it is configured correctly.
-
Enter "w" to write the information to the
flash card.
-
Make a Minix file system with: "mkfs.minix
/dev/sda1".
-
Now mount this flash disk with: mount /dev/sda1
/mnt/sda. (You can do a cd /mnt/sda/ to view the contents. Notice it is
empty.)
-
Return to the root on your hard disk with
"cd /home/flash_images/icon_root" if you are not already there.
-
Copy to the new flash disk with: "cp * /mnt/sda/
-R". (This says copy all the files from the current location to /mnt/sda/
which is your new flash disk and the -R (recursive) means do all the sub
directories too.
-
Use "cd /mnt/sda/sbin" to move to the sbin
sub directory on your flash disk.
-
Run command "./lilo -C /mnt/sda/etc/lilo.conf"
to write to your flash boot sector. (It will respond with "Added linux
*".)
-
Do a "cd /" to get out of your flash disk.
-
Unmount the flash disk with: "umount /dev/sda1".
-
You may remove the flash card and insert into
a new ICON and power up the system.