Firmware and infrastructure for a 6502 portable

Let's talk about anything related to the 6502 microprocessor.
User avatar
BigDumbDinosaur
Posts: 9425
Joined: 28 May 2009
Location: Midwestern USA (JB Pritzker’s dystopia)
Contact:

Re: Firmware and infrastructure for a 6502 portable

Post by BigDumbDinosaur »

No True Scotsman wrote:
I only learned yesterday that ASCII characters 17 and 19 are the conventional characters for XON/XOFF. The charts just say "device control." To be fair though, the ASCII standard doesn't specify a use.
DC1 and DC3 were originally in a group of proprietary Teletype (TTY) control signals (DC1-DC4 and DLE) and were not part of the first published ASCII standard (1963).  My 80-year-old brain has forgotten much of my ancient ASCII and Teletype knowledge—the noisy contraptions, at one time, were present on all American warships, and many of their British counterparts, and I often got called on to repair them—even fixed one on a Royal Navy ship that was cruising with us in the North Sea.

All Teletype control codes were handed down through modifications to the 19th century Baudot 5-bit code set, which was telegraphy-based.  Following the invention of the teleprinter, additions were made to accommodate increasing capabilities.  The reworked Baudot code set was extended to 7 bits, which is why the original ASCII standard was 7 bits—the Teletype 33ASR machine’s Baudot code ended up being the model for ASCII.

In the Teletype universe, the machine would do different things if it received one of the DC codes. Usually DC1 and DC2 were used to start an accessory attached to the TTY and DC3 and DC4 were used to stop an accessory.  The Teletype Corporation didn’t specify the accessory being so controlled, it was up to the TTY operators to figure it out based on what was attached to the machine.  The Navy units I worked with used DC1 to stop the paper tape reader and DC3 to start it.  It could be that was why DC1 and DC3 were subsequently adopted for use as software flow-control symbols, with DC3 telling the remote station to stop sending.

Many of the other control characters in the ASCII set are only of historical interest—the obsolescence of TTYs saw to that.  Some dot matrix printers continue to use them for various odd things.
x86?  We ain't got no x86.  We don't NEED no stinking x86!
No True Scotsman
Posts: 127
Joined: 22 Mar 2023

Re: Firmware and infrastructure for a 6502 portable

Post by No True Scotsman »

BigDumbDinosaur wrote:
My 80-year-old brain has forgotten much of my ancient ASCII and Teletype knowledge...
One thing we'll never forget is the 26 year old GIF at the top of this page, which continues to grace discussions about ASCII years later. :lol:
BigDumbDinosaur wrote:
... the noisy contraptions, at one time, were present on all American warships, and many of their British counterparts, and I often got called on to repair them—even fixed one on a Royal Navy ship that was cruising with us in the North Sea.
The Mk 152 (Univac 1219B) fire control computer on USS Long Beach had a Teletypewriter that sat on top of an I/O console containing a paper tape reader. You can see part of it sticking out at the far end of the row of machines in this picture. The cabinet between the tape drive and the I/O console is a DAC/ADC. Weapons were aimed with the aid of analog synchros tied into the ship's inertial navigation system. While it was nominally my job to maintain the Teletype, I never had to do anything to it.
No True Scotsman
Posts: 127
Joined: 22 Mar 2023

Re: Firmware and infrastructure for a 6502 portable

Post by No True Scotsman »

BigDumbDinosaur wrote:
All of this is explained in the data sheet.
I'm finding it difficult to get my head around the datasheet for some reason. The application notes seem to only exacerbate the confusion. That's why I've been digging up scant amplifying information from users in the wild.

I'm currently re-examining my need (or, more accurately, desire) for two UARTs. "Nice to have" two isn't really a reason to have two. The ESP32 can do any additional I/O that needs doing with a lot less fuss. I really only need a UART to talk to the ESP32.

That, and the lack of FIFOs in the non-L version of the chip that I have, is making me reconsider using the 2892 altogether. The L version is hard to find in a DIP package. If I'm going to buy another chip, the 16C550 is ubiquitous as well as much better documented in the DIY community.

Today, I have in mind to try to burn an Arduino bootloader with an ESP32, since the Chinese clone makers stopped burning them for whatever reason. I bought a USBasp for that, but I also have to load the firmware for the USBasp myself - using an Arduino that already has a bootloader installed. What kind of chicken-or-egg nonsense is that?
No True Scotsman
Posts: 127
Joined: 22 Mar 2023

Re: Firmware and infrastructure for a 6502 portable

Post by No True Scotsman »

I was rummaging through my vast archives of old code today, as one will, when I found that I've already written the file server and download client for the proposed online facility. I apparently modified it as recently as November, so it'll probably work.

The server and client implement a simple ad hoc request and response protocol between them. There's also a WebSocket server in the package for some reason. Maybe the thinking was to build a hybrid website / Telnet BBS - which still ain't a bad idea. Or maybe I included one for the sake of completeness.

The TcpServer base class is an abstract class that requires the application developer to extend it with a concrete class (FileServer in this case) in which the event handlers (or callbacks, if you prefer) onIterate(), onConnect(), onReceive(), and onDisconnect() are defined. I'm going to refactor it to use a general purpose pluggable trait that implement JavaScript-like addEventListener(), removeEventListener(), and fireEvent() methods instead. A "trait" is a mechanism for "horizontal inheritance" in PHP and some other languages. Instead of inheriting the properties and methods that implement a mechanism from a parent class, the child class acquires them from a trait.

The client software will have to be ported from PHP to Arduino C++ using Espressif's Arduino libraries to run on the ESP32, but that'll be a simple affair.

In preparation for this project, I tested one of my two ESP32 boards with a blinking LED sketch, the Arduino equivalent to "Hello World," to confirm that it works. I don't want any more nasty surprises like the one I got with the Non-duinos I mentioned earlier. This is an older module, a DEVKIT V1. I think it only has 2 MB of RAM. Some newer ESP32 boards have as much as 32 MB.

Out of curiosity, I compiled an example ESP-NOW sketch in the Arduino IDE, and it consumed 68% of the onboard RAM. I won't be using ESP-NOW.

With such limited RAM, it's a safe bet I won't be using regular expressions in my ANSI parser either. Fortunately, I found Joshua Haberman's vtparse, a serial parser written in C, whilst researching many things today.

I've watched a few YouTube videos about SPI display libraries for Arduino, and I'm impressed by what some people have done with TFT_eSPI. It should be pretty easy to map ANSI commands to TFT_eSPI class methods.

And, believe it or leave it, I even found an Arduino driver for my I2C stereo volume control. 8)
No True Scotsman
Posts: 127
Joined: 22 Mar 2023

Re: Firmware and infrastructure for a 6502 portable

Post by No True Scotsman »

Well-commented code is priceless. Maybe I'll adopt the habit someday.

I'm referring to BDD's 26C92 driver when I say that. The design process is thoroughly documented in comments throughout the code. A criticism of code comments I often hear is that they only tell you what you can infer on your own from a function signature or whatever, rather than explain what the code does and why.

The summaries of the 26C92's registers in the comments are more lucid than the endlessly monotonous-looking tables in the datasheet. Sometimes I just need things explained a different way. Most of the time, I just need to read light text on a dark background rather than stare into a flashlight.

And there are little things most programmers wouldn't think to write comments about. For example, potential pitfalls are foreseen and warned against well in advance, as at the top of buffers.asm:
BigDumbDinosaur wrote:
Read all comments before changing any definitions, as there are a number of dependencies that must be maintained.
Using this package as a guide, I'm going to press on with the 26C92 I already have before abandoning it for the 16C550.
No True Scotsman
Posts: 127
Joined: 22 Mar 2023

Re: Firmware and infrastructure for a 6502 portable

Post by No True Scotsman »

No True Scotsman wrote:
And, believe it or leave it, I even found an Arduino driver for my I2C stereo volume control. 8)
This library was a dud. The author wrote his own I2C driver, which hooks deep into the AVR architecture, instead of using the standard built-in Wire library like everybody else since the beginning of time. Consequently, it won't compile for the ESP32-based Nano. Luckily there's more than one way to skin a cat.

I included all of the libraries I'll be using in one barebones sketch to make sure they'll compile without conflicts. No complaints from the compiler, finally. Now I can start writing the terminal firmware.
No True Scotsman
Posts: 127
Joined: 22 Mar 2023

Re: Firmware and infrastructure for a 6502 portable

Post by No True Scotsman »

No True Scotsman wrote:
I was rummaging through my vast archives of old code today, as one will, when I found that I've already written the file server and download client for the proposed online facility.
I tested the file server and downloader parts of this package with a dynamic DNS service, and found it to be working.

My Web hosting will be up for renewal in July, at a cost of over $200 US per year. It's always cheap the first year, and expensive to renew. I dropped my hosting for a year last year because of the cost, and haven't done anything with it since I renewed it. I'll be dropping it again when it expires in July, as I'm still not particularly motivated to start another website. At that time, I'll redirect my domain name via the dynamic DNS service to a computer on my home network, probably a Raspberry Pi or some old PC I'll fix up specifically for the purpose.

My system won't allow me to listen on port 23 (Telnet) for some reason. Maybe you have to run the server as admin. I tried several ports higher than 8000, and finally got the file server and router port forwarding to work on port 8079, so I'll probably leave it there.

The transfer protocol is simple.

(1) The client connects, and sends a request to the server:

Code: Select all

GET ice_cream.png
(2) The server responds with:

Code: Select all

<File Not Found>
or

Code: Select all

<Continue>
(3) The client then says:

Code: Select all

<Ready>
(4) The chunked transfer begins. The server will read 2048 bytes from the file handle, base-64 encode it, compress it in ZLIB format, and write it to the socket. The client will receive each chunk, decompress and decode it, and write it to a local file handle. This step will repeat until the following is received:

Code: Select all

<Transfer Complete>
That should be all you need to know to write a compatible downloader in your language of choice. You can test your client program by sending the following request to devastatia.freeddns.org:8079:

Code: Select all

GET ice_cream.png
If it works, you'll find the attached picture in your program's download folder.
ice_cream.png
ice_cream.png (35.07 KiB) Viewed 1977 times
For all services other than file transfers. e.g., reading and writing messages or chatting with the sysop, any terminal program ought to work. (No other services are live as yet.)
User avatar
GARTHWILSON
Forum Moderator
Posts: 8773
Joined: 30 Aug 2002
Location: Southern California
Contact:

Re: Firmware and infrastructure for a 6502 portable

Post by GARTHWILSON »

No True Scotsman wrote:
My Web hosting will be up for renewal in July, at a cost of over $200 US per year. It's always cheap the first year, and expensive to renew. I dropped my hosting for a year last year because of the cost, and haven't done anything with it since I renewed it. I'll be dropping it again when it expires in July, as I'm still not particularly motivated to start another website. At that time, I'll redirect my domain name via the dynamic DNS service to a computer on my home network, probably a Raspberry Pi or some old PC I'll fix up specifically for the purpose.
Mine is on Digital Ocean, and the service, run on a virtual server in New York, is cheaper than just the electric bill to host my site on a PC in the garage.  It has been years, and it has never been down, and the connection speed is a hundred times as fast as what we had at home.
http://WilsonMinesCo.com/ lots of 6502 resources
The "second front page" is http://wilsonminesco.com/links.html .
What's an additional VIA among friends, anyhow?
No True Scotsman
Posts: 127
Joined: 22 Mar 2023

Re: Firmware and infrastructure for a 6502 portable

Post by No True Scotsman »

I went with SiteGround because I'd previously had problems with uptime and sluggish transfers on cheap hosts. It's a very good host, probably the best, but you pay for what you get.

I don't think a Raspberry Pi on residential broadband will have any difficulty with an old school BBS. They used to run them on 8-bit computers and POTS lines, after all. The dynamic DNS service is free, so the only costs will be domain name and electricity. I don't really need the domain name, as the DNS service offers subdomain names for free, but it's a unique brand name, so I hold onto it. The only real problem is using standard service ports. Residential ISPs block them, and lie through their teeth about doing so.

I noticed somebody connected to the server last night, and there was an error. PHP used to implement a socket as a "resource" that evaluated to an integer handle. Since I wrote that code, they've made Socket a full-fledged object. I'd have to extend the Socket class with an integer ID property and some "magical" methods, if possible, to duplicate the old behavior.

