-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
52 lines (40 loc) · 1.59 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
XTENSA ?=
# Mac and linux
SDK_BASE ?= /tools/esp8266/sdk/ESP8266_NONOS_SDK
ESPTOOL ?= /tools/esp8266/esptool/esptool.py
# Windows with unofficial dev kit (default install location is C:/Espressif)
# SDK_BASE ?= C:/Espressif/ESP8266_SDK
# ESPTOOL ?= C:/Espressif/utils/ESP8266/esptool.py
SDK_LIBS := -lc -lgcc -lhal -lphy -lpp -lnet80211 -lwpa -lmain -llwip -lcrypto -ljson
CC := $(XTENSA)xtensa-lx106-elf-gcc
LD := $(XTENSA)xtensa-lx106-elf-gcc
AR := $(XTENSA)xtensa-lx106-elf-ar
LDFLAGS = -nostdlib -Wl,--no-check-sections -u call_user_start -Wl,-static
CFLAGS = -g -Wpointer-arith -Wundef -Wl,-EL -fno-inline-functions -nostdlib\
-mlongcalls -mtext-section-literals -ffunction-sections -fdata-sections\
-fno-builtin-printf -DICACHE_FLASH\
-I.
LD_SCRIPT = -T$(SDK_BASE)/ld/eagle.app.v6.ld
all: main.bin
main.bin: main.out
$(ESPTOOL) elf2image $(ESPTOOL_FLASHDEF) main.out -o main
main.out: main.a
@echo "LD $@"
$(LD) -L$(SDK_BASE)/lib $(LD_SCRIPT) $(LDFLAGS) -L$(SDK_BASE)/lib -Wl,--start-group $(SDK_LIBS) main.a -Wl,--end-group -o main.out
main.a: main.o
@echo "AR main.o"
$(AR) cru main.a main.o rf_init.o
main.o:
@echo "CC main.c & rf_init.c"
$(CC) -I$(SDK_BASE)/include $(CFLAGS) -c main.c -o main.o
$(CC) -I$(SDK_BASE)/include $(CFLAGS) -c rf_init.c -o rf_init.o
clean:
rm -rf *.o *.bin *.a *.out
flash:
$(ESPTOOL) --port /dev/ttyUSB0 \
--baud 921600 \
write_flash --flash_freq 40m --flash_mode dio --flash_size 32m \
0x00000 main0x00000.bin \
0x10000 main0x10000.bin \
0x3fc000 $(SDK_BASE)/bin/esp_init_data_default.bin
.PHONY: all clean