Jump to content

[Info] create SSH-Login for a serial device (here Z80-MBC2) using ser2net and a local User


guidol

Recommended Posts

The Z80-MBC2 is a 4-chip Z80-computer which can run CP/M and has a 5V TTL-serial-port.
The Z80-MBC2 is powered and accessable via a USB-TTL-serial-adapter (configured to 5V - not 3.3V) type CP2102 seen as /dev/ttyUSB0

 

The easy way would be to connect the USB-adapter to a Pi-style computer wth armbian, login via SSH and start minicom for the port.

But that way doenst look as good - to me - as the following way ;) 

 

First we need to install ser2net and telnet (telnet doesnt seem to be installed as standard) in armbian via

apt install ser2net telnet

 

Then we have to edit /etc/ser2net.conf (delete all lines after the comments and insert these):
 

BANNER:banner:\r\nser2net port \p device \d [\s] (Debian GNU/Linux)\r\n\r\n
BANNER:z80mbc2:\r\nZ80-MBC2 via Telnet on Port [\p]\r\nDevice connected to         [\d]\r\nConnection Speed            [\s]\r\n


# 2000:telnet:600:/dev/ttyS0:9600 8DATABITS NONE 1STOPBIT banner
# 2001:telnet:600:/dev/ttyS1:9600 8DATABITS NONE 1STOPBIT banner
# 3000:telnet:600:/dev/ttyS0:19200 8DATABITS NONE 1STOPBIT banner
# 3001:telnet:600:/dev/ttyS1:19200 8DATABITS NONE 1STOPBIT banner
127.0.0.1,2023:telnet:0:/dev/ttyUSB0:115200 8DATABITS NONE 1STOPBIT z80mbc2

 

Now create a login "shell"/pogram for the new local user z80mbc2 as /usr/local/bin/z80mbc2 :
 

#!/bin/sh
/usr/bin/telnet 127.0.0.1 2023
exit

Do a chmod 755  /usr/local/bin/z80mbc2

 

Now we can create the new local user z80mbc2 as seen on
http://www.lug-wr.de/wiki/index.php/Howto:Network:SerialConsoleServer
 

adduser --shell /usr/local/bin/z80mbc2.sh -q z80mbc2

 

If you havent done - connect your TTL-USB-Dongle to your SBC - and it should show up as /dev/ttyUSB0 :

[354660.047087] usb 7-1: Product: CP2102 USB to UART Bridge Controller
[354660.047099] usb 7-1: Manufacturer: Silicon Labs
[354660.047109] usb 7-1: SerialNumber: 0001
[354660.112318] usbcore: registered new interface driver usbserial_generic
[354660.112414] usbserial: USB Serial support registered for generic
[354660.131499] usbcore: registered new interface driver cp210x
[354660.131617] usbserial: USB Serial support registered for cp210x
[354660.131902] cp210x 7-1:1.0: cp210x converter detected
[354660.141405] usb 7-1: cp210x converter now attached to ttyUSB0



Now its time to reboot your SBC (I used my NanoPi K1 Plus) via
reboot 

to automatically let start ser2net-service while booting

 

Now when you connect to your SBC via SSH and use the z80mbc2 User to login, you should generate a automatic and local (127.0.0.1) telnet-login to Port 2023 where /dev/ttyUSB0 a.k.a the Z80-MBC2 device is configured.

 

PS: other (german) interesting Page about ser2net:
http://www.nwlab.net/tutorials/ser2net/konsolenserver-linux.html

 

Z80-MBC2_SSH.thumb.jpg.4ec15265cb1cd4401804be280dd4ebeb.jpg

 

Z80-MBC2_blue_800px_1.thumb.jpg.e1af9c3784611b53d5b8326b4c62ccd6.jpg

Z80-MBC2_SSH_Ser2Net.zip

Edited by guidol
added 127.0.0.1 - only localhost - to port 2023
Link to comment
Share on other sites

If you want to use a "real" Terminal - instead of SSH / Ser2Net- like the TTGO VGA32 FabGL ANSI-Terminal and you dont have a 3.3V <-> 5.0V logic level converter available then using the NanoPi K1 Plus (or any other armbian device with 2 USB-ports) as a "mediator" may be possible using the "socat"-command ;) 

 

To use socat we should disable (disable for every boot or stop until the next boot) the ser2net service:
 

Usage: /etc/init.d/ser2net {start|stop|restart|reload|force-reload|status}
sudo service ser2net restart
sudo service ser2net stop
sudo service ser2net start

sudo systemctl disable ser2net
sudo systemctl enable ser2net

 

We do connect 2 USB-TTL-serial-Adapters to the SBC (one for 3.3V TTL-Level and one for 5V TTL-Level).
Via software (socat = apt install socat) we tie them together:
 

socat /dev/ttyUSB0,raw,echo=0,crnl,b115200 /dev/ttyUSB1,raw,echo=0,crnl,b115200

 

For the correct backspace-function the FabGL-ANSI-Terminal has to be in "ANSI Legacy"-Mode, because in normal "ANSI"-Mode the backspace-key doenst work right with the output of the Z80-MBC2 ;) 

 

Z80-MBC2_USB_socat.thumb.jpg.a724254c6d903b385bf742a85e4dac6a.jpg

Logic_Level_converter.png.57b60c8d9ef44f8eb282a8cff655e593.png

Link to comment
Share on other sites

On 3/21/2021 at 9:52 AM, guidol said:

Then we have to edit /etc/ser2net.conf 

In the newer version of ser2net (like v4.3.3-1) the /etc/ser2net.conf is replaced

by the /etc/ser2net.yaml which has the yaml-format :(

 

OK - here is a working version in yaml-format:

 

# A fully featured configuration file is in
# /usr/share/doc/ser2net/examples/ser2net.yaml

define: &banner \r\nZ80-MBC2 via Telnet on Port [\p]\r\nDevice connected to         [\d]\r\n

connection: &z80mbc2
    accepter: telnet(rfc2217),tcp,2023
    enable: on
    options:
      banner: *banner
      kickolduser: true
      telnet-brk-on-sync: true
    connector: serialdev,
              /dev/ttyUSB0,
              115200n81,local

 

Link to comment
Share on other sites

This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...

Important Information

Terms of Use - Privacy Policy - Guidelines