Last active
January 25, 2021 17:22
-
-
Save mkuf/bb7cbdd6d03f0acf9a27 to your computer and use it in GitHub Desktop.
compile Repetier-Firmware without GUI
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| ## Licensed under GNU GPLv3 | |
| ## Get the most recent Version via https://gist.github.com/voodoo-bravo/bb7cbdd6d03f0acf9a27 | |
| ## | |
| ## compile Repetier-Firmware without GUI | |
| ## | |
| ## Before you start: | |
| ## Set ADIR to your ArduinoIDE-Directory | |
| ## Set GPP, GCC, AR, OC. These can either be the binaries from the ArduinoIDE or your Distro | |
| ## | |
| ## How to use: | |
| ## Place this file in the Repetier-Directory (besides Repetier.ino) | |
| ## cd to your Repetier-Dir | |
| ## to compile, execute './compile157.sh compile' (no output except errors) | |
| ## after compiling, you can upload the binary with './compile157.sh upload' | |
| ## Changelog | |
| ## 13Nov2015: Minor tweaks to support repetier 0.92.6 | |
| ## 10Jan2016: Minor tweaks to support repetier 0.92.8 | |
| ## 09Feb2016: Add new Project-Files automatically to Binary-Creation | |
| PROJECT=$(ls *.ino) | |
| ADIR=/opt/arduino-1.5.7 #location of your arduino-ide | |
| BDIR=./build | |
| DUE=ttymxc3 #device-file under '/dev/' | |
| case $1 in | |
| upload) | |
| /usr/bin/sudo stty -F /dev/${DUE} cs8 115200 hupcl | |
| /usr/bin/sudo ${ADIR}/hardware/tools/bossac --port=${DUE} -U false -e -w -b ${BDIR}/${PROJECT}.cpp.bin -R | |
| ;; | |
| *) | |
| GPP=/usr/bin/arm-none-eabi-g++ | |
| GCC=/usr/bin/arm-none-eabi-gcc | |
| AR=/usr/bin/arm-none-eabi-ar | |
| OC=/usr/bin/arm-none-eabi-objcopy | |
| GPPOPTS="-c -g -Os -w -ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -Dprintf=iprintf -mcpu=cortex-m3 -DF_CPU=84000000L -DARDUINO=157 -DARDUINO_SAM_DUE -DARDUINO_ARCH_SAM -D__SAM3X8E__ -mthumb -DUSB_VID=0x2341 -DUSB_PID=0x003e -DUSBCON" # -DUSB_MANUFACTURER=\"Unknown\" -DUSB_PRODUCT=\"Arduino Due\"" | |
| GCCOPTS="-c -g -Os -w -ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500 -Dprintf=iprintf -mcpu=cortex-m3 -DF_CPU=84000000L -DARDUINO=157 -DARDUINO_SAM_DUE -DARDUINO_ARCH_SAM -D__SAM3X8E__ -mthumb -DUSB_VID=0x2341 -DUSB_PID=0x003e -DUSBCON" # -DUSB_MANUFACTURER=\"Unknown\" -DUSB_PRODUCT=\"Arduino Due\"" | |
| INC_ALL="-I${ADIR}/hardware/arduino/sam/system/libsam -I${ADIR}/hardware/arduino/sam/system/CMSIS/CMSIS/Include/ -I${ADIR}/hardware/arduino/sam/system/CMSIS/Device/ATMEL/ -I${ADIR}/hardware/arduino/sam/cores/arduino -I${ADIR}/hardware/arduino/sam/variants/arduino_due_x" | |
| INC_GPP="-I${ADIR}/hardware/arduino/sam/libraries/SPI" | |
| INC_GCC="" | |
| if [ -d "${BDIR}" ]; then | |
| rm -rf ${BDIR} | |
| fi | |
| mkdir ${BDIR} | |
| #======================== | |
| # Compile Repetier | |
| #======================== | |
| #create mainfile | |
| cat ${ADIR}/hardware/arduino/sam/cores/arduino/main.cpp > ${PROJECT}.cpp | |
| cat ${PROJECT} >> ${PROJECT}.cpp | |
| echo 'extern "C" void __cxa_pure_virtual() {while (true);}' >> ${PROJECT}.cpp | |
| #compile application | |
| for dot_cpp in $(ls *.cpp); do | |
| ${GPP} ${GPPOPTS} ${INC_ALL} ${INC_GPP} ${dot_cpp} -o ${BDIR}/${dot_cpp}.o | |
| gpp_group="${gpp_group} ${BDIR}/${dot_cpp}.o" | |
| done | |
| rm ${PROJECT}.cpp | |
| #======================== | |
| # Compile Libraries | |
| #======================== | |
| #arduino c libs | |
| for dot_c in $(ls ${ADIR}/hardware/arduino/sam/cores/arduino/*.c ${ADIR}/hardware/arduino/sam/cores/arduino/avr/*.c); do | |
| dot_c_out=$(echo ${dot_c} | sed -rs 's/.*\/(.*.c)/\1\.o/g') | |
| ${GCC} ${GCCOPTS} ${INC_ALL} ${dot_c} -o ${BDIR}/${dot_c_out} | |
| ${AR} rcs ${BDIR}/core.a ${BDIR}/${dot_c_out} | |
| done | |
| #arduino cpp libs | |
| for dot_cpp in $(ls ${ADIR}/hardware/arduino/sam/cores/arduino/*.cpp ${ADIR}/hardware/arduino/sam/cores/arduino/USB/*.cpp ${ADIR}/hardware/arduino/sam/libraries/SPI/*.cpp); do | |
| dot_cpp_out=$(echo ${dot_cpp} | sed -rs 's/.*\/(.*\.cpp)/\1.o/g') | |
| ${GPP} ${GPPOPTS} ${INC_ALL} ${dot_cpp} -o ${BDIR}/${dot_cpp_out} | |
| ${AR} rcs ${BDIR}/core.a ${BDIR}/${dot_cpp_out} | |
| done | |
| ${GPP} ${GPPOPTS} ${INC_ALL} ${ADIR}/hardware/arduino/sam/variants/arduino_due_x/variant.cpp -o ${BDIR}/variant.cpp.o | |
| #======================== | |
| # Create Binary | |
| #======================== | |
| ${GPP} \ | |
| -Os \ | |
| -Wl,--gc-sections \ | |
| -mcpu=cortex-m3 \ | |
| -T${ADIR}/hardware/arduino/sam/variants/arduino_due_x/linker_scripts/gcc/flash.ld \ | |
| -Wl,-Map,${BDIR}/${PROJECT}.cpp.map \ | |
| -o ${BDIR}/${PROJECT}.cpp.elf \ | |
| -L${BDIR} \ | |
| -lm \ | |
| -lgcc \ | |
| -mthumb \ | |
| -Wl,--cref \ | |
| -Wl,--check-sections \ | |
| -Wl,--gc-sections \ | |
| -Wl,--entry=Reset_Handler \ | |
| -Wl,--unresolved-symbols=report-all \ | |
| -Wl,--warn-common \ | |
| -Wl,--warn-section-align \ | |
| -Wl,--warn-unresolved-symbols \ | |
| -Wl,--start-group \ | |
| ${gpp_group} \ | |
| ${ADIR}/hardware/arduino/sam/variants/arduino_due_x/libsam_sam3x8e_gcc_rel.a \ | |
| ${BDIR}/core.a \ | |
| ${BDIR}/SPI.cpp.o \ | |
| ${BDIR}/syscalls_sam3.c.o \ | |
| ${BDIR}/variant.cpp.o \ | |
| -Wl,--end-group | |
| #======================== | |
| # Binary Copy | |
| #======================== | |
| ${OC} -O binary ${BDIR}/${PROJECT}.cpp.elf ${BDIR}/${PROJECT}.cpp.bin | |
| ;; | |
| esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment