Patchwork Bus Pirate UART speedup.

login
register
about
Submitter Stefan Tauner
Date 2013-04-01 16:49:02
Message ID <1364834942-2899-1-git-send-email-stefan.tauner@student.tuwien.ac.at>
Download mbox | patch
Permalink /patch/3919/
State New
Headers show

Comments

Stefan Tauner - 2013-04-01 16:49:02
Increase PIC/FT232 UART speed to 2 Mbaud (instead of 115200 baud) in
firmware 5.5 and newer. Given that UART speed is the biggest bottleneck
for Bus Pirate communication (right now 90% of the read time is caused
by slow BP<->host communication), this patch is absolutely needed to get
any decent speed out of the Bus Pirate.

WARNING: This patch may hang flashrom or corrupt data for any non-v3 Bus
Pirate model. I haven't tested such models, and it might work without
problems. Who knows. We would have to find someone with a v2 (or
earlier) Bus Pirate and a firmware version >=v5.5 to test this. For Bus
Pirate model v4 this patch may be completely superfluous. Anyway,
activating fast UART only for some models is probably the way to go. We
already have code to determine the hardware model in the init function,
this just needs to be stored in some variable.

Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
Signed-off-by: Stefan Tauner <stefan.tauner@student.tuwien.ac.at>
---
 buspirate_spi.c |   44 +++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 43 insertions(+), 1 deletion(-)
Idwer Vollering - 2014-02-08 17:43:05
2013-04-01 18:49 GMT+02:00 Stefan Tauner <stefan.tauner@student.tuwien.ac.at>:
> Increase PIC/FT232 UART speed to 2 Mbaud (instead of 115200 baud) in
> firmware 5.5 and newer. Given that UART speed is the biggest bottleneck
> for Bus Pirate communication (right now 90% of the read time is caused
> by slow BP<->host communication), this patch is absolutely needed to get
> any decent speed out of the Bus Pirate.
>
> WARNING: This patch may hang flashrom or corrupt data for any non-v3 Bus
> Pirate model. I haven't tested such models, and it might work without
> problems. Who knows. We would have to find someone with a v2 (or
> earlier) Bus Pirate and a firmware version >=v5.5 to test this. For Bus
> Pirate model v4 this patch may be completely superfluous. Anyway,
> activating fast UART only for some models is probably the way to go. We
> already have code to determine the hardware model in the init function,
> this just needs to be stored in some variable.

I've applied this patch but it doesn't use 2Mbaud on my buspirate v3.a
with firmware v6.3-beta1 r2088 or v6.3-beta1 r2151, nor will it
proceed to probing. Platforms used are linux and windows.

flashrom v0.9.7-r1764 on Linux 3.10-3-amd64 (x86_64)
flashrom is free software, get the source code at http://www.flashrom.org

