6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Sat Nov 23, 2024 3:02 am

All times are UTC




Post new topic Reply to topic  [ 5 posts ] 
Author Message
PostPosted: Sat Dec 07, 2019 3:37 am 
Offline

Joined: Tue Dec 03, 2019 1:48 am
Posts: 11
Location: New Mexico
The WDC W65C134SXB is an affordable SBC based on the 65C02S processor. It's a very attractive package, but WDC's tool-chain is windows only. Luckily, it's not difficult to get it running under Linux. In this guide we'll go from plugging it into to running a simple Hello World type program. I'm using xUbuntu 19.10, these instructions should work for any of the Debian based distros, out of the box, and on other distros with only a little modifcation.

The first thing we need to do is get our software environment set up. We'll be using EasySXB to talk to the 134 over a USB port. EasySXB isn't available in the repositories, so we'll need to get it from Sourceforge.

https://sourceforge.net/projects/easysxb/files/

Other than EasySXB, we'll need CC65 which contains our assembler and linker and SRecord which will allow us to convert the binaries produced by CC65 to something we can send over the USB cable. This software can be installed with the command
Code:
sudo apt install cc65 srecord

Once the software is installed, we're ready to plug in the 134. Grab any old micro-usb cable and connect the 134 to your computer. Now, we need to find out what tty it has been assigned to. The 134 uses an FTDI chip to run it's USB port, so we can search through the system log to find it by typing the following
Code:
dmesg |grep FTDI

On my system the output looks like this
Code:
[  335.907678] usb 2-1.2: Manufacturer: FTDI
[  335.944133] usbserial: USB Serial support registered for FTDI USB Serial Device
[  335.944230] ftdi_sio 2-1.2:1.0: FTDI USB Serial Device converter detected
[  335.946246] usb 2-1.2: FTDI USB Serial Device converter now attached to ttyUSB0

We can see that the 134 is on /dev/ttyUSB0.

Now, we're ready to fire up EasySXB and start talking to the 134. Start EasySXB. From the Options menu, chose Board Model and then select the 134. Now, from the File menu, choose Connect to SXB. You will be prompted to enter a device. Enter the port that we found in the previous step. Connect, then press the reset button on the 134. You should see something that looks like this
Code:
134 ROM Version 1.07
(C) Copyright 1995
Western Design Center
01 07/04/1993  12:47:03

ADDR F  A  X  Y  SP
F1BC 30 0D 30 3F FF
.

This is the Machine Code Monitor for the 134. You can type ? for a list of commands.

Now, we need to write some code and get it over to the 134. Here's a simple Hello World(ish) program
Code:
;;Code start location. Be sure to set this when converting
;;to .srec with the --offset option
   .org $0800
;;turn off the interupt routines
   sei
;;set the number of times to print the string (10)
   ldx   #$0a
;;give us a little whitespace
   jsr $f012
   jsr $f012
   
main:
   lda #'H' ;;put the first char in A
   jsr $f00f ;;call the outch routine to print A to tty
   lda #'i'
   jsr $f00f
   lda #'!'
   jsr $f00f
   lda #' '
   jsr $f00f
   dex ;;decrement counter
   cpx $00 ;;is it zero?
   beq done
   jmp main
   
;;clean up and return to the monitor
done:
   ;;print cr/lf
   jsr $f012
   brk

This uses two routines from the monitor rom on the 134. JSR $F00F prints the contents of A as an ASCII character to the tty. And, JSR $F012 prints a CR/LF to the tty. The code is located at 0x0800. WDC suggests that this is a good part of RAM for messing around. Save this as hi.asm and we'll get it over to the 134. Assemble and link the code with the commands
Code:
ca65 --cpu 65c02 hi.asm
ld65 -t none -o hi.bin hi.o

We're ignoring CC65s ability to generate relocatable code but for simple code that's ok. If you're going to do serious development for the 134 a ld65 compatible memory map would be very useful. (If I end up making one, I'll post it here)

Now, we need to convert the binary into a Motorola SRecord file so we can upload it to the 134. The following command will do the conversion as well as letting the 134 know where to load it into memory so that our jumps will match up with reality.
Code:
srec_cat hi.bin -binary --offset 0x0800 -o hi.srec

The most important thing here is that the --offset match up with the .org in the assembler source.

Finally, we can upload our code and run it. Switch back to EasySXB. If you've been messing around with the monitor, go ahead and reset the 134. Now, type e into the monitor. This will display and clear the error log. From the File menu, choose Upload Program. Browse to the folder that has hi.srec. You'll need to change the file type from hex to srec in the bottom. Once the file has uploaded, you will see several lines beginning with S then you should see the . prompt. Type g 0800. This will transfer control to the memory address containing the start of our program. If everything went according plan you should see something like this
Code:
Uploading Program, ESC to cancel.
S
.S
.S
.g 0800

Hi! Hi! Hi! Hi! Hi! Hi! Hi! Hi! Hi! Hi!

ADDR F  A  X  Y  SP
0829 30 0D 00 3F FF
.

And there you have it! I strongly suggest that you check out WDC's ROM documentation. It has almost everything you need to develop for the 134. You can snag it here

http://www.westerndesigncenter.com/wdc/documentation/134monrom.pdf

I'm a total beginner at this, so i'd love to hear any suggestions.

Hope this helps someone!


Top
 Profile  
Reply with quote  
PostPosted: Sat Dec 07, 2019 9:08 am 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10986
Location: England
Great write-up, thanks!


Top
 Profile  
Reply with quote  
PostPosted: Mon Dec 09, 2019 3:44 am 
Offline
User avatar

Joined: Sat Dec 01, 2018 1:53 pm
Posts: 730
Location: Tokyo, Japan
That's an excellent write-up; thanks for that.

One thing I think should be added to your documentation: I the official home of of EasySXB appears to be https://github.com/JoeDavisson/EasySXB/. (Various bits of evidence point to the JoeDavisson account being the same joe_7 who did all the commits up to the start of 2017.)

That said, the releases page on GitHub has only source releases, not binaries, so I guess for whatever reason he's chosen to keep the binary releases on SourceForge only.

_________________
Curt J. Sampson - github.com/0cjs


Top
 Profile  
Reply with quote  
PostPosted: Mon Dec 09, 2019 11:17 pm 
Offline

Joined: Tue Dec 03, 2019 1:48 am
Posts: 11
Location: New Mexico
cjs wrote:
That's an excellent write-up; thanks for that.

One thing I think should be added to your documentation: I the official home of of EasySXB appears to be https://github.com/JoeDavisson/EasySXB/. (Various bits of evidence point to the JoeDavisson account being the same joe_7 who did all the commits up to the start of 2017.)

That said, the releases page on GitHub has only source releases, not binaries, so I guess for whatever reason he's chosen to keep the binary releases on SourceForge only.


Thanks for mentioning this! EasySXB is a great program and Joe deserves lots of credit for putting it out there.


Top
 Profile  
Reply with quote  
PostPosted: Tue Dec 10, 2019 6:19 am 
Offline
User avatar

Joined: Sat Dec 01, 2018 1:53 pm
Posts: 730
Location: Tokyo, Japan
rclancy wrote:
Thanks for mentioning this! EasySXB is a great program and Joe deserves lots of credit for putting it out there.

Right, although my main thought was actually just that it's nice to know where the source is so one can poke through it to debug things, find out how WDC's protocol works, and so on.

_________________
Curt J. Sampson - github.com/0cjs


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 32 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: