if "%1"=="" goto ERROR1 if not exist %1 goto PDE set PDEFILE=%1 goto ARDUINO :PDE if not exist %1.pde goto ERROR1 set PDEFILE=%1.pde :ARDUINO set CPPFILE=applet/main.cpp set MAPFILE=applet/main.map set ELFFILE=applet/main.elf set EEPFILE=applet/main.eep set COREFILE=applet/core.a set CAT=%INSTALL_DIR%/hardware/tools/avr/utils/bin/cat set TEST=%INSTALL_DIR%/hardware/tools/avr/utils/bin/test set RM=%INSTALL_DIR%/hardware/tools/avr/utils/bin/rm -f set AR=%AVR_TOOLS_PATH%/avr-ar rcs %COREFILE% set CC=%AVR_TOOLS_PATH%/avr-gcc -c -g -Os -w -ffunction-sections -fdata-sections -mmcu=%MCU% -DF_CPU=%F_CPU% -I%ARDUINO% -I. set CPP=%AVR_TOOLS_PATH%/avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -mmcu=%MCU% -DF_CPU=%F_CPU% -I. -I%ARDUINO% set LINKER=%AVR_TOOLS_PATH%/avr-gcc -Os -Wl,--gc-sections -mmcu=%MCU% set SIZE=%AVR_TOOLS_PATH%/avr-size set OBJCOPY=%AVR_TOOLS_PATH%/avr-objcopy -O ihex set OBJDUMP=%AVR_TOOLS_PATH%/avr-objdump %TEST% -d applet || mkdir applet %RM% applet/* echo #include "WProgram.h">%CPPFILE% echo void setup();>>%CPPFILE% echo void loop();>>%CPPFILE% %CAT% %PDEFILE%>>%CPPFILE% %CAT% %ARDUINO%/main.cxx>>%CPPFILE% rem // 1. compile the core, outputting .o files to and then rem // collecting them into the core.a library file if exist %COREFILE% goto EXISTCORE %CC% %ARDUINO%/pins_arduino.c -o applet/pins_arduino.o %CC% %ARDUINO%/wiring.c -o applet/wiring.o %CC% %ARDUINO%/wiring_analog.c -o applet/wiring_analog.o %CC% %ARDUINO%/wiring_digital.c -o applet/wiring_digital.o %CC% %ARDUINO%/wiring_pulse.c -o applet/wiring_pulse.o if exist %ARDUINO%/wiring_serial.c %CC% %ARDUINO%/wiring_serial.c -o applet/wiring_serial.o %CC% %ARDUINO%/wiring_shift.c -o applet/wiring_shift.o %CC% %ARDUINO%/WInterrupts.c -o applet/WInterrupts.o %CPP% %ARDUINO%/HardwareSerial.cpp -o applet/HardwareSerial.o %CPP% %ARDUINO%/WMath.cpp -o applet/WMath.o %CPP% %ARDUINO%/Print.cpp -o applet/Print.o if exist %COREFILE% erase %COREFILE% %AR% applet/pins_arduino.o %AR% applet/wiring.o %AR% applet/wiring_analog.o %AR% applet/wiring_digital.o %AR% applet/wiring_pulse.o if exist applet/wiring_serial.o %AR% applet/wiring_serial.o %AR% applet/wiring_shift.o %AR% applet/WInterrupts.o %AR% applet/HardwareSerial.o %AR% applet/WMath.o %AR% applet/Print.o :EXISTCORE rem // 2. compile the libraries, outputting .o files to: // rem // 3. compile the sketch (already in the buildPath) %CPP% %CPPFILE% -o applet/main.o rem // 4. link it all together into the .elf file %LINKER% -o %ELFFILE% applet/main.o %COREFILE% -Lapplet -lm if ERRORLEVEL 1 goto ERROR2 rem // 5. extract EEPROM data (from EEMEM directive) to .eep file. %OBJCOPY% -j .eeprom --set-section-flags=.eeprom=alloc,load --no-change-warnings --change-section-lma .eeprom=0 %ELFFILE% %EEPFILE% rem // 6. build the .hex file %OBJCOPY% -R .eeprom %ELFFILE% %HEXFILE% rem // 7. show file size %SIZE% --target=ihex %HEXFILE% rem // 8. writing hex file into AVR chip %WRITE% if ERRORLEVEL 1 pause goto END :ERROR1 echo %1 not exist :ERROR2 pause :END