(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);
}