I have a Pi Zero with Raspbian which I'd like to use as a logger device with WiFi (it's not a W, I'm using an external WiFi stick). I need the UART to communicate with a microcontroller but sometimes I also need the serial console eg. if I need to reconfigure the WiFi.

What I'd like to achieve is when I start the Pi the UART shall be configured for serial console mode and with a command it shall be reconfigured to be an ordinary serial line. The command will be triggered maybe with a switch which will be read at startup.

I'm familiar with the Linux basics but I don't know how the serial interfaces work.

  • 1
    Can't be done. Sorry.
    – Dougie
    Jan 4 '20 at 12:10
  • Ah, I think only one of serial console or Rpi built in on board UART (RxD and TxD pins) can be configured before booting. If you enable one in Rpi Config, then you must disable the other. Perhaps you can use Rpi's USB to serial adapter/cable, but I don't if there are other side problems. Just brainstorming. Good luck and cheers.
    – tlfong01
    Jan 4 '20 at 13:53
  • @Dougie I think what can't be done is dynamically switching the kernel output (although I guess that could be done by directing it to somewhere else that can be redirected from userspace to or from the serial port). What could be done is stopping or starting a login console -- that's done with a userspace service ("I also need the serial console eg. if I need to reconfigure the WiFi").
    – goldilocks
    Jan 4 '20 at 16:53
  • @bmann Without the login console enabled by default, and the kernel logging set to something else in cmdline.txt, try sudo systemctl start serial-getty@AMA0 (or whaterver port you use). Obviously you need to be logged in some other way to test that but if it works you could use a toggle on a GPIO etc.
    – goldilocks
    Jan 4 '20 at 16:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.