Author Topic: pATA HBA that only accepts LBA>0? is it possible?  (Read 3353 times)

0 Members and 4 Guests are viewing this topic.

Offline DiTBhoTopic starter

  • Super Contributor
  • ***
  • Posts: 5090
  • Country: gb
pATA HBA that only accepts LBA>0? is it possible?
« on: February 01, 2025, 11:45:42 pm »
There are quite a few strange things with this embedded pATA controller.
It is a PIOMODE, which works in LBA28

The CPU is LittleEndian.
The "identify" command returns a buffer that is BigEndian, when it should be LittleEndian
while, rhe read and write commands instead work with a LittleEndian buffer.

There is also one very strange thing: the read operations done with LBA=0,
which normally should return the MBR of the PC partitions .. fails.
Does not returns nothing! Instead, read operations done with LBA=1 return the MBR!

ummm, have you ever seen anything similar?  :-//
The opposite of courage is not cowardice, it is conformity. Even a dead fish can go with the flow
 

Offline DiTBhoTopic starter

  • Super Contributor
  • ***
  • Posts: 5090
  • Country: gb
Re: pATA HBA that only accepts LBA>0? is it possible?
« Reply #1 on: February 01, 2025, 11:57:42 pm »
Code: [Select]
# de 0
disk_ata_read,LBA=0
disk_ata_piomode_block_get,LBA=0
disk_ans=false

Code: [Select]
# de 1
disk_ata_read,LBA=1
disk_ata_piomode_block_get,LBA=1
disk_ans=true
00000000: 73 75 70 70 61 64 69 73 6b 00 00 00 00 00 00 00 | suppadisk.......
00000010: 64 6f 20 79 6f 75 20 73 65 65 20 74 68 69 73 3f | do you see this?
00000020: 4c 42 41 3d 31 20 6f 72 20 4c 42 41 3d 30 3f 00 | LBA=1 or LBA=0?.
00000030: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | ................
00000040: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | ................
00000050: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | ................
00000060: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | ................
00000070: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | ................
00000080: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | ................
00000090: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | ................
000000a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | ................
000000b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | ................
000000c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | ................
000000d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | ................
000000e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | ................
000000f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | ................
00000100: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | ................
00000110: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | ................
00000120: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | ................
00000130: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | ................
00000140: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | ................
00000150: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | ................
00000160: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | ................
00000170: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | ................
00000180: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | ................
00000190: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | ................
000001a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | ................
000001b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | ................
000001c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | ................
000001d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | ................
000001e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | ................
000001f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | ................
#

Code: [Select]
    /*
     * Status Register (I/O base + 7)
     *
     * bit0  ERR   Indicates an error occurred
     *             Send a new command to clear it
     *             or nuke it with a Software Reset
     * bit1  IDX   Index. Always set to zero
     * bit2  CORR  Corrected data. Always set to zero
     * bit3  DRQ   Set when the drive has PIO data to transfer
     *             or is ready to accept PIO data
     * bit4  SRV   Overlapped Mode Service Request
     * bit5  DF    Drive Fault Error (does not set ERR)
     * bit6  RDY   Bit is clear when drive is spun down
     *             or after an error. Set otherwise.
     * bit7  BSY   Indicates the drive is preparing to send/receive data
     *             wait for it to clear
     *             In case of 'hang' it never clears, do a software reset
     *             Technically, when BSY is set
     *             the other bits in the Status byte are meaningless
     *             It is a Bad Idea to test the "Seek Complete" (DSC) bit
     *             because it has been deprecated, only works in old HBAs
     *             and replaced by the newer SRV bit.
     */

