How To Set Up The Midifighter Development Environment in Mac OS X
Results 1 to 6 of 6
  1. #1
    Tech Wizard djoverzero's Avatar
    Join Date
    Jul 2010
    Location
    Chicago / San Francisco
    Posts
    44

    Arrow 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
    Last edited by Fatlimey; 03-10-2011 at 09:42 AM.

  2. #2
    Tech Guru Fatlimey's Avatar
    Join Date
    Mar 2008
    Location
    Redmond, WA
    Posts
    1,169

    Default

    Awesome, thank you.

  3. #3
    Tech Mentor
    Join Date
    Jun 2010
    Location
    London, UK
    Posts
    160

    Default

    Sweeeeeeeet

    I meant to do a video of how to flash via DFU a while back but then the install program came out and I didn't ever get around to it.

    I may add it back onto the list ...
    London - UK
    VCI-100-SE Arcade Moded (v1.4 FW), 2 x CDJ-1000, 1 x 1210 MK2, A&H Xone:62, 2 x KRK RP 6 G2's, Traktor Scratch Pro 2, 1 x Midi Fighter, Audio8DJ, Focusrite Saffire 6 USB, Novation 25, Korg Kontrol, 1 x custom built MacPro (Quad Core i7, 6GB DDR3 RAM, OSX 10.7.1), 1 x MacBook Pro (2.2Ghz, 8GB RAM, OSX 10.6.8)

  4. #4
    Tech Mentor
    Join Date
    Jun 2010
    Location
    London, UK
    Posts
    160

    Default

    This method works a treat !
    London - UK
    VCI-100-SE Arcade Moded (v1.4 FW), 2 x CDJ-1000, 1 x 1210 MK2, A&H Xone:62, 2 x KRK RP 6 G2's, Traktor Scratch Pro 2, 1 x Midi Fighter, Audio8DJ, Focusrite Saffire 6 USB, Novation 25, Korg Kontrol, 1 x custom built MacPro (Quad Core i7, 6GB DDR3 RAM, OSX 10.7.1), 1 x MacBook Pro (2.2Ghz, 8GB RAM, OSX 10.6.8)

  5. #5
    Tech Guru Fatlimey's Avatar
    Join Date
    Mar 2008
    Location
    Redmond, WA
    Posts
    1,169

    Default

    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.
    To get the command line to pick up new tools after a Path change, type "rehash".

  6. #6

    Default

    Thanks for this guide! This will be very helpful once I start messing around with the firmware code. Nothing kills programming excitement more than spending hours fiddling with the development environment just trying to get code compiled.

    Btw, one thing I'd like to mention, I highly recommend HomeBrew (http://mxcl.github.com/homebrew/) over MacPorts. It handles the same function but I much prefer it and it tends to have more updated packages. Once HomeBrew is installed (which requires Xcode, like MacPorts), a simple "brew install dfu-programmer" (no sudo needed) will install the tool.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •