Contents:
Key chain camera (Hetai HD-818) hardware modification
How the switching to the USB mode works?
Convert dedicated emergency charger to a standard charger
Convert dedicated car charger to a standard charger
Related: Posts #4266, #5013, #5995, #5998, #6011, #6018 and #6026 in The REAL (#11) HD Key Cam Thread on RC Groups.com, USB Mini connectors
I
was dissatisfied with a need of a dedicated car “charger” and especially
with the fact, that it depletes battery during recording. Use of a
standard charger switches the camera to the USB mode and makes recording
control impossible. Well, it is basically a firmware problem, but as I
don't have many changes to fix the firmware, I decided to poke into the
hardware and create a circuit that fixes this problem.
There must be a voltage detector that detects USB power voltage on the USB pin 1. The nearest parts there are:
Apparently one of the resistor is the right way to search. As one of these resistors is the 0R, we have a clean candidate.
It was easy to disable switching to mass storage or webcam mode at all. Just removed a single 0R resistor and the camera will never more switch to USB modes:
Right
side of the removed resistor is connected directly to USB pin 1 (Vcc).
Left side of the removed resistor is connected to the mass storage switch. If the voltage there is below 4.1V, the device remains in normal mode. If the voltage raises above 4.3V, the camera switches to mass storage or webcam mode and activates USB circuits (like the pull-up).
We need to detect status of the USB data lines and turn USB mode switch on only if they are wired to the real USB port.
So we need to detect that USB D+ or D- lines have proper wiring. (Chargers don't wire these lines, some high current chargers short D+ and D-.)
It is not as elegant as firmware modification to not switch to mass storage if handshake fails, but it works nearly exactly in the same way. Behavior after calling of “Safely remove the device” in the computer is the only difference between this solution and the standard software solution (simple detector cannot detect software USB suspend).
Discrimination between USB host and USB charger is not as simple as I initially thought. First of all, I needed to know the exact behavior of the hardware, which may work in several states.
The camera has three different USB modes:
I implemented detection while the camera is on and the camera mode is active (see 2. above). It seems to be very intuitive, avoids need of dedicated charger, and not so complicated.
Here is my solution (the design was created in gEDA using toporouter):

USB Vcc means pin 1, USB D+ means USB data line, USB mode switch means left pin of removed 0R resistor, the main part is a cheap comparator with rail-to-rail support (MCP6541), diode (TS4148) is a plain cheap small SMD diode (0805), resistors and capacitors are standard SMD (0402) parts.
Using a 1MΩ pull-up to 5V should be safe according to the USB specification. It introduces effective error that is equivalent to about 2% change of the D+ pin pull-up resistor. USB v2 resistor ECN allows much higher tolerance.
Once the circuit is powered but the input voltage decreases below 0.06V, the output raises to 5V. Due to the positive feedback, it never fails back. Only turning or the power or raising input voltage above 4.2V (it never happens on USB data lines) may reset it back. It is exactly what we want: When our circuit turns on USB mode, voltage on D+ raises to 3.0V, but we want to ignore that – we already detected USB data lines and this should be true as long as power on pin 1 exists.
The board was assembled on a small piece of a single sided 0.8mm thick copper clad (FR-4 type) using SMD parts. It is possible to get MCP6541 and diode even in yet smaller package, but my board is already small enough to fit inside the camera.
The finished board was connected to the main board with a thin wires (from an old Ultra ATA cable), covered by a Kapton tape (to prevent short circuits) and placed into a free space between the USB connector and the card holder. (You can also see the removed resistor 0R on the top of the USB connector on the photo above.)
As a last step, you can remove the Schottky diode near the pin 4 of the USB connector to disable dedicated “chargers”.
The complete assembly adds about 0.26g to the weight of the camera.
After the modification of the camera, there is no need to have a dedicated AA charger that overcharges the camera battery.
Conversion to a standard charger is really simple: carefully open the connector and resolder red cable from pin 4 to pin 1. Hopefully, manufacturer did not cut pin 1, so I can recycle the connector.
Now I have a standard emergency charger that can be used with any device.
After the modification of the camera, there is no need to have a dedicated car charger that never fully charges the camera battery.
To convert it back to 5V, you need to replace R3 on the board with a resistor (or combination of resistors) with value about 30.3kΩ.
The connector of a dedicated charger cannot be disassembled. You have to cut it and replace with another one with correct wiring.