Monday, December 5, 2022

More Retro Computing fun with ESP32 : Meatloaf

I recently stumbled upon a new project which provides an Internet connected file and BBS interface for the Commodore userport. 


The project I'm talking about is MEATLOAF.

A Commodore IEC serial floppy drive, and Wifi modem multi-device emulator by Jaime Idolpx

If you have experience with pi1514 or other modern wifi adapters, you might write this project off as "Yet another modern drive or modem" replacement for the C64, but it has a feature which is definitely worth a look.   It might even be completely game changing by the time the project is complete.

The idea here is a simple file loading system which uses the Internet itself as the 1541 floppy disk.   Meatloaf allows you to skip the downloading of files to your PC, transfer to a USB device and sneaker-net them to Ultimate/pi1541 device on the C64.  Instead, you can simply LOAD the programs directly from their existing download locations.  

The parts for this project are extremely inexpensive, the basic build uses a $6 ESP32 device from Amazon, and a serial IEC cable to the C64.  (I used a DIN45322(6) connector, only to keep from cutting an IEC cable)   If all you have is a Commodore computer C64,C128,VIC20,C16,PLUS/4, and no other hardware, this simple device will get you loading software.

Don't chuck your pi1541 into the bin yet, this project is in Alpha state.   You will experience bugs and minor flaws.   The project is also not intended to be 1541 exact, so while .prg programs will work (and there are thousands of them out there to keep you occupied) you will probably not be loading any copy protected nibble images any time soon.  (Note: This project is developing quickly.  It's possible that some of this information will be inaccurate by the time you read it.)  If you are like myself and have a little hardware in your parts box and enjoy a challenge to play with up and coming technology for your old computers, then meatloaf.cc wants you to participate.

This blog post is intended to document my own experience with getting a very simple Meatloaf up and running with minimal parts.   I'd also recommend watching a couple videos on getting started with both Visual Studio Code and Platform.IO.   Don't worry, I'm a complete rookie on both, and was able to figure it out enough to be compile and upload Meadloaf.  If you have experience with the Arduino, it's an easy enough jump.

You'll need the following:

This parts list is just enough to get you loading programs from the Internet.  We are skipping the userport connector for now which enables the ability both parallel loading (faster) and TelBBS modem.

The first step is solder up and map our your selected DIN cable or connector.  Here's an image from out on the interwebs that will help you out.

 


There are also a couple helpful images on the Commodore Bus Wiki page.



At the moment you'll need to identify four connections: GND, Clock, Data,  & ATN. These are connections 2,4,5, and 3.   While the image doesn't properly show a cable/pin graphic for male, you'll need to use the reversed pin image on the left if you using a cable.

Next install Visual Studio Code and Platform.IO and watch a couple Youtube videos on them.  Dave's Garage has a video that will teach you enough to be dangerous if you have never worked with them before.

Now that you are an "expert" on those, it's time to download the WS-WROOM-32 version of the Meatloaf software from it's github.   Use the basic instructions on the page itself to get started.

https://github.com/idolpx/meatloaf-specialty

(Note: the /meatloaf-specialty project is the version designed for ESP32.)

Make special note to edit and rename the ssid.h and the platformio.ini files as indicated in the instructions.    I won't show you my own ssid.h which contains my Wifi settings, but you are welcome to use my platformio.ini as a reference. 

 

;FujiNet PlatformIO Project Configuration File
;
;   Build options: build flags, source filter
;   Upload options: custom upload port, speed and extra flags
;   Library options: dependencies, extra library storages
;   Advanced options: extra scripting
;
; Please visit documentation for the other options and examples
; https://docs.platformio.org/page/projectconf.html

[fujinet]
; Espressif32 PlatformIO Version to use for building
esp32_platform_version = 5.1.0

build_platform = BUILD_CBM
build_bus      = IEC

; Change this to target hardware you use from the list of [env:xxx] sections below
; Commodore IEC using Atari FujiNet

build_board = meatloaf-fujinet-v1.nopsram  ; Board has no SPI PSRAM


flash_filesystem = FLASH_SPIFFS
;flash_filesystem = FLASH_LITTLEFS
flash_size = 4mb    ; 4mb, 8mb, 16mb

[platformio]
description = Meatloaf / FujiNet retro computer to ESP32 WiFi Multifunction Firmware
default_envs = ${fujinet.build_board}
data_dir = $PROJECT_DIR/data/${fujinet.build_platform}


[env]
; Common settings for all enivornments
framework = espidf
extra_scripts = pre:build_version.py
lib_ldf_mode = deep+
upload_speed = 460800 ;921600

upload_port = /dev/ttyUSB0 ; Linux
;upload_port = COM1 ;Windows
monitor_speed = 460800  ;921600
monitor_port = /dev/ttyUSB0 ; Linux
;upload_port = COM1 ;Windows
monitor_filters = esp32_exception_decoder

build_type = debug
build_flags =
    -D ${fujinet.build_platform}
    -D ${fujinet.flash_filesystem}

    ;-D CMAKE_EXPORT_COMPILE_COMMANDS=ON
    -D DEBUG_SPEED=460800  ;921600
    -D NO_PSRAM            ; if your hardware has no psram
    -D NO_BUTTONS          ; if your hardware has no physical buttons
    ;-D LED_STRIP           ; if your hardware has an led strip
    ;-D PIEZO_BUZZER        ; if your hardware has a piezo buzzer
    ;-D PARALLEL_BUS        ; if your hardware has parallel interface
    ;-D JTAG                ; enable use with JTAG debugger
    ;-D BLUETOOTH_SUPPORT   ; enable BlueTooth support
    ;-D VERBOSE_TNFS        ;
    ;-D VERBOSE_DISK        ;
    ;-D VERBOSE_HTTP        ;
    ;-D DEBUG_TIMING
    -D DATA_STREAM
    ;-D NO_VIRTUAL_KEYBOARD
    ;-D DBUG2               ; enable monitor messages for a release build

;debug_tool = esp-prog
;debug_init_break = tbreak setup


[env:meatloaf-fujinet-v1.nopsram]
platform = espressif32@${fujinet.esp32_platform_version}
board = fujinet-v1-${fujinet.flash_size}
build_type = debug
build_flags = ${env.build_flags}


The changes I made "No Buttons", "No PSRAM", and "Data Stream".  I also deleted a few of the remarked/unused items to streamline the file.   If you have "build_board = meatloaf-fujinet-v1.nopsram  ; Board has no SPI PSRAM" and "flash_size = 4mb    ; 4mb, 8mb, 16mb" then you'll probably be in good shape.

(Note: I've used Linux to compile mine, and the example reflects this.   You should be able to change your upload_port and monitor_port settings for both Windows and MAC compatibility as well.  See the platformio.ini.sample included in the package.)

Next, you'll want to open the pinmap.h located in the projects \include folder.  Make sure the bold line is the selected board.

/* FujiNet Hardware Pin Mapping */
#ifndef PINMAP_H
#define PINMAP_H

//#include "pinmap/fujinet-v1.6.h"
//#include "pinmap/lolin-d32-pro.h"
//#include "pinmap/lolin-s2-mini.h"
#include "pinmap/esp-wroom-32.h"
//#include "pinmap/esp32-a1s-audio-kit-v2.2.h"
//#include "pinmap/esp32s3.h"
//#include "pinmap/fujiapple-rev0.h"
//#include "pinmap/fujiloaf-rev0.h"

#endif

Now open up the esp-wroom-32.h file located in \include\pinmap folder.

You want to remark the line with a couple slashes.  It should read:

// Reset line is available
//#define IEC_HAS_RESET

Toward the bottom of the file you'll find the pin-map connections for your ESP32.

// LOLIN D32 PRO
#define PIN_IEC_RESET           GPIO_NUM_34
#define PIN_IEC_ATN           GPIO_NUM_32
#define PIN_IEC_CLK_IN      GPIO_NUM_23

#define PIN_IEC_CLK_OUT      GPIO_NUM_23
#define PIN_IEC_DATA_IN    GPIO_NUM_25
#define PIN_IEC_DATA_OUT    GPIO_NUM_25
#define PIN_IEC_SRQ               GPIO_NUM_26

Remember that we are only interested in ATN, CLK, DATA, and GND.   You can ignore the others for now.   Make the connections you mapped out to GPIO32, GPIO23, GPIO25, and GND TO GND.

The only speed-bump I ran into with this project was the need to disable "Support for External, SPI connected RAM".  You can do this by using the "Run Menuconfig" option in your programs' Project Task's menu.   The option is located in "Component Config" --> "ESP-32 specific".  Just toggle it off and "S"ave the configuration.

 

Also don't forget to "Upload FileSystem Image" so that the LOAD "$",8 has something to find on your Meatloaf.

Hit the -> button at the bottom of your screen.   If all goes well you will be using the Internet as your 1541.  Connect your Meatloaf device to your Commodore computer and try LOAD "$",8.  Once that works, try LOAD "HTTP://C64.MEATLOAF.CC/GOTD/",8.  This will load Meatloaf.cc's Game of the Day.

Ready to load C64 files from other websites?   Time for the "Send to Meatloaf" plug-in for Firefox, Opera, or Chrome

One you have the plug-in installed, go to a website like CSDb and find the link to a .prg file in the Latest Releases section.   Right-click on the link, and select "Send to Meatloaf".  A screen will open with a Command to use on your Commodore computer to load the file directly.  

On your Commodore computer, type LOAD "ML:*",8,1

If you have made it this far, seriously consider joining the Discord channel for the Meatloaf project.   The channel would love to see your build of the device.   I had some initial difficulty getting things up and running.  Jaime as well as other members were quick to assist.  The more feedback and input on this project will improve the final versions hardware and features.

 

Author's very simple 4 wire Meatloaf on a breadboard.