From c179741cf31ac338867082d503626f19e841731e Mon Sep 17 00:00:00 2001 From: Florent Kermarrec Date: Tue, 27 Aug 2019 09:45:44 +0200 Subject: [PATCH] software/bios: switch to standard CRLF Avoid setting terminal to "implicit CR in every LF" mode. --- .../core/modules/serial2console/serial2console.c | 6 ++---- litex/soc/software/libbase/console.c | 2 ++ litex/tools/litex_term.py | 15 +-------------- 3 files changed, 5 insertions(+), 18 deletions(-) diff --git a/litex/build/sim/core/modules/serial2console/serial2console.c b/litex/build/sim/core/modules/serial2console/serial2console.c index 12704c423..c32b568f7 100644 --- a/litex/build/sim/core/modules/serial2console/serial2console.c +++ b/litex/build/sim/core/modules/serial2console/serial2console.c @@ -72,7 +72,7 @@ void read_handler(int fd, short event, void *arg) struct session_s *s = (struct session_s*)arg; char buffer[1024]; ssize_t read_len; - + int i; read_len = read(fd, buffer, 1024); for(i = 0; i < read_len; i++) { @@ -137,7 +137,7 @@ static int serial2console_add_pads(void *sess, struct pad_list_s *plist) litex_sim_module_pads_get(pads, "source_valid", (void**)&s->tx_valid); litex_sim_module_pads_get(pads, "source_ready", (void**)&s->tx_ready); } - + if(!strcmp(plist->name, "sys_clk")) litex_sim_module_pads_get(pads, "sys_clk", (void**) &s->sys_clk); @@ -154,8 +154,6 @@ static int serial2console_tick(void *sess) { *s->tx_ready = 1; if(*s->tx_valid) { - if(*s->tx == '\n') - printf("\r"); printf("%c", *s->tx); fflush(stdout); } diff --git a/litex/soc/software/libbase/console.c b/litex/soc/software/libbase/console.c index 45fbc574e..7861a1d98 100644 --- a/litex/soc/software/libbase/console.c +++ b/litex/soc/software/libbase/console.c @@ -25,6 +25,8 @@ int putchar(int c) uart_write(c); if(write_hook != NULL) write_hook(c); + if (c == '\n') + putchar('\r'); return c; } diff --git a/litex/tools/litex_term.py b/litex/tools/litex_term.py index cee989cbb..d4607b63a 100755 --- a/litex/tools/litex_term.py +++ b/litex/tools/litex_term.py @@ -152,8 +152,6 @@ class LiteXTerm: signal.signal(signal.SIGINT, self.sigint) self.sigint_time_last = 0 - self.lf_insert = True - def open(self, port, baudrate): if hasattr(self, "port"): return @@ -261,21 +259,10 @@ class LiteXTerm: def reader(self): try: - c_last = 0 while self.reader_alive: c = self.port.read() - if c_last == b"\r": - if c == b"\n": - self.lf_insert = False - else: - self.lf_insert = True - c_last = c - if self.lf_insert and c == b"\r": - sys.stdout.buffer.write(b"\n") - else: - sys.stdout.buffer.write(c) + sys.stdout.buffer.write(c) sys.stdout.flush() - if len(self.mem_regions): if self.serial_boot and self.detect_prompt(c): self.answer_prompt()