]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
serial: Call flush() before changing baudrate
authorPali Rohár <pali@kernel.org>
Mon, 5 Sep 2022 09:31:20 +0000 (11:31 +0200)
committerTom Rini <trini@konsulko.com>
Sat, 24 Sep 2022 15:34:38 +0000 (11:34 -0400)
Changing baudrate is a sensitive operation. To ensure that U-Boot messages
printed before changing baudrate are not lost, call new U-Boot console
flush() function.

Signed-off-by: Pali Rohár <pali@kernel.org>
Reviewed-by: Simon Glass <sjg@chromium.org>
cmd/load.c
drivers/serial/serial-uclass.c

index e44ae0d56b750c4311ff006fbcf8cd864ac77edc..5c4f34781d452e83448ed8f35142e860c157f4bc 100644 (file)
@@ -83,6 +83,7 @@ static int do_load_serial(struct cmd_tbl *cmdtp, int flag, int argc,
                printf("## Switch baudrate to %d bps and press ENTER ...\n",
                        load_baudrate);
                udelay(50000);
+               flush();
                gd->baudrate = load_baudrate;
                serial_setbrg();
                udelay(50000);
@@ -126,6 +127,7 @@ static int do_load_serial(struct cmd_tbl *cmdtp, int flag, int argc,
                printf("## Switch baudrate to %d bps and press ESC ...\n",
                        current_baudrate);
                udelay(50000);
+               flush();
                gd->baudrate = current_baudrate;
                serial_setbrg();
                udelay(50000);
@@ -317,6 +319,7 @@ int do_save_serial(struct cmd_tbl *cmdtp, int flag, int argc,
                printf("## Switch baudrate to %d bps and press ESC ...\n",
                        (int)current_baudrate);
                udelay(50000);
+               flush();
                gd->baudrate = current_baudrate;
                serial_setbrg();
                udelay(50000);
@@ -471,6 +474,7 @@ static int do_load_serial_bin(struct cmd_tbl *cmdtp, int flag, int argc,
                printf("## Switch baudrate to %d bps and press ENTER ...\n",
                        load_baudrate);
                udelay(50000);
+               flush();
                gd->baudrate = load_baudrate;
                serial_setbrg();
                udelay(50000);
@@ -533,6 +537,7 @@ static int do_load_serial_bin(struct cmd_tbl *cmdtp, int flag, int argc,
                printf("## Switch baudrate to %d bps and press ESC ...\n",
                        current_baudrate);
                udelay(50000);
+               flush();
                gd->baudrate = current_baudrate;
                serial_setbrg();
                udelay(50000);
index 53df10ee853dcdc7c489317d308cce882f5798d1..da3e1eb3ab1fa9bf621cda37edbc517ac3917b13 100644 (file)
@@ -476,6 +476,7 @@ static int on_baudrate(const char *name, const char *value, enum env_op op,
                        printf("## Switch baudrate to %d bps and press ENTER ...\n",
                               baudrate);
                        udelay(50000);
+                       flush();
                }
 
                gd->baudrate = baudrate;