HowTo: Compile MutableInstruments firmware under Win7-64bit step by step

This small HowTo will show you how to compile the firmware for a Mutable Instruments device. The description is valid for the Shruthi-1 as well as for the MidiPal device. In the examples below I’m referencing the Shruthi firmware. If you want to create the MidiPal firmware just replace the references to Shruthi-1 and shruthi by “midipal”.

I know that there are already some threads and small articles on the webpage/forum but i couldn’t see and complete description showing all steps one by one, and also mentioning all the traps you might have to expect.

REMARK: At the moment there seems to be a problem with the code as an error during the compilation for the function “UpdateLedsTask()” shows up. Unfortunately this is nothing i can fix. Anyway, the MidiPal FW compilation just works perfect.

O.K., here we go:

1. Download the following tools:

2. Install the tools on your PC. See the comments below for further details.

  • Install WinAVR wherever you like and let the installation routine add the pathnames to the Windows PATH. After the installation has been finished replace the file named “make” in the WinAVR\\utils\\bin directory with the one you downloaded in the first step. If you want you can rename the original file so that you can go back to version 3.81 if needed.
  • git: When being asked for the PATH envrionment settings by the installer, choice the second option (“Run Git from Windows command prompt”).
    • As the Windows Explorer integration it’s enough to choose “Git Bash Here” only.
  • Python: You don’t have to install the test tools or the documentation if you are not interested in any further Python development.
    • As the Python installation does not change the Windows path you have to do it manually.In Windows go to
    • Start->Control Panel->System->Advanced System settings->Environment variables
    • In the “Sytem variables” section double click on the “Path” variable. At the end enter the path to your Python installation (i.e. “C:\\Program Files\\Python”).
  • Last but not least install the numpy library. Should be straightforward without any further parameters to be changed.

3. Create a directory on your disk where you will put in your code (like c:\\Projects\\MutableInstruments).

4. Start a windows command line prompt in that directory (you can Shift-click on the directory in your Windows explorer and select the “command line here”-option).

5. Clone the repository and activate it by typing in the following commands:

6. Go into the ./avrlib directory and edit the “makefile.mk” file with an editor of your choice.
Look for the following entries:
AVRLIB_TOOLS_PATH
AVRLIB_ETC_PATH
Replace them both with the Windows path to the “bin” directory of your WinAVR installation. IT IS VERY IMPORTANT to put a slash “/” at the end of the path name, NOT a backslash!
Example:
AVRLIB_TOOLS_PATH = C:\\PROGRA~1\\WinAVR\\bin/

As you can see YOU HAVE TO REPLACE PATHNAMES WITH SPACES by using the windows 8.3 naming (you can always check which name is being used by calling “dir /X” from the commandline).

7. Go back into the shruthi-1 directory and start the WinAVR shell by running “sh”.
Then run the following command (the -d option is for showing detailed information only; you can leave it out later):
make -d -f shruthi/makefile

8. If everything goes well a new directory “build” with a subdirectory “shruthi” will be created. Here you will find a file called “shruthi1.hex” which contains the new firmware.

9. Now you can use the python converter to create a .syx or .mid file out of this. For the Shruthi Firmware it should be O.K. to run the following command (still using the sh shell!):
make -d -f shruthi/makefile midi
and/or
make -d -f shruthi/makefile syx
In any case you have problems with this procedure you can also converted it manually:
a) Exit the sh shell by typing “exit”.
b) You should still be in the root directory of your repository.
c) Now run the following command:
python tools\\hex2sysex\\hex2sysex.py build\\shruthi1\\shruthi1.hex --syx --output_file build\\YourOutputFileName.syx
and for the MidiPal use this command:
python tools\\hex2sysex\\hex2sysex.py build\\shruthi1\\shruthi1.hex --page_size 64 --device_id 3 --syx --output_file build\\YourOutputFileName.syx

So that’s all. I hope this helps the community so that we can see even more interesting firmware changes and additions for the Shruthi and the MidiPal.

Thanks to Olivier for making all of his fantastic code available to the public!

2 Likes

Could you please tell me:

  • What’s the error with UpdateLedsTask() (which firmware)? It might be a problem (forgot to commit a file) with the very recent code I wrote to handle the delay filter board.
  • What went wrong when you tried getting a sysex file for the midipal?

Thanks a lot for this, I have moved it to the wiki

O.K., here are some more details:

  • Regarding the version: it’s the latest one on github i cloned this morning.
  • These are the details of the error:

    D:\\PROGRA~2\\WinAVR\\bin/avr-g++ -c -mmcu=atmega644p -I. -g -Os -w -Wall -DF_CPU=20000000 -fdata-sections -ffunction-sections -fshort-enums -fno-move-loop-invariants -DDISABLE_DEFAULT_UART_RX_ISR -DATMEGA644P -DSERIAL_RX_0 -mcall-prologues -fno-exceptions shruthi/shruthi.cc -o build/shruthi1/shruthi.o
    shruthi/shruthi.cc: In function ‘void UpdateLedsTask()’:
    shruthi/shruthi.cc:135: error: ‘struct avrlib::Serial<avrlib::SerialPort<avrlib::BitInRegister<avrlib::UCSR1BRegister, 3u>, avrlib::BitInRegister<avrlib::UCSR1ARegister, 5u>, avrlib::BitInRegister<avrlib::UCSR1BRegister, 4u>, avrlib::BitInR
    egister<avrlib::UCSR1ARegister, 7u>, avrlib::BitInRegister<avrlib::UCSR1BRegister, 7u>, avrlib::BitInRegister<avrlib::UC
    SR1ARegister, 1u>, avrlib::UBRR1HRegister, avrlib::UBRR1LRegister, avrlib::UDR1Register, 32u, 32u>, 115200ul, DISABLED,
    POLLED, false>’ has no member named ‘Disable’

Please let me know if you’ll need any further details.

  • Sorry, “make midi” should be fine. Tried it with the MidiPal and it worked. I slighty changed the wording in the description therefore.

Please get the latest avrlib, I forgot to commit a change in it. Note that each release of the firmware is in its own branch, so you can checkout v096 to get to the latest stable and proven version of the code.

O.K., great. Works perfect now, thanks!
Still having some problems with “make midi” (“make.exe: Nothing to be done for `all’.”) but i can work around it manually, no problem.

Btw. i had to update the python command in my description above as well.

Added the installation description of “numpy” to the HowTo.

Great tutorial. Don’t be disappointed that only pichenettes replied to it. I’m among the dudes directly interested in what you wrote.

Yes, good jorb. Need moar hacks!

Windows is so sick when you try to setup such toolchains. In my case one time I have luck with only arduino/python installed, avrlib makefile.mk edited and python and arduino added to windows path, another time i need WinAVR and MSYS. Both times it works with long filenames.

Just checked with clean install of Windows7 x64.
Here’s the way it works for me

  1. install python-2.5.4.amd64.msi (get from here ) to it’s default destination c:\\python25
  2. unzip arduino-1.0.1-windows.zip (get from here ) to c:\\arduino
  3. Press Win+Pause/Break >Advanced system settings> Environment variables, doubleclick “path” variable and add ;c:\\python25;c:\\arduino\\hardware\\tools\\avr\\utils\\bin to the end of it’s line. (exactly all the bold text) Press Ok, Ok.
  4. Download avril, avril-firmware-tools and shruthi1 source archives from github, extract contents of shruthi(midipal) archive somewhere, than extract contents of avril and avril-firmware-tools archives to shruthi1\\avrlib and shruthi1\\tools folders respectively. Do the same for midipal.
  5. Open avrlib\\makefile.mk in text editor and replace path variables with
    AVRLIB_TOOLS_PATH = C:\\arduino\\hardware\\tools\\avr\\bin/
    AVRLIB_ETC_PATH = C:\\arduino\\hardware\\tools\\avr\\etc/
  6. In the windows shell cd to shruthi folder and type “make”, “make midi” or “make syx” if you need .mid/.syx files. After completing firmware compilation cd to build/shruthi1 (or build/midipal) and look for fresh firmware.

Updated the python command line to convert to .syx format.

hey this could be a chance for me to learn to do it once in a professional manner. are the instructions also true for Windows 7 32 bit ?

Just had a go at this on Win7 32 bit. I followed Schrab’s instructions (getting the x86 version of Python 2.5) and kept getting the depends.mk: No such file or directory error when running make (described in an earlier forum post by Mr_Roboto).

I did two things, one or both may have been required to fix it. Firstly I installed WinAVR, to get to the ‘sh.exe’ mentioned in that thread. (I don’t think this was necessary as the same file resides in the Arduino package, and anyway I didn’t seem to need it) The installation of WinAVR adds the ‘winavr\\utils\\bin’ folder to the path, which might be important.

Secondly I quit the command line prompt I had been using and started a new one (I think an open cmd doesn’t receive changes to the path) - successfully compiled shruthi and ambika_voicecard with just a make in the relevant project folder.
I had to do *make f controller/makefile* to create ambika_controller.hex is this the right way to do it?

Yes, make -f controller/makefile for the mobo code and make -f voicecard/makefile for the voicecard code.

@mangros that’s i’m talking about :wink:
and you’re absolutely right about cmd. PATH variable values reading during shell startup.
I have no more clear windows installtions so now i’m deploing Windows XP in virtual machine, I want to check all the steps with it maybe record step-by-step video.
UPD: try to use c:\\arduino\\hardware\\tools\\avr\\utils\\bin instead of c:\\arduino\\hardware\\tools\\avr\\bin in the Windows PATH variable. I think i’ve made a mistake with it. It’s not simillar to makefile.mk path!

Yes, it’s my fault! Windows path variable sould be c:\\arduino\\hardware\\tools\\avr\\utils\\bin

Here is my video tutoral for W7 x64

(actually just step-by-step screen capture). There’s something strange happened with background music during recording so just mute it.
If anyone needs Windows XP video - tell me. It’s recorded but not edited yet.

1 Like

schrab, you are my personal TutorialHero™

Thanks Frank!
After doing this i’ve understood that screen recording is much easier than taking screenshots and writing comments.
If no one is against this i’ll make future tutorials this manner.

Anyone got avrdude working on Windows 7 64 bit? My setup keeps failing with:

/WinAVR/bin/avrdude -V -p m644p -C /WinAVR/bin/avrdude.conf -c avrispmkII -P usb -B 10 -e -u \\
-U efuse:w:0xfd:m \\
-U hfuse:w:0xd6:m \\
-U lfuse:w:0xff:m \\
-U lock:w:0x2f:m
avrdude: usbdev_open(): did not find any USB device "usb"
make[1]: ***** [fuses] Error 1