MI Firmware build environment on RaspberryPi / Ubuntu

Hi all,
I’ve spent a few hours setting up a toolchain for building MI firmware on one of my Raspberries, perhaps this is useful for someone else too so I thought I should share it :slight_smile:
(Note: This is not a complete step-by-step guide with every keystroke documented so it might not be that beginner-friendly.)

This procedure has been tested on a RaspberryPi with Raspbian (latest updates as of yesterday) and Ubuntu 12.04.2/i386. I would expect 64bit Ubuntu to work as well but I haven’t tested it. (Everything except possibly the udev-non-root fix for avrdude should work on most up-to-date Linuxes).

These steps will install the software in the directory “avr-gcc” in the current user’s home directory.

The installation document for the parts of the AVR tool chain is here:

http://www.nongnu.org/avr-libc/user-manual/install_tools.html (read that too, it’s pretty good).

Used versions:

binutils 2.23.2
gcc 4.3.3
avr-libc 1.7.1

Optional, if you have a programmer:
avrdude 5.11.1

Download links are in the document linked above.

The following additional system packages also need to be installed first:

$ sudo apt-get install flex bison libgmp-dev libmpfr-dev libusb-dev texinfo

note: libusb-dev is only needed if you want to build avrdude with USB support. If not, you can skip it.

Setup environment for installation in directory avr-gcc in current user’s home :

$ export PREFIX=$HOME/avr-gcc
$ export PATH=$PATH:$PREFIX/bin

Make compiles use -O2 flag only (will build w/ debug -g otherwise)

$ export CFLAGS=-O2

Now, for the different components, follow the build guide document linked above:

  • build and install binutils
  • build and install gcc
  • build and install avr-libc

Optional, if you have a programmer:

  • build and install avrdude

If you have an AVRISPmkII USB programmer then by default you need to be root
to use it in Linux. This can be fixed:

Create the file /etc/udev/rules.d/50-avrispmk2.rules with this line in it:

SUBSYSTEM"usb", ATTRS{idVendor}“03eb”, ATTRS{idProduct}==“2104”, GROUP=“plugdev”, MODE=“0666”

Tehn, restart udev:
sudo udevadm control --reload-rules

(You will need to re-plug the USB programmer too if it was already connected. If you still have problems, make sure your user ID is a member of the “plugdev” group.)

Done! :slight_smile:

edit: fixed the worst things that textile did to the initial post… :slight_smile:

For the lazy, on you RaspberryPi do this:

$ wget https://dl.dropboxusercontent.com/u/6764423/avr-gcc-4.3.3-MI-Toolchain-RPi-20130818.tgz

$ tar xfz avr-gcc-4.3.3-MI-Toolchain-RPi-20130818.tgz

PROFIT! :slight_smile:


Me and a few others around here are in the process of designing (read: dreaming) up a Raspberry Pi Sampler- this cold be the missing link! Ordering some Raspberries and getting started Might have to be: the RPi’s interfacing and controlling and 2 PCBs, RPi for sample loading, chopping, assigning to 6-8 voices, sampling engine (modification+filter/FX). Might have some trouble with the limits of 512 MB of RAM, but you can upgrade to 1 GB, apparently…

larsen managed to build the firmware on a Rπ, not running the firmware…

Running the firmware might be a bit of a challenge, you’d need an AMTEL CPU emulator and then a simulation of the circuitry.

@RyanA4 - down boy! I’ve not even figured out what the hell Olivier and Larsen are talking about in this thread yet, where they talk about SPI, bit banging, and a whole lot of other stuff I have no clue about. :wink:

> Running the firmware might be a bit of a challenge, you’d need an AMTEL CPU emulator and then a simulation of the circuitry.

Not that much. All the assembly code is located in one single file - and there are already pure C equivalent for most of the assembly routines. The code that touches the hardware is relatively well isolated.

Well, I’m going to become familiar with the RPi and work on some hypothetical models in Max for Live. Obviously what I lack in coding know how and proficiently with electronics, I make up for with excitement and persistence!

I’m currently rigging up my Aurdino RGB/LED mods for the Monome I lucked into.


I’m in love with the “elements” module and i think something like this could be very useful for my post rock band. But i’m a poor university student :frowning: so i tried to think of alternative methods to have a modal synth like elements at a really low budget… So i thought: why not trying to run elements on a raspberry pi? It is the cheapest solution, i believe, but seems to be not so simple to do…

I’am able to understand and write c/c++ code, so i’ve already downloaded the programs and they don’t seem to be too much difficult to understand.

So i want to ask you: is it actually possible to “install” a module like elements into a raspberry pi? What are the hardware parameters that i have to change to make it possible?

Thank you very much for the attention and hope someone find some minutes to answer :slight_smile:

PS: sorry for my bad english :smiley:

> So i want to ask you: is it actually possible to “install” a module like elements into a raspberry pi?

If you’re willing to spend 2-3 days of coding, yes.

> What are the hardware parameters that i have to change to make it possible?

Write your own GUI around the code in the dsp directory.

Wrapping the Elements code as a PureData external might be a good approach, so you can leverage all of PD for modulation etc. PureData runs well on the RPi, especially the RPi2.

Uhm, seems that wrapping the code as a PD external is a long and hard work to do (class initialization, constructors, destructors and methods are too much different in externals compared to c/c++ syntax)…
Maybe i could begin by creating in pure data the patches with some exciters, envelopes and resonators… But i can’t find where frequencies and q factors are computed! Any help?

It’s not like the method is called SnorfulateNimoxes()

Oh, sure! Thank you very much and sorry for the off topic

pichenettes> It’s not like the method is called SnorfulateNimoxes()

Of course, the real magic in the MI code is hidden in the interstices.

Could we update this for the ARM days :slight_smile: ?
I’m trying to make a Ubuntu laptop toolchain. So far I installed Ubuntu :slight_smile: , GNU for ARM, OpenOCD, and Eclipse. (https://istarc.wordpress.com/)

The steps are (sort of) documented in the setup scripts for the Vagrant based development environment, in particular this: https://github.com/pichenettes/mutable-dev-environment/blob/master/0_install-toolchain.sh
(That whole setup is based on Ubuntu 14.04 if I’m not mistaken, but it should not be that hard to adapt to the latest one… I think :slight_smile: )

Well Ubuntu 14.04 is what I have on my Mutable dedicated laptop :slight_smile:
I tried to follow the steps from pichenettes github readme and failed… for about one night spent on it, so I tried really really hard till I end up writing here… so help a poor guy, would you?
Here is what I’ve got:

1. I installed VirtualBox 5 (downloaded, double-click install, as a windows looser :slight_smile:
2. I installed VirtualBox Extrapack (from command line, although it worked with double click also)
3. I installed Vagrant for Debian 32 (my Ubuntu is on 32bit) (double-click install)

  • here stats the mess in my head: Vagrant installs itself into /opt/vagrant , but I saw that the 0_install-toolchain refer to /home/vagrant

4. I overwritten the Vagrantfile with the one from github.
5. sudo usermod -a -G vboxusers $adeser (adeser is my username) Log out of Ubuntu, log back in
6. vagrant up -did his thing, downloaded all the gizmos…

vagrant up again
Here some red colored text apeared and I got freaked out so I executed the github files:
sudo ./0_install-toolchain.sh = installed a lot of things OK but also some error about /home/vagrant
sudo ./1_clone-code.sh

When I try to run vagrant up it tells me to run the VirtualBox with the same user I created it. (I must be doing something wrong with the usermod command)
I tried sudo vagrant up, and got a different error… and gave up

I know there is a nobrainer error in my attempt, that’s because I’m a linux newbie.
After all this mess, should I reinstall Ubuntu ?

“/home/vagrant” Is not a directory in your hardrive, but in the VM’s filesystem. So you don’t have to change it.

The shellscripts should be run within the VM, not from the host system. Are you sure you ran them from the VM?

I’m having a “DUH” moment. So I’m building this virtual linux machine with a file system of it’s own and run the two 0…sh and 1…sh files inside it, connected via an ssh protocol (as I connect to a raspberry without a display :slight_smile:
I think I’m not there yet, vagrant isn’t running. It has to be something with the usermod. How can I check the user that created the virtualbox, or if the usermod command worked? Can I view this vboxusers file ?