Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CHS (pre-LBA drives) #3

Open
edescourtis opened this issue Aug 28, 2021 · 6 comments
Open

CHS (pre-LBA drives) #3

edescourtis opened this issue Aug 28, 2021 · 6 comments

Comments

@edescourtis
Copy link

edescourtis commented Aug 28, 2021

I realise that this project doesn't currently have many practical uses since a simple USB to IDE adapter will do a much better job. But we could make this project useful by adding support for hard drives without LBA support. Early IDE drives are not readable by most modern IDE interfaces and this can be a pain for vintage computer owners, by adding support for those drives this immediately becomes a useful project to a lot of people.

As a first step we could allow manual configuration of drives similar to an old BIOS type 1-46 + a custom parameter mode. And later also detect pre-LBA drives with autodetect parameters.

I am more than happy to help with this.

@Manawyrm
Copy link
Owner

Hm, I do have quite a collection of old hardware, but I don't seem to have any HDDs old enough to only support CHS, not LBA.
Not sure, how CHS is handled in the Linux kernel (if at all?), but the 3 registers LBAH, LBAM, LBAL are used for Cylinder, Heads and Sectors instead. The kernel can specify these registers directly, so if it wanted, my driver should (?!) be able to handle CHS.

Please feel free to test this yourself, you don't need the fancy PCB, just plug some wires (and ideally the resistors, not 100% strictly required though) into the GPIOs and you should be good to go.

I'd be happy to accept PRs fixing issues regarding CHS.

@fonic
Copy link

fonic commented Jan 2, 2022

I have a Conner CP30254 (252 MB, ca. 1992) that I'd really like to access. This project would be perfect for this.

AFAICT, the Linux kernel is (still) fully aware of CHS, see these source files of the 5.10 LTS branch (search for CHS):

libata:
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/tree/Documentation/driver-api/libata.rst?h=v5.10
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/tree/include/linux/libata.h?h=v5.10
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/tree/drivers/ata/libata-core.c?h=v5.10

ide (legacy, deprecated, removed in 5.13+):
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/tree/Documentation/ide/ide.rst?h=v5.10
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/tree/drivers/ide/ide-disk.c?h=v5.10
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/tree/drivers/ide/ide.c?h=v5.10

Your pata-gpio hooks into libata, right? So CHS drives would probably just work out of the box? What do you think?

@fonic
Copy link

fonic commented Jan 2, 2022

The only thing I'm unsure of is how one would specify the drive geometry for libata. The legacy driver offers ide_core.chs=[interface_number.device_number]:cyls,heads,sects, but I was unable to find similar parameters for libata.

Old drives like mine do not support any auto-detection - I clearly remember having to enter (or select) the correct CHS values for the drive within the BIOS.

@Manawyrm
Copy link
Owner

Manawyrm commented Jan 2, 2022

Not sure if something still might be parsing the ide_core parameters… I‘d give it a try.

My driver is very low level and only handles the raw communication and setting of registers, everything else is done by libata.

Not sure if anyone has ever used libata with a CHS drive…

I have been looking for some very old pre-LBA drives in my collection over Christmas, but I wasn‘t able to find one that doesn‘t support autodetection.

@fonic
Copy link

fonic commented Jan 2, 2022

Not sure if something still might be parsing the ide_core parameters… I‘d give it a try.

I've studied the kernel sources for quite a bit - the ide_core parameters are only parsed by the legacy driver (i.e. the one activated by configuration item Device Drivers -> ATA/ATAPI/MFM/RLL support (DEPRECATED)).

libata has its own set of parameters, defined here. Manually setting CHS drive geometry is not supported, libata relies solely on information sent by the drive itself (i.e. in reply to a ATA_CMD_ID_ATA request), which early drives likely won't provide (see FIXME in this comment block).

Thus, I'd presume that drives made before ATA-1 (first standard, started 1986, finalized 1994) won't work with libata and thus won't work with pata-gpio.


The way I see it, the best bet to access a CHS-only drive in 2022 is a mainboard with an IDE interface that's supported by the legacy 'ide' driver + Linux distribution with 5.10 LTS kernel (as 'ide' was removed from the Linux kernel starting with 5.13).

@VasylSamoilov
Copy link

Well, libata supports CHS, see here: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/tree/drivers/ata/libata-core.c?h=v5.10#n747

If device don't report LBA support libata will convert LBA to CHS. So it's pretty possible and will be quite useful feature to implement, given that motherboards capable of accessing CHS drives are more rare to come by, and speed for drives that old is usually not the concern...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants