Serial console without modding the Pi

1,798 views
Skip to first unread message

James L-W

unread,
May 8, 2016, 7:46:26 AM5/8/16
to PiDP-8
Hi all,

I picked up a shiny new Pi 3 to drive my PiDP, and didn't really want to get at it with a soldering iron just yet... I found that with some tweaks, it's possible to overcome the I2C pullups and scan out the switches quite reliably.

Shorting the three row resistors gets you most of the way there, but not at all reliably - the 390R column resistor plus the diode drop are just a bit much. It turns out that the GPIO pads have a Schmitt trigger input, which can be bypassed; without hysteresis, Vih is low enough to sense correctly.

The necessary mods are:
1. replace the three row resistors with 100 ohms
2. patch gpio.c to disable hysteresis (patch follows).

100 ohms *should* be enough to avoid frying the LEDs if you mess up the programming and drive both the switch and LED rows simultaneously.

I then also found that the Pi 3 has changed over the serial port from ttyAMA0 to ttyS0, and that the latter is clocked from the core clock - so if clock scaling is enabled (which it usually is) then the port baud rate is all over the shop. With the latest firmware you can add enable_uart=1 to /boot/config.txt; on a Pi 3 this will lock the core clock, and on older models it is a no-op. Another option is to set force_turbo=1 which will lock the core at max - if you can spare the heat & power.

I'd be curious to hear if this works on earlier Pis as well.

Cheerio,
James


--- snip ---

--- pidp8/src/gpio.c    2015-12-16 08:49:26.000000000 +1100
+++ gpio_pads.c    2016-05-08 20:24:57.286266930 +1000
@@ -29,6 +28,7 @@
 static unsigned get_dt_ranges(const char *filename, unsigned offset); // Pi 2 detect
 
 struct bcm2835_peripheral gpio;    // needs initialisation
+struct bcm2835_peripheral pads;    // needs initialisation
 
 long intervl = 300000;        // light each row of leds this long
 
@@ -113,6 +113,12 @@
         return (void *)-1;
     }
 
+    // Disable the hysteresis on the GPIO inputs
+    #define BCM2835_GPIO_PADS 0x100000
+    pads.addr_p = bcm_host_get_peripheral_address() + BCM2835_GPIO_PADS;
+    map_peripheral(&pads);
+    pads.addr[0x2c/4] = (pads.addr[0x2c/4] & 0xf7) | (0x5A << 24);
+
     // initialise GPIO (all pins used as inputs, with pull-ups enabled on cols)
     //    INSERT CODE HERE TO SET GPIO 14 AND 15 TO I/O INSTEAD OF ALT 0.
     //    AT THE MOMENT, USE "sudo ./gpio mode 14 in" and "sudo ./gpio mode 15 in". "sudo ./gpio readall" to verify.

Oscar Vermeulen

unread,
May 8, 2016, 8:04:29 AM5/8/16
to James L-W, PiDP-8
James,

On 8 May 2016 at 13:46, James L-W <soul.cake.t...@gmail.com> wrote:
100 ohms *should* be enough to avoid frying the LEDs if you mess up the programming and drive both the switch and LED rows simultaneously.

I set the resistor values as high as possible - as conservative as possible. So lowering them should be completely OK like you say!
You're right - if this eliminates the need to remove the two resistors on the Pi for the Serial Mod, it's probably well worth it.

Another idea that I was slow to come up with is to use two USB-to-Serial cables, connected to each other (RX-TX and TX-RX). That would be a plug-in connection to any PC. For that you need to configure for a console to ttyUSB0 on the PiDP. As these cables are about $4 each, it's a very simple thing.

Kind regards,

Oscar.

Neil Higgins

unread,
May 9, 2016, 1:53:16 AM5/9/16
to PiDP-8
"I then also found that the Pi 3 has changed over the serial port from ttyAMA0 to ttyS0, and that the latter is clocked from the core clock - so if clock scaling is enabled (which it usually is) then the port baud rate is all over the shop. "

Sure it's ok for a baud rate generator to be "all over the place" (not!) I wonder what genius had that idea? The hurried progress of the BCM series, and the corresponding rush from Pi 2 to Pi 3, were always going to be grounds for wondering what mistakes had slipped through the cracks.

AB

unread,
May 9, 2016, 9:14:55 AM5/9/16
to PiDP-8, soul.cake.t...@gmail.com
Hi guys- does anyone have an idiot-proof example of how a ttyUSB would be configured in (say) 2.script?  (located in /opt/pidp8/bootscripts)
cheers!
andy b

