software/bios: switch to standard CRLF
authorFlorent Kermarrec <florent@enjoy-digital.fr>
Tue, 27 Aug 2019 07:45:44 +0000 (09:45 +0200)
committerFlorent Kermarrec <florent@enjoy-digital.fr>
Tue, 27 Aug 2019 07:45:44 +0000 (09:45 +0200)
Avoid setting terminal to "implicit CR in every LF" mode.

litex/build/sim/core/modules/serial2console/serial2console.c
litex/soc/software/libbase/console.c
litex/tools/litex_term.py

index 12704c42353073394de0574aee4cc6642cd37250..c32b568f7a22c884b8cf7d400e1c2b73a5e6d61c 100644 (file)
@@ -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);
   }
index 45fbc574ea543b548b71494a94a660eb7f95085f..7861a1d9862f97cb8aebc769ede331f0e4565302 100644 (file)
@@ -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;
 }
 
index cee989cbb5a6c9e8c38ace85f389a2b7215ae7e6..d4607b63aeb8969d11e8d13b020fe0d54402216f 100755 (executable)
@@ -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()