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:

  1. How to take a functional compact flash disk and copy the image to a Linux PC disk file for backup.
  2. How to copy this backup compact flash image from the Linux PC to a compact flash card.
  3. How to build a compact flash image from scratch.
    1. Can be used to conserve space since as compact flash images get larger they waste more PC hard disk space.
    2. 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.
  1. Plug the reader into any available USB connector on the Linux PC.
  2. It will appear as /dev/sda or /dev/sdb.
  3. Plug a compact flash card into the compact flash reader.
  4. To verify that you can "see" the flash card enter: fdisk /dev/sda.
  5. It should respond with some information about an attached removable scsi device and then run fdisk which will give "Command (m for help):"
  6. If it can't find your flash disk it will respond with "Unable to open /dev/sda".
  7. If this occurs try fdisk /dev/sdb.
  8. It should find your device at one location or another.
  9. Then type "q" and "Enter" to exit fdisk since we were simply verifying that we could find the device.
  10. 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:
  1. 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.
  2. Make sure "Watchdog type" is set to "Elan520". If not, set it now and click "Update".
  3. Now select "Reset system" from the "Watchdog" entry on the "System Parameter Config" drop down menu.
  4. Click "OK".
  5. Your connection to the ICON will immediately be terminated.
  6. This will cause the ICON to reboot in about 20 seconds. It will be completely rebooted by 34 seconds.
  7. Therefore, turn the power to the ICON off about 25 seconds after you do a system reset.
  8. With the ICON power off, remove the compact flash card.
  9. Insert the compact flash card into the compact flash reader connected to the linux PC.
  10. Create a sub directory for compact flash images on your Linux PC.
  11. I suggest /home/flash_images or something similar and change to that directory.
  12. Choose a name for your image and it should include the compact flash size. For example "wtcmaster64.img".
  13. Now copy the image from the flash card to the pc file with Linux command : "dd if=/dev/sda of=wtcmaster64.img".
  14. "if" means input file and "of" means output file.
  15. 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.
  16. 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.
  1. Insert the compact flash card into the compact flash reader/writer connected to the linux PC.
  2. Change to the directory containing the file with your flash image.
  3. The new compact flash must be the same size as the flash card used to make the image.
  4. Now copy this image with the command: "dd if=wtcmaster64.img of=/dev/sda.
  5. 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.
  6. You may remove the flash card. (You do not need to do a mount or a umount.)
  7. 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:

  1. Partition your flash disk with fdisk.
  2. Create a "minix" file system with mkfs.minix.
  3. Mount the flash disk so Linux "sees" it as a normal Linux disk.
  4. 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.)
  5. You run a program called "lilo" to make this new flash disk "bootable".
  6. 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:

  1. Obtain an ICON functional compact flash.
  2. Insert into your compact flash reader connected to the Linux PC.
  3. Make sure you have a sub directory under /mnt called sda. Therefore /mnt/sda will exist.
  4. 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.)
  5. Go to the flash disk root directory with: "cd /mnt/sda".
  6. You may do an "ls" to look at the contents of the root of your flash disk.
  7. 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).
  8. Now change to this sub directory with "cd /home/flash_images/icon_root".
  9. 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).
  10. You now have a copy of the entire directory structure with contents on your Linux PC hard disk.
  11. 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.)
  12. Remove the compact flash and insert your new one (which might be of larger capacity).
  13. Partition the new flash disk with: "fdisk /dev/sda"
    1. Enter command "p" to view current partitions. If it is a newly purchased flash card it probably has a DOS partition (fat).
    2. Enter command "d" to delete the partition. Then enter 1 to delete the first partition. Repeat if there are other partitions.
    3. Do a "p" command to make sure there are no partitions.
    4. Enter command "n" to create your new partition.
    5. Enter "p" for primary partition.
    6. Enter "1" to create partition 1.
    7. Press "Enter" for first and last cylinders to default to using the entire flash disk.
    8. Enter "t" to change the partition type.
    9. Enter "1" for partition 1.
    10. Enter "81" to select a "Minix" file system.
    11. Enter "a" to make it bootable.
    12. Enter "1" to select partition 1.
    13. Enter "p" to verify it is configured correctly.
    14. Enter "w" to write the information to the flash card.
  14. Make a Minix file system with: "mkfs.minix /dev/sda1".
  15. 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.)
  16. Return to the root on your hard disk with "cd /home/flash_images/icon_root" if you are not already there.
  17. 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.
  18. Use "cd /mnt/sda/sbin" to move to the sbin sub directory on your flash disk.
  19. Run command "./lilo -C /mnt/sda/etc/lilo.conf" to write to your flash boot sector. (It will respond with "Added linux *".)
  20. Do a "cd /" to get out of your flash disk.
  21. Unmount the flash disk with: "umount /dev/sda1".
  22. You may remove the flash card and insert into a new ICON and power up the system.