# AHCI kernel cannot find cdrom



## Beeblebrox (Aug 15, 2012)

I have a custom kernel. HDD is handled through AHCI. My CDROM does not show up at all (not in dmesg nor in pciconf). My kernel.config is below. As you can see, ATA_CAM is enabled for the ata-type cdrom and it should work over the cam layer but something is missing.

```
device          acpi
device          pci
options         ATA_CAM

# SCSI peripherals - Eenable if using ATA_CAM !!
device          ahci
device          scbus           # SCSI bus (required for SCSI)
device          da              # Direct Access (disks)
device          cd              # CD
device          pass            # Passthrough device (direct SCSI access)
#device         ch              # SCSI media changers
#device         sa              # Sequential Access (tape etc)
```
Maybe I should have enabled ch? I tried to find the module to kldoad it but cannot find the module name for ch.


----------



## Bunyan (Aug 15, 2012)

You forgot to add ALL needed ATA related options.
Here's an example from my config. 

```
# The 'ATA' driver supports all ATA and ATAPI devices, including PC Card
# devices. You only need one "device ata" for it to find all
# PCI and PC Card ATA/ATAPI devices on modern machines.
# Alternatively, individual bus and chipset drivers may be chosen by using
# the 'atacore' driver then selecting the drivers on a per vendor basis.
# For example to build a system which only supports a VIA chipset,
# omit 'ata' and include the 'atacore', 'atapci' and 'atavia' drivers.
device		ata
device		atadisk		# ATA disk drives
device		atapicd		# ATAPI CDROM drives
device		atapicam	# emulate ATAPI devices as SCSI ditto via CAM
				# needs CAM to be present (scbus & pass)
# Modular ATA
device		atacore		# Core ATA functionality
device		ataintel	# Intel
```


----------



## Beeblebrox (Aug 15, 2012)

ATA and AHCI are mutually exclusive. You either use ATA or you use AHCI - not both. In fact, the kernel build will refuse it if you try to enable both, while trying to kldload an ATA module later will give a "version mismatch" error.

That's why there's ATA_CAM. AHCI and ATA_CAM are not mutually exclusive and ATA_CAM is what should be used in the event you are using AHCI but have ATA devices also.


----------



## kpa (Aug 15, 2012)

How are you going to get the achi(4) driver to attach to a non-ACHI controller? You still need the ata(4) to drive non-AHCI ATA-controllers, there's no way around it.

This is my pciconf(8) output, both ata and ahci are included in the kernel, ATA_CAM option turned on.


```
ahci1@pci0:0:31:2:      class=0x010601 card=0xb0051458 chip=0x27c18086 rev=0x02 hdr=0x00
    vendor     = 'Intel Corporation'
    device     = 'N10/ICH7 Family SATA AHCI Controller'
    class      = mass storage
    subclass   = SATA
ahci0@pci0:2:0:0:       class=0x010601 card=0xb0001458 chip=0x2363197b rev=0x02 hdr=0x00
    vendor     = 'JMicron Technology Corp.'
    device     = 'JMB362/JMB363 Serial ATA Controller'
    class      = mass storage
    subclass   = SATA
atapci0@pci0:2:0:1:     class=0x010185 card=0xb0001458 chip=0x2363197b rev=0x02 hdr=0x00
    vendor     = 'JMicron Technology Corp.'
    device     = 'JMB362/JMB363 Serial ATA Controller'
    class      = mass storage
    subclass   = ATA
```


----------



## Beeblebrox (Aug 15, 2012)

From /usr/src/UPDATING, *20110424*


> The GENERIC kernels for all architectures now default to the new CAM-based ATA stack. It means that all legacy ATA drivers were removed and replaced by respective CAM drivers....
> 
> It is possible to load devices ahci, ata, siis and mvs as modules, but option ATA_CAM should remain in kernel configuration to make ata module work as CAM driver supporting legacy ATA controllers. Device ata still can be used in modular fashion (atacore + ...). Modules atadisk and atapi* are not used and won't affect operation in ATA_CAM mode. Note that to use CAM-based ATA kernel should include CAM devices scbus, pass, da (or explicitly ada), cd and optionally others. All of them are parts of the cam module.



It looks like only these 2 need to be added for ATA_CAM to work. Will try and post result.

```
device		atacore
device		atapci
```


----------



## kpa (Aug 15, 2012)

What that says isn't what you think it says. It says that the ata(4) driver can be included in the kernel with the device keyword in the kernel config or loaded as a module, both ways are still valid.  This is an excerpt from the GENERIC kernel config of 9.1 release candidate(no there hasn't been any change in these options since 9.0):


```
# ATA controllers
device          ahci            # AHCI-compatible SATA controllers
device          ata             # Legacy ATA/SATA controllers
options         ATA_CAM         # Handle legacy controllers with CAM
options         ATA_STATIC_ID   # Static device numbering
device          mvs             # Marvell 88SX50XX/88SX60XX/88SX70XX/SoC SATA
device          siis            # SiliconImage SiI3124/SiI3132/SiI3531 SATA
```

So in a nutshell, you're missing the ata(4) driver from your kernel config.


----------



## Beeblebrox (Aug 15, 2012)

After including the slim set of atacore and atapci options, the dvd-rw device was detected but had functionality problems. I removed those two and just added ata as you noted and read functionality for cd and dvd returned.

A different strange problem now however, sysutils/brasero does not detect write functionality of the dvd and a writer in brasero cannot be selected.


----------



## znanie (Nov 12, 2012)

Hello,

I'm having trouble getting my ide dvd drives to work with 9.0.  They all worked fine with 8.2.  8.2 booting produced a /dev/acd0  but 9.0 does not.  9.0 works with the cdrom drive that I have but not with the dvd's.

Can you post the portion of the kernel configuration file that got the drives to work?

Thank you.


----------



## mav@ (Nov 13, 2012)

Everything should work with default GENERIC kernel, but CD device is now called /dev/cd0. If it doesn't appear, please boot with verbose kernel messages (press respective button in boot menu) and upload somewhere your /var/run/dmesg.boot file.


----------



## znanie (Nov 14, 2012)

Thanks Mav,

I'm going to try a new DVD drive (Lite-On).  

If it still doesn't work,  I'll post my dmesg output.

Kirill


----------

