2020-04-19 01:47:49 -07:00
|
|
|
ARDUINO_DIR?=external/ArduinoCore-avr
|
|
|
|
NANOPB_DIR?=external/nanopb
|
2020-04-06 19:08:50 -07:00
|
|
|
|
|
|
|
CC=avr-gcc
|
|
|
|
CXX=avr-g++
|
|
|
|
OBJCOPY=avr-objcopy
|
|
|
|
OBJDUMP=avr-objdump
|
|
|
|
BINSIZE=avr-size
|
|
|
|
OUT=./bin/
|
|
|
|
NAME=collar
|
|
|
|
|
|
|
|
CFLAGS?=-Datmega328p\
|
2020-04-19 01:47:49 -07:00
|
|
|
-Dmega328p\
|
|
|
|
-mmcu=atmega328p\
|
|
|
|
-Wl,--gc-sections\
|
|
|
|
-DF_CPU=16000000L\
|
|
|
|
-DARDUINO=200\
|
|
|
|
-DARDUINO_AVR_NANO\
|
|
|
|
-DARDUINO_ARCH_AVR\
|
2020-05-15 14:20:43 -07:00
|
|
|
-DARDUINO_LMIC_PROJECT_CONFIG_H=fenceless_lmic_config.h\
|
2020-04-19 01:47:49 -07:00
|
|
|
-Os\
|
|
|
|
-fdata-sections\
|
|
|
|
-MMD\
|
|
|
|
-flto\
|
|
|
|
-fno-fat-lto-objects\
|
2020-05-12 21:48:51 -07:00
|
|
|
-fuse-linker-plugin\
|
2020-05-15 18:27:51 -07:00
|
|
|
-Wall\
|
2020-05-15 23:12:03 -07:00
|
|
|
-ffunction-sections\
|
2020-05-15 18:27:51 -07:00
|
|
|
|
|
|
|
|
2020-04-19 01:47:49 -07:00
|
|
|
|
|
|
|
CXXFLAGS?=-Datmega328p\
|
2020-05-13 23:12:34 -07:00
|
|
|
-std=c++11\
|
2020-04-06 19:08:50 -07:00
|
|
|
-Dmega328p\
|
|
|
|
-mmcu=atmega328p\
|
|
|
|
-Wl,--gc-sections\
|
|
|
|
-DF_CPU=16000000L\
|
|
|
|
-DARDUINO=200\
|
|
|
|
-DARDUINO_AVR_NANO\
|
|
|
|
-DARDUINO_ARCH_AVR\
|
2020-05-15 14:20:43 -07:00
|
|
|
-DARDUINO_LMIC_PROJECT_CONFIG_H=fenceless_lmic_config.h\
|
2020-04-06 19:08:50 -07:00
|
|
|
-Os\
|
|
|
|
-fdata-sections\
|
|
|
|
-MMD\
|
|
|
|
-flto\
|
|
|
|
-fno-fat-lto-objects\
|
2020-05-12 21:48:51 -07:00
|
|
|
-fuse-linker-plugin\
|
2020-05-15 14:20:43 -07:00
|
|
|
-Wall\
|
2020-05-15 23:12:03 -07:00
|
|
|
-ffunction-sections\
|
2020-05-15 18:27:51 -07:00
|
|
|
|
2020-04-06 19:08:50 -07:00
|
|
|
|
2020-05-15 05:30:37 -07:00
|
|
|
INC_DIRS?=-I./\
|
|
|
|
-I./$(ARDUINO_DIR)/libraries/SPI/src\
|
2020-04-06 19:08:50 -07:00
|
|
|
-I./$(ARDUINO_DIR)/cores/arduino\
|
|
|
|
-I./$(ARDUINO_DIR)/variants/eightanaloginputs\
|
|
|
|
-I./libraries/TinyGPSPlus/src\
|
2020-04-18 23:27:19 -07:00
|
|
|
-I./libraries/arduino-base64\
|
2020-04-06 19:08:50 -07:00
|
|
|
-I./$(NANOPB_DIR)\
|
|
|
|
-I./protobuf\
|
2020-05-13 23:12:34 -07:00
|
|
|
-I./$(ARDUINO_DIR)/libraries/SoftwareSerial/src/\
|
|
|
|
-I./libraries/arduino-lmic/src/\
|
|
|
|
-I./libraries/arduino-lmic/src/hal/\
|
|
|
|
-I./libraries/arduino-lmic/src/lmic/\
|
2020-05-15 05:30:37 -07:00
|
|
|
-I./libraries/arduino-lmic/src/aes/\
|
2020-05-15 14:20:43 -07:00
|
|
|
-I./libraries/AltSoftSerial/\
|
|
|
|
-I./
|
2020-04-06 19:08:50 -07:00
|
|
|
|
|
|
|
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\
|
2020-04-19 01:47:49 -07:00
|
|
|
./$(NANOPB_DIR)/pb_encode.c\
|
|
|
|
./$(NANOPB_DIR)/pb_decode.c\
|
|
|
|
./$(NANOPB_DIR)/pb_common.c\
|
|
|
|
./protobuf/gateway/message.pb.c\
|
2020-04-06 19:08:50 -07:00
|
|
|
./$(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)/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\
|
2020-04-18 20:07:23 -07:00
|
|
|
./$(ARDUINO_DIR)/libraries/SPI/src/SPI.cpp\
|
2020-04-06 19:08:50 -07:00
|
|
|
./libraries/TinyGPSPlus/src/TinyGPS++.cpp\
|
2020-05-13 23:12:34 -07:00
|
|
|
./libraries/arduino-lmic/src/hal/hal.cpp\
|
|
|
|
./libraries/arduino-lmic/src/hal/getpinmap_thisboard.cpp\
|
|
|
|
./libraries/arduino-lmic/src/aes/ideetron/AES-128_V10.cpp\
|
|
|
|
./libraries/arduino-lmic/src/lmic/lmic.c\
|
|
|
|
./libraries/arduino-lmic/src/lmic/lmic_eu_like.c\
|
|
|
|
./libraries/arduino-lmic/src/lmic/lmic_compliance.c\
|
|
|
|
./libraries/arduino-lmic/src/lmic/lmic_us_like.c\
|
|
|
|
./libraries/arduino-lmic/src/lmic/lmic_util.c\
|
|
|
|
./libraries/arduino-lmic/src/lmic/lmic_as923.c\
|
|
|
|
./libraries/arduino-lmic/src/lmic/lmic_au915.c\
|
|
|
|
./libraries/arduino-lmic/src/lmic/oslmic.c\
|
|
|
|
./libraries/arduino-lmic/src/lmic/lmic_eu868.c\
|
|
|
|
./libraries/arduino-lmic/src/lmic/lmic_us915.c\
|
|
|
|
./libraries/arduino-lmic/src/lmic/lmic_kr920.c\
|
|
|
|
./libraries/arduino-lmic/src/lmic/radio.c\
|
|
|
|
./libraries/arduino-lmic/src/lmic/lmic_in866.c\
|
|
|
|
./libraries/arduino-lmic/src/aes/lmic.c\
|
2020-05-15 05:30:37 -07:00
|
|
|
./libraries/arduino-lmic/src/aes/other.c\
|
|
|
|
./libraries/AltSoftSerial/AltSoftSerial.cpp
|
2020-05-13 23:12:34 -07:00
|
|
|
|
2020-04-18 20:07:23 -07:00
|
|
|
|
|
|
|
SRC_FILES_COMMON?=\
|
2020-04-06 19:08:50 -07:00
|
|
|
./$(NANOPB_DIR)/pb_encode.c\
|
|
|
|
./$(NANOPB_DIR)/pb_decode.c\
|
|
|
|
./$(NANOPB_DIR)/pb_common.c\
|
2020-05-13 23:12:34 -07:00
|
|
|
./protobuf/gateway/message.pb.c\
|
2020-04-06 19:08:50 -07:00
|
|
|
|
2020-04-19 01:47:49 -07:00
|
|
|
# Make targets for each source file
|
|
|
|
OBJS := $(SRC_FILES:%=./bin/%.o)
|
|
|
|
OBJDIRS := $(SRC_FILES:%=./bin/%)
|
|
|
|
|
2020-04-07 15:23:50 -07:00
|
|
|
build: $(OUT)$(NAME)
|
2020-04-06 19:08:50 -07:00
|
|
|
|
2020-04-19 01:47:49 -07:00
|
|
|
$(OBJDIRS):
|
2020-04-28 13:32:47 -07:00
|
|
|
@mkdir -p $(shell dirname $@)
|
2020-04-19 01:47:49 -07:00
|
|
|
$(OUT)%.cpp.o: %.cpp
|
|
|
|
$(CXX) $(CXXFLAGS) -c $(INC_DIRS) -o $@ $<
|
|
|
|
$(OUT)%.c.o: %.c
|
|
|
|
$(CC) $(CFLAGS) -c $(INC_DIRS) -o $@ $<
|
|
|
|
|
2020-04-07 15:23:50 -07:00
|
|
|
$(OUT)$(NAME): $(OUT)$(NAME).elf
|
2020-04-06 19:08:50 -07:00
|
|
|
$(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
|
2020-04-19 01:47:49 -07:00
|
|
|
$(OUT)$(NAME).elf: protobufg bin $(OBJDIRS) $(OBJS)
|
2020-05-15 05:30:37 -07:00
|
|
|
$(CC) $(CXXFLAGS) -o $(OUT)$(NAME).elf collar.cpp $(INC_DIRS) $(OBJS)
|
2020-05-15 23:12:03 -07:00
|
|
|
avr-size --mcu=atmega328p --format=avr $(OUT)$(NAME).elf
|
2020-04-06 19:08:50 -07:00
|
|
|
|
2020-04-18 20:07:23 -07:00
|
|
|
test:
|
2020-05-14 00:33:50 -07:00
|
|
|
g++ -o $(OUT)test test.c $(INC_DIRS) $(SRC_FILES_COMMON)
|
2020-04-18 20:07:23 -07:00
|
|
|
$(OUT)test
|
|
|
|
|
|
|
|
protobufg:
|
2020-04-28 13:32:47 -07:00
|
|
|
@mkdir -p protobuf/gateway
|
2020-04-07 15:23:50 -07:00
|
|
|
python3 external/nanopb/generator/nanopb_generator.py gateway/message.proto -D protobuf
|
2020-04-06 19:08:50 -07:00
|
|
|
|
|
|
|
bin:
|
2020-04-28 13:32:47 -07:00
|
|
|
@mkdir bin
|
2020-04-06 19:08:50 -07:00
|
|
|
|
2020-04-18 20:07:23 -07:00
|
|
|
flash: $(OUT)$(NAME)
|
2020-04-06 19:08:50 -07:00
|
|
|
avrdude -v -patmega328p -carduino -P/dev/ttyUSB0 -b115200 -D -Uflash:w:$(OUT)$(NAME).hex:i
|
2020-04-07 15:23:50 -07:00
|
|
|
|
2020-04-18 20:07:23 -07:00
|
|
|
run: flash
|
2020-05-15 14:20:43 -07:00
|
|
|
screen /dev/ttyUSB0
|
2020-04-18 20:07:23 -07:00
|
|
|
|
2020-05-15 23:12:03 -07:00
|
|
|
frun:
|
|
|
|
avrdude -v -patmega328p -carduino -P/dev/ttyUSB0 -b115200 -D -Uflash:w:$(OUT)$(NAME).hex:i
|
|
|
|
screen /dev/ttyUSB0
|
|
|
|
|
2020-04-18 20:07:23 -07:00
|
|
|
start: flash
|
|
|
|
systemctl start lora-gateway-bridge loraserver
|
2020-04-18 23:27:19 -07:00
|
|
|
|
2020-04-07 15:23:50 -07:00
|
|
|
stop:
|
|
|
|
avrdude -v -patmega328p -carduino -P/dev/ttyUSB0 -b115200 -D -Uflash:w:nothing.hex:i
|
|
|
|
|
2020-04-06 19:08:50 -07:00
|
|
|
clean:
|
|
|
|
rm -r protobuf
|
|
|
|
rm -r bin
|