new build system, does not use arduino ide

This commit is contained in:
sessionm21 2020-04-06 19:08:50 -07:00
parent 95032c0d98
commit 23d27d7e2d
4 changed files with 86 additions and 2 deletions

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
/bin
/protobuf

82
Makefile Normal file
View File

@ -0,0 +1,82 @@
ARDUINO_DIR?="external/ArduinoCore-avr"
NANOPB_DIR?="external/nanopb"
CC=avr-gcc
CXX=avr-g++
OBJCOPY=avr-objcopy
OBJDUMP=avr-objdump
BINSIZE=avr-size
OUT=./bin/
NAME=collar
CFLAGS?=-Datmega328p\
-Dmega328p\
-mmcu=atmega328p\
-Wl,--gc-sections\
-DF_CPU=16000000L\
-DARDUINO=200\
-DARDUINO_AVR_NANO\
-DARDUINO_ARCH_AVR\
-Os\
-ffunction-sections\
-fdata-sections\
-MMD\
-flto\
-fno-fat-lto-objects\
-fuse-linker-plugin
INC_DIRS?=-I./$(ARDUINO_DIR)/libraries/SPI/src\
-I./$(ARDUINO_DIR)/cores/arduino\
-I./$(ARDUINO_DIR)/variants/eightanaloginputs\
-I./libraries/arduino-LoRa/src\
-I./libraries/TinyGPSPlus/src\
-I./$(NANOPB_DIR)\
-I./protobuf\
-I./$(ARDUINO_DIR)/libraries/SoftwareSerial/src/
SRC_FILES?=./$(ARDUINO_DIR)/cores/arduino/main.cpp\
./$(ARDUINO_DIR)/cores/arduino/wiring_digital.c\
./$(ARDUINO_DIR)/cores/arduino/wiring_analog.c\
./$(ARDUINO_DIR)/cores/arduino/WInterrupts.c\
./$(ARDUINO_DIR)/cores/arduino/hooks.c\
./$(ARDUINO_DIR)/cores/arduino/wiring.c\
./$(ARDUINO_DIR)/cores/arduino/HardwareSerial.cpp\
./$(ARDUINO_DIR)/cores/arduino/HardwareSerial0.cpp\
./$(ARDUINO_DIR)/cores/arduino/HardwareSerial1.cpp\
./$(ARDUINO_DIR)/cores/arduino/HardwareSerial2.cpp\
./$(ARDUINO_DIR)/cores/arduino/HardwareSerial3.cpp\
./$(ARDUINO_DIR)/libraries/SPI/src/SPI.cpp\
./$(ARDUINO_DIR)/cores/arduino/WString.cpp\
./$(ARDUINO_DIR)/cores/arduino/Print.cpp\
./$(ARDUINO_DIR)/cores/arduino/Stream.cpp\
./$(ARDUINO_DIR)/cores/arduino/new.cpp\
./$(ARDUINO_DIR)/cores/arduino/abi.cpp\
./$(ARDUINO_DIR)/libraries/SoftwareSerial/src/SoftwareSerial.cpp\
./libraries/arduino-LoRa/src/LoRa.cpp\
./libraries/TinyGPSPlus/src/TinyGPS++.cpp\
./$(NANOPB_DIR)/pb_encode.c\
./$(NANOPB_DIR)/pb_decode.c\
./$(NANOPB_DIR)/pb_common.c\
./gateway/message.pb.c
build: $(OUT)$(NAME).hex
$(OUT)$(NAME).hex: $(OUT)$(NAME).elf
$(OBJCOPY) -R .eeprom -O ihex $(OUT)$(NAME).elf $(OUT)$(NAME).hex
$(OUT)eep.hex: $(OUT)$(NAME).elf
$(OBJCOPY) -j .eeprom --change-section-lma .eeprom=0 -O ihex $(OUT)$(NAME).elf $(OUT)eep.hex
$(OUT)$(NAME).elf: protobuf bin
$(CC) $(CFLAGS) -o $(OUT)$(NAME).elf collar.cpp $(INC_DIRS) $(SRC_FILES)
protobuf:
mkdir -p protobuf/gateway
python external/nanopb/generator/nanopb_generator.py gateway/message.proto -D protobuf
bin:
mkdir bin
flash:
avrdude -v -patmega328p -carduino -P/dev/ttyUSB0 -b115200 -D -Uflash:w:$(OUT)$(NAME).hex:i
clean:
rm -r protobuf
rm -r bin

View File

@ -7,7 +7,7 @@
#include "pb.h"
#include "pb_encode.h"
#include "message.pb.h"
#include "gateway/message.pb.h"
unsigned long previousMillis = 0;
const long interval = 5000;

@ -1 +1 @@
Subproject commit 19985b04c221441bfe461d694023d1cb76147c56
Subproject commit 927f3dc6c614fc20ff2300b1d34139deceaea063