Reply to How To Set Up The Midifighter Development Environment in Mac OS X

How To Set Up The Midifighter Development Environment in Mac OS X
How To set up the Midifighter Development Environment
20100224: created by Fatlimey
20110209: Modified for Mac OS X by DJ Overzero (Kevin Reedy)

Developing under Mac OS X

Create a project directory that will hold the libraries and tools, say, "midifighter" in an easy to find location. As many of the tools we will be using are command-line based, keeping the path to this directory short will help keep typing to a minimum. I keep my workspace at "~/Projects/midifighter". ~ is a shortcut for the current user's home directory, which in my case is /Users/kevin.

The source code for the Midifighter firmware can be downloaded from Sourceforge at:


Unzip the source tree into your project directory and you should find the source code (.c and .h files) as well as the project Makefile. The source code is heavily documented and is broken into logical systems with the main program loop residing in "midifighter.c".

The Midifighter zip archive contains the source code only, and so you will need to download two additional sets of libraries that are required to produce working binaries. CrossPack for AVR Development is a set of libraries, compilers, debuggers and command line tools for the AVR series of processors that can be found at:


CrossPack for AVR Development comes with an installer that installs all the tools and adds the install path to the PATH environment variable. This means that all the command line tools are available at the command prompt. You may need to relaunch Terminal for it to pick up these changes though.

Next you will need to download the LUFA libraries for USB on AVR chips. This library, written by he indispensable Dean Camera, can be found at:


Unzip the LUFA-101122.zip file into your midifighter directory. This will expand into a directory named LUFA101122. The resulting layout after installing these tools
should be:
Code:
 ~ (home directory)
  |_ Projects
     |_ midifighter
        |_ LUFA101122
        | |_ ..
        |_ COPYING.txt
        |_ Makefile
        |_ README.txt
        |_ adc.c
        |_ adc.h
        |_ constants.h
        |_ eeprom.c
        |_ eeprom.h
        |_ expansion.c
        |_ expansion.h
        |_ fourbanks.c
        |_ fourbanks.h
        |_ key.c
        |_ key.h
        |_ led.c
        |_ led.h
        |_ menu.c
        |_ menu.h
        |_ midi.c
        |_ midi.h
        |_ midifighter.c
        |_ selftest.c
        |_ selftest.h
        |_ spi.c
        |_ spi.h
        |_ usb_descriptors.c
        |_ usb_descriptors.h
To build the firmware, open a terminal window (Applications/Utilities/Terminal.app). Change the directory to your project directory and build the project using the make command:
Code:
Kevins-MacBook-Pro:~ kevin$ cd Projects/midifighter
Kevins-MacBook-Pro:midifighter kevin$ make -s
The "-s" on the make command silences printout of the actual commands executed (which is optional), but the output should resemble:
Code:
-------- begin --------
avr-gcc (GCC) 4.3.3
Copyright (C) 2008 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Compiling C: midifighter.c
Compiling C: eeprom.c
Compiling C: spi.c
Compiling C: adc.c
Compiling C: led.c
Compiling C: key.c
Compiling C: midi.c
Compiling C: menu.c
Compiling C: selftest.c
Compiling C: expansion.c
Compiling C: usb_descriptors.c
Compiling C: LUFA101122/LUFA/Drivers/USB/LowLevel/Device.c
Compiling C: LUFA101122/LUFA/Drivers/USB/LowLevel/Endpoint.c
Compiling C: LUFA101122/LUFA/Drivers/USB/LowLevel/Host.c
Compiling C: LUFA101122/LUFA/Drivers/USB/LowLevel/Pipe.c
Compiling C: LUFA101122/LUFA/Drivers/USB/LowLevel/USBController.c
Compiling C: LUFA101122/LUFA/Drivers/USB/LowLevel/USBInterrupt.c
Compiling C: LUFA101122/LUFA/Drivers/USB/HighLevel/ConfigDescriptor.c
Compiling C: LUFA101122/LUFA/Drivers/USB/HighLevel/DeviceStandardReq.c
Compiling C: LUFA101122/LUFA/Drivers/USB/HighLevel/Events.c
Compiling C: LUFA101122/LUFA/Drivers/USB/HighLevel/EndpointStream.c
Compiling C: LUFA101122/LUFA/Drivers/USB/HighLevel/HostStandardReq.c
Compiling C: LUFA101122/LUFA/Drivers/USB/HighLevel/PipeStream.c
Compiling C: LUFA101122/LUFA/Drivers/USB/HighLevel/USBTask.c
Compiling C: LUFA101122/LUFA/Drivers/USB/Class/Host/HIDParser.c
Compiling C: LUFA101122/LUFA/Drivers/USB/Class/Device/Audio.c
Compiling C: LUFA101122/LUFA/Drivers/USB/Class/Device/CDC.c
Compiling C: LUFA101122/LUFA/Drivers/USB/Class/Device/HID.c
Compiling C: LUFA101122/LUFA/Drivers/USB/Class/Device/MassStorage.c
Compiling C: LUFA101122/LUFA/Drivers/USB/Class/Device/MIDI.c
Compiling C: LUFA101122/LUFA/Drivers/USB/Class/Device/RNDIS.c
Compiling C: LUFA101122/LUFA/Drivers/USB/Class/Host/CDC.c
Compiling C: LUFA101122/LUFA/Drivers/USB/Class/Host/HID.c
Compiling C: LUFA101122/LUFA/Drivers/USB/Class/Host/MassStorage.c
Compiling C: LUFA101122/LUFA/Drivers/USB/Class/Host/MIDI.c
Compiling C: LUFA101122/LUFA/Drivers/USB/Class/Host/Printer.c
Compiling C: LUFA101122/LUFA/Drivers/USB/Class/Host/RNDIS.c
Compiling C: LUFA101122/LUFA/Drivers/USB/Class/Host/StillImage.c
Linking: midifighter.elf
Creating load file for Flash: midifighter.hex
Creating load file for EEPROM: midifighter.eep
Creating Extended Listing: midifighter.lss
Creating Symbol Table: midifighter.sym

