reset chip via JTAG

Before programming, the chip is nor properly reset, causing the peripherals like timers to continue operating.
some real world hardware like Motors driven by PWM do not like that. And occasionally the chip hangs after programming. This patch resets the chip before programming to stop peripherals, and after programming for a clean start. This is the behaviour of the original software, sending a 2 causes a 10ms reset pulse.