How to disable a Virtual Terminal in Yocto Linux - linux

Would anyone know how to disable the virtual terminals in linux? I am using Yocto, Morty version on an i.MX6 processor. Even though our base distribution is Yocto, unfortunately we have diverged from building it with recipes, so this is more of a straight linux question than Yocto…
To give some detail as to my problem: It is for an embedded device that has an HDMI port - when I attach a terminal to the HDMI port it shows the Linux Penguin logo, a getty service and blanks out after 600 seconds. I just want to use the hdmi port as an output with nothing displayed on the output and I want it to stay on all the time.
I have found that the hdmi port maps to /dev/tty1 – when I type: echo “asdfasdf” > /dev/tty1 I see the characters output to the monitor.
Here are a few things I have tried to no avail – a lot of these are not needed if I can figure out how to disable it as a virtual terminal…
• I figured out how to disable the getty service but a cursor still blinks. I don’t even want a cursor to show
• I have tried to disable the display of the penguins by disabling the LOGO in the kernel config parameters - I commented anything with LOGO out:
CONFIG_LOGO=y
CONFIG_LOGO_LINUX_MONO=y
CONFIG_LOGO_LINUX_VGA16=y
CONFIG_LOGO_LINUX_CLUT224=y
To no avail. The logo still shows : .
• The fact that it blanks after 600 seconds is console blanking – I can see it set to 600 in the file: /sys/module/kernel/parameters/consoleblank. When I issue the command: echo -e '\033[9;0]'>/dev/tty1
It sets the console blanking to 0 and wakes the terminal. Being able to wake the console up is limited success but I would like to disable the virtual terminal altogether…
• I tried commenting out any virtual terminal defines in the config file to no avail:
CONFIG_VT=y
CONFIG_VT_CONSOLE=y
CONFIG_VT_CONSOLE_SLEEP=y
CONFIG_HW_CONSOLE=y
CONFIG_VT_HW_CONSOLE_BINDING=y
Everything I have read suggests that /dev/tty1 is a virtual terminal or console. From what I read about the VT option, disabling the CONFIG_VT should do it:
VT — Virtual terminal Say yes here to get support for terminal devices
with display and keyboard devices. These are called "virtual" because
you can run several virtual terminals (also called virtual consoles)
on one physical terminal. You need at least one virtual terminal
device in order to make use of your keyboard and monitor. Therefore,
only people configuring an embedded system would want to say no here
in order to save some memory; the only way to log into such a system
is then via a serial or network connection. Virtual terminals are
useful because, for example, one virtual terminal can display system
messages and warnings, another one can be used for a text-mode user
session, and a third could run an X session, all in parallel.
Switching between virtual terminals is done with certain key
combinations, usually Alt-function key. If you are unsure, say yes, or
else you won't be able to do much with your Linux system.
But for some reason it doesn’t do anything!
• I found this thread; https://askubuntu.com/questions/357039/how-do-i-disable-virtual-consoles-tty1-6 among others, but none are much help since my distribution does not have any of the directories in the solutions offered in this thread or any others I have found. For instance I do not have a /etc/events.d nor do I have a /etc/default/console-setup file nor do I have a /etc/init directory… I imagine the reason for this is that my distribution uses systemd and the solutions are SysV based init maybe?
Disabling the logo or console blanking would not be necessary if I could just figure out how to disable that port as a terminal…
So does anyone have pointers or things I could try? I am relatively new (returning after 10 years - I worked with DNX 10 years ago v2.6 and it seems everything I knew about init is fairly obsolete lol) to linux so I am sure I am missing a lot…
Thanks,
- Chuck

I think I found the answer to my question. This is actually a frame buffer console documented here: Documentation/fb/fbcon.txt. From the documentation:
The framebuffer console (fbcon), as its name implies, is a text
console running on top of the framebuffer device. It has the
functionality of any standard text console driver, such as the VGA
console, with the added features that can be attributed to the
graphical nature of the framebuffer.
Commenting out the line
CONFIG_FRAMEBUFFER_CONSOLE=y
In the configuration file located in /arch/arm/configs will disable it.
Also this part of the documentation shows you how to disable it at runtime:
So, how do we unbind fbcon from the console? Part of the answer is in
Documentation/console/console.txt. To summarize:
Echo a value to the bind file that represents the framebuffer console
driver. So assuming vtcon1 represents fbcon, then:
echo 1 > sys/class/vtconsole/vtcon1/bind - attach framebuffer console
to
console layer echo 0 > sys/class/vtconsole/vtcon1/bind - detach framebuffer console from
console layer
When I issue the echo 0 command, the cursor stops blinking and starts blinking again when I issue the echo 1 command.
I think there is another way of doing it as well by modifying the Yocto build environment by putting the USE_VT="0" in the OpenEmbedded machine config file. The "USE_VT" variable is referenced by the sysvinit-inittab recipe. This answer was given to me from the Yocto Linux mailing list - but I have not tested it since we have diverged from Yocto...

Related

Disable console output but show kernel boot logo

I'm currently working with AOSP Android 10 with Linux kernel v5.4.70 on a custom device and I'm trying to reduce the boot time of the device. Disabling the kernel console output with "quiet" command line argument reduces the boot time by almost 4 seconds but there is a side effect where it also hides my custom kernel boot logo so the screen is initially blank for 15 seconds until the Android boot animation starts. This option is really nice because I can still read the kernel output using dmesg after the boot but I need to show the logo. Obviously disabling printk() in kernel config would work but I want to keep the output after boot + kernel logo.
Things I've tried so far:
Using "loglevel=3" command line argument - also hides boot logo
Setting loglevel to 3 in android init.rc script on early-init stage - doesn't give such a big time save and messages are still printed for the first ~6 seconds
Using "quiet splash" command line arguments - splash seems to do nothing
Setting console and androidboot.console to ttynull - works but then I don't get any output from kernel at all
Using "quiet" and directly modifying fbcon.c file in drivers/video/fbdev/core and removed the following check - seems like "quiet" doesn't do anything in this case, boot logo is displayed and console shows output messages from the kernel
if (logo_shown < 0 && console_loglevel <= CONSOLE_LOGLEVEL_QUIET)
logo_shown = FBCON_LOGO_DONTSHOW;
Is there any way I can achieve the desired result or is console logging directly tied to boot logo and there is no way to avoid it?