Dylan McNamee

unread,
May 14, 2016, 11:22:14 PM5/14/16
to PiDP-8
James,

I'd like to try your alternate serial mod on my RPi 2 model B. Just to clarify the instructions, I replace the 3 x 1K resistors with 100 ohm resistors, right? Do I still need to cut the traces on the PiDP/8 board? Do I still install the X (=500) and 2*X (=1K) resistors?

I'm guessing not, and also that I don't need to recompile pidp8 with the serialmod compile flag, is that correct?

thanks, this will be nice!
dylan

Dr. James

unread,
May 14, 2016, 11:43:23 PM5/14/16
to Dylan McNamee, PiDP-8
On Sat, May 14, 2016 at 08:22:13PM -0700, Dylan McNamee wrote:
> I replace the 3 x 1K resistors with 100 ohm resistors, right?

Yes.


> Do I still need to cut the traces on the PiDP/8 board?

Yes, and jumper them to the other side. The default connections use the
serial port lines for scanning the matrix. This is also reflected in the
SERIALSETUP compile flag, which you will need to supply.


> Do I still install the X (=500) and 2*X (=1K) resistors?

Yes. These are a voltage divider to turn a 5V TTL input from external
device into ~3.3V safe levels for the Pi. You won't receive anything
without them.


> I'm guessing not, and also that I don't need to recompile pidp8 with the
> serialmod compile flag, is that correct?

You need both SERIALSETUP and the patch I posted that adjusts the
levels.

Good luck! Excited to hear how you go.

Cheerio,
James

Dylan McNamee

unread,
May 24, 2016, 5:16:32 PM5/24/16
to PiDP-8, dylan....@gmail.com
It's 100% working great. Yahoo! It's very nice to not have to modify the Pi.

thanks for doing this!
dylan 

Peter Willard

unread,
May 25, 2016, 8:28:29 AM5/25/16
to PiDP-8
The really easy way to get serial without modding.

1) Get a USB serial adapter.  I had a Parallax adapter handy --> http://www.robotshop.com/en/parallax-usb-to-serial-rs-232-adapter.html.  It shows up as a ttyUSB0.
2) Edit /boot/cmdline.txt  so it looks pretty much like this:

dwc_otg.lpm_enable=0 console=ttyUSB0,9600 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait

3) Attach a nice RS232 terminal... in my case I had a VT220 handy.  Set it up for 9600 baud (or for closer to reality 'legacy' speeds, 300 or 1200 baud)    ;-)

Reboot and you have a serial console, 1 less USB adapter and no need to solde.

 
 

Oscar Vermeulen

unread,
May 25, 2016, 9:09:34 AM5/25/16
to Peter Willard, PiDP-8
Peter,

To add to your suggestion:

The easiest way to hook up the PiDP to your PC-as-a-terminal is two of these USB-serial cables wired together. One USB goes into the PC, the other in the PiDP. Wire them so that RX and TX are crossed as a nullmodem. And do not connect the red 5V wire, just GND, TX, RX.

At about $2 per cable (PL2303 cables on Aliexpress) including shipping, it's affordable.


The other thing: in the new Raspbian distributions (Jessie, also pipaOS) your changes will not work anymore, because Raspbian moved to an initd boot setup. The setup steps to get a USB-to-Serial cable started up with a console are now:

1. Copy the file 'serial-getty@.service' from '/lib/systemd/system' to
  •  '/etc/systemd/system' (for standard Raspbian)
  •  '/etc/systemd/system/xyz' - where xyz is a 'wants' subdirectory whose exact name I forgot, but it'll be obvious.
This file is a generic template for setting up a serial terminal with a log-in prompt.

2. The file must be renamed, so that it points to your serial terminal which will be ttyUSB0. The filename becomes:
'serial...@ttyUSB0.service'

3. The file may need to be edited with the parameters of your serial terminal, or the default setting may work.
In my case I changed the first line in the [Service] section to read:
ExecStart=-/sbin/agetty ttyUSB0 9600 vt100

4. Now, enable the service with:
'sudo systemctl enable serial...@ttyUSB0.service'
You should get a 'Creating sim link ....' message. The service will now start up at every boot.

Reboot. I agree - this setup is the ideal way to communicate with the PiDP. No networking needed.


Kind regards,

Oscar.

Peter Willard

unread,
May 25, 2016, 9:53:06 AM5/25/16
to PiDP-8, petew...@gmail.com

Thank you for the update.  My method is only good for quick and easy single TTY.

Your method is scalable. 

Chris Smith

unread,
May 25, 2016, 6:59:10 PM5/25/16
to PiDP-8, petew...@gmail.com
In hindsight, it's too bad the Pi doesn't do this by default with the power USB connector.

A Pi running with no networking (no Ethernet, no WiFi) has power consumption well within what a standard USB port should be able to deliver. I'm not certain what the front panel consumes, but scanning panels (as opposed to static lit panels) often have very lower consumption.

It's even possible that you could take the data connections and ground from the back to back USB serial solution, and route it out through a carefully wired Y-adapter which also connects to the power port. This would give you a PiDP8 which has exactly one USB connection that you plug into your computer.

It doesn't get much cleaner than that.

I will want to keep my networking and video options open, but I can see using the back-to-back serial and routing the extra USB "client" port to the back panel.

... Chris

Oscar Vermeulen

unread,
May 25, 2016, 8:03:57 PM5/25/16
to Chris Smith, PiDP-8, Peter Willard
Chris,

On 26 May 2016 at 00:59, Chris Smith <cjs...@gmail.com> wrote:
In hindsight, it's too bad the Pi doesn't do this by default with the power USB connector.

You mean 'backfeeding' 5V from the normal USB connectors into the Pi? It's reputed to work but I got poor results.

But if you mean you get the PiDP's power from the USB-Serial cable -- yes, I do it all the time. First with the 'serial mod', which basically allows you to use the USB serial cable with the serial end of it plugged into the PiDP.
That needs no other power source for a Model A+ or B+. The Pi 2 and 3 are too power hungry to work reliably like that, they need their own power supply. 

But with this setup of a USB-Serial cable in your PC, hooked up to an identical cable in your Pi's USB port, you can still route the 5V from the PC end into the PiDP's power pins. And thus, have only 1 cable to rule the PiDP. As long as you use a B+/A+...

 

A Pi running with no networking (no Ethernet, no WiFi) has power consumption well within what a standard USB port should be able to deliver. I'm not certain what the front panel consumes

Almost nothing. Easily fits into a USB's 0.5A power budget together with the Model B+/A+. Or Zero.

 
It's even possible that you could take the data connections and ground from the back to back USB serial solution, and route it out through a carefully wired Y-adapter which also connects to the power port. This would give you a PiDP8 which has exactly one USB connection that you plug into your computer.

It doesn't get much cleaner than that.

Precisely! That's what I do all the time.

Kind regards,

Oscar.

AB

unread,
May 29, 2016, 10:38:59 PM5/29/16
to PiDP-8, petew...@gmail.com
Hi Oscar- sorry for dumb question -will this approach work for (say) a keyspan usb using your standard pipaos image?

I followed your notes below but I assume I do nothing here for pipaos right?


  •  '/etc/systemd/system/xyz' - where xyz is a 'wants' subdirectory whose exact name I forgot, but it'll be obvious.

And of course I still have all the attach ttix /dev/ttyusb0 stuff as well?

cheers!
andy b



On Wednesday, May 25, 2016 at 9:09:34 AM UTC-4, Obsolescence wrote:

Obsolescence

unread,
May 31, 2016, 9:15:09 AM5/31/16
to PiDP-8, petew...@gmail.com
Andy,


On Monday, May 30, 2016 at 4:38:59 AM UTC+2, AB wrote:
will this approach work for (say) a keyspan usb using your standard pipaos image?

I don't know the keyspan USB-serial cable. I only used the (cheap, Chinese made) PL2303 and FTDI USB serial cables. Both of these are supported with drivers in the standard Raspbian, so no need to install any drivers. If that's true for your USB-cable, it will work.

I followed your notes below but I assume I do nothing here for pipaos right?

  •  '/etc/systemd/system/xyz' - where xyz is a 'wants' subdirectory whose exact name I forgot, but it'll be obvious.

For pipaOS you need to copy the file to the above-mentioned directory - pipaOS needs to have the file in that 'wants' subdirectory Normal Raspbian needs it in /etc/systemd/system itself (the parent directory). I hate this new initd stuff in Raspbian Jessie, although I understand the benefits it brings...


And of course I still have all the attach ttix /dev/ttyusb0 stuff as well?

Err - not sure. I would think that approach needs ttyUSB0 for itself, it might not like it when ttyUSB0 is already tied up with a Linux console before simh ever gets a chance to claim it. My approach just gives you a second 'generic' console port for linux. Which is then happily used by the pidp as well.

Adding a (second) terminal to TSS/8 using ttix in simh just makes TSS/8 aware of a second terminal for its own use. That's a different thing of course.

