Trying to open console on LCD using fbcon and USB keyboard - console

(Wow it took me a while to post this question because of the formatting problem coming from special characters..)
I'm trying to bring up virtual terminal on our embedded system's LCD usnig USB keyboard which is also connected to the system. I have UART connection to my PC so I've been using UART for console till now but I want to switch to framebuffer console on LCD during the boot at some point..
The USB host controller seems to work fine because I've seen USB memory is attached, read and written ok. And when I connect a keyboard and print the events at keyboard_event function, it prints events that seem normal and corresponding to my action(type of key, press or release..)
I have a feeling that it's a configuration problem. In init/main.c, there is
run_init_process(ramdisk_execute_command);
(In my case, ramdisk_execute_command = "/sbin/init")
And this immediately calls
kernel_execve(init_filename, argv_init, envp_init);
// above, init_filename and argv_init are "/sbin/init" same.
I expect busybox to run after this.. (ramdisk had been installed before by a bootloader-like part) but I cannot see any prints on the LCD after this point. But I can see printks on the LCD until just before calling kernel_execve above. I'm using linux 3.3.
I understand I have to open a frame buffer console on LCD and connect it to a tty but I don't know how. Below are printed the current releavant settings.
(In serial UART connection case, linux boots ok up to the final busybox shell prompt printing things in busybox initialization after kernel_execve call. and #cat /proc/fb0 returns 0 for your info. Only LCD/framebuffer console mode stops after kernel_execve.)
#### arch/sparc/boot/ourprocessor/prom_stage.c : #####
// "console=ttyS,mmio,0xff003000,115200n8 " <== serial port case
"console=tty " <= frame buffer console case (below line too)
"fbcon=font:SUN8x16,map:0000 " <= Is this boot argment correct?..
#### sbin/init: #####
#!/bin/busybox sh
export LD_LIBRARY_PATH=/lib
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/mnt/nand/lib
exec /bin/busybox init
### rcS #####
mknod /dev/tty0 c 4 0 <== Do I need to explicitly make tty0 and tty1 like this?
mknod /dev/tty1 c 4 1
mknod /dev/tty2 c 4 2
mknod /dev/tty3 c 4 3
mknod /dev/tty4 c 4 4
### .config #####
CONFIG_FRAMEBUFFER_CONSOLE=y <= LCD/framebuffer console case. Otherwise none.
CONFIG_FONT_SUN8x16=y
CONFIG_LOGO=y
By the way, I'm not using /etc/inittab.(so use default init). The busybox init/init.c code says if there isn't the inittab file and console is not the serial port, it runs
tty2::askfirst:/bin/sh
tty3::askfirst:/bin/sh
tty4::askfirst:/bin/sh
(starting shell on tty 2, 3 and 4) then How do make tty2's shell appear on the LCD/framebuffer/framebuffer console? It's confusing and books are not so kind..
Any hint would be deeply appreciated.

This question was solved months ago and I forgot to answer to this question myself.
Adding CONFIG_FRAMEBUFFEr and CONFIG_FBCONSOLE and setting console=ttyS,.. was all that is necessary. In my case, I had another bug in DMA that was causing the frambe buffer console's text not appear on the LCD. So I can use 3 virtual consoles on the LCD (switch using Alt-F2, Alt-F3, .. ) by default. Long storyg short, console is a console(on serial port), and we have 3 (by default busybox setting) virtual console on the LCD.

Related

Qemu - Redirect host input to guest UART for bare metal kernel

I'm writing a kernel from scratch in Rust for 64-bit ARM devices. For testing purpose, I use Qemu virt machine.
Currently, I'm able to write characters from guest to host console through UART. Now I would like to do the opposite, i.e. send characters from host console to guest UART port. Is there a way to do this? Should I add some arguments to Qemu?
I run Qemu virt machine with the following arguments:
qemu-system-aarch64 -M virt -cpu cortex-a57 -nographic -serial pty -S -kernel target/aarch64-unknown-none/debug/cortex-a57
It gives me a new pty that I can attach with screen /dev/pts/mypty. Then I run the program tapping c in Qemu console.
I would like to use the same pty (or a new one?) to write data to the guest.
QEMU always redirects both input and output for a guest UART to the same place; this is true of all of '-serial stdio', '-nographic' (which does an implicit '-serial mon:stdio') and '-serial pty'. So you don't need to do anything extra. If UART input is not working then the problem seems likely to be a bug in your guest code.
Just read the same TTY as Qemu redirects all input to the same place.

How to open a tty device in noncanonical mode on Linux using .NET Core

I'm using .NET Core on an embedded Linux platform with good success so far. I just ran into a problem with trying to open a tty device in raw (noncanonical mode) though. If I was using regular C or C++ I would call cfmakeraw() after opening the device, but how do I do that from a .NET Core app?
The device I need to work with is a CDC ACM function driver for the USB client connector, i.e. it's a virtual COM port. It appears in my system as /dev/ttyGS0. I can open the device and then read from it and write to it using this code:
FileStream vcom = new FileStream("/dev/ttyGS0", FileMode.Open);
Because the tty device opens in canonical mode by default I don't receive any characters until the user sends the carriage return character at the end of the line of text. I need to receive each character as it is sent, rather than waiting untill the carriage return is sent, i.e. I need to use raw mode for the tty device.
The code below does not work because .NET Core does not realize that this device is a virtual serial port, so it throws an exception when I try to open it this way. When I open the real UART devices using SerialPort then they do behave in raw mode as expected.
SerialPort serialPort = new SerialPort("/dev/ttyGS0);
Since you have a terminal device, you could try to alter its termios configuration prior to actually using it.
Try issuing the shell command stty -F /dev/ttyGS0 raw before you run your program.
The raw setting will make the following termios changes (according to the stty man page) for noncanonical mode:
-ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr -icrnl -ixon -ixany -ixoff -imaxbel
-opost
-icanon -isig -xcase -iuclc
min 1 time 0
Note that no c_cflag attributes (e.g. baudrate, parity, character size) nor echo attributes (as you already know) are changed by the raw setting.
For comparison the libc cfmakeraw() routine that you mention makes the following termios settings:
t->c_iflag &= ~(IGNBRK|BRKINT|PARMRK|ISTRIP|INLCR|IGNCR|ICRNL|IXON);
t->c_oflag &= ~OPOST;
t->c_lflag &= ~(ECHO|ECHONL|ICANON|ISIG|IEXTEN);
t->c_cflag &= ~(CSIZE|PARENB);
t->c_cflag |= CS8;
t->c_cc[VMIN] = 1; /* read returns when one char is available. */
t->c_cc[VTIME] = 0;
You can use stty -F /dev/ttyGS0 sane to restore the terminal to a default termios configuration.

What does pl2303 "error sending break" mean?

I have a problem with my pl2303 converter. I'm using two of them like this:
LAPTOP <-USB-SERIAL-> <-SERIAL-SERIAL-> <-SERIAL-USB-> RASPBERRYPI
In other words, I'm connecting Raspberry Pi with my laptop using two usb-to-serial converters and having null modem in the middle.
I can communicate through minicom and "visually" it looks fine (all information is sent properly), but when I look into the logs it produces following dmesg output:
[ 343.390610] pl2303 ttyUSB1: pl2303_get_line_request - failed: -32
[ 343.685367] pl2303 ttyUSB1: error sending break = -32
I could live with that as long as everything works fine... but it doesn't. For example, I can't connect with RPi via ser2net. The "other side" simply doesn't get the messages. I suspect that this error is the cause of this problem. I was googling around, but I didn't find any solution. Could somebody help me with it?
Also - when I try to connect via ser2net, one thing breaks. Before that I can to stuff like
cat -v < /dev/ttyUSB0
and
echo "blablabla" > /dev/ttyUSB0
with success. After I try to connect via ser2net, it stops working and only minicom communication is fine.

Weird delay when using "tail -f" command

To monitor a log file I have to connect to an ssh connection and redirect the output of the log file(let's call it RemoteLog.txt) out to a local machine so it can be read by a java program and put on a GUI.
Right now I have the output redirected out of the ssh connection and onto the local machine with the command:
ssh remote#ip.address tail logs/RemoteLog.txt -f > ~/Log/LocalLog.txt
and everything works fine technically with one exception: for some reason LocalLog.txt only gets updated with the changes to RemoteLog.txt every 35 seconds to the millisecond.
It doesn't matter the number of changes to RemoteLog, the number of lines specified with the tail command, or using the >> operator vs the > operator; there is always a 35 second delay between updates of LocalLog.txt while RemoteLog is constantly updating.
Does anyone have any clue why this might be?

how to redirect the output of serial console (e.g. /dev/ttyS0) to a buffer or file

Is it possible to pipe serial console output to a file or a buffer or some virtual or pseudo device (in /dev)?
The Kernel command line has in startup at this point "console=null,115200".
(Normally it has "console=ttyS0,115200" - my requirement is: if "console=null,115200", should the output go to some other place than ttyS0, e.g. a virtual or pseudo device or to a file/buffer)
Maybe somebody know if there is good solution available?
Thanks a lot in advance!
There are two ways that I am aware of :-
First way :-
get ttylog from sourceforge :-
http://sourceforge.net/projects/ttylog/files/latest/download
Fire the below command:-
nohup ttylog -b 115200 -d /dev/ttyS0 > log.txt
this will then show you the PID of the process that is running, you now need to disown that PID so it doesn't get killed when you log out. Note that 115200 is the serial port speed/baud rate you configured grub for on the box you are monitoring.
Second way :-
Setup a serial console from system under test to some other linux/windows box. In case of linux install minicom and set minicom to listen on the serial port define in grub of system under test. Save that as dfl. You are good to go for more info :-
https://www.kernel.org/doc/Documentation/serial-console.txt

Resources