How To Setup Serial Console Cable Over the Pinebook
#1
Information 
Greetings,

The purpose of this photo blog is to provide a working tutorial for setting up a serial console over the Pinebook, by utilizing the audio headphone jack which also doubles as a universal asynchronous receiver|transmitter; uart(0).



Materials

You will need a usb extension cable for the serial adapter cable.  You will also need a usb ttl serial bridge adapter.  And you will need a 3.5 phone plug and cable.  The headphone jack is technically an apple style four pole 3.5 jack;  however, a three pole plug will work also.  You might also want to have some electrical tape, shrink tubing, and female header connectors;  I made my phone jack cable; however, commercial cables are available !

Theory

The serial console is the "sonic screwdriver" of the embedded world.  With it you can monitor boot-up messages, shutdown messages, and even logon to the system via serial connection with terminal software like minicom, from another system. The Pinebook's audio headphone jack has a double function;  with minimal configuration steps ( all covered here ) the headphone jack may be configured to run as a serial uart(0) device.

Procedure

                      


First let's talk about the plugs diagram pic(s) above;  the headphone jack is a four plug port, but a three pole plug will work just fine.  I have chosen to use a three pole plug for the proof of concept, and because they are readily available from the market with a cable-- ready for the female header jumpers to be installed.

In the left pic above the plugs have been labeled:  tip--Rx,  ring--Tx,  ring--Gnd.   These labels are in respect of the Pinebook; in other words, the labels are the Pinebook's pin definitions. The Pinebook receives on Rx (red wire, tip) and transmits on Tx (white wire, ring).  The second ring is the Pinebook's ground, and the collar (unused) is the Pinebook's mic connection.  The reason the three pole plug works is that the HP-jack shorts the unused mic connection to ground;  the important connections Rx, Tx, and Gnd  are all valid and fully functional.  I chose to use the right angle three pole plug in the pic, but feel free to use an actual four pole plug if you feel more comfortable with that electrical choice ( it really comes down to availability and price ).

Create the Cable

Please refer to the pics above.  I have added standard female header jumpers to my phone plug cable (solder and crimp) and then have sealed it with heat shrink tubing.  Make sure the plug is fully seated in the HP-jack-- not doing so is a common mistake which will keep your serial console from working !  You will notice from the pic of the ch340g adapter that the red Rx line from the Pinebook is plugged into the adapter Tx position, and that the white Tx line from the Pinebook is plugged into the Rx position of the adapter  (ground black is plugged into ground). The relationship is cross-wired for serial comm as follows :    ( you must use all three wires )

                                Rx-->Tx,  Tx-->Rx,  ground--ground

Please note the gold jumper in the second pic from the left.  This jumper on the ch340g (from the Pine Store) selects the logic voltage either 5v or 3v3.  Important:  always set the logic voltage to 3v3;  failure to do so can irreparably damage your Pinebook!  On the connector end of the ch340g serial adapter exist green LED(s) which will flicker during xmit and recv;  the red LED is a power indicator for the usb 5v rail.

Plug in the Cables and Connectors

I am actually using the Pine Rock64 board (desktop configuration running xenial-mate) as the serial console over the Pinebook.  I have connected the usb extension cable into the Rock64 usb2.0 lower port, and I have plugged the other end of the usb extension cable into the ch340g serial ttl bridge adapter ( make sure to set the logic jumper to 3v3, or you will damage your Pinebook!).  The ch340g adapter may be purchased from the Pine store for about $1.98 usd.  This adapter has become my standard go-to  serial adapter for all of my serial console use cases.

          Important Note:   In the pic above you will notice that all three wires are plugged in.  In practice don't do this on the outset;  only plug in the black and white wires-- only ground and the Pinebook's transmit wire ( in my case white-Tx ).   The reason for this is that often the Pinebook will not boot at all, or only partially boot, if the red wire-Rx is plugged in-- because the Tx line from the Rock64 provides 3v3 voltage (bleed current) that interferes with the Pinebook!  Start the boot-up with the red-Rx wire unplugged and then plug it in after the logon prompt appears on the console.  Failure to heed this warning will cause frustration -- words to the wise.

Start the Terminal Software

Open a terminal on your Rock64 ( or other gnu+linux computer);  this terminal will eventually be our serial console, but for the time being enter the following command after connecting the CH340g to the Rock64 usb port:

         dmesg  |tail  -n  10

Assuming the kernel can "see" your CH340g you should see this line in the output:

          usb ch341-uart converter now attached to /dev/ttyUSB0

If your device is different, please make a note of it;  you will use that device name in the minicom initialization command string below!

I prefer to use minicom for my terminal software-- it is the old standby;  others will work like "screen,"  or "cu".  Minicom is the best in my opinion;  the most flexible, and has the most features.  Please refer to the minicom man page for details. From a terminal on the Rock64 I start minicom with the command sequence :

          sudo  minicom  -s  -D  /dev/ttyUSB0  -b  115200  --color=on

The  -s  flag will take you into the minicom configuration panel;  choose Serial Port Setup and confirm the following defaults;  make sure the software and hardware flow controls are both set to NO.

      device  /dev/ttyUSB0
      baud  115200
      parms  8n1    8 bits,  no parity,  1 stopbit

... on the same panel press enter,  then select 'exit' and press enter again;  the serial terminal emulation software should now be running.

Set the Pinebook for uart(0) mode, and plug in the 3.5 jack plug

To use the uart(0) serial port you must toggle a switch inside the Pinebook.  Please refer to this link for details.

Also you will need to shutdown the headphones service in systemd with the following command:

           sudo  systemctl  disable  pinebook-headphones     ( important )

          plug in the 3.5 cable plug

Power-ON the Pinebook

With all connections made, and the terminal software running on the Rock64,  power up the Pinebook by pressing the power button briefly.  Almost immediately (everything being correct) boot-up messages will begin flowing on the serial console, culminating in a logon prompt  ( at this time plug in the red-Rx wire from the Pinebook to the ch340g ). 

   

The pic above is the console running on my Rock64.   I have logged on to the Pinebook and run some commands, the output(s) of which you can see here.

We now have a serial console running. We can use it for boot diagnostics, as a control terminal interface and to view the power-off messages as well.

Press the power button;  the shutdown dialogue will appear on the Pinebook.  Select 'shutdown' and again, almost immediately the shutdown messages will scroll down the serial console culminating in systemd  target shutdown , and then the Pinebook should power off. 

Close the Terminal Software

Press Ctrl + A on the serial console minicom software.  Then press x followed by the enter key.  Minicom will exit
marcushh777    Cool

please join us for a chat @  irc.pine64.xyz:6667   or ssl  irc.pine64.xyz:6697

( I regret that I am not able to respond to personal messages;  let's meet on irc! )
#2
(08-26-2017, 06:05 AM)MarkHaysHarris777 Wrote: Greetings,

The purpose of this photo blog is to provide a working tutorial for setting up a serial console over the Pinebook, by utilizing the audio headphone jack which also doubles as a universal asynchronous receiver|transmitter; uart(0).

<cut>

          Important Note:   In the pic above you will notice that all three wires are plugged in.  In practice don't do this on the outset;  only plug in the black and white wires-- only ground and the Pinebook's transmit wire ( in my case white-Tx ).   The reason for this is that often the Pinebook will not boot at all, or only partially boot, if the red wire-Rx is plugged in-- because the Tx line from the Rock64 provides 3v3 voltage (bleed current) that interferes with the Pinebook!  Start the boot-up with the red-Rx wire unplugged and then plug it in after the logon prompt appears on the console.  Failure to heed this warning will cause frustration -- words to the wise.

<cut>
Thank you for this post! Sounds interesting and fun to be able to access the pb via serial (and see boot and shutdown process), so I've ordered a ch340g and a plug online Smile 

I've cut out the bit above, because i was wondering if the issue described there (" because the Tx line from the Rock64 provides 3v3 voltage (bleed current) that interferes with the Pinebook!  ") will also be there if you connect it to the pine64 usb?

Cheers!
#3
(08-27-2017, 01:53 AM)rookieone Wrote:
(08-26-2017, 06:05 AM)MarkHaysHarris777 Wrote: Greetings,

The purpose of this photo blog is to provide a working tutorial for setting up a serial console over the Pinebook, by utilizing the audio headphone jack which also doubles as a universal asynchronous receiver|transmitter; uart(0).

<cut>

          Important Note:   In the pic above you will notice that all three wires are plugged in.  In practice don't do this on the outset;  only plug in the black and white wires-- only ground and the Pinebook's transmit wire ( in my case white-Tx ).   The reason for this is that often the Pinebook will not boot at all, or only partially boot, if the red wire-Rx is plugged in-- because the Tx line from the Rock64 provides 3v3 voltage (bleed current) that interferes with the Pinebook!  Start the boot-up with the red-Rx wire unplugged and then plug it in after the logon prompt appears on the console.  Failure to heed this warning will cause frustration -- words to the wise.

<cut>
Thank you for this post! Sounds interesting and fun to be able to access the pb via serial (and see boot and shutdown process), so I've ordered a ch340g and a plug online Smile 

I've cut out the bit above, because i was wondering if the issue described there (" because the Tx line from the Rock64 provides 3v3 voltage (bleed current) that interferes with the Pinebook!  ") will also be there if you connect it to the pine64 usb?

Cheers!


Yes, it is possible.  If the transmit line from the serial console is plugged into the SBC being booted, the SBC being booted may not boot.   I have noticed this behavior on all of the boards--  sopine, pineA64+, Pinebook, and Rock64.

I always boot the the SBC with the transmit line from the serial console (transmit Tx from the CH340g) unplugged until I get the logon prompt from the SBC;  Again, to watch the boot-up messages all you need is ground, and the transmit line from the SBC!
marcushh777    Cool

please join us for a chat @  irc.pine64.xyz:6667   or ssl  irc.pine64.xyz:6697

( I regret that I am not able to respond to personal messages;  let's meet on irc! )
#4
Is it really uart0 port of the chipset? According to linux DTI files I thought it is somehow used for the bluetooth.
#5
(07-01-2020, 12:09 AM)lowenware Wrote: Is it really uart0 port of the chipset? According to linux DTI files I thought it is somehow used for the bluetooth.

uart2


Possibly Related Threads…
Thread Author Replies Views Last Post
  pinebook 1080p power/barrel connector/cable cel 0 803 08-03-2023, 11:43 AM
Last Post: cel
  eMMC compatible with Pinebook leperotero 0 1,608 07-19-2022, 07:15 AM
Last Post: leperotero
Heart [solved] Anyone selling their Pinebook? feyn 0 1,513 07-11-2022, 03:38 PM
Last Post: feyn
  Move PB Pro eMMC 128 GB to Pinebook 11 1080p petet0n76 1 2,051 06-07-2022, 10:35 PM
Last Post: tllim
  UART switch Pinebook 11.6" irongarment 3 3,946 01-03-2022, 03:28 AM
Last Post: kqlnut
Exclamation "6" Key direly needed for 11" Pinebook Corkonian 1 3,018 09-25-2021, 12:03 AM
Last Post: tllim
  Pinebook 14 " Battery Swollen/Bulged billjon 1 4,035 01-13-2021, 11:03 AM
Last Post: barray
  touchpad on pinebook issues? ron_burgundy 14 15,580 12-19-2020, 06:55 PM
Last Post: ron_burgundy
  Pinebook doesn't charge anymore Reinoud 0 2,921 08-20-2020, 08:18 AM
Last Post: Reinoud
  How to write image to emmc module on the pinebook eclay 16 36,347 06-11-2020, 03:03 PM
Last Post: jezek

Forum Jump:


Users browsing this thread: 1 Guest(s)