Monday, April 7, 2025

Raspberry PI Zero freeing up serial port /dev/ttyAMA0 for

The Pi Zeros only have two serial ports, only one can be mapped to the GPIO pin header at a time.  So, how to free up the serial port for a user/app to use?

This is for a buildroot generated file system.

The edit cmdline.txt:

root=/dev/mmcblk0p2 rootwait console=tty1 console=ttyAMA0,115200

remove console=ttyAMA,115200
so it looks like this:
root=/dev/mmcblk0p2 rootwait console=tty1

next edit /etc/inittab to start a tty shell
add this line at the bottom of the file:
ttyGS0::respawn:/sbin/getty -L ttyGS0 115200 vt100

edit config.txt 
add dtoverlay=dwc2 

This will start the OTG USB driver. 

I did something simple, edit S40network add:
     modprobe dwc2
      modprobe g_serial

This will start the serial interface.  A new serial interface will be created /dev/ttyGS0  

I'm using a Linux PC, so, when the USB is plugged in Zero will create a serial connection to Linux PC over USB OTG.  Then use minicom --dev /dev/ttyACM0