How To set up the Midifighter Development Environment
20100224: created by Fatlimey
Developing under Windows
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 "C:\midifighter"
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. WinAVR is a set of libraries, compilers, debuggers
and command line tools for the AVR series of processors that can be found
at:
WinAVR 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 instantly available at the command prompt. Part of
the WinAVR package is a set of Gnu Tools compiled for Win32 that provide
the Unix command line tools "make", "grep", "find" etc.
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:
Create a "LUFA" subdirectory inside the project directory and Unzip the LUFA
project into that place. The resulting layout after installing these tools
should be:
To build the firmware, open a command line (from the Start button you can use "AllCode:drive (c:) |_ Program Files | |_ Atmel | |_ Flip 3.4.1 | |_ bin |_ ... |_ WinAVR | |_ bin | |_ utils |_ ... |_ midifighter |_ LUFA | |_ .. |_ 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
Programs/Accessories/Command Prompt", or use the "Run..." option and execute
"cmd"). Change the directory to your project dir and build the project using
the make command:
The "-s" on the make command silences printout of the actual commandsCode:> cd C:\midifighter > make -s
executed (which is optional), but the output should resemble:
At the end of this you will find a firmware image called "midifighter.hex"Code:-------- begin -------- avr-gcc (WinAVR 20100110) 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: fourbanks.c Compiling C: usb_descriptors.c Compiling C: LUFA/LUFA/Drivers/USB/LowLevel/DevChapter9.c Compiling C: LUFA/LUFA/Drivers/USB/LowLevel/Endpoint.c Compiling C: LUFA/LUFA/Drivers/USB/LowLevel/Host.c Compiling C: LUFA/LUFA/Drivers/USB/LowLevel/HostChapter9.c Compiling C: LUFA/LUFA/Drivers/USB/LowLevel/LowLevel.c Compiling C: LUFA/LUFA/Drivers/USB/LowLevel/Pipe.c Compiling C: LUFA/LUFA/Drivers/USB/HighLevel/Events.c Compiling C: LUFA/LUFA/Drivers/USB/HighLevel/USBInterrupt.c Compiling C: LUFA/LUFA/Drivers/USB/HighLevel/USBTask.c Compiling C: LUFA/LUFA/Drivers/USB/HighLevel/ConfigDescriptor.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 Checking for invalid events... ---- Compile Time Library Options ---- NO_STREAM_CALLBACKS USB_DEVICE_ONLY FIXED_CONTROL_ENDPOINT_SIZE=8 FIXED_NUM_CONFIGURATIONS=1 USE_FLASH_DESCRIPTORS USE_STATIC_OPTIONS=(USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL) -------------------------------------- --------- Target Information --------- AVR Model: at90usb162 Board: Clock: 16000000Hz CPU, 16000000Hz Master -------------------------------------- Size after: AVR Memory Usage ---------------- Device: at90usb162 Program: 6160 bytes (37.6% Full) (.text + .data + .bootloader) Data: 96 bytes (18.8% Full) (.data + .bss + .noinit) -------- end --------
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.
If you have already installed the Atmel Flip tool and added the "bin"
directory from that tool to your PATH environment variable:
we can use the "batchisp" command to do the work. Make sure the MidifighterCode:> set PATH= %PATH%;C:\Program Files\Atmel\Flip 3.4.1\bin
is in Bootloader Mode and execute "make flip". This will execute a script
that will upload the firmware and reset the Midifighter to start the program
executing:
There are similar targets for programming using the "dfu-programmer" tool orCode:> make flip batchisp -hardware usb -device at90usb162 -operation erase f Running batchisp 1.2.4 on Wed Feb 24 01:19:15 2010 AT90USB162 - USB - USB/DFU Device selection....................... PASS Hardware selection..................... PASS Opening port........................... PASS Reading Bootloader version............. PASS 1.0.5 Erasing................................ PASS Summary: Total 5 Passed 5 Failed 0 batchisp -hardware usb -device at90usb162 -operation loadbuffer midifighter.hex program Running batchisp 1.2.4 on Wed Feb 24 01:19:16 2010 AT90USB162 - USB - USB/DFU Device selection....................... PASS Hardware selection..................... PASS Opening port........................... PASS Reading Bootloader version............. PASS 1.0.5 Parsing HEX file....................... PASS midifighter.hex Programming memory..................... PASS 0x00000 0x0180f Summary: Total 6 Passed 6 Failed 0 batchisp -hardware usb -device at90usb162 -operation start reset 0 Running batchisp 1.2.4 on Wed Feb 24 01:19:18 2010 AT90USB162 - USB - USB/DFU Device selection....................... PASS Hardware selection..................... PASS Opening port........................... PASS Reading Bootloader version............. PASS 1.0.5 Starting Application................... PASS RESET 0 Summary: Total 5 Passed 5 Failed 0
hardware programming debugging using Avrdude and a JTAG programmer. If you are familiar with those tools, read the Makefile for more information.

Reply With Quote

Bookmarks