MiSTer-devel / Main_MiSTer

Main MiSTer binary and Wiki
GNU General Public License v3.0
3.03k stars 328 forks source link

Connect minimig (or ao486) serial to arbitrary serial device on Linux #202

Open clarkema opened 4 years ago

clarkema commented 4 years ago

Hi,

I'm trying to use the Amiga core to connect to some dial-up BBSes. To do this the Amiga needs access to a real modem, but none of the current UART modes seem suitable for this.

Is it / would it be possible to have a UART mode that just bridges the Amiga's serial.device to an arbitrary serial device on the Linux host? This would allow the core to be connected to a wide range of hardware, using socat to bridge remote serial ports (or network connections...) from another machine onto the MiSTer, or even via USB->serial adapters in the future.

Thanks!

sorgelig commented 4 years ago

it's already implemented: http://www.atari-forum.com/viewtopic.php?f=117&t=33507

clarkema commented 4 years ago

I must be missing something. At the moment (ignoring MIDI) I can see two possible options.

'PPP' binds serial.device to /dev/ttyS1 on Linux, but also starts pppd (which I don't want) and provides no way to change which device the Amiga serial port is bound to.

'Console' binds directly to the Linux console. If I start NComm on the Amiga I see the MiSTer prompt and can login and do terminal stuff, but that's also not what I'm looking for.

What I want to be able to do is use socat to create a new serial device on the linux side (e.g., /dev/ttyR0) which is connected to some network stream to another remote machine; then I'm imagining an option in the OSD which allows me to specify that I want to bind serial.device on the Amiga to my new /dev/ttyR0 on Linux.

I guess it might be possible to go the PPP route, manually kill pppd to get it to relinquish control of /dev/ttyS1 and then use a second socat process to link that to the new serial device, but that seems a bit hacky.

clarkema commented 4 years ago

It looks like I might be able to do the above by linking directly to /dev/ttyS1 with UART mode set to none -- I'm going to explore that a bit and experiment with some different socat incantations.

clarkema commented 4 years ago

I now have NComm running within the minimig core talking to a USB modem plugged in to a modern Linux host on the same local network; I can issue commands like 'ATZ' and 'ATDT123456' on the Amiga, and the modem responds and dials correctly.

This requires 3 separate invocations of socat.

  1. On the main, non-MiSTer Linux host (the machine with the modem attached) run:
sudo socat tcp-listen:8000,reuseaddr,fork file:/dev/ttyACM0,nonblock,waitlock=/var/run/tty0.lock,b115200,raw,echo=0

to share /dev/ttyACM0 over the network.

  1. On the Linux side of the MiSTer, first run
socat pty,link=/dev/ttyR1,waitslave tcp:192.168.1.10:8000

to connect to the shared serial port on the main machine and make it available as a new character device /dev/ttyR1

  1. Now we have /dev/ttyR1 on the MiSTer; you should be able to open it using minicom, enter ATZ and get a response from the modem. However, the cores only have access to /dev/ttyS1. A third socat invocation is used to bridge the two together:
socat open:/dev/ttyS1,raw,echo=0,crnl open:/dev/ttyR1,raw,echo=0,crnl
  1. On the core OSD, set UART mode to console.
  2. On the 'Amiga', open up NComm, select the appropriate baud rate and hit enter and you should see the MiSTer login prompt.
  3. Back in the OSD, set UART mode to 'None'.
  4. And finally now in NComm you can enter ATZ and get back the magic OK

Setting UART mode to console and then to none is required; it doesn't seem to be connected if you start off as none. This little dance links the minimig core to /dev/ttyS1 and then (presumably) removes the getty but leaves the serial link in place.

So finally it does work, although it feels a little inelegant. I'd be very grateful for any pointers on how to do this in a less kludgy manner.

sorgelig commented 4 years ago

You simply should use PPP connection. Then install some TCP/IP stack on Amiga like AmiTCP and then you will get internet connection over MiSTer ethernet/WiFi. No modems required.

clarkema commented 4 years ago

The whole point is that I don't want PPP or TCP; I'm not connecting to the Internet. I want to connect to a serial device so that I can dial in to an actual dial-up BBS. I think this setup should work, but need to wait until the BBS opens later tonight for final confirmation.

sorgelig commented 4 years ago

i see.. It's funny dialup BBS is still working somewhere.

clarkema commented 4 years ago

Well, they're certainly not common! Just to confirm for anyone else searching, the above method does indeed work -- I've just used it to dial up a BBS from the minimig core and it worked perfectly.

bbond007 commented 4 years ago

To dial a BBS you can simply set the OSD to:

UART : MIDI MidiLink : Remote Type : TCP

ATDT HOSTNAME:PORT

The modem "AT" commands are documented here --> https://github.com/MiSTer-devel/MidiLink_MiSTer

rsn8887 commented 4 years ago

He wanted to dial over a phone line with a modem, not telnet. It is really cool that it works and that dial up bbs‘ still exist.

bbond007 commented 4 years ago

He wanted to dial over a phone line with a modem, not telnet. It is really cool that it works and that dial up bbs‘ still exist.

In that case, alternately, you could connect the MiSTer directly to the modem using an inexpensive USB to serial adapter.

The main issue is that you'll have to build the module ".ko" appropriate to your adapter as this is not part of the kernel.

Edit "/media/fat/linux/Midilink.INI"

USB_SERIAL_MODULE   = /media/fat/linux/modules/pl2303.ko

This functionality is not currently exposed in the OSD, so to start via SSH:

uartmode 0

midilink USBSER BAUD 115200

bbond007 commented 4 years ago

Here is another (very simple) idea I just thought of.

I now have NComm running within the minimig core talking to a USB modem plugged in to a modern Linux host on the same local network; I can issue commands like 'ATZ' and 'ATDT123456' on the Amiga, and the modem responds and dials correctly.

This requires 3 separate invocations of socat.

  1. On the main, non-MiSTer Linux host (the machine with the modem attached) run:

sudo socat tcp-listen:8000,reuseaddr,fork file:/dev/ttyACM0,nonblock,waitlock=/var/run/tty0.lock,b115200,raw,echo=0

With the Amiga core set OSD to: UART : MIDI MidiLink : Remote Type : TCP

Use Ncomm @ 115200

"ATDT192.168.1.XXX:8000"

or even "ATDTHOSTNAME:8000"

it will be like dialing/connecting twice, but then you won't need to use the SSH or console to set things up...

Venomtek commented 2 years ago

It's amazing how people keep saying to use TCP when the OP clearly states dial up over POTS/voip. Telling us to "just use TCP" is akin to me telling you "just use an emulator". There is a reason you use FPGA, and there is a reason we use actual hardware modems.

Now that more serial<>usb drivers have been added to the MiSTer:

Re: MiSTer updates and changelog Post by Sorgelig » Sun Jul 11, 2021 12:26 pm Linux:

  • Add support for DualSense (PS5) controller.
  • enable CH341 and PL2303 USB serial drivers.
  • Update SSL certificate to latest.

Has anyone tried this again? Has any work been done to simplify it? Dial up BBSs are actually quite common, I use them all the time. And I am planning on running either an Amiga, C64 or DOS BBS on the MiSTer. I also have 3 voip lines with 3 modems just sitting and waiting for people to call up for the people who want to experience such a thing.

Here is a good list: https://ramsaso.com/ Here is another list: https://www.telnetbbsguide.com/bbs/connection/dial-up/list/brief/

I can access my modem from Dosbox, Vice, Applewin and a multitude of other emulators. How is it the mighty MiSTer can't do this easily? I would say it's as much fun and nostalgic as playing old games, especially since most BBSs have door games. My MiSTer has not arrived yet, so I haven't been able to play around with this. If anyone has had any success please let me know!

sorgelig commented 2 years ago

ao486 supports UART (COM2) on USER I/O. So with proper level shifters on USER I/O you can connect modem directly without using Linux.

bbond007 commented 2 years ago

You can also select UART/MODEM/SERIAL and connect your modem with an inexpensive USB serial adapter. I tested this a while back using an inexpensive FT232 device.

Venomtek commented 2 years ago

You can also select UART/MODEM/SERIAL and connect your modem with an inexpensive USB serial adapter. I tested this a while back using an inexpensive FT232 device.

This is exactly what I wanted to hear! I have several adapters with the Prolific PL2303HXD and PL2303RA and one with CH341 chipsets which have been added to the kernel recently, so they should work like a charm I hope.

Thank you for your suggestion, I'll post a record of the entire process once my board arrives so hopefully this issue can be closed.

ao486 supports UART (COM2) on USER I/O. So with proper level shifters on USER I/O you can connect modem directly without using Linux.

Thank you for the suggestion. I'm hoping to use it on more than just the ao486 core though if possible.

Venomtek commented 2 years ago

So, no longer an issue? External modem works great!

bandicam 2021-11-17 00-44-26-400

mpv-shot0016

mpv-shot0015

terminal3 commented 2 years ago

I am looking at the same scenario and have found the pinouts for USER I/O to use with an RS-232 module which handles voltage differences. Could someone who has gotten this working (via USER I/O or USB serial adapter) share their hardware connections and core configuration? Is this documented elsewhere?

bbond007 commented 2 years ago

@terminal3

I really can't help you with the User I/O configuration other than to confirm you'll need a Max232 (or something) to convert the voltages. Hopefully somebody else can give you more info on that...

For the USB option, you'll need a USB serial cable based on the FT232 chip.

When this is cable is detected you'll get an additional OSD UART option UART:Modem:USB Serial.

Hope that helps...

waldoalvarez00 commented 8 months ago

You can also select UART/MODEM/SERIAL and connect your modem with an inexpensive USB serial adapter. I tested this a while back using an inexpensive FT232 device.

Can you please share some details on how to do it, I need it to output debug info over serial line but once the cyclone V is programmed, the Linux side is rebooted as well and connection with the development computer lost. Therefore preventing watching debug messages from the BIOS. Connecting FT232 to the de10 nano and connecting TX and RX to the module would help capture debug messages as the machine boots. Would make a great development addon for the Mister btw.