Kind regards,

Oscar.

AB

unread,
May 31, 2016, 10:05:42 PM5/31/16
to pid...@googlegroups.com, petew...@gmail.com
Hi Oscar, thanks for the tips.... but I am still not there yet......  OK so I copied

serial...@ttyUSB0.service to
/etc/systemd/system/multi-user.target.wants


that's the right directory?  The folder options are

getty.target.wants
poweroff.target.wants
sshd.target.wants
multi-user.target.wants
halt.target.wants
reboot.target.wants
sysinit.target.wants

Anyway I then enabled the service and rebooted.

I did this with my keyspan and repeated with one of my serial-to-USB Prolifics. Connected to my old faithful Dell laptop with serial port using Putty.

Also tried this with and without the attach ttix ttyusb0 and so forth commands in 2.script.

I am doing this on a "fresh" version of Option 1 image

I feel like I am on the threshold of this working.... but something ridiculously small is holding me back (lack of knowledge :-))

cheers!
Andy

Kurt Hamm

unread,
Jun 15, 2016, 10:38:32 PM6/15/16
to PiDP-8
I have a VT220 that I am trying to get working with a prolific adapter.  I copied:


serial...@ttyUSB0.service to 
/etc/systemd/system/getty.target.wants  (Not Multi-user).

I don't get any response on the terminal.  I see other changes to bootscripts in other posts.  Is that necessary?

What  are the correct settings on the VT220?  I don't see handshaking as an option to turn off.  8-N-1?

I will keep plugging as well.  I would love to see this old terminal working.

Thanks, Kurt

AB

unread,
Jun 16, 2016, 7:55:52 AM6/16/16
to PiDP-8
Hi Kurt - so you didn't modify the 0.script or 2.script file adding line(s) similar to

  attach ttix Line=1 Connect=/dev/ttyUSB1;300-8n1

correct?

(I tried both ways but without luck)

cheers
Andy

Kurt Hamm

unread,
Jun 16, 2016, 8:49:44 AM6/16/16
to PiDP-8
Yep, I tried both ways.  I tried things with the 0.script and the 2.script.  My USB looks like ttyUSB0, not USB1. 

It could be any number of things, but I should at least be getting garbage if the Pi is setup correctly.

Kurt

Kurt Hamm

unread,
Jun 16, 2016, 10:08:46 AM6/16/16
to PiDP-8
I think, like you say, we are both missing something relatively minor, but readily apparent to others more knowledgeable.  ha!

Kurt

AB

unread,
Jun 16, 2016, 10:57:44 AM6/16/16
to PiDP-8
lol i think you're right.

I am half expecting Oscar to ask me "Andy- you DID install the parkinised flange sprocket beforehand right?!" :-)

 cheers... Andy

Peter Willard

unread,
Jun 16, 2016, 6:56:54 PM6/16/16
to PiDP-8
Kurt, 


My method above (using the config files in boot partition) was done with a VT220 if you want the truly easy way to do it.

Kurt Hamm

unread,
Jun 16, 2016, 7:53:06 PM6/16/16
to PiDP-8
doh, I thought that I needed to follow Oscar's instructions right after your post because I was running Pipos.  

I did make the change and reboot, but no joy.  what settings did you use on the VT220?  I attached pictures of my vt220 settings.  I am running with the serial mod if that makes  difference.

After all my machinations and changes, I have probably messed something up.

Here is the output from Setserial:
sudo setserial -g /dev/ttyUSB0
/dev/ttyUSB0, UART: unknown, Port: 0x0000, IRQ: 0, Flags: low_latency
VT220config1.jpg
VT220config2.jpg

Kurt Hamm

unread,
Jun 16, 2016, 8:10:02 PM6/16/16
to PiDP-8

Now, I do have this set I purchased in case I needed it, but I have no idea which color lead on the USB cable goes to which post on the RS-232 board.

Kurt
unnamed.jpg

Kurt Hamm

unread,
Jun 16, 2016, 8:18:37 PM6/16/16
to PiDP-8
scratch that cable.  It has a female  connector and I don't have a 9 pin gender changer.  shame on me.

...there is one around here somewhere.....

Kurt

Peter Willard

unread,
Jun 17, 2016, 1:46:57 PM6/17/16
to PiDP-8

Oh, I didn't do the serial mod.  I just attached a USB/Serial adapter.

AB

unread,
Jun 17, 2016, 5:52:33 PM6/17/16
to pid...@googlegroups.com
Hi Peter  - do you happen to recall what files you modified or configurations you performed when you plugged in your serial adapter?  One of the scripts like 0.script or 2.script?
cheers!
Andy B