flashrom was built with libpci 3.2.1, GCC 4.8.2, little endian
Command line (5 args): ./flashrom -VVV -p
buspirate_spi:dev=/dev/ttyUSB0 -r buspirate_read.bin
Calibrating delay loop... OS timer resolution is 1 usecs, 945M loops
per second, 10 myus = 12 us, 100 myus = 119 us, 1000 myus = 1187 us,
10000 myus = 11863 us, 4 myus = 5 us, OK.
Initializing buspirate_spi programmer
Baud rate is 115200 now.
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 , receiving 0x42 0x42 0x49 0x4f
buspirate_sendrecv: write 1, read 0 Sending 0x0f
buspirate_sendrecv: write 0, read 6 , receiving 0x31 0x01 0x0d 0x0a 0x42 0x75
buspirate_sendrecv: write 0, read 1 , receiving 0x73
buspirate_sendrecv: write 0, read 1 , receiving 0x20
buspirate_sendrecv: write 0, read 1 , receiving 0x50
buspirate_sendrecv: write 0, read 1 , receiving 0x69
buspirate_sendrecv: write 0, read 1 , receiving 0x72
buspirate_sendrecv: write 0, read 1 , receiving 0x61
buspirate_sendrecv: write 0, read 1 , receiving 0x74
buspirate_sendrecv: write 0, read 1 , receiving 0x65
buspirate_sendrecv: write 0, read 1 , receiving 0x20
buspirate_sendrecv: write 0, read 1 , receiving 0x76
buspirate_sendrecv: write 0, read 1 , receiving 0x33
buspirate_sendrecv: write 0, read 1 , receiving 0x2e
buspirate_sendrecv: write 0, read 1 , receiving 0x61
buspirate_sendrecv: write 0, read 1 , receiving 0x0d
Detected Bus Pirate hardware v3.a
buspirate_sendrecv: write 0, read 8 , receiving 0x0a 0x46 0x69 0x72
0x6d 0x77 0x61 0x72
buspirate_sendrecv: write 0, read 1 , receiving 0x65
buspirate_sendrecv: write 0, read 1 , receiving 0x20
buspirate_sendrecv: write 0, read 1 , receiving 0x76
buspirate_sendrecv: write 0, read 1 , receiving 0x36
buspirate_sendrecv: write 0, read 1 , receiving 0x2e
buspirate_sendrecv: write 0, read 1 , receiving 0x33
buspirate_sendrecv: write 0, read 1 , receiving 0x2d
buspirate_sendrecv: write 0, read 1 , receiving 0x62
buspirate_sendrecv: write 0, read 1 , receiving 0x65
buspirate_sendrecv: write 0, read 1 , receiving 0x74
buspirate_sendrecv: write 0, read 1 , receiving 0x61
buspirate_sendrecv: write 0, read 1 , receiving 0x31
buspirate_sendrecv: write 0, read 1 , receiving 0x20
Detected Bus Pirate firmware 6.3 ("v6.3-beta1")
buspirate_sendrecv: write 0, read 4 , receiving 0x72 0x32 0x30 0x38
buspirate_sendrecv: write 0, read 1 , receiving 0x38
buspirate_sendrecv: write 0, read 1 , receiving 0x20
buspirate_sendrecv: write 0, read 1 , receiving 0x20
buspirate_sendrecv: write 0, read 1 , receiving 0x42
buspirate_sendrecv: write 0, read 1 , receiving 0x6f
buspirate_sendrecv: write 0, read 1 , receiving 0x6f
buspirate_sendrecv: write 0, read 1 , receiving 0x74
buspirate_sendrecv: write 0, read 1 , receiving 0x6c
buspirate_sendrecv: write 0, read 1 , receiving 0x6f
buspirate_sendrecv: write 0, read 1 , receiving 0x61
buspirate_sendrecv: write 0, read 1 , receiving 0x64
buspirate_sendrecv: write 0, read 1 , receiving 0x65
buspirate_sendrecv: write 0, read 1 , receiving 0x72
buspirate_sendrecv: write 0, read 1 , receiving 0x20
buspirate_sendrecv: write 0, read 1 , receiving 0x76
buspirate_sendrecv: write 0, read 1 , receiving 0x34
buspirate_sendrecv: write 0, read 1 , receiving 0x2e
buspirate_sendrecv: write 0, read 1 , receiving 0x34
buspirate_sendrecv: write 0, read 1 , receiving 0x0d
buspirate_sendrecv: write 0, read 1 , receiving 0x0a
buspirate_sendrecv: write 0, read 1 , receiving 0x44
buspirate_sendrecv: write 0, read 1 , receiving 0x45
buspirate_sendrecv: write 0, read 1 , receiving 0x56
buspirate_sendrecv: write 0, read 1 , receiving 0x49
buspirate_sendrecv: write 0, read 1 , receiving 0x44
buspirate_sendrecv: write 0, read 1 , receiving 0x3a
buspirate_sendrecv: write 0, read 1 , receiving 0x30
buspirate_sendrecv: write 0, read 1 , receiving 0x78
buspirate_sendrecv: write 0, read 1 , receiving 0x30
buspirate_sendrecv: write 0, read 1 , receiving 0x34
buspirate_sendrecv: write 0, read 1 , receiving 0x34
buspirate_sendrecv: write 0, read 1 , receiving 0x37
buspirate_sendrecv: write 0, read 1 , receiving 0x20
buspirate_sendrecv: write 0, read 1 , receiving 0x52
buspirate_sendrecv: write 0, read 1 , receiving 0x45
buspirate_sendrecv: write 0, read 1 , receiving 0x56
buspirate_sendrecv: write 0, read 1 , receiving 0x49
buspirate_sendrecv: write 0, read 1 , receiving 0x44
buspirate_sendrecv: write 0, read 1 , receiving 0x3a
buspirate_sendrecv: write 0, read 1 , receiving 0x30
buspirate_sendrecv: write 0, read 1 , receiving 0x78
buspirate_sendrecv: write 0, read 1 , receiving 0x33
buspirate_sendrecv: write 0, read 1 , receiving 0x30
buspirate_sendrecv: write 0, read 1 , receiving 0x34
buspirate_sendrecv: write 0, read 1 , receiving 0x36
buspirate_sendrecv: write 0, read 1 , receiving 0x20
buspirate_sendrecv: write 0, read 1 , receiving 0x28
buspirate_sendrecv: write 0, read 1 , receiving 0x32
buspirate_sendrecv: write 0, read 1 , receiving 0x34
buspirate_sendrecv: write 0, read 1 , receiving 0x46
buspirate_sendrecv: write 0, read 1 , receiving 0x4a
buspirate_sendrecv: write 0, read 1 , receiving 0x36
buspirate_sendrecv: write 0, read 1 , receiving 0x34
buspirate_sendrecv: write 0, read 1 , receiving 0x47
buspirate_sendrecv: write 0, read 1 , receiving 0x41
buspirate_sendrecv: write 0, read 1 , receiving 0x30
buspirate_sendrecv: write 0, read 1 , receiving 0x30
buspirate_sendrecv: write 0, read 1 , receiving 0x32
buspirate_sendrecv: write 0, read 1 , receiving 0x20
buspirate_sendrecv: write 0, read 1 , receiving 0x42
buspirate_sendrecv: write 0, read 1 , receiving 0x38
buspirate_sendrecv: write 0, read 1 , receiving 0x29
buspirate_sendrecv: write 0, read 1 , receiving 0x0d
buspirate_sendrecv: write 0, read 1 , receiving 0x0a
buspirate_sendrecv: write 0, read 1 , receiving 0x68
buspirate_sendrecv: write 0, read 1 , receiving 0x74
buspirate_sendrecv: write 0, read 1 , receiving 0x74
buspirate_sendrecv: write 0, read 1 , receiving 0x70
buspirate_sendrecv: write 0, read 1 , receiving 0x3a
buspirate_sendrecv: write 0, read 1 , receiving 0x2f
buspirate_sendrecv: write 0, read 1 , receiving 0x2f
buspirate_sendrecv: write 0, read 1 , receiving 0x64
buspirate_sendrecv: write 0, read 1 , receiving 0x61
buspirate_sendrecv: write 0, read 1 , receiving 0x6e
buspirate_sendrecv: write 0, read 1 , receiving 0x67
buspirate_sendrecv: write 0, read 1 , receiving 0x65
buspirate_sendrecv: write 0, read 1 , receiving 0x72
buspirate_sendrecv: write 0, read 1 , receiving 0x6f
buspirate_sendrecv: write 0, read 1 , receiving 0x75
buspirate_sendrecv: write 0, read 1 , receiving 0x73
buspirate_sendrecv: write 0, read 1 , receiving 0x70
buspirate_sendrecv: write 0, read 1 , receiving 0x72
buspirate_sendrecv: write 0, read 1 , receiving 0x6f
buspirate_sendrecv: write 0, read 1 , receiving 0x74
buspirate_sendrecv: write 0, read 1 , receiving 0x6f
buspirate_sendrecv: write 0, read 1 , receiving 0x74
buspirate_sendrecv: write 0, read 1 , receiving 0x79
buspirate_sendrecv: write 0, read 1 , receiving 0x70
buspirate_sendrecv: write 0, read 1 , receiving 0x65
buspirate_sendrecv: write 0, read 1 , receiving 0x73
buspirate_sendrecv: write 0, read 1 , receiving 0x2e
buspirate_sendrecv: write 0, read 1 , receiving 0x63
buspirate_sendrecv: write 0, read 1 , receiving 0x6f
buspirate_sendrecv: write 0, read 1 , receiving 0x6d
buspirate_sendrecv: write 0, read 1 , receiving 0x0d
buspirate_sendrecv: write 0, read 1 , receiving 0x0a
buspirate_sendrecv: write 0, read 1 , receiving 0x48
buspirate_sendrecv: write 0, read 1 , receiving 0x69
buspirate_sendrecv: write 0, read 1 , receiving 0x5a
buspirate_sendrecv: write 0, read 1 , receiving 0x3e
Using SPI command set v2.
buspirate_sendrecv: write 2, read 0 Sending 0x62 0x0a
buspirate_sendrecv: write 0, read 1 , receiving 0x62
buspirate_sendrecv: write 0, read 1 , receiving 0x0d
buspirate_sendrecv: write 0, read 1 , receiving 0x0a
buspirate_sendrecv: write 0, read 1 , receiving 0x53
buspirate_sendrecv: write 0, read 1 , receiving 0x65
buspirate_sendrecv: write 0, read 1 , receiving 0x74
buspirate_sendrecv: write 0, read 1 , receiving 0x20
buspirate_sendrecv: write 0, read 1 , receiving 0x73
buspirate_sendrecv: write 0, read 1 , receiving 0x65
buspirate_sendrecv: write 0, read 1 , receiving 0x72
buspirate_sendrecv: write 0, read 1 , receiving 0x69
buspirate_sendrecv: write 0, read 1 , receiving 0x61
buspirate_sendrecv: write 0, read 1 , receiving 0x6c
buspirate_sendrecv: write 0, read 1 , receiving 0x20
buspirate_sendrecv: write 0, read 1 , receiving 0x70
buspirate_sendrecv: write 0, read 1 , receiving 0x6f
buspirate_sendrecv: write 0, read 1 , receiving 0x72
buspirate_sendrecv: write 0, read 1 , receiving 0x74
buspirate_sendrecv: write 0, read 1 , receiving 0x20
buspirate_sendrecv: write 0, read 1 , receiving 0x73
buspirate_sendrecv: write 0, read 1 , receiving 0x70
buspirate_sendrecv: write 0, read 1 , receiving 0x65
buspirate_sendrecv: write 0, read 1 , receiving 0x65
buspirate_sendrecv: write 0, read 1 , receiving 0x64
buspirate_sendrecv: write 0, read 1 , receiving 0x3a
buspirate_sendrecv: write 0, read 1 , receiving 0x20
buspirate_sendrecv: write 0, read 1 , receiving 0x28
buspirate_sendrecv: write 0, read 1 , receiving 0x62
buspirate_sendrecv: write 0, read 1 , receiving 0x70
buspirate_sendrecv: write 0, read 1 , receiving 0x73
buspirate_sendrecv: write 0, read 1 , receiving 0x29
buspirate_sendrecv: write 0, read 1 , receiving 0x0d
buspirate_sendrecv: write 0, read 1 , receiving 0x0a
buspirate_sendrecv: write 0, read 1 , receiving 0x20
buspirate_sendrecv: write 0, read 1 , receiving 0x31
buspirate_sendrecv: write 0, read 1 , receiving 0x2e
buspirate_sendrecv: write 0, read 1 , receiving 0x20
buspirate_sendrecv: write 0, read 1 , receiving 0x33
buspirate_sendrecv: write 0, read 1 , receiving 0x30
buspirate_sendrecv: write 0, read 1 , receiving 0x30
buspirate_sendrecv: write 0, read 1 , receiving 0x0d
buspirate_sendrecv: write 0, read 1 , receiving 0x0a
buspirate_sendrecv: write 0, read 1 , receiving 0x20
buspirate_sendrecv: write 0, read 1 , receiving 0x32
buspirate_sendrecv: write 0, read 1 , receiving 0x2e
buspirate_sendrecv: write 0, read 1 , receiving 0x20
buspirate_sendrecv: write 0, read 1 , receiving 0x31
buspirate_sendrecv: write 0, read 1 , receiving 0x32
buspirate_sendrecv: write 0, read 1 , receiving 0x30
buspirate_sendrecv: write 0, read 1 , receiving 0x30
buspirate_sendrecv: write 0, read 1 , receiving 0x0d
buspirate_sendrecv: write 0, read 1 , receiving 0x0a
buspirate_sendrecv: write 0, read 1 , receiving 0x20
buspirate_sendrecv: write 0, read 1 , receiving 0x33
buspirate_sendrecv: write 0, read 1 , receiving 0x2e
buspirate_sendrecv: write 0, read 1 , receiving 0x20
buspirate_sendrecv: write 0, read 1 , receiving 0x32
buspirate_sendrecv: write 0, read 1 , receiving 0x34
buspirate_sendrecv: write 0, read 1 , receiving 0x30
buspirate_sendrecv: write 0, read 1 , receiving 0x30
buspirate_sendrecv: write 0, read 1 , receiving 0x0d
buspirate_sendrecv: write 0, read 1 , receiving 0x0a
buspirate_sendrecv: write 0, read 1 , receiving 0x20
buspirate_sendrecv: write 0, read 1 , receiving 0x34
buspirate_sendrecv: write 0, read 1 , receiving 0x2e
buspirate_sendrecv: write 0, read 1 , receiving 0x20
buspirate_sendrecv: write 0, read 1 , receiving 0x34
buspirate_sendrecv: write 0, read 1 , receiving 0x38
buspirate_sendrecv: write 0, read 1 , receiving 0x30
buspirate_sendrecv: write 0, read 1 , receiving 0x30
buspirate_sendrecv: write 0, read 1 , receiving 0x0d
buspirate_sendrecv: write 0, read 1 , receiving 0x0a
buspirate_sendrecv: write 0, read 1 , receiving 0x20
buspirate_sendrecv: write 0, read 1 , receiving 0x35
buspirate_sendrecv: write 0, read 1 , receiving 0x2e
buspirate_sendrecv: write 0, read 1 , receiving 0x20
buspirate_sendrecv: write 0, read 1 , receiving 0x39
buspirate_sendrecv: write 0, read 1 , receiving 0x36
buspirate_sendrecv: write 0, read 1 , receiving 0x30
buspirate_sendrecv: write 0, read 1 , receiving 0x30
buspirate_sendrecv: write 0, read 1 , receiving 0x0d
buspirate_sendrecv: write 0, read 1 , receiving 0x0a
buspirate_sendrecv: write 0, read 1 , receiving 0x20
buspirate_sendrecv: write 0, read 1 , receiving 0x36
buspirate_sendrecv: write 0, read 1 , receiving 0x2e
buspirate_sendrecv: write 0, read 1 , receiving 0x20
buspirate_sendrecv: write 0, read 1 , receiving 0x31
buspirate_sendrecv: write 0, read 1 , receiving 0x39
buspirate_sendrecv: write 0, read 1 , receiving 0x32
buspirate_sendrecv: write 0, read 1 , receiving 0x30
buspirate_sendrecv: write 0, read 1 , receiving 0x30
buspirate_sendrecv: write 0, read 1 , receiving 0x0d
buspirate_sendrecv: write 0, read 1 , receiving 0x0a
buspirate_sendrecv: write 0, read 1 , receiving 0x20
buspirate_sendrecv: write 0, read 1 , receiving 0x37
buspirate_sendrecv: write 0, read 1 , receiving 0x2e
buspirate_sendrecv: write 0, read 1 , receiving 0x20
buspirate_sendrecv: write 0, read 1 , receiving 0x33
buspirate_sendrecv: write 0, read 1 , receiving 0x38
buspirate_sendrecv: write 0, read 1 , receiving 0x34
buspirate_sendrecv: write 0, read 1 , receiving 0x30
buspirate_sendrecv: write 0, read 1 , receiving 0x30
buspirate_sendrecv: write 0, read 1 , receiving 0x0d
buspirate_sendrecv: write 0, read 1 , receiving 0x0a
buspirate_sendrecv: write 0, read 1 , receiving 0x20
buspirate_sendrecv: write 0, read 1 , receiving 0x38
buspirate_sendrecv: write 0, read 1 , receiving 0x2e
buspirate_sendrecv: write 0, read 1 , receiving 0x20
buspirate_sendrecv: write 0, read 1 , receiving 0x35
buspirate_sendrecv: write 0, read 1 , receiving 0x37
buspirate_sendrecv: write 0, read 1 , receiving 0x36
buspirate_sendrecv: write 0, read 1 , receiving 0x30
buspirate_sendrecv: write 0, read 1 , receiving 0x30
buspirate_sendrecv: write 0, read 1 , receiving 0x0d
buspirate_sendrecv: write 0, read 1 , receiving 0x0a
buspirate_sendrecv: write 0, read 1 , receiving 0x20
buspirate_sendrecv: write 0, read 1 , receiving 0x39
buspirate_sendrecv: write 0, read 1 , receiving 0x2e
buspirate_sendrecv: write 0, read 1 , receiving 0x20
buspirate_sendrecv: write 0, read 1 , receiving 0x31
buspirate_sendrecv: write 0, read 1 , receiving 0x31
buspirate_sendrecv: write 0, read 1 , receiving 0x35
buspirate_sendrecv: write 0, read 1 , receiving 0x32
buspirate_sendrecv: write 0, read 1 , receiving 0x30
buspirate_sendrecv: write 0, read 1 , receiving 0x30
buspirate_sendrecv: write 0, read 1 , receiving 0x0d
buspirate_sendrecv: write 0, read 1 , receiving 0x0a
buspirate_sendrecv: write 0, read 1 , receiving 0x31
buspirate_sendrecv: write 0, read 1 , receiving 0x30
buspirate_sendrecv: write 0, read 1 , receiving 0x2e
buspirate_sendrecv: write 0, read 1 , receiving 0x20
buspirate_sendrecv: write 0, read 1 , receiving 0x42
buspirate_sendrecv: write 0, read 1 , receiving 0x52
buspirate_sendrecv: write 0, read 1 , receiving 0x47
buspirate_sendrecv: write 0, read 1 , receiving 0x20
buspirate_sendrecv: write 0, read 1 , receiving 0x72
buspirate_sendrecv: write 0, read 1 , receiving 0x61
buspirate_sendrecv: write 0, read 1 , receiving 0x77
buspirate_sendrecv: write 0, read 1 , receiving 0x20
buspirate_sendrecv: write 0, read 1 , receiving 0x76
buspirate_sendrecv: write 0, read 1 , receiving 0x61
buspirate_sendrecv: write 0, read 1 , receiving 0x6c
buspirate_sendrecv: write 0, read 1 , receiving 0x75
buspirate_sendrecv: write 0, read 1 , receiving 0x65
buspirate_sendrecv: write 0, read 1 , receiving 0x0d
buspirate_sendrecv: write 0, read 1 , receiving 0x0a
buspirate_sendrecv: write 0, read 1 , receiving 0x0d
buspirate_sendrecv: write 0, read 1 , receiving 0x0a
buspirate_sendrecv: write 0, read 1 , receiving 0x28
buspirate_sendrecv: write 0, read 1 , receiving 0x39
buspirate_sendrecv: write 0, read 1 , receiving 0x29
buspirate_sendrecv: write 0, read 1 , receiving 0x3e
buspirate_sendrecv: write 3, read 0 Sending 0x31 0x30 0x0a
buspirate_sendrecv: write 0, read 1 , receiving 0x31
buspirate_sendrecv: write 0, read 1 , receiving 0x30
buspirate_sendrecv: write 0, read 1 , receiving 0x0d
buspirate_sendrecv: write 0, read 1 , receiving 0x0a
buspirate_sendrecv: write 0, read 1 , receiving 0x45
buspirate_sendrecv: write 0, read 1 , receiving 0x6e
buspirate_sendrecv: write 0, read 1 , receiving 0x74
buspirate_sendrecv: write 0, read 1 , receiving 0x65
buspirate_sendrecv: write 0, read 1 , receiving 0x72
buspirate_sendrecv: write 0, read 1 , receiving 0x20
buspirate_sendrecv: write 0, read 1 , receiving 0x72
buspirate_sendrecv: write 0, read 1 , receiving 0x61
buspirate_sendrecv: write 0, read 1 , receiving 0x77
buspirate_sendrecv: write 0, read 1 , receiving 0x20
buspirate_sendrecv: write 0, read 1 , receiving 0x76
buspirate_sendrecv: write 0, read 1 , receiving 0x61
buspirate_sendrecv: write 0, read 1 , receiving 0x6c
buspirate_sendrecv: write 0, read 1 , receiving 0x75
buspirate_sendrecv: write 0, read 1 , receiving 0x65
buspirate_sendrecv: write 0, read 1 , receiving 0x20
buspirate_sendrecv: write 0, read 1 , receiving 0x66
buspirate_sendrecv: write 0, read 1 , receiving 0x6f
buspirate_sendrecv: write 0, read 1 , receiving 0x72
buspirate_sendrecv: write 0, read 1 , receiving 0x20
buspirate_sendrecv: write 0, read 1 , receiving 0x42
buspirate_sendrecv: write 0, read 1 , receiving 0x52
buspirate_sendrecv: write 0, read 1 , receiving 0x47
buspirate_sendrecv: write 0, read 1 , receiving 0x0d
buspirate_sendrecv: write 0, read 1 , receiving 0x0a
buspirate_sendrecv: write 0, read 1 , receiving 0x0d
buspirate_sendrecv: write 0, read 1 , receiving 0x0a
buspirate_sendrecv: write 0, read 1 , receiving 0x28
buspirate_sendrecv: write 0, read 1 , receiving 0x33
buspirate_sendrecv: write 0, read 1 , receiving 0x34
buspirate_sendrecv: write 0, read 1 , receiving 0x29
buspirate_sendrecv: write 0, read 1 , receiving 0x3e
buspirate_sendrecv: write 2, read 0 Sending 0x31 0x0a
Baud rate is 115200 now.
buspirate_sendrecv: write 1, read 0 Sending 0x20
buspirate_sendrecv: write 0, read 4 , receiving 0x31 0x0d 0x0a 0x41
buspirate_sendrecv: write 0, read 1 , receiving 0x64
buspirate_sendrecv: write 0, read 1 , receiving 0x6a
buspirate_sendrecv: write 0, read 1 , receiving 0x75
buspirate_sendrecv: write 0, read 1 , receiving 0x73
buspirate_sendrecv: write 0, read 1 , receiving 0x74
buspirate_sendrecv: write 0, read 1 , receiving 0x20
buspirate_sendrecv: write 0, read 1 , receiving 0x79
buspirate_sendrecv: write 0, read 1 , receiving 0x6f
buspirate_sendrecv: write 0, read 1 , receiving 0x75
buspirate_sendrecv: write 0, read 1 , receiving 0x72
buspirate_sendrecv: write 0, read 1 , receiving 0x20
buspirate_sendrecv: write 0, read 1 , receiving 0x74
buspirate_sendrecv: write 0, read 1 , receiving 0x65
buspirate_sendrecv: write 0, read 1 , receiving 0x72
buspirate_sendrecv: write 0, read 1 , receiving 0x6d
buspirate_sendrecv: write 0, read 1 , receiving 0x69
buspirate_sendrecv: write 0, read 1 , receiving 0x6e
buspirate_sendrecv: write 0, read 1 , receiving 0x61
buspirate_sendrecv: write 0, read 1 , receiving 0x6c
buspirate_sendrecv: write 0, read 1 , receiving 0x0d
buspirate_sendrecv: write 0, read 1 , receiving 0x0a
buspirate_sendrecv: write 0, read 1 , receiving 0x53
buspirate_sendrecv: write 0, read 1 , receiving 0x70
buspirate_sendrecv: write 0, read 1 , receiving 0x61
buspirate_sendrecv: write 0, read 1 , receiving 0x63
buspirate_sendrecv: write 0, read 1 , receiving 0x65
buspirate_sendrecv: write 0, read 1 , receiving 0x20
buspirate_sendrecv: write 0, read 1 , receiving 0x74
buspirate_sendrecv: write 0, read 1 , receiving 0x6f
buspirate_sendrecv: write 0, read 1 , receiving 0x20
buspirate_sendrecv: write 0, read 1 , receiving 0x63
buspirate_sendrecv: write 0, read 1 , receiving 0x6f
buspirate_sendrecv: write 0, read 1 , receiving 0x6e
buspirate_sendrecv: write 0, read 1 , receiving 0x74
buspirate_sendrecv: write 0, read 1 , receiving 0x69
buspirate_sendrecv: write 0, read 1

