3

I'm experimenting with upstream kernel and now I try to get serial console working. I'm getting only garbage symbols when I try to communicate:

enter image description here

I think it is important to notice that I only get garbage when I send something or when RPi send something back, not constantly.

It is also not a baud rate problem because same baud rate is valid when I use default RPi kernel. Therefore it is also not a cable problem, because serial console works well using default kernel or Raspbian OS.

I found out that different parameters like core_freq or enable_uart could help, so I tried them with no success.

Here is my config.txt:

# gpu_mem=64
kernel=Image
core_freq=250
enable_uart=1
arm_64bit=1
initramfs initramfs-linux.img followkernel

and cmdline.txt:

root=UUID=[deleted] rw rootwait console=ttyS1,115200 console=tty1  plymouth.enable=0

Kernel version 5.7

Ingo
  • 42,107
  • 20
  • 85
  • 197
aryndin
  • 201
  • 3
  • 6
  • 2
    I can't see a question. This is not the correct place to report a kernel bug if that is what you are doing. – joan Jun 06 '20 at 20:38
  • @joan How can I understand if it is a kernel bug or not? That's why I came here, because I get behavior that I can't explain or understand. – aryndin Jun 06 '20 at 23:20
  • 1
    There could be many reasons for this behaviour. First and most obvious is the incorrect or not matching baudrate. In both ends of the line should be exactly same frequency - if not, it looks like in your screenshot. – tswaehn Jun 07 '20 at 07:58
  • Another thing could be the overlays in RPI. Please note that there are two options for uart. One is attached over usb the other is a direct hardware uart. Enabling both at the same time offers you clash. – tswaehn Jun 07 '20 at 08:01
  • Another thing could be Core frequency of the processor. The uart frequency is derived from the core frequency. So changing the core frequency means incorrect uart frequency and can produce the screenshot as you post. You can fix this by adjusting the prescaler for uart. – tswaehn Jun 07 '20 at 08:03
  • Easiest thing is to use an oscilloscope to measure the actual frequency of the uart. – tswaehn Jun 07 '20 at 08:04
  • 1
    @tswaehn please, refer my comment https://raspberrypi.stackexchange.com/questions/113198/rpi-4-garbage-on-serial-console-uart-using-upstream-kernel#comment194513_113215. Also, how can I "adjust the prescaler for uart?" – aryndin Jun 07 '20 at 10:17
  • I see the same problem with upstream 5.8, but not with raspberry kernel 5.8-rc6. No idea what's the problem yet. – robert.berger Aug 06 '20 at 22:26
  • I had similar issue when tried to power RPI through USB to UART TTL Cable. Then I added standard 5V power adapter and it solved my problem. I probably had this problem because I bought cheep cable. However, be warned that this is extremely dangerous and could fry your RPI because you are adding 2 different power sources to it. – Artūrs Laizāns Nov 22 '21 at 22:45

3 Answers3

3

Only for the completeness: first check your connection as shown at What is the correct way to connect serial console on RPi4 Model B?. But I believe you are right.

As I see you are experimenting with the 64 bit version of the Raspberry Pi OS in addition with an init ramdisk. First you should verify that your serial console is working as expected. Download the Raspberry Pi OS beta test version and configure it as shown at Run 64-bit Raspberry Pi OS beta test version. In addition to that settings add the option enable_uart=1 to /boot/config.txt before starting it in a RasPi that is able to run 64 bit.

You don't tell us what serial terminal program you are using. I have made very good experience with tio, a tiny, but very stable Terminal IO program, just exactly made for a serial console. I suggest to also use it.

I can confirm that this works on my Raspberry Pi 4B. If it also works on your RasPi then you can be sure that your custom kernel or your initramfs does not work with the serial console.

Ingo
  • 42,107
  • 20
  • 85
  • 197
  • 1
    I have made very good experience with pico, which I prefer to use. – aryndin Jun 07 '20 at 10:15
  • "It is not a baud rate problem because same baud rate is valid when I use default RPi (Raspbian OS) kernel." -- so serial console connected and works as expected. Also it is not a cable (connection) problem, because serial console works well using default kernel or Raspbian OS. Also, look at my config.txt, where I set core_freq=250 and enable_uart=1 – aryndin Jun 07 '20 at 10:20
  • I'm experimenting with arch linux, not raspibian, but I use kernel provided by raspbian as reference, working kernel. – aryndin Jun 07 '20 at 10:26
  • please note that in raspbian the device is named console=serial0; you did use ttyS1 -- could be ok. just guessing. Please also note about dtoverlay options for uart. as there are 2 uarts channels on RPI. – tswaehn Jun 07 '20 at 10:39
  • regarding overlays: https://www.raspberrypi.org/documentation/configuration/uart.md – tswaehn Jun 07 '20 at 10:41
  • again in raspbian there is no ttyS1 – tswaehn Jun 07 '20 at 10:44
  • @tswaehn I tried both -- ttyS0 and ttyS1. ttyS0 given me nothing, ttyS1 -- garbage. – aryndin Jun 07 '20 at 10:44
2

This is a baud rate problem. You're getting a lot of x and f characters which have ASCII codes of 01111000 and 01100110 - note all bits inside those are repeated twice. The effective baud rate of your Pi should be twice as low as what you think: if your terminal is set to 115200, try setting it to 57600.

Perhaps reading the messages you're receiving (using the right baud rate) will give you a clue about the root cause.

Dmitry Grigoryev
  • 27,928
  • 6
  • 53
  • 144
1

If hardware loopback works, then it could be clock issue. When using the analog tv out via the 3.5 mm jack on the RasPi4, then the clock gets reduced (see the RasPi documentation about overclocking). The UART seems to work properly only with HDMI output.

StefanProb
  • 11
  • 1
  • And what is the solution of the problem? – Ingo Jul 22 '20 at 17:27
  • @Ingo:It seems not possible to use the UART while using the analog tv out. If you want to use an UART, you have to use HDMI out (even if none is connected). – StefanProb Aug 13 '20 at 16:20