Linux detect/read/write from a sata drive

I am trying to verify an AHCI HBA that is built using the Amirix/FPGA board. The Amirix AP1000 board is sitting on the PCI bus of the PC. There is no SATA drive attached to the AHCI HBA, but a collection of SRAM(onchip) is to be treated as sectors of data on a real disk.

The goal is to have the SATA drive recognized and accessed using Linux.
i.e.If I run Linux, the PC host should think it sees a real disk attached.

I am new to Linux, so I am not sure how to do that, I will really appreciate if someone can give me some hints/guidelines/pointers/advices/etc.

Currently, I am running Debian Etch with kernel 2.6.25.2, which already has AHCI module. Since my AHCI HBA is not fully implemented/only has few features/using ABAR=2 (instead of 5)/etc, so I need to modify the AHCI driver code to match what I have implemented/modification in the implementation.

I did some online searching…
Here is what I think I should do in order to get my host pc to think/detect the SATA drive, and able to read/write the driver. Please correct me if my steps/procedures do not make sense.

1. modify the AHCI driver
2. rebuild/recompile it..and load it into the kernel (insmod ahci.ko)
3. Creates a special block device file named xxx and gives it major number and minor number.

mknod /dev/xxx b major# minor#

However, I don’t really know what major or minor # that I should use?
From linux-2.6.25.2/Documentation/device.txt….it kinda explains what major/minor number to use according to the type of the device….is that what I am supposed to look to determine the major and minor number. There is a section about SATA drive, but still confusing to me what I should use..

4. Do I need to mount the SATA drive? If yes, how do I do that…just use the “mount” command

5. read/write to the SATA drive. I only know the ”echo”, is that the right way to write/read from the SATA drive?

My project is due really SOON, please HELP. Thanks for helping in advance!

0

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Re: Linux detect/read/write from a sata drive

1. modify the AHCI driver
- OK

2. rebuild/recompile it..and load it into the kernel (insmod ahci.ko)
- Fine if you don't actually need it to boot your machine; is your lack of features going to cause the driver to crash or hang?

3. Creates a special block device file named xxx and gives it major number and minor number.
- You can use any major/minor pair which does not clash with already assigned numbers. The major/minor list in 'device.txt' will slowly become obsolete as driver maintainers switch to dynamically assigned numbers - the catch is that maintainers would much rather do more interesting things like write a new driver.

4. Do I need to mount the SATA drive? If yes, how do I do that…just use the “mount” command
- NO. mounting the drive requires that it has a valid partition scheme and filesystem; instead you have to play with the raw device.

5. read/write to the SATA drive. I only know the ”echo”, is that the right way to write/read from the SATA drive?
- use 'dd' (man dd). You can read/write an arbitrary length of data from a device starting at an arbitrary offset.

Syndicate content