IDE-SD adapter question

Maciej W. Rozycki macro at linux-mips.org
Fri Jun 26 20:14:36 CDT 2020


On Fri, 26 Jun 2020, W2HX via cctech wrote:

> Thanks for previous help on this project. I am working on an old 486 
> computer and I have replaced a 40 pin IDE hard drive with this SD 
> adapter...
> https://www.amazon.com/gp/product/B07G29TZPS/ref=ppx_yo_dt_b_asin_title_o01_s00?ie=UTF8&psc=1

 There is a worrisome note there about the requirement to use the LBA 
rather than CHS storage device addressing mode with the adapter.  A PC 
BIOS that old may not support LBA.

 IIRC the two modes are told apart by a bit set in one of the ATA control 
registers used to select the sector to perform an operation on.  If that 
bit is silently ignored by the adapter's firmware, then the storage device 
may appear to work, however CHS sector addresses presented by the PC BIOS 
will not correspond to LBA sector addresses interpreted by the firmware.  
Consequently things will undoubtedly break and data corruption will likely 
happen sooner or later, depending on whether the OS installed uses the PC
BIOS interface or has its own driver using LBA.  Also accesses to 
inexistent sectors may be attempted.

 An additional complication is that the PC BIOS CHS API, which predates 
ATA and has been designed with MFM and ESDI disks in mind, has a range 
mismatch with the ATA CHS API.  Consequently the CHS sector range 
accessible via the PC BIOS is limited to the intersection of the two 
ranges.  Once LBA support has become available in PC BIOS implementations 
for ATA storage devices a translation scheme was introduced so that the 
full range of the PC BIOS CHS API could be used by the OS.

> In general it seems to mostly be working. I can see a directory listing 
> of several thousands files located on a 2GB SD card from yesteryear. The 
> SD card was new when I installed it (has been in my possession for 
> years).

 What OS do you use that works with the 2GB SD card correctly?

> However, I do get errors "sector not found" and if I A)bort I get INT 24 
> error.  I am trying to get windows 95 installed and this is certainly 
> preventing that.

 INT 24 is the software interrupt invoked by DOS for I/O error recovery, 
the handler of which asks the user how to proceed.  I gather you're using 
DOS then?

> In the BIOS settings I have the hard drive set as "USER" and these parameters:
> CY:[1024] HD:[16] ST:[63] LZ:[1024] WP:[0]
> These were the parameters in use while I was still using the actual hard 
> drive.

 These are the intersection of the maximum values both the PC BIOS and ATA 
supported, which corresponds to 528MB (or 504MiB); for a 2GB ATA storage 
device that's the best you can do here.

 All but some very early ATA disks actually report their CHS configuration 
via the ATA IDENTIFY DEVICE command.  Unfortunately it took years for PC 
BIOS implementers to discover the existence of that command and add an 
auto-detect feature.  Software exists for various OSes that can retrieve 
and print ATA IDENTIFY DEVICE information in a human parseable format, 
e.g. with my non-LBA disk from 1993 I get:

/dev/hda:

ATA device, with non-removable media
	Model Number:       Maxtor 7245 AT                          
	Serial Number:      [...]
	Firmware Revision:  6ADF1E57
Standards:
	Likely used: 1
Configuration:
	hard sectored
	not MFM encoded 
	head switch time > 15us
	fixed drive
	disk xfer rate > 5Mbs, <= 10Mbs
	format speed tolerance gap reqd
	Logical		max	current
	cylinders	967	967
	heads		16	16
	sectors/track	31	31
	--
	bytes/track: 19778	bytes/sector: 638
	CHS current addressable sectors:     479632
	device size with M = 1024*1024:         234 MBytes
	device size with M = 1000*1000:         245 MBytes 
Capabilities:
	no IORDY
	Buffer type: 0003: dual port, multi-sector with read caching ability
	Buffer size: 64.0kB	bytes avail on r/w long: 11
	Can perform double-word IO
	R/W multiple sector transfer: Max = 32	Current = ?
	DMA: sdma2
	PIO: pio0 pio1 pio2 

(this is output from the `hdparm -I' command on Linux).

> Question 1: Now that I am using an SD card instead of an IDE drive, 
> what, if anything, should I be doing with these BIOS parameters?

 You will need them for the bootloader, which will use PC BIOS calls to 
load the OS, and possibly also the OS itself.  Unless your PC BIOS does 
LBA this generally means you'll have to partition the boot storage device 
and keep the boot partition within the first 528MB of the device.  The 
rest can be used as a second partition, provided that the OS has its own 
ATA driver and does not use the PC BIOS to access the device; otherwise 
it'll remain inaccessible.

> Question 2: The BIOS has an option to format the hard drive. Should I 
> format the SD card using this facility?

 I doubt it.  The operation was meant for magnetic media, to set up tracks 
and sectors across the device, like with floppy disks (DOS nomenclature, 
where formatting, depending on the context have meant both actual medium 
formatting and filesystem creation, or the latter only, caused further 
confusion).  AFAIK for ATA devices a format command interface has never 
been standardised, though a FORMAT TRACK command code has been reserved.

 This was partially due to zone bit recording most (though not all) ATA 
disks used, however SCSI actually defined an interface also for ZBR disks, 
and I used it in the past (this was a way to set up a non-standard sector 
size some SCSI disks supported, in particular for RAID preparation with a 
hardware RAID controller).  MFM and ESDI disks did support formatting 
normally as they didn't support ZBR and therefore the interface was 
straightforward, like with floppy media.

> I did not explicitly put a filesystem on that SD card. I placed it in a 
> windows 7 machine, it was recognized, and I began copying files to it. I 
> then place the SD card into the 486 machine where I saw the sector not 
> found errors.

 Indeed that seems likely due to the mismatch between LBA and CHS 
addressing.  Making a piece of software retrieve ATA IDENTIFY DEVICE 
information might help determining whether the adapter supports CHS 
addressing properly.  If not, then you may have to find another adapter.

 HTH,

  Maciej


More information about the cctalk mailing list