Smonson's untitled simple harddisk project

General discussions or ideas about hardware.
czietz
Posts: 549
Joined: Sun Jan 14, 2018 1:02 pm

Re: Smonson's untitled simple harddisk project

Post by czietz »

Iirc, AHDI does a compulsory bad blocks check after formatting. I.e. basic writing and reading must already work with you HW. Otherwise, AHDI would have marked all sectors as bad. You could check the SD card's contents on another machine: is there a root sector? Does it look correct?
User avatar
Smonson
Posts: 710
Joined: Sat Oct 28, 2017 10:21 am
Location: Canberra, Australia
Contact:

Re: Smonson's untitled simple harddisk project

Post by Smonson »

Yeah, it's not the ACSI FORMAT command I'm really talking about here (which does nothing in my implementation) but the bad blocks check, which writes and then reads every sector of the drive. I checked the first 8 sectors and they have stuff in them that looks like a TOS partition table in a hex editor - compared with the information I've been able to find online. But not having a working hard disk I can't compare side-by-side.
Attachments
first8.zip
(716 Bytes) Downloaded 155 times
User avatar
arkadiusz.makarenko
Moderator Team
Moderator Team
Posts: 1208
Joined: Wed Jun 19, 2019 7:36 am
Location: Edinburgh

Re: Smonson's untitled simple harddisk project

Post by arkadiusz.makarenko »

Do you say that microcontrollers interrupts are not quick enough to handle this protocol?
Do not trust people. They are capable of greatness.
~ Stanislaw Lem
czietz
Posts: 549
Joined: Sun Jan 14, 2018 1:02 pm

Re: Smonson's untitled simple harddisk project

Post by czietz »

Smonson wrote: Sun Jul 19, 2020 12:35 pm I checked the first 8 sectors and they have stuff in them that looks like a TOS partition table in a hex editor - compared with the information I've been able to find online.
At first glance I'd agree that this looks like a proper root sector. So, just to avoid any misunderstanding: If you reboot with this harddisk, then load AHDI (from floppy), you don't get any hard disk drive letters C: etc.? (Note that with some TOS versions they might not appear automatically as icons on the Desktop; you might have to manually add icons.)
User avatar
Smonson
Posts: 710
Joined: Sat Oct 28, 2017 10:21 am
Location: Canberra, Australia
Contact:

Re: Smonson's untitled simple harddisk project

Post by Smonson »

czietz wrote: Sun Jul 19, 2020 6:42 pm At first glance I'd agree that this looks like a proper root sector. So, just to avoid any misunderstanding: If you reboot with this harddisk, then load AHDI (from floppy), you don't get any hard disk drive letters C: etc.? (Note that with some TOS versions they might not appear automatically as icons on the Desktop; you might have to manually add icons.)
That's right. I did check the menu at the desktop to see if I could manually add the letters at one point, but the option was greyed out, although I can't recall now whether I did that when the card had these exact contents. I'll confirm that tonight after work. I'm on TOS 1.04.
User avatar
Smonson
Posts: 710
Joined: Sat Oct 28, 2017 10:21 am
Location: Canberra, Australia
Contact:

Re: Smonson's untitled simple harddisk project

Post by Smonson »

arkadiusz.makarenko wrote: Sun Jul 19, 2020 3:29 pm Do you say that microcontrollers interrupts are not quick enough to handle this protocol?
Yup, at least for an ATMega328. For example, the commands are sent using a series of short pulses 250nS in length. It's necessary to toggle an output pin within 30nS of the beginning of that pulse, then read 9 bits before the end of the pulse.
czietz
Posts: 549
Joined: Sun Jan 14, 2018 1:02 pm

Re: Smonson's untitled simple harddisk project

Post by czietz »

Smonson wrote: Sun Jul 19, 2020 11:45 pm I did check the menu at the desktop to see if I could manually add the letters at one point, but the option was greyed out [...] I'm on TOS 1.04.
Note that on TOS 1.0x you have to first select an existing drive icon (e.g. floppy drive) by clicking on it before the menu option becomes active.
User avatar
Smonson
Posts: 710
Joined: Sat Oct 28, 2017 10:21 am
Location: Canberra, Australia
Contact:

Re: Smonson's untitled simple harddisk project

Post by Smonson »

czietz wrote: Mon Jul 20, 2020 6:33 am Note that on TOS 1.0x you have to first select an existing drive icon (e.g. floppy drive) by clicking on it before the menu option becomes active.
...well, that's clearly a ridiculous UI decision!

Unfortunately I wasn't able to test this again tonight because I've done tons of refactoring in the meantime and wasn't able to locate the commit that produced that bootsector in time (it takes an hour to complete the format). I'll post again when I've got something. :)
User avatar
Smonson
Posts: 710
Joined: Sat Oct 28, 2017 10:21 am
Location: Canberra, Australia
Contact:

Re: Smonson's untitled simple harddisk project

Post by Smonson »

After fixing a few bugs and implementing some more ACSI commands (such as MODE SENSE page code 0) I can get it to recognise the partitions are there and even assign drive letters to them. I can't use the drives yet because there's a problem in my SD card handling routines. So I have 2 tasks to do now:
  • Solve the problem that causes SD multisector writes to fail in some cases
  • Narrow down the reason why the ST isn't getting the disk size right
Regarding the first, I'm going to build another board on the weekend that will just have the AVR and SD socket on it and a serial connection to my PC so I can interactively read and write sectors for testing. I've come this far with 2 LEDs, but it's getting limiting now. That will allow me to see all the responses and statuses coming out of the card.

No real plan for the second item at the moment. I found the vedor-specific page 0 for MODE SENSE in the linux kernel source and copied that, but the values for heads, cylinders and sectors seems to be ignored. I have yet to implement MODE SELECT so perhaps that is the problem. The Seagate SCSI reference is so vague and convoluted, I can't make head or tail of the info in there about MODE SELECT. Needs more research.
User avatar
Smonson
Posts: 710
Joined: Sat Oct 28, 2017 10:21 am
Location: Canberra, Australia
Contact:

Re: Smonson's untitled simple harddisk project

Post by Smonson »

Over the week I did a bunch of debugging and now my SD-card code seems pretty solid. So now reads and writes all work fine and never fail (so far). I can format the drive with AHDI and partition it into 4x 32MB partitions, which I can write files on. That's great progress. I'm not sure how AHDI is getting the disk size but it seems to have changed from thinking it's a 32MB disk to a 128MB disk. I was unable to make the drives bootable, or get GEM to recognise them at boot - dunno if that's normal for AHDI.

The ICD utilities still can't do anything, it fails before format with an error about being able to determine the disk's size. That's left to solve. It looks like the hard disk API has no concept of hard disk sizes, it all just comes from the partition table. So each driver must do its own process for determining how big the disk is at format/partitioning time. ICD asks for MODE SENSE page 63 which is "give me everything" - I only supply pages 3 and 4 at the moment but that's obviously not the right ones.
Post Reply

Return to “HARDWARE DISCUSSIONS”