Display Linux boot messages on tty1 instead of ttyS1 - linux

I'm working on an embedded Linux system with a display panel. The system is setup to output boot messages through the serial port on the system /dev/ttyS1. I'm trying to get these messages to show up on the display,tty1, and I'm looking for suggestions on how I go about doing this.
I tried changing the kernel command line from console=ttyS1 to console=tty1; this has no effect. Even with the change above boot messages are sent only to the serial port. I verified that the change to the kernel command line did take effect by querying cat /proc/cmdline
The last step of the boot process spawns getty to tty1 and the login screen does appear on the panel. The panel itself is initialized much earlier in the boot sequence.
EDIT: #artless noise pointed out that sending the console to the virtual terminal requires a change in the kernel config. And indeed it does. Follow the steps below to enable console output on virtual terminal
make menuconfig
and from the displayed GUI select the following
Device Drivers -> Character devices -> Support for console in virtual terminal
When invoking make you may need to provide additional options (ARCH, CROSS_COMPILE etc.) depending on the target you're building for.

Command line options can be provided either by the bootloader (e.g., u-boot bootargs) or hardcoded when configuring the kernel.
I know that on some older versions of the Linxu kernel, hard-coded options erroneously overwrote bootloader options.
So, have a look at the .config file and see if the wrong console has been set there.

Related

How do I turn off the console on an embedded system built with Yocto?

I am running Linux kernel 4.14.149 built by Yocto Zeus, and I am running 2019.07 U-boot. At the recommendation of our security team, I am trying to get rid of the Linux console. I am not worried about debugging (once I get this to work anyways); we have other ways of getting the system logs out of the machine, and this will not be done on software development boards. That mechanism is already in place and is tested working. We have an i.MX6 as our core (this is an embedded system), and we have dedicated UART5 to our console on dev boards.
I have tried a few different methods to do this. The first was to disable the framebuffer console kernel config (CONFIG_FRAMEBUFFER_CONSOLE). The primary issue with this approach is that it disabled the splash screen. We have a splash screen that is put up in U-boot (and it is displayed again by Linux), but Linux appears to reset the framebuffer or something when it is booting, resulting in the display flickering and being blank for a bit before our applications start, which was unacceptable (and is the reason we put the splash screen up in both U-boot and Linux).
I also tried just setting "console=" on our command line. This is close to what we want to achieve in that the console doesn't come out the UART anymore, but we see it start to appear on the display on top of the splash screen. I haven't found any way to fix that (I can upload a screenshot if desired).
Just eliminating the console parameter entirely didn't appear to work, it still came out the UART. This is to be expected based on the serial console documentation which says it just uses the first available device.
I have tried commenting out the console initialization in main.c in the Linux source, which exploded rather quickly.
I tried setting to be a netconsole (see Where do you send the kernel console on an embedded system?) but the splash screen still got overwritten, same as the setting it nothing case.
The last thing I have tried was just setting it to a bogus device ("console=ttymxc9" on the Linux command line). While this appears to work (there is no data on the display or the UART) it appears to stall (crash?) partway through bootup and without being able to get the logs (it stalls before our application service runs). I say stall because we have Linux configured for a heartbeat and we do still get proper LED heartbeat behavior. None of the systemd services I added to our build however appear to run (I added one to save the journalctl log file after boot to a file on an external SD card for debugging purposes until I get this working)
At this point, I have run out of ideas on how to get rid of the console while keeping the splash screen intact. What is the proper way to disable the Linux console?
For kernel versions 5.11 and newer:
In the submenu "Character devices" under "Device Drivers" from make menuconfig, there is an option called "Null TTY driver" (CONFIG_NULL_TTY) that you can enable and add console=ttynull to the kernel boot cmdline so that all console output will be simply discarded.
You can also disable CONFIG_VT and CONFIG_UNIX98_PTYS, since you don't need to interact with your program via console at all.
For older kernels (like my 4.14):
You can add this support with the diffs at: https://lore.kernel.org/lkml/20190403131213.GA4246#kroah.com/T/ and then follow the instructions above.
More recent versions of yocto use systemd and a service called getty.target to load the serial port console. Disable by running the following command (once):
systemctl mask getty.target
This answer may not fully fit your question, however, it could serve as a research source for other users, just like me. I use the commands below to temporarily turn the console (ttyS0) on and off.
systemctl stop serial-getty#ttyS0.service
and
systemctl start serial-getty#ttyS0.service

