Using the Patchblocks software under Linux

From Patchblocks
Jump to: navigation, search

Using the Patchblocks Software Under Linux[edit]

The Patchblocks software is not available for Linux. The workaround described here is not officially supported and may not work on your system. Questions may be raised in the Community Forum.

The Windows version of the Patchblocks software runs reasonably well under Wine, with the following limitations:

  • Dragging and dropping behaves strangely - blocks appear to be stuck to the mouse pointer when in fact they have been dropped.
  • The emulator doesn't work.
  • Writing to the patchblock hardware doesn't work.

The first two problems can be tolerated, the third can be overcome by installing the following shell script in the software's "compile/firmware" directory (giving it the filename "linux_post_process.sh"). The script itself contains installation instructions, and instructions for configuring Wine and Linux.

The emulator may be brought to work if you extract the Installer and copy the content of the $_OUTDIR folder to the folder with the Patchblocks.exe and link or copy the bass.dll from the compile/emulator folder to the folder with the Patchblocks.exe. (tested on Debian 7.11, wine-1.4.1)

#!/bin/bash
 
# This scripts supports the use of the patchblocks software under Wine
# (https://www.winehq.org/) on Linux systems. It has been tested with
# Wine 1.7.2 on OpenSUSE 13.1.
#
# The Patchblocks software treats the patchblock storage as a filesystem, and
# copies the firmware to it. Under Windows the written firmware is contiguous,
# but under Linux the file is split, which is permissible from the FAT
# filesystem perspective, but not what the patchblock expects.
#
# This script (which should be run as part of the compile operation in the
# Patchblocks GUI) writes the firmware to the correct location. In order for
# this script to be run at the correct time, make the following changes to the
# Patchblocks software installation and the operating system configuration:
#
#
### Patchblocks Software Changes ##############################################
#
# First install the Patchblocks software under Wine, then locate the firmware
# compilation directory. From the Wine perspective this will be something like
#
# "C:\users\<user_name>\Local Settings\Application Data\Mindflood Ltd\Patchblocks\compile\firmware"
#
# From the Linux perspective it will be something like
# "/home/<user name>/.wine/drive_c/users/<user_name>/Local Settings/Application Data/Mindflood Ltd/Patchblocks/compile/firmware"
#
# Copy this file ("linux_post_process.sh") to that directory.
#
# The directory should contain a file called "compile.bat". Edit this file,
# adding the line
#
#     linux_post_process
#
# to the end. The result will be that this script is run at the end of the
# compilation process, but in order for that to happen, Wine must be told that
# a file with the extension ".sh" is executable, as follows:
#
### Wine Configuration Changes ################################################
#
# Run Wine RegEdit, by finding it in your menu of applications, or by typing
# "wine regedit" in a terminal. Navigate to:
#
# "HKEY_LOCAL_MACHINE/System/CurrentControlSet/Control/Session Manager/Environment"
#
# Edit the "PATHEXT" entry, adding a semicolon, followed by ".SH" to the end
# of the list.
#
# Note that (depending on what else you do with Wine) this might introduce a
# security vulnerability.
#
### Linux Configuration Changes ###############################################
#
# This script will only work if the patchblock device is writable by the
# current user. This can be achieved with a udev rule such as this:
#
#    ATTRS{idVendor}=="04cc", ATTRS{idProduct}=="0003", GROUP:="users"
#
# appearing in a file such as "/etc/udev/rules.d/98-patchblocks.rules"
#
# The exact details of this depend on the Linux distribution. Look for
# operating system documentation on "Udev Rules" if this filename seems not to
# be correct.
#
### Unmounting Permissions ####################################################
#
# It is also necessary for ordinary users to be able to umnount the patchblocks
# filesystem. In this script this is done with "umount.udisks2". This will not
# be the correct approach on all Linux systems, so consult your operating
# system documentation and modify this script if necessary.
#
###############################################################################
 
firmware=firmware.bin
 
AWK=/usr/bin/awk
DD=/usr/bin/dd
DF=/usr/bin/df
HEAD=/usr/bin/head
UMOUNT=/usr/sbin/umount.udisks2
 
# Does this firmware file exist?
if ! [ -f "${firmware}" ]
then
    echo "${firmware} missing - perhaps not yet compiled"
    exit 1
fi
 
# Try to identify the patchblock device file, and check permissions
dev_file=`df -k | awk '/CRP DISABLD/ {print $1; exit}'`
if [ "${dev_file}" == "" ]
then
    echo "Cannot identify patchblock device"
    exit 1
fi
 
if ! [ -w "${dev_file}" ]
then
    echo "patchblock device ${dev_file} is not writable"
    exit 1
fi
 
# Unmount the device file before writing to it
if ! ${UMOUNT} "${dev_file}"
then
  echo "Could not unmount patchblock device ${dev_file}"
  exit 1
fi
 
# Write the firmware at an offset of 2048 bytes
if ! ${DD} bs=1024 if="${firmware}" of="${dev_file}" seek=2
then
  echo "Failed to write firmware to ${dev_file}"
  exit 1
fi
 
echo "Firmware written, patchblock can be unplugged"