Skip to main content
Topic: Adding Bus Pirate support to flashrom? (Read 62481 times) previous topic - next topic

Re: Adding Bus Pirate support to flashrom?

Reply #45
Com on... Don't tell me I will have tu buy/make another device just to program this one flash chip.

Re: Adding Bus Pirate support to flashrom?

Reply #46
I'm sorry, I'm not a flash rom expert so I can't help with the software. If you capture the traffic with portmon I can look to be sure the Bus Pirate isn't having any errors.
Got a question? Please ask in the forum for the fastest answers.

Re: Adding Bus Pirate support to flashrom?

Reply #47
[quote author="RJSC"]
My conclusion is that the flashrom program has to have some bug in it. Can you help me?
[/quote]

Well, yesterday with the same memory chip, I simply used :-

flashrom -r test.bin -p buspiratespi:dev=COM5

and after a very long time (an hour ?) it completed without problems.


David

Re: Adding Bus Pirate support to flashrom?

Reply #48
Do you have the buspirate v 5.1 firmware? (as I do)

Re: Adding Bus Pirate support to flashrom?

Reply #49
No, 3.0 on SparkFun BusPirate.

Re: Adding Bus Pirate support to flashrom?

Reply #50
Ok, now I'm almost shure it's the newer versions of the BusPirate firmware who are to blame!

I've found someone with a similar unsolved problem on another topic: http://dangerousprototypes.com/forum/index.php?topic=651.msg5970
Quote
Hi,

I'm currently debugging a problem with a flashrom user who has a Bus-Pirate V3 with Firmware v4.5. The problem manifests itself as an all-0x00 read from SPI for the first SPI command.

Seems that it only works on v3 firmwares.

Now, how will I downgrade the firmware? Since from v4 upwards the bootloaders are different/incompatible.

Re: Adding Bus Pirate support to flashrom?

Reply #51
Well I think it would be best to fix the firmware :) I need to see a log of the traffic (portmon) to know what it's doing and what isn't working.

Quote
Does it work if you send a dummy byte while CS is not active for the flash chip and avoid the broken first byte?

How many bytes are you send/reading with 0x10? The Bus Pirate should respond to the 0x10 with 0x01 and then respond to each send/read with a byte from the bus.

I'd be happy to take a look at a full log.
Got a question? Please ask in the forum for the fastest answers.

Re: Adding Bus Pirate support to flashrom?

Reply #52
I want to add - biosflasher is you're listening - I want to add a new bulk write for flashrom that allows up to 4096 to be read/write without the ack and without pausing. Let me know if you're still around.
Got a question? Please ask in the forum for the fastest answers.

Re: Adding Bus Pirate support to flashrom?

Reply #53
Ok, I'll try to log the comms.
As for sending a dummy byte first, it has to be done on the PC program flashrom, and I don't think I know how to do it just yet.
Our best shot is to fix the firmware, since it works on v3, and manual SPI mode, the defect is on the firmware.

Re: Adding Bus Pirate support to flashrom?

Reply #54
Got a log!

Command Line:
Code: [Select]
C:>flashrom -p buspiratespi:dev=COM5 -c EN25F16 -V
flashrom v0.9.1-r905
SPI speed is 8MHz
Raw bitbang mode version 1
Raw SPI mode version 1
Calibrating delay loop... 619M loops per second, 100 myus = 0 us. OK.
Probing for Eon EN25F16, 2048 KB: RDID[u][b] returned 0x1f 0xff 0xff[/b][/u]. probe_spi_rdid_generic: id1 0x1f, id2 0xffff
No EEPROM/flash device found.
If you know which flash chip you have, and if this version of flashrom
supports a similar flash chip, you can try to force read your chip. Run:
flashrom -f -r -c similar_supported_flash_chip filename

Note: flashrom can never write when the flash chip isn't found automatically.
Raw bitbang mode version 1
Bus Pirate shutdown completed.

Serial Comunication Log:
Code: [Select]
Port opened by process "flashrom.exe" (PID: 848)

Request:

 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00   ................
 00 00 00 00                                       ....           

Answer:

 42 42 49 4F 31                                    BBIO1          

Request:

 01                                                .              

Answer:

 53 50 49 31                                       SPI1           

Request:

 4B                                                K              

Answer:

 01                                                .              

Request:

 67                                                g              

Answer:

 01                                                .              

Request:

 8A                                                Å               

Answer:

 01                                                .              

Request:

 03                                                .              

Answer:

 01                                                .              

Request:

 02                                                .              

Answer:

 01                                                .              

Request:

 13 9F 00 00 00                                    .Ÿ...          

Answer:

 01 00 1F FF FF                                    ...ÿÿ          

Request:

 03                                                .              

Answer:

 01                                                .              

Request:

 00                                                .              

Answer:

 42 42 49 4F 31                                    BBIO1          

Request:

 0F                                                .              

Port closed

Re: Adding Bus Pirate support to flashrom?

Reply #55
Quote
Request:

 13 9F 00 00 00                                    .Ÿ...          

Answer:

 01 00 1F FF FF                                    ...ÿÿ          

Thanks! This is a ton of help. I'll work on this today. I'm guessing this shows the elusive preceding 0x00 byte.
Got a question? Please ask in the forum for the fastest answers.

Re: Adding Bus Pirate support to flashrom?

Reply #56
[quote author="ian"]
Quote
Request:

 13 9F 00 00 00                                    .Ÿ...          

Answer:

 01 00 1F FF FF                                    ...ÿÿ          

Thanks! This is a ton of help. I'll work on this today. I'm guessing this shows the elusive preceding 0x00 byte.
[/quote]

But the 0x00 is not the only problem.

On manual mode (as shown before) the chip answers to 0x9F with 0x1C 0x3F, but on that raw spi mode the buspirate after that first 0x00 byte shows 0x1F 0xFF and that is still wrong, so, maybe its mixing bits in the buffer or something.

Re: Adding Bus Pirate support to flashrom?

Reply #57
01= SPI mode

4b = 0100-1011 =
0100wxyz – Configure peripherals, w=power, x=pullups, y=AUX, z=CS

67= 0110-0111 =
01100xxx – Set SPI speed, 30, 125, 250khz; 1, 2, 2.6, 4, 8MHz

8a=1000-1010=
1000wxyz – SPI config, w=output type, x=idle, y=clock edge, z=sample

3 = CS high (1)

2 = CS low (0)

