HP 16500C Hard Drive Notes

This file is part of OpenGPIB.
 For details, see http://opengpib.sourceforge.net

 Copyright (C) 2008-2009 Doug Springer <gpib a t rickyrockrat d o t net>
    OpenGPIB is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License version 3
    as published by the Free Software Foundation. Note that permission
    is not granted to redistribute this program under the terms of any
    other version of the General Public License.

    OpenGPIB is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with OpenGPIB.  If not, see <http://www.gnu.org/licenses/>.
    The License should be in the file called COPYING.

The HP 16500C has a very  interesting HDD.  It is MS-Dos Fat16, with some twists.

1) They are byte-swapped meaning every byte has to be swapped before reading/writing on a intel machine (and any Linux machine)
2) The bytes per sector is set to 32768 (for the 1.6G hdd).
3) There is no partiton table. Instead, the drive appears as a single partition. 

There is hope, however. Here is how you can extract and save the data. This all happens on a Linux box. Sorry, windows users, get a real OS. :)

Introduction to Linux

On Windows you have C: D:  until you run out of drive letters, and I don't know what the raw device access looks like. Not even sure a non-developer can access it.

On Linux, which is a form a Unix, life is much easier for these sorts of things. Free compilers, free source code, and best of all an OS that makes sense and isn't out to take over the world.

Drives are mounted somewhere on the file system, and the mother of them all is root, accessed with a /.  Just change C: to / and you've got a good start.  Since they are not drive letters anymore, how do you find your drives and use them?  Well, they are all mounted under root.  Many Linux systems choose to mount removable media under /media, and some will show up under /media/Lexar128M or some other name.  The F: drive (or whatever Windows chose to call it) is equivalent to /media/Lexar128M.

One more thing, Linux is case sensitive, so Help and help are not the same.

The other wonderful thing about Linux is that you can access a disk image (i.e. a file that contains all the bytes from your hard drive). This includes iso images, floppy images, etc. -- Even if Linux doesn't recognize it.

One further cool idea that Unix has is that everything is a file. You want to print to a screen? It's a file. You want to write to your monitor? It's a file. You want to write to your hard drive? You guessed it, file.  Everything is done with open, read, write, close, and just for those cases you want to circumvent anything, there's ioctl.

On Linux there is something called a loopback device, and it allows you to present a file as a block device (which is what hard drives are). You can do all kinds of horrible things to the block device but not actually write any data to the hard drive. It also allows you to save your drive so if you completly screw it up you can get it back.

The raw disk devices are either hdx or sdx, where x is replaced by a consecutive run of letters (sorta like Windows), however the drive is accesed in a logical manner.

Let's use sdb as an example. /dev/sdb is the whole drive. /dev/sdb1 is the first partition and so on. In Windows you would never have access to /dev/sdb.

Dump the Hard Drive

This section assumes you have and IDE adapter and/or a CF to IDE adapter if you are using a compact flash - and more importantly, know how to hook it up properly.

There is a nice utility called dd (dump data, I believe) and that's what it does (dumps data, that is).

First, dd the data from the device while byte swapping it:

  1. First, dd the data from the device while byte swapping it: dd if=/dev/sdb of=hp16500bs.img conv=swab
  2. Remove the current Linux fat drivers (called modules). This means you will have to unmount all file systems using FAT: sudo rmmod vfat fat
  3. Modify the Linux fat driver found in fs/fat/inode.c in the Linux source, or use my build. That's a separate discussion for another page (Look Here).
  4. Install the driver (covered in 3): sudo insmod fat; sudo insmod vfat
  5. Create the mount point: mkdir hp
  6. Mount the driver: sudo mount -o loop p16500bs.img hp.
  7. Make the destination directory: mkdir hp.sav
  8. Copy the files from the image: cp -r hp/* hp.sav
  9. Unmount the drive: sudo umount hp
If you want to create a backup copy of your drive, use this:
dd if=/dev/sdb of=hp16500bs.img

To create a backup copy of just the MBR, use this:
dd if=/dev/sdb of=Memorex128M.mbr bs=512 count=1

If you want to put that image back on the drive, do this:
dd if=/dev/sdb of=hp16500bs.img conv=swab
Notice the conv=swab - that byteswaps all of the bytes on the drive while it's copying. Pretty nifty if you ask me.

To zero the first 10k bytes:
dd if=/dev/zero of=/dev/sdb bs=1024 count=10

On the 256M Simple Tech CF, I did just these steps - it's quite fast and it does work.

1) Format on 16500C
2) dd if=/dev/sdb of=hp16500bs.img conv=swab
3) mount -o loop hp16500bs.img mnt
4) Copy all system files to mnt/SYSTEM, and any setup files to mnt
5) umount mnt
6) dd if=hp16500bs.img of=/dev/sdb conv=swab

A *VERY* interesting effect is that none of these cards worked with the USB-IDE adapter I used with the CF-IDE adapter.
They would timeout and give disk errors.  The Simple Tech card had no problems, so I suspect that if it works with a USB-IDE adapter it will work on the HP.

This much is working, but I don't know if the kernel developers will like my patch to the fat driver.

I have a plan to build a new working image from that file dump. It goes something like this:
  1. Format the new device using FAT16 (HDD/Compact Flash).
  2. dump the data to a file, so there's an image of that format.
  3. Mount the image and copy all the files from the old drive, or from the floppies.
  4. Unmount the image.
  5. Write a simple program that morks the FAT boot block so it fits HP's wackiness.
  6. Run said program on image.
  7. dd the image back to the device and byte swap at the same time.

Compact Flash Tested

It seems there are more that don't work than do.  I tried these:

San Disk
Works, but won't retain file data on boot. Change dir will work after a while and files will show up, but it doesn't work.
Disk timeouts on format
Same as 16M San Disk
Same as 16M San Disk
Simple Tech
It Works! Use dd to zero the start of the drive. Boot with 1st floppy disk. Format drive. Create SYSTEM directory and copy floppy files into that directory. Via FTP, that directory is /system/disk/hard/system.  But I never did get all the files copied successfully via FTP.  Instead, I mounted the the byte-swapped CF flash image copied the files over, then copied the file back using dd and swab.
Same as 16M San Disk - even tried the Simple Tech image, which means the data is exactly the same, so it's got to be the card.
Same as San Disk 16M
Most any of the SimpleTech HDDs should work. I have 64/128/256M that work. They look like this:

Here is a 64M image that can be used to test any media (Click the image above). This is a byte swapped image so that it can be read on a x86 machine. This has the latest software (V1.09) already on it. You create the Hard Drive using this command (after bunzip2 ing it):
dd if=SimpleTech64MZeroed.img.bs of=/dev/sdx conv=swab
The /dev/sdx is the device on Linux where your CF card appears. There are many adapters out there to adapt from CF to IDE-PATA, and from there are USB-IDE adapters. The most useful CF to IDE-PATA is the one that just plugs into the end of the IDE cable. You will need a Floppy Drive power adapter to go from the standard 4-Pin PC power supply to the floppy connector found on most of these CF-IDE adapters.

I just received an email from Alexandre Becoulet on using mtools to access the HDD (which, if it works, is MUCH preferrable to kernel module hacking described above):

I found a new way to access the FAT16 with non-standard sector
size which does not involve kernel hacking. Here is what I found:

The GNU mtools have support for non standard sector size.
The sector size is limited to 8192 bytes however. You have
to change this constant before building the mtools package:

./msdos.h:#define MAX_SECTOR    32768           /* largest sector size */

Then you can access the byte swapped image using your custom built mtools:

./mdir -i /tmp/hp16500bs.img

./mcopy -o -i /tmp/hp16500bs.img /tmp/PVTEST/* ::SYSTEM