Bus Pirate 5 resetting itself, causing storage corruption

tl;dr - turning off flash write from host did not solve corruption problem (which is kind of a good thing, amirite? :wink: )

I pulled the artifact and loaded it. Verified by doing an info:

Bus Pirate 5 REV10
Firmware main branch @ unknown (2024-09-18T22:26:05Z)
RP2040 with 264KB RAM, 128Mbit FLASH
S/N: 264235D3012961E4
https://BusPirate.com/
Storage:   0.10GB (FAT16 File System)

Connected it to my Linux box, verified in the kernel log that initial Flash is read only:

[177457.364177] usb 3-3.4.1.4.3: new full-speed USB device number 118 using xhci_hcd
[177457.507467] usb 3-3.4.1.4.3: New USB device found, idVendor=1209, idProduct=7332, bcdDevice= 1.01
[177457.507490] usb 3-3.4.1.4.3: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[177457.507497] usb 3-3.4.1.4.3: Product: Bus Pirate 5
[177457.507503] usb 3-3.4.1.4.3: Manufacturer: Bus Pirate
[177457.507508] usb 3-3.4.1.4.3: SerialNumber: 264235D3012961E4
[177457.533790] cdc_acm 3-3.4.1.4.3:1.0: ttyACM0: USB ACM device
[177457.535591] cdc_acm 3-3.4.1.4.3:1.2: ttyACM1: USB ACM device
[177457.536111] usb-storage 3-3.4.1.4.3:1.4: USB Mass Storage device detected
[177457.536419] scsi host1: usb-storage 3-3.4.1.4.3:1.4
[177458.555996] scsi 1:0:0:0: Direct-Access     BP5      Storage          1.0  PQ: 0 ANSI: 2
[177458.557051] sd 1:0:0:0: Attached scsi generic sg1 type 0
[177458.565833] sd 1:0:0:0: [sdb] 47824 2048-byte logical blocks: (97.9 MB/93.4 MiB)
[177458.566655] sd 1:0:0:0: [sdb] Write Protect is on
[177458.566663] sd 1:0:0:0: [sdb] Mode Sense: 03 00 80 00
[177458.567382] sd 1:0:0:0: [sdb] No Caching mode page found
[177458.567386] sd 1:0:0:0: [sdb] Assuming drive cache: write through
[177458.591213]  sdb: sdb1

Trust, but verify: checked that BP storage was mounted and that I could not create, modify, or delete anything on that volume.

In minicom, I set up SPI mode (which creates the config file for it). Saw some strangeness in the kernel log, but it worked as expected and did create the correct config file:

[177532.650267] sd 1:0:0:0: [sdb] Sense Key : Illegal Request [current] 
[177532.650273] sd 1:0:0:0: [sdb] Add. Sense: Invalid command operation code
[177547.829317] sd 1:0:0:0: [sdb] Sense Key : Illegal Request [current] 
[177547.829322] sd 1:0:0:0: [sdb] Add. Sense: Invalid command operation code
[177547.867596] sd 1:0:0:0: [sdb] Sense Key : Illegal Request [current] 
[177547.867602] sd 1:0:0:0: [sdb] Add. Sense: Invalid command operation code
[177547.868558] sdb: detected capacity change from 191296 to 0
[177547.876969] sd 1:0:0:0: [sdb] 47824 2048-byte logical blocks: (97.9 MB/93.4 MiB)
[177547.879407] sdb: detected capacity change from 0 to 191296  

I was sitting idle in minicom after that and saw the detach/attach messages in the kernel log:

[177587.199292] usb 3-3.4.1.4.3: reset full-speed USB device number 118 using xhci_hcd
[177587.341601] cdc_acm 3-3.4.1.4.3:1.0: ttyACM0: USB ACM device
[177587.341985] cdc_acm 3-3.4.1.4.3:1.2: ttyACM1: USB ACM device
[177587.353480] sdb: detected capacity change from 191296 to 0
[177587.360928] sd 1:0:0:0: [sdb] 47824 2048-byte logical blocks: (97.9 MB/93.4 MiB)
[177587.363700] sdb: detected capacity change from 0 to 191296
[177591.080420] sdb: detected capacity change from 191296 to 0
[177591.398629] sd 1:0:0:0: [sdb] 47824 2048-byte logical blocks: (97.9 MB/93.4 MiB)
[177591.400982] sdb: detected capacity change from 0 to 191296
[177591.430639]  sdb: sdb1

I went ahead and did the flash read -f flash.bin command anyway:

SPI> A 0
IO0 set to OUTPUT: 1

SPI> A 1
IO1 set to OUTPUT: 1

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: 2.6mA

SPI> flash read -f flash.bin
Probing:
                Device ID       Manuf ID        Type ID         Capacity ID
RESID (0xAB)    0x16
REMSID (0x90)   0x16            0xc8
RDID (0x9F)                     0xc8            0x40            0x17

SFDP (0x5A): found 0x50444653 "PDFS"
 Version: 1.0
 Headers: 2

**Param Table 0**
                Type            Ver.    Length  Address
Table 0         JEDEC (0x00)    1.0     36      0x000030

MSB-LSB  3    2    1    0
[0001] 0xFF 0xF1 0x20 0xE5
[0002] 0x03 0xFF 0xFF 0xFF
[0003] 0x6B 0x08 0xEB 0x44
[0004] 0xBB 0x42 0x3B 0x08
[0005] 0xFF 0xFF 0xFF 0xEE
[0006] 0xFF 0x00 0xFF 0xFF
[0007] 0xFF 0x00 0xFF 0xFF
[0008] 0x52 0x0F 0x20 0x0C
[0009] 0xFF 0x00 0xD8 0x10

Density: 8388608 bytes
Address bytes: 3
Write granularity:>=64B
Write Enable Volatile: 0
Write Enable instruction: 0x50
4K erase instruction: 0x20

Fast read:      1-1-2   1-1-4   1-2-2   1-4-4   2-2-2   4-4-4
Instruction:    0x3b    0x6b    0xbb    0xeb    --      --
Wait states:    8       8       2       4       0       0
Mode clocks:    0       0       4       4       0       0

Erase:          1       2       3       4
Instruction:    0x20    0x52    0xd8    0xff
Size:           4K      32K     64K     1B

**Param Table 1**
                Type            Ver.    Length  Address
Table 1         manuf (0xc8)    1.0     12      0x000060

MSB-LSB  3    2    1    0
[0001] 0x27 0x00 0x36 0x00
[0002] 0x64 0x77 0xF9 0x9E
[0003] 0xFF 0xFF 0xEB 0xFC

VCC min: 2700mV
VCC max: 3600mV
/Reset pin: -
/Hold pin: Y
Deep Power Down (DPDM): Y
SW reset: Y (instruction 0x99)
Suspend/Resume program: Y
Suspend/Resume erase: Y
Wrap Read mode: Y (instruction 0x77, length 100)
Individual block lock: - (nonvolatile -, instruction 0xff, default 0)
Secured OTP: Y
Read lock: -
Permanent lock: Y

Initializing SPI flash...
Flash device manufacturer ID 0xC8, type ID 0x40, 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 0xF1 0x20 0xE5
[0002] 0x03 0xFF 0xFF 0xFF
[0003] 0x6B 0x08 0xEB 0x44
[0004] 0xBB 0x42 0x3B 0x08
[0005] 0xFF 0xFF 0xFF 0xEE
[0006] 0xFF 0x00 0xFF 0xFF
[0007] 0xFF 0x00 0xFF 0xFF
[0008] 0x52 0x0F 0x20 0x0C
[0009] 0xFF 0x00 0xD8 0x10
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 32KB block erase (instruction 0x52)
Flash device supports 64KB block erase (instruction 0xD8)
Found a GigaDevice  flash chip (8388608 bytes)
Flash device reset success
Dumping to flash.bin...
[o o o o o o o o o o ]

It finished right away, which is a bad sign. I did an ls and saw corrupted flash:

SPI> ls
   <DIR>   ��������.���
   <DIR>   ��������.���
   <DIR>   ��������.���
   <DIR>   ��������.���
 <<<<<  snipped out 500-some entries of the same >>>>>
   <DIR>   ��������.���
   <DIR>   ��������.���
   <DIR>   ��������.���
   <DIR>   ��������.���
512 dirs, 0 files

SPI> 

Tried to format the flash, got the usual error I’ve been seeing:

SPI> format
Erase the internal storage?
y/n> y
Are you sure?
y/n> y

Formatting...
Error: filesystem not foundError: Format failed...
Error: filesystem not found
SPI> 

A question is why didn’t I see this yesterday when I was doing the testing with automount turned off? That is a good questions - maybe the conditions that cause this just didn’t line up that time :man_shrugging:

Anyway, I think this is good news, right? At least it is contained on the device and not a Linux-related thing.

For reference, I do own a pico probe. I saw the thread on the 3rd com port and saw this as an alternative, so I can help remotely debug that way, too.

As always, thanks the community for the help and response!

1 Like