1PROG_BIN := test.bin 2PROG_ELF := test.elf 3OBJ := test.o 4PREFIX := xtensa-esp32-elf- 5CC := $(PREFIX)gcc 6LD := $(PREFIX)ld 7GDB ?= $(PREFIX)gdb 8CFLAGS := -g -O0 9LDFLAGS := -L $(IDF_PATH)/components/bootloader/subproject/main/ld/esp32 \ 10 -T bootloader.ld \ 11 -u entry \ 12 -e entry \ 13 -g 14 15TRACE_FILE := trace_pro.bin 16GDB_LOG := gdb_log.txt 17GDB_LOG_REF := gdb_log_expected.txt 18 19all: $(PROG_BIN) 20 21$(PROG_ELF): $(OBJ) 22 $(LD) $(LDFLAGS) -o $@ $< 23 24$(PROG_BIN): $(PROG_ELF) 25 esptool.py --chip esp32 elf2image --output $@ --flash_freq 40m --flash_mode dio $< 26 27flash: $(PROG_BIN) 28 esptool.py --port $(ESPPORT) write_flash 0x1000 $(PROG_BIN) 29 30test: 31 rm -f $(TRACE_FILE) 32 $(GDB) -n --batch -x gdbinit | tee $(GDB_LOG) 33 diff $(GDB_LOG) $(GDB_LOG_REF) 34 @echo "Test pass" 35 36clean: 37 rm -f $(PROG_ELF) $(PROG_BIN) $(OBJ) $(TRACE_FILE) $(GDB_LOG) 38 39.PHONY: all clean flash test 40