Rev10 various SPI problems

I’ve observed a few issues with a Rev10 that I got in the mail early last week running very recent firmware (ci-buspirate5-main-f0b33d2).

First up:
it is giving an unexpected response to the MX25L6406E RDID command (datasheet) when nothing is attached to the BP in SPI mode as well as an unexpected response when attached to the above chip.

BP IO ports free:

Bus Pirate 5 REV10
Firmware main branch (2024-03-24T15:52:54Z)
RP2040 with 264KB RAM, 128Mbit FLASH
S/N: 283221D3012961E4
https://BusPirate.com/
Storage:   0.10GB (FAT16 File System)

Configuration file: Loaded
Available modes: HiZ 1-WIRE UART HDPLXUART I2C SPI 2WIRE LED
Active mode: HiZ ()=()
Display format: Auto

HiZ> m 

Mode selection
 1. HiZ
 2. 1-WIRE
 3. UART
 4. HDPLXUART
 5. I2C
 6. SPI
 7. 2WIRE
 8. LED
 x. Exit
Mode > 6

Use previous settings?
 SPI speed: 100 kHz
 Data bits: 8
 Clock polarity: Idle LOW
 Clock phase: LEADING edge
 Chip select: Active LOW (/CS)

y/n, x to exit (Y) > 

Actual speed: 122kHz
Mode: SPI
SPI> [0x9f r:3]

CS Enabled
TX: 0x9F 
RX: 0x68 0x88 0xA8 
CS Disabled

BP IO ports attached to a MX25L6406E:

SPI> W
Power supply
Volts (0.80V-5.00V)
x to exit (3.30) > 
Maximum current (0mA-500mA), <enter> for none
x to exit (none) > 
3.30V requested, closest value: 3.30V
Current limit:Disabled

Power supply:Enabled
Vreg output: 3.3V, Vref/Vout pin: 3.3V, Current: 72.4mA

SPI> [0x9f r:3]

CS Enabled
TX: 0x9F 
RX: 0x68 0x88 0xA8 
CS Disabled

I would expect in the first scenario to not get an RX, and in the second scenario to get the ID in the RX, so 0xc2 0x20 0x17 not 0x68 0x88 0xA8. As a sanity check that the chip is still good, I used flashrom to read the data to a file using a BP 3.5 and verified that the expected data was still there.

Second up:
I’ve also found that I can’t apply a current limit without it immediately tripping, hence why I have don’t have a limit set in the examples above.

Third up:
I can’t get flashrom to work with the Rev10, I’ve tried both ttyACM0 and ttyACM1. I tried with ttyACM1 first, but it hangs fairly quickly, never getting a response:

flashrom v1.2 on Linux 6.6.10-76060610-generic (x86_64)
flashrom is free software, get the source code at https://flashrom.org

flashrom was built with libpci 3.7.0, GCC 11.2.0, little endian
Command line (7 args): flashrom -r test.bin -VVV -p buspirate_spi:dev=/dev/ttyACM1,spispeed=1M -c MX25L6406E/MX25L6408E
Using clock_gettime for delay loops (clk_id: 1, resolution: 1ns).
Initializing buspirate_spi programmer
buspirate_sendrecv: write 1, read 0 Sending 0x00
buspirate_sendrecv: write 1, read 0 Sending 0x00
buspirate_sendrecv: write 1, read 0 Sending 0x00
buspirate_sendrecv: write 1, read 0 Sending 0x00
buspirate_sendrecv: write 1, read 0 Sending 0x00
buspirate_sendrecv: write 1, read 0 Sending 0x00
buspirate_sendrecv: write 1, read 0 Sending 0x00
buspirate_sendrecv: write 1, read 0 Sending 0x00
buspirate_sendrecv: write 1, read 0 Sending 0x00
buspirate_sendrecv: write 1, read 0 Sending 0x00
buspirate_sendrecv: write 1, read 0 Sending 0x00
buspirate_sendrecv: write 1, read 0 Sending 0x00
buspirate_sendrecv: write 1, read 0 Sending 0x00
buspirate_sendrecv: write 1, read 0 Sending 0x00
buspirate_sendrecv: write 1, read 0 Sending 0x00
buspirate_sendrecv: write 1, read 0 Sending 0x00
buspirate_sendrecv: write 1, read 0 Sending 0x00
buspirate_sendrecv: write 1, read 0 Sending 0x00
buspirate_sendrecv: write 1, read 0 Sending 0x00
buspirate_sendrecv: write 1, read 0 Sending 0x00
buspirate_sendrecv: write 0, read 4 

Whereas ttyACM0 responds, but I suspect that it’s because it’s getting garbage from the serial connection. Admittedly, I haven’t looked at the flashrom repo to see if it just needs to be added, but thought I’d bring it up for good measure.

Fourth up:
The flash command seems to be broken at the moment:

HiZ> m

Mode selection
 1. HiZ
 2. 1-WIRE
 3. UART
 4. HDPLXUART
 5. I2C
 6. SPI
 7. 2WIRE
 8. LED
 x. Exit
Mode > 6

Use previous settings?
 SPI speed: 2000 kHz
 Data bits: 8
 Clock polarity: Idle LOW
 Clock phase: LEADING edge
 Chip select: Active LOW (/CS)

y/n, x to exit (Y) > 

Actual speed: 1953kHz
Mode: SPI
SPI> help mode
Peer to peer 3 or 4 wire full duplex protocol. Very
high clockrates upto 20MHz are possible.

More info: https://en.wikipedia.org/wiki/Serial_Peripheral_Interface_Bus

BPCMD	 {,] |                 DATA (1..32bit)               | },]
CMD	START| D7  | D6  | D5  | D4  | D3  | D2  | D1  | D0  | STOP
MISO	---{#|##}{#|##}{#|##}{#|##}{#|##}{#|##}{#|##}{#|##}--|------
MOSI	---{#|##}{#|##}{#|##}{#|##}{#|##}{#|##}{#|##}{#|##}--|------
CLK	_____|__""_|__""_|__""_|__""_|__""_|__""_|__""_|__""_|______
CS	""___|_____|_____|_____|_____|_____|_____|_____|_____|___"""

Current mode is spi_clock_phase=0 and spi_clock_polarity=0

Connection:
	MOSI 	------------------ MOSI
	MISO 	------------------ MISO
{BP}	CLK	------------------ CLK	{DUT}
	CS	------------------ CS
	GND	------------------ GND

Available mode commands:
flash	Erase, write, read and verify SPI flash chips

SPI> flash read
flash command is currently only available in SPI mode

And lastly:
The IO pins listed in the docs (https://firmware.buspirate.com/overview/io-pins) don’t appear to match the IO pins on the device.
Device in SPI mode:

IO4 -> MISO
IO5 -> CS
IO6 -> CLK
IO7 -> MOSI

Docs:

IO4 -> SCLK
IO5 -> CDO
IO6 -> CDI
IO7 -> CS

Thank you so much, I’m sorry for the issues. This one should be fixed in the firmware I just pushed. The docs I will update tomorrow, and the others I will investigate.

1 Like

Updated the Docs. The binary mode is in progress so flashrom won’t work yet. The idle issue I’ll look into now.

1 Like

I pushed an update. After a big reorganization there’s been some concurrency issues between the two cores in the RP2040. Does this help?

1 Like

The latest firmware seems to have gotten it most of the way, though I think there’s still something weird happening:

SPI> W
Power supply
Volts (0.80V-5.00V)
x to exit (3.30) > 
Maximum current (0mA-500mA), <enter> for none
x to exit (none) > 300
3.30V requested, closest value: 3.30V
300.0mA requested, closest value: 300.0mA

Power supply:Enabled
Vreg output: 3.3V, Vref/Vout pin: 3.3V, Current: 113.0mA

SPI> w
Power supply: Disabled

SPI> W
Power supply
Volts (0.80V-5.00V)
x to exit (3.30) > 
Maximum current (0mA-500mA), <enter> for none
x to exit (none) > 200
3.30V requested, closest value: 3.30V
200.0mA requested, closest value: 200.0mA

Power supply:Enabled
Vreg output: 3.3V, Vref/Vout pin: 3.3V, Current: 119.1mA

SPI> 

Error: Current over limit, power supply disabled

Also, checking the flash read function, when running it, the BP will disconnect after a few seconds of reading:

SPI> W
Power supply
Volts (0.80V-5.00V)
x to exit (3.30) > 
Maximum current (0mA-500mA), <enter> for none
x to exit (none) > 
3.30V requested, closest value: 3.30V
Current limit:Disabled

Power supply:Enabled
Vreg output: 3.3V, Vref/Vout pin: 3.3V, Current: 79.5mA

SPI> flash read -f test.bin
Flash device manufacturer ID 0xC2, type ID 0x20, capacity ID 0x17
SFDP V1.0, 1 parameter headers
		Type		Ver.	Length	Address
Table 0		JEDEC (0x00)	1.0	36B	0x000030
JEDEC basic flash parameter table info:
MSB-LSB  3    2    1    0
[0001] 0xFF 0x81 0x20 0xE5
[0002] 0x03 0xFF 0xFF 0xFF
[0003] 0xFF 0x00 0xFF 0x00
[0004] 0xFF 0x00 0x3B 0x08
[0005] 0xFF 0xFF 0xFF 0xEE
[0006] 0xFF 0x00 0xFF 0xFF
[0007] 0xFF 0x00 0xFF 0xFF
[0008] 0xD8 0x10 0x20 0x0C
[0009] 0xFF 0x00 0xFF 0x00
4 KB Erase is supported throughout the device (instruction 0x20)
Write granularity is 64 bytes or larger
Flash status register is non-volatile
3-Byte only addressing
Capacity is 8388608 Bytes
Flash device supports 4KB block erase (instruction 0x20)
Flash device supports 64KB block erase (instruction 0xD8)
Found a Macronix  flash chip (8388608 bytes)
Flash device reset success
Dumping to test.bin...
[o o o o o o o o o o ]
[tio 15:12:56] Disconnected

Edit: But the BIN file it generates is accurate! So it’s disconnecting after it completes maybe?

Also, no need to be sorry! I’m just trying to help with documenting bugs and things as I come across them! Thank you for being so responsive and receptive!

2 Likes

I haven’t looked the code in detail - but could the over current limit be an issue that the PWM signal to the comparator (CURRENT_ADJ_MCU) isn’t given enough time to ramp up and the comparator adjusting to it before the voltage regulator is activated?

Another issue could be some capacitor charging up on enable with a short current spike. So maybe ramp up the voltage more slowly instead of directly going to the target voltage and enabling?

There’s a bunch of updates to SPI and the current limit stuff in the latest firmware. Has it solved the current limit issue? There were several code and concurrency issues.

There’s also several updates to the flash command. The disconnect was probably due to a pointer issue somewhere, it might be fixed now. I have been unable to reproduce it. If you happen to try again please let me know if the issue persists.

1 Like