Author Topic: How do I disable or redirect the console (UART0) output to a file?  (Read 1232 times)

0 Members and 1 Guest are viewing this topic.

Offline betocoolTopic starter

  • Regular Contributor
  • *
  • Posts: 96
  • Country: au
How do I disable or redirect the console (UART0) output to a file?
« on: September 02, 2022, 12:06:22 pm »
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
 

Offline magic

  • Super Contributor
  • ***
  • Posts: 6760
  • Country: pl
Re: How do I disable or redirect the console (UART0) output to a file?
« Reply #1 on: September 18, 2022, 10:20:27 am »
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.
« Last Edit: September 18, 2022, 10:26:31 am by magic »
 

Online eutectique

  • Frequent Contributor
  • **
  • Posts: 389
  • Country: be
Re: How do I disable or redirect the console (UART0) output to a file?
« Reply #2 on: September 18, 2022, 09:51:37 pm »
Do you have /var/log/syslog and /var/log/dmesg files?
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf