Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

flashrom hangs with latest buspirate firmware #231

Open
nhorman opened this issue Dec 1, 2021 · 4 comments
Open

flashrom hangs with latest buspirate firmware #231

nhorman opened this issue Dec 1, 2021 · 4 comments

Comments

@nhorman
Copy link

nhorman commented Dec 1, 2021

testing with buspirate firmware at commit 4bd112bfefbc6ec07e56b944bd2753801ffb558e, trying to program a winbond 32Mb flash chip.

The flashrom utility hangs when sending this command sequence to the buspirate:

0x4 0x0 0x1 0x0 0x0 0x6
This is a buspirate read/write command writing a single byte to the chip over the spi bus, specifically the write enable command (0x6). buspirate_sendrecv indicates we are writing 6 bytes and receiving 1 (which is more than is the command string due to the +1 in the call made from buspirate_spi_send_command_v2 in flashrom

I think I know whats going on, but was hoping someone else could take a closer look.

Flashrom sends the above command string to indicate that the spi bus should send back 0 bytes to the buspirate, but it adds one to the receive count because it expects the bus pirate to send back a success/failure code (0 or 1), in flashrom, this addition of a single byte to read outside the command string, causes it to sit on a read call for the serial port

meanwhile in the latest buspirate firmware, in spi_read_write_io, we fetch the bytes_to_read from the command string (which is 0). As such, at the bottom of this function, we have this code:
if (bytes_to_read > 0) {
spi_read_to_uart(bytes_to_read);
}

so spi_read_write_io is expecting the status byte to be included in the read count, whereas buspirate_spi_send_command_v2 is not.

I think the right solution is to modify buspirate_spi_send_command_v2 so that readcnt is incremented in the command strings to include the status byte, which triggers the latest buspirate firmware to send said status byte, but I wanted to check here first, as I wasn't sure if there were any other repercussions to making that change.

@BlazejCwik
Copy link

Hi, any progress with that?

@redawl
Copy link

redawl commented Apr 22, 2024

Running into this as well, I will take a look, but I am not familiar with flashrom so it could take a while

@nhorman
Copy link
Author

nhorman commented Apr 22, 2024

I've moved away from this, but FWIW, modifying buspirate_spi_send_command_v2 as I described above got me working again. Just wasn't sure if it was the right fix or not

@redawl
Copy link

redawl commented Apr 22, 2024

For others who are running into this issue, see this issue on the the Bus Pirate repo:
BusPirate/Bus_Pirate#131

The firmware version they mention worked for me. Seems to be a problem on the Bus_Pirate firmware end.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants