CMSIS-DAP cannot read IDR

(See also my post CMSIS-DAP command CMD_DAP_SWJ_CLOCK failed . After solving that error Arduino IDE v2.0.3 reported the error 'Error connecting DP: cannot read IDR'.

The following 'dialog' on Picoprobe SWDCLK and SWDIO lines catched with an oscilloscope:

Image of the: hardware setup

The sketch:

// The MIT License (MIT)
// Copyright (c) 2019 Ha Thach for Adafruit Industries

#include <SPI.h>
#include <SdFat.h>
#include <Adafruit_SPIFlash.h>

// for flashTransport definition
#include "flash_config.h"

Adafruit_SPIFlash flash(&flashTransport);

/*
* Notes @PaulskPt 2022-12-14 13h52 utc
* The Adafruit external SPI_Flash device I have is: W25Q128JV   JEDEC ID 0xEF4015
* See: I:\Pico\adafruit\Adafruit_SPIFlash-master\src\flash_devices.h L474-L500
*
* Update 2022-12-15 11h53 utc
* Because I was not able to run this sketch on the RPi Pico W of the 
* Pimoroni INKY GRAME, I try today with a single RPi Pico H, on a breadboard.
*
*/

/*  
*  If you want to use a specific flash device, for example for a custom built
*  board, first look for it in Adafruit_SPIFlash\src\flash_devices.h
*  If it isn't in there you need to create your own definition like the
*  W25Q80DLX_EXAMPLE example below.
*  These definitions need to be edited to match information on the data sheet
*  of the flash device that you want to use.
*  If you are not sure what the manufacture ID, memory type and capacity values
*  should be, try running the sketch anyway and look at the serial output
*  The flash device will report these values to you as a single hexadecimal
*  value (the JDEC ID)
*  For example, the first device on the list - the W25Q80DLX - will report its
*  JDEC ID as 0xef4014, which is made of these three values:
*  manufacturer_id = 0xef
*  memory_type     = 0x40
*  capacity        = 0x14
*  With this macro properly defined you can then create an array of device
*  definitions as shown below, this can include any from the list of devices in
*  flash_devices.h, and any you define yourself here
*  You need to update the variable on line 81 to reflect the number of items in
*  the array
*  You also need to uncomment line 84 and comment out line 81 so this array
*  will be passed to the flash memory driver.
*
*  Example of a user defined flash memory device:
*/

#if !defined(W25Q128JV_SQ)
/* 16 MiB */ 
/* 
  #define W25Q128JV_SQ {
    .total_size = (1UL << 24),
    .start_up_time_us = 5000,
    .manufacturer_id = 0xef,
    .memory_type = 0x40,
    .capacity = 0x18,
    .max_clock_speed_mhz = 133,
    .quad_enable_bit_mask = 0x02,
    .has_sector_protection = false,
    .supports_fast_read = true,
    .supports_qspi = true,
    .supports_qspi_writes = true,
    .write_status_register_split = false,
    .single_status_byte = false,
    .is_fram = false,
  }
*/
#endif


/* Next definition from file: https://github.com/adafruit/Adafruit_SPIFlash/blob/master/src/flash_devices.h */
/*
 * Create an array of data structures and fill it with the settings we defined
 * above. We are using two devices, but more can be added if you want.
 *
*
static const SPIFlash_Device_t my_flash_devices[] = {
  W25Q128JV_SQ,   // W25Q128JV_EXAMPLE,
};
*/

/*
 * Specify the number of different devices that are listed in the array we just
 * created. If you add more devices to the array, update this value to match.
 *
const int flashDevices = 1;
*/

// the setup function runs once when you press reset or power the board
void setup() {
  Serial.begin(115200);  // Serial connected to RPi Pico H on COM19
  while (!Serial)
    delay(100); // wait for native usb

  pinMode(LED_BUILTIN, OUTPUT);
  digitalWrite(LED_BUILTIN, HIGH);  // Switch LED on to indicate we have power.
  /*
    Serial.print("we\'re using the following flash with capacity: 0x");
    Serial.println(my_flash_devices[0].capacity, HEX);
  */
  Serial.println("\nAdafruit Serial Flash Info example");  
  flash.begin();

  /*
    Due to the 'Error: CMSIS-DAP command CMD_DAP_SWJ_CLOCK failed',
    in the gdb-server window, after clicking on 'Start Debugging' (top left of the IDE window)
    and the fact that UART0 (GP0 and GP1) of the RPi Pico W are connected to GP4 and GP5 of RPi Pico H (Picoprobe)
    and SWD (SWCLK and SWDIO) of the RPi Pico W are connected to GP2 and GP3 of the RPi Pico H (Picoprobe),
    in an attempt to solve this error, I try to not activate Serial1 in this sketch

  */
  // Tools > DEBUG level = All
  // Serial1 (Tools > DEBUG port) connected to Raspberry Pi Pico H (PicoProbe) (PC COM21)
  // Serial1.begin(115200);


  // Using a flash device not already listed? Start the flash memory by passing
  // it the array of device settings defined above, and the number of elements
  // in the array. flash.begin(my_flash_devices, flashDevices);
  //flash.begin(my_flash_devices, flashDevices);

  uint16_t cnt = 0;
  bool show_info = true;
  while (flash.isBusy()) {
    delay(200);
    cnt += 1;
    if (cnt > 1000) {
      Serial.println("timeout: flash is busy");
      show_info = false;
      break;
    }
  }
  if (show_info) {
    Serial.print("JEDEC ID: 0x");
    Serial.println(flash.getJEDECID(), HEX);
    Serial.print("Flash size: ");
    uint32_t f_size = flash.size();
    Serial.println(f_size);   /* 16 MB = 16777216 Bytes (in binary) */
    Serial.print("Flash size/1024 = ");
    Serial.println(f_size / 1024);
    delay(10000);
  }
}

// Additions by @PaulskPt
uint16_t loop_nr = 1;

void loop() {
  // nothing to do
  Serial.print("Loop nr: ");
  Serial.println(loop_nr);
  loop_nr += 1;
  if (loop_nr > 1000)
    loop_nr = 1;
  delay(5000);
}

What do you try to use?
I get: you want to sent debug info via DAP (debug) to host, e.g. as ITM messages.

I use it.
What is important to know:

  1. You have to enable ITM and print debug messages into ITM channel.
  2. When you start debugger with the ITM Trace, e.g. STM32ST-Link-Utility: the SWO viewer core clock frequency must match with your real MCU core clock
  3. the Single Wire Debug (SWD) signal SWO must be connected.

Using DAP and ITM, with SWO viewer, works fine for me.

Check:
a) do you have SWO wired (connected)?
b) is ITM enabled and do you print to ITM channel?
c) when you start debugger tool with SWO Viewer: do you specify the correct MCU core clock?

Hi, Tjaekel, thank you for your reply!
I am new to DAP debugging. I don't know what are ITM messages.

The script running on the DUT is a trial to communicate with an Adafruit SPI FLASH RAM. Tried to read the capacity info of the SPI FLASH. Since I received a 0 value I wanted to try debugging.

Since the DAP communication is failing I did not arrive to the point where I can receive, via de Picoprobe, the print output of the DUT (using the UART data).

I just want to try the 'road' that the documentation for the RPi Pico describes. Setting up other type of debugging environments needs the installation of a lot of other tools. I want to keep it simple.
What I am trying to do is for a hobby project and via debugging also to learn more about controlling this type of MCU.

The RPi Pico H is flashed with the latest Picoprobe fw of Nov 11, 2022.

The hardware is wired according to Getting started with Pico, Appendix A : 'Using Picoprobe', image on page 63.

DUT                                      Picoprobe
-------------                            ----------------
SWDCLK                                   (GP2) pin 5
SWDIO                                    (GP3) pin 6
GND                                      GND
VSYS                                     VSYS         (DC Voltage measured: 5.2 V)
UART0 TX/RX (GP0/GP1)                    UART1 (GP4/GP5)

I made and annotated another image of the latest dialogue that I saw happening on an oscilloscope when, while using the Arduino IDE v2.0.3, press the 'Start debugging' button. The frequency set is as in the Raspberry Pi documentation: 5000 kHz (5 MHz).

The Picoprobe has the following USB and COM attached.

Update 2023-01-02 11h13 utc

Problem solved!

It seemed a dupont wire problem.
I replaced the dupont wires by another set of two, a bit shorter also,
and voilá, it is working!
After pressing the 'Start debugging' button,
I saw a list of openocd dialog passing by, then disappear and next,
inside the Arduino IDE v.2.0.3, I saw debug data being presented and a dbg prompt '>' shown (see link to image at the end).

By the way - I don't know if this also helped: after starting the Arduino IDE, I was informed to update some boards software. One was: 'Raspberry Pi Pico/RP2040 by Earle F. Philhower, III, version 2.7.0.' However, after doing this, the changes I made in files:

  • C:\Users<User>\AppData\Local\Arduino15\packages\rp2040\hardware\rp2040\2.7.0\lib\picoprobe.tcl and
  • C:\Users<User>\AppData\Local\Arduino15\packages\rp2040\tools\pqt-openocd\1.5.0-a-5007782\share\openocd\scripts\interfacescripts/interface/cmsis-dap.cfg,

were un-done by some update. I had to modify these files again to reflect the hardware used.
After all this, the debugging started OK.

See: debug output

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.