Any attempt to read a block at LBA=0 returns the ERR bit set in the disk status register  :-//
(it shouldn't be this way, but umm, perplexed)
The opposite of courage is not cowardice, it is conformity. Even a dead fish can go with the flow
 

Offline DiTBhoTopic starter

  • Super Contributor
  • ***
  • Posts: 5090
  • Country: gb
Re: pATA HBA that only accepts LBA>0? is it possible?
« Reply #2 on: February 02, 2025, 12:27:12 am »
Wiki, about LBA, see here

Quote
Logical block addressing (LBA) is a common scheme used for specifying the location of blocks of data stored on computer storage devices, generally secondary storage systems such as hard disk drives. LBA is a particularly simple linear addressing scheme; blocks are located by an integer index, with the first block being LBA 0, the second LBA 1, and so on.
The opposite of courage is not cowardice, it is conformity. Even a dead fish can go with the flow
 

Offline Nominal Animal

  • Super Contributor
  • ***
  • Posts: 8349
  • Country: fi
    • My home page and email address
Re: pATA HBA that only accepts LBA>0? is it possible?
« Reply #3 on: February 02, 2025, 11:21:34 am »
Could it be a zoned block controller or drive?

If zone 0 is not a conventional zone (say, is a write pointer zone of one block), and zone 1 is a conventional zone starting at LBA 0 and covers most of the drive (except the blocks reserved for the write zone buffer), it would work something like that.

You could find out by issuing the REPORT ZONE command for LBA 0 (9E 14  00 00 00 00 00 00 00  00 00 02 00  00 00, or 95 00  00 00 00 00 00 00 00  00 00 02 00   00 00, I believe). 
 

Offline DiTBhoTopic starter

  • Super Contributor
  • ***
  • Posts: 5090
  • Country: gb
Re: pATA HBA that only accepts LBA>0? is it possible?
« Reply #4 on: February 02, 2025, 02:12:53 pm »
I used a compact flash, 1GByte.

I will try with MicroDrives { Hitachi 4Gbyte, Seagate 5Gbyte } I to see if it's the media rather than the HBA.
I will investigate about zoned-block and add support to my simple ATA library.
The opposite of courage is not cowardice, it is conformity. Even a dead fish can go with the flow
 

Offline DiTBhoTopic starter

  • Super Contributor
  • ***
  • Posts: 5090
  • Country: gb
Re: pATA HBA that only accepts LBA>0? is it possible?
« Reply #5 on: February 02, 2025, 06:53:43 pm »
Tried with a Microdrive:
- reading on LBA 0 doesn't return any error, but it also doesn't return any valid data
- reading on LBA 1 returns the block 0

my conclusions:
- HBA quirks

 :-//
The opposite of courage is not cowardice, it is conformity. Even a dead fish can go with the flow
 

Offline DiTBhoTopic starter

  • Super Contributor
  • ***
  • Posts: 5090
  • Country: gb
Re: pATA HBA that only accepts LBA>0? is it possible?
« Reply #6 on: February 03, 2025, 08:07:30 pm »
Ok, it's a quirk.
The HBA is not fully ATA compliant.
Fixed.

The CF 8 used is a zoned block device.
With MicroDrives, now it works as expected.
The opposite of courage is not cowardice, it is conformity. Even a dead fish can go with the flow
 
The following users thanked this post: Nominal Animal

Offline Nominal Animal

  • Super Contributor
  • ***
  • Posts: 8349
  • Country: fi
    • My home page and email address
Re: pATA HBA that only accepts LBA>0? is it possible?
« Reply #7 on: February 04, 2025, 04:59:39 pm »
Have you noticed that AliExpress has SD to CF adapters, so you can use SDHC cards to emulate a CF device?  I don't know how well they work, but at those prices it's worth examining.  With e.g. SanDisk High Endurance cards (32G, U3/V30), it might be a viable option with your older CF-based devices.
 

Offline DiTBhoTopic starter

  • Super Contributor
  • ***
  • Posts: 5090
  • Country: gb
Re: pATA HBA that only accepts LBA>0? is it possible?
« Reply #8 on: February 04, 2025, 05:05:46 pm »
Have you noticed that AliExpress has SD to CF adapters, so you can use SDHC cards to emulate a CF device?
I don't know how well they work, but at those prices it's worth examining.
With e.g. SanDisk High Endurance cards (32G, U3/V30), it might be a viable option with your older CF-based devices.

I don't trust AliExpress too much due to their poor QA-acceptance.
Anyway, I will buy one from DeLock  :-+
The opposite of courage is not cowardice, it is conformity. Even a dead fish can go with the flow
 

Offline DiTBhoTopic starter

  • Super Contributor
  • ***
  • Posts: 5090
  • Country: gb
Re: pATA HBA that only accepts LBA>0? is it possible?
« Reply #9 on: February 04, 2025, 07:02:08 pm »
Code: [Select]
# de 0 -verbose
disk_ata_read(),LBA=0,blocksize=512byte,1block
disk_ans=true
00000000: 6c 62 61 30 00 00 00 00 00 00 00 00 00 00 00 00 | lba0............
00000010: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | ................
00000020: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | ................
00000030: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | ................
00000040: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | ................
00000050: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | ................
00000060: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | ................
00000070: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | ................
00000080: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | ................
00000090: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | ................
000000a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | ................
000000b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | ................
000000c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | ................
000000d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | ................
000000e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | ................
000000f0: 30 78 30 66 30 20 20 64 6f 20 79 6f 75 20 73 65 | 0x0f0  do you se
00000100: 65 20 74 68 69 73 3f 00 00 00 00 00 00 00 00 00 | e this?.........
00000110: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | ................
00000120: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | ................
00000130: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | ................
00000140: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | ................
00000150: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | ................
00000160: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | ................
00000170: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | ................
00000180: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | ................
00000190: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | ................
000001a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | ................
000001b0: 00 00 00 00 00 00 00 00 59 c2 b6 e4 00 00 00 21 | ........Y......!
000001c0: 03 00 27 2d 12 02 00 08 00 00 00 40 00 00 00 2d | ..'[email protected]
000001d0: 13 02 82 73 1a 23 00 48 00 00 00 00 04 00 00 73 | ...s.#.H.......s
000001e0: 1b 23 83 5f d6 fa 00 48 04 00 00 28 75 00 00 5f | .#._...H...(u.._
000001f0: d7 fa 83 7d fe ff 00 70 79 00 00 a0 00 00 55 aa | .......py.....U.
The opposite of courage is not cowardice, it is conformity. Even a dead fish can go with the flow
 

Offline Nominal Animal

  • Super Contributor
  • ***
  • Posts: 8349
  • Country: fi
    • My home page and email address
Re: pATA HBA that only accepts LBA>0? is it possible?
« Reply #10 on: February 04, 2025, 07:28:09 pm »
So, it was Zoned?

Anyway, DeLock 61795 (using microSDHC/microSDXC cards as CF I), 62637 (using SDHC/SDXC, or microSDHC/microSDXC via SD-microSD adapter, as CF I), and 61796 (using SDHC/SDXC, or or microSDHC/microSDXC via SD-microSD adapter, as CF II), seem suitable.  All support up to 25 MB/s transfers, so with SanDisk High Endurance cards they ought to be quite nice while still being affordable.
 

Offline DiTBhoTopic starter

  • Super Contributor
  • ***
  • Posts: 5090
  • Country: gb
Re: pATA HBA that only accepts LBA>0? is it possible?
« Reply #11 on: February 04, 2025, 10:13:37 pm »
So, it was Zoned?

Yup, the CF was Zoned, LBA 1 is addressed as LBA 0.
The Microdrive was not, LBA 0 is addresed as LBA 0.
The opposite of courage is not cowardice, it is conformity. Even a dead fish can go with the flow
 

Offline DiTBhoTopic starter

  • Super Contributor
  • ***
  • Posts: 5090
  • Country: gb
Re: pATA HBA that only accepts LBA>0? is it possible?
« Reply #12 on: February 04, 2025, 10:15:48 pm »
DeLock 61795 (using microSDHC/microSDXC cards as CF I), 62637 (using SDHC/SDXC, or microSDHC/microSDXC via SD-microSD adapter, as CF I), and 61796 (using SDHC/SDXC, or or microSDHC/microSDXC via SD-microSD adapter, as CF II), seem suitable.  All support up to 25 MB/s transfers, so with SanDisk High Endurance cards they ought to be quite nice while still being affordable.

I found one on eBay for only 20 euros, it's not expensive.
Bought to try it :-+
The opposite of courage is not cowardice, it is conformity. Even a dead fish can go with the flow
 
The following users thanked this post: Nominal Animal

Offline fzabkar

  • Super Contributor
  • ***
  • Posts: 3246
  • Country: au
Re: pATA HBA that only accepts LBA>0? is it possible?
« Reply #13 on: February 18, 2025, 02:25:12 am »
It sounds to me as if the drive is talking CHS whereas the controller is talking LBA.

CHS 0/0/1 = LBA 0

CHS 0/0/0 is undefined because sectors count from 1 in CHS mode.

See the documentation for the Drive/Head task file register (0xE0 for LBA versus 0xA0 for CHS).

https://wiki.osdev.org/ATA_PIO_Mode#Drive_/_Head_Register_(I/O_base_+_6)
« Last Edit: February 18, 2025, 06:02:24 am by fzabkar »
 

Offline DiTBhoTopic starter

  • Super Contributor
  • ***
  • Posts: 5090
  • Country: gb
Re: pATA HBA that only accepts LBA>0? is it possible?
« Reply #14 on: February 18, 2025, 07:15:34 pm »
It doesn't support CHS, and ATA identify reports LBA28
The opposite of courage is not cowardice, it is conformity. Even a dead fish can go with the flow
 

Offline fzabkar

  • Super Contributor
  • ***
  • Posts: 3246
  • Country: au
Re: pATA HBA that only accepts LBA>0? is it possible?
« Reply #15 on: February 18, 2025, 08:47:56 pm »
What value are you sending in the D/H register?
 

Offline DiTBhoTopic starter

  • Super Contributor
  • ***
  • Posts: 5090
  • Country: gb
Re: pATA HBA that only accepts LBA>0? is it possible?
« Reply #16 on: February 18, 2025, 09:50:03 pm »
Code: [Select]
    magic0 = ((LBA bitwiseAnd 0x000000ff) shiftRight 0);
    magic1 = ((LBA bitwiseAnd 0x0000ff00) shiftRight 8);
    magic2 = ((LBA bitwiseAnd 0x00ff0000) shiftRight 16);
    magic3 = ((LBA bitwiseAnd 0x0f000000) shiftRight 24);
    magic3 = (magic3 bitwiseOr 0xe0);

    block_n = 1; /* read only one block, 512 byte */

    is_ok = ata_piomode0_wait_for(p_ata_disk, ATA_sr_bit_bsy, False);
    if (is_ok isEqualTo True)
    {
        outportb(io + ATA_REG_HDDEVSEL, magic3);
        outportb(io + ATA_REG_ERROR, 0x00);
        outportb(io + ATA_REG_SECCOUNT0, block_n);
        outportb(io + ATA_REG_LBA0, magic0);
        outportb(io + ATA_REG_LBA1, magic1);
        outportb(io + ATA_REG_LBA2, magic2);
        outportb(io + ATA_REG_COMMAND, ATA_CMD_READ_PIO);
The opposite of courage is not cowardice, it is conformity. Even a dead fish can go with the flow
 

Offline fzabkar

  • Super Contributor
  • ***
  • Posts: 3246
  • Country: au
Re: pATA HBA that only accepts LBA>0? is it possible?
« Reply #17 on: February 18, 2025, 11:21:56 pm »
I can only imagine that the PIO READ command somehow overrides the LBA bit and invokes CHS mode in the drive. There is a professional data recovery tool (PC3000) that uses PIO mode for CHS access in older drives. I always wondered why this tool had no specific CHS functionality, so perhaps that is an explanation.

Edit:

This is the PC3000 case I was referring to:

https://forum.hddguru.com/viewtopic.php?f=1&t=35277&p=246597#p246597
« Last Edit: February 19, 2025, 01:25:54 am by fzabkar »
 
The following users thanked this post: DiTBho


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf