Flashrom Hangs During Read

Bus Pirate support for the Flashrom project

Flashrom Hangs During Read

Postby bkc177 » Sun Mar 12, 2017 2:58 am

Hi all,

Thank you in advance for any guidance/help you may be able to provide.

Summary of Problem

I am using the Bus Pirate and flashrom to read the contents of a Winbond W25Q64FVAIG chip (via a breadboard). To do this, I have followed the setup described in the flashrom Bus Pirate setup guide. At first the read operation seems to work (I have validated this by looking at -VVV output of flashrom while reading occurs). However, after sometime (30 secs - 1 min) the read operation hangs (after sending) and the USB LED on the Bus Pirate shuts off (all other LEDs remain on). I ran the Bus Pirate self-test and all tests passed.

There are two things that seem odd to me. First, the calibration delay loop is found to be unreliable. I am unsure if this poses a real issue (I have seen other posts that seem to ignore this point as a problem). Second, flashrom complains that the chip may contain one-time programmable memory (again, however, I have seen posts that ignore this issue).

If it is at all helpful, I am running flashrom in a VM running Ubuntu Desktop 12.04. Any guidance on how to work through this issue would be much appreciated!

Command I am running (-VV)

Code: Select all
sudo flashrom -VV -p buspirate_spi:dev=/dev/ttyUSB0,spispeed=1M -c W25Q64.V -r test.rom


and corresponding output...

Code: Select all
flashrom v0.9.9-rc1-r1942 on Linux 4.8.0-36-generic (x86_64)
flashrom is free software, get the source code at ...

flashrom was built with libpci 3.3.1, GCC 5.3.1 20160225, little endian
Command line (7 args): flashrom -VV -p buspirate_spi:dev=/dev/ttyUSB0,spispeed=1M -c W25Q64.V -r test.rom
Calibrating delay loop... OS timer resolution is 1 usecs, 2188M loops per second, delay more than 10% too short (got 74% of expected delay), recalculating... 2269M loops per second, delay more than 10% too short (got 69% of expected delay), recalculating... 2130M loops per second, delay more than 10% too short (got 65% of expected delay), recalculating... 2173M loops per second, delay more than 10% too short (got 66% of expected delay), recalculating... 2231M loops per second, 10 myus = 7 us, 100 myus = 67 us, 1000 myus = 782 us, 10000 myus = 8357 us, 4 myus = 3 us, OK.
Initializing buspirate_spi programmer
Detected Bus Pirate hardware v3b
Detected Bus Pirate firmware 5.10 ("v5.10")
Using SPI command set v2.
SPI speed is 1MHz
Raw bitbang mode version 1
Raw SPI mode version 1
The following protocols are supported: SPI.
Probing for Winbond W25Q64.V, 8192 kB: probe_spi_rdid_generic: id1 0xef, id2 0x4017
Found Winbond flash chip "W25Q64.V" (8192 kB, SPI) on buspirate_spi.
Chip status register is 0x00.
This chip may contain one-time programmable memory. flashrom cannot read
and may never be able to write it, hence it may not be able to completely
clone the contents of this chip (see man page for details).
Block protection is disabled.
Reading flash...


and the last line or so from a run with -VVV where flashrom hangs

Code: Select all
buspirate_sendrecv: write 9, read 257 Sending 0x04 0x00 0x04 0x01 0x00 0x03 0x00 0x8c 0x00, receiving 0x01 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff
buspirate_sendrecv: write 9, read 257 Sending 0x04 0x00 0x04 0x01 0x00 0x03 0x00 0x8d 0x00


Note: I verified that the USB is not somehow being "disconnected" by the machine by checking the dmesg log.
bkc177
Newbie
Newbie
 
Posts: 5
Joined: Sun Mar 12, 2017 2:09 am

Re: Flashrom Hangs During Read

Postby USBEprom » Sun Mar 12, 2017 9:13 am

Hi bkc177.
Bus Pirate firmware 5.10 is pretty old and has some known problems with SPI protocol.
You must upgrade it to a newer version.

Be seeing you.

U.Sb
USBEprom
Full Member
Full Member
 
Posts: 113
Joined: Wed Mar 14, 2012 4:09 pm

Re: Flashrom Hangs During Read

Postby bkc177 » Mon Mar 13, 2017 12:09 am

Hi USBEprom,

Thank you for your help!

I followed your direction and updated my BPv3 firmware to the community version (7.0) using the hex file you provided in another post (http://dangerousprototypes.com/forum/viewtopic.php?f=28&t=8498&start=45#p65500). Upon writing the firmware using pirate-loader I received the error below

Code: Select all
Erasing page 42, a800...ERROR [50]
Error updating firmware :(


It appears, however, that this should be ignored, as you detail in previous posts.

Now, when I run the flashrom read command

Code: Select all
sudo flashrom -VV -p buspirate_spi:dev=/dev/ttyUSB0 -c W25Q64.V -r test.rom


I see the following output.

Code: Select all
flashrom v0.9.9-rc1-r1942 on Linux 4.8.0-36-generic (x86_64)
flashrom is free software, get the source code at ...

flashrom was built with libpci 3.3.1, GCC 5.3.1 20160225, little endian
Command line (7 args): flashrom -VV -p buspirate_spi:dev=/dev/ttyUSB0 -c W25Q64.V -r test.rom
Calibrating delay loop... OS timer resolution is 1 usecs, 2175M loops per second, delay more than 10% too short (got 64% of expected delay), recalculating... 2236M loops per second, delay more than 10% too short (got 66% of expected delay), recalculating... 2187M loops per second, delay more than 10% too short (got 65% of expected delay), recalculating... 2206M loops per second, delay more than 10% too short (got 89% of expected delay), recalculating... 2146M loops per second, delay loop is unreliable, trying to continue 10 myus = 6 us, 100 myus = 63 us, 1000 myus = 1042 us, 10000 myus = 6312 us, 4 myus = 3 us, OK.
Initializing buspirate_spi programmer
Detected Bus Pirate hardware v3.5
Detected Bus Pirate firmware 7.0 ("v7.0")
Using SPI command set v2.
SPI speed is 8MHz
Raw bitbang mode version 1
Raw SPI mode version 1
The following protocols are supported: SPI.
Probing for Winbond W25Q64.V, 8192 kB: probe_spi_rdid_generic: id1 0xef, id2 0x4017
Found Winbond flash chip "W25Q64.V" (8192 kB, SPI) on buspirate_spi.
Chip status register is 0x00.
This chip may contain one-time programmable memory. flashrom cannot read
and may never be able to write it, hence it may not be able to completely
clone the contents of this chip (see man page for details).
Block protection is disabled.
Reading flash...


Unfortunately, the flashrom program then hangs as it did before (with the USB LED shutting off). Do you have any hints on how to proceed? I am starting to suspect that this is a wiring issue between the BPv3 and the breadboard I am using to flash the chip...
bkc177
Newbie
Newbie
 
Posts: 5
Joined: Sun Mar 12, 2017 2:09 am

Re: Flashrom Hangs During Read

Postby USBEprom » Mon Mar 13, 2017 2:02 pm

Hi bkc177.
The very last V7 release of the firmware for the Bus Pirate V3 that I built from the repository is here:

dangerousprototypes.com/forum/download/file.php?id=12196

However that does not matter, you can quietly use the V7 firmware that you already have used for the upgrade, no problem.
As you wrote could be there some mistake in the connections, so please describe them and how you are feeding the chip.
The power supply provided by the Bus Pirate is only enough for feeding a single chip, do not of the whole mainboard.
Last but not least, what revision of flashrom are you using?

Be seeing you.

U.Sb
USBEprom
Full Member
Full Member
 
Posts: 113
Joined: Wed Mar 14, 2012 4:09 pm

Re: Flashrom Hangs During Read

Postby bkc177 » Mon Mar 13, 2017 5:42 pm

Hi USBEprom,

Thank you again for your help and guidance on this; the fast replies are much appreciated :)

First, I updated my BPv3 firmware to the release you pointed to in your previous post.

Then, with respect to flashrom, I am using the following revision:
Code: Select all
flashrom v0.9.9-rc1-r1942 on Linux 4.8.0-36-generic (x86_64)


Finally, with respect to the connections between the BP and the Winbond chip, it looks something like this:

Winbond W25Q64FVAIG Pin Layout

1 --> /CS
2 --> DO (IO_1)
3 --> /WP (IO_2)
4 --> GND
5 --> DI (IO_0)
6 --> CLK
7 --> /HOLD (IO_3)
8 --> VCC

BPv3 to Winbond Pin Connections (using BP cable)

White (CS) --> 1 (/CS)
Black (MISO) --> 2 (DO)
Red (3V3) --> 3 (/WP)
Brown (GND) --> 4 (GND)
Gray (MOSI) --> 5 (DI)
Purple (CLK) --> 6 (CLK)
Red (3V3) --> 7 (/HOLD)
Red (3V3) --> 8 (VCC)

(see https://www.flashrom.org/Bus_Pirate for the guide I am following)

Note that to supply voltage to the 3,7,8 pins on the chip (which all require connection to 3V3 on BP), I have a connection between 3V3 on the BP and the positive power rail on the breadboard. I then have three jumper cables from that rail to the three pins. I am concerned that these indirect connections are the main issue (as they are likely not enough to feed the chip).

Is there a way to improve my setup? I have very little experience with setting up circuits (my background is in software), so any direction is much appreciated!
bkc177
Newbie
Newbie
 
Posts: 5
Joined: Sun Mar 12, 2017 2:09 am

Re: Flashrom Hangs During Read

Postby USBEprom » Tue Mar 14, 2017 2:40 pm

Hi bkc177.
Based on the diagram you wrote the connections you are using are good.
I do not think that the indirect connections you wrote are the problem because the current drain is not so much.
However, you can use a simple voltmeter to check 3,3V on the various pins, just in case.
Are your Bus Pirate and its cable from SeeedStudio, SparkFun or other?
Based on the colors you wrote it should be from SeeedStudio.
Maybe the chip has some trouble.
In order to exclude that possibility you must take a look at this:

viewtopic.php?f=4&t=7482&p=64760&hilit=sre71#p62373

The chip is different but connections are the same as for your case.
Of course in your case the response at [0x9f r r r] will be 0x16 0x40 0x17 instead of 0xC2 0x20 0x17.
Those are some indications that your chip is not broken and your Bus Pirate can access it.
Further evidence would be to follow these guidelines:

viewtopic.php?f=4&t=7950&p=63904&hilit=sre71+8192#p63904

Although flashrom v0.9.9-rc1-r1942 is not so recent (22-Feb-2016) it should be fine for your purposes.
However, if you want you can try with a more recent release:

http://buildbot.flashrom.org/buildresults/?M=D
https://download.flashrom.org/snapshots/?C=M;O=D

Be seeing you.

U.Sb
USBEprom
Full Member
Full Member
 
Posts: 113
Joined: Wed Mar 14, 2012 4:09 pm

Re: Flashrom Hangs During Read

Postby bkc177 » Wed Mar 15, 2017 1:15 am

Hi USBEprom,

I purchased the Bus Pirate cable from SparkFun. However, I believe the color scheme, as I described it, is correct (see https://learn.sparkfun.com/tutorials/bus-pirate-v36a-hookup-guide).

I was able to read the chip ID by interfacing with the Bus Pirate firmware. The values were 0xEF 0x40 0x17. While these differ from those you mentioned, I believe they are correct, as described in the data sheet (see https://www.winbond.com/resource-files/w25q64fv%20revq%2006142016.pdf page 21).

I was also able to read the contents of the chip using the pyBusPirate Python library. Unfortunately, the Python code is quite slow. I believe flashrom will be quite faster. It was, however, nice to validate that my connections are correct.

I did update flashrom to the latest version, as you suggested; nevertheless, I am running into the same issue.

I will purchase a voltmeter tomorrow and confirm that nothing funny is happening on the circuit during reads. However, I am feeling more and more that this is a flashrom issue. I plan to ask in their IRC and see if they have any thoughts.

Thank you again for all your help! If you have any further suggestions, they would be much appreciated!
bkc177
Newbie
Newbie
 
Posts: 5
Joined: Sun Mar 12, 2017 2:09 am

Re: Flashrom Hangs During Read

Postby USBEprom » Wed Mar 15, 2017 3:51 pm

Hi bkc177.
OK, your Bus Pirate and cable are from SparkFun so colours are matching.
OK, JEDEC as 0xEF 0x40 0x17 is correct, 0x16 0x40 0x17 was a my typo.
I am sorry, my bad from page 21 of the same datasheet you have written.
OK, flashrom is now upgraded.
At this point me too I think the culprit could be something else, likely flashrom it itself.
Since in some cases somebody wrote about problem with Ubuntu and Bus Pirate (especially by performing upgrade of the firmware), I suspect it could be an Ubuntu issue also because you are using it into a virtual machine.
However since your background is in software you can adapt what is explained here:

viewtopic.php?f=4&t=7950&p=63904&hilit=sre71+8192#p63904

It should not be too slow compared to the speeds listed there into the post.

Be seeing you.

U.Sb
USBEprom
Full Member
Full Member
 
Posts: 113
Joined: Wed Mar 14, 2012 4:09 pm

Re: Flashrom Hangs During Read

Postby bkc177 » Thu Mar 16, 2017 3:21 am

Hi USBEprom,

Today I finally had success!

Like you, I was suspicious of using a VM to interface with the Bus Pirate. I had originally tried running flashrom on my macOS-based laptop, but flashrom failed early due to an error I did not completely understand (and for which there was little to nothing about online). Today I used a friend's laptop (running Linux) to test my circuit and I was able to read the chip without issue. I then used the pointers you provided to older versions of flashrom to find a newer version of flashrom for macOS. Then, running this version on my laptop worked!

So it appears, for me, that running flashrom running on a VM can have some issues..

Thanks again for all your help and guidance and sticking with me throughout the process :)
bkc177
Newbie
Newbie
 
Posts: 5
Joined: Sun Mar 12, 2017 2:09 am

Re: Flashrom Hangs During Read

Postby luisaestrada » Tue Mar 21, 2017 11:18 am

I am really happy to be here Thank You for Help :)
Points Plus Calculator - Weight Watchers Online Tool weight watchers points calculator
luisaestrada
Newbie
Newbie
 
Posts: 2
Joined: Tue Mar 21, 2017 11:07 am


Return to Flashrom