With `-d3`, I get the following, surrounded by information: ~~~ Error: 499 8935 rp2040.c:455 rp2040_flash_probe(): Unknown flash device (ID 0x001560ba) Error: 500 8935 core.c:316 get_flash_bank_by_addr(): auto_probe failed Debug: 501 8935 command.c:544 run_command(): Command 'flash mdw' failed with error code -4 ~~~
First thing to note is that it does not point to spi.c, nor does it suggest anything about the user adding code to support the flash device. It is very common that errors are not indicative of the actual root problem. Anyone with experience debugging compile errors using the output from GCC is well aware of this, and OpenOCD isn't much better in that regard. Any sign that the actual problem isn't writing to the flash memory, e.g. being able to write to the flash memory over a USB connection using the RP2040 bootloader, is likely to send the user looking down many other rabbit holes. When you notice that you can only connect if you set `gdb_memory_map disable` suggests that the problem likely goes beyond the flash memory. And when the timer isn't running while debugging (with the flag set), there is other cause to look elsewhere. Also, even assuming that the error message is pointing at the actual cause of the error, the error doesn't clearly indicate that the external nor flash chip is what's unrecognized, as opposed to the flash controller in the RP2040 itself. I also had several other potential points of failure to consider: 1. I had recently switched to a different Linux distribution, and had not yet successfully debugged any other embedded device since. 2. Since the reinstall, I switched from a git version of OpenOCD modified to work with the Picoprobe, so I had no previous success using vanilla OpenOCD. The Tcl files from Raspberry Pi's modified version of OpenOCD and vanilla OpenOCD 0.12.0 were radically different, and were thus potential points of failure. 3. The RP2040 has a dual-core processor, which was the focus of some of the major changes between the Tcl files, and gives the possibility of all sorts of multicore issues. 4. In the process of exploring possible points of failure, I flashed a new firmware onto the debugging probe, in place of the old freedap firmware that I had tweaked to use the same pins as the Picoprobe. 5. I had no experience using OpenOCD directly, rather than through VSCode, so when I had more debugging output enabled, I was unsure that I was using the correct post-init commands in the correct order. 6. I was using the next iteration of my custom PCB, and had no board that I could guarantee would work properly, and wasn't even sure how much success I had gotten in my debugging sessions from around a month or two earlier, using the same flash chip. 7. I wasn't sure that the recent updates to the VSCode cortex-debug plugin hadn't introduced any breaking changes for the multicore RP2040. Problems are much easier to find when there aren't lots of new points of failure and multiple issues going on at the same time, but life isn't ideal, and in real life, problems don't always come one at a time, nor do potentially breaking changes to things. I spent weeks trying to fix the problem before finally finding the solution. Also, it didn't help that I never found any forum posts about the issue, or even any that had a non-zero unrecognized flash device ID, for that matter. Excuses that someone else seeing the error in a less confusing situation may have an easier time figuring out what to do don't do anything to fix the problem. The line of code that I gave earlier should be incorporated into upstream OpenOCD. As for the chips, there are multiple models with different amounts of memory, and I shouldn't need to modify and recompile OpenOCD every time I use a different one from the same manufacturer with more or less memory, and there are probably other less-common brands out there for someone else to use, then spend a week or more figuring out what's wrong and how to fix it, or throwing in the towel if they aren't as determined as I was. --- **[tickets:#408] No support for generic SPI flash** **Status:** new **Milestone:** 0.11.0 **Created:** Sat Jul 08, 2023 06:33 AM UTC by Ben Larson **Last Updated:** Mon Jul 10, 2023 09:58 AM UTC **Owner:** nobody I have been using the RP2040 with an SPI flash chip that was not on the list in `src/flash/nor/spi.c`. I found that I could write programs onto the chip using the RP2040 bootloader (which presents itself as a USB mass storage device), but OpenOCD 0.12.0 was unable to upload anything to the flash, giving the error `Unknown flash device (ID 0x001560ba)`. Considering that almost all SPI flash chips can be programmed and read using the same commands and parameters, shouldn't an unknown flash device be treated that way, as done in the RP2040 bootloader? (sourced from multiple datasheets and Pico bootrom code at [https://github.com/raspberrypi/pico-bootrom/tree/master/bootrom]) * use a slow clock speed * keep ~WP pin high * 03h reads until stopped * 06h enables writing * 20h erases 4kB (usually called a sector) * 02h writes up to 256B (usually called a page) * assume that the chip has enough memory when writing, then verify by reading Am I missing anything? While reading/writing/erasing past the end of the flash memory seems to be undefined behavior, it seems very unlikely to damage the chip, and should always result in write verification failure. --- Sent from sourceforge.net because openocd-devel@lists.sourceforge.net is subscribed to https://sourceforge.net/p/openocd/tickets/ To unsubscribe from further messages, a project admin can change settings at https://sourceforge.net/p/openocd/admin/tickets/options. Or, if this is a mailing list, you can unsubscribe from the mailing list.