Hello David Hendricks, Paul Menzel, build bot (Jenkins), Nico Huber,
I'd like you to reexamine a change. Please visit
https://review.coreboot.org/23057
to look at the new patch set (#2).
Change subject: buspirate_spi: Add support for variable serial speeds
......................................................................
buspirate_spi: Add support for variable serial speeds
This patch sets the default baud rate for communication between
the host device and the Bus Pirate for hardware versions 3.0
and greater to 2M baud.
It also introduces the ability to manually set the baud rate via
the added 'serialspeed' programmer parameter.
This is done in two parts. Firstly, the requested serial speed is looked up
in a table to determine the appropriate clock divisor and the divisor is sent
to the bus pirate. Then, the system's baud rate for the selected serial port
is set using serial.c's 'serialport_config'. This function's prototype had to
be added to programmer.h.
In testing, using the 2M baud rate was able to significantly decrease
flash times (down from 20+ minutes to less than 2 minutes for an 8MB flash).
Change-Id: I3706f17a94fdf056063f2ad4a5f0a219665cdcbf
Signed-off-by: Shawn Anastasio <shawnanastasio(a)yahoo.com>
---
M buspirate_spi.c
M programmer.h
2 files changed, 122 insertions(+), 8 deletions(-)
git pull ssh://review.coreboot.org:29418/flashrom refs/changes/57/23057/2
--
To view, visit https://review.coreboot.org/23057
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I3706f17a94fdf056063f2ad4a5f0a219665cdcbf
Gerrit-Change-Number: 23057
Gerrit-PatchSet: 2
Gerrit-Owner: Shawn Anastasio <shawnanastasio(a)yahoo.com>
Gerrit-Reviewer: David Hendricks <david.hendricks(a)gmail.com>
Gerrit-Reviewer: Nico Huber <nico.h(a)gmx.de>
Gerrit-Reviewer: Paul Menzel <paulepanter(a)users.sourceforge.net>
Gerrit-Reviewer: Shawn Anastasio <shawnanastasio(a)yahoo.com>
Gerrit-Reviewer: build bot (Jenkins) <no-reply(a)coreboot.org>
Nico Huber has posted comments on this change. ( https://review.coreboot.org/23057 )
Change subject: buspirate_spi: Add support for variable serial speeds
......................................................................
Patch Set 1:
(3 comments)
https://review.coreboot.org/#/c/23057/1/buspirate_spi.c
File buspirate_spi.c:
https://review.coreboot.org/#/c/23057/1/buspirate_spi.c@41
PS1, Line 41: const int divisor;
> For the divisor, that algorithm doesn't always result in the
> optimal divisor value (higher error than some other values).
For which value exactly??? I tried all you add below and got
the exact same numbers. Actually one of the lower ones would
be more accurate if you don't round down in (4,000,000 / baud)
but I don't see a reason for anything below 115200 anyway.
> I
> obtained the values used in the patch from this link:
> http://unwind.se/buspirate-baudrate/#std250000.
Don't care.
> As for the older buspirates, I'm not sure what custom baud values
> they support, if any. I could potentially add a hardware version
> check to prevent this functionality on older boards.
Yes, please do so. Actually, I think we should just use 2M for
newer versions and stick to 115200 for older ones. Less options,
less confusion and if anybody comes up with a pre-v3 model that
could go faster, we can still add an option for that.
https://review.coreboot.org/#/c/23057/1/buspirate_spi.c@202
PS1, Line 202: goto out_shutdown;
> I added the goto to prevent the code from breaking if more statements were added before the `out_shu […]
I would just drop it. We already take care of it when we open the
UART in buspirate_serialport_setup(). (IMHO, if any effect, reset-
ting it here might hide bugs in other programs that just assume
it's at 115200.)
https://review.coreboot.org/#/c/23057/1/buspirate_spi.c@352
PS1, Line 352: msg_pdbg("Detected Bus Pirate hardware %s\n", bp_commbuf);
> The BP can support many variable baud rates and some may be more
> appropriate in certain situations for different use cases. Instead
> of trying to guess this, I added the parameter so that the user can
> select the correct baud rate if they know it will work for their
> use case. The wiki could be updated to reflect this information as
> well.
v3 pirates all have the USB to UART integrated, right? If so, I think
it's fair to assume that there are no "different use cases".
--
To view, visit https://review.coreboot.org/23057
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I3706f17a94fdf056063f2ad4a5f0a219665cdcbf
Gerrit-Change-Number: 23057
Gerrit-PatchSet: 1
Gerrit-Owner: Shawn Anastasio <shawnanastasio(a)yahoo.com>
Gerrit-Reviewer: David Hendricks <david.hendricks(a)gmail.com>
Gerrit-Reviewer: Nico Huber <nico.h(a)gmx.de>
Gerrit-Reviewer: Paul Menzel <paulepanter(a)users.sourceforge.net>
Gerrit-Reviewer: Shawn Anastasio <shawnanastasio(a)yahoo.com>
Gerrit-Reviewer: build bot (Jenkins) <no-reply(a)coreboot.org>
Gerrit-Comment-Date: Wed, 03 Jan 2018 23:16:41 +0000
Gerrit-HasComments: Yes
Gerrit-HasLabels: No
Shawn Anastasio has posted comments on this change. ( https://review.coreboot.org/23057 )
Change subject: buspirate_spi: Add support for variable serial speeds
......................................................................
Patch Set 1:
(3 comments)
Hi, thanks for the comments.
I saw that patch earlier but didn't like how it enforced a single baud rate which might not always be compatible with your hardware, so I added the parameter.
I've addressed some of your replies below. Please let me know which directions to take with them.
Thanks again,
Shawn Anastasio
https://review.coreboot.org/#/c/23057/1/buspirate_spi.c
File buspirate_spi.c:
https://review.coreboot.org/#/c/23057/1/buspirate_spi.c@41
PS1, Line 41: const int divisor;
> Looks like the divisor is simply `4,000,000 / baud - 1`. Though, as […]
For the divisor, that algorithm doesn't always result in the optimal divisor value (higher error than some other values). I obtained the values used in the patch from this link: http://unwind.se/buspirate-baudrate/#std250000.
As for the older buspirates, I'm not sure what custom baud values they support, if any. I could potentially add a hardware version check to prevent this functionality on older boards.
https://review.coreboot.org/#/c/23057/1/buspirate_spi.c@202
PS1, Line 202: goto out_shutdown;
> Actually, no goto needed here. […]
I added the goto to prevent the code from breaking if more statements were added before the `out_shutdown` label with the thought that the compiler would optimize it out if it's not needed. I can remove it, however, if you believe it to be unnecessary.
As for the baud change, I figured that since the Bus Pirate was resetting itself to 115200, the host should do the same, but you're right that it's unnecessary since we're closing the UART connection immediately after. I can remove it if you want.
https://review.coreboot.org/#/c/23057/1/buspirate_spi.c@352
PS1, Line 352: msg_pdbg("Detected Bus Pirate hardware %s\n", bp_commbuf);
> Here the hardware version is stored in `bp_commbuf` can we use […]
The BP can support many variable baud rates and some may be more appropriate in certain situations for different use cases. Instead of trying to guess this, I added the parameter so that the user can select the correct baud rate if they know it will work for their use case. The wiki could be updated to reflect this information as well.
Since I don't have any BP 2 or older hardware to test, though, I could use this value to prevent baud rate changes entirely on the older hardware as mentioned above.
--
To view, visit https://review.coreboot.org/23057
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I3706f17a94fdf056063f2ad4a5f0a219665cdcbf
Gerrit-Change-Number: 23057
Gerrit-PatchSet: 1
Gerrit-Owner: Shawn Anastasio <shawnanastasio(a)yahoo.com>
Gerrit-Reviewer: David Hendricks <david.hendricks(a)gmail.com>
Gerrit-Reviewer: Nico Huber <nico.h(a)gmx.de>
Gerrit-Reviewer: Paul Menzel <paulepanter(a)users.sourceforge.net>
Gerrit-Reviewer: Shawn Anastasio <shawnanastasio(a)yahoo.com>
Gerrit-Reviewer: build bot (Jenkins) <no-reply(a)coreboot.org>
Gerrit-Comment-Date: Tue, 02 Jan 2018 22:05:51 +0000
Gerrit-HasComments: Yes
Gerrit-HasLabels: No
Nico Huber has posted comments on this change. ( https://review.coreboot.org/23057 )
Change subject: buspirate_spi: Add support for variable serial speeds
......................................................................
Patch Set 1:
(5 comments)
Carl-Daniel pointed out on IRC that there already was a patch floating
around:
https://mail.coreboot.org/pipermail/flashrom/2012-November/010102.html
He was also discussing pre-v3 buspirates. I guess we should filter
them out unless we can test the patch with one.
https://review.coreboot.org/#/c/23057/1/buspirate_spi.c
File buspirate_spi.c:
https://review.coreboot.org/#/c/23057/1/buspirate_spi.c@41
PS1, Line 41: const int divisor;
Looks like the divisor is simply `4,000,000 / baud - 1`. Though, as
I've just learned, most buspirates come with an integrated serial
UART to USB chip. So that raises the question if older buspirates
support the BAUD switch at all and if it makes sense to use any-
thing but the 2M?
https://review.coreboot.org/#/c/23057/1/buspirate_spi.c@200
PS1, Line 200: ret = buspirate_sendrecv(bp_commbuf, 1, 0);
If you are going to overwrite `ret` below, you should check it
here too and bail out in case.
https://review.coreboot.org/#/c/23057/1/buspirate_spi.c@201
PS1, Line 201: if ((ret = serialport_config(sp_fd, 115200)))
> nit: extra parens
IIRC, gcc wants those parens (because of the assignment).
https://review.coreboot.org/#/c/23057/1/buspirate_spi.c@202
PS1, Line 202: goto out_shutdown;
Actually, no goto needed here.
I'm also wondering why we should do this at all. We are not going
to transfer any more data and the baud is reset to 115200 whenever
we open the UART.
https://review.coreboot.org/#/c/23057/1/buspirate_spi.c@352
PS1, Line 352: msg_pdbg("Detected Bus Pirate hardware %s\n", bp_commbuf);
Here the hardware version is stored in `bp_commbuf` can we use
that to decide which baud rate to chose? I'd prefer that over
another option for the user to guess.
--
To view, visit https://review.coreboot.org/23057
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I3706f17a94fdf056063f2ad4a5f0a219665cdcbf
Gerrit-Change-Number: 23057
Gerrit-PatchSet: 1
Gerrit-Owner: Shawn Anastasio <shawnanastasio(a)yahoo.com>
Gerrit-Reviewer: David Hendricks <david.hendricks(a)gmail.com>
Gerrit-Reviewer: Nico Huber <nico.h(a)gmx.de>
Gerrit-Reviewer: Paul Menzel <paulepanter(a)users.sourceforge.net>
Gerrit-Reviewer: build bot (Jenkins) <no-reply(a)coreboot.org>
Gerrit-Comment-Date: Tue, 02 Jan 2018 20:40:50 +0000
Gerrit-HasComments: Yes
Gerrit-HasLabels: No