*** DISCLAIMER: The information on these pages is not an official instruction or documentation. No responsibility will be taken. Use at your own risk. ***

Sunday, March 8, 2020

How do you convert lha to ADF?

The contents of the files are completely different:

lha file is a compressed image of one or more AmigaDOS files (file or folder).
ADF is a raw track-by-track image of an AmigaDOS floppy disk, that might, or might not be bootable.

To use the contents of an lha file from an ADF ("convert to ADF"), you have to extract the lha file to an ADF.  
(This implies that the contents of the lha file must fit onto a floppy disk - if they don't, extra work is required, which is beyond the scope of this article.)

You can do so for example by inserting some ADF (a copy!) to your Amiga emulator, formatting it, then extracting lha to that disk (e.g. lha x my_archive.lha df0: ). Example:

> format drive df0: name my_floppy_disk
> lha x myarchive.lha df0:



Note that every good archive - if it contains more than one file - should contain a root folder. For your disk (ADF), you probably want the disk itself to be the root folder. So instead of the above steps, directly extracting your lha file to disk, you might want to extract, then copy folder contents. Example:

> format drive df0: name my_floppy_disk
> makedir RAM:adfdir
> lha x myarchive.lha RAM:adfdir
> copy RAM:adfdir/#? df0: all clone




If you're using an emulator, you're done. Quit emulator, use ADF as desired.

Using a hardware Amiga with physical floppy, you'll need to read the floppy to ADF - you can use transadf from AmiNet, or any other ADF-reading tool. Example:

> transadf df0: my_adf.adf


To make the disk (ADF) bootable:

Run "install". example:

> install df0:

Then create a text file "s/startup-sequence" that contains the commands to be run on boot - you can use AmigaOS's ed, or any other text editor. Example:

> ed df0:s/startup-sequence

Example: If you want to run "mygame" from folder "myfolder", put this line into the "startup-sequence" file:

myfolder/mygame

Thursday, February 27, 2020

How do I create Amiga-compatible lha archives on other platforms (Linux)?

Problem

You've created an lha archive, e.g. on Linux, and your Amiga's lha is unable to decompress it.

Error message: "ERROR on file '...' : Unknown compression"

Possible reason

The lha version used to create the archive is newer than your Amiga's lha version, and/or uses a different default compression method.

You might have obtained your Amiga lha binaries from AmiNet, by downloading the self-extracting lha archive which contains them, and have used these to extract other lha archives from AmiNet.
http://aminet.net/search?query=lha.run
Depending on when you did so, these binaries might be quite old, and have different options than the lha version you're using e.g. on your Linux machine, including compression method settings.

Solution

Manually set lha compression method when creating archive - lh5 will probably the best supported. Here's a quick overview of some lha versions, and the most commonly available compression methods:

Linux "LHa for UNIX version 1.14i-ac20081023":

lha a -o5 filename.lha myfile
      use lh5 compression

lha a -o6 filename.lha myfile
      use lh6 compression

Amiga "LhA Evaluation V1.54 - Copyright (c) 1993 by Stefan Boberg":
(This version does not support lh6 compression.)

lha a -1 filename.lha myfile
      use lh4 compression

lha a -2 filename.lha myfile
      use lh5 compression

Amiga "LhA Freeware Version 2.15":

lha a -2 filename.lha myfile
      use lh5 compression

lha a -3 filename.lha myfile
      use lh6 compression


To check an archive's compression method, use "vv":

lha vv filename.lha

See lha's man page / info / help / version texts for detailed info about more compression options (lh1, lh7, ...).

* * *

Thursday, December 6, 2018

How to set up NFS and mount on Amiga

Here's one way to set up an nfs server under Linux, and mount an nfs share on your Amiga.

Requirements / prerequisites


We're using:

- Linux Fedora 25 (x86_64 hardware)
Probably any Linux will do, but configuration files and command syntax may differ. NFS must be supported, obviously. We need to be able to set up a NFS v2 server with udp support. This is non-standard on Fedora 25.

- Amiga 1200
Any Amiga that's able to run AmiTCP3.0b2, and connect to the machine running our Linux, will do.

- TCP/IP connection via AmiTCP3.0b2
We're assuming a working AmiTCP3.0b2 installation, which provides the nfs tools required on the Amiga side, and an active TPC/IP connection to the Linux machine.


In this example we're using IP addresses...

10.10.10.1 for the Amiga and
10.10.10.2 for the Linux box

Our netmask is: 255.255.255.0


We'll be using a Linux user account called "ami" with UID (user id) 1000 and GID (group id) 1000.

We'll create a user account on the Amiga accordingly ("ami", UID 1000, GID 1000) to avoid access-rights confusion. The Amiga user's home directory will be:

Work:home/ami


Our nfs share (the Linux directory visible to the Amiga) will be:

/home/ami

This directory - in this case it's the user "ami"'s home directory - should be accessible to the Linux-user "ami", thus it will also be accessible the same way to the (newly created) Amiga-user "ami" via nfs.

In your setup, replace numbers/paths/names with your own values as required.


Linux (IP 10.10.10.2)


Fedora 25's nfs server needs to be "downgraded" to be compatible with AmiTCP3.0b2's nfs tools. nfs version must be 2, and AmiTCP only supports nfs via udp protocol. If udp is not enabled, you will get a RPC error message on the Amiga side.

In Fedora 25, the config file is...

/etc/sysconfig/nfs

...and the arguments required are:

# Optional arguments passed to rpc.nfsd. See rpc.nfsd(8)
RPCNFSDARGS="-V 2 --udp"



Next tell nfs server which directories we want to share with the Amiga or other machines, and who's allowed to access them.

The file...

/etc/exports

...contains the setup - use the example below, or add the second line to your file if you already have one. You can see our shared directory, the 10.10.10.xxx range of IP addresses allowed to access it, and our netmask:

/ *(ro,fsid=0)
/home/ami 10.10.10.0/255.255.255.0(rw,nohide,insecure,no_subtree_check,no_root_squash)


NOTE: These are two lines, each starting with "/".

You could also use e.g. just 10.10.10.2, restricting access to this IP address only.

NOTE: Try "man exports" on your Linux machine if you want to know more about the configuration file.



Now we can start (or restart) the nfs server. On Fedora 25 the command is: 

systemctl start nfs-server.service

NOTE: On other Linux systems, you may have to start portmap or rpcbind service first. On Fedora 25 rpcbind.service is enabled by default.


To see if your nfs server is ready enter:

rpcinfo -p

...which will probe and print services registered with the portmapper (see note above). You should see a list roughly like this:

[root@linux]# rpcinfo -p
   program vers proto   port  service
    100000    4   tcp    111  portmapper
    100000    3   tcp    111  portmapper
    100000    2   tcp    111  portmapper
    100000    4   udp    111  portmapper
    100000    3   udp    111  portmapper
    100000    2   udp    111  portmapper
    100024    1   udp  38814  status
    100024    1   tcp  53319  status
    100005    1   udp  20048  mountd
    100005    1   tcp  20048  mountd
    100005    2   udp  20048  mountd
    100005    2   tcp  20048  mountd
    100005    3   udp  20048  mountd
    100005    3   tcp  20048  mountd
    100003    2   tcp   2049  nfs
    100003    3   tcp   2049  nfs
    100003    4   tcp   2049  nfs
    100227    2   tcp   2049  nfs_acl
    100227    3   tcp   2049  nfs_acl
    100003    2   udp   2049  nfs
    100003    3   udp   2049  nfs
    100227    2   udp   2049  nfs_acl
    100227    3   udp   2049  nfs_acl
    100021    1   udp  39239  nlockmgr
    100021    3   udp  39239  nlockmgr
    100021    4   udp  39239  nlockmgr
    100021    1   tcp  33909  nlockmgr
    100021    3   tcp  33909  nlockmgr
    100021    4   tcp  33909  nlockmgr


The important lines are the ones with a "2" in the "vers" = "version column. Remember configuring nfs server for version-2 support?
We need a version-2 portmapper supporting udp (line 6), same for mountd (line 11), nfs (line 15), and nfs_acl (line 18).


If you got this far without errors, you're done with the Linux part.

For setup/testing it's probably best to make sure your Linux's firewall is off. You can examine network traffic/ports and adjust your firewall settings later.


Amiga (IP 10.10.10.1)


Now we can partly test the setup from the Amiga side using "rpcinfo", which comes with AmiTCP3.0b2:

rpcinfo -p 10.10.10.2

This should give you the same list as on the Linux side. (See above.)

NOTE: Output syntax may differ slightly - service names (rightmost column) might be missing.


We need to specify a user account on the Amiga side. For a proper setup it should match the Linux user "ami"'s UID and GID (see "Requirements / prerequisites" above).

NOTE: The user's name is actually not relevant to nfs, but for simplicity and clearness we also call it "ami", just like the Linux one.

Before creating an Amiga user for AmiTCP, we first create a home directory for him/her:

makedir Work:home/ami



Next, create the user account. Edit the file...

AmiTCP:db/passwd

...and add a line that looks like this:

ami|*|1000|1000|Amiga 1200|Work:home/ami|shell

Separated by pipes ("|"), these are...
...user name
...password ("*" = empty)
...UID (user id)
...GID (group id)
...real name
...home directory
...login shell command

NOTE: Try "man 5 passwd" on Fedora 25 for an explanation of the password-file. (Linux uses colons instead of pipes here.)


Probably not required, but it's always good to set a password for a user - do so by entering:

AmiTCP:bin/passwd ami

...and enter your desired password. (Twice.)

NOTE: Now your AmiTCP:db/passwd file contains an encrypted password instead of an asterisk in the password-field for user "ami".


Next set up the nfs share (directory) for the Amiga - to do so, we edit the file...

AmiTCP:db/ch_nfstab

...and add this line:

10.10.10.2:/home/ami NFS: user ami umask 0755

As you can see there's our Linux's IP address, and the shared Linux directory.
Next is the local (Amiga) name for the share ("NFS:"), with a trailing colon, just like a logical drive ("assign") on the Amiga. Finally the user account we want to use, and a umask, defining which access-rights a file written to the share will have.

NOTE: "0755" basically means: owner can read, write (also delete), and execute file, others can just read and execute. Here's an extensive explanation of Linux file permissions: https://help.ubuntu.com/community/FilePermissions


And here cometh the moment of truth!

Finally, to mount your nfs share on your Amiga, enter this:

AmiTCP:bin/ch_nfsmount nfs: 

NOTE: Needs stacksize > 30000. You will get an error message if it's insufficient. Use e.g. "stack 100000" to set it to 100000.

As you can see the argument to "ch_nfsmount" is our local nfs share name "nfs:". (AmigaDOS is not case sensitive.)

A disk icon named "NFS" should pop up on your workbench, and you're ready to use your Linux's directory from your Amiga! 


Debugging


Network debugging etc. is very limited on the Amiga:

Test your TCP/IP network connection:

ping 10.10.10.2

List your Linux's registered RPC services from the Amiga side:

rpcinfo -p 10.10.10.2


Linux has some powerful network debugging tools:

You can switch on kernel debugging modules, then watch your Linux log files (syslog, kernel log) for output:

rpcdebug -m nfsd -s all rpcdebug -m rpc -s all

NOTE: This sets all debug flags for modules "nfsd" and "rpc", enabling debug logging. To clear use "-c" instead of "-s".

"wireshark" is a powerful network traffic analyzing tool, that allows to capture, and view network traffic in full detail.


Notes

  • Your mileage may vary. There are a couple of bugs and instabilities along the way. Don't be too harsh with nfs on the Amiga. If in doubt reset and retry. (See next note, too.)
  • An update to the nfs tools provided with AmiTCP 3.0b2 is available on AmiNet, including docs: http://aminet.net/package/comm/net/chnfsc102-30b2
  • AmiTCP is known for it's extensive documentation. Read the docs for general TCP/IP information, and details about AmiTCP's components.
  • Your Linux most likely contains man-pages on the network commands and configuration files used here. The commands provided with AmiTCP 3.0b2 are more or less compatible.
  • Special thanks to Markus "Tulpi" T. for massive technical and moral support!


Saturday, September 30, 2017

how do I get rid of the "Ebola" virus?

Possible symptoms:
executable file size grows by 1116 bytes after run.

Possible reasons:
- system infected with Ebola virus

Possible solutions:
- remove Ebola virus:
  1. get antivirus software (e.g. VirusZ or VirusExecutor) from http://www.vht-dk.dk/ or from AmiNet: http://aminet.net/search?query=virus
  2. put antivirus on some media that can be mounted from shell
  3. have a write-protected, virus-free workbench bootdisk*
  4. boot from write-protected, virus-free workbench bootdisk, mount media with antivirus software as required
  5. run antivirus software, scan all drives / files, hit "repair file" or "remove virus" as indicated by antivirus software ("Ebola" can be removed successfully. May fail on OS3.9 "SetPatch", though. Replace bad file with good one from original installation media, if required.)
  6. run HDToolbox, check every partition of harddisc for RDB's installed filesystem: go to "Advanced options..." -> "Filesystem..." -> "Change/Update..." and compare size of installed filesystem with filesystem on disk (now scanned/cleaned). Re-Install filesystem from disk, if it's 1116 bytes smaller than the one installed in RDB. (Keep in mind AmigaOS versions: compare filesystems of equal versions.)
  7. switch off Amiga and let rest for at least 30 seconds
*) not strictly required, but may avoid multiple de-contamination runs/reboots

Tuesday, August 15, 2017

why does vbcc's printf()/snprintf()... not respect %f in format strings?

Problem:
using printf("%f", 1.2);
prints
   %f
instead of
   1.20000

Possible reasons:
no math lib included

Possible solutions:
- add -lmieee or -lmsoft (or other math library -> see vbcc manual) to list of compiler options
- put -lmieee (or whatever math lib you're using) before -lvc in list of compiler libs options

Saturday, August 12, 2017

how do I properly read user input using a AmigaDOS script?

Problem:
- user input handling via "ask" isn't sufficient
- empty user input (empty string, user just hit return) can't be checked


Possible solution:

this is an example AmigaDOS script asking user for an ip address, and using a default value if user just hits return:

; default value:
set DEF_IP 192.168.178.1
 

; message to user, including default value:
echo "please enter your IP address (default: ${DEF_IP}):"
 

; unset variable before use, for proper testing afterwards:
unset IP

; read user input into variable.
; if user just hits return, variable doesn't get set.
set >nil: IP ?

; get variable, suppress output:
get >nil: IP


; if there was an error, it means variable hasn't been set.
if WARN

    ; use default value if there was an error
    set IP ${DEF_IP}
endif


; print result (default value, or user input)
echo "using IP address: ${IP}"

rawkey-class description strings containing Amiga/RAmiga/LAmiga not working under AmigaOS2.0?

Problem:
- rawkey-class input filter description strings containing Amiga/RAmiga/LAmiga do not work under AmigaOS2.0
- CxFilter() fails when using such a rawkey-class input filter description string

Possible reasons:
because the Amiga keys are called "Command" in OS versions below 3.

Possible solutions:
Use "Command"/"LCommand"/"RCommand" instead of "Amiga"/"LAmiga"/"RAmiga".