2023-01-22 19:31:06 +08:00
|
|
|
CFLAGS ?= -W -Wall -Wextra -Werror -Wundef -Wshadow -Wdouble-promotion \
|
|
|
|
-Wformat-truncation -fno-common -Wconversion -Wno-sign-conversion \
|
|
|
|
-g3 -Os -ffunction-sections -fdata-sections \
|
|
|
|
-I. -Ih7/Include -Icmsis/CMSIS/Core/Include \
|
2023-02-04 03:32:38 +08:00
|
|
|
-mcpu=cortex-m7 -mthumb -mfloat-abi=hard -mfpu=fpv5-sp-d16 \
|
2023-01-22 19:31:06 +08:00
|
|
|
$(EXTRA_CFLAGS)
|
|
|
|
LDFLAGS ?= -Tlink.ld -nostartfiles -nostdlib --specs nano.specs -lc -lgcc -Wl,--gc-sections -Wl,-Map=$@.map
|
|
|
|
SOURCES = startup.c main.c syscalls.c
|
|
|
|
|
|
|
|
# Add Mongoose-specific flags and source files
|
2023-02-08 05:16:42 +08:00
|
|
|
CFLAGS += -I../../.. -DMG_ARCH=MG_ARCH_NEWLIB -DMG_ENABLE_CUSTOM_MILLIS=1 -DMG_ENABLE_TCPIP=1 -DMG_ENABLE_DRIVER_STM32H=1 -DMG_ENABLE_PACKED_FS=1
|
2023-02-04 03:32:38 +08:00
|
|
|
SOURCES += ../../../mongoose.c ../../device-dashboard/net.c ../../device-dashboard/packed_fs.c
|
2023-01-22 19:31:06 +08:00
|
|
|
|
|
|
|
all build example: firmware.bin
|
|
|
|
|
|
|
|
firmware.bin: firmware.elf
|
|
|
|
arm-none-eabi-objcopy -O binary $< $@
|
|
|
|
|
|
|
|
firmware.elf: $(SOURCES) mcu.h
|
|
|
|
arm-none-eabi-gcc $(SOURCES) $(CFLAGS) $(LDFLAGS) -o $@
|
|
|
|
|
|
|
|
# Note: on "unknown chip id" flash error, wire BOOT0 to VDD and st-flash erase
|
|
|
|
flash: firmware.bin
|
|
|
|
st-flash --freq 600 --reset write $< 0x8000000
|
|
|
|
|
|
|
|
# Requires env variable VCON_API_KEY set
|
|
|
|
DEVICE_URL ?= https://dash.vcon.io/api/v3/devices/6
|
2023-02-04 03:32:38 +08:00
|
|
|
test: EXTRA_CFLAGS += -DUART_DEBUG=UART1
|
|
|
|
test: update
|
2023-01-22 19:31:06 +08:00
|
|
|
curl --fail-with-body -su :$(VCON_API_KEY) $(DEVICE_URL)/tx?t=5 | tee /tmp/output.txt
|
2023-02-04 03:32:38 +08:00
|
|
|
grep 'READY, IP:' /tmp/output.txt
|
|
|
|
grep 'MQTT connected' /tmp/output.txt
|
2023-01-22 19:31:06 +08:00
|
|
|
|
|
|
|
update: firmware.bin
|
|
|
|
curl --fail-with-body -su :$(VCON_API_KEY) $(DEVICE_URL)/ota --data-binary @$<
|
|
|
|
|
|
|
|
clean:
|
|
|
|
@rm -rf firmware.* *.su
|