This is the circuit I designed and use.

As dynamo voltage output approaches 5 volts the impedance of the Ni-MH batteries becomes so high the dynamo is limited to a maximum of 5.2 volts. This is well within USB voltage requirements and sufficient to recharge the batteries. The batteries also absorb excess current as recharging current protecting the USB device. Batteries must be solder tab type with no possibility of poor or open connections. Open or poor connections would allow unregulated voltage and current which could damage the device plugged into the USB port. Any standard dynamo headlight can be used in place of the duel LED headlight shown in the circuit. In places such as tunnels where you would need your headlight during the day you may switch from the USB circuit to the headlight circuit allowing the batteries to continue to provide limited power to the USB device. It's not possible to completely recharge most USB devices without help from the dynamo. The batteries may be rapid recharged by disconnecting any USB devices from the USB connector. Most AA Ni-MH batteries which are completely discharged may be fully recharged by the dynamo in about 2.5 hours. Your cycle computer trip time can be used to time battery charging. Simply reset it and when it shows 2.5 hours your batteries should be fully recharged. It will automatically start and stop timing as you start and stop moving allowing you take breaks during this time.