Discovering USB disconnect/reboot

Want to build very simple arduino relay:

PC -USB(serial-over-usb)-arduino-GPIO-relay-(hdd,...)

Aka: switch power of some devices on the PC on/off via relay. I would not even need an arduino project because usb-relays are readily available, BUT:

When the PC reboots, i need the relay to switch to off without any input from the USB port, so that a reset safely gets the PC into a safe state of operations instead of hanging on a powered-on device (bad disk or the like). But i can not get the PC to really withdraw power from the USB port, so the relay i have will not reset.

When looking at an arduino solution, i was wondering how the poor arduino would know whether the PC resets. Most arduino boards seem to use an external USB->serial adapter chip (CH340 or the like) and connect via serial port to the arduino. I don't know if there is any option to get a reset notification pin from the serial port side to the arduino.

If the arduino chip has native USB support and the serial port over USB is just part of the software/firmware on the arduino, i am a lot more hopeful that there would be a reset signal whenever the PC reboots and after reboot the new operating system initializes the USB ports.

Any insight/suggestions ?

Post a timing diagram of your expected setup.

From your description I got the impression that you expect that Arduino to cut power from the hard drive if the PC is reset (p.e. by the reset button). You can do that but if you wait for the reset message of the operating system you might be much to late to keep a malicious hard drive from influencing the boot process.

The only way to get to that target is to periodically inform the Arduino to keep the relay up and if that information is not received for let's say one second, cut power by releasing the relay.

pylon:
Post a timing diagram of your expected setup.

Nah... I think you nailed it without one.

pylon:
From your description I got the impression that you expect that Arduino to cut power from the hard drive if the PC is reset (p.e. by the reset button). You can do that but if you wait for the reset message of the operating system you might be much to late to keep a malicious hard drive from influencing the boot process.

Yes, ideally i would like to know when the PC is really starting to reboot. As you suggested: I tested rebooting with a broken drive powered on, and it severely prolonged the boot process.

pylon:
The only way to get to that target is to periodically inform the Arduino to keep the relay up and if that information is not received for let's say one second, cut power by releasing the relay.

Watchdog, style, yes. More work on the software side of the PC, so not ideal, but would work.

But just for the fun of it: What is the smallest/cheapest arduino model where the USB port that can also power the arduino has the USB attached directly to the arduino and USB implemented in the arduino firmware ?

For example, if the USB stack would be able to emulate a HID (kbd), it could be that the PC initializes it before probing all disk drives.

Why not boot the pc from a different device? CD or Thumb drive, etc.

Paul

But just for the fun of it: What is the smallest/cheapest arduino model where the USB port that can also power the arduino has the USB attached directly to the arduino and USB implemented in the arduino firmware ?

Probably the Micro.

For example, if the USB stack would be able to emulate a HID (kbd), it could be that the PC initializes it before probing all disk drives.

You can try that but then don't use HID as the USB boot keyboard is not HID. HID is used to communicate with an operating system, the BIOS/EFI/UEFI use a simpler protocol.