Linux - Open terminal for input/output

I'm coding a Rust app and since it's fairly small and there don't appear to be any stable UI frameworks, I've made it run in the console using println! and whatnot for input/output. However since this program is intended to be used by people directly after downloading from the internet (due to its use case), they're likely to just double click on it instead of navigating to their downloads directory in a terminal and running it from there.
This is a problem because on Linux, it runs in the background waiting for input and looks like it's not working. On Windows, Rust programs do open in CMD by default. (and in fact many of the search results for my question were about disabling this behavior - the exact opposite of what I want!).
So is it possible to somehow make my application open in the system's default terminal? My preferred way would be to somehow embed in the executable to open in terminal (similar to the -mconsole compiler flag on MinGW). Otherwise would it be possible to detect it's in the background and fork it into a terminal? If that's not possible then is it at least possible to detect that the app is not running in a terminal and throw up a message box telling the user to run in a terminal?
My app is cross-platform but I'm OK with writing code conditionally compiled on one OS.
One typical way would be to distribute a program.sh along with your executable. If .sh extension is bound to opening a terminal in their window manager of choice, it would open automatically. If not - it is enough of a hint for running it from the shell.
Without this file you could:
Detect if the program is already running inside a terminal can be done with isatty(). There's a crate for it.
If not, spawn the terminal app process (see process::Command) and relaunch the program with it by passing its path to the terminal command line options. As #Caesar mentioned there's a bunch of popular terminals that you might want to check for presence on Linux. If nothing is found, xterm could sometimes be a fallback.

NixOS: boot to terminal

I'm using NixOS with XMonad as a window manager, which was enabled via the configurations.nix. This works fine.
After booting, the initial login is done via the NixOS login gui.
On a Debian system for instance systemd can be configured to boot only to the terminal and not directly to a desktop environment. One can setup an .xinit file then to start the chosen window manager or desktop environment without using any display manager (like lightdm, kdm...). It's started then by calling startx.
How would described effect be done in Nix? I guess there's an
declarative way to do so.
Another question, partly related to this, is: After changing
xserver settings in the configurations.nix (e.g. in
services.xserver.synaptics) and rebuilding via nixos-rebuild
switch/test, what do I have to do in order to take them in effect?
Those are 2 separate questions, thus I believe you'd be much better splitting them into 2 StackOverflow questions (it's much harder now to answer e.g. only one of them). That said:
AFAIK, people building the NixOS are not aware of a way to do this in systemd. If you know of such method, I believe there might be interested to learn about it!
I suppose you want:
$ systemctl start display-manager.service # CAUTION: see NOTE below!!!
NOTE: this will kill any open X session! (I guess that this might be the reason why it's not done automatically on nixos-rebuild switch...)
By the way, you may have noticed that after nixos-rebuild switch, a message is shown, something like: "display-manager.service is not restarted". That's what led me to find the answer to this question when I needed it myself.
One way to do it is to enable startx, which will be treated as a display manager:
services.xserver.displayManager.startx.enable = true;
Another way to accomplish this is to bypass the display manager by logging in automatically from the TTY login prompt. NixOS default display manager being lightdm, you do that by adding the following lines to your configuration:
lightdm = {
enable = true;
autoLogin.enable = true;
autoLogin.user = "username";
};

ZOC Terminal:text has been cut halfway down the page

I work with ZOC terminal installed at windows 7 in order to communicate with device that has Linux operating system zoc picture.
The communication via terminal works great but recently the text has been cut halfway down the page.
attached picture .
The picture shows 24 lines. You can get this behavior if your terminal description sets scrolling margins to 24 lines — as some might do, when initializing the terminal if the application assumes that the screen has 24 lines.
Since ZOC could be connecting via a serial port, that may not allow negotiations about window size (NAWS). You might then see that stty -a shows 24 lines in its output. ZOC is said to emulate a VT100; you can usually adjust its notion of screensize either directory (using stty) or using the resize program (which calls the same system functions as stty as a side-effect).
Alt+y solved the issue I had..

Handling input device plug/unplug while reading from it

I have a bluetooth remote that is paired with my linux box, when active, this remote is visible at /dev/input/event13.
I have a small C program that open this device and read directly from it, which works fine.
Now, my problem is that this remote goes to sleep after a few minutes of inactivity and /dev/input/event13 disappears. It reappears as soon as I press a key on my remote.
I put the output of udevadm here: https://gist.github.com/9fff2f0d7edef1050060.
I use the following code (small ruby ext I wrote), to read from the device: https://gist.github.com/b403d538eb6a8627e2bd.
I thought of writing an udev rule that would start my program when my remote is added and stop it when it is removed. I read the udev documentation, but I couldn't figure it out how to do it. I'm open for suggestion.
After some digging and a lot of frustration I did the following:
I put into /etc/udev/rules.d/99-rmote.rules
KERNEL=="event*", SUBSYSTEM=="input", ACTION=="add|remove", ATTRS{name}=="TiVo Keyboard Remote", RUN+="/home/kuon/handleConnect.rb"
And in handleConnect.rb I check the ACTION environment variable and I start/stop my daemon accordingly. Quite simple in the end and it works well.

Resources