Size after:
AVR Memory Usage
----------------
Device: at90usb162

Program:    7698 bytes (47.0% Full)
(.text + .data + .bootloader)

Data:        241 bytes (47.1% Full)
(.data + .bss + .noinit)

-------- end --------
At the end of this you will find a firmware image called "midifighter.hex" in the project directory.

Flashing from the Makefile

The Makefile that comes with the project contains a build target that will reflash the Midifighter from the command line. In order to use this, dfu-programmer must be installed. The easiest way to do this is via MacPorts, which can be downloaded from:


Note that MacPorts requires XCode to be installed. You can get XCode from your Mac OS X DVD, or you can download it from:


Once you have MacPorts installed you can install dfu-programmer from the command line using the port command:
Code:
Kevins-MacBook-Pro:~ kevin$ sudo port install dfu-programmer
Password:
You'll have to enter your user password. The output should resemble:
Code:
--->  Computing dependencies for dfu-programmer
--->  Fetching libusb
--->  Attempting to fetch libusb-1.0.6.tar.bz2 from http://distfiles.macports.org/libusb
--->  Verifying checksum(s) for libusb
--->  Extracting libusb
--->  Applying patches to libusb
--->  Configuring libusb
--->  Building libusb
--->  Staging libusb into destroot
--->  Installing libusb @1.0.6_1
--->  Activating libusb @1.0.6_1
--->  Cleaning libusb
--->  Fetching libusb-compat
--->  Attempting to fetch libusb-compat-0.1.3.tar.bz2 from http://voxel.dl.sourceforge.net/libusb
--->  Verifying checksum(s) for libusb-compat
--->  Extracting libusb-compat
--->  Configuring libusb-compat
--->  Building libusb-compat
--->  Staging libusb-compat into destroot
--->  Installing libusb-compat @0.1.3_0
--->  Activating libusb-compat @0.1.3_0
--->  Cleaning libusb-compat
--->  Fetching dfu-programmer
--->  Attempting to fetch dfu-programmer-0.5.2.tar.gz from http://distfiles.macports.org/dfu-programmer
--->  Verifying checksum(s) for dfu-programmer
--->  Extracting dfu-programmer
--->  Configuring dfu-programmer
--->  Building dfu-programmer
--->  Staging dfu-programmer into destroot
--->  Installing dfu-programmer @0.5.2_0
--->  Activating dfu-programmer @0.5.2_0
--->  Cleaning dfu-programmer
To flash the firmware, make sure the Midifighter is in Bootloader Mode and execute "make dfu" from the midifighter directory. This will execute a script that will upload the firmware and reset the Midifighter to start the program executing:

Code:
Kevins-MacBook-Pro:midifighter kevin$ make dfu
dfu-programmer at90usb162 erase
dfu-programmer at90usb162 flash midifighter.hex
Validating...
7698 bytes used (62.65%)
dfu-programmer at90usb162 reset
You need to login in order to write on our forum

<< Cancel

Copyright 2012-2023
DJRANKINGS.ORG n.g.o.
Chuo-ku, Osaka, Japan

Created by Ajaxel CMS

Terms & Privacy