From 3273003062841d1dfe73663cd8e8e0f02574c9fb Mon Sep 17 00:00:00 2001 From: Vadim Yanitskiy Date: Thu, 3 Feb 2022 02:37:39 +0600 Subject: 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 --- src/host/osmocon/osmocon.c | 10 +++++----- 1 file 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 */ -- cgit v1.2.3