Manage LIME2 from PC via USB-Serial-F Cable Connection to UART0 with Picocom

Started by miroR, September 09, 2020, 02:55:59 PM

Previous topic - Next topic

miroR

This is for anybody having issues with USB-serial connection, and issues finding documentation and tutorials about is.

Pls. first see:
UART0 Connection to PC via USB-Serial-F Cable Fails
https://www.olimex.com/forum/index.php?topic=7806

for the possible issues, then this will be clearer to follow.

Also maybe this will suffice for you:
Ubuntu - How do I connect to TTY_COM
https://www.youtube.com/watch?v=874XnIGjEjM

and then you don't need to read here at all.

This is what it looks like on my system:
2020-09-09T07:23:13.858723+00:00 gdOv kernel: [  348.743829] usb 4-1: new full-speed USB device number 2 using ohci-pci
2020-09-09T07:23:14.021621+00:00 gdOv kernel: [  348.906980] usb 4-1: New USB device found, idVendor=067b, idProduct=2303, bcdDevice= 3.00
2020-09-09T07:23:14.021640+00:00 gdOv kernel: [  348.906985] usb 4-1: New USB device strings: Mfr=1, Product=2, SerialNumber=0
2020-09-09T07:23:14.021656+00:00 gdOv kernel: [  348.906989] usb 4-1: Product: USB-Serial Controller
2020-09-09T07:23:14.021660+00:00 gdOv kernel: [  348.906991] usb 4-1: Manufacturer: Prolific Technology Inc.
2020-09-09T07:23:14.024812+00:00 gdOv kernel: [  348.910173] pl2303 4-1:1.0: pl2303 converter detected
2020-09-09T07:23:14.048627+00:00 gdOv kernel: [  348.934719] usb 4-1: pl2303 converter now attached to ttyUSB0
So I apt-get install picocom, and read the man page and the README, and:
root@gdOv:/home/mr# picocom /dev/ttyUSB0
picocom v3.1

port is        : /dev/ttyUSB0
flowcontrol    : none
baudrate is    : 9600
parity is      : none
databits are   : 8
stopbits are   : 1
escape is      : C-a
local echo is  : no
noinit is      : no
noreset is     : no
hangup is      : no
nolock is      : no
send_cmd is    : sz -vv
receive_cmd is : rz -vv -E
imap is        :
omap is        :
emap is        : crcrlf,delbs,
logfile is     : none
initstring     : none
exit_after is  : not set
exit is        : no

Type [C-a] [C-h] to see available commands
Terminal ready
I typed Ctrl-A Ctrl-H.

*** Picocom commands (all prefixed by [C-a])

*** [C-x] : Exit picocom
*** [C-q] : Exit without reseting serial port
*** [C-b] : Set baudrate
*** [C-u] : Increase baudrate (baud-up)
*** [C-d] : Decrease baudrate (baud-down)
*** [C-i] : Change number of databits
*** [C-j] : Change number of stopbits
*** [C-f] : Change flow-control mode
*** [C-y] : Change parity mode
*** [C-p] : Pulse DTR
*** [C-t] : Toggle DTR
*** [C-g] : Toggle RTS
*** [C-|] : Send break
*** [C-c] : Toggle local echo
*** [C-w] : Write hex
*** [C-s] : Send file
*** [C-r] : Receive file
*** [C-v] : Show port settings
*** [C-h] : Show this message

I typed Ctrl-A Ctrl-B


*** baud: 115200

*** baud: 115200 ***

a20-olinuxino login:  root��
                           P���wor�:��
                                      �o�i�ti�e�o�t��fter�60��eco���.�

Id est: I got a little rubbish at first, for whatever reason...

Debian GNU/Linux 10 a20-olinuxino ttyS0

a20-olinuxino login: root
Password:
Last login: Wed Aug 26 20:58:05 UTC 2020 from 192.168.2.252 on pts/3
Linux a20-olinuxino 5.6.14-olimex #081742 SMP Fri Jul 31 08:18:08 UTC 2020 armv7l

The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
xset:  unable to open display ""
root@a20-olinuxino:~#

But now it looks like I'm in A20 LIME2 server...

root@a20-olinuxino:~# ls -ltr
total 42736
-r--r----- 1 root   root        669 Feb  2  2020 sudoers.O
-rw-r--r-- 1 root   root         40 Aug 20 15:49 interfaces.d.ethO
-rw-r--r-- 1 olimex olimex      320 Aug 20 16:14 aplay-l.txt
-rw-r--r-- 1 root   root   38307840 Aug 22 15:39 boot.tar
-rw-r--r-- 1 root   root    5068800 Aug 22 15:48 linux-image-5.6.14-olimex.tar
-rw-r--r-- 1 root   root      61324 Aug 22 17:15 dmesg_200822_17Y15.txt
-rw-r--r-- 1 root   root       3303 Aug 22 17:23 dmesg_200822_17Y15_HDMI_audio_backtrace.txt
-rw-r--r-- 1 root   root        864 Aug 22 17:27 dmesg_200822_17Y15_Micrel_KSZ9031_Gigabit_PHY.txt
-rw-r--r-- 1 root   root       1949 Aug 22 17:31 dmesg_200822_17Y15_Micrel_KSZ9031_Gigabit_PHY_at017000.txt
-rw-r--r-- 1 root   root      51200 Aug 23 19:34 etc_network.tar
-rw-r--r-- 1 root   root     238028 Aug 23 19:39 syslog_200823_1937
root@a20-olinuxino:~#

Yep! That's what it currently looks like.

Let's change to a better TIME_STYLE setting:

This is currently the setting:

root@a20-olinuxino:~# cat /etc/default/locale
#  File generated by update-locale
LANG=en_GB.UTF-8
root@a20-olinuxino:~#

And now:

root@a20-olinuxino:~# cat >> /etc/default/locale
TIME_STYLE="posix-long-iso"
root@a20-olinuxino:~#

However, here, new to managing serial line like this, and using keyboard in my xterms with a lot of Ctrl-this and Ctrl-that and Alt-this,that when, say, addapting command line find after rummaging through bash history, and here I must have accidentally typed C-a C-d, or even just C-d, and I got:

root@a20-olinuxino:~# cat >> /etc/default/locale
*** flow: RTS/CTS ***


And setting the baud rate didn't anymore get me the terminal back.

LATER NOTE: Apparently plain C-d gets you the terminal back in a case like that. WARN: it does also log you out from where you're logged in.

Will exit
C-a C-x


Terminating...
Thanks for using picocom
root@gdOv:/home/mr#

Another session.

root@gdOv:/home/mr# picocom /dev/ttyUSB0
picocom v3.1

port is        : /dev/ttyUSB0
flowcontrol    : none
baudrate is    : 9600
parity is      : none
databits are   : 8
stopbits are   : 1
escape is      : C-a
local echo is  : no
noinit is      : no
noreset is     : no
hangup is      : no
nolock is      : no
send_cmd is    : sz -vv
receive_cmd is : rz -vv -E
imap is        :
omap is        :
emap is        : crcrlf,delbs,
logfile is     : none
initstring     : none
exit_after is  : not set
exit is        : no

Type [C-a] [C-h] to see available commands
Terminal ready

C-a C-b

*** baud: 115200

*** baud: 115200 ***


And I can't get the login anymore...

What? It is C-d without C-a) that gets me back into the terminal?


root@a20-olinuxino:~# ls -ltr
total 42736
-r--r----- 1 root   root        669 Feb  2  2020 sudoers.O
-rw-r--r-- 1 root   root         40 Aug 20 15:49 interfaces.d.ethO
-rw-r--r-- 1 olimex olimex      320 Aug 20 16:14 aplay-l.txt
-rw-r--r-- 1 root   root   38307840 Aug 22 15:39 boot.tar
-rw-r--r-- 1 root   root    5068800 Aug 22 15:48 linux-image-5.6.14-olimex.tar
-rw-r--r-- 1 root   root      61324 Aug 22 17:15 dmesg_200822_17Y15.txt
-rw-r--r-- 1 root   root       3303 Aug 22 17:23 dmesg_200822_17Y15_HDMI_audio_backtrace.txt
-rw-r--r-- 1 root   root        864 Aug 22 17:27 dmesg_200822_17Y15_Micrel_KSZ9031_Gigabit_PHY.txt
-rw-r--r-- 1 root   root       1949 Aug 22 17:31 dmesg_200822_17Y15_Micrel_KSZ9031_Gigabit_PHY_at017000.txt
-rw-r--r-- 1 root   root      51200 Aug 23 19:34 etc_network.tar
-rw-r--r-- 1 root   root     238028 Aug 23 19:39 syslog_200823_1937
root@a20-olinuxino:~#

And I had also mistyped a few "Enter" keys, because:

root@a20-olinuxino:~# cat /etc/default/locale
#  File generated by update-locale
LANG=en_GB.UTF-8
TIME_STYLE="posix-long-iso"







root@a20-olinuxino:~#

root@a20-olinuxino:~# vi /etc/default/locale

and corrected it:

root@a20-olinuxino:~# cat /etc/default/locale
#  File generated by update-locale
LANG=en_GB.UTF-8
TIME_STYLE="posix-long-iso"
root@a20-olinuxino:~#

Let's source that file:

root@a20-olinuxino:~# . /etc/default/locale
root@a20-olinuxino:~#

But it doesn't work for some reason:

root@a20-olinuxino:~# ls -ltr
total 42736
-r--r----- 1 root   root        669 Feb  2  2020 sudoers.O
-rw-r--r-- 1 root   root         40 Aug 20 15:49 interfaces.d.ethO
-rw-r--r-- 1 olimex olimex      320 Aug 20 16:14 aplay-l.txt
[...]
root@a20-olinuxino:~#


And it must look like:

root@a20-olinuxino:~# ls -ltr --time-style=long-iso
total 42736
-r--r----- 1 root   root        669 2020-02-02 07:41 sudoers.O
-rw-r--r-- 1 root   root         40 2020-08-20 15:49 interfaces.d.ethO
-rw-r--r-- 1 olimex olimex      320 2020-08-20 16:14 aplay-l.txt
-rw-r--r-- 1 root   root   38307840 2020-08-22 15:39 boot.tar
-rw-r--r-- 1 root   root    5068800 2020-08-22 15:48 linux-image-5.6.14-olimex.tar
-rw-r--r-- 1 root   root      61324 2020-08-22 17:15 dmesg_200822_17Y15.txt
-rw-r--r-- 1 root   root       3303 2020-08-22 17:23 dmesg_200822_17Y15_HDMI_audio_backtrace.txt
-rw-r--r-- 1 root   root        864 2020-08-22 17:27 dmesg_200822_17Y15_Micrel_KSZ9031_Gigabit_PHY.txt
-rw-r--r-- 1 root   root       1949 2020-08-22 17:31 dmesg_200822_17Y15_Micrel_KSZ9031_Gigabit_PHY_at017000.txt
-rw-r--r-- 1 root   root      51200 2020-08-23 19:34 etc_network.tar
-rw-r--r-- 1 root   root     238028 2020-08-23 19:39 syslog_200823_1937
root@a20-olinuxino:~#


This should do it:



root@a20-olinuxino:~# cat /etc/environment
root@a20-olinuxino:~# cat >> /etc/environment
TIME_STYLE="posix-long-iso"
root@a20-olinuxino:~# cat /etc/environment
TIME_STYLE="posix-long-iso"
root@a20-olinuxino:~#

It didn't. More tries...

root@a20-olinuxino:~# . /etc/environment
root@a20-olinuxino:~# echo $TIME_STYLE
posix-long-iso
root@a20-olinuxino:~# ls -ltr
total 42736
-r--r----- 1 root   root        669 Feb  2  2020 sudoers.O
-rw-r--r-- 1 root   root         40 Aug 20 15:49 interfaces.d.ethO
-rw-r--r-- 1 olimex olimex      320 Aug 20 16:14 aplay-l.txt
[...]
root@a20-olinuxino:~#

So how is this done??

I want:

root@a20-olinuxino:~# ls -l --time-style=long-iso
total 42736
-rw-r--r-- 1 olimex olimex      320 2020-08-20 16:14 aplay-l.txt
-rw-r--r-- 1 root   root   38307840 2020-08-22 15:39 boot.tar
[...]

root@a20-olinuxino:~# cp -iav /etc/environment  /etc/xdg
'/etc/environment' -> '/etc/xdg/environment'
root@a20-olinuxino:~# . /etc/xdg/environment
root@a20-olinuxino:~# ls -l --time-style=long-iso
total 42736
-rw-r--r-- 1 olimex olimex      320 2020-08-20 16:14 aplay-l.txt
-rw-r--r-- 1 root   root   38307840 2020-08-22 15:39 boot.tar
-rw-r--r-- 1 root   root       3303 2020-08-22 17:23 dmesg_200822_17Y15_HDMI_audio_backtrace.txt
-rw-r--r-- 1 root   root       1949 2020-08-22 17:31 dmesg_200822_17Y15_Micrel_KSZ9031_Gigabit_PHY_at017000.txt
-rw-r--r-- 1 root   root        864 2020-08-22 17:27 dmesg_200822_17Y15_Micrel_KSZ9031_Gigabit_PHY.txt
-rw-r--r-- 1 root   root      61324 2020-08-22 17:15 dmesg_200822_17Y15.txt
-rw-r--r-- 1 root   root      51200 2020-08-23 19:34 etc_network.tar
-rw-r--r-- 1 root   root         40 2020-08-20 15:49 interfaces.d.ethO
-rw-r--r-- 1 root   root    5068800 2020-08-22 15:48 linux-image-5.6.14-olimex.tar
-r--r----- 1 root   root        669 2020-02-02 07:41 sudoers.O
-rw-r--r-- 1 root   root     238028 2020-08-23 19:39 syslog_200823_1937
root@a20-olinuxino:~#


Wow! Finally... Phew!...


And now I'll try and see how it works if I reboot the system. If I were logged in over SSH, it would dump me and go without me, I wouldn't be able to see anything once the network is stopped.

root@a20-olinuxino:~# shutdown -r 0
Shutdown scheduled for Wed 2020-09-09 10:08:28 UTC, use 'shutdown -c' to cancel.
root@a20-olinuxino:~# [  OK  ] Started Show Plymouth Reboot Screen.
[  OK  ] Stopped Permit User Sessions.
[  OK  ] Stopped target Remote File Systems.
[  OK  ] Stopped target Network.
         Stopping ifup for eth0...
[...]
[  OK  ] Reached target Shutdown.
[  OK  ] Reached target Final Step.
[  OK  ] Started Reboot.
[  OK  ] Reached target Reboot.
[863736.990338] reboot: Restarting system

U-Boot SPL 2020.01+olimex-1-20200701.165703 (Jan 30 2020 - 11:10:18 +0000)
DRAM: 1024 MiB
CPU: 912000000Hz, AXI/AHB/APB: 3/2/2
Loading configuration from EEPROM: OK
Verifying data: OK
Trying to boot from MMC1


U-Boot 2020.01+olimex-1-20200701.165703 (Jan 30 2020 - 11:10:18 +0000) Allwinner Technology

CPU:   Allwinner A20 (SUN7I)
ID:    A20-OLinuXino-LIME2-s16M Rev.K
SN:    00005157
MAC:   30:1F:9A:D0:30:5A
I2C:   ready
DRAM:  1 GiB
SF: Detected w25q128 with page size 256 Bytes, erase size 4 KiB, total 16 MiB
MMC:   mmc@1c0f000: 0
Loading Environment from EXT4... OK
In:    serial
Out:   serial
Err:   serial
Allwinner mUSB OTG (Peripheral)
Net:   eth0: ethernet@1c50000
Warning: usb_ether using MAC address from ROM
, eth1: usb_ether
starting USB...
Bus usb@1c14000: USB EHCI 1.00
Bus usb@1c14400: USB OHCI 1.0
Bus usb@1c1c000: USB EHCI 1.00
Bus usb@1c1c400: USB OHCI 1.0
scanning bus usb@1c14000 for devices... 4 USB Device(s) found
scanning bus usb@1c14400 for devices... 1 USB Device(s) found
scanning bus usb@1c1c000 for devices... 1 USB Device(s) found
scanning bus usb@1c1c400 for devices... 1 USB Device(s) found
       scanning usb for storage devices... 0 Storage Device(s) found
Hit any key to stop autoboot:  0
=>
=>

And it stopped there. I mean I stopped it by hitting any key.

And now I hit Tab:

=>
  base bdinfo blkcache boot bootd bootefi bootelf bootm bootp bootvx bootz
  clrlogo cmp coninfo cp crc32 dfu dhcp ...
=>

Full control... Will just boot now.

=> boot

and it went on fast.

[...]
[  OK  ] Started Permit User Sessions.
[  OK  ] Started Authorization Manager.
         Starting Network Manager Script Dispatcher Service...
[  OK  ] Listening on Load/Save RF ...itch Status /dev/rfkill Watch.
         Starting Light Display Manager...
         Starting Hold until boot process finishes up...
         Starting LSB: Set sysfs variables from /etc/sysfs.conf...
[  OK  ] Started Network Manager Script Dispatcher Service.
[  OK  ] Started Modem Manager.
[  OK  ] Started LSB: Set sysfs variables from /etc/sysfs.conf.

Debian GNU/Linux 10 a20-olinuxino ttyS0

a20-olinuxino login:

Password:
Last login: Wed Sep  9 08:30:58 UTC 2020 on ttyS0
Linux a20-olinuxino 5.6.14-olimex #081742 SMP Fri Jul 31 08:18:08 UTC 2020 armv7l

The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
xset:  unable to open display ""
root@a20-olinuxino:~# ls -l
total 42736
-rw-r--r-- 1 olimex olimex      320 2020-08-20 16:14 aplay-l.txt
-rw-r--r-- 1 root   root   38307840 2020-08-22 15:39 boot.tar
-rw-r--r-- 1 root   root       3303 2020-08-22 17:23 dmesg_200822_17Y15_HDMI_audio_backtrace.txt
-rw-r--r-- 1 root   root       1949 2020-08-22 17:31 dmesg_200822_17Y15_Micrel_KSZ9031_Gigabit_PHY_at017000.txt
-rw-r--r-- 1 root   root        864 2020-08-22 17:27 dmesg_200822_17Y15_Micrel_KSZ9031_Gigabit_PHY.txt
-rw-r--r-- 1 root   root      61324 2020-08-22 17:15 dmesg_200822_17Y15.txt
[...]
That's all.