How to use FreeBSD camcontrol epc command with USB...

Created on: May 20, 2025

Answered using O3 by Chat01

Question

How to use FreeBSD camcontrol epc command with USB bridged SATA HDDs

Thought

Crafting steps for FreeBSD EPC

To use the camcontrol epc command with USB bridged SATA HDDs:

  1. Identify your disk: Run camcontrol devlist to confirm the disk, then test with camcontrol identify /dev/da0. Don’t forget to check pass-through support.

  2. **

Thought for 1m 30s

Answer

Below is a practical checklist you can follow to make camcontrol epc(8) work on a SATA hard-disk that sits behind a USB bridge on FreeBSD.


1 Check that the bridge really passes ATA commands

camcontrol (and SMART, APM, EPC, …) only work if the USB-to-SATA bridge implements SAT-2/SAT-3 ATA PASS THROUGH (12/16).
A fast way to test is:

sh
# Identify the drive through the SCSI layer camcontrol identify /dev/da0
  • If you see a normal IDENTIFY-DEVICE block, the bridge is translating OK.
  • If you get “unsupported field in SCSI command / ILLEGAL REQUEST”, the bridge does not forward ATA commands – you are out of luck with camcontrol on that enclosure. Many recent ASMedia, JMicron, Realtek, Cypress and Initio bridges work; older or very cheap ones often don’t. Smartmontools

2 Locate the right device node

USB disks appear as daX (and a matching passY) rather than adaX.
Either node works, but passY makes it absolutely clear you are talking to the CAM pass-through layer:

sh
# List all CAM devices camcontrol devlist # Example result <ST4000DM004-2CV104> at scbus2 target 0 lun 0 (pass4,da0)

3 Does the drive support EPC at all?

sh
camcontrol epc /dev/da0 -c status
  • Success ➜ the firmware replied with the current EPC state/timers.
  • “SETFEATURES EXTENDED POWER CONDITIONS … ABRT” ➜ the disk does not implement EPC (it may only have APM). The FreeBSD Forums

4 Enable EPC (only needed once per power-cycle)

sh
# Turn APM off first – spec says APM and EPC are mutually exclusive camcontrol apm /dev/da0 # no number = disable # Enable the EPC feature set camcontrol epc /dev/da0 -c enable

If that works you are ready to program timers or disable individual low-power states. Example recipes below come straight from real-world usage and the FreeBSD community docs Server Fault:


5 Typical things you may want to do

GoalCommandNotes
See current timers / allowed statescamcontrol epc da0 -c statusShows which EPC timers are running and which states (Idle _a/b/c, Standby _y/z, DevSleep) the drive may enter.
Disable head-parking but keep spin-down<br>camcontrol epc da0 -c state -d -p Idle_b<br>camcontrol epc da0 -c state -d -p Idle_cUse -s to make it persistent.
Disable spin-down completelycamcontrol epc da0 -c state -d -p Standby_z -s-d = disable that state, -s = save to disk NVRAM so it survives power-cycling.
Change a timer (e.g. Standby_z after 1 h)camcontrol epc da0 -c timer -p Standby_z -T 3600 -e -s-e first enables EPC if it was still off. -T is in seconds; fractional values allowed (e.g. 60.5).
Instantly put the drive into Standby_z (for scripts)camcontrol epc da0 -c goto -p Standby_zUseful when you want to spin a disk down right now.

(Run the commands as root; they are safe for data but a typo can still leave a drive unwritable until the next reset.)


6 Persisting the settings

  • All EPC state or timer sub-commands accept -s – that asks the firmware to copy the current value into its “saved” page so it survives a power loss.
  • Some consumer drives ignore -s; simply re-run your chosen commands from /etc/rc.local or a periodic script at boot.

7 Troubleshooting cheat-sheet

SymptomLikely cause / fix
camcontrol: ATA SETFEATURES… ABRT immediatelyDisk does not support EPC – stay with APM instead.
Sense key ILLEGAL REQUEST from umassBridge does not pass ATA commands ➜ try a different enclosure.
Works on SATA but not on USBSame as above – or the bridge only supports 12-byte pass-through. FreeBSD uses 16-byte by default; rebuild kernel with CAM_ATA_PASS_THROUGH_12 or test with smartctl -d sat,12 to confirm.
Settings work until reboot onlyAdd -s, or run the commands from an rc script.

