pATA HBA that only accepts LBA>0? is it possible? - Page 1
Forum section: electronics / general

author: DiTBho
author_rank: Super Contributor
timestamp: February 01, 2025, 11:45:42 pm
content: There are quite a few strange things with this embedded pATA controller.It is a PIOMODE, which works in LBA28The CPU is LittleEndian.The "identify" command returns a buffer that is BigEndian, when it should be LittleEndianwhile, 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?

author: DiTBho
author_rank: Super Contributor
timestamp: February 01, 2025, 11:57:42 pm
content: Code:# de 0disk_ata_read,LBA=0disk_ata_piomode_block_get,LBA=0disk_ans=falseCode:# de 1disk_ata_read,LBA=1disk_ata_piomode_block_get,LBA=1disk_ans=true00000000: 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:/** 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)

author: DiTBho
author_rank: Super Contributor
timestamp: February 02, 2025, 12:27:12 am
content: Wiki, about LBA, seehereQuote

author: Nominal Animal
author_rank: Super Contributor
timestamp: February 02, 2025, 11:21:34 am
content: Could it be azoned blockcontroller 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 theREPORT ZONEcommand 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).

author: DiTBho
author_rank: Super Contributor
timestamp: February 02, 2025, 02:12:53 pm
content: 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.

author: DiTBho
author_rank: Super Contributor
timestamp: February 02, 2025, 06:53:43 pm
content: 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 0my conclusions:- HBA quirks

author: DiTBho
author_rank: Super Contributor
timestamp: February 03, 2025, 08:07:30 pm
content: 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.

author: Nominal Animal
author_rank: Super Contributor
timestamp: February 04, 2025, 04:59:39 pm
content: 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.

author: DiTBho
author_rank: Super Contributor
timestamp: February 04, 2025, 05:05:46 pm
content: Quote from: Nominal Animal on February 04, 2025, 04:59:39 pmI don't trust AliExpress too much due to their poor QA-acceptance.Anyway, I will buy one from DeLock

author: DiTBho
author_rank: Super Contributor
timestamp: February 04, 2025, 07:02:08 pm
content: Code:# de 0 -verbosedisk_ata_read(),LBA=0,blocksize=512byte,1blockdisk_ans=true00000000: 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 se00000100: 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 | ..'-.......@...-000001d0: 13 02 82 73 1a 23 00 48 00 00 00 00 04 00 00 73 | ...s.#.H.......s000001e0: 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.

author: Nominal Animal
author_rank: Super Contributor
timestamp: February 04, 2025, 07:28:09 pm
content: So, it was Zoned?Anyway, DeLock61795(using microSDHC/microSDXC cards as CF I),62637(using SDHC/SDXC, or microSDHC/microSDXC via SD-microSD adapter, as CF I), and61796(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.

author: DiTBho
author_rank: Super Contributor
timestamp: February 04, 2025, 10:13:37 pm
content: Quote from: Nominal Animal on February 04, 2025, 07:28:09 pmYup, the CF was Zoned, LBA 1 is addressed as LBA 0.The Microdrive was not, LBA 0 is addresed as LBA 0.

author: DiTBho
author_rank: Super Contributor
timestamp: February 04, 2025, 10:15:48 pm
content: Quote from: Nominal Animal on February 04, 2025, 07:28:09 pmI found one on eBay for only 20 euros, it's not expensive.Bought to try it

author: fzabkar
author_rank: Super Contributor
timestamp: February 18, 2025, 02:25:12 am
content: It sounds to me as if the drive is talking CHS whereas the controller is talking LBA.CHS 0/0/1 = LBA 0CHS 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)

author: DiTBho
author_rank: Super Contributor
timestamp: February 18, 2025, 07:15:34 pm
content: It doesn't support CHS, and ATA identify reports LBA28

author: fzabkar
author_rank: Super Contributor
timestamp: February 18, 2025, 08:47:56 pm
content: What value are you sending in the D/H register?

author: DiTBho
author_rank: Super Contributor
timestamp: February 18, 2025, 09:50:03 pm
content: Code: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);

author: fzabkar
author_rank: Super Contributor
timestamp: February 18, 2025, 11:21:56 pm
content: 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