![]() |
|
|||||||
| Register | >> Amiga FAQ/Wiki << | Rules & Help | Members List / Moderators List | Search | Today's Posts | Mark Forums Read |
![]() |
|
|
Thread Tools |
|
|
#1 |
|
Thalion Webshrine
Join Date: Jan 2004
Location: Oxford
Posts: 10,514
|
IDE & Max Transfer
I was replying to someone over at Amiga.org about MAX TRANSFER settings for IDE controllers (such as A1200/A600 Gayle IDE) giving them the standard "try 0x1FE00 and if that doesnt work try 0xFE00".
While writing I accidentally worked out the logical reason behind these "Magic numbers".
I noticed that "0x1FE00" is 255 * 512, and that 255 is the largest value that can be represented by 8-bits. So by using "0x1FE00" it prevents the driver (scsi.device) creating malformed IDE commands with sector counts larger than 8-bit. I am positive this is the logical answer as to why MAX TRANSFER should be "0x1FE00" for IDE devices. ------------ Now while the IDE (ATA5 and lower) command set supports an 8-bit sector count, very few operating systems use the maximum value. Windows (and most other operating systems) tend to use 64 or 128 sector commands. I know this because I discovered at work several years ago that PATA hard drives have their cache optimised for 64 sectors while SATA were optimised for 128 sector commands. Back to the plot: The second magic number touted for MAX transfer "0xFE00" is 127 * 512. I am not sure exactly why this value would be more compatible than 0x1FE00, but I imagine it has to do with the fact poor quality IDE devices do not expect sector counts above 128 sectors. You pretty much guarantee "sector count" compatibility with any IDE device with 0xFE00 and I cannot believe that it is slower. Anyhow, hope that has explained things, rather than confused things.
__________________
Thalion Webshrine |
|
|
|
|
|
#2 |
|
Global Moderator
Join Date: Aug 2008
Location: Sidcup, England
Posts: 8,700
|
That's a useful display of detective work, alexh!
![]() Thanks for sharing your thoughts on this with us. ![]() |
|
|
|
|
|
#3 |
|
Thalion Webshrine
Join Date: Jan 2004
Location: Oxford
Posts: 10,514
|
I dunno if my explanation is dumb enough.
You still have to be reasonably computer literate (at a low level) to get it.
__________________
Thalion Webshrine |
|
|
|
|
|
#4 |
|
Turpentine
Join Date: Oct 2007
Location: Kent, United Kingdom
Posts: 739
|
That's very clear and actually explains a lot.
|
|
|
|
|
|
#5 |
|
Ya' like it Retr0?
Join Date: Jul 2005
Location: United Kingdom
Age: 38
Posts: 9,185
|
I think it should be added to the CF-IDE for the Amiga Wiki...... if we have one....
|
|
|
|
|
|
#6 |
|
I like potato ;)
Join Date: Nov 2009
Location: Dont try to ask this to a drunken guy.
Age: 34
Posts: 593
|
Thanks alexh !
I put the magic number in the RDB of my hardfile, and now it works much better! ![]()
__________________
Quote from Mr. Burns, from the tv-show "The Simpsons": "Hmm, Simpson, hein..." |
|
|
|
|
|
#7 |
|
Registered User
Join Date: Mar 2009
Location: texas,usa
Posts: 83
|
Nice one alex,
another good reason to use SCSI on amiga also ![]() |
|
|
|
|
|
#8 |
|
-
|
Added Alexh's post to Amiga Problems.
__________________
The X-Copy shrine! |
|
|
|
|
|
#9 |
|
Registered User
Join Date: Sep 2007
Location: Tampere / Finland
Posts: 118
|
Nicely reasoned, and makes sense.
However, when I was setting up my CF card, I went with what looked like the most reliable-looking advice I could find at the time and set the Max Transfers value as high as 0x1FE0000. At 256 times more than reasoned above, it seems quite absurd. The magic is it has worked just fine, and apparently also in some cases where 0x1FE00 hasn't. I would like to know why it works, whether it is just waiting to cause trouble, or if there is any other reason to change it. I was thinking perhaps it is not taking the entire 32-bit value into account, but the less significant word is all zeroes so wouldn't it likely result in a MaxTransfer of 0 then? ![]() |
|
|
|
|
|
#10 | |
|
Precious & fragile things
Join Date: Feb 2009
Location: Victoria, Australia
Posts: 1,590
|
Quote:
|
|
|
|
|
|
|
#11 |
|
Registered User
Join Date: Jan 2002
Location: Germany
Posts: 3,908
|
Actually there shouldn't be a problem with MaxTransfer. The device driver should know the hardware limitations and automatically split large packets into smaller ones. Just like ping and MTU in TCP/IP world.
But scsi.device does not do this. If you specify a MaxTransfer value larger than 0x1fe00, it will send a mangled command to the device, resulting in corrupted data. So it is important to set MaxTransfer to a reasonable value when using scsi.device. However, it also depends on the version of scsi.device which is used. For example when using IDEfix, a new scsi.device is used which does automatically split large packets. So with IDEfix MaxTransfer should not be an issue. Finally MaxTransfer issues only arise when using files larger than the critical limit. Files smaller than 127.5K are not affected at all. Similarly large files might not be affected if a copy program is used which does not attempt to write more than 127.5K at a time. |
|
|
|
|
|
#12 |
|
Settler
Join Date: Feb 2007
Location: Amigastan
Posts: 885
|
Where can I set the max transfers properly? I have tried HD tool box but it doesnt save my changes? im trying to put 0x1fe00 but it kees changeing. Do i need to change the mask as well?
__________________
![]() |
|
|
|
|
|
#13 |
|
Missile Command Champion
Join Date: Aug 2005
Location: Germany
Age: 41
Posts: 8,379
|
You have to press the enter button after typing 1fe00, then save the settings.
|
|
|
|
|
|
#14 |
|
-
|
No need to adjust the mask.
__________________
The X-Copy shrine! |
|
|
|
|
|
#15 |
|
Settler
Join Date: Feb 2007
Location: Amigastan
Posts: 885
|
Thank you Retro-Nerd for the very quick response, that worked. I cant believe thats what I was missing!
Ok Jope thanks.
__________________
![]() |
|
|
|
|
|
#16 | |
|
Posts: n/a
|
Quote:
With 48-bit LBA (what is necessary with drives over 128GB) max count is 65536 as sector count is given as 16-bit value. |
|
|
|
|
#17 | ||
|
Thalion Webshrine
Join Date: Jan 2004
Location: Oxford
Posts: 10,514
|
Quote:
Quote:
You would need this version of scsi.device in your Kickstart ROM or eFlash/Kickflash/Deneb to be able to boot from a device with a the MAX TRANSFER set to larger than 0x1FE00. This is going to be a VERY small set of people. I thought that I had used the scsi.device (45.45) with 48-bit LBA support using a MAX TRANSFER larger than 0x1FE00 with a SanDisk CF card and had data corruption. I will be able to confirm soon as I'm making my own KS3.9 EPROMs for my A4000
__________________
Thalion Webshrine Last edited by alexh; 03 June 2011 at 16:11. |
||
|
|
|
|
|
#18 |
|
I hate potatos and shirts
|
The real problem is not the sector count, but the fact compact flash & microdrives doesn't have a built-in buffer .
Notice that real HD doesn't suffer from this issue, from the old IDE to SCSI drives. So anything over 255 will choke in the Amiga IDE bus (read "Gayle"), who will still try to put more data than the slow IDE channel can really cope.
__________________
Amigan since 1989 Known drunk since 1982 (don't know quite well, I was drunk) 13 Amigas at home Finally a Z3 one! I'll stick with 'Cachaça do Inter' for this week: Chivas gives headaches! :D |
|
|
|
|
|
#19 |
|
Thalion Webshrine
Join Date: Jan 2004
Location: Oxford
Posts: 10,514
|
???? How did you work that out? I was sure the problem is about malformed commands. The Amiga tries to transfer more data on the bus than the drive is expecting.
AmigaOS tries to send a command for say 131584 bytes (257 sectors). It made sense that scsi.device can only send ATA commands with an 8-bit sector count (and it doesn't check the incoming request size) which gets converted into an ATA command of 1 sector. With a MAX TRANSFER above 0x1FE00 I get data corruption on Gayle IDE using 2.5" PATA IDE disks just as I do with CF cards. I imagined it was not a problem for SCSI drives because SCSI commands have a bigger (32-bit?) sector count field.
__________________
Thalion Webshrine Last edited by alexh; 05 June 2011 at 01:01. |
|
|
|
|
|
#20 |
|
Missile Command Champion
Join Date: Aug 2005
Location: Germany
Age: 41
Posts: 8,379
|
Really? I never had any issues with standard MaxTransfer settings and PC hard drives. Pure luck?
|
|
|
|
|
|
#21 |
|
Thalion Webshrine
Join Date: Jan 2004
Location: Oxford
Posts: 10,514
|
Using the onboard IDE?
__________________
Thalion Webshrine |
|
|
|
|
|
#22 |
|
Missile Command Champion
Join Date: Aug 2005
Location: Germany
Age: 41
Posts: 8,379
|
Yes.
|
|
|
|
|
|
#23 |
|
Thalion Webshrine
Join Date: Jan 2004
Location: Oxford
Posts: 10,514
|
Well maybe rkauer is right that it is not a sector count problem.
I cannot imagine his description of what could be going wrong is the truth though. Pretty sure IDE is 100% flow controlled. CF cards even without a buffer are many, many times faster than the old 2.5" PATA hard drives of the time.
__________________
Thalion Webshrine |
|
|
|
|
|
#24 |
|
-
|
I can verify that 1fe00 is needed with many real hard disks too.
__________________
The X-Copy shrine! |
|
|
|
|
|
#25 |
|
WinUAE developer
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 38
Posts: 11,944
|
I may have (finally) found the problem..
When AOS IDE driver gets transfer that is longer than 256 bytes, it splits it in two or more pieces (because max ATA transfer is 256 blocks). After first piece has finished, it reads IDE CHS/LBA registers, adds one to address and then writes it back as start address of second piece. (ATA spec says they contain last read/written address) So far so good but: ATA-1 spec says: At command completion, the Command Block Registers contain the cylinder, head, and sector number of the last sector read. ATA-2 spec says: This register shall be updated to reflect the media address of the error when a media access command is unsuccessfully completed. NOTE 9 - Prior to the development of this standard, this register was updated at the end of every media access command to reflect the current media address In other words ATA-2 or newer device does not need to update CHS/LBA address after command finishes normally, only in error situations. This will break AOS ATA driver logic, start address of second piece becomes invalid (I assume drive keeps old values unmodified, second piece of data overwrites beginning of first piece which also explains why filesystem structure corruption has never been reported, only data corruption) NOTE: This theory is not tested! (EDIT: it is now) Last edited by Toni Wilen; 14 August 2011 at 11:15. |
|
|
|
|
|
#26 |
|
Thalion Webshrine
Join Date: Jan 2004
Location: Oxford
Posts: 10,514
|
I tried it today with every 2.5" PATA drive I have and if I set the MAX TRANSFER above 0x1FE00 I get data corruption on a READ on all of them.
The file has to be larger than 255 sectors obviously!
__________________
Thalion Webshrine |
|
|
|
|
|
#27 |
|
Registered User
Join Date: Feb 2007
Location: Melbourne, Australia
Age: 30
Posts: 1,390
|
Me either..
__________________
"The sad thing is that today's computers totally abuse their memory - totally wasteful, you have to wait for the damn things to boot up, just appalling designs." -Sir Clive Sinclair |
|
|
|
|
|
#28 |
|
Missile Command Champion
Join Date: Aug 2005
Location: Germany
Age: 41
Posts: 8,379
|
I've used PC drives in the 90s on my A1200 and now since 2007 with the standard MaxTransfer settings. No problems at all. To be honest: never heard/read of this 1fe00 setting before the IDE-CF HD solution became popular, and there it's obviously needed. X-file?
|
|
|
|
|
|
#29 |
|
Thalion Webshrine
Join Date: Jan 2004
Location: Oxford
Posts: 10,514
|
All my hard drives are very modern PC laptop hard drives. Dunno if that makes any difference?
__________________
Thalion Webshrine |
|
|
|
|
|
#30 |
|
Settler
Join Date: Feb 2007
Location: Amigastan
Posts: 885
|
I bumped this thread becuase when i installed classic wb on my 10.1gb 2.5 IDE hard drive(over 10 yeas old), some programs didnt open and some games came back with illegal expression errors. I reinstaled everything again after setting the drive to 0x1fe00 and it works fine.
__________________
![]() |
|
|
|
|
|
#31 |
|
Missile Command Champion
Join Date: Aug 2005
Location: Germany
Age: 41
Posts: 8,379
|
I've never used 2.5 HDs, only 3.5. Could this really make a difference?
|
|
|
|
|
|
#32 |
|
Thalion Webshrine
Join Date: Jan 2004
Location: Oxford
Posts: 10,514
|
Not if it is malformed ATA commands as I suggested.
If I could be arsed I could easily prove it with our ATA analyser at work. I wonder if IDE emulation on WinUAE is closely tied closely enough to the hardware to show this problem? I know if you use the high-level UAE hard disk driver then it does not show up. (You can prep disks in WinUAE using the high level driver with MAX TRANSFER above 0x1FE00 which work fine in WinUAE but fail on Amiga)
__________________
Thalion Webshrine |
|
|
|
|
|
#33 |
|
I hate potatos and shirts
|
@Alexh: I don't doubt your research, I just see the problem occurring mostly on CF & micro Drives (which doesn't have a cache memory between the inner "disk" controller and the outside IDE bus).
SCSI drives is another can of worms and they have their own behaviour. The problem is related to the Amiga IDE and the way it talks to the devices hooked in. But I never had a validation problem before the CF era. Now I had so much of those errors that I simply not use CF for anything but file transfers.
__________________
Amigan since 1989 Known drunk since 1982 (don't know quite well, I was drunk) 13 Amigas at home Finally a Z3 one! I'll stick with 'Cachaça do Inter' for this week: Chivas gives headaches! :D |
|
|
|
|
|
#34 |
|
Posts: n/a
|
I don't no much how Amiga OS works. But usually hard disk driver is responsible to take care about max sector counts possible with certain hard drives. So, if it exceeds it driver splits into several requests with allowed counts.
Considering buffering by CF cards: some may have it, some not. All it is pretty irrelevant on slow machines like Amiga. Modern CF cards are much faster. Buffer is needed mostly by slow mechanical hard disks. But by CF cards sector access times are much-much better, so buffer is not a must. I see other problems with CF cards and old micros without some advanced ATA compatible IDE IF : signal timing problems. It is worst in case of writing. Problem is that usual IDE logics activate and deactivate IDE SELP (CS0) signal together with RD and WR signals. By ATA spec it is not so (must activate RD and WR later and deactivate earlier) . Was OK with old hard drives, but after 20 years things are different. With Sandisk CF cards usually no timing problems, because they have better behaviour and different timing than usual CF cards (as Kingston). Of course, best is to design new IDE (ATA) adapters with better signal timing, according to new ATA specs. |
|
|
|
#35 |
|
Thalion Webshrine
Join Date: Jan 2004
Location: Oxford
Posts: 10,514
|
I thought that was what MAX TRANSFER was for. It tells some part of the OS/driver the limit at which a file system request of N bytes is split into multiple transfers.
__________________
Thalion Webshrine |
|
|
|
|
|
#36 | |
|
WinUAE developer
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 38
Posts: 11,944
|
Quote:
Device driver does not know nothing about max transfer parameter. (and check also post 25) |
|
|
|
|
|
|
#37 | |
|
Registered User
Join Date: Jan 2002
Location: Germany
Posts: 3,908
|
Quote:
BTW, WinUAE emulates the MaxTransfer problem on the internal IDE port, too. So if this wasn't intentional, then it's really scsi.device which sends malformed ATA commands to the hardware and not some missing cache on the harddrive or something. |
|
|
|
|
|
|
#38 | |
|
Registered User
Join Date: Jan 2002
Location: Germany
Posts: 3,908
|
Quote:
If you examine the data written by WinUAE to a HDF connected to IDE0, you'll see exactly this: if you transfer 257 sectors (0 - 256), sector 1 to 255 are written correctly, sector 0 contains the data of written sector 256 and sector 256 remains unchanged. |
|
|
|
|
|
|
#39 |
|
Thalion Webshrine
Join Date: Jan 2004
Location: Oxford
Posts: 10,514
|
I missed that post. That certainly explains why only some devices are affected. Seems dumb to read the tailgate status to form the next command but hey.
I know that our modern ATA8 hard drive controllers always update the tailgate status for all commands, not just errors.
__________________
Thalion Webshrine |
|
|
|
|
|
#40 | ||
|
WinUAE developer
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 38
Posts: 11,944
|
Quote:
Quote:
Should WinUAE detect this situation and warn about it? It is easy to emulate this exactly as ATA-1 spec says which is technically right thing to do but may not the best choice from non-technical point of view ![]() |
||
|
|
|
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Max transfer & mask for CF card? | PowerPie5000 | support.Hardware | 7 | 29 November 2010 12:35 |
| issues cf ide pcmcia cfs fat95 x4 ide | jimmer78 | support.Hardware | 9 | 29 April 2010 00:15 |
| IDE & Max Transfer-temp | prowler | support.Hardware | 0 | 16 June 2009 21:30 |
| CF to IDE adapter - Max size card? | crispywotsits | support.Other | 11 | 19 February 2009 16:38 |
| SCSI-IDE bridge + IDE to CF adapter - How can I make a backup? | Tuffy | New to Emulation or Amiga scene | 2 | 02 April 2008 21:14 |