I've got a bit of a strange issue with my nRF52832 which I can't for the life of me explain - so I shall try and explain...
I have loaded in the softdevice and a custom HCI serial bootloader - I say custom because I've disabled flow control and swapped the LED assignment. The softdevice and bootloader have been downloaded via SWD and I'm using the `nrfutil` utility to program the application when in bootloader mode. Flow control is disabled as the USB-to-serial adapter I'm using doesn't have the pins (TX, RX and GND).
This works perfectly well and I can update the device to my hearts content.
Now, if I power off the device and leave it for a few hours, when I power it back up I notice that the serial debug messages I spit out from my main application are a bit jumbled. When I then try and put the device into bootloader mode and attempt a firmware update, it fails EVERY time with the following:
[------------------------------------] 0%Timed out waiting for acknowledgement from device.
Failed to upgrade target. Error is: No data received on serial port. Not able to proceed.
Possible causes:
- bootloader, SoftDevice or application on target does not match the requirements in the DFU package.
- baud rate or flow control is not the same as in the target bootloader.
- target is not in DFU mode. If using the SDK examples, press Button 4 and RESET and release both to enter DFU mode.
I know that if I re-flash the softdevice and the bootloader then everything is fine and dandy again. I know for a fact that the device is definitely in DFU mode when attempting to flash via nrfutil.
It doesn't make sense, its like the baud rate has changed to a non-standard setting.
**UPDATE**
So this morning, I came back to my board which was fully working last night and I could no longer download any firmware updates due to the above issue. I re-flashed softdevice and bootloader using the SWD programmer then low and behold, it works again.
Now, for the kicker - if I unplug the SWD programmer from the USB port, the issue rears its ugly head again and any communication via UART is legible but most characters are scrambled. If I attempt a firmware update, it fails. If I re-plug in the SWD programmer back into the USB port, everything returns back to normal. Whaaaaaaat is going on!
**ANOTHER UPDATE**
If I disconnect all wires from the SWD programmer EXCEPT the VTref wire (3.3V on the board) then it still works perfectly. As soon as the VTref wire is disconnected, the UART gets all scrambled and the framing error (or whatever error) occurs. There is no GND reference going back to the SWD programmer - just the VTref signal connection.
I'm confused...