From aa4d9d9b73f7218d40bdb30efffea5e001498bda Mon Sep 17 00:00:00 2001 From: "edouard@lafargue.name" Date: Sat, 25 Apr 2009 21:19:59 +0000 Subject: [PATCH] - Added new Makefile.linux in bootrom directory - Cleaned up Makefile.linux in armsrc directory - Added Linux toolchain build script in tools directory - Made LCD support optional (disabled by default) in armsrc - Small formatting changes --- .cdtproject | 88 ++++++++ .cproject | 118 +++++++++++ .project | 85 ++++++++ .settings/org.eclipse.cdt.core.prefs | 3 + armsrc/Makefile | 9 +- armsrc/Makefile.linux | 74 ++++--- armsrc/appmain.c | 16 +- bootrom/Makefile.linux | 65 ++++++ include/usb_cmd.h | 2 +- .../at91sam7s256-armusbocd-flash-program.cfg | 39 ++++ tools/at91sam7s256-armusbocd.cfg | 29 +++ tools/install-gnuarm4.sh | 198 ++++++++++++++++++ 12 files changed, 686 insertions(+), 40 deletions(-) create mode 100644 .cdtproject create mode 100644 .cproject create mode 100644 .project create mode 100644 .settings/org.eclipse.cdt.core.prefs create mode 100644 bootrom/Makefile.linux create mode 100644 tools/at91sam7s256-armusbocd-flash-program.cfg create mode 100644 tools/at91sam7s256-armusbocd.cfg create mode 100755 tools/install-gnuarm4.sh diff --git a/.cdtproject b/.cdtproject new file mode 100644 index 00000000..07ab80bb --- /dev/null +++ b/.cdtproject @@ -0,0 +1,88 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +make + +all +false +true + + +make + +all +false +true + + +make +-f Makefile.linux +all +false +false + + +make +-f Makefile.linux +clean +false +false + + + + + diff --git a/.cproject b/.cproject new file mode 100644 index 00000000..c157cc59 --- /dev/null +++ b/.cproject @@ -0,0 +1,118 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +make +-f Makefile.linux +all +false +false +true + + +make +-f Makefile.linux +clean +false +false +true + + +make + +all +false +true +true + + +make + +clean +false +true +true + + +make +-f Makefile.linux +all +false +false +true + + +make +-f Makefile.linux +clean +false +false +true + + + + + + diff --git a/.project b/.project new file mode 100644 index 00000000..0ad67cd4 --- /dev/null +++ b/.project @@ -0,0 +1,85 @@ + + + Proxmark3-SVN + + + + + + org.eclipse.cdt.make.core.makeBuilder + clean,full,incremental, + + + org.eclipse.cdt.make.core.enableCleanBuild + true + + + org.eclipse.cdt.make.core.append_environment + true + + + org.eclipse.cdt.make.core.stopOnError + false + + + org.eclipse.cdt.make.core.enabledIncrementalBuild + true + + + org.eclipse.cdt.make.core.build.command + make + + + org.eclipse.cdt.make.core.build.target.inc + all + + + org.eclipse.cdt.make.core.build.arguments + + + + org.eclipse.cdt.make.core.environment + PATH=/usr/local/new/gnuarm-4.3.0/bin:/home/lafargue/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games| + + + org.eclipse.cdt.make.core.useDefaultBuildCmd + true + + + org.eclipse.cdt.make.core.enableAutoBuild + false + + + org.eclipse.cdt.make.core.build.target.auto + all + + + org.eclipse.cdt.make.core.enableFullBuild + true + + + org.eclipse.cdt.make.core.build.target.clean + clean + + + org.eclipse.cdt.make.core.build.location + + + + org.eclipse.cdt.core.errorOutputParser + org.eclipse.cdt.core.MakeErrorParser;org.eclipse.cdt.core.GCCErrorParser;org.eclipse.cdt.core.GASErrorParser;org.eclipse.cdt.core.GLDErrorParser;org.eclipse.cdt.core.VCErrorParser; + + + + + org.eclipse.cdt.make.core.ScannerConfigBuilder + + + + + + org.eclipse.cdt.core.cnature + org.eclipse.cdt.make.core.makeNature + org.eclipse.cdt.make.core.ScannerConfigNature + + diff --git a/.settings/org.eclipse.cdt.core.prefs b/.settings/org.eclipse.cdt.core.prefs new file mode 100644 index 00000000..a0061784 --- /dev/null +++ b/.settings/org.eclipse.cdt.core.prefs @@ -0,0 +1,3 @@ +#Tue Apr 21 17:19:37 CEST 2009 +eclipse.preferences.version=1 +indexerId=org.eclipse.cdt.core.fastIndexer diff --git a/armsrc/Makefile b/armsrc/Makefile index e8db3b31..574e4f08 100644 --- a/armsrc/Makefile +++ b/armsrc/Makefile @@ -10,17 +10,20 @@ INCLUDE = -I../include INCLUDES = ../include/proxmark3.h ../include/at91sam7s128.h ../include/config_gpio.h ../include/usb_cmd.h apps.h LIB = "..\..\devkitARM\lib\gcc\arm-elf\4.1.0\interwork" +# Add the "-DWITH_LCD" flag in CLFAGS to add support for LCD +# and add OBJLCD to OBJ too CFLAGS = -O6 -c $(INCLUDE) -Wall +OBJLCD = $(OBJDIR)/fonts.o \ + $(OBJDIR)/LCD.o + OBJ = $(OBJDIR)/start.o \ $(OBJDIR)/appmain.o \ $(OBJDIR)/fpga.o \ $(OBJDIR)/iso14443.o \ $(OBJDIR)/iso14443a.o \ $(OBJDIR)/iso15693.o \ - $(OBJDIR)/util.o \ - $(OBJDIR)/fonts.o \ - $(OBJDIR)/LCD.o + $(OBJDIR)/util.o OBJFPGA = \ $(OBJDIR)/fpgaimg.o diff --git a/armsrc/Makefile.linux b/armsrc/Makefile.linux index 0f2d0d4e..98c9c386 100644 --- a/armsrc/Makefile.linux +++ b/armsrc/Makefile.linux @@ -1,67 +1,77 @@ # This makefile needs to be edited to reflect the location -# of your own arm-elf-gcc installation (LIB variable) +# of your own arm-elf-gcc toolchain (LIB variable) CC = arm-elf-gcc AS = arm-elf-as LD = arm-elf-ld OBJCOPY = arm-elf-objcopy -INCLUDE = -I../include - -INCLUDES = ../include/proxmark3.h ../include/at91sam7s128.h ../include/config_gpio.h ../include/usb_cmd.h apps.h +# Indicate where your gnuarm toolchain libgcc.a library is located: LIB = /usr/local/new/gnuarm-4.3.0/lib/gcc/arm-elf/4.3.0/interwork +# Add -DWITH_LCD to EXTRA_CFLAGS if you want support for LCD +# in your firmware (add OBJLCD to OBJ too!) +#EXTRA_CFLAGS = -DWITH_LCD +EXTRA_CFLAGS = + +### You should not need to edit below this line + +INCLUDE = -I../include +INCLUDES = ../include/proxmark3.h ../include/at91sam7s128.h ../include/config_gpio.h ../include/usb_cmd.h apps.h CFLAGS_COMMON = -O6 -c $(INCLUDE) -Wall -mthumb-interwork -CFLAGS = $(CFLAGS_COMMON) -mthumb +CFLAGS = $(CFLAGS_COMMON) $(EXTRA_CFLAGS) -mthumb OBJDIR = obj -OBJ = start.o \ - appmain.o \ - fpga.o \ - iso15693.o \ - iso14443.o \ - util.o\ - LCD.o\ - fonts.o -OBJFAST = iso14443a.o +OBJLCD = $(OBJDIR)/LCD.o\ + $(OBJDIR)/fonts.o + +OBJ = $(OBJDIR)/start.o \ + $(OBJDIR)/appmain.o \ + $(OBJDIR)/fpga.o \ + $(OBJDIR)/iso15693.o \ + $(OBJDIR)/iso14443.o \ + $(OBJDIR)/util.o -OBJFPGA = fpgaimg.o -OBJCOMMON = usb.o +OBJFAST = $(OBJDIR)/iso14443a.o +OBJFPGA = $(OBJDIR)/fpgaimg.o + +OBJCOMMON = $(OBJDIR)/usb.o all: osimage.s19 fpgaimage.s19 fullimage.s19 fpgaimage.s19: $(OBJFPGA) @echo fpgaimage.s19 - $(LD) -g -Tldscript-fpga -o fpgaimage.elf $(patsubst %.o, obj/%.o, $^) - $(OBJCOPY) -Osrec --srec-forceS3 fpgaimage.elf fpgaimage.s19 + $(LD) -g -Tldscript-fpga -o $(OBJDIR)/fpgaimage.elf $^ + $(OBJCOPY) -Osrec --srec-forceS3 $(OBJDIR)/fpgaimage.elf fpgaimage.s19 osimage.s19: $(OBJ) $(OBJFAST) $(OBJCOMMON) @echo osimage.s19 - $(LD) -g -Tldscript -o osimage.elf $(patsubst %.o, obj/%.o, $^) $(LIB)/libgcc.a - $(OBJCOPY) -Osrec --srec-forceS3 osimage.elf osimage.s19 + $(LD) -g -Tldscript -o $(OBJDIR)/osimage.elf $^ $(LIB)/libgcc.a + $(OBJCOPY) -Osrec --srec-forceS3 $(OBJDIR)/osimage.elf osimage.s19 fullimage.s19: $(OBJ) $(OBJFAST) $(OBJCOMMON) $(OBJFAST) $(OBJFPGA) @echo fullimage.s19 - $(LD) -g -Tldscript-full -o fullimage.elf $(patsubst %.o, obj/%.o, $^) $(LIB)/libgcc.a - $(OBJCOPY) -Osrec --srec-forceS3 fullimage.elf fullimage.s19 - -$(OBJ): %.o : %.c - $(CC) $(CFLAGS) $< -o $(OBJDIR)/$@ + $(LD) -g -Tldscript-full -o $(OBJDIR)/fullimage.elf $^ $(LIB)/libgcc.a + $(OBJCOPY) -Osrec --srec-forceS3 $(OBJDIR)/fullimage.elf fullimage.s19 -$(OBJFPGA): %.o : %.c - $(CC) $(CFLAGS) $< -o $(OBJDIR)/$@ +# Directives to put the *.o in the OBJDIR directory: +$(OBJ): $(OBJDIR)/%.o : %.c + $(CC) $(CFLAGS) $< -o $@ +$(OBJFPGA): $(OBJDIR)/%.o : %.c + $(CC) $(CFLAGS) $< -o $@ -$(OBJFAST): %.o : %.c - $(CC) $(CFLAGS_COMMON) $< -o $(OBJDIR)/$@ +$(OBJFAST): $(OBJDIR)/%.o : %.c + $(CC) $(CFLAGS_COMMON) $< -o $@ -$(OBJCOMMON): ../common/usb.c - $(CC) $(CFLAGS) ../common/usb.c -o $(OBJDIR)/usb.o +$(OBJCOMMON): $(OBJDIR)/%.o : ../common/%.c + $(CC) $(CFLAGS) $< -o $@ +# Those do not work on the current firmware ! flash-fpga: fpgaimage.s19 ../linux/flasher fpga fpgaimage.s19 @@ -78,6 +88,6 @@ jtag-flash: osimage.s19 ../../OpenOCD/openocd -c "halt; flash write_image osimage.s19 0x00100000; halt; reset; resume; poll; exit" clean: - rm -f $(OBJDIR)/*.o *.elf *.s19 + rm -f $(OBJDIR)/*.o $(OBJDIR)/*.elf *.s19 .PHONY: all clean diff --git a/armsrc/appmain.c b/armsrc/appmain.c index 372bcf68..a0bb00d3 100644 --- a/armsrc/appmain.c +++ b/armsrc/appmain.c @@ -4,10 +4,14 @@ // Jonathan Westhues, Mar 2006 // Edits by Gerhard de Koning Gans, Sep 2007 (##) //----------------------------------------------------------------------------- + + #include #include "apps.h" #include "fonts.h" +#ifdef WITH_LCD #include "LCD.h" +#endif // The large multi-purpose buffer, typically used to hold A/D samples, // maybe pre-processed in some way. @@ -682,11 +686,11 @@ void UsbPacketReceived(BYTE *packet, int len) SimulateTagLowFrequency(c->ext1); LED_A_OFF(); break; - +#ifdef WITH_LCD case CMD_LCD_RESET: LCDReset(); break; - +#endif case CMD_SWEEP_LF: SweepLFrange(); break; @@ -694,11 +698,11 @@ void UsbPacketReceived(BYTE *packet, int len) case CMD_SET_LF_DIVISOR: FpgaSendCommand(FPGA_CMD_SET_DIVISOR, c->ext1); break; - +#ifdef WITH_LCD case CMD_LCD: LCDSend(c->ext1); break; - +#endif case CMD_SETUP_WRITE: case CMD_FINISH_WRITE: USB_D_PLUS_PULLUP_OFF(); @@ -745,6 +749,8 @@ void AppMain(void) // Load the FPGA image, which we have stored in our flash. FpgaDownloadAndGo(); +#ifdef WITH_LCD + LCDInit(); // test text on different colored backgrounds @@ -767,6 +773,8 @@ void AppMain(void) LCDFill(0, 1+8*14, 132, 8, CYAN); LCDFill(0, 1+8*15, 132, 8, MAGENTA); +#endif + for(;;) { UsbPoll(FALSE); WDT_HIT(); diff --git a/bootrom/Makefile.linux b/bootrom/Makefile.linux new file mode 100644 index 00000000..d558cc72 --- /dev/null +++ b/bootrom/Makefile.linux @@ -0,0 +1,65 @@ +CC = arm-elf-gcc +AS = arm-elf-as +LD = arm-elf-ld +OBJCOPY = arm-elf-objcopy + +OBJDIR = obj + +INCLUDE = -I../include + +INCLUDES = ../include/proxmark3.h ../include/at91sam7s128.h ../include/config_gpio.h ../include/usb_cmd.h + +CFLAGS = -g -c $(INCLUDE) -Wall + +OBJJTAG = $(OBJDIR)/bootrom.o $(OBJDIR)/ram-reset.o $(OBJDIR)/usb.o + +OBJFLASH = $(OBJDIR)/flash-reset.o $(OBJDIR)/fromflash.o + +all: bootrom.s19 bootrom-forjtag-swapped.s19 + +bootrom-merged.s19: bootrom.s19 bootrom-forjtag.s19 + perl ../tools/merge-srec.pl bootrom.s19 bootrom-forjtag.s19 > bootrom-merged.s19 + +bootrom-forjtag-swapped.s19: bootrom-merged.s19 + perl ../tools/srecswap.pl bootrom-forjtag.s19 > bootrom-forjtag-swapped.s19 + +bootrom.s19: $(OBJFLASH) + @echo bootrom.s19 + $(LD) -g -Tldscript-flash --oformat elf32-littlearm -o $(OBJDIR)/bootrom.elf $(OBJFLASH) + $(OBJCOPY) -Osrec --srec-forceS3 $(OBJDIR)/bootrom.elf bootrom.s19 + +bootrom-forjtag.s19: $(OBJJTAG) + @echo bootrom-forjtag.s19 + $(LD) -g -Tldscript-ram-jtag --oformat elf32-littlearm -o $(OBJDIR)/bootrom-forjtag.elf $(OBJJTAG) + $(OBJCOPY) -Osrec --srec-forceS3 $(OBJDIR)/bootrom-forjtag.elf bootrom-forjtag.s19 + +$(OBJDIR)/bootrom.o: bootrom.c $(INCLUDES) + @echo $@ + $(CC) $(CFLAGS) -mthumb -mthumb-interwork $< -o $@ + +$(OBJDIR)/fromflash.o: fromflash.c $(INCLUDES) + @echo $@ + $(CC) $(CFLAGS) -mthumb -mthumb-interwork $< -o $@ + +$(OBJDIR)/usb.o: ../common/usb.c $(INCLUDES) + @echo $@ + $(CC) $(CFLAGS) -mthumb -mthumb-interwork $< -o $@ + +$(OBJDIR)/ram-reset.o: ram-reset.s + @echo $@ + $(CC) $(CFLAGS) -mthumb-interwork -o $@ $< + +$(OBJDIR)/flash-reset.o: flash-reset.s + @echo $@ + $(CC) $(CFLAGS) -mthumb-interwork -o $@ $< + +# Those do not work in this Firmware distribution! +flash: bootrom-merged.s19 + ../linux/flasher bootrom bootrom-merged.s19 + +jtag-flash: bootrom-merged.s19 + ../../OpenOCD/openocd -c "halt; flash write_image bootrom-merged.s19 0x00100000; halt; reset; resume; poll; exit" + +clean: + rm -f $(OBJDIR)/*.o $(OBJDIR)/*.elf *.s19 + diff --git a/include/usb_cmd.h b/include/usb_cmd.h index 54141f79..af822c32 100644 --- a/include/usb_cmd.h +++ b/include/usb_cmd.h @@ -51,7 +51,7 @@ typedef struct { #define CMD_ACQUIRE_RAW_ADC_SAMPLES_ISO_15693 0x0300 #define CMD_ACQUIRE_RAW_ADC_SAMPLES_ISO_14443 0x0301 #define CMD_ACQUIRE_RAW_ADC_SAMPLES_ISO_14443_SIM 0x0302 -#define CMD_READ_SRI512_TAG 0x0303 +#define CMD_READ_SRI512_TAG 0x0303 #define CMD_READER_ISO_15693 0x0310 // ## New command to act like a 15693 reader - greg #define CMD_SIMTAG_ISO_15693 0x0311 // ## New command to act like a 15693 reader - greg diff --git a/tools/at91sam7s256-armusbocd-flash-program.cfg b/tools/at91sam7s256-armusbocd-flash-program.cfg new file mode 100644 index 00000000..2dce014f --- /dev/null +++ b/tools/at91sam7s256-armusbocd-flash-program.cfg @@ -0,0 +1,39 @@ +#define our ports +telnet_port 4444 +gdb_port 3333 + +#commands specific to the Olimex ARM-USB-OCD Dongle +interface ft2232 +ft2232_device_desc "Olimex OpenOCD JTAG" +ft2232_layout "olimex-jtag" +ft2232_vid_pid 0x15BA 0x0003 +jtag_speed 2 +jtag_nsrst_delay 200 +jtag_ntrst_delay 200 + +#reset_config [combination] [trst_type] [srst_type] +reset_config srst_only srst_pulls_trst + +#jtag_device +jtag_device 4 0x1 0xf 0xe + +#daemon_startup <'attach'|'reset'> +daemon_startup reset + +#target [variant] +target arm7tdmi little run_and_init 0 arm7tdmi_r4 + +#run_and_halt_time +run_and_halt_time 0 30 + +# commands below are specific to AT91sam7 Flash Programming +# --------------------------------------------------------- + +#target_script specifies the flash programming script file +target_script 0 reset script.ocd + +#working_area
<'backup'|'nobackup'> +working_area 0 0x40000000 0x4000 nobackup + +#flash bank at91sam7 0 0 0 0 +flash bank at91sam7 0 0 0 0 0 diff --git a/tools/at91sam7s256-armusbocd.cfg b/tools/at91sam7s256-armusbocd.cfg new file mode 100644 index 00000000..3d0bdd24 --- /dev/null +++ b/tools/at91sam7s256-armusbocd.cfg @@ -0,0 +1,29 @@ +#define our ports +telnet_port 4444 +gdb_port 3333 + +#commands specific to the Olimex arm-usb-ocd +interface ft2232 +# Be careful to reflect the exact description here: +ft2232_device_desc "Olimex OpenOCD JTAG" +ft2232_layout "olimex-jtag" +ft2232_vid_pid 0x15BA 0x0003 +jtag_speed 2 +jtag_nsrst_delay 200 +jtag_ntrst_delay 200 + +#reset_config [combination] [trst_type] [srst_type] +reset_config srst_only srst_pulls_trst + +#jtag_device +jtag_device 4 0x1 0xf 0xe + +#daemon_startup <'attach'|'reset'> +daemon_startup reset + +#target [variant] +target arm7tdmi little run_and_init 0 arm7tdmi_r4 + +#run_and_halt_time +run_and_halt_time 0 30 + diff --git a/tools/install-gnuarm4.sh b/tools/install-gnuarm4.sh new file mode 100755 index 00000000..cf8c494b --- /dev/null +++ b/tools/install-gnuarm4.sh @@ -0,0 +1,198 @@ +#!/bin/bash + +# Some things for you to configure + +# Where you want to install the tools +DESTDIR=/usr/local/gnuarm-4.3.0 + +# Where do you want to build the tools. This is where the log files +# will be written (which you can monitor with 'tail' during compilation). +# You can delete this directory after everything is done. +SRCDIR="/home/lafargue/Documents/Hobbies/RFID/Toolchain/linux" + +# Where to get each of the toolchain components +BINUTILS=ftp://ftp.gnu.org/gnu/binutils/binutils-2.18.tar.bz2 +GCCCORE=ftp://ftp.gnu.org/gnu/gcc/gcc-4.3.0/gcc-core-4.3.0.tar.bz2 +GPP=ftp://ftp.gnu.org/gnu/gcc/gcc-4.3.0/gcc-g++-4.3.0.tar.bz2 +NEWLIB=ftp://sources.redhat.com/pub/newlib/newlib-1.16.0.tar.gz +#INSIGHT=ftp://sourceware.org/pub/insight/releases/insight-6.8.tar.bz2 +INSIGHT=http://mirrors.kernel.org/sources.redhat.com/insight/releases/insight-6.8.tar.bz2 +#INSIGHT=http://www.mirrorservice.org/sites/sources.redhat.com/pub/insight/releases/insight-6.8.tar.bz2 + +# Common configuration options (i.e., things to pass to 'configure') +COMMON_CFG="--enable-interwork --target=arm-elf --program-prefix=arm-elf- --prefix=${DESTDIR} --disable-werror --enable-languages=c,c++ --enable-multilib --disable-shared" + +# Extra configuration options for each toolchain component +BINUTILS_CFG= +GCCCORE_CFG="--disable-libssp --disable-threads --with-newlib" # Not sure about these last 2 options...there to try to make C++ support work +NEWLIB_CFG= +INSIGHT_CFG= + +# Compiler flags for compiling Newlib (-O2 is already hard-coded) +NEWLIB_FLAGS="-march=armv4t -mcpu=arm7tdmi -g" + +############################################################################ +# End of configuration section. You shouldn't have to modify anything below. +############################################################################ + +if [[ `whoami` != "root" ]]; then + echo You must be root to run this script + exit 1 +fi + +mkdir -p ${SRCDIR} +cd ${SRCDIR} + +if [[ -f `basename ${BINUTILS}` ]]; then + echo Looks like BINUTILS has already been downloaded. +else + echo Now downloading BINUTILS... + # -nv: non-verbose but not too quiet (still print errors/warnings) + # -nc: no-clobber, do not download a file that already exists + # -t 0: retry indefinitely + # -a wget.log: append errors/warnings to wget.log file + wget -nv -nc -t 0 -a wget.log ${BINUTILS} +fi + +if [[ -f `basename ${GCCCORE}` ]]; then + echo Looks like GCC has already been downloaded. +else + echo Now downloading GCC... + wget -nv -nc -t 0 -a wget.log ${GCCCORE} +fi + +if [[ -f `basename ${GPP}` ]]; then + echo Looks like G++ has already been downloaded. +else + echo Now downloading G++... + wget -nv -nc -t 0 -a wget.log ${GPP} +fi + +if [[ -f `basename ${NEWLIB}` ]]; then + echo Looks like NEWLIB has already been downloaded. +else + echo Now downloading NEWLIB... + wget -nv -nc -t 0 -a wget.log ${NEWLIB} +fi + +if [[ -f `basename ${INSIGHT}` ]]; then + echo Looks like INSIGHT has already been downloaded. +else + echo Now downloading INSIGHT... + wget -nv -nc -t 0 -a wget.log ${INSIGHT} +fi + +if [[ -f binutils.built ]]; then + echo Looks like BINUTILS was already built. +else + echo Building BINUTILS... + tar -xjf `basename ${BINUTILS}` + echo ___________________ > make.log + echo Building binutils... >> make.log + cd `find . -maxdepth 1 -type d -name 'binutils*'` + mkdir gnuarm + cd gnuarm + ../configure ${COMMON_CFG} ${BINUTILS_CFG} >> ../../make.log 2>&1 + make MAKEINFO=`which makeinfo` >> ../../make.log 2>&1 + make install >> ../../make.log 2>&1 + cd ../.. + touch binutils.built +fi + + echo ___________________ >> make.log + echo Adding ${DESTDIR}/bin to PATH >> make.log +export PATH; PATH=${DESTDIR}/bin:$PATH + echo ___________________ >> make.log + +if [[ -f gcc.built ]]; then + echo Looks like GCC was already built. +else + echo Building GCC... + tar -xjf `basename ${GCCCORE}` + tar -xjf `basename ${GPP}` + echo ___________________ >> make.log + +cat << EOF > gcc.patch +--- gcc-4.2.2.orig/gcc/config/arm/t-arm-elf 2006-11-06 13:13:53.000000000 +0100 ++++ gcc-4.2.2.mod/gcc/config/arm/t-arm-elf 2007-10-05 12:13:00.000000000 +0200 +@@ -23,8 +23,8 @@ + # MULTILIB_DIRNAMES += fpu soft + # MULTILIB_EXCEPTIONS += *mthumb/*mhard-float* + # +-# MULTILIB_OPTIONS += mno-thumb-interwork/mthumb-interwork +-# MULTILIB_DIRNAMES += normal interwork ++MULTILIB_OPTIONS += mno-thumb-interwork/mthumb-interwork ++MULTILIB_DIRNAMES += normal interwork + # + # MULTILIB_OPTIONS += fno-leading-underscore/fleading-underscore + # MULTILIB_DIRNAMES += elf under +EOF + + echo Patching GCC >> make.log + cd `find . -maxdepth 1 -type d -name 'gcc*'` + patch -p1 < ../gcc.patch + echo Building gcc... >> make.log + mkdir gnuarm + cd gnuarm + ../configure ${COMMON_CFG} ${GCCCORE_CFG} >> ../../make.log 2>&1 + make >> ../../make.log 2>&1 + make install >> ../../make.log 2>&1 + cd ../.. + touch gcc.built +fi + +if [[ -f newlib.built ]]; then + echo Looks like NEWLIB was already built. +else + echo Building NEWLIB... + tar -xzf `basename ${NEWLIB}` + echo ___________________ >> make.log + echo Building newlib... >> make.log + cd `find . -maxdepth 1 -type d -name 'newlib*'` + mkdir gnuarm + cd gnuarm + ../configure ${COMMON_CFG} ${NEWLIB_CFG} >> ../../make.log 2>&1 + + # This line adds our NEWLIB_CFLAGS to the configure.host file in the + # newlib subdirectory. This is the only way I could find to tell Newlib to + # compile itself with the -mmarch=armv4t and -mcpu=arm7tdmi flags. + sed -i "/^newlib_cflags=/s/=.*\$/=\"${NEWLIB_FLAGS}\"/" ../newlib/configure.host + make >> ../../make.log 2>&1 + make install >> ../../make.log 2>&1 + cd ../.. + touch newlib.built +fi + + echo ___________________ >> make.log + echo "Now that newlib is built, second pass for GCC..." >> make.log + cd `find . -maxdepth 1 -type d -name 'gcc*'` + cd gnuarm + make >> ../../make.log 2>&1 + make install >> ../../make.log 2>&1 + cd ../.. + + +if [[ -f insight.built ]]; then + echo Looks like INSIGHT was already built. +else + echo Building INSIGHT... + tar -xjf `basename ${INSIGHT}` + echo ___________________ >> make.log + echo Building insight... >> make.log + cd `find . -maxdepth 1 -type d -name 'insight*'` + mkdir gnuarm + cd gnuarm + ../configure ${COMMON_CFG} ${INSIGHT_CFG} >> ../../make.log 2>&1 + make >> ../../make.log 2>&1 + make install >> ../../make.log 2>&1 + cd ../.. + touch insight.built +fi + +echo ___________________ >> make.log +echo Build complete. >> make.log + +cd ${DESTDIR} +chmod -R a+rX . + +exit 0 -- 2.39.5