#!/bin/bash #************************************************************************** #** Copyright (c) 2012 Paolo Galeone #** #** The authors hereby grant permission to use, copy, modify, distribute, #** and license this software and its documentation for any purpose, provided #** that existing copyright notices are retained in all copies and that this #** notice is included verbatim in any distributions. No written agreement, #** license, or royalty fee is required for any of the authorized uses. #** Modifications to this software may be copyrighted by their authors #** and need not follow the licensing terms described here, provided that #** the new terms are clearly indicated on the first page of each file where #** they apply. #************************************************************************** #put your settings here PROCESSOR=32MX440F256H #linker dir LKDIR=~/MIPS/Pinguino/p32/lkr/PIC32_PINGUINO_OTG #include dir for non-free file INDIR=~/MIPS/Toolchain/include/non-free #object dir for non-free objects OBJDIR=~/MIPS/Pinguino/p32/obj/non-free ########### do not edit below this line ########## if [ ! "$#" -eq 1 ] then echo "Usage: $0 source.c" exit -1 fi GCC_INPUT=$1 FILENAME=`echo $1 | cut -d '.' -f 1` GCC_OUTPUT="$FILENAME".elf HEX_OUTPUT="$FILENAME".hex HEX_TMP="$FILENAME".tmp #little endian - #preserve sections and data defined in linker and in non-free header file #define macro to identify processor #link 2 linker script non free #link non free object with processor specific functions #link to crt0.S for program entry point (_reset) and other mips assemply routine #input #output GCC_PARAMS="-EL -ffunction-sections -fdata-sections -D __"$PROCESSOR"__ -I $INDIR -T $LKDIR/procdefs.ld -T $LKDIR/elf32pic32mx.x $OBJDIR/processor.o $OBJDIR/crt0.S $GCC_INPUT -o $GCC_OUTPUT"; BADRECORD='^:040000059D006000FA' # unsupported record in hex file / Jean-pierre Mandon 2012 ########## EXECUTION ######### #on non return 0 status, exit failure trap "exit -1" ERR #copy specific processor object to processor.o cp "$OBJDIR/$PROCESSOR".o "$OBJDIR"/processor.o #compile mips-sde-elf-gcc $GCC_PARAMS #extract hexfile from elf mips-sde-elf-objcopy -Oihex $GCC_OUTPUT $HEX_TMP #remove unsupported record in hex file grep --invert-match --binary $BADRECORD $HEX_TMP > $HEX_OUTPUT #remove tmp file rm $HEX_TMP #remove trap on err trap - ERR #END EXECUTION echo "Created $HEX_OUTPUT" echo "Now you can upload this file to your board using ubw32"