Run script on Linux startup as late as possible

I created a simple module that controls wheter a USB supplies power for a device when in host mode or not. When loaded, this module cuts off the power to any device connected until told otherwise.
It is also desired that when booted, the system comes with both my module loaded, and the USB supply cut off. To this end, so far I've tried:
Setting my module as a kernel built-in: had no effect, modules that are loaded later overrun my configuration;
Creating an init.d script: Created the script, and set it up to run on rc5. No luck as well, I run into multiple problems with USB devices (such as usb 2-1: device descriptor read/64, error -110);
I'm running Kernel 3.12 on a custom board, and I've tested that the module works as intended if I load it manually (via modprobe) into the system, after logging in.
Ideally, I want to keep these configurations to be done during boot, without any need of logins and such.
So, my question is: how can I postpone the module loading until the last possible minute, assuring that any other configuration is already finished? Also, is udev a good solution for this sort of thing? From what I read, I had the impression it wouldn't be the best fit...
Regards,
Guilherme
So, I've figured out how to get rid of the errors when using an init.d script. All that is needed is to unbind the devices before loading the module. the following line before the modprobe did the trick for me:
echo "2-1" > /sys/bus/usb/drivers/usb/unbind
Regards,
Guilherme

Where is g_multi configured in BeagleBone Black?

With the default Debian installation in a BeableBone Black you can access it via USB as different devices: mass storage device, virtual ethernet and virtual serial uart. This is accomplished with the g_multi module. You can review its configuration via files in /sys/module/g_multi/parameters/ .
I am trying to use it only as a mass storage device but with other disk/block device, not the second partition in the boot block device. I have checked that it is always the same partition not matter if it is /dev/mmcblk1p2 (when I have a microSD inserted on boot) or /dev/mmcblk0p2 (without it). I have tried removing g_multi after boot and modprobing g_multi or g_mass_storage with my own configuration, and it works OK.
But I don't want the default configuration to load on startup, so I need g_multi to not load at all, or to load with my own parameters.
I search for its configuration in every place I could think of: configuration for modules in /etc, configuration for systemd, parameters of uboot for kernel, decompiling dtbs, and even with a compiled kernel I searched for the manufacturer that the startup g_multi shows in its /sys/module/g_multi/parameters/iManufacturer in all the files.
I am not able to find anything. Could someone help me?
Thank you very much in advance.
I have finally found it. It is a bit hidden (in a Debian perspective).
It is configured in the /opt/scripts/boot/am335x_evm.sh script.
I had forgotten all those scripts and utilities for the Beagle platforms. I had to follow the major part of the boot proccess.

Linux - Get to Shell before other driver boot up

How can I edit my startup scripts in linux so that I get to the login screen as soon as possible? I want all the other accessories (such as Bluetooth, Wifi, Ethernet) drivers to run ONCE I have gotten to the login screen and can now log into shell.
The only thing I can think of is to change the rmnologin order so that it runs before anything else. Is that a good idea?
Use a dependency based init tool like systemd or startpar, then if you still don't have prompt fast enugh dependency reasearch (or trial and error) would be in order. Also set your bios to fast boot. You can also boot into single user mode then change run level later if you want.

Debugging the Linux Kernel on Boot

I have compiled the Linux kernel with configuration options for ROOT_NFS. My problem now is the screen prints to fast for me the see the error and I cannot find any documentation on the best approach to solve this problem. I am performing this in VirtualBox.
There is Documentation/serial-console.txt you could look into. Serial console has traditionally been used for debugging linux boot problems, where you then can save all of the screen capture on a different pc. This should be possible for a virtualbox use case as well, although I do not know how difficult it will be to configure serial access.
The dmesg command prints the kernel's circular log buffer. Your messages may be in there.

Resources