© Warren Gay 2018
Warren GayAdvanced Raspberry Pihttps://doi.org/10.1007/978-1-4842-3948-3_19

19. Linux Console and Pi Zero

Warren Gay1 
(1)
St. Catharine’s, Ontario, Canada
 

The Raspbian Linux console is configured (or assumed) by the kernel command line at boot time. Before we examine serial console access however, let’s step through the challenges of setting up the Pi Zero or Zero W. The main challenge is working with the single USB port and having the correct adapters. Then we’ll examine the option of a serial device console.

Pi Zero / Zero W

Starting up a Pi Zero is a problem for two main reasons:
  1. 1.

    The ssh access is disabled on new Raspbian images.

     
  2. 2.

    There is only one USB port to attach a keyboard and mouse to.

     

And to see what you’re doing, you’re going to need a mini HDMI to HDMI adapter.

The reason that ssh is disabled by default is that the Pi’s image comes with a default password for the Pi account. Everybody knows it, especially the hackers. The unwitting user could start up a Pi and leave it connected to the network, inviting all kinds of nasty business. So the Raspbian image comes with ssh disabled.

What you really need is a USB hub that is supported by Raspbian. I tried an old Apple hub with no luck. So I switched to a more recent one. Some keyboards provide an extra USB port or two. That can be useful, provided that Raspbian Linux supports it.

If you’re patient, you might be able to get by without a hub at all. Power up the Zero and plug only the mouse into the USB adapter cable. Then mouse around to your system preferences. When you need to type in something, you can unplug the mouse and plug in the keyboard. You may not need the keyboard for much of the initial configuration.

Adapters Needed

The following is a list of adapters you should have on hand, even if you only use them once to set up your Zero. Figure 19-1 illustrates an example.
  • Power adapter (black plug plugged into Zero at right).

  • USB 2.0 Micro B 5-pin to female USB 2.0 type A adapter cable (white cable in middle).

  • HDMI mini adapter (white adapter at Pi left).

  • Optional USB to ethernet adapter (far right, white).

../images/326071_2_En_19_Chapter/326071_2_En_19_Fig1_HTML.jpg
Figure 19-1

Photo of a Pi Zero with mini HDMI adapter, USB adapter cable, and optional USB Ethernet adapter

If you use the serial port console later in this chapter, you can get away without the USB and mini HDMI adapters.

Enabling ssh and VNC Access

If you have a supported USB to ethernet adapter , then attach your HDMI, keyboard, and/or mouse and boot Raspbian Linux. My USB ethernet adapter only consumes about 42 mA. If operating without a hub, plug in your mouse alone. Once you have the graphical desktop, open the Raspberry Pi Configuration using the mouse. Click on the Interfaces tab, and then click the following entries to enable them:
  • Enable SSH

  • Enable VNC

  • Optionally enable Serial Port (enabled by default)

  • Optionally enable Serial Console (enabled by default)

Don’t forget to click OK at the bottom right. Then still using your mouse , click on reboot to apply these new settings. Figure 19-2 illustrates the control panel involved.
../images/326071_2_En_19_Chapter/326071_2_En_19_Fig2_HTML.jpg
Figure 19-2

The Raspberry Pi Configuration, Interfaces panel

Once your Zero reboots, you should be able to:
  1. 1.

    Unplug your mouse (if not using a hub).

     
  2. 2.

    Plug in your USB to ethernet adapter.

     
  3. 3.

    Plug in your ethernet cable to a router.

     
  4. 4.

    Scan your network to discover the assigned IP address.

     
If you’re using a hub, use your keyboard and mouse to open a terminal window and type the ifconfig command to determine the assigned address . The example in Figure 19-3 shows the address as 192.168.1.15.
../images/326071_2_En_19_Chapter/326071_2_En_19_Fig3_HTML.jpg
Figure 19-3

Displaying your USB to ethernet address in the terminal window, using the ifconfig command

Otherwise, scan for your Pi Zero from the desktop. The following example scans addresses between 192.168.1.2 to 192.168.1.254 on Mac/Linux:
$ nmap -sP 192.168.1.2-254
Starting Nmap 7.40 ( https://nmap.org ) at 2018-07-12 20:04 EDT
Nmap scan report for 192.168.1.3
Host is up (0.077s latency).
...
Nmap scan report for 192.168.1.15
Host is up (0.0017s latency).
...
Nmap done: 253 IP addresses (6 hosts up) scanned in 2.86 seconds
[email protected]'s password:
Linux pizero 4.14.52+ #1123 Wed Jun 27 17:05:32 BST 2018 armv6l
...

In this example, I knew that the Pi would be assigned a 192.168.1.* address because of the router that the ethernet cable was plugged into. I discovered by experimentation that the Pi Zero had the address 192.168.1.15.

Serial Console

If the mouse and HDMI approach isn’t suitable, perhaps because you lack the adapters, you might try the serial console approach instead. The Raspbian Linux image has the serial console enabled by default. It uses the baud rate of 115200 baud, without hardware flow control.

It is crucial, however, that you use a serial adapter that works at the 3.3 V level. Do not use 5 V serial adapters because they can cause damage to the Pi. Some adapters can operate at either level, configured by a jumper.

Wire your adapter so that the Pi +3.3 V (P1-01) supplies the serial adapter with power (some USB adapters supply their own power). The connections are summarized below:
  • Pi +3.3 V (P1-01) supply to adapter +3.3 V (may be labeled VCC).

  • Pi ground (P1-06) to the adapter ground (usually labeled Gnd).

  • Pi TX (P1-08) to the adapter TX.

  • Pi RX (P1-10) to the adapter RX.

Caution

 Do not connect a 5 Volt TTL serial adapter. This can cause damage. Some adapters have a jumper to choose a 3.3 or 5 volt operation.

If you find that this doesn’t work, try connecting TX to RX and RX to TX. Some adapters may be labeled according to the DCE (data communication equipment) perspective, while others will use the DTE (data terminal equipment) convention.

Once connected, plug your USB adapter into your desktop, start minicom (or other favorite terminal program), and set your serial parameters for:
  • 155200 baud

  • 8-Bits, no parity and 1 stop bit (8-N-1)

  • Hardware flow control off

Boot your Pi Zero and allow it to come up. Allow extra time, especially when the desktop is coming up. Once it comes up, press Enter to cause the login prompt to show. Then you can log in as usual:
Welcome to minicom 2.7
OPTIONS:
Compiled on Sep 17 2016, 05:53:15.
Port /dev/cu.usbserial-A100MX3L, 20:52:57
Press Meta-Z for help on special keys
Raspbian GNU/Linux 9 pizero ttyAMA0
pizero login: pi
Password:
Last login : ...

Summary

The serial port console can be very helpful when you lack all of the other devices: keyboard, mouse, and screen. This is often all you need to get a Pi Zero or Pi Zero W initialized for your special project.

The patient user can get by with just one USB adapter cable and a mini HDMI adapter for initial setup. The keyboard and mouse can be swapped in and out as needed. Once ssh or VNC is enabled, you can operate from the comfort of your favorite desktop.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.134.78.106