From: Stafford Horne Date: Tue, 9 Oct 2018 02:16:05 +0000 (+0900) Subject: sim: serial: Send '\r\n' instead of just '\n' X-Git-Tag: 24jan2021_ls180~1566^2 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=8877dba7e96115ffbc406461919fca0d5aee8b0b;p=litex.git sim: serial: Send '\r\n' instead of just '\n' This fixes an issue when running with the HDMI2USB firmware which expects \r\n to come from the UART. Since the verilator adapter is just sending \n commands cannot be executed. Also, one minor whitespace cleanup. (could remove if needed) --- diff --git a/litex/build/sim/core/modules/serial2console/serial2console.c b/litex/build/sim/core/modules/serial2console/serial2console.c index 20cb12d2..12704c42 100644 --- a/litex/build/sim/core/modules/serial2console/serial2console.c +++ b/litex/build/sim/core/modules/serial2console/serial2console.c @@ -76,6 +76,11 @@ void read_handler(int fd, short event, void *arg) int i; read_len = read(fd, buffer, 1024); for(i = 0; i < read_len; i++) { + /* If we are reading a newline make sure its \r\n. */ + if (buffer[i] == '\n') { + s->databuf[(s->data_start + s->datalen ) % 2048] = '\r'; + s->datalen++; + } s->databuf[(s->data_start + s->datalen ) % 2048] = buffer[i]; s->datalen++; } @@ -157,7 +162,7 @@ static int serial2console_tick(void *sess) { *s->rx_valid = 0; if(s->datalen) { - *s->rx=s->databuf[s->data_start]; + *s->rx = s->databuf[s->data_start]; s->data_start = (s->data_start + 1) % 2048; s->datalen--; *s->rx_valid = 1;