Jump to content
TobyJennings

From 0 to (SDrive) Max on OS X: A Guide

Recommended Posts

The UNO

The basis of an SDrive-Max is an Arduino UNO.

Compared to a "Genuine" UNO R3 (top), the clone (bottom) is not very different. Most obvious is where the Genuine UNO has a large socketed DIP package for the Mega328, the clone has the chip in a much smaller package. This opens up space on the board for what I wanted: solder pads for each pin and an extra set of headers. Since the LCD shield is going to occupy all the pins, these extra pads make a good place to attach the SIO cable. Otherwise, I would have had to attach them underneath the board.
 
[sharedmedia=core:attachments:641571]

This is a "HiLetgo" UNO clone I got from Amazon for less than 10 bucks.

First Connection

Connect USB to the UNO. It lights up, but as expected, there's no serial device present on my computer after doing so. The chipset driver needs to be installed. Unplug the device for now.

This UNO uses a CH340 serial driver. This is the first step down a rabbit hole of software installations, so let's just follow it.

OS X Software

We need to have certain things installed. OS X gives us a terminal program and a lot of other command-line utilities for free, but we have to go out of our way to install some more.

Starting Point

As a note, the starting point for this guide is a fresh install of OS X 10.13 (High Sierra) in a VMWare Fusion virtual machine. The only software installed are the current updates from the App Store and the VMWare Tools package. Otherwise, the starting point is as vanilla and out-of-the-box as possible.

XCode

We don't need the whole giant multi-gigabyte XCode development environment installed, we just need the "XCode Command Line Tools" which include utilities and compilers used at the Terminal.

A quick way to get these installed is to open a Terminal and enter the command gcc. This is a compiler command that doesn't exist, and the system tells us so:
 
xcode-select: note: no developer tools were found at '/Applications/Xcode.app', requesting install. Choose an option in the dialog to download the command line developer tools.
Additionally, the system generates a pop up asking if we'd like to install the command line tools. Select the "Install" button and accept the license agreement. The installation is pretty small and doesn't take long.
 
[sharedmedia=core:attachments:641574]

After the install completes, press "Done" and enter the following command in the Terminal. The output should match what's shown here:
$ xcode-select -p
/Library/Developer/CommandLineTools
Homebrew

I'll be honest. I dislike downloading a bunch of little disk images and running installers for a bunch of things. You never really know what you have or where it went. Linux systems have "package managers" for this sort of thing. There are a couple of projects that bring similar functionality to OS X, incuding macports and homebrew. These are package managers that (1) know how to install a whole bunch of software, (2) know how to keep it updated, and (3) lets you keep track of what you have. I choose Homebrew.

Install Homebrew with this Terminal command:
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
I don't like this method of installing software, and if you don't either, then you can browse the Homebrew web site (https://brew.sh) and investigate alternative installation methods. This script method is fast and direct, though.

The Homebrew install script starts by showing you what directories and binaries are being installed. Notice that everything listed is prefixed by /usr/local meaning it's not putting stuff all over the system. Instead, it's staying in one location. Press Return to continue and enter your OS X user password to allow the changes.

A lot of stuff happens that takes a few minutes but it should work out just fine. You'll know it's done when it's done.

Test it out by typing brew list. This won't show anything but it doesn't produce an error either. This command lists all the software that Homebrew has installed, so you can always take a look.

CH340 Serial Driver

With XCode and Homebrew taken care of, we can take the next step in our adventure and install the CH340 serial driver for the UNO clone. There are roughly one million references to this driver from all sorts of places on the 'net, and if you want to go this route and install the thing from some disk image package somewhere, go for it. In this guide, we're using Homebrew.

The driver we're installing is a repackage of the OEM driver available at GitHub but the great thing about this guy is he's made it available through Homebrew too.

The command brew tap lets you manage repositories from which Homebrew may find the software you ask for. This command adds the place we'll find the CH340 driver:
brew tap mengbo/ch340g-ch34g-ch34x-mac-os-x-driver \
https://github.com/mengbo/ch340g-ch34g-ch34x-mac-os-x-driver
The command brew cask installs a piece of software. The "cask" means that's it's a special piece of software, like a GUI or other kind of specialized program, like a CH340 serial driver. The distinction isn't important here.
brew cask install wch-ch34x-usb-serial-driver
This command fetches the driver and installs it. You'll need to provide your OS X password again to allow it. Functionally this is not different to downloading a PKG file and running the installer, but now Homebrew manages it.

You may get a popup saying that an extension was blocked. Follow the on-screen prompts to open the "Security & Privacy" preference pane to "Allow" the driver to work.

Once Brew is done installing, it'll tell you:
installer: Package name is CH34x_Install
installer: Installing at base path /
installer: The install was successful.
installer: The install requires restarting now.
  wch-ch34x-usb-serial-driver was successfully installed!
So, restart the computer and prepare for the next phase. If all goes well you'll get no error messages or popups.

After the restart, open a Terminal window and plug in the UNO board. We're going to look for the UNO's serial port now. Issue the following command and check that output:
$ ls /dev/*usbserial*
/dev/cu.wchusbserial1710    /dev/tty.wchusbserial1710
The listing that starts with "tty" is the one we're looking for. The fact that it's there means we're on the right track.

The SDrive-MAX Repository

Next we'll install the thing about which there is all this fuss: the SDrive-Max repository.

Open a Terminal and make sure you're in your home directory (which would be the default landing spot for a Terminal). You can issue the command pwd (Present Working Directory) and get a response like /Users/yourname and be satisfied you're in the right place.

Now retrieve the SDrive-Max repository using git, a popular source code tool that's built into OS X:
git clone https://github.com/kbr-net/sdrive-max.git
There'll be some output then you'll be back at the prompt. Enter the directory and "check out" the correct version, like it was a book at a library:
cd sdrive-max
git checkout V1.1
This switches the repository to the version 1.1 of the SDrive-Max. Developers use tags like this like bookmarks to keep track of things. In the future, if there was a new version you'd check that one out instead.

Build Toolchain

Before we can build the SDrive-Max stuff, we need to turn back to Homebrew briefly and install a couple of things to make this possible:
brew install xa
brew install avrdude
brew cask install crosspack-avr
The package "xa" is a 6502 cross-assembler we'll need to build SDrive-MAX, and "avrdude" is the tool that writes firmware files to the Arduino.

The "crosspack-avr" cask should have everything else we need to continue. Enter your password when prompted. At completion, a browser window may open to a page about CrossPack, which you can read or dismiss. Once you're back at the Terminal window, we'll move ahead.

The "crosspack-avr" cask essentially installs the same package you could download from the CrossPack site, and you could also install individual items through HomeBrew. This would include "avrdude", "avr-gcc" and "avr-binutils" but you'd have to tap an extra repository to get most of these.

Build SDrive-Max

After installing the CrossPack, you need to restart the Terminal (not the computer). Just "exit" and start a new Terminal, again making sure you're in your home directory. Then get back into the SDrive directory and "make" the software.
cd sdrive-max
make
The make command goes out and does all the work, and builds all the things. It should complete successfully and the output should resemble the following and at least not include anything that says "Error".
AVR Memory Usage
----------------
Device: atmega328

Program:   30872 bytes (94.2% Full)
(.text + .data + .bootloader)

Data:       1497 bytes (73.1% Full)
(.data + .bss + .noinit)

EEPROM:      321 bytes (31.3% Full)
(.eeprom)
Software Phase Complete

That's it for software. Now it's time to install it on the UNO.

Flashing the Arduino

First things first, disconnect the Arduino and attach the display shield.

I'm using the Elegoo 2.8" TFT Touch Screen which has the "ili9341" chipset. It fits perfectly atop the Arduino.

Plug the Arduino back into the computer. The screen will light up but won't say anything because it's got nothing to say.

The screen chipset is important, because the SDrive-Max supports a handful of different ones. In the previous section, the "make" command went through and created builds for all of them.

In the "sdrive-max" directory, enter this command to list some stuff:
$ ls -d atmega*
atmega328-hx8347g    atmega328-ili9329    atmega328-ili9341
atmega328-hx8347i    atmega328-ili9340
These are all combos that SDrive-Max supports. "atmega328" is the chipset on the Arduino, and the other part is the chipset of the screen. Since I have the "ili9341" screen, I want to enter the matching directory "atmega328-ili9341".

There are two files we're interested in within this directory, shown below.
$ cd atmega328-ili9341
$ ls *.hex
SDrive.hex        eeprom_writer.hex
EEPROM Writer

The first file to load is the eeprom_writer.hex. We use the next command to do it:
avrdude -p m328p -c arduino -P /dev/tty.wchusbserial1710 -U flash:w:./eeprom_writer.hex
This command has a few pieces to it, so let's break it down. Note that capitalization matters and this is all case-sensitive -- "-p" is not the same as "-P":
  • "avrdude": the program we installed with HomeBrew that will program the Arduino.
  • "-p m328p": the AVR "part" so avrdude knows what it's working with. The chip on the Arduino is a "ATMEGA328P" and the token for this is "m328p" according to avrdude.
  • "-c arduino": the "programmer" type. We have an Arduino, so this should be self-explanatory.
  • "-P /dev/tty.wchusbserial1710": the serial port used to communicate with the device. We identified this thing earlier after we installed the serial driver. This will be different on your system.
  • "-U flash:w:./eeprom_writer.hex": I'm not sure what "U" means but this option tells avrdude what to actually do. There are three parts to the command but they're not in natural order. The command is "w" (write) to "flash" memory on the device the contents of the ./eeprom_writer.hex file (the './' prefix tells avrdude to look in the current directory for that file).
When you execute this command, two things happen: one, avrdude does the thing, and two, you'll see the thing happening on the Arduino's screen.

The avrdude output looks like this:
avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.02s

avrdude: Device signature = 0x1e950f (probably m328p)
avrdude: NOTE: "flash" memory has been specified, an erase cycle will be performed
         To disable this feature, specify the -D option.
avrdude: erasing chip
avrdude: reading input file "./eeprom_writer.hex"
avrdude: input file ./eeprom_writer.hex auto detected as Intel Hex
avrdude: writing flash (3646 bytes):

Writing | ################################################## | 100% 1.77s

avrdude: 3646 bytes of flash written
avrdude: verifying flash memory against ./eeprom_writer.hex:
avrdude: load data flash data from input file ./eeprom_writer.hex:
avrdude: input file ./eeprom_writer.hex auto detected as Intel Hex
avrdude: input file ./eeprom_writer.hex contains 3646 bytes
avrdude: reading on-chip flash data:

Reading | ################################################## | 100% 1.64s

avrdude: verifying ...
avrdude: 3646 bytes of flash verified

avrdude: safemode: Fuses OK (E:00, H:00, L:00)

avrdude done.  Thank you.
The Arduino screen will say "Writing EEPROM..." then "Verifying EEPROM..." and then "Done!" in green letters.
 
[sharedmedia=core:attachments:641573]

Unplug the Arduino, count to 5, and plug it back in to reboot it before continuing.

SDRive Writer

The second file to load is the SDrive.hex. The command is similar to the last one, the only difference being the name of the file to write:
avrdude -p m328p -c arduino -P /dev/tty.wchusbserial1710 -U flash:w:./SDrive.hex
The avrdude output is going to look a lot like the last time, but it will take a little bit longer.

When it's done, the screen will have a white calibration crosshair. Use the stylus to press the crosshair center. It turns green and a new one appears. Repeat this for the four corners. Some information text appears in the center of screen. Tap once more to finish calibration and enter the SDrive-Max software.

You're done! All that remains is to attach the cable and plug it in. Edited by TobyJennings

Share this post


Link to post
Share on other sites

Or, if you aren't planning to edit the firmware at all, you could skip all of that.
 

  1. Get Arduino IDE from here and install it to /Applications.
  2. Run it to make sure it works, it will set itself up.
  3. Get HexUploader from here and install it to /Applications. 
  4. Get the latest firmware for SDrive-MAX from here 
  5. Plug your UNO into your mac and run HexUploader
  6. Use HexUploader to upload eeprom_writer.hex and SDRive.hex from the folder with your screens chip name on it to your UNO, it's pretty simple just three dropdown options to fill in before hitting "Upload a Hex File"
  7. If you got the wrong screen hex file and your UNO doesn't pop up with the screen calibration, don't panic, just upload the correct one, you can't brick it by doing it wrong.
  8. Make a note of the right software ready for the next update.

Share this post


Link to post
Share on other sites

Or, if you aren't planning to edit the firmware at all, you could skip all of that.
 
<snip>


There are always multiple ways to do a thing. Thanks for the contribution. Readers should recognize that this isn't really any simpler, it just has more GUIs, and you still have to find and install a serial driver for your board if the Arduino IDE doesn't do it for you.

Share this post


Link to post
Share on other sites

There are always multiple ways to do a thing. Thanks for the contribution. Readers should recognize that this isn't really any simpler, it just has more GUIs, and you still have to find and install a serial driver for your board if the Arduino IDE doesn't do it for you.

 

 

The Arduino IDE does recognise an Arduino UNO when it's plugged into USB, it wouldn't be a lot of use otherwise.

 

I think you'll find that most macOS users will find NOT having to open a terminal window, install xcode command-line, homebrew, crosspack-avr and avrdude then git clone a bunch of repo's to get the entire dev history of a bunch of source code they only want the binaries for IS quite a lot simpler.

 

Just trying to convince them that installing homebrew and typing 'brew install atari800' is a 'simple' way to get the latest Atari800 emulator was for most of them a step too far. The next question is generally, where's the icon? Then "I'll stick to running this copy of Altirra from a Winebottled app someone uploaded here".

 

I'm not trying to steal your thunder and you have documented in great detail how you would set up a dev environment for Arduino for people who don't want to use the Arduino IDE but I think you are not recognising your target audience here!

 

Oh! If you aren't a paid subscriber those placeholder posts will be uneditable by now.

Share this post


Link to post
Share on other sites

I'm not trying to steal your thunder and you have documented in great detail how you would set up a dev environment for Arduino for people who don't want to use the Arduino IDE but I think you are not recognising your target audience here!


I mean, do you say the same thing to people who design new boards for these computers? "People just want to plug and play, not solder stuff to their motherboards." I suspect that the people on this forum that *are* my target audience don't really need you speaking for them.

Cheers.

Share this post


Link to post
Share on other sites

TobyJennings and Mr Robot,

Thanks to both of you for the updated instructions.

 

I used Mr Robots instructions a few weeks ago and they worked fine. I'm not a programmer and I'm not interested in compiling the source code if the binary (hex) file is available.

 

Mr Robots instructions should work on a Windows machine, substituting Xloader https://github.com/xinabox/xLoader in place of HexUploader

Share this post


Link to post
Share on other sites

I mean, do you say the same thing to people who design new boards for these computers?

 
You mean people like me? ;)
 

"People just want to plug and play, not solder stuff to their motherboards." I suspect that the people on this forum that *are* my target audience don't really need you speaking for them.

Cheers.


Yes that's exactly what I would say to myself. I give all my designs away for free, so that people can make these things themselves as cheaply as possible. What happens? 

 

People make lots of them to sell  they offer upgrade services and use them to make SDrive-Max's to sell prebuilt 

 

Gavin (the guy who runs Vintage Computer Center) is filling the gap between the people who design them and don't want the hobby to be a job (me), and people who need one but don't want/don't have the confidence/can't be bothered to make their own. He by all accounts has sold quite a few, far more than the number of downloads the gerber files have had by the people wanting to do it themselves.

Edited by Mr Robot

Share this post


Link to post
Share on other sites

Hey MrRobot - just wanted to let you know I bought one of your mod-boards pre-built by Gavin last week. It arrived Wednesday. I plan to install it into my SDrive-MAX this weekend (assuming I get a day off - not entirely guaranteed! Work has been brutal). I'd have ordered a few bare PCBs and built them up myself but I'm kind of short on time and I'd have had to wait another week or more for the boards and parts to trickle in separately. :) 

Share this post


Link to post
Share on other sites

To be fair, and to not give Gavin all the free publicity.

Other SDrive-Maxs are available
https://thebrewingacademy.com/collections/atari-800-xl-xe-xel-xld/products/atari-sdrive-max

 

Oh, trust me, I've bought my share of stuff from MacRorie over the last 18 months as well. Which reminds me, I want to buy an Ultimate Cart at some point this summer ... 

Share this post


Link to post
Share on other sites

 

 I want to buy an Ultimate Cart at some point this summer ... 

 

I have one, they are awesome but... Development of the firmware is slow to put it generously. I feel that the AVG cart is currently a better proposition as a flash cart, and it's cheaper.

Share this post


Link to post
Share on other sites
I‘m a Mac user who doesn’t mind the Terminal and do appreciate both the ‚easy‘ and the ‚harder‘ instructions. Please do continue. I didn’t find 1.1 on my own on GitHub, so this thread has helped me already.


Gesendet von iPhone mit Tapatalk

Share this post


Link to post
Share on other sites

It's been my experience, that many of the people that have been here a while tend to give very high-level instructions on how to do something that leave out details that may be obvious for the poster, but not necessarily for the audience.

 

Given the choice, I'd like to have both. The executive summary showing how to do it if you don't want to get in the weeds, supplemented by the details so when you get stuck on a command that seems vague to you, you can trace through the details to get the answer.

 

I will provide an example based on this same device. The SDrive Max ATX support thread started exploring why the diode didn't always work when you wanted to hook it up with more than one SIO device. The community came up with an elegant solution that involved a custom board and some components.

 

Then, BigBen came in and said:
 

If you have the Atmega in the DIP version, you just need to bend pin 2 out of the socket and connect it to the lead of 1-TX. For a software update, it must be reconnected.

 

 

http://atariage.com/forums/topic/275629-sdrive-max-atx-support/?p=4189049

 

There was a picture showing the second pin out of the socket, but not connected to anything. There is a pin on the Arduino that is labelled 1-TX, but I wasn't sure what that meant.

 

I posted a response that had pictures showing the layout of the processor and the layout of the board and asked if that was what needed to be done.

 

BigBen helpfully tried to clarify it for me, but left me somewhat more confused than I was before.

 

Better with picture.

Arduino Uno Atmega put out of the DIL socket and bent out Pin3, put it in the socket and connect with SIO Pin3.

 

http://atariage.com/forums/topic/275629-sdrive-max-atx-support/?p=4289859

 

This includes a picture showing a different pin being removed than the earlier post.

 

The first post said to pop out pin 2 and connect it to 1-TX, the second, clarfying, post said to pop out pin 3 and connect it to SIO pin3.

 

While I GREATLY appreciate that there are so many people on this board that are willing to help people out, and I don't want to come across as complaining, these high-level answers can sometimes lead to frustration, and I can imagine scenarios where it might even damage something.

 

Now, I will admit that there is a LOT of low-level detail in that SDrive MAX ATX Support thread, much of it is above my ability to understand. I'm sure the explanation is in there somewhere, but I would love to see someone put together a thread similar to the OP showing how to assemble the hardware so that it can be used with more than one SIO device with distinct separate instruction sets depending on the form factor of the CPU.

 

I would be happy to do that for the DIP CPU if I could figure out what I need to do.

 

Todd

Share this post


Link to post
Share on other sites

I think it's not so much that the answers are high level more that they are part of a conversation and additional to everything that came before. If you come to a thread later and don't read everything up to that point you miss important information that was previously mentioned and so no one sees the need to mention it again. 

 

Yeah the first pic I think was a mistake, it shows pin two not pin 3, but the rest of the text he wrote makes sense if you had read everything that came before it, it all fits in context. Remember he is talking about fixing an existing SDM (I'm so fed up with typing SDrive-Max!), not building a new one from scratch. 

 

The problem is that the TX pin is connected to the USB chip on the UNO via a 1K resistor so there is *always* a small signal on it and the Atari never sees the bus as not in use, so no other devices ever get to have a go. 

 

What bigben is saying is that pin 3 on the ATmega chip (TX) should be bent out of the socket and the wire that you previously soldered to pin 1-TX on the UNO board should be soldered to it, so desolder that wire from the UNO board (it goes to SIO pin 3) and solder it to the chip leg.

 

If you want to update the firmware at some later date you will need to reconnect that pin back to the UNO, so you should probably fit a switch.

ATmega chip Pin-3 -   - UNO BOARD DIP Socket Pin-3
                    \ - SIO Connector Pin-3

You no longer need the diode, it never worked in the first place.

Share this post


Link to post
Share on other sites

THANK YOU! This makes sense. Once I get back in town, I will do this to my SDM (Much better way to refer to it) and I will start a new topic for creating one from scratch.

 

Thank you, again.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...