13 =send 4 bytes
9f=JEDEC ROM ID command
3 byte read = JEDEC ID (I thought it was four according to:
http://dangerousprototypes.com/docs/AT4 ... ash_memory

3 = CS high

00=return to BBIO

0F = reset

I connected to the Logic Sniffer with the aforementioned ROM IC. It works in terminal mode:

Quote
SPI> [0x9f r:4]
CS ENABLED
WRITE: 0x9F
READ: 0x1F 0x24 0x00 0x00
CS DISABLED
SPI>

Now I'll try with the binary mode:

Code: [Select]
{0D}{0A}Bus Pirate v3a{0D}{0A}Firmware v5.2RC (r413) Bootloader v4.3{0D}{0A}DEVID:0x0447 REVID:0x3043 (B5){0D}{0A}http://dangerousprototypes.com{0D}{0A}HiZ> {00}{00}{00}{00}{00}{00}{00}{00}{00}{00}{00}{00}{00}{00}{00}{00}{00}{00}{00}{00}BBIO1{01}SPI1{4B}{01}{67}{01}{8A}{01}{03}{01}{02}{01}{13}{01}{9F}{00}{00}{1F}{00}{24}{00}{00}{03}{01}{00}BBIO1{0F}{01}{0D}{0A}Bus Pirate v3a{0D}{0A}Firmware v5.2RC (r413) Bootloader v4.3{0D}{0A}DEVID:0x0447 REVID:0x3043 (B5){0D}{0A}http://dangerousprototypes.com{0D}{0A}HiZ> 

Broken down:

Code: [Select]
{0D}{0A}Bus Pirate v3a{0D}{0A}Firmware v5.2RC (r413) Bootloader v4.3{0D}{0A}DEVID:0x0447 REVID:0x3043 (B5){0D}{0A}http://dangerousprototypes.com{0D}{0A}HiZ> 

Reset

Code: [Select]
{00}{00}{00}{00}{00}{00}{00}{00}{00}{00}{00}{00}{00}{00}{00}{00}{00}{00}{00}{00}BBIO1

Enter BBIO

Code: [Select]
{01}SPI1

Enter SPI

Code: [Select]
{4B}{01}{67}{01}{8A}{01}

Setup sequence
Code: [Select]
{03}{01}{02}{01}

CS setup

Code: [Select]
{13}{01}{9F}{00}{00}{1F}{00}{24}{00}{00}

Get JEDEC ID

Code: [Select]
{03}{01}

set CS

Code: [Select]
{00}BBIO1

return to BBIO

Code: [Select]
{0F}{01}

reset

Code: [Select]
{0D}{0A}Bus Pirate v3a{0D}{0A}Firmware v5.2RC (r413) Bootloader v4.3{0D}{0A}DEVID:0x0447 REVID:0x3043 (B5){0D}{0A}http://dangerousprototypes.com{0D}{0A}HiZ> 

So far I don't see any indication of a problem. I didn't see the phantom byte described in another thread, I don't see anything mixed up in the buffer. The binary mode code has been the same over the last several firmwares. Nothing has changed, and the SPI functions are pretty simple. Just to be sure, you can check the revision history here:
http://code.google.com/p/the-bus-pirate ... &start=416

Raw SPI mode was added here:
http://code.google.com/p/the-bus-pirate ... I.c&old=48

and there were no major revisions to the rawspi part until today when I removed some old, unused options (this isn't in the compile or SVN yet).

There could still very well be something wrong with the Bus Pirate firmware, especially if Flashrom consistently works on old versions but not new ones. I don't know what it would be though because repeating the flashrom commands seem to work fine for me. I'll get the flashrom app and try it now too.
Got a question? Please ask in the forum for the fastest answers.

Re: Adding Bus Pirate support to flashrom?

Reply #58
@Microfunguy - what version/platform of flashrom did you use?
Got a question? Please ask in the forum for the fastest answers.

Re: Adding Bus Pirate support to flashrom?

Reply #59
I tested with the newest and the older version of flashrom, both are working for me with with v5.2 nightly:

Here's a test with r881, the latest I already had:

Code: [Select]
C:>flashrom -p buspiratespi:dev=COM3
flashrom v0.9.1-r881
Calibrating delay loop... OK.
Found chip "Atmel AT45DB041D" (512 KB, SPI) at physical address 0xfff80000.
===
This flash part has status NOT WORKING for operations: READ
This flash part has status UNTESTED for operations: PROBE ERASE WRITE
Please email a report to flashrom@flashrom.org if any of the above operations
work correctly for you with this flash part. Please include the flashrom
output with the additional -V option for all operations you tested (-V, -rV,
-wV, -EV), and mention which mainboard or programmer you tested. Thanks for your
 help!
===
No operations were specified.

C:>

Here's the latest in the forum (905):

Code: [Select]
C:>flashrom -p buspiratespi:dev=COM3
flashrom v0.9.1-r905
Calibrating delay loop... OK.
Found chip "Atmel AT45DB041D" (512 KB, SPI) at physical address 0xfff80000.
===
This flash part has status NOT WORKING for operations: READ
This flash part has status UNTESTED for operations: PROBE ERASE WRITE
Please email a report to flashrom@flashrom.org if any of the above operations
work correctly for you with this flash part. Please include the flashrom
output with the additional -V option for all operations you tested (-V, -rV,
-wV, -EV), and mention which mainboard or programmer you tested. Thanks for your
 help!
===
No operations were specified.

C:>
Got a question? Please ask in the forum for the fastest answers.