Page 1 of 1

Calculating CHS for USB memory

Posted: Tue Dec 10, 2013 2:48 am
by ZigZogZang
Hey,
I have problem with reading usb memory.
I have properly calculated data sector and now it's a moment where i suppose to use 0x13 (ah=0x02) interrupt for reading. Well while I was using code for floppy disk then it was normal to calculate CHS to get known head/sector/cylinder becouse of floppy's geometry and I have been using this kind of pattern to calculate it:

absolute sector = (logical sector mod sectors per track) + 1
absolute head = (logical sector / sectors per track) MOD number of heads
absolute track = logical sector / (sectors per track * number of heads)

I have found this code

https://github.com/ishanthilina/USB-FAT ... c/boot.asm

and this pdf file

https://github.com/ishanthilina/USB-FAT ... tation.pdf

and guy says to use it same way for usb memory but wtf ? ;) USB memory has sd card inside that hasn't cylinder etc, but a microcontroller inside it. So what for CHS is here and is int 13h (ah=0x02) correct interrupt to read usb memory ?

Re: Calculating CHS for USB memory

Posted: Tue Dec 10, 2013 3:02 am
by wichtounet
What about Extended Read Sectors From Drive (int 0x13 (ah = 0x42)) ?

With that you can read using LBA. This call does not support floppy.

Re: Calculating CHS for USB memory

Posted: Tue Dec 10, 2013 4:02 am
by iansjack
Set the geometry to what you want it to be.

http://www.damnsmalllinux.org/wiki/sett ... drive.html

Re: Calculating CHS for USB memory

Posted: Tue Dec 10, 2013 4:42 am
by ZigZogZang
wichtounet wrote:What about Extended Read Sectors From Drive (int 0x13 (ah = 0x42)) ?

With that you can read using LBA. This call does not support floppy.
Yea, but I don't understand ""USB-FAT32-BOOTLOADER" @ github project, what is it ? Guy who did it definitely use 0x13 (ah=0x02) interrupt for floppy and he is also calculating CHS. Why ? What for ?


One more question about 0x13 (ah=0x42) interrupt:
How about drive index (parameter for interrupt) ? How to get it for USB memory stick ?
iansjack wrote:Set the geometry to what you want it to be.

http://www.damnsmalllinux.org/wiki/sett ... drive.html
So use which one ? ah=0x02 or ah=0x42 ? What's difference ?