raspberrypi / linux

Kernel source tree for Raspberry Pi-provided kernel builds. Issues unrelated to the linux kernel should be posted on the community forum at https://forums.raspberrypi.com/
Other
11.16k stars 5k forks source link

Cannot disable console output on UART pins Rpi0W #6300

Closed domints closed 3 months ago

domints commented 3 months ago

Is this the right place for my bug report? This repository contains the GPU firmware used on the Raspberry Pi. This software is the closed source part of the Raspberry Pi system, it includes booting (including network booting and USB booting), low-level power and clock control, FKMS and legacy HDMI control (not full KMS that is in the linux kernel), hardware legacy codecs (MPEG2, H264 and VC1), encode hardware including the ISP (image sensor pipeline) and camera control, audio output (analogue and HDMI audio).

If you believe that the issue you are seeing is within this area, this is the right place. If not, we have other repositories for the linux kernel at github.com/raspberrypi/linux and Raspberry Pi userland applications at github.com/raspberrypi/userland. If you have problems with the Raspbian distribution packages, report them in the github.com/RPi-Distro/repo. If you simply have a question, then the Raspberry Pi forums are the best place to ask it.

Describe the bug Cannot disable the console output on serial pins (GPIO 14 and 15) on Raspberry Pi Zero W. I tried changing cmdline to remove "console" parameters, setting loglevel etc, used raspi-config to disable login shell, but nothing really fully helped. The only thing that helped was use these steps: https://www.jeffgeerling.com/blog/2023/how-customize-dtb-device-tree-binary-on-raspberry-pi to edit correct dtb file and remove stdout-path entry from chosen section. After removal there is no more logs on UART pins, but UART is still accessible to Python, also bluetooth functions correctly, so I assume it's fine.

To reproduce

Expected behaviour No dmesg output, no boot messages, no e2fsck messages, no login prompt

Actual behaviour Whatever you do, something still outputs to the UART pins

System Raspinfo generated with modded dtb file. https://pastebin.com/cnCTzmVq

Additional context I tried creating overlay file to disable this one line, but I failed. If you think this thing is important to have on by default I'd suggest creating overlay file that would let user disable console output.

pelwell commented 3 months ago

It works for me:

  1. Install 32-bit Lite image. It's probably best to let it boot completely - the first time takes longer and involves reboots because the rootfs gets expanded to fill the card.
  2. Add enable_uart=1 to /boot/firmware/config.txt.
  3. Remove console=serial0,115200 from /boot/firmware/cmdline.txt.
  4. Reboot.

That's it. With a logic analyser on pin 8/GPIO 14 you see the line level go low for 1.2s at the point of reboot, then it stays high until something else - a shell script, Python app, minicom. etc. - writes to /dev serial0 (a.k.a. /dev/ttyS0 with the normal Pi Zero W configuration. The same is true if you also add dtoverlay=miniuart-bt or dtoverlay=disable-bt to config.txt, except that /dev/serial0 is now an alias for /dev/ttyAMA0. Either way, there is no UART output until an app of your choice uses it.

Ah, I see from you've removed console=tty1 - why? The kernel wants somewhere to put it's output, and without the virtual console it seems to force the use of the UART. Try not doing that.

domints commented 3 months ago

Thank you! That indeed was the issue. I removed both, since I didn't want any serial console, I didn't know this console=tty1 is important. As a note, when I removed that stdout-path entry from dtb kernel was looking still perfectly fine, and giving me no output on serial. (Maybe it was also giving no output on HDMI, which I didn't see because I don't need display?).

I think then it's fine to close that issue. One needs to remove serial0 entry, while leaving the tty1 entry on so it probably overrides dtb setting or something.