How to enable the serial port in OSMC

Hi,

Before OSMC, when I was using raspbmc, the serial port was very useful for me, because a lot of processes crash a lot of time in my raspberry and the bash was still available through serial, allowing me to safely restart my raspberry pi.

How can I enable it again in OSMC? What are they used for right now?

I have a raspberry pi model b. the UART pins are supposed to be gpio 14 and 15.

Thanks.

1 Like

Nothing in OSMC currently occupies the serial port. It should be possible to add a console with this command

systemctl enable serial-getty@ttyAMA0

@popcornmix can confirm this, but I believe that a DT overlay is now needed to bring this up as well which will involve editing /boot/config.txt. I have asked @Karnage to add this, but he has not got around to this yet.

Re crashes: is this with normal OSMC use? I’d be interested in fixing these.

Sam

2 Likes

I would have thought SSH would be much easier than setting up a serial console ? You’re unlikely to get a crash that takes down your network connection too…

maybe my raspberry has some hw problem, but lately the network has been crashing a lot.

Hi,

A serial console is better if you want to see all the messages from the bootloader on. You also don’t need to open a new console after a reboot.
Sam is correct that you can open a serial console with systemctl. A better way in my opinion is to copy the serial-getty file from the lib to the etc. You then make the link to this file instead of the common file in the lib. I suggest to edit the copy to remove the --keep-baud and only keep the baud rate you need (115200). Another to thing you might change is the autologin. Add -a osmc. Pay attention here because the login is different for a virtual console, a serial console or SSH. You can see this with .hushlogin, message of the day (motd). Also osmc is different then Jessie in the serial console login. In Jessie you can remove the uname message after login. No idea how to remove it in osmc.

Regards,

Bor.

1 Like

Re: the serial-getty file:

Do you mean file /lib/systemd/system/serial-getty@.service?

It worked with sudo systemctl enable serial-getty@ttyAMA0 when I tried it (as the only change). OSMC was the latest release (‘2015.11-1’) and installed on a Raspberry Pi (model B+, v 1.2 - not Raspberry Pi 2). I used a 3.3 V USB-to-serial adapter on Windows to connect (very similar to Adafruit’s Raspberry Pi Lesson 5. Using a Console Cable”, section “Connect the Lead).

The baud rate happened to be 9600 (and the rest presumed to be N81).

During boot time one, and only one, line was issued at another baud rate, 115200:

Uncompressing Linux… done, booting the kernel.

PuTTY didn’t mind the resulting garbled characters (interpreted at 9600 baud) and logging in using 9600 baud worked fine. Without pressing anything on the keyboard this came up when booting:

OSMC: Open Source Media Center osmc ttyAMA0

osmc login:

Hi Peter,

Yes. Use this as a template for a file in /etc/systemd/system. Name is not important. I used autologin-getty@.service because I used the autologin. In getty.target.wants create a link serial-getty@ttyAMA0.service -> …/autologin-getty@.service. Now your custom file is loaded.
I also remove the keep baudrate option because osmc default startup is quiet and I set the baudrate to 115200. This is what I have:
ExecStart=-/sbin/agetty -a osmc 115200 %I $TERM
In this way you can change between custom and default behaviour by changing the link. In Rasbian Jessie there is an example for the virtual console.

Regards,

Rob.

2 Likes

Hi Peter,

The first line is from the bootloader. In most cases you can ignore that.
If you want more info you should edit the boot arguments. (/boot/cmdline.txt This is mine: root=/dev/mmcblk0p2 rootfstype=ext4 rootwait osmcdev=rbp2 console=ttyAMA0,115200 kgdboc=ttyAMA0,115200)
OSMC is in quiet mode because that’s faster. You can direct the messages to the serial port and you can specify the serial parameters there. Not sure what the default values are.
At a certain moment the service is started with the parameters from the file.
In putty I set the remote character set to UTF-8.

Regards,

Rob.

2 Likes

My os is
Linux osmc 4.9.29-10-osmc #1 SMP PREEMPT Mon Oct 9 02:18:18 UTC 2017 armv7l GNU/Linux

This one works for me, hope it is helpfull to all.

For serial consol, append nano /boot/config.txt. this will enable uart
//—
enable_uart=1
dtoverlay=pi3-disable-bt

//— this will enable consol on uart
sudo systemctl start getty@ttyAMA0.service
sudo systemctl enable getty@ttyAMA0.service

//-- in case you want to use uart other then consol. just follow this commands.
sudo systemctl stop getty@ttyAMA0.service
sudo systemctl disable getty@ttyAMA0.service

//-- than after you can check communication. with minicom package.
minicom -b 9600 -o -D /dev/ttyAMA0