Products > Embedded Computing
How do I disable or redirect the console (UART0) output to a file?
(1/1)
betocool:
Hello all,
I thought I'd fine clear information online how to do it, but I admit all this u-boot and linux kernel stuff has me confused in some things. Some other, not so much... it's a learning process.
I built a Cyclone V Linux image with Uboot using Buildroot and was able to customize a bunch of things to my liking. Most of it going very well.
Now, after start up, I'd like to either:
- Disable the Console output
- Move to Console output to ttyUSB0 (which in some cases may or may not be connected...)
- Redirect the Console or dmesg outputs to a file, so I can have a look at them after a reboot.
Thing is I want to use UART0 and UART1 for my own purposes and the additional ports (ttyUSB for example) in case I need the console. I can always log into the unit via SSH, so I don't necessarily need the console output.
Is it possible to do any of the three above? I guess. Where do I find information about /dev/console, which at the moment is the same as /dev/ttyS0 ?
Any pointers are very welcome.
Cheers,
Alberto
magic:
A bit late to the party ::)
Apparently there is an IOCTL for changing the console device at run time, or if you want it changed right at the beginning of the boot process set the console= kernel parameter. For saving kernel log to a file, simply run dmesg >file.txt at the beginning of your init scripts.
https://unix.stackexchange.com/questions/397700/how-to-change-the-console-tty-after-booting
https://www.kernel.org/doc/html/v5.0/admin-guide/kernel-parameters.html
The dmesg utility can disable printing kernel messages to the console, but any program can open /dev/console and print something there. On some systems all software may run with its stdout and stderr pointed to /dev/console.
edit
I read the man page and I'm not sure if the IOCTL changes the console device or just redicects kernel messages elsewhere. Maybe the boot parameter is the only way.
eutectique:
Do you have /var/log/syslog and /var/log/dmesg files?
Navigation
[0] Message Index
Go to full version