Kurt Hamm

unread,
Jun 20, 2016, 6:35:36 PM6/20/16
to PiDP-8
Well, I  got it working.  The entire issue seemed to be my cable.  I bought one specifically for this.  It was USB to 9 pin serial with a 9 to 25 pin adapter.

I bought these items as a backup just in case my other new cable didn't work:

I used the 9 to 25 pin adapter that can with the new cable and nothing would work.  I finally tried an old 9 to 25 pin adapter that I had laying around the the terminal jumped to life.  I have attached some pics to show the adapter and where I plugged  what into where.

Now, as to PI configuration.  I do have the /boot/cmdline.txt change made as listed above.  I also performed the steps recommended by Oscar above.  I should mention that I was running Pipos (?), but I reinstalled a new Raspian instance on a spare microSD and installed the Pidp8 software from scratch. 

Andy, I  sure hope you get yours going.  As everyone mentioned, it should just work.  Once I got the right cabling, it just started to work.

Kurt
vt220a.jpg
vt220b.jpg
vt220c.jpg

AB

unread,
Jun 22, 2016, 3:19:32 PM6/22/16
to PiDP-8
Hi Kurt, have ordered these items from Ali express... will report back about how I get on :-)
Andy

Kurt Hamm

unread,
Jul 22, 2016, 5:11:29 PM7/22/16
to PiDP-8
OK, now I am trying to get fancy.  Bought this RCA/QWist terminal printer and trying to get it to work on PIDP-8.  I think it can only talk 7 bits even parity.  I have attached the configuration pages that I think are relevant to configuration.

Where can I change the Serial settings on the Pi?  Does this device look compatible?

Thanks for any assistance.  I have tried to change what I could and haven't gotten a peep from the printer.

Kurt
IMG_0455.JPG
IMG_0456.JPG
IMG_0457.JPG
IMG_0458.JPG
IMG_0459.JPG
IMG_0460.JPG

sunnyboy010101

unread,
Jul 26, 2016, 1:43:08 PM7/26/16
to PiDP-8, petew...@gmail.com

Oscar,

Just to confirm your post and Peter's...

You are saying that the changes posted above REPLACE Peter's suggestion to change the line in /boot/cmdline.txt ? That cmdline.txt no longer works? Or do we do Peter's change to cmdline.txt AND also do the changes you recommend above?

I'm confused because I'm at the stage of having my serial terminal  stuff 'almost' working. That is, the terminal is verified working and can communicate to a PC and vice versa, plus the R-PI USB-serial cable is also installed and available (/dev/ttyUSB0 is there and setserial reports accurate info). However, when I try to use a program like minicom on the Rpi it does not successfully communicate with the terminal. It is not an issue with connections or null modems or such (been there many years ago), but rather just wanting to confirm the Raspbian setup for the serial-usb.

Also - what exactly is the console stuff (either in cmdline.txt or your procedure) actually doing? My thinking is this is setting up a serial boot console much like one would have on an older computer (like my old SUN V440 that did 'first boot' only via serial console).

Thanks.

w9gb

unread,
Jul 26, 2016, 5:16:14 PM7/26/16
to PiDP-8
Kurt -

Well this is a "Back to the Future" moment .....
the RCA terminal has MANY options (flexble, but complicated if unfamiliar with that era).

1. Your RCA appears to be 7-bit only (no option for 8-bit).

2. You can change the RCA's PARITY to EVEN, ODD, NO.

3. The Serial option is either simple 3-wire (TxD, RxD, GND) or FULL RS-232 (CTS/RTS, hardware flow controls).
START with the 3-wire option -- easier and with USB/RS-232 conversions you are performing -- less headaches.

slob

unread,
Jul 27, 2016, 12:57:00 PM7/27/16
to PiDP-8

Where did you get this??? I worked for that company and probably wrote a good part of the manual that you are using. I assure you that it can connect to darned near anything up to 9600 baud, 7,8, maybe even 5 bits, even, odd, marking, or spacing. Depending on exactly what model you have, the settings were in battery backed RAM or in WAROM (which was known to poop out).

I have the service manual (I wrote that entirely); I used it to repair mine 25+ years later!

I have my Qwint on loan to the founder of the company who didn't have one and wanted to show it to his grandchildren.

If you are interested in selling it or trading it for a teleprinter or a DEC computer terminal of that era, let me know.
Reply all
Reply to author
Forward
0 new messages