summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVadim Yanitskiy <axilirator@gmail.com>2022-02-03 02:37:39 +0600
committerVadim Yanitskiy <vyanitskiy@sysmocom.de>2022-02-03 03:43:11 +0600
commit3273003062841d1dfe73663cd8e8e0f02574c9fb (patch)
tree5194c2fec3aab3c519075dd20824c8f8805140c9
parent3cc05e1480035835bda1de3479c77d2389b23af3 (diff)
host/osmocon: fix setting custom baudrate for CP210x
Sniffing requires higher baudrates, so in serial_up_to_eleven() we try first to set a non-standard baudrate=406250, which is known to work well with USB-UART converters based on FTDI's FT232 chip. Contrary to the FTDI's converters, CP210x based ones cannot be configured to use a non-standard baudrate directly. They require special mappings to be present in the EEPROM, so then using a setting baudrate=B460800 would actually make it use 406250. Normally, setting baudrate=406250 should fail for CP210x, so we fall-back to setting baudrate=B460800 if I_HAVE_A_CP210x is defined. However, for some weird reason, osmo_serial_set_custom_baudrate() *succeeds* setting non-standard baudrate=406250, what makes osmocon unable to communicate with the firmware. This looks like a regression in libosmocore, so let's try to work it around by moving the baudrate=406250 setting into the else block. Change-Id: I6c8a8227e5e5862a0f6b4121a6e67a9a2dda2a6d
-rw-r--r--src/host/osmocon/osmocon.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/host/osmocon/osmocon.c b/src/host/osmocon/osmocon.c
index c9dbfce1..43cc9438 100644
--- a/src/host/osmocon/osmocon.c
+++ b/src/host/osmocon/osmocon.c
@@ -237,16 +237,16 @@ int serial_up_to_eleven(void)
{
int rv;
- /* Attempt custom baudrate */
- rv = osmo_serial_set_custom_baudrate(dnload.serial_fd.fd, 406250);
- if (rv == 0)
- return 0;
-
#ifdef I_HAVE_A_CP210x /* and I know what I'm doing, I swear ! */
/* Try closest standard baudrate (CP210x reprogrammed adapters) */
rv = osmo_serial_set_baudrate(dnload.serial_fd.fd, B460800);
if (rv == 0)
return 0;
+#else
+ /* Attempt custom baudrate */
+ rv = osmo_serial_set_custom_baudrate(dnload.serial_fd.fd, 406250);
+ if (rv == 0)
+ return 0;
#endif
/* Everything failed */