|
|
@ -7,28 +7,28 @@ set -e
|
|
|
|
######
|
|
|
|
######
|
|
|
|
|
|
|
|
|
|
|
|
build_version () {
|
|
|
|
build_version () {
|
|
|
|
GIT_VERSION="$(cd $(find_sketch); git describe --abbrev=4 --dirty --always)"
|
|
|
|
GIT_VERSION="$(cd $(find_sketch); git describe --abbrev=4 --dirty --always)"
|
|
|
|
LIB_VERSION="$(cd $(find_sketch); (grep version= ../../library.properties 2>/dev/null || echo version=0.0.0) | cut -d= -f2)-g${GIT_VERSION}"
|
|
|
|
LIB_VERSION="$(cd $(find_sketch); (grep version= ../../library.properties 2>/dev/null || echo version=0.0.0) | cut -d= -f2)-g${GIT_VERSION}"
|
|
|
|
|
|
|
|
|
|
|
|
BUILD_PATH="${BUILD_PATH:-$(mktemp -d 2>/dev/null || mktemp -d -t 'build')}"
|
|
|
|
BUILD_PATH="${BUILD_PATH:-$(mktemp -d 2>/dev/null || mktemp -d -t 'build')}"
|
|
|
|
OUTPUT_DIR="${OUTPUT_DIR:-output/${LIBRARY}}"
|
|
|
|
OUTPUT_DIR="${OUTPUT_DIR:-output/${LIBRARY}}"
|
|
|
|
OUTPUT_PATH="${OUTPUT_PATH:-${SOURCEDIR}/${OUTPUT_DIR}}"
|
|
|
|
OUTPUT_PATH="${OUTPUT_PATH:-${SOURCEDIR}/${OUTPUT_DIR}}"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
build_filenames () {
|
|
|
|
build_filenames () {
|
|
|
|
OUTPUT_FILE_PREFIX="${SKETCH}-${LIB_VERSION}"
|
|
|
|
OUTPUT_FILE_PREFIX="${SKETCH}-${LIB_VERSION}"
|
|
|
|
HEX_FILE_PATH="${OUTPUT_PATH}/${OUTPUT_FILE_PREFIX}.hex"
|
|
|
|
HEX_FILE_PATH="${OUTPUT_PATH}/${OUTPUT_FILE_PREFIX}.hex"
|
|
|
|
HEX_FILE_WITH_BOOTLOADER_PATH="${OUTPUT_PATH}/${OUTPUT_FILE_PREFIX}-with-bootloader.hex"
|
|
|
|
HEX_FILE_WITH_BOOTLOADER_PATH="${OUTPUT_PATH}/${OUTPUT_FILE_PREFIX}-with-bootloader.hex"
|
|
|
|
ELF_FILE_PATH="${OUTPUT_PATH}/${OUTPUT_FILE_PREFIX}.elf"
|
|
|
|
ELF_FILE_PATH="${OUTPUT_PATH}/${OUTPUT_FILE_PREFIX}.elf"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
firmware_size () {
|
|
|
|
firmware_size () {
|
|
|
|
if [ "${BOARD}" = "virtual" ]; then
|
|
|
|
if [ "${BOARD}" = "virtual" ]; then
|
|
|
|
echo "[Size not computed for virtual build]"
|
|
|
|
echo "[Size not computed for virtual build]"
|
|
|
|
return
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
## This is a terrible hack, please don't hurt me. - algernon
|
|
|
|
## This is a terrible hack, please don't hurt me. - algernon
|
|
|
|
|
|
|
|
|
|
|
|
MAX_PROG_SIZE=28672
|
|
|
|
MAX_PROG_SIZE=28672
|
|
|
|
|
|
|
|
|
|
|
@ -57,7 +57,7 @@ find_sketch () {
|
|
|
|
return
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
done
|
|
|
|
echo "Couldn't find sketch (.ino file)" >&2
|
|
|
|
echo "Couldn't find sketch (.ino file)" >&2
|
|
|
|
exit 1
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -84,9 +84,9 @@ flash_over_usb () {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
flash_from_bootloader() {
|
|
|
|
flash_from_bootloader() {
|
|
|
|
prepare_to_flash
|
|
|
|
prepare_to_flash
|
|
|
|
find_bootloader_ports
|
|
|
|
find_bootloader_ports
|
|
|
|
flash_over_usb || flash_over_usb
|
|
|
|
flash_over_usb || flash_over_usb
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
program() {
|
|
|
|
program() {
|
|
|
@ -96,12 +96,12 @@ program() {
|
|
|
|
|
|
|
|
|
|
|
|
flash_with_programmer() {
|
|
|
|
flash_with_programmer() {
|
|
|
|
${AVRDUDE} -v \
|
|
|
|
${AVRDUDE} -v \
|
|
|
|
-C ${AVRDUDE_CONF} \
|
|
|
|
-C ${AVRDUDE_CONF} \
|
|
|
|
-p${MCU} \
|
|
|
|
-p${MCU} \
|
|
|
|
-cusbtiny \
|
|
|
|
-cusbtiny \
|
|
|
|
-D \
|
|
|
|
-D \
|
|
|
|
-B 1 \
|
|
|
|
-B 1 \
|
|
|
|
"-Uflash:w:${HEX_FILE_PATH}:i"
|
|
|
|
"-Uflash:w:${HEX_FILE_PATH}:i"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
hex_with_bootloader () {
|
|
|
|
hex_with_bootloader () {
|
|
|
@ -109,11 +109,11 @@ hex_with_bootloader () {
|
|
|
|
compile
|
|
|
|
compile
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
cat ${HEX_FILE_PATH} | awk '/^:00000001FF/ == 0' > ${HEX_FILE_WITH_BOOTLOADER_PATH}
|
|
|
|
cat ${HEX_FILE_PATH} | awk '/^:00000001FF/ == 0' > ${HEX_FILE_WITH_BOOTLOADER_PATH}
|
|
|
|
echo "Using ${BOOTLOADER_PATH}"
|
|
|
|
echo "Using ${BOOTLOADER_PATH}"
|
|
|
|
${MD5} ${BOOTLOADER_PATH}
|
|
|
|
${MD5} ${BOOTLOADER_PATH}
|
|
|
|
cat ${BOOTLOADER_PATH} >> ${HEX_FILE_WITH_BOOTLOADER_PATH}
|
|
|
|
cat ${BOOTLOADER_PATH} >> ${HEX_FILE_WITH_BOOTLOADER_PATH}
|
|
|
|
ln -sf "${HEX_FILE_WITH_BOOTLOADER_PATH}" "${OUTPUT_PATH}/${SKETCH}-latest-with-bootloader.hex"
|
|
|
|
ln -sf "${HEX_FILE_WITH_BOOTLOADER_PATH}" "${OUTPUT_PATH}/${SKETCH}-latest-with-bootloader.hex"
|
|
|
|
cat <<EOF
|
|
|
|
cat <<EOF
|
|
|
|
|
|
|
|
|
|
|
|
Combined firmware and bootloader are now at ${HEX_FILE_WITH_BOOTLOADER_PATH}
|
|
|
|
Combined firmware and bootloader are now at ${HEX_FILE_WITH_BOOTLOADER_PATH}
|
|
|
@ -143,29 +143,29 @@ compile () {
|
|
|
|
|
|
|
|
|
|
|
|
ARDUINO_PACKAGES=""
|
|
|
|
ARDUINO_PACKAGES=""
|
|
|
|
if [ -d ${ARDUINO_PACKAGE_PATH} ]; then
|
|
|
|
if [ -d ${ARDUINO_PACKAGE_PATH} ]; then
|
|
|
|
ARDUINO_PACKAGES="-hardware \"${ARDUINO_PACKAGE_PATH}\""
|
|
|
|
ARDUINO_PACKAGES="-hardware \"${ARDUINO_PACKAGE_PATH}\""
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
${ARDUINO_BUILDER} \
|
|
|
|
${ARDUINO_BUILDER} \
|
|
|
|
-compile \
|
|
|
|
-compile \
|
|
|
|
${ARDUINO_PACKAGES} \
|
|
|
|
${ARDUINO_PACKAGES} \
|
|
|
|
-hardware "${ARDUINO_PATH}/hardware" \
|
|
|
|
-hardware "${ARDUINO_PATH}/hardware" \
|
|
|
|
-hardware "${BOARD_HARDWARE_PATH}" \
|
|
|
|
-hardware "${BOARD_HARDWARE_PATH}" \
|
|
|
|
${ARDUINO_TOOLS_PARAM} \
|
|
|
|
${ARDUINO_TOOLS_PARAM} \
|
|
|
|
-tools "${ARDUINO_PATH}/tools-builder" \
|
|
|
|
-tools "${ARDUINO_PATH}/tools-builder" \
|
|
|
|
-fqbn "${FQBN}" \
|
|
|
|
-fqbn "${FQBN}" \
|
|
|
|
-libraries "." \
|
|
|
|
-libraries "." \
|
|
|
|
-libraries "${ROOT}" \
|
|
|
|
-libraries "${ROOT}" \
|
|
|
|
-libraries "${BOARD_HARDWARE_PATH}/.." \
|
|
|
|
-libraries "${BOARD_HARDWARE_PATH}/.." \
|
|
|
|
${local_LIBS} \
|
|
|
|
${local_LIBS} \
|
|
|
|
${EXTRA_BUILDER_ARGS} \
|
|
|
|
${EXTRA_BUILDER_ARGS} \
|
|
|
|
-build-path "${BUILD_PATH}" \
|
|
|
|
-build-path "${BUILD_PATH}" \
|
|
|
|
-ide-version "${ARDUINO_IDE_VERSION}" \
|
|
|
|
-ide-version "${ARDUINO_IDE_VERSION}" \
|
|
|
|
-prefs "compiler.cpp.extra_flags=-std=c++11 -Woverloaded-virtual -Wno-unused-parameter -Wno-unused-variable -Wno-ignored-qualifiers ${ARDUINO_CFLAGS} ${LOCAL_CFLAGS}" \
|
|
|
|
-prefs "compiler.cpp.extra_flags=-std=c++11 -Woverloaded-virtual -Wno-unused-parameter -Wno-unused-variable -Wno-ignored-qualifiers ${ARDUINO_CFLAGS} ${LOCAL_CFLAGS}" \
|
|
|
|
-warnings all \
|
|
|
|
-warnings all \
|
|
|
|
${ARDUINO_VERBOSE} \
|
|
|
|
${ARDUINO_VERBOSE} \
|
|
|
|
${ARDUINO_AVR_GCC_PREFIX_PARAM} \
|
|
|
|
${ARDUINO_AVR_GCC_PREFIX_PARAM} \
|
|
|
|
"$(find_sketch)/${SKETCH}.ino"
|
|
|
|
"$(find_sketch)/${SKETCH}.ino"
|
|
|
|
|
|
|
|
|
|
|
|
cp "${BUILD_PATH}/${SKETCH}.ino.hex" "${HEX_FILE_PATH}"
|
|
|
|
cp "${BUILD_PATH}/${SKETCH}.ino.hex" "${HEX_FILE_PATH}"
|
|
|
|
cp "${BUILD_PATH}/${SKETCH}.ino.elf" "${ELF_FILE_PATH}"
|
|
|
|
cp "${BUILD_PATH}/${SKETCH}.ino.elf" "${ELF_FILE_PATH}"
|
|
|
@ -173,15 +173,15 @@ compile () {
|
|
|
|
ln -sf "${OUTPUT_FILE_PREFIX}.elf" "${OUTPUT_PATH}/${SKETCH}-latest.elf"
|
|
|
|
ln -sf "${OUTPUT_FILE_PREFIX}.elf" "${OUTPUT_PATH}/${SKETCH}-latest.elf"
|
|
|
|
|
|
|
|
|
|
|
|
if [ "${ARDUINO_VERBOSE}" = "-verbose" ]; then
|
|
|
|
if [ "${ARDUINO_VERBOSE}" = "-verbose" ]; then
|
|
|
|
echo "Build artifacts can be found in ${BUILD_PATH}";
|
|
|
|
echo "Build artifacts can be found in ${BUILD_PATH}";
|
|
|
|
else
|
|
|
|
else
|
|
|
|
rm -rf "${BUILD_PATH}"
|
|
|
|
rm -rf "${BUILD_PATH}"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
_find_all () {
|
|
|
|
_find_all () {
|
|
|
|
for plugin in ./*.ino \
|
|
|
|
for plugin in ./*.ino \
|
|
|
|
examples/* \
|
|
|
|
examples/* \
|
|
|
|
src/*.ino; do
|
|
|
|
src/*.ino; do
|
|
|
|
if [ -d "$(dirname ${plugin})" ] || [ -f "${plugin}" ]; then
|
|
|
|
if [ -d "$(dirname ${plugin})" ] || [ -f "${plugin}" ]; then
|
|
|
|
p="$(basename "${plugin}" .ino)"
|
|
|
|
p="$(basename "${plugin}" .ino)"
|
|
|
@ -207,9 +207,9 @@ size () {
|
|
|
|
compile
|
|
|
|
compile
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
echo "- Size: firmware/${LIBRARY}/${OUTPUT_FILE_PREFIX}.elf"
|
|
|
|
echo "- Size: firmware/${LIBRARY}/${OUTPUT_FILE_PREFIX}.elf"
|
|
|
|
firmware_size "${AVR_SIZE}" -C --mcu="${MCU}" "${ELF_FILE_PATH}"
|
|
|
|
firmware_size "${AVR_SIZE}" -C --mcu="${MCU}" "${ELF_FILE_PATH}"
|
|
|
|
echo
|
|
|
|
echo
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
size_map () {
|
|
|
|
size_map () {
|
|
|
|