Disable console over Serial in Dev on RPi3?

Ok, thanks for the details.

“Do you have any overlay” was a bit short for me to recreate the good context around :wink:

Yeah, sorry about that. :slight_smile: Working with devices all day it takes a bit of context switching sometimes to make sure everyone’s talking about the same thing.

Just for confirmation and others with the same problem. When using a production image, it was enough to change the host config as mentioned:

so no need to change cmdline.txt or mask serial-getty or lowering the baudrate!

I folllowed the details above on my Dev OS to enable the serial port.

I use Bluetooth on the RPi to do BLE communications - after I open the serial port now, my bluetooth no longer works.

If I try Bluetooth before opening the serial port, it communicates fine, then as soon as I open the Serial Port, the Bluetooth fails.

I am on v2.29.2 of Device OS, I am testing on Prod now.

@mhazley, How are you connecting your bluetooth device, and which commands did you run in dev?

Hi, apologies all, this was a red-herring.

Stripped my pyserial code back to basics, removing some additional libs and it all seems to work now. Not 100% what was causing the issue at this point.

mount -o remount,rw /
systemctl mask serial-getty@serial0.service

Worked great to solve my problem. Can this be defined in the dashboard under “Device Configuration” ?

Sorry to open this back up…

Having the same issues here, running balenaOS 2.32.0+rev4 dev version on an intel nuc. We are having serial issues in one of our docker containers. The fixes above don’t seem to be working. I am not sure if it is a raspberry pi vs intel nuc issue or a docker issue, or some other issue.

Any ideas?

@tylorbayer which specific issues are you seeing? As I would expect Disable console over Serial in Dev on RPi3? to work fine for disabling the serial console in dev images

I think I still need to poke around a little bit in the HostOS… in the meantime, is there any way to check if the console is definitely disabled?

If you run systemctl | grep getty in the host os then it should give a list of all the getty services currently running and there shouldn’t be any like serial-getty@*.service running

1 Like

So running the commands above (mount/remount then systemctl mask) and then rebooting wouldn’t change that grep output and I was still seeing the serial-getty@*.service and my device was still throwing the errors regarding the serial port like it was before…

Then I ran ‘systemctl mask serial-getty@ttyS0.service’ and that worked instantly and persisted after reboot… I am not sure why it fixed my issue but the device is working great for me now with the development os. I tested in localmode as well and it works thankfully!

Thank you for the help and quick responses!

Hi Forum,

If I understood correctly only development images have the getty service enabled by default and this can be disable using

Question : If I download a development image from Balena Cloud.
Is there any way I can modify the image disabling the getty service before the first boot up?
My guess that I have to compile a custom development image But exist something easier?

Thank you.

ps: If I have to build a custom development image what files and parameters has to be changed in order to disable the getty service?

Hi Forum,

Can someone please shed some light on this?

Maybe Balena team.

Thank you.

Hi everyone.
Necroposting here to let people know that I found a way to disable the console over the serial port directly from a docker container.

Long story short:

  1. Either add a new service or merge this with an existing one in docker-compose.yml:
      - 'DBUS_SYSTEM_BUS_ADDRESS=unix:path=/host/run/dbus/system_bus_socket'
      io.balena.features.dbus: '1'
  1. Add dbus to your Dockerfile:
RUN install_packages dbus
  1. Run the following commands at runtime inside the container:
DBUS_SYSTEM_BUS_ADDRESS=unix:path=/host/run/dbus/system_bus_socket \
  dbus-send \
  --system \
  --print-reply \
  --dest=org.freedesktop.systemd1 \
  /org/freedesktop/systemd1 \
  org.freedesktop.systemd1.Manager.MaskUnitFiles \
  array:string:"serial-getty@serial0.service" \
  boolean:true \

DBUS_SYSTEM_BUS_ADDRESS=unix:path=/host/run/dbus/system_bus_socket \
  dbus-send \
  --system \
  --print-reply \
  --dest=org.freedesktop.systemd1 \
  /org/freedesktop/systemd1 \
  org.freedesktop.systemd1.Manager.StopUnit \
  string:"serial-getty@serial0.service" \

You can find a fully working example in this repository, as well as documentation and more in depth explanations: