summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Pointner <equinox@spreadspace.org>2018-11-28 18:11:29 +0100
committerChristian Pointner <equinox@spreadspace.org>2018-11-28 18:11:29 +0100
commit33f599bdb87e0604d2e3905b835c5f23b5e3b877 (patch)
treefb0801a97de92409dc6146723c19a0e34e497f78
parentusb-lora example works now - but is not stable yet... (diff)
added supported for arduino crypot lib
-rw-r--r--.gitignore2
-rw-r--r--contrib/Makefile18
-rw-r--r--crypto.mk44
-rw-r--r--include.mk31
-rw-r--r--lib/stdc++-minimal.cpp12
5 files changed, 104 insertions, 3 deletions
diff --git a/.gitignore b/.gitignore
index b336bc7..2d3a6f2 100644
--- a/.gitignore
+++ b/.gitignore
@@ -13,6 +13,8 @@ contrib/BMP180-*
contrib/vusb-*
contrib/RadioHead-*
contrib/RadioHead/
+contrib/.crypto.prepared
+contrib/crypto
contrib/.teensy-loader.prepared
contrib/teensy_loader_cli
contrib/.micronucleus.prepared
diff --git a/contrib/Makefile b/contrib/Makefile
index 9d606bb..eb86305 100644
--- a/contrib/Makefile
+++ b/contrib/Makefile
@@ -28,8 +28,8 @@ PJON_VERSION := 3.0
VUSB_VERSION := 20121206
RADIOHEAD_VERSION := 1.89
-all: download-lufa download-fastled download-pjon download-vusb download-radiohead update-teensy-loader update-micronucleus
-
+all: download-lufa download-fastled download-pjon download-vusb download-radiohead clone-crypto clone-teensy-loader clone-micronucleus
+update-all: update-crypto update-teensy-loader update-micronucleus
download-lufa: LUFA-${LUFA_VERSION}.zip
@@ -68,10 +68,22 @@ RadioHead-${RADIOHEAD_VERSION}.zip:
cd RadioHead; patch -p1 < ../radiohead.patch
+.crypto.prepared:
+ git clone https://github.com/rweather/arduinolibs.git crypto
+ touch $@
+
+clone-crypto: .crypto.prepared
+
+update-crypto: .crypto.prepared
+ cd crypto; git pull
+
+
.teensy-loader.prepared:
git clone https://github.com/PaulStoffregen/teensy_loader_cli.git
touch $@
+clone-teensy-loader: .teensy-loader.prepared
+
update-teensy-loader: .teensy-loader.prepared
cd teensy_loader_cli; git pull; make
@@ -80,5 +92,7 @@ update-teensy-loader: .teensy-loader.prepared
git clone https://github.com/micronucleus/micronucleus/
touch $@
+clone-micronucleus: .micronucleus.prepared
+
update-micronucleus: .micronucleus.prepared
cd micronucleus/commandline; git pull; make
diff --git a/crypto.mk b/crypto.mk
new file mode 100644
index 0000000..f35102d
--- /dev/null
+++ b/crypto.mk
@@ -0,0 +1,44 @@
+##
+## spreadspace avr utils
+##
+##
+## Copyright (C) 2013-2016 Christian Pointner <equinox@spreadspace.org>
+##
+## This file is part of spreadspace avr utils.
+##
+## spreadspace avr utils is free software: you can redistribute it and/or modify
+## it under the terms of the GNU General Public License as published by
+## the Free Software Foundation, either version 3 of the License, or
+## any later version.
+##
+## spreadspace avr utils is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with spreadspace avr utils. If not, see <http://www.gnu.org/licenses/>.
+##
+
+include $(SPREADAVR_PATH)/defines.mk
+
+SRC:=$(wildcard $(CRYPTO_PATH)/libraries/Crypto/*.cpp)
+DEPLIBS := stdc++-minimal
+
+CXXFLAGS += -I$(CRYPTO_PATH)/libraries/Crypto
+CXXFLAGS += $(CRYPTO_OPTS)
+
+OBJ = $(SRC:%.cpp=%.o)
+OBJ_DEPLIB = $(DEPLIBS:%=deplib-crypto--%.o)
+
+libcrypto.a: $(OBJ) $(OBJ_DEPLIB)
+ $(AR) $@ $(OBJ) $(OBJ_DEPLIB)
+
+%.o: %.cpp
+ $(CXX) -c $(CXXFLAGS) $< -o $@
+
+deplib-crypto--%.o: $(LIB_DIR)/%.cpp
+ $(CXX) $(CXXFLAGS) -c $< -o $@
+
+clean:
+ rm -f $(SRC:%.cpp=%.o) $(OBJ_DEPLIB)
diff --git a/include.mk b/include.mk
index d47827c..b1e3e0d 100644
--- a/include.mk
+++ b/include.mk
@@ -41,7 +41,7 @@ CXX_OBJ_LIB := $(CXX_LIBS:%=lib-%.o)
CXX_SRC_LIB := $(CXX_LIBS:%=$(LIB_DIR)/%.cpp)
CXX_DEP_LIB := $(CXX_LIBS:%=lib-%.d)
-.PHONY: prepare clean clean-external distclean clean-lufa clean-fastled clean-pjon clean-vusb clean-radiohead program erase flash reset run
+.PHONY: prepare clean clean-external distclean clean-lufa clean-fastled clean-pjon clean-vusb clean-radiohead clean-crypto program erase flash reset run
ELFFILE := $(NAME).elf
HEXFILE := $(NAME).hex
@@ -89,6 +89,12 @@ CXXFLAGS += -DRH_PLATFORM=RH_PLATFORM_GENERIC_AVR8
CXXFLAGS += $(RADIOHEAD_OPTS)
endif
+ifdef CRYPTO_PATH
+CXXFLAGS += -I$(CRYPTO_PATH)/libraries/Crypto
+CXXFLAGS += -DUSES_CRYPTO
+CXXFLAGS += $(CRYPTO_OPTS)
+endif
+
prepare: $(EXTERNAL_LIBS:%=build-%)
clean-external: $(EXTERNAL_LIBS:%=clean-%)
@@ -209,6 +215,29 @@ clean-radiohead:
@echo "****************************************************"
+build-crypto: libcrypto.a
+
+libcrypto.a: Makefile
+ @echo ""
+ @echo "****************************************************"
+ @echo "building external crypto lib ($(CRYPTO_PATH))"
+ @echo ""
+ make -f $(SPREADAVR_PATH)/crypto.mk libcrypto.a
+ make -f $(SPREADAVR_PATH)/crypto.mk clean
+ @echo ""
+ @echo "****************************************************"
+
+clean-crypto:
+ @echo ""
+ @echo "****************************************************"
+ @echo "cleaning external crypto lib ($(CRYPTO_PATH))"
+ @echo ""
+ make -f $(SPREADAVR_PATH)/crypto.mk clean
+ rm -f libcrypto.a
+ @echo ""
+ @echo "****************************************************"
+
+
## project-specific objects
%.d: %.c Makefile
@set -e; rm -f $@; \
diff --git a/lib/stdc++-minimal.cpp b/lib/stdc++-minimal.cpp
index c3b0559..982719b 100644
--- a/lib/stdc++-minimal.cpp
+++ b/lib/stdc++-minimal.cpp
@@ -39,3 +39,15 @@ void __cxa_deleted_virtual(void) {
printf("PANIC: __cxa_deleted_virtual() got called ...\r\n");
for(;;);
}
+
+void * operator new(size_t n)
+{
+ void * const p = malloc(n);
+ // handle p == 0
+ return p;
+}
+
+void operator delete(void * p) // or delete(void *, std::size_t)
+{
+ free(p);
+}