No word on whether the person testing the service was able to successfully download the ice cream picture.
No True Scotsman
Posts: 127
Joined: 22 Mar 2023

Re: Firmware and infrastructure for a 6502 portable

Post by No True Scotsman »

A threat mitigation outfit called VisionHeight has taken a sudden interest in that port for some reason. Opening a port on my PC is more of a risk to me than to anybody else, and I haven't consulted with this VisionHeight. No idea what's up with that, but scanning people's ports uninvited is a good way to get blocked.

Until I have a throwaway computer to run it on, I'm going to kill the server and disable port forwarding.
Last edited by No True Scotsman on Wed Mar 04, 2026 5:55 pm, edited 1 time in total.
User avatar
drogon
Posts: 1671
Joined: 14 Feb 2018
Location: Scotland
Contact:

Re: Firmware and infrastructure for a 6502 portable

Post by drogon »

No True Scotsman wrote:
No True Scotsman wrote:
I was rummaging through my vast archives of old code today, as one will, when I found that I've already written the file server and download client for the proposed online facility.
I tested the file server and downloader parts of this package with a dynamic DNS service, and found it to be working.

My Web hosting will be up for renewal in July, at a cost of over $200 US per year. It's always cheap the first year, and expensive to renew. I dropped my hosting for a year last year because of the cost, and haven't done anything with it since I renewed it. I'll be dropping it again when it expires in July, as I'm still not particularly motivated to start another website. At that time, I'll redirect my domain name via the dynamic DNS service to a computer on my home network, probably a Raspberry Pi or some old PC I'll fix up specifically for the purpose.

My system won't allow me to listen on port 23 (Telnet) for some reason. Maybe you have to run the server as admin. I tried several ports higher than 8000, and finally got the file server and router port forwarding to work on port 8079, so I'll probably leave it there.
Traditionally only programmes running as root could put a service on low number ports (< 1024 or something) so that's probably what's blocking you.

And re. a later comment - My ISP categorically does not block ports and I get a static, routable IP address as part of the package. I host several things and can SSH directly into my home servers. I don't think many (if any) ISPs do implement port blocking in the UK although you are more likely to be on a CG NAT (Carrier Grade Network Address Translation) service which is harder to tunnel into. A few do offer native IPv6 now too.

As for blocking ports - take the opposite approach and block everything. then open just the ports you want. works for me, anyway.

-Gordon
--
Gordon Henderson.
See my Ruby 6502 and 65816 SBC projects here: https://projects.drogon.net/ruby/
No True Scotsman
Posts: 127
Joined: 22 Mar 2023

Re: Firmware and infrastructure for a 6502 portable

Post by No True Scotsman »

drogon wrote:
As for blocking ports - take the opposite approach and block everything. then open just the ports you want.
My firewall (UFW) and router already do that by default.
drogon wrote:
I don't think many (if any) ISPs do implement port blocking in the UK....
It's a whole different ball game in the US. American corporations routinely provide as little value for the money as possible, and their buddies in government who are supposed to be regulating them instead aid and abet them. The bandwidth we get from our local ISPs is a trickle compared to what Europeans get for far less money. They block ports and cap bandwidth because they want the little people to be passive consumers of corporate slop rather than independent producers.

The most egregious examples of corporate tomfoolery can be found in the food industry. The current administration is the first in 100 years to finally do something about food companies putting known toxins in their slop. We've grown so accustomed to their poisoning us over the past century that we think it's normal for everything in the chemistry lab to be listed on the label.

The CEO of McDonald's recently made a video touting their new "product." Not "food," mind you, but "product." The "big bite" he took out of the burger was really a tiny nibble, and he looked like he wanted to spit it out.

Then there was that incident with the Campbell's soup executive telling a co-worker, "We make sh*t for poor people."

If you ask me, most American corporations should be sued out of existence, and the entire C suite pilloried. They're an absolute disgrace to the principles of free enterprise. Many have outlived their usefulness to society by decades. Corn syrup shouldn't be a staple of anybody's diet, let alone the source of a perpetual windfall for sociopaths. No wonder the kids are clamoring for communism. As much as I despise communism, I can see their point.

Okay, I'd better shut up before I get in trouble. :lol:
Post Reply