Skip to content

thomasfaingnaert/scriptable-guitar-pedal

Repository files navigation

A scriptable guitar pedal

Build Status

Building

GNU/Linux (native compilation)

The following instructions are for Debian-based distributions. Change the commands according to the distribution you are using.

  1. Install the following prerequisites:
  • CMake
  • GNU Toolchain
  • Make
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install cmake build-essential
  1. Clone the repository and build the project:
git clone https://github.com/thomasfaingnaert/scriptable-guitar-pedal
mkdir build
cd build
cmake ../scriptable-guitar-pedal
make
  1. Run the executable:
chmod +x ./scriptable-guitar-pedal
./scriptable-guitar-pedal

Windows (cross compilation)

  1. Install the following prerequisites, and make sure they are in your PATH:
  1. Clone the repository and build the project:
git clone https://github.com/thomasfaingnaert/scriptable-guitar-pedal
mkdir build
cd build
cmake -G"NMake Makefiles" -DCMAKE_TOOLCHAIN_FILE="../scriptable-guitar-pedal/cmake/Toolchain.cmake" ../scriptable-guitar-pedal
nmake

GNU/Linux (cross compilation)

  1. Install the following prerequisites:
  • CMake
  • GNU Toolchain for ARM
  • Make

If you are using Ubuntu or one of its derivatives:

sudo apt install make cmake binutils-arm-linux-gnueabihf gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf

If you are using Fedora:

sudo dnf copr enable lantw44/arm-linux-gnueabihf-toolchain
sudo dnf install make cmake arm-linux-gnueabihf-{binutils,gcc,glibc}

Otherwise, change the commands according to the distribution you are using.

  1. Clone the repository and build the project:
git clone https://github.com/thomasfaingnaert/scriptable-guitar-pedal
mkdir build
cd build
cmake -DCMAKE_TOOLCHAIN_FILE="../scriptable-guitar-pedal/cmake/Toolchain.cmake" ../scriptable-guitar-pedal
make

Configuring the PRU

These instructions are for the Beaglebone image Debian 9.3 2018-03-05 4GB SD IoT. They may or may not work for you if you use a different one.

  1. Make sure you can access the internet on the BeagleBone Black. This can be done by configuring your internet adapter on your PC to share its connection with the Beaglebone. Create a script internet.sh with the following contents:
#!/usr/bin/env bash
route add default gw 192.168.7.1
echo "nameserver 8.8.8.8" >> /etc/resolv.conf

Finally, run the script with sudo:

chmod +x ./internet.sh
sudo ./internet.sh
  1. Update all packages:
sudo apt update
sudo apt upgrade
  1. Delete RoboticsCape, as it blacklists the uio_pruss module
sudo apt purge roboticscape
  1. Apply the Xenomai patches to the kernel using:
cd /opt/scripts/tools/
git pull
sudo ./update_kernel.sh --ti-xenomai-kernel --lts-4_9
sudo reboot

Finally, you can check if you are running the right kernel using:

uname -a

This should output something similar to Linux beaglebone 4.9.88-ti-xenomai-r107 #1 SMP PREEMPT Sat Mar 24 09:29:27 UTC 2018 armv7l GNU/Linux.

  1. Next, we need to install our custom overlay:
cd device-tree/
make
sudo make install
  1. Enable it by copying uEnv-pru.txt to the boot/ folder:
cd boot/
sudo cp uEnv-pru.txt /boot/uEnv.txt
  1. The UIO driver should now be loaded. You can verify this by running:
lsmod | grep uio
ls /dev/uio*
  1. If you want to assemble PRU Assembly files on your PC, you should install the PRU assembler from https://github.com/beagleboard/am335x_pru_package. Otherwise, you could copy the *.p files to the BBB using SCP and assemble them there. To assemble a file test.p, you can use:
pasm -b test.p
  1. Install the RTDM kernel module from https://github.com/thomasfaingnaert/rtdm_pruss_irq:
wget https://github.com/thomasfaingnaert/rtdm_pruss_irq/releases/download/v1.0/rtdm_pruss_irq.ko
sudo cp rtdm_pruss_irq.ko /lib/modules/`uname -r`/extra
sudo depmod -a
sudo modprobe rtdm_pruss_irq
  1. Run the PRU loader to execute the PRU code:
./scriptable-guitar-pedal test.bin

Building the ASoC codec driver

GNU/Linux - Fedora (cross compilation)

These instructions are for Fedora based distributions. Change the commands according to the distribution you are using.

  1. Clone the official BeagleBoard and BeagleBone kernel repository and checkout the version the BeagleBone is running:
git clone https://github.com/beagleboard/linux
cd linux
git checkout 4.9.82-ti-r102
  1. Make sure you have no stale .o files and dependencies lying around:
make mrproper
  1. Modularize the ASoC codec driver:
mkdir ../build
make O=../build ARCH=arm bb.org_defconfig
make O=../build ARCH=arm menuconfig

Navigate to Device Drivers/Sound Card Support/Advanced Linux Sound Architecture/ALSA for SoC audio support/CODEC drivers and modularize Cirrus Logic CS4271 CODEC (I2C).

  1. Compile the kernel:
make O=../build ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf-
  1. Copy the modules on your to the BeagleBone Black:
scp ../build/sound/soc/codecs/snd-soc-cs4271-i2c.ko ../build/sound/soc/codecs/snd-soc-cs4271.ko debian@beaglebone.local:~
  1. Install the modules on the BeagleBone Black:
ssh debian@beaglebone.local
sudo mv snd-soc-cs4271-i2c.ko snd-soc-cs4271.ko /lib/modules/4.9.82-ti-r102/extra/
sudo depmod -a

Transferring to BeagleBone Black

To transfer the executable to your BeagleBone Black, you can use SSH, e.g. using PSCP (PuTTY Secure Copy) on Windows or SCP (Secure Copy) on GNU/Linux:

  1. Copy the executable on your computer to the BeagleBone Black:
pscp scriptable-guitar-pedal debian@192.168.7.2:/home/debian/scriptable-guitar-pedal

If you are using scp, change pscp to scp. Also make sure to change the username (debian), destination path (/home/debian/scriptable-guitar-pedal) and IP address (192.168.7.2) if required.

  1. Log in to the BeagleBone Black using SSH, and run the application:
chmod +x ./scriptable-guitar-pedal
./scriptable-guitar-pedal

Using a custom Ne10 installation

The repository already includes a version of Ne10 in include/ne10 and lib/libNE10.a. If you want to use a custom Ne10 installation, you have to set the CMake variables NE10_INCLUDE_DIRS and NE10_LIBRARIES to point to the Ne10 include directory and library file, respectively. An example when cross compiling on Windows:

cmake -G"NMake Makefiles" -DCMAKE_TOOLCHAIN_FILE="../scriptable-guitar-pedal/cmake/Toolchain.cmake" -DNE10_INCLUDE_DIRS="/path/to/ne10/inc" -DNE10_LIBRARIES="/path/to/ne10/build/modules/libNE10.a" ../scriptable-guitar-pedal