2023-08-22 06:11:50 +08:00
|
|
|
CFLAGS = -W -Wall -Wextra -Wundef -Wshadow -Wdouble-promotion
|
2023-08-11 05:59:23 +08:00
|
|
|
CFLAGS += -Wformat-truncation -fno-common -Wconversion
|
2023-08-22 06:11:50 +08:00
|
|
|
CFLAGS += -g3 -Os -ffunction-sections -fdata-sections
|
2023-08-11 05:59:23 +08:00
|
|
|
CFLAGS += -I. -Icmsis_core/CMSIS/Core/Include
|
2023-08-22 06:11:50 +08:00
|
|
|
CFLAGS += -D__SAME54P20A__ -Icmsis_sam/include
|
|
|
|
CFLAGS += -mcpu=cortex-m4 -mthumb -mfloat-abi=softfp
|
2023-08-11 05:59:23 +08:00
|
|
|
LDFLAGS ?= -Tlink.ld -nostartfiles -nostdlib --specs nano.specs -lc -lgcc -Wl,--gc-sections -Wl,-Map=$@.map
|
|
|
|
|
|
|
|
SOURCES = main.c syscalls.c startup.c
|
|
|
|
|
2023-08-22 06:11:50 +08:00
|
|
|
# Mongoose-specific source code files and build options. See https://mongoose.ws/documentation/#build-options
|
|
|
|
SOURCES += mongoose.c
|
|
|
|
CFLAGS += -DMG_ENABLE_TCPIP=1 -DMG_ARCH=MG_ARCH_NEWLIB -DMG_ENABLE_CUSTOM_MILLIS=1 -DMG_ENABLE_LINES=1
|
2023-08-11 05:59:23 +08:00
|
|
|
CFLAGS += -DMG_ENABLE_DRIVER_SAME54=1 -DMG_ENABLE_CUSTOM_RANDOM=1 -DMG_ENABLE_PACKED_FS=1 $(CFLAGS_EXTRA)
|
|
|
|
|
2023-08-22 06:11:50 +08:00
|
|
|
# Example specific build options. See README.md
|
|
|
|
CFLAGS += -DHTTP_URL=\"http://0.0.0.0/\"
|
2023-08-11 05:59:23 +08:00
|
|
|
|
|
|
|
ifeq ($(OS),Windows_NT)
|
|
|
|
RM = cmd /C del /Q /F
|
|
|
|
else
|
|
|
|
RM = rm -rf
|
|
|
|
endif
|
|
|
|
|
|
|
|
build: firmware.bin
|
|
|
|
|
|
|
|
firmware.bin: firmware.elf
|
|
|
|
arm-none-eabi-objcopy -O binary $< $@
|
|
|
|
|
2023-08-22 06:11:50 +08:00
|
|
|
firmware.elf: cmsis_core cmsis_sam hal.h link.ld Makefile $(SOURCES)
|
|
|
|
arm-none-eabi-gcc $(SOURCES) $(CFLAGS) $(CFLAGS_EXTRA) $(LDFLAGS) -o $@
|
|
|
|
|
2023-08-11 05:59:23 +08:00
|
|
|
flash: firmware.bin
|
|
|
|
bossac -p /dev/cu.usb* -w -v -b $<
|
|
|
|
|
|
|
|
cmsis_core:
|
|
|
|
git clone --depth 1 -b 5.9.0 https://github.com/ARM-software/CMSIS_5 $@
|
|
|
|
cmsis_sam:
|
|
|
|
curl -sL https://packs.download.microchip.com/Microchip.SAME54_DFP.3.8.234.pack -o $@.zip
|
|
|
|
mkdir $@ && cd $@ && unzip ../$@.zip
|
|
|
|
|
|
|
|
# Automated test via https://vcon.io/automated-firmware-tests/. Set VCON_API_KEY and update DEVICE_URL
|
|
|
|
DEVICE_URL ?= https://dash.vcon.io/api/v3/devices/9
|
2023-08-22 06:11:50 +08:00
|
|
|
update: firmware.bin
|
2023-08-11 05:59:23 +08:00
|
|
|
curl --fail-with-body -su :$(VCON_API_KEY) $(DEVICE_URL)/ota --data-binary @$<
|
2023-08-22 06:11:50 +08:00
|
|
|
|
|
|
|
test update: CFLAGS += -DUART_DEBUG=USART1
|
|
|
|
test: update
|
2023-08-11 05:59:23 +08:00
|
|
|
curl --fail-with-body -su :$(VCON_API_KEY) $(DEVICE_URL)/tx?t=5 | tee /tmp/output.txt
|
2023-08-22 06:11:50 +08:00
|
|
|
grep 'READY, IP:' /tmp/output.txt # Check for network init
|
|
|
|
grep 'RECEIVED hello' /tmp/output.txt # Check for MQTT success
|
|
|
|
|
|
|
|
clean:
|
|
|
|
$(RM) firmware.* cmsis_core cmsis_sam *.zip
|