Just reading your description, I imagine that the power may not be sufficient.
I've seen similar symptom with other vendor's MCU when supply current/voltage was not good enough.
Can you try supplying external power to psoc5lp and see if there will be some improvement?
A common problem is connecting the programming signals with wires that are too long. 10cm length is about the limit for signal integrity issues. 5cm works extremely well.
Good luck with your project.
Hi, thank you it helped me solve the issue in programming psoc5lp to psoc5lp, but with esp32 its again the same issue.