8 Take-aways

  • camcontrol epc works fine through USB as long as the bridge is SAT-compliant.
  • Use the daX/passY node, enable EPC once, then configure timers or disable unwanted states with -c timer / -c state.
  • Save with -s if the drive firmware supports it; otherwise replay the commands at boot.

After you have verified that your enclosure passes ATA commands, the examples above should let you tune or disable any power-saving state on the drive just as if it were plugged into a native SATA port.

Question

How to solve "The epc subcommand only works with ATA protocol devices" error for command "camcontrol epc /dev/da1 -c status"

Thought

The error usually appears when a controller cannot treat the device as ATA. This happens because CAM sets the protocol to PROTO_SCSI for USB mass storage unless the bridge supports SAT translation. You can verify this by using camcontrol inquiry and testing with camcontrol identify and smartctl. If the bridging doesn't pass ATA, it can’t use certain features. You need to identify the chipset, and if it's not compatible with SAT, alternative hardware may be necessary for full functionality.

If the bridging device uses 12-byte pass-through, you can work around it by adding a specific configuration or compiling the kernel with the right options. Alternatively, use smartctl -d sat,12 to test if it works with the 12-byte format. If the bridge doesn't support SAT, switching to a compatible enclosure might be the only solution. A few enclosures like ASM1153E, JMS578, and RTL9210B support SAT. The issue is that CAM didn't recognize the device as an "ATA protocol" device, explaining the error.

Thought for 2m 23s

Answer

Why FreeBSD prints

camcontrol: The epc subcommand only works with ATA protocol devices

camcontrol epc refuses to run unless the CAM layer thinks the target speaks the ATA protocol.
When a disk is behind a USB–-to-SATA adapter the kernel sees it as a SCSI device (daX).
If (and only if) the bridge advertises SAT (SCSI → ATA Translation) CAM marks the device internally as PROTO_ATA, so camcontrol epc, apm, SMART, etc. work.
If the bridge does not expose SAT CAM marks it PROTO_SCSI, and epc bails out with the message you are seeing. Wikipedia The FreeBSD Forums


Checklist to find (and fix) the problem

StepCommandWhat you should seeWhat it means
1. Does the kernel think it’s ATA?camcontrol identify /dev/da1A normal IDENTIFY blockBridge is SAT-compliant → jump to step 3
passN: <…> SPC-4 SCSI device or “ATA IDENTIFY failed”Bridge is not SAT-compliant → you cannot use epc, go to Only real fix below
2. Double-check with smartctlsmartctl -d sat -i /dev/da1Drive info printsConfirms SAT works
smartctl -d sat,12 -i /dev/da1 prints but plain -d sat failsBridge only accepts 12-byte ATA PASS-THROUGH – see Old bridges below FreeBSD Manual Pages
3. Now ask EPC againcamcontrol epc /dev/da1 -c statusEPC state/timersSuccess – you’re done

If it still fails even though identify works

  1. Old bridges that only support 12-byte pass-through

    FreeBSD uses the 16-byte SAT commands by default.
    Re-build your kernel with

    options CAM_ATA_PASS_12
    

    or, on 14-CURRENT and newer, add to /boot/loader.conf:

    kern.cam.ata.pass_12=1
    

    Then reboot and repeat the test. FreeBSD Manual Pages

  2. Ancient userland / kernel

    EPC support for SAT devices was completed in FreeBSD 13.0.
    Make sure you’re on at least 13.2-RELEASE or any 14-STABLE snapshot.


Only real fix when the bridge is not SAT-compliant

If step 1 already shows a plain “SPC-4 SCSI device”, your enclosure does not forward ATA commands.
There is no software workaroundcamcontrol epc, SMART, APM, and friends will never work through that adapter.
You need a USB-SATA bridge that advertises SAT (look for chips such as ASMedia ASM1153/1153E, ASM235CM, JMicron JMS567/JMS578, Realtek RTL9210) or plug the disk into a native SATA port. The FreeBSD Forums


Quick summary

  • The error simply says “CAM does not see an ATA device here”.
  • Most of the time that means your USB enclosure doesn’t implement SAT; replace it.
  • If the bridge is SAT but only handles 12-byte commands, enable CAM_ATA_PASS_12 or update to a current kernel.
  • Once the bridge passes ATA, camcontrol epc works exactly as it does on a direct SATA port.

Run the three-step checklist above and you’ll know immediately which case you have and how to proceed.

Share this Q&A