Modding ansible firmware

wondering if anyone here can help me modify the ansible firmware?

i’d like to replace the default scales available in “levels” with some of my own.

i think this is where i’d make my changes: https://github.com/monome/libavr32/blob/86af65cef1130e4a40dd3616add84198f521bd0b/src/music.c

yeah?

i have xcode & homebrew installed… just no idea how to compile!

Can you have a go at following the instructions from here. I know they’re for compiling teletype rather than ansible, but getting all the tools installed is half the battle. Once you can compile the teletype firmware I can help you get ansible compiling.

And yes, I think that is the correct location for scale editing. But I’ve not used levels so maybe someone else can comment…

thanks for pointing me to that guide. downloading the avr toolchain now.

all was moving smoothly until i hit this:

checking for correct version of gmp.h... no
configure: error: Building GCC requires GMP 4.1+ and MPFR 2.3.2+.
Try the --with-gmp and/or --with-mpfr options to specify their locations.
Copies of these libraries' source code can be found at their respective
hosting sites as well as at ftp://gcc.gnu.org/pub/gcc/infrastructure/.
See also http://gcc.gnu.org/install/prerequisites.html for additional info.
If you obtained GMP and/or MPFR from a vendor distribution package, make
sure that you have installed both the libraries and the header files.
They may be located in separate packages.
make: *** [stamps/build-gcc] Error 1

Did you type the following in:

brew install mpfr gmp libmpc texinfo dfu-programmer

If you did, can you instead tell me your OS? And the output of brew doctor and brew config.

yeah, i typed that. shows everything is installed:

Warning: mpfr-3.1.3 already installed
Warning: gmp-6.1.0 already installed
Warning: libmpc-1.0.3 already installed
Warning: texinfo-6.0 already installed
Warning: dfu-programmer-0.7.2 already installed

i’m on OS X 10.11.6

brew doctor threw a bunch of warnings. do i need to attend to all of these?

Warning: /usr/local/sbin isn't writable.

This can happen if you "sudo make install" software that isn't managed
by Homebrew. If a formula tries to write a file to this directory, the
install will fail during the link step.

You should probably change the ownership and permissions of /usr/local/sbin
back to your user account.
  sudo chown -R $(whoami) /usr/local/sbin

Warning: "config" scripts exist outside your system or Homebrew directories.
`./configure` scripts often look for *-config scripts to determine if
software packages are installed, and what additional flags to use when
compiling and linking.

Having additional scripts in your path can confuse software installed via
Homebrew if the config script overrides a system or Homebrew provided
script of the same name. We found the following "config" scripts:
    /Library/Frameworks/Python.framework/Versions/2.7/bin/python-config
    /Library/Frameworks/Python.framework/Versions/2.7/bin/python2-config
    /Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7-config

Warning: Your XQuartz (2.7.7) is outdated
Please install XQuartz 2.7.8:
  https://xquartz.macosforge.org

Warning: Python is installed at /Library/Frameworks/Python.framework

Homebrew only supports building against the System-provided Python or a
brewed Python. In particular, Pythons installed to /Library can interfere
with other software installs.

Warning: Unbrewed dylibs were found in /usr/local/lib.
If you didn't put them there on purpose they could cause problems when
building Homebrew formulae, and may need to be deleted.

Unexpected dylibs:
    /usr/local/lib/liblo.7.dylib
    /usr/local/lib/libmonome.1.1.dylib

Warning: Unbrewed header files were found in /usr/local/include.
If you didn't put them there on purpose they could cause problems when
building Homebrew formulae, and may need to be deleted.

Unexpected header files:
    /usr/local/include/monome.h

Warning: Broken symlinks were found. Remove them with `brew prune`:
    /usr/local/bin/2to3-3.5
    /usr/local/bin/easy_install-3.5
    /usr/local/bin/idle3
    /usr/local/bin/idle3.5
    /usr/local/bin/pip3
    /usr/local/bin/pip3.5
    /usr/local/bin/pydoc3
    /usr/local/bin/pydoc3.5
    /usr/local/bin/python3
    /usr/local/bin/python3-32
    /usr/local/bin/python3-config
    /usr/local/bin/python3.5
    /usr/local/bin/python3.5-32
    /usr/local/bin/python3.5-config
    /usr/local/bin/python3.5m
    /usr/local/bin/python3.5m-config
    /usr/local/bin/pyvenv
    /usr/local/bin/pyvenv-3.5

Warning: Your Homebrew is outdated.
You haven't updated for at least 24 hours. This is a long time in brewland!
To update Homebrew, run `brew update`.

brew config:

