Error connecting DP: Cannot read IDR when flashing external MCU via OpenOCD on Jetson Orin Nano

Issue Overview

Users are experiencing difficulties when attempting to use the Nvidia Jetson Orin Nano to flash an external MCU (specifically a SparkFun SAMD21 Dev Breakout Board) using OpenOCD v12. The main symptom is an error message stating "Error connecting DP: cannot read IDR" when running OpenOCD after following a series of setup steps. This issue occurs during the initial setup and configuration process, preventing users from successfully flashing the external MCU.

The problem appears to be related to GPIO pin configuration and the use of the linuxgpiod driver for OpenOCD. The issue impacts the ability to use the Jetson Orin Nano for external MCU programming, which is a critical function for many embedded system development projects.

Possible Causes

  1. Incorrect GPIO pin configuration: The default configuration of the PAA.01, PAA.02, and PAA.03 pins may be set for CAN bus usage instead of SWC/SWD/RSTn functions required for OpenOCD.

  2. Incompatibility between OpenOCD and Jetson Orin Nano: The OpenOCD software may not be fully compatible or verified for use with the Jetson device.

  3. Improper driver setup: The linuxgpiod driver may not be correctly configured or recognized by the system.

  4. Missing low-level pin configuration: There might be additional steps required to properly set up the GPIO pins for use with OpenOCD that are not covered in the current setup process.

  5. Hardware connection issues: Incorrect wiring or faulty connections between the Jetson Orin Nano and the external MCU could lead to communication errors.

  6. Software version incompatibility: The version of OpenOCD or the Jetson Linux (L4T) may not be compatible with each other or with the specific hardware setup.

Troubleshooting Steps, Solutions & Fixes

  1. Verify GPIO pin configuration:

    • Check the current pinmux spreadsheet to ensure PAA.01, PAA.02, and PAA.03 are not being used for CAN bus.
    • Use the following command to view current GPIO configuration:
      sudo cat /sys/kernel/debug/gpio
      
  2. Configure GPIO pins manually:

    • If necessary, manually configure the GPIO pins using the Jetson GPIO Python library or sysfs interface:
      import Jetson.GPIO as GPIO
      GPIO.setmode(GPIO.BOARD)
      GPIO.setup(37, GPIO.OUT)  # SWCLK
      GPIO.setup(33, GPIO.OUT)  # SWDIO
      GPIO.setup(29, GPIO.OUT)  # RSTn
      
  3. Verify OpenOCD installation:

    • Ensure OpenOCD is correctly installed and built with the appropriate flags:
      ./configure --enable-dln-2-gpiod --enable-linuxgpiod
      make
      sudo make install
      
  4. Check OpenOCD configuration:

    • Review and modify the /usr/local/share/openocd/scripts/interface/dln-2-gpiod.cfg file to ensure correct pin mappings.
  5. Test OpenOCD on a host PC:

    • As suggested by NVIDIA support, try running OpenOCD on a Ubuntu host PC first to isolate whether the issue is specific to the Jetson device.
  6. Use alternative GPIO control method:

    • If linuxgpiod is not working, try using the sysfs GPIO interface instead:
      echo 3 > /sys/class/gpio/export
      echo 2 > /sys/class/gpio/export
      echo 1 > /sys/class/gpio/export
      echo out > /sys/class/gpio/gpio3/direction
      echo out > /sys/class/gpio/gpio2/direction
      echo out > /sys/class/gpio/gpio1/direction
      
  7. Check hardware connections:

    • Double-check all wiring between the Jetson Orin Nano and the SAMD21 Dev Breakout Board, ensuring proper connections for SWCLK, SWDIO, RSTn, 3.3V, and GND.
  8. Update Jetson Linux and OpenOCD:

    • Ensure you are using the latest compatible versions of Jetson Linux (L4T) and OpenOCD.
  9. Consult NVIDIA Developer Forums:

    • If the issue persists, create a new thread in the NVIDIA Developer Forums, providing detailed information about your setup, including:
      • Jetson Orin Nano model and L4T version
      • OpenOCD version and configuration
      • Complete error logs
      • Any modifications made to the default configuration
  10. Consider alternative flashing methods:

    • If OpenOCD continues to be problematic, explore other flashing methods compatible with the SAMD21 MCU and Jetson Orin Nano, such as using a dedicated programmer or exploring NVIDIA-specific tools for external MCU programming.

Note: As NVIDIA support has indicated that they don’t verify OpenOCD for this type of usage on Jetson devices, you may need to rely on community support or explore alternative solutions if these troubleshooting steps do not resolve the issue.

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *