Showing posts with label serial. Show all posts
Showing posts with label serial. Show all posts

Saturday, 25 March 2017

Amiga Explorer to Linux

I use Amiga Explorer from CloanTo on the Amiga for transferring files to/from my Linux PC.

Although it's fairly easy in Linux to transfer serial data to the Amiga using transwarp and similar, using Amiga Explorer makes things easier.

Amiga Explorer has a PC client for Windows but nothing for Linux.  The Explorer program partially works under Wine but seems flaky and crashes doing directory listings on my standard Fedora 25 machine.

I've created a script that can be used as a Linux client for communicating with the Explorer program running on the Amiga.  The script supports both RS232 serial and LAN connections.  This is a command line tool, there's no graphical user interface.

I've uploaded the code to GitHub here:
https://github.com/marksmanuk/lxamiga

I have uploaded a bootable Amiga Explorer ADF disk image Amiga Explorer 6.0.  Transfer and write it to disk from Linux using transwarp as mentioned in my earlier post.  (edit: new version that boots on A500 onwards)

Example Usage (Serial):

     lxamiga -l
     lxamiga -d df0:
     lxamiga -s myfile.txt df0:Empty/myfile.txt
     lxamiga -r df0:Empty/remote.txt -w local.txt
     lxamiga -r :df0:disk.adf -w image.adf
     lxamiga -s image.adf :df0:empty.adf/image.adf
     lxamiga -u df0:Empty/deleteme.txt
     lxamiga -f df1: Empty


It's the same commands to use the LAN connection, just use the -t switch first:

     lxamiga -t -l

1. List available devices/volumes:

$ lxamiga.pl -l
Connected to host successfully at 19200
Read 996/996 Bytes 100.0%
14 entries:
 DH0:WORKBENCH           10234 kB    10710 kB 18/01/1996 20:18 RWED                  
 DH1:SIMULATOR           25628 kB    51510 kB 18/01/1996 20:35 RWED                  
 DH2:CREATE              14187 kB    95795 kB 18/01/1996 20:49 RWED                  
 DH3:DOCUMENTS           25220 kB    94095 kB 18/01/1996 21:05 RWED                  
 RAM:Ram Disk              605 kB      611 kB 25/03/2017 15:47 RWED                  
 DF0:Explorer              174 kB      880 kB 16/02/1993 15:40 RWED                  
 DF1:Blank                   2 kB      880 kB 25/03/2017 09:26 RWED                  
 :R:Kick.rom                 0 kB      512 kB 15/07/1993 00:00 R       AMIGA ROM Operating
 :DF0:Explorer.adf           0 kB      880 kB 16/02/1993 15:40 R                     
 :DF1:Blank.adf              0 kB      880 kB 25/03/2017 09:26 RW                    
 :DH0:WORKBENCH.hdf          0 kB    10710 kB 18/01/1996 20:18 RW      SEC:34 SUR:5 RES:2
 :DH1:SIMULATOR.hdf          0 kB    51510 kB 18/01/1996 20:35 RW      SEC:34 SUR:5 RES:2
 :DH2:CREATE.hdf             0 kB    95795 kB 18/01/1996 20:49 RW      SEC:34 SUR:5 RES:2
 :DH3:DOCUMENTS.hdf          0 kB    94095 kB 18/01/1996 21:05 RW      SEC:34 SUR:5 RES:2



2. Format disk:

$ lxamiga.pl -f df1: Blank
Connected to host successfully at 19200
Formatting df1: Blank
Formatting 100.0%
Finished.



3. Send ADF image to disk:

$ lxamiga.pl -s DragonsMegaDemoI.adf :DF1:Blank.adf
Connected to host successfully at 19200
Uploading DragonsMegaDemoI.adf to :DF1:Blank.adf
Sent 901120/901120 Bytes 100.0%



4. Read disk to ADF image:

$ lxamiga.pl -r :DF0:Explorer.adf -w AExplorer.adf
Connected to host successfully at 19200
Read 901120/901120 Bytes 100.0%
901120 bytes saved to AExplorer.adf



5. Read a file from Amiga to local filesystem:

$ lxamiga.pl -r :R:Kick.rom -w kick.rom
Connected to host successfully at 19200
Read 524288/524288 Bytes 100.0%
524288 bytes saved to kick.rom


$ md5sum kick.rom
e40a5dfb3d017ba8779faba30cbd1c8e  kick.rom (Kickstart 3.1)


6. Upload a file to the Amiga (over LAN):

$ lxamiga.pl -t -s ProTracker-3.15.lha RAM:
Connected to 192.168.1.200:356 successfully.
Uploading ProTracker-3.15.lha to RAM:/ProTracker-3.15.lha
Sent 97654/97654 Bytes 100.0%
 

$ lxamiga.pl -t -d RAM:
Connected to 192.168.1.200:356 successfully.
Read 168/168 Bytes 100.0%
4 entries:
 Clipboards              (dir) 28/10/2017 21:27 RWED                  
 ENV                     (dir) 28/10/2017 21:28 RWED                  
 T                       (dir) 28/10/2017 21:28 RWED                  
 ProTracker-3.15.lha     97654 07/04/2017 18:45 RWED  
            
    

