Firmware and infrastructure for a 6502 portable
Posted: Thu Feb 19, 2026 12:11 am
Previously, I mentioned my goal of creating an online environment suitable for 8-bit computers:
We talked mainly about hardware in that thread. I'd like to now flesh out the picture a little more, and discuss the software that will power it. As the complete system will involve other systems in a addition to the 6502 portable itself, some of the code presented here will be in languages other than those that will run on a 6502. For that reason, I've posted this thread in the General Discussion forum, rather than Programming. If the mods think it belongs there instead, feel free to move it.
Foremost in my mind in recent days has been a software loader. This part of the 6502 firmware would send an in-band file request over the terminal connection to the onboard ESP32 that runs the terminal and controls the SD card slot and WiFi connection.
Coincidentally, AlexeyM82 recently mentioned a loader he wrote for his 6502 SBC that loads files over a serial connection, which I'd very much like to see. Thanks in advance!
My preliminary research into creating a loader turned up the Sixty502 project on Github. That package was expressly designed to work with the hardware in Ben Eater's breadboard computer kit, and does not reflect the way I'd write client-server software. It requires that the server and client computers be connected via an Arduino Mega and ten or so Dupont wires. The user must manually initiate both ends of the transfer. My software will transfer files the way one would actually download a file in real life.
The Sixty502 server, "sender.js," is written in JavaScript and runs on Node.js. Node.js is one of the countless unnecessary platforms du jour that cropped up in the late 2000s and 2010s. Although JavaScript is my favorite language, and Microsoft's sever object bindings in the original Active Server Pages were well designed, the latest trends in software abstraction make simple things like creating a TCP socket unnecessarily tedious. Programmers are way too literalistic where design patterns are concerned. I almost wish they'd never been taught. Wanna know how I write a page controller or section front controller for a WebMVC site? I write a switch statement, because that's all a controller really is. I use PHP on the server side because it's "unixy," by which I mean it implements scriptable versions of Unix system calls that closely parallel their C counterparts. You shouldn't have to instantiate a bunch of objects and pass them to each other to do this:
I've omitted error handling code for clarity here, but you get the idea.
Incidentally, if you've tried to connect to an Arduino from a Linux terminal and failed, that's because it's weird. I forget where I learned this, but here's how to do it:
Notice that the catch-all "sane" argument to stty doesn't work for Arduino. I guess the Arduino is insane.
But I digress.
As I mentioned elsewhere, I'm inclined to forego an onboard BASIC interpreter altogether, as writing programs on the desktop and downloading them over WiFi seems a more natural workflow. Therefore, the main 6502 firmware components would appear to be as follows:
Since the terminal will have a CSI parser for the UI anyway, it may as well handle filesystem and WiFi commands too.
No True Scotsman wrote:
Beyond just building a portable computer, I envision an ecosystem to support it that will include both local and online services. The device won't be "always connected" in the way a smartphone is. Rather, the ESP32's WiFi capabilities will be used to connect to a simple Telnet BBS running on my desktop computer at home. The BBS will initially be a simple remote file storage system, but will evolve over time to provide other services, such as an IMAP/SMTP proxy. It may even become a full multi-user BBS at some point.
The overall aesthetic of the text-mode user interface will be influenced by dialup BBS design, which may help explain the design strategy. Data sent from the 65C02 to the terminal display will be parsed for ANSI escape sequences, which will be translated into commands to the TFT driver, e.g., to set text foreground and background colors, move the cursor, and delete things. Said driver also has codepage 437 support, which makes it perfect for this application. As you'd expect, data from the BBS will be likewise marked up with ANSI sequences.
Long story short, I intend to integrate local programs and online services in a cohesive environment that has an old school BBS look and feel.
The overall aesthetic of the text-mode user interface will be influenced by dialup BBS design, which may help explain the design strategy. Data sent from the 65C02 to the terminal display will be parsed for ANSI escape sequences, which will be translated into commands to the TFT driver, e.g., to set text foreground and background colors, move the cursor, and delete things. Said driver also has codepage 437 support, which makes it perfect for this application. As you'd expect, data from the BBS will be likewise marked up with ANSI sequences.
Long story short, I intend to integrate local programs and online services in a cohesive environment that has an old school BBS look and feel.
Foremost in my mind in recent days has been a software loader. This part of the 6502 firmware would send an in-band file request over the terminal connection to the onboard ESP32 that runs the terminal and controls the SD card slot and WiFi connection.
Coincidentally, AlexeyM82 recently mentioned a loader he wrote for his 6502 SBC that loads files over a serial connection, which I'd very much like to see. Thanks in advance!
My preliminary research into creating a loader turned up the Sixty502 project on Github. That package was expressly designed to work with the hardware in Ben Eater's breadboard computer kit, and does not reflect the way I'd write client-server software. It requires that the server and client computers be connected via an Arduino Mega and ten or so Dupont wires. The user must manually initiate both ends of the transfer. My software will transfer files the way one would actually download a file in real life.
The Sixty502 server, "sender.js," is written in JavaScript and runs on Node.js. Node.js is one of the countless unnecessary platforms du jour that cropped up in the late 2000s and 2010s. Although JavaScript is my favorite language, and Microsoft's sever object bindings in the original Active Server Pages were well designed, the latest trends in software abstraction make simple things like creating a TCP socket unnecessarily tedious. Programmers are way too literalistic where design patterns are concerned. I almost wish they'd never been taught. Wanna know how I write a page controller or section front controller for a WebMVC site? I write a switch statement, because that's all a controller really is. I use PHP on the server side because it's "unixy," by which I mean it implements scriptable versions of Unix system calls that closely parallel their C counterparts. You shouldn't have to instantiate a bunch of objects and pass them to each other to do this:
Code: Select all
$socket = @socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
@socket_bind($socket, $address, $port);
@socket_listen($socket);
@socket_set_nonblock($socket);
Incidentally, if you've tried to connect to an Arduino from a Linux terminal and failed, that's because it's weird. I forget where I learned this, but here's how to do it:
Code: Select all
if (strtolower($type) == "arduino") {
$command = "/bin/stty -F {$device} {$baudRate} {$dataBits} {$this->stopBits} {$localEcho} ignbrk -brkint -icrnl -imaxbel -opost -onlcr -isig -icanon -iexten -echo -echoe -echok -echoctl -echoke noflsh -ixon -crtscts";
}
else {
$command = "/bin/stty -F {$device} {$baudRate} sane raw {$dataBits} {$stopBits} hupcl cread clocal {$localEcho} -onlcr";
}
exec($command);
But I digress.
As I mentioned elsewhere, I'm inclined to forego an onboard BASIC interpreter altogether, as writing programs on the desktop and downloading them over WiFi seems a more natural workflow. Therefore, the main 6502 firmware components would appear to be as follows:
- * terminal I/O
* command interpreter, main menu, or hybrid
* in-band serial file transfer protocol, possibly a custom CSI extension
* loader
* text editor
* monitor
Since the terminal will have a CSI parser for the UI anyway, it may as well handle filesystem and WiFi commands too.