If factory data reset is done, then most likely it's hardware. Easiest one is replacing the USB cable with another and test it. I've got a Redmi Note 7 that had a faulty cable recently.