I've only implemented the features useful to me. If there's interest I'm happy to add the remaining functionality from Explorer.

I originally wrote lxamiga for Linux about 10 years ago but lost the source.  The earlier version supported both serial and network connections and had a separate graphical interface front end written in Perl/GTK.

EDIT: A kind reader had the source and sent me a copy, which to my surprise was written in C++, but it's horribly broken on 64 bit machines so I won't post it here.

Sunday, 5 March 2017

Amiga disk transfer bootstrap

I was given an old Amiga A600HD in a pretty poor state with a collection of various disks.  To be usable I need to transfer Amiga disk images in ADF format between my PC and the Amiga.

I'm on a Linux PC so I followed the guide here:
https://www.area536.com/projects/amiga/transfer-disk-images-from-linux-pc-to-amiga/

First we need to bootstrap the machine by getting an ADF program (transwarp) onto an Amiga format disk which the machine can read.  We can then use transwarp to transfer other ADF disk images and build from there.

The only Workbench disk I could find was a bad copy of Workbench 2.05 (37.71) which I couldn't even copy due to bad sectors.  Fortunately it would boot into Workbench and open a CLI.

I found a 25way to 9 way serial cable and plugged it into my Linux PC via a USB to serial adapter as /dev/ttyUSB0 


1. Transfer ARexx receive script to Amiga

The version of "type" on the A600 with Workbench 2.05 (the version I have) has problems with binary files.  Use the following ARexx receive script as described here:

http://adfsender.stoeggl.com/adfsenderterminal/methods.html

On Amiga:
Go into Prefs and set Serial to 9600 baud 8N1, RTS/CTS hardware flow control enabled.  I left everything else at defaults.

In CLI:
> type ser: to ram:receive

In Linux:
You can use minicom by adding a new binary File Transfer Protocol (/usr/bin/cat) but it's fairly easy from the command line.

$ stty -F /dev/ttyUSB0 cs8 -parenb -cstopb -crtscts raw speed 9600
$ cat receive.rexxlong > /dev/ttyUSB0

You may need to send additional characters to fill Amiga serial buffer if the command prompt doesn't appear immediately.  I sent a break character from Minicom (Ctrl-A, Z,  F).

Check the file is received on the Amiga side with:
> type ram:receive


2. Transfer Transwarp to Amiga

We'll do this in the RAM disk.

Run the ARexx script with:
> RAM:
> rx receive

Filename? transwarp.run
Bytes? 21363

$ stty -F /dev/ttyUSB0 cs8 -parenb -cstopb -crtscts raw speed 9600
$ cat transwarp.run > /dev/ttyUSB0

The ARexx script knows exactly how many bytes to receive and terminates nicely.


3. Unpack Transwarp.run self-extracting archive.
Make sure file is named "transwarp.run" on the ram disk.

> transwarp.run

It should unpack the relevant files (transwarp, baudbandit.device) to the ram disk. If there's an error (file is not executable, bad loadfile hunk, etc.) the file was corrupted during serial transfer.  Try again and maybe at a lower baud rate.

To avoid having to do this initial serial transfer ever again, copy the Transwarp files from RAM: to a blank disk DF0:



3. Transfer Hombre utilities disk image to blank disk

http://wiki.abime.net/file_transfer/hombre

This step isn't really necessary as we already have Transwarp available on an Amiga format disk and can therefore transfer disk images over serial.  However, this is a useful set of utilities and boots stand-alone without Workbench.
 
Transfer the Hombre v1.01 (single disk version) ADF to a new bank disk.

On Amiga:

> RAM:
> transwarp -w ser: -b 9600 -1

On Linux:

Send the binary file as we did before:

$ stty -F /dev/ttyUSB0 cs8 -parenb -cstopb -crtscts raw speed 9600
$ cat Hombre*.adf > /dev/ttyUSB0

    0860e27d5ae3cd519a0f7740d774f3ff  Hombre_v1.01_1d_[pal].adf

Now reboot into Hombre!



4. Reading ADF images from the Amiga

As I only had a broken copy of Workbench 2.05, I then wrote a copy of Workbench 2.1 using the same transfer method above using transwarp.

As a sanity check I read back the newly written Workbench disk image from the Amiga and compared the md5sum with the original ADF file.

On Linux:
For reading Amiga disks we can run at full 115,200 baud rate.
$ stty -F /dev/ttyUSB0 cs8 -parenb -cstopb -crtscts raw speed 115200
$ cat < dev/ttyUSB0 > verify.adf

On Amiga:

> transwarp -b 115200 -s 0 -e 79

Do a Control-C to terminate cat on Linux when all bytes have been received.

7310f152b05f66bcfbffe3529a41f3fb  Workbench v2.1 rev 38.35 (1992)(Commodore)(M10)(Disk 2 of 5)(Workbench).adf
7310f152b05f66bcfbffe3529a41f3fb verify.adf

Perfect match!
I'm happy to use Transwarp for now until I can get an Ethernet connection set up and maybe use the Amiga Forever from CloneTo.