>
> Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
> Signed-off-by: Stefan Tauner <stefan.tauner@student.tuwien.ac.at>
> ---
>  buspirate_spi.c |   44 +++++++++++++++++++++++++++++++++++++++++++-
>  1 file changed, 43 insertions(+), 1 deletion(-)
>
> diff --git a/buspirate_spi.c b/buspirate_spi.c
> index d2ebc75..57da63a 100644
> --- a/buspirate_spi.c
> +++ b/buspirate_spi.c
> @@ -178,7 +178,10 @@ static int buspirate_spi_shutdown(void *data)
>         }
>         /* Reset Bus Pirate (return to user terminal) */
>         bp_commbuf[0] = 0x0f;
> -       ret = buspirate_sendrecv(bp_commbuf, 1, 0);
> +       if ((ret = buspirate_sendrecv(bp_commbuf, 1, 0)))
> +               goto out_shutdown;
> +       if ((ret = serialport_config(sp_fd, 115200)))
> +               goto out_shutdown;
>
>  out_shutdown:
>         /* Shut down serial port communication */
> @@ -365,6 +368,45 @@ int buspirate_spi_init(void)
>                 spi_programmer_buspirate.command = buspirate_spi_send_command_v1;
>         }
>
> +       /* Increase PIC/FT232 UART speed to 2 Mbaud (instead of 115200 baud) in firmware 5.5 and newer.

Where is the firmware able to increase UART speed when/while 115200 is
the highest speed documented? See
https://code.google.com/p/dangerous-prototypes-open-hardware/source/browse/trunk/Bus_Pirate/Firmware/UART.c#499

> +        * Although this is already possible in firmware 5.2, fast UART in combination with the old SPI
> +        * command set causes hangs for bigger transactions. This is caused by a UART buffer overrun
> +        * in the PIC, and all firmware versions up to (hopefully not including) 6.2 are affected.
> +        */
> +       if (BP_FWVERSION(fw_version_major, fw_version_minor) >= BP_FWVERSION(5, 5)) {
> +               // FIXME: Do this only for USB-based Bus Pirates... unless you're sure the UART can handle more.
> +               int cmdlen;
> +               /* Request setting the UART baud rate. */
> +               cmdlen = snprintf((char *)bp_commbuf, DEFAULT_BUFSIZE, "b\n");
> +               if ((ret = buspirate_sendrecv(bp_commbuf, cmdlen, 0)))
> +                       return ret;
> +               if ((ret = buspirate_wait_for_string(bp_commbuf, ">")))
> +                       return ret;
> +               /* Request setting the UART clock divisor manually. */
> +               cmdlen = snprintf((char *)bp_commbuf, DEFAULT_BUFSIZE, "10\n");
> +               if ((ret = buspirate_sendrecv(bp_commbuf, cmdlen, 0)))
> +                       return ret;
> +               if ((ret = buspirate_wait_for_string(bp_commbuf, ">")))
> +                       return ret;
> +               /* Set the UART clock divisor. New clock is 4000000/(divisor+1). */
> +               cmdlen = snprintf((char *)bp_commbuf, DEFAULT_BUFSIZE, "%i\n", 1);
> +               if ((ret = buspirate_sendrecv(bp_commbuf, cmdlen, 0)))
> +                       return ret;
> +               sleep(1);
> +               if (serialport_config(sp_fd, 115200) != 0)
> +                       return 1;
> +               bp_commbuf[0] = ' ';
> +               if ((ret = buspirate_sendrecv(bp_commbuf, 1, 0)))
> +                       return ret;
> +               if ((ret = buspirate_wait_for_string(bp_commbuf, "HiZ>")))
> +                       return ret;
> +               msg_pdbg("Using fast 2 Mbaud for Bus Pirate <-> host communication.\n");
> +       } else {
> +               msg_pinfo("Bus Pirate firmware 5.4 and older does not support fast Bus Pirate <-> host "
> +                         "communication. Limiting UART speed to 115200 Baud.\n");
> +               msg_pinfo("It is recommended to upgrade to firmware 6.2 or newer.\n");
> +       }
> +
>         /* Workaround for broken speed settings in firmware 6.1 and older. */
>         if (BP_FWVERSION(fw_version_major, fw_version_minor) < BP_FWVERSION(6, 2))
>                 if (spispeed > 0x4) {
> --
> Kind regards, Stefan Tauner
>
>
> _______________________________________________
> flashrom mailing list
> flashrom@flashrom.org
> http://www.flashrom.org/mailman/listinfo/flashrom

Patch

diff --git a/buspirate_spi.c b/buspirate_spi.c
index d2ebc75..57da63a 100644
--- a/buspirate_spi.c
+++ b/buspirate_spi.c
@@ -178,7 +178,10 @@  static int buspirate_spi_shutdown(void *data)
 	}
 	/* Reset Bus Pirate (return to user terminal) */
 	bp_commbuf[0] = 0x0f;
-	ret = buspirate_sendrecv(bp_commbuf, 1, 0);
+	if ((ret = buspirate_sendrecv(bp_commbuf, 1, 0)))
+		goto out_shutdown;
+	if ((ret = serialport_config(sp_fd, 115200)))
+		goto out_shutdown;
 
 out_shutdown:
 	/* Shut down serial port communication */
@@ -365,6 +368,45 @@  int buspirate_spi_init(void)
 		spi_programmer_buspirate.command = buspirate_spi_send_command_v1;
 	}
 
+	/* Increase PIC/FT232 UART speed to 2 Mbaud (instead of 115200 baud) in firmware 5.5 and newer.
+	 * Although this is already possible in firmware 5.2, fast UART in combination with the old SPI
+	 * command set causes hangs for bigger transactions. This is caused by a UART buffer overrun
+	 * in the PIC, and all firmware versions up to (hopefully not including) 6.2 are affected.
+	 */
+	if (BP_FWVERSION(fw_version_major, fw_version_minor) >= BP_FWVERSION(5, 5)) {
+		// FIXME: Do this only for USB-based Bus Pirates... unless you're sure the UART can handle more.
+		int cmdlen;
+		/* Request setting the UART baud rate. */
+		cmdlen = snprintf((char *)bp_commbuf, DEFAULT_BUFSIZE, "b\n");
+		if ((ret = buspirate_sendrecv(bp_commbuf, cmdlen, 0)))
+			return ret;
+		if ((ret = buspirate_wait_for_string(bp_commbuf, ">")))
+			return ret;
+		/* Request setting the UART clock divisor manually. */
+		cmdlen = snprintf((char *)bp_commbuf, DEFAULT_BUFSIZE, "10\n");
+		if ((ret = buspirate_sendrecv(bp_commbuf, cmdlen, 0)))
+			return ret;
+		if ((ret = buspirate_wait_for_string(bp_commbuf, ">")))
+			return ret;
+		/* Set the UART clock divisor. New clock is 4000000/(divisor+1). */
+		cmdlen = snprintf((char *)bp_commbuf, DEFAULT_BUFSIZE, "%i\n", 1);
+		if ((ret = buspirate_sendrecv(bp_commbuf, cmdlen, 0)))
+			return ret;
+		sleep(1);
+		if (serialport_config(sp_fd, 115200) != 0)
+			return 1;
+		bp_commbuf[0] = ' ';
+		if ((ret = buspirate_sendrecv(bp_commbuf, 1, 0)))
+			return ret;
+		if ((ret = buspirate_wait_for_string(bp_commbuf, "HiZ>")))
+			return ret;
+		msg_pdbg("Using fast 2 Mbaud for Bus Pirate <-> host communication.\n");
+	} else {
+		msg_pinfo("Bus Pirate firmware 5.4 and older does not support fast Bus Pirate <-> host "
+			  "communication. Limiting UART speed to 115200 Baud.\n");
+		msg_pinfo("It is recommended to upgrade to firmware 6.2 or newer.\n");
+	}
+
 	/* Workaround for broken speed settings in firmware 6.1 and older. */
 	if (BP_FWVERSION(fw_version_major, fw_version_minor) < BP_FWVERSION(6, 2))
 		if (spispeed > 0x4) {