#!/bin/bash # USAGE # ./scripts/compile (("program" | "flash" | "f" | "build" | "compile" | "b" | # "clean" | "c" | "rebuild" | "recompile" | "r" | "terminal" | "com" | # "picocom" | "t" | "pause" | "wait" | "p" | "w") " ")* # # # USAGE EXAMPLE # ./scripts/compile r f t # # # DIRECTORY STRUCTURE # main.c The main program's C-File # main.h The main program's H-File # config_application.h The main program's Femto OS configuration # femtoos_devices/ Femto OS files # femtoos_headers/ Femto OS files # femtoos_source/ Femto OS files # obj/ Compiler outputs # scripts/compile This script # scripts/overall_info Can be fount in Femto OS # scripts/test_fp_use Can be fount in Femto OS # http://img35.imageshack.us/f/compilerflags.png/ CARGS=" \ -I../femtoos_headers \ -I../femtoos_devices \ -I../femtoos_source \ -I.. -mmcu=atmega1280 \ -Os \ --param inline-call-cost=2 \ -gdwarf-2 \ -mint8 \ -Wall \ -Wno-main \ -Winline \ -Wundef \ -Wl,--defsym=__stack=xOS+xOSstackShift \ -Wl,--gc-sections \ -Wl,--relax \ -funsigned-char \ -fpack-struct \ -fshort-enums \ -ffunction-sections \ -fomit-frame-pointer -save-temps " LARGS="$CARGS \ -minit-stack='xOS+xOSstackShift' -Wl,-Map=main.map" CARGS="$CARGS \ -DF_CPU=16000000ULL \ -DdefExtReduceProEpilogue=cfgBikini \ -c " AARGS="$CARGS \ -x assembler-with-cpp " PREFIX="/usr/local/bin" GCC="$PREFIX/avr-gcc" OBJCOPY="$PREFIX/avr-objcopy" OBJDUMP="$PREFIX/avr-objdump" AVRDUDE="$PREFIX/avrdude" SIZE="$PREFIX/avr-size" function doFlash() { # -V Disable automatic verify check when uploading data. $AVRDUDE -p atmega1280 -P /dev/ttyUSB* -c arduino -b 57600 -U flash:w:obj/main.hex } function doClean() { rm obj/* } function doBuild() { mkdir -p obj cd obj echo "main.c" $GCC $CARGS -o main.o ../main.c || exit 1 echo "femtoos_core.c" $GCC $CARGS -o femtoos_core.o ../femtoos_source/femtoos_core.c || exit 1 echo "femtoos_port.c" $GCC $CARGS -o femtoos_port.o ../femtoos_source/femtoos_port.c || exit 1 echo "femtoos_shared.c" $GCC $CARGS -o femtoos_shared.o ../femtoos_source/femtoos_shared.c || exit 1 echo "emtoos_startup.s" $GCC $AARGS -o femtoos_startup.o ../femtoos_source/femtoos_startup.s || exit 1 echo "LINKING" $GCC $LARGS -o main.elf femtoos_shared.o femtoos_core.o femtoos_port.o femtoos_startup.o main.o || exit 1 $OBJCOPY -O binary -R .eeprom main.elf main.bin || exit 1 $OBJCOPY -O ihex -R .eeprom main.elf main.hex || exit 1 $OBJCOPY -j .eeprom --set-section-flags=.eeprom="alloc,load" --change-section-lma .eeprom=0 --no-change-warnings -O ihex main.elf main.eep || exit 1 $OBJDUMP -dt main.elf > main.lss || exit 1 ../scripts/test_fp_use main.lss || exit 1 ../scripts/overall_info main.lss femtoos_shared.i main.map > main.defs || exit 1 ../scripts/overall_info main.lss femtoos_shared.i main.map registers | tee main.regs || exit 1 ../scripts/overall_info main.lss femtoos_shared.i main.map labels || exit 1 $SIZE main.elf | tee main.size cd .. } function doTerminal() { # picocom -b 19200 /dev/ttyUSB* picocom /dev/ttyUSB* } function doWait() { echo "Just waiting for YOU!!!!!1111eleven" read } while [ $# -ne 0 ] do case $1 in "program" | "flash" | "f") doFlash || exit 1 ;; "build" | "compile" | "b") doBuild || exit 1 ;; "clean" | "c") doClean || exit 1 ;; "rebuild" | "recompile" | "r") doClean || exit 1 doBuild || exit 1 ;; "terminal" | "com" | "picocom" | "t") doTerminal || exit 1 ;; "pause" | "wait" | "p" | "w") doWait || exit 1 ;; esac shift done