Category: osx-avr

  • Focused Workshop: Programming the Midi Monster (28FEB10 PNCA).

    What: Focused workshop: programming Midi devices using the Lightweight Usb For AVR library (Lufa) and the MidiMonster.

    When: Sunday 28 Feb 2010 1-5 pm.

    Where: PNCA (NW 12th and Johnson) #205

    Cost: $35 (includes Midi Monster)
    (If you have a MidiMonster from the PD Workshop and wish to use it please bring $10)

    Materials: you Should Bring, a laptop and a mini usb cable. Please install Arduino >16 as well.

    In this workshop we will be going through the firmware built by Alex Norman as an example of how to develop midi devices using the avr microcontoller. Topics covered will include:

    • The Midi Specification
    • The USB Midi Specification
    • The Lightweight Usb for AVR  library.
    • Programming the avr using avr-gcc

    To reserve a place in the class please rsvp at http://tempusdictum.com/tdproducts.html

  • Our Work is Done Here 02FEB08

    I have been looking at AvrMacPack as a recommended platform. They have done a really nice job ob doing everything that I was trying to do and they also have paid attention to a lot of detail that I haven’t.

    Please look at this and tell me what you think. I am considering dropping OSX-AVR and focusing on other underserved platform pieces if everyone agrees that it is done as well as I think it is.

    http://www.obdev.at/products/avrmacpack/download-de.html

    I will be contacting them to see if they can consider bundling nick’s x-code templates or I may put any pieces that are missing as individual packages.

  • December 07 Release Contents

    Gcc toolchain.

  • Notes on Ports to Packages

    Ports,

    The bsd community maintains a huge collection of reviewed and stable sources for open source software. The ports collection contains a framework of Makefiles and descriptions containing enough information to build the port from source. Using the ports collection on a bsd box is as simple as changing to the port’s working directory and typing make &&make install.

    The ports collection can be retrieved in one of two ways. You can get the port collection in its entirety at ftp://ftp.freebsd.org/pub/FreeBSD/ports/ports-current/ports.tar.gz or you can pull the individual port from the cvs tree. http://www.freebsd.org/cgi/cvsweb.cgi/ports/$category/$port/$port.tar.gz?tarball=1

    The structure of the ports tree is:

    • /usr/ports/<category>/<package>

    The port’s directory itself contains the following

    • Makefile
      — Contains most of the information required to build the package. Key variables include.

      • PORTNAME
      • PORTVERSION
      • PORTREVISION
      • CATEGORIES
      • PKGNAMEPREFIX
      • DISTFILES
      • BUILD_DEPENDS
      • RUN_DEPENDS
      • CONFIGURE_ARGS
      • CONFIGURE_ENV
      • MAKE_ARGS
      • MAKE_ENV
    • pkg-plist
      — This file contains a manifest of the files to be installed. It includes directory information and weather or not the directory should be cleared out or not.
    • pkg-descr
      — This file contains the package description
    • distinfo
      — contains the filenames, sizes and checksums for the source
    • files/
      contains any file not in the distribution and patches needed to build the file on xxxBSD

      • patch-xx

    Packages

    PackageMaker

  • October Status

    I have still not released an equivalent to the early summer release of WinAvr however people seem to be getting along pretty well with the January release. I am moving and I am once again without a functioning Intel system so I will probably not have a new release until thanksgiving. In the mean time I am working on automating a ports to packages script which will be used to expedite the process of building the next release.

  • note on FreeBSD ports use for avr-gcc tool chain.

    Tack #1

    Write script to download and patch FreeBSD sources.

    #!/bin/bash
    function getfiles ()
    {
    for fname in $FILES ; do
    echo "GETTING ----- $fname -----"
    case ${fname##*.} in
      bz2)
         echo "GETTING ----- $fname ----- using bunzip "
         curl ftp://ftp2.freebsd.org/pub/FreeBSD/distfiles/$fname 
          |bunzip2 -dc|tar -xf -
         ;;
      gz|tgz)
         echo "GETTING ----- $fname ----- using gunzip "
         curl ftp://ftp2.freebsd.org/pub/FreeBSD/distfiles/$fname 
          |gzip -dc|tar -xf -
         ;;
    esac
    done
    
    }
    
    function patchfiles () {
    PORTNAME=`cat $port/Makefile |grep ^PORTNAME|cut -f2`
    PORTVERSION=`cat $port/Makefile |grep ^PORTVERSION|cut -f2`
    ocd=`pwd`
    cd $PORTNAME-$PORTVERSION*
    echo "-------- PATCHING HERE `pwd`  ------"
    for p in $ocd/$port/files/patch* ; do
       patch -p0 -u <$p
    done
    cd $ocd
    
    }
    
    function makeit () {
    PREFIX=/usr/local
    LOCALBASE=/usr/local
    CONFIGURE_ARGS=`cat $port/Makefile |grep ^CONFIGURE_ARGS|sed 's/^CONFIGURE_ARGS=t//'`
    MAKE_ARGS=`cat $port/Makefile |grep ^MAKE_ARGS|sed 's/^MAKE_ARGS=t//'`
    PORTNAME=`cat $port/Makefile |grep ^PORTNAME|cut -f2`
    PORTVERSION=`cat $port/Makefile |grep ^PORTVERSION|cut -f2`
    ocd=`pwd`
    cd $PORTNAME-$PORTVERSION*
    echo "-------- CONFIGURING HERE `pwd`  ------"
    echo "$CONFIGURE_ENV ./configure $CONFIGURE_ARGS "
    export `cat $port/Makefile |grep ^CONFIGURE_ENV|sed 's/t/ /g'|sed 's/^CONFIGURE_ENV=//'`
    ./configure $CONFIGURE_ARGS >config.out
    echo "$MAKE_ENV make $MAKE_FLAGS && $MAKE_ENV make $MAKE_FLAGS install"
    export `cat $port/Makefile |grep ^MAKE_ENV|sed 's/t/ /g'|sed 's/^MAKE_ENV=//'`
    make $MAKE_FLAGS && make $MAKE_FLAGS install
    # make $MAKE_FLAGS distclean
    cd $ocd
    }
    
    for port in avr-binutils avr-gcc avr-libc avr-gdb avarice simulavr ; do
    curl  "http://www.freebsd.org/cgi/cvsweb.cgi/ports/devel/$port/$port.tar.gz?tarball=1"|gzip -dc|tar -xvf -
    export FILES=`grep MD5 $port/distinfo|cut -d( -f2|cut -d) -f1`
    getfiles "$FILES"
    patchfiles "$port" "$FILES"
    makeit "$port" "$FILES"
    done

    Tack #2

    Work with the ports tree, bsdmake and the .mk files to try to get the download, build and packaging to work as they do in the ports.

  • July Release Process Notes

    I have been really busy. So of course I have to start all over from srcatch. If you build gdb for either avarice or simulavr along with avra then scripting this environment goes out the obscening window. As usual however I start with the distfiles and the ports. In general the process goes like

    1. grab the “files” for the port
    2. grab the ftp://ftpx.freebsd.org/ports/disfiles/zzzz referenced in the files/<zzzz>/distinfo file (this could be automated)
    3. unpack and apply all of the patches in <zzzz>/files/patch-*. (except for the goober that I have to chase down with Joerge in gdb this could be automated).
    4. Then pull out the config args and the other compilation arguments from the make file. (Except that every other port has this done slightly differently this might be automatable)
    5. configure && make && make install (at this point the process becomes adaptive and frustraiting because the software is disparate and of varying quality, some of it requires you to upgrade Xcode (Avarice), Some of it wont obcening compile at all (Simulavr), and some of it is not as broken as it used to be but still doesnt have any of the new devices (avra)).
      1. So deal with it and a few days later…
    6. reinstall into a staging directory
    7. find all of the bin directories and run strip on the executables
    8. copy and adapt the package maker files to the new versions.
    9. repackage them using PackageMaker (this is automatable)
    10. make a folder
    11. build a readwrite uncompressed dmg from the folder
    12. mount dmg ajust the background and layout of the folder.
    13. test mount and install.
    14. convert dmg to compressed dmg.
    15. repeat for intel.
    16. release and pray.
  • January 07 Release (PPC and Intel)

    Go to sourceforge download area

    AVRGCC20070131 contains patched versions of

    • avr-gcc-4.1.1
    • avr-binutils-2.17
    • and libc-1.4.5
    • gdb-6.5

    This includes the new_devices patches posted to the freebsd ports collection as of 01JAN07.

    • AvrDude5.3.1 contains avrdude 5.3.1 plus the osxintel hack
    • LibUsb.pkg contains the library required by avrdude to talk to the Atmel AVR-ISP MKII
    • AvrA1.0.3 contains a version of avra based on avra1.0.1 with my new device.c added to it.
    • Mfile is Jeorg Wunsch’s Makefile Generator
    • XCodeAvrTemplates contain the templates created by Nick Lott to make the tool chain work within XCode
    • simulavr.pkg and avarice contain experimental versions of these emulators.
  • October Release (PPC – Intel)

    Go to sourceforge download area

    This release contains:

    • avr-gcc-3.4.6
    • avr-binutils-2.17
    • and avr-libc 1.4.5
    • avrdude 5.2.

    These versions are all patched using the patches released into the FreeBSD ports collection as of october first.

    To keep the devices in sync I am also releasing avra 1.03 which adds the following to avra 1.02

    • AT90PWM2
    • AT90PWM3
    • AT90USB1286
    • AT90USB1287
    • ATmega164P
    • ATmega165P
    • ATmega169P
    • ATmega324P
    • ATmega3250P
    • ATmega325P
    • ATmega3290P
    • ATmega329P
    • ATmega48P
    • ATmega644P

    (I will add this to the avra sourceforge project later)

    The pre patched source for avr-gcc, avr-binutils, and avra are at http://www.digithink.com/OSX-AVR/sources/

  • Packaging Avr Tool Chain

    General outline for creating AVR development environment for OSX.

    Since the gcc chain serves a much greater community than just the avr and its stability is critical to the stability of the entire open software community the avr community has elected to maintain patches. The avr-binutils, avr-gcc and patches used are all to be found in the freebsd ports collection. The avr-libc does not require patching as it is seperate from gcc.

    (If you would rather just download and install the resulting package it is here)

    Process for multiple installations

    1. create a staging directory.
    2. patch, build and install (in order)
      1. avr-binutils
      2. avr-gcc
    3. clean and then rebuild them into the staging directory.
    4. build avr-libc into ste staging directory.
    5. use PackageMaker to build a package.
    6. add README and other utilities you want to include
    7. use disk-utility to create DMG
    8. mount and install the package
    9. put the dmg where it can be shared.

    avr-binutils

    The the binary utilities make up the loader and assemblers and other tools needed by gcc to create usable code for the target. Like gcc the binary utilities are not specific to the target but are built for the target. I built the binutilities out of the freebsd currents distfiles (ftp://ftp.freebsd.org/pub/FreeBSD/distfiles), and then applied all of the patches from the freebsd cvs directory (http://www.freebsd.org/cgi/cvsweb.cgi/ports/devel/avr-gcc/files/). The patch that changes most often is the new-devices patch which Jeorg Wunsch updates in order to keep the avr-libc current. Then the source tree is unpacked and “./configure”d with the –targe=avr flag. (For some reason I also had to –disable-nls to get this to work).

    # tar -xzvf binutils-xxx
    # cd binutils-xxx
    # for p in ${avr-binutils-patches}/* ;do
           patch<$p
      done
    # /configure --target=avr --disable-nls
    # make && make install && make clean

    avr-gcc

    Once the avr-binutils are built and installed gcc is built exactly the same way.

    # tar -xzvf gcc-xxx
    # cd gcc-xxx
    # for p in ${avr-gcc-patches}/* ;do
           patch<$p
       done
    # /configure --target=avr --disable-nls

    avr-libc

    The libc for avr avr-libc is a seperate package from binutils and gcc and it is updated often. You can build this directly into the staging directory. If you are not preparing the code for packaging then you can build the libc directly into the target directory.

    # tar -xzvf avr-libc-xxxx
    # cd avr-libc-xxxx
    # ./configure CC=avr-gcc --host=avr
    # make && make install && make clean

    Preparing the code for packaging.

    If you are going to deploy the avrgcc chain on more than one system or if you want to back up and or share the software then you should at this point rebuild both binutils and gcc into a staging directory.

    # rm -rf /usr/local/staging
    # mkdir /usr/local/staging
    # cd /usr/local/src/avr-gcc/binutils-xxx
    # /configure --target=avr --prefix=/usr/local/staging --disable-nls
    # make && make install && make clean
    # cd ../../avr-gcc/gcc-xxx
    # /configure --target=avr --prefix=/usr/local/staging --disable-nls
    # make && make install && make clean
    # cd ../../avr-libc/
    # tar -xzvf avr-libc-xxxx
    # cd avr-libc-xxxx
    # ./configure CC=avr-gcc --host=avr --prefix=/usr/local/staging
    # make && make install && make clean

    PackageMaker

    One of the applications included in the X-code suite is packagemaker. On my installation it is found under the folder in Developer->Applications->Utilities. PackageMaker can also ge called from the command line but this will require further investigation. .

    1. open packagemaker
      1. in the first tab describe the software.
      2. in the second tab (files) type the path of the staging directory (in our case /usr/local/staging)
      3. in the forth tab (info)
        1. put the default location of the software (/usr/local/)
        2. set the authorization required to “root authorization required”
      4. fill out the information as appropriate.
    2. create the package (command-K)

    Creating the Disk image.

    Once the package is created

    1. copy the resulting package into its own folder.
    2. You should probably create a readme file
    3. add any other software you want in your archive.
    4. open the Disk Utility (under Applications->Utilities)
    5. under the images menue select New->Image from folder

    References.