Sunday, July 10, 2022

Devuan on a Raspberry Pi using Serial Console

     Greetings! As anyone who knows me might know, I'm an avid Linux fan and specifically I enjoy Devuan. I have my reasons like everyone but for me, it just works. That is to say until I decided to head down the Devuan on a Raspberry Pi (RPi) path! Long story short, I was given a RPi4 at work and asked to setup a dropbox of sorts and noticing that Devuan had some Daedalus (next release of Devuan) images available at the ARM Trial Images page, I thought this would be a great opportunity to try out the new release on a new RPi4. 

    One of the first things immediately noticed was that the RPi4 uses USB-C for power as well as a micro HDMI for video out. Shoot! USB-C wasn't an issue but the micro HDMI would prove to be an issue. Not to fear like all my other RPi's, the Pi 4 also supports a UART interface and I have more than a few UART capable devices laying around at all times.  

    After downloading the Daedalus zip from Devuan's site, extracting it, and writing it to the micro-sd card for the Pi, I set off to enable the UART interface by modifying the RPi's config.txt file on the boot partition. Normally when doing this, all that had been needed with recent distros like Raspbian was to add enable_uart=1 to the config.txt file. 

    Prior to booting the Pi, a connection to the primary serial interface is needed to see the output. A JTAGulator board was used for this purpose. So making the proper connections from the JTAGulator to the RPi was follows:

JTAGulator Pin RPI GPIO Pin
GNDPin 9
CH0Pin 8
CH1Pin 10

    Hopefully at this point, the following command can be used to access the JTAGulator interface picocom -q -b 115200 /dev/ttyUSB0.Upon successful connection, the JTAGulator ascii art should be displayed and a UART passthrough connection can be configured.

# picocom -q -b 115200 /dev/ttyUSB0
                                    UU  LLL
 JJJ  TTTTTTT AAAAA  GGGGGGGGGGG   UUUU LLL   AAAAA TTTTTTTT OOOOOOO  RRRRRRRRR
 JJJJ TTTTTTT AAAAAA GGGGGGG       UUUU LLL  AAAAAA TTTTTTTT OOOOOOO  RRRRRRRR
 JJJJ  TTTT  AAAAAAA GGG      UUU  UUUU LLL  AAA AAA   TTT  OOOO OOO  RRR RRR
 JJJJ  TTTT  AAA AAA GGG  GGG UUUU UUUU LLL AAA  AAA   TTT  OOO  OOO  RRRRRRR
 JJJJ  TTTT  AAA  AA GGGGGGGGG UUUUUUUU LLLLLLLL AAAA  TTT OOOOOOOOO  RRR RRR
  JJJ  TTTT AAA   AA GGGGGGGGG UUUUUUUU LLLLLLLLL AAA  TTT OOOOOOOOO  RRR RRR
  JJJ  TT                  GGG             AAA                         RR RRR
 JJJ                        GG             AA                              RRR
JJJ                          G             A                                 RR

           Welcome to JTAGulator. Press 'H' for available commands.
         Warning: Use of this tool may affect target system behavior!

> u

UART> v
Current target I/O voltage: Undefined
Enter new target I/O voltage (1.4 - 3.3, 0 for off): 3.3
New target I/O voltage set: 3.3
Warning: Ensure VADJ is NOT connected to target!

UART> p
UART pin naming is from the target's perspective.
Enter X to disable either pin, if desired.
Enter TXD pin [0]: 
Enter RXD pin [0]: 1
Enter baud rate [0]: 115200
Enable local echo? [y/N]: 
Entering UART passthrough! Press Ctrl-X to exit...

    After applying power to the RPi, Kernel messages proceeded to fly across the screen as expected until the final portion of the init sequence in which getty should should be spawned to allow for interacting with the RPi running Devuan.

### Trimmed Kernel messages for brevity###
Starting firstboot:
 Expanding root filesystem ...
 Running fsck on boot partition ...
.
INIT: Entering runlevel: 2
Using makefile-style concurrent boot in runlevel 2.
Setting up console font and keymap...done.
Starting enhanced syslogd: rsyslogd.
LED Service:mmc0
.
Governor:performance
.
haveged: command socket is listening at fd 3
Starting periodic command scheduler: cron.
Mounting zramswap virtual memory:Setting up swapspace version 1, size = 1024 MiB (1073737728 bytes)
no label, UUID=cf07e06f-a881-491f-8eca-bb86a4fc9362
.
Starting NTP server: ntpd2022-07-09T05:32:55 ntpd[1293]: INIT: ntpd ntpsec-1.2.1: Starting
2022-07-09T05:32:55 ntpd[1293]: INIT: Command line: /usr/sbin/ntpd -p /run/ntpd.pid -c /etc/ntpsec/ntp.conf -g -N -u ntpsec:ntpsec
.
Starting system message bus: dbus.
Starting bluetooth: bluetoothd.
Starting session management daemon: elogind
.
Starting Avahi mDNS/DNS-SD Daemon: avahi-daemon.
Starting OpenBSD Secure Shell server: sshd.
Starting network connection manager: NetworkManager.
Checking credentials:
Restarting OpenBSD Secure Shell server: sshd.
.

    Sadly immediately after the messages about SSH, the CLI simply appears to hang. Normally this is when getty should be started and a login prompt visible. Dang! Alright after some trial and error a solution was found by visiting the inittab file in the RPi's ROOTFS partition and correcting the proper line to enable a serial getty. To accomplish this task, ensure that the RPI's microSD card is accessible and modify the following line in ROOTFS/etc/inittab.


<File contents trimmed for brevity>
# Example how to put a getty on a serial line (for a terminal)
#
#T0:23:respawn:/sbin/getty -L ttyS0 9600 vt100 <-- This line needs changed
#T1:23:respawn:/sbin/getty -L ttyS1 9600 vt100
#
<File contents trimmed for brevity>

--- Corrected line contents below

<File contents trimmed for brevity>
# Example how to put a getty on a serial line (for a terminal)
#
T0:23:respawn:/sbin/getty -L serial0 115200 linux
#T1:23:respawn:/sbin/getty -L ttyS1 9600 vt100
#
<File contents trimmed for brevity>

Saving the file and booting the RPI again yielded a successful prompt over the serial interface.

Starting bluetooth: bluetoothd.
Starting session management daemon: elogind.
Starting Avahi mDNS/DNS-SD Daemon: avahi-daemon.
Starting OpenBSD Secure Shell server: sshd.
Starting network connection manager: NetworkManager.

Devuan GNU/Linux daedalus/ceres devuanpi serial0

devuanpi login: 

Success! At this point the default username:password (devuan:devuan) can be used to log in and continue configuring the RPi as desired. Hopefully this can save others some headaches trying to get a serial interface working through Devuan on a RPi. 

EDIT - Worth noting this process also works on a RPi 2 running Devuan Daedalus.

No comments:

Post a Comment

Have a thought or question? Please share!