MultiDrive – free backup, clone & wipe disk utility from Atola Technology

All times are UTC - 5 hours [ DST ]




Post new topic Reply to topic  [ 14 posts ] 
Author Message
 Post subject: how to write a base program to send ATA command in dos
PostPosted: December 4th, 2006, 9:00 
Offline

Joined: November 16th, 2006, 15:35
Posts: 55
Hi!
some of you who have just read my precedent post may think I'm a little crazy with my mania about writing bad sector unc on hd....
I understand btw, after have saved 4 hd with this "makebad" technique, I wanna go over............ ;-))
I would like to write a program that send directelly ata command to the hd, in a dos environment.... with purpose of intentionally writing UNC sector.
Looking on http://www.t13.org/ I only found the command I have to send to the I/O port, instead I would like a scheletal program in C or in Assembly who may teach me how to implement it.
Any help please?
Any "strong" help please: it's about 25 years I no longer programming..... and I have fear that my death will arrive before I'll be able in writing this (in)utility...... ;-) so please help a poor old man....:-)

BYE


Top
 Profile  
 
 Post subject:
PostPosted: December 4th, 2006, 13:27 
Offline

Joined: October 23rd, 2006, 8:56
Posts: 1336
I also want to write some utility to send ATA commands directly to the controller.

I found this: http://ata-atapi.com/products.htm

also at the end of this article there is a link to some Assembler code
which you can take a look at.
http://polya.computing.dcu.ie/wiki/inde ... rnal_Links

Happy coding :D


Top
 Profile  
 
 Post subject:
PostPosted: December 17th, 2006, 18:16 
Offline

Joined: December 17th, 2006, 17:42
Posts: 9
Location: Poland
Hard drive controller is available through CPU I/O ports. All available commands and the reigisters used to program HDD controller are described in ATA specification.

The biggest problem will be converting the address of the particular sector to proper register values, I think. The addressing rules are different for CHS and LBA addressing.

I've been doing some direct controller programming. Yet, I never found to be necesary writing those sectors from own program. I've been using disk editor utilities to write to particular UNC sectors, instead.


Top
 Profile  
 
 Post subject:
PostPosted: December 18th, 2006, 4:26 
Offline

Joined: November 16th, 2006, 15:35
Posts: 55
Sfor wrote:
I've been doing some direct controller programming. Yet, I never found to be necesary writing those sectors from own program. I've been using disk editor utilities to write to particular UNC sectors, instead.

Uhm..... what disk sector utilities is able to write UNC?
Thanks


Top
 Profile  
 
 Post subject:
PostPosted: December 18th, 2006, 8:16 
Offline

Joined: December 17th, 2006, 17:42
Posts: 9
Location: Poland
Norton Disk Editor is just one of them. It can access physical sectors of a disk drive. But, since it is a very old software designed to work with CHS it does not work perfectly with the high capacity disk drives. Yet, I managed to get rid of a few UNC sectors, that way.

To speak the truth, the disk done the hard job itself relocating the sector, I just had to persuade it the particular sector is realy damaged.

In some cases the standard procedure does not work perfectly, and the drive does not want to relocate a particular sector. I think the procedure does not believe the sector is damaged enough for the sector to be moved. So, pesuading it the sector does not work well can take a few read write cycles. The DOS format procedure is quite effective in those cases, as it is trying to recover damaged clusters by multiple read write cycles.


Top
 Profile  
 
 Post subject:
PostPosted: December 18th, 2006, 9:28 
Offline

Joined: November 16th, 2006, 15:35
Posts: 55
Hi!!
I have understand the concept: you let that the hd itself does execute relocation, and we have to try to convince it that a particular sector is bad performing on it multiple read/write operations.
Ok!! This works great generally, but not always( at least for me... ;-)):
I had an hd maxtor 80gb where the smart relocate raw parameter is 1172 (normally must not be over 50!!!), well no bad sector on it, but only weak /red and brown ) sectors: no relocation is now possible, in this case my utilty works great manually marking as UNC al these weak sectors, then a full format under window will give me bad sector running chkdsk, btw now the disk is really stable and I no longer experiment slowdown and freeze....
Of course with Pc300 I may solve the situation, but makebad is for people who do not own Pc300......
CYA!!


Top
 Profile  
 
 Post subject:
PostPosted: December 18th, 2006, 12:48 
Offline

Joined: December 17th, 2006, 17:42
Posts: 9
Location: Poland
Oh. You want to set the sector as bad, so the OS will stop from using it.

This means, I misunerstood you completely.

In such a case using direct disk access is a complicated task. Because OS is using a completely different addressing system. It would be much simpler to do it from DOS level. In other case it would be necesary to analyze the partition table and calculate between logical cluster number - logical sector number - physical sector number - physical sector address.

I never had a heart for those calculations.


Top
 Profile  
 
 Post subject:
PostPosted: December 19th, 2006, 6:16 
Offline

Joined: November 16th, 2006, 15:35
Posts: 55
No, no........
Was me that was no clear: my english is terrible..... but what can I do? I'm too old now to study english.... ;-)
I mean the follows:
I HAVE NOT GOT PC3000!!!
I have an hd whose g/list is full so is unable in relocate anymore, so:
1) backup my data
2) low level format it
3) run a scansion (F4) with mhdd or victoria
4) take note of ALL lba warnings (access >500ms)
5) use "inside" mhdd the command "makebad" to manually mark as UNC all these defective sectors
6) come back to window
7) perform a re-partition and a FULL (no fast) format
8) Now OS automatically mark as bad all that UNC sectors, from now performing chkdsk on my hd will tell me that I have bad sector, btw the hd now works very well

My utility is able in automatizing pass from 1) to 5)
maybe you wanna give a try:
http://files.hddguru.com/index.php?&dir ... ft/Makebad

CYA


Top
 Profile  
 
 Post subject:
PostPosted: December 19th, 2006, 6:41 
Offline

Joined: December 17th, 2006, 17:42
Posts: 9
Location: Poland
I got the picture, now.

I'm not sure if marking bad clusters by the same utility is a good idea. The all in one system would require to repartition and then to reformat partitions from the utility.

Unless a script solution would satisfy your needs. It will be difficult to repartition the drive with what DOS provides. But, automatical format from a batch is possible, I think.


Top
 Profile  
 
 Post subject:
PostPosted: December 19th, 2006, 6:58 
Offline

Joined: December 17th, 2006, 17:42
Posts: 9
Location: Poland
Wait a minute....

Repartitioning is not necesary. The program can store the partition table sector while doing the drive cleaning. Then it can write it back to the drive. Only system format remains in such a case.


Top
 Profile  
 
 Post subject:
PostPosted: December 19th, 2006, 7:10 
Offline

Joined: November 16th, 2006, 15:35
Posts: 55
yeah, of course a re-partioning is NOT necessary, only a FULL format, or even worse: chkdsk /f /r may be enough....
BTW, please go and read if you've time my last post here:
http://forum.hddguru.com/are-you-hddgur ... t6544.html
See you later...


Top
 Profile  
 
 Post subject:
PostPosted: January 15th, 2007, 11:28 
Offline

Joined: December 23rd, 2006, 10:50
Posts: 28
Hi,

This was the tutorial that actually helped me to send ATA commands:

http://www.geocities.com/SiliconValley/2072/atapi.htm

It's pretty straight forward and after reading it, you'll have no difficulties sending ATA commands.

However, I now want to send ATA commands to a SATA device and don't know how to do that. If anybody has info on that, that would be much appreciated !


Top
 Profile  
 
 Post subject:
PostPosted: January 19th, 2007, 19:19 
Offline

Joined: December 23rd, 2006, 10:50
Posts: 28
If you're going to write more than 1 sector to a device with the 0x30 ATA cmd, then make SURE that you poll the status register for NBSY after each sector. I found out the hard way that it's needed :) It works fine without that check on my IDE drive, but my SATA drive messes up if you don't wait for NBSY after each sector (it then skips data).


Top
 Profile  
 
 Post subject: Re: how to write a base program to send ATA command in dos
PostPosted: March 18th, 2013, 8:11 
Offline

Joined: March 18th, 2013, 8:06
Posts: 2
Location: bangalore
Can any one send me the C/C++ code for writing sector to the device with 0x30 ATA cmd!
Thanks in advance.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 14 posts ] 

All times are UTC - 5 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 5 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group