Search code examples
visual-studiodebuggingatmelsamd21visualgdb

Error connecting DP: cannot read IDR-No connection could be made because target machine actively refused it


I could program and debug this project for the first time. But the problem is that I can't reprogram or debug it again. There is no bootloader on the chip. The only way to communicate with this chip is SWD. As a debugger, I am using Atmel ice. The microchip is SAMD21E16B-U. The project is created by Atmel Start. Visual Studio is used as an IDE to import the project.

After debugging again, the error is:

enter image description here

  • The problem may be because of setup. I am not sure what I missed. I followed the visualGDB website for importing this project.
  • I checked the power connection.
  • There is no option for "connect under reset" on visualgdb debug setting. However, this option was available on STM chips. enter image description here

I really appreciate it if you can guide me on what I can do for reprogramming this chip? Or which information I should look for. Thanks for any helpful recommendations, in advance.


Solution

  • The following steps solved my problems. I think erasing my chip was helpful to reprogram the chip. I am not sure which step exactly caused the error. But after these steps, I didn't get that error.

    • Choose the right chip: samd21e16b instead of samd21e16b-U (The first selection was based on a schematic. My schematic wasn't correct (look at the physical chips on our board or use a microchip studio. Microchip studio detected the right chip for me). I have selected an incorrect device while creating our project (e.g. Our device has different SRAM, Flash, and packages.)). Then, I needed to set up again and choose the right chip.
    • Erase the chip by microchip studio and was able to reprogram it. So, I am using microchip studio for erasing the chip and getting back to visual studio, and then reprogramming, or debugging it
    • Checked the power connection (connect the Vcc 3.3 by SWD connector and make sure that the green light on Atmel ice is on before debugging (The green led on Atmel ice is showing that the chip power is ok and correct) also, I should make sure that my chip is connected to pc by USB. It may be different in your chip to provide power)
    • I didn't change my debugger from Atmel ice to J-Link but it was a solution that the visualGDB (sysProgs) support team mentioned. I will only add their quotes briefly. It may be helpful for the ones who want to solve the problem by the visual studio and reset the chip. But I didn't change my debugger or didn't configure openOCD. I used microchip studio and reset the chip instead.

    VisualGDB Support team: This looks like a device connectivity issue rather than something VisualGDB-specific. Our best advice would be to try using Segger J-Link. It comes with its own fully supported replacement for OpenOCD, which generally works better in many edge cases. VisualGDB supports both OpenOCD and J-Link software, so all the features you previously used will continue working the same way. VisualGDB does not manage resetting/erasing directly. It simply launches the open-source OpenOCD tool that handles the low-level communication with the target. You might be able to configure OpenOCD to change the reset behavior by editing the OpenOCD script files, however, this is something to do at your own risk and it may require extensive research into OpenOCD internals. If you are looking for an easy out-of-the-box solution, please consider using Segger J-Link instead.