HOMEBREW_VERSION: 0.9.5
ORIGIN: https://github.com/Homebrew/homebrew
HEAD: a69b2903014466453cf14a3ae0d98aaa419e9044
Last commit: 10 months ago
HOMEBREW_PREFIX: /usr/local
HOMEBREW_REPOSITORY: /usr/local
HOMEBREW_CELLAR: /usr/local/Cellar
HOMEBREW_BOTTLE_DOMAIN: https://homebrew.bintray.com
CPU: 8-core 64-bit haswell
OS X: 10.11.6-x86_64
Xcode: 8.1
CLT: N/A
Clang: 8.0 build 800
X11: 2.7.7 => /opt/X11
System Ruby: 2.0.0-p648
Perl: /usr/bin/perl
Python: /Library/Frameworks/Python.framework/Versions/2.7/bin/python => /Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python
Ruby: /usr/bin/ruby => /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby
Java: 1.6.0_65-b14-468

thanks for your help with this!

Okay, first thing to try is:

xcode-select --install

this will install the command line tools (CLT) (a window will open asking you to install them).

Then go into the avr32-toolchain directory and type the following to try the build again.

make clean
PREFIX=$HOME/avr32-tools make install-cross

Otherwise… the next simplest option would be to use VMWare or VirtualBox or a Linux computer.

Failing that we’ll have to work through a variety of different things.

do you mean avr32-tools?

if so, i get:

make: *** No rule to make target clean. Stop.

No I mean the avr32-toolchain directory that you got from the git clone.

Does that make sense?

(and sorry it’s being a pain, once we get if fixed I’ll try and update the instructions with whatever we’ve learnt)

success! thanks for clarifying.

this looks like a proper teletype build, yeah?

CC      ../module/main.o
CC      ../src/command.o
CC      ../src/helpers.o
CC      ../src/state.o
CC      ../src/table.o
CC      ../src/teletype.o
CC      ../src/euclidean/euclidean.o
CC      ../src/euclidean/data.o
CC      ../src/ops/op.o
CC      ../src/ops/constants.o
CC      ../src/ops/controlflow.o
CC      ../src/ops/delay.o
CC      ../src/ops/hardware.o
CC      ../src/ops/maths.o
CC      ../src/ops/metronome.o
CC      ../src/ops/patterns.o
CC      ../src/ops/queue.o
CC      ../src/ops/stack.o
CC      ../src/ops/variables.o
CC      ../libavr32/src/adc.o
CC      ../libavr32/src/events.o
CC      ../libavr32/src/fix.o
CC      ../libavr32/src/font.o
CC      ../libavr32/src/i2c.o
CC      ../libavr32/src/init_teletype.o
CC      ../libavr32/src/init_common.o
CC      ../libavr32/src/kbd.o
CC      ../libavr32/src/region.o
CC      ../libavr32/src/screen.o
CC      ../libavr32/src/timers.o
CC      ../libavr32/src/usb.o
CC      ../libavr32/src/util.o
CC      ../libavr32/src/usb/ftdi/ftdi.o
CC      ../libavr32/src/usb/ftdi/uhi_ftdi.o
CC      ../libavr32/src/usb/hid/hid.o
CC      ../libavr32/src/usb/hid/uhi_hid.o
CC      ../libavr32/src/usb/midi/uhi_midi.o
CC      ../libavr32/src/usb/midi/midi.o
MKDIR   avr32/drivers/adc/
CC      avr32/drivers/adc/adc.o
MKDIR   avr32/drivers/flashc/
CC      avr32/drivers/flashc/flashc.o
MKDIR   avr32/drivers/gpio/
CC      avr32/drivers/gpio/gpio.o
MKDIR   avr32/drivers/intc/
CC      avr32/drivers/intc/intc.o
MKDIR   avr32/drivers/pm/
CC      avr32/drivers/pm/pm.o
CC      avr32/drivers/pm/pm_conf_clocks.o
CC      avr32/drivers/pm/power_clocks_lib.o
MKDIR   avr32/drivers/spi/
CC      avr32/drivers/spi/spi.o
MKDIR   avr32/drivers/tc/
CC      avr32/drivers/tc/tc.o
MKDIR   avr32/drivers/twi/
CC      avr32/drivers/twi/twi.o
MKDIR   avr32/drivers/usart/
CC      avr32/drivers/usart/usart.o
MKDIR   avr32/drivers/usbb/
CC      avr32/drivers/usbb/usbb_host.o
MKDIR   avr32/services/fs/fat/
CC      avr32/services/fs/fat/fat.o
CC      avr32/services/fs/fat/fat_unusual.o
CC      avr32/services/fs/fat/file.o
CC      avr32/services/fs/fat/navigation.o
MKDIR   avr32/utils/debug/
CC      avr32/utils/debug/print_funcs.o
MKDIR   common/services/storage/ctrl_access/
CC      common/services/storage/ctrl_access/ctrl_access.o
MKDIR   common/services/usb/class/msc/host/
CC      common/services/usb/class/msc/host/uhi_msc.o
CC      common/services/usb/class/msc/host/uhi_msc_mem.o
MKDIR   common/services/spi/uc3_spi/
CC      common/services/spi/uc3_spi/spi_master.o
MKDIR   common/services/usb/uhc/
CC      common/services/usb/uhc/uhc.o
MKDIR   common/services/clock/uc3b0_b1/
CC      common/services/clock/uc3b0_b1/sysclk.o
MKDIR   avr32/utils/startup/
AS      avr32/utils/startup/trampoline_uc3.o
AS      avr32/drivers/intc/exception.o
LN      teletype.elf
SIZE    teletype.elf
teletype.elf  :
section                size         addr
.reset               0x200c   0x80000000
.rela.got               0x0   0x8000200c
.init                  0x1a   0x8000200c
.text                0xd9b0   0x80002028
.exception            0x200   0x8000fa00
.fini                  0x18   0x8000fc00
.rodata              0x398c   0x8000fc18
.lalign                 0x4   0x800135a4
.dalign                 0x4          0x4
.ctors                  0x8          0x8
.dtors                  0x8         0x10
.jcr                    0x4         0x18
.got                    0x0         0x1c
.data                0x1d44         0x1c
.balign                 0x0       0x1d60
.bss                 0x1fc8       0x1d60
.heap               0x122d8       0x3d28
.comment               0x2f          0x0
.debug_aranges       0x21c0          0x0
.debug_pubnames      0x4e96          0x0
.debug_info         0x4471d          0x0
.debug_abbrev        0x961d          0x0
.debug_line         0x26c60          0x0
.debug_frame         0x6378          0x0
.debug_str           0xd3bc          0x0
.debug_loc          0x12dd3          0x0
.debug_macinfo    0x20d519a          0x0
.stack               0x2000      0x16000
.flash_nvram        0x23e84   0x80040000
.debug_ranges        0x3ac8          0x0
Total             0x21c9f86


   text	   data	    bss	    dec	    hex	filename
0x1357a	 0x1d58	0x3a12c	 324606	  4f3fe	teletype.elf
OBJDUMP teletype.lss
NM      teletype.sym
OBJCOPY teletype.hex
OBJCOPY teletype.bin

Yep! I’ll insert a note into the instructions about installing the command line tools on OSX.

Right, to compile ansible do the following:

git clone --recursive https://github.com/monome/ansible.git
cd ansible
cd src
export PATH="$HOME/avr32-tools/bin:$PATH" # only need to do this once per terminal session
make

You’ll end up with an ansible.hex file in the src directory. Are you okay flashing it?

Once you’ve got that working you can start fiddling with your scales. Replace an existing scale rather than add a new one.

rad! i’ve flashed modules a few times with update_firmware.command - i see that in the src directory.

i’m a little unclear on the order of events. i understand i’d use git clone to pull down the ansible repo, but do i run the rest of the commands before modifying music.c? and after i’ve modified that file, which of those commands should i run in order to compile? just make?

thanks!

Yes you can use this, or if you’ve got the terminal open in the src directory you can just type ./flash.sh.

To recompile after you’ve edited a file you need to have an open terminal in the ansible/src directory and then just type make as you’ve worked out.

The only complication is that for each newly opened terminal window you need to type:

export PATH="$HOME/avr32-tools/bin:$PATH"

to get the compiler on the path. This is saved for that windows session, but it will be lost as soon as the window is closed.


Hope that helps… now you’re a firmware hacker :sunglasses:

3 Likes

yeah that totally makes sense!

one more question re: music.c

i’m seeing that all of the strings include 7 values:

{2, 2, 1, 2, 2, 2, 1}, // ionian

do my custom scales need to be the same length? what if i only want 5 note scales?

That’s less straightforward. First I’d confirm that those values are the ones you need to edit. It’s possible that they aren’t. (I haven’t done any coding on the ansible, and I don’t own an arc, so haven’t used levels.)

If you’ve confirmed that they are the values you need to edit then…

On the highlighted line you need to change the i1 % 7 to i1 % 5 if you only have 5 notes in your scale. But it will limit all scales to 5 notes (and I can’t promise it will work either, as I’m flying blind here).

PR to mention the Xcode command line tools. I’ve been burned way too many times by not having it installed.

i tried this:
{2, 2, 3, 2, 3, 0, 0},

and it works!

thanks again for showing me the ropes!

3 Likes

I appreciate the legwork. I’m only a couple days into owning a Grid & Ansible, but I started considering doing just this. Maj Pent FTW!

1 Like

Can’t wait to see what you come up with, Bryan!

1 Like

following this with wide eyes as I may be jumping on an arc/ansible combo from the store