Access Raspberry Pi 3 UART Console on MacOS

       800 words, 4 minutes

Raspberry Pi can be used with a prepared OS, booted up and just used. But when it comes to customising or doing something else than what was planned, you may need to use the console. And that requires a TTL adapter connected to the GPIO. The thing is, using MacOS is not as straightforward as I thought. So here are my notes.

The hardware

I’m using a Raspberry Pi 3 Model B V1.2. But according to the documentation, the console pins are the same as previous models.

To be able to connect to the GPIO, I use a USB to TTL Serial Cable. I got mine on Amazon but the model is the same as the ADA Fruit 954.

The software

For a first try, I used a preconfigured documented system: Raspbian. I got the image from their website and used 2018-06-27-raspbian-stretch-lite.img

I inserted a MicroSD in the HyperDrive Hub of my MacBook Pro and opened a MacOS Terminal:

# sudo su -
# diskutil list
# diskutil unmountDisk /dev/disk2
# dd if=2018-06-27-raspbian-stretch-lite.img of=/dev/disk2 bs=1m
# diskutil unmountDisk /dev/disk2

There is a tweak on MacOS to get access to the console. AFAIK dealing with disabling RP3 bluetooth. So I plugged the MicroSD card back in MacOS and wait for it to mount the MSDOS partition. Then I edited the config.txt file, saved it and unmounted the MicroSD.

# vim /Volumes/boot/config.txt
(...)
# Correct console for MacOS
dtoverlay=pi3-disable-bt
systemctl disable hciuart
<esc>:wq

# diskutil unmountDisk /dev/disk2

The MicroSD card can then be plugged in the Raspberry.

Then I had to install the Prolific PL2303 driver for MacOS. That’s the driver for the chipset used in the TTL to USB adapter that I got. The driver is available  here . I used PL2303_MacOSX_1.6.1_20160309.pkg on MacOS High Sierra 10.13.5. Note that a reboot is required to use the driver…

The experiment

Thanks to the hardware I got and the Internet documentation, plugging the cables was really easy. Just have the black cable on pin6, the white cable on pin8 and the green cable on pin10. If the red cable is plugged on pin2 or pin4, then the card will be powered-on using the TTL to USB adapter. It does work although I noticed a warning in the U-Boot console. It is also widely recommended to add an extra power source for better usage ; that’s what the MicroUSB plug is for.

Plug the USB part of serial cable into the computer. Wait 3 seconds for the hardware to be recognised and driver to be loaded. Then, in a Terminal, issue one of those commands :

# screen /dev/cu.usbserial 115200
# cu -l /dev/cu.usbserial -s 115200

There seem to be a bug with the screen command. When you quit the first session and start a new one, the process will end up using 100% CPU and not being killed, ever. A hard reboot is required on the Mac :(

Hence, I decided to use “cu”. To quit the command, just issue “option-n + .”

I also added a tee part to be able to capture what happens in a log file. Much better to later copy/paste operations.

# cu -l /dev/cu.usbserial -s 115200 | tee cu.log

To be able to see all the booting process, I went in this order:

The console then outputs the whole card and system boot process. You end up with a standard Debian/Linux login prompt. The default user is pi:raspberry. When logged in, switch to root using “sudo su -”.

Configure the WiFi interface:

# vi /etc/wpa_supplicant/wpa_supplicant.conf
(...)
country=FR
network={
  ssid="tumfatig"
  psk="secret"
}

# wpa_cli -i wlan0 reconfigure

Configure the SSH daemon:

# systemctl enable ssh
# systemctl start ssh

Et voilà, basic things are done.

From my testings, there are issues with using certains USB sticks as bootable device. I tried to use a Corsair FlashVoyagerGT which never was found by U-Boot ; although the booted Linux & OpenBSD system found them. Best bet is to install any system on the MicroSD card.

The documentation

When you know nothing, you have to learn. So here’re the things I read.