[How To] Use the Katana SDK on Linux

Context
Windows 10 being what it is, I thought it was time for me to move to Linux.
The biggest thing that still kept me on Windows was the Katana devkit & SDK,
so I searched / am searching for a way to make them work under Linux... with some success already after a few hours :)
This is a work in progress, I'll keep updating this when I have new info.

DISCLAIMER:
I'm a total noob in Linux, so don't hesitate to correct me where needed / suggest better solutions.

Related Threads:
- How To Use the Katana SDK on Windows 7
- How to connect the HKT-01 devkit without pci slot
- Recommended (replacement) hard drive for katana dev unit

Current Status
18/11/2016:
  • DAcheck works for the DA part only.
    • Does not work for the GD-M part. Error:
    • Failed to get the drive map for the GDM Device.
    • Please check the GDM Drive is set as a 'Removable Drive'.
  • Codescape seems to work
    • Tested with km2Demo\CheapBump & several other demos (dragonfly, Marble, ...) which seemed to run ok.
  • CodeWarrior works partially
    • Opening/Creating a project, compiling works
    • sending a program to the devkit to debug/run seems to have some issues
  • DBFlash does not work
    • I expect a small patch to Wine should fix this, ie implement ASPI32_SC_GETSET_TIMEOUTS.
    • (even a dummy implementation should work, since that worked on my wnaspi32.dll replacement for Windows 7)
  • GDWorkshop does not work
    • Several patches are needed to Wine to fix this, this is more complicated
Preparation
  • Linux - tested with Manjaro Linux 16.10 with xcfe that I updated on 11/11/2016
  • install Wine, Wine-mono & wine-gecko. I tested with:
  • Wine 1.9.22-1
  • wine-mono 4.6.3-1
  • wine-gecko 2.47-1
​
  • launch the SCSI Generic (sg) module (since it is not loaded by default):
sudo modprobe sg

If you want to launch sg at boot, create a sg.conf file in /etc/modules-load.d/ with following content:
# Load SCSI generic driver (sg) at boot
sg
​
  • install lsscsi to easily find the sg* number of the Katana DA
lsscsi -g​

gives sg10 on my pc:
[2:0:3:0] process CPL KATANA DA 4090 - /dev/sg10​
  • To avoid having to use sudo with wine, grant read & write access to the Katana Debug Adapter (DA)
ls -al /dev/sg10​
shows that by default, you don't have read/write access to the DA:
crw------- 1 root root 21, 10 Nov 11 18:33 sg10 ​

sudo chmod 666 /dev/sg10

If you want this done automatically at boot, adding this command in file /etc/rc.local should do the trick (not the cleanest way I'm certain...):
lsscsi -g |grep 'KATANA DA' |grep -E -o '/dev/sg\w+' |sudo xargs chmod 666​
  • unzip the SDK in a folder if needed
I tested with Katana SDK 11b only.​

Installing
  • launch setup.exe (of the Katana SDK) by right-clicking on the .exe file & choose "open with Wine Windows program loader"
  • follow the instructions of the Setup Wizard:
  • ignore the warning that says you need the latest wnaspi drivers
  • you can select any folder where to install to, I chose to install to a folder in my /home directory
  • ignore the reflash of the firmware
  • if the screen remains black, you might have to click somewhere to make a dialog bog appear
​
  • Launch the dos-prompt in WINE:
wineconsole cmd​
  • go to the /bin directory of CodeWarrior in the SDK:
/Utl/Dev/CodeWarrior/Bin/​
  • launch the batch file: regservers.bat
  • after that, you can launch the CodeWarrior IDE directly from Wine
​
Execution
  • right-click on the .exe file of the application & choose "open with Wine Windows program loader", or
  • launch the application via a terminal:
    • eg: wine DAcheck
  • if you want to debug an application under Wine:
    • winedbg DAcheck
(and press 'c' to continue once you get the winedbg prompt)​
Small status update of 18/11/2016:

- the CodeWarrior IDE works partially
  • previous status:
    • CodeWarrior crashed (Unhandled exception: page fault on read access to 0x00000004 in 32-bit code)
  • current status:
    • the IDE works, can create/open projects & compile code.
    • sending a program to the devkit to debug/run seems to have issues.
    • Tutorial in main post adapted: I forgot to launch regservers.bat, hence it was crashing...
- DBFlash seems to work on my pc
  • previous status:
    • The application launched, but could not communicate with the devkit to retrieve the firmware versions
  • current status:
    • I patched/hacked* the wine source code on my pc:
      • winaspi32.c needed a (dummy) implementation of SC_GETSET_TIMEOUTS
    • Now, DBFlash can retrieve the firmware versions.
    • I'm not trying to flash the firmwares of my devkit yet, I'm not taking risks yet, I'll do that once the rest of the SDK is working.
- DACheck: GD-M test part is going further on my pc, but still has problems
  • previous status:
    • The GD-M test stopped immediately at the very beginning, with error "Please check the GDM Drive is set as a 'Removable Drive'".
  • current status:
    • I patched/hacked* the wine source code on my pc:
      • the GetDriveType function needs to return DRIVE_REMOVABLE for the GD-M drive.
    • The GD-M test can create files on my devkit, but fails when it tries to switch to EMULATOR mode.

Note on "patched/hacked*":

I quickly hardcoded/hacked the wine source code on my pc to see what I need to make these programs work.
Once I know what the programs need, I will have to think about how I can clean the code up so that the Wine people accept to change their source code, which will not always be easy ...
I will update the status of the apps needing a patch in the main tutorial once the patch is available to everyone in Wine

Original thread: https://assemblergames.com/threads/how-to-use-the-katana-sdk-on-linux.64132/