forked from cnlohr/nosdk8266
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
96 lines (78 loc) · 2.98 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
TARGET_OUT = image.elf
all : $(TARGET_OUT)
#First, select whether you are targeting PICO or REGULAR.
#
#PICO Operates at 52 MHz, and makes no calls to ROM.
# It's ideal for the HackADay 1kB Challenge.
# You can also run PICO at 104 MHz but it takes a couple extra bytes to set the overclocking bits.
#
#REGULAR Operates at a variety of frequencies and allows for a number of
# ROM functions.
#SUBMODULE if we are including this in another project.
SUBMODULE?=NO
BUILD?=PICO
#BUILD:=REGULAR
MAIN_MHZ?=320 #Pick from *52, *80, 104 or *115, 160, *173, *189#, 231, 346, 378# * = peripheral clock at processor clock. # = Mine won't boot + on ESP8285, Clock Lower and unreliable. Warning. Peripheral clocks of >115 will NOT boot without a full power-down and up. (Don't know why)
USE_I2S?=YES
#USE_PRINT:=YES
ESP_OPEN_SDK:=~/esp8266/esp-open-sdk
FW_1 = image.elf-0x10000.bin
FW_2 = image.elf-0x00000.bin
GCC_FOLDER:=$(ESP_OPEN_SDK)/xtensa-lx106-elf
ESPTOOL:=$(ESP_OPEN_SDK)/esptool/esptool.py
ESPTOOLOPTS?=-b 115200
PREFIX:=$(GCC_FOLDER)/bin/xtensa-lx106-elf-
SIZE:=$(PREFIX)size
OBJDUMP:=$(PREFIX)objdump
OBJCOPY:=$(PREFIX)objcopy
GCC:=$(PREFIX)gcc
ADDITIONAL_DEPS?=
#-mno-serialize-volatile will prevent extra memw things from being generated.
ifneq (YES, $(SUBMODULE))
SRCPREFIX:=
ifeq (REGULAR, $(BUILD))
#Non-PIOC66 mode (Regular, 80 MHz, etc.)
CFLAGS:=$(CFLAGS) -flto
SRCS:=$(SRCS) main.c
else ifeq (PICO, $(BUILD))
#PICO66 Mode... If you want an absolutely strip down environment (For the HaD 1kB challenge)
CFLAGS:=$(CFLAGS) -DPICO66 -flto
#TODO: Why can't we use -fwhole-program instead of -flto?
SRCS:=$(SRCS) pico.c
else
ERR:=$(error Need either REGULAR or PICO to be defined to BUILD. Currently $(BUILD))
endif
else
SRCPREFIX:=nosdk8266/
endif
LDFLAGS:=-T $(SRCPREFIX)ld/linkerscript.ld -T $(SRCPREFIX)ld/addresses.ld
FOLDERPREFIX:=$(GCC_FOLDER)/bin
PORT:=/dev/ttyUSB0
ifeq (YES, $(USE_PRINT))
CFLAGS:=$(CFLAGS)
else
CFLAGS:=$(CFLAGS) -DPICONOPRINT
endif
ifeq (YES, $(USE_I2S))
SRCS:=$(SRCS) $(SRCPREFIX)src/nosdki2s.c
CFLAGS:=$(CFLAGS) -DUSE_I2S
else ifeq (SUBMODULE, $(USE_I2S))
CFLAGS:=$(CFLAGS) -DUSE_I2S
endif
#Adding the -g flag makes our assembly easier to read and does not increase size of final executable.
CFLAGS:=$(CFLAGS) -Os -I$(SRCPREFIX)include -nostdlib -DMAIN_MHZ=$(MAIN_MHZ) -mno-serialize-volatile -mlongcalls -g
SRCS:=$(SRCS) $(SRCPREFIX)src/startup.S $(SRCPREFIX)src/nosdk8266.c
$(TARGET_OUT) : $(ADDITIONAL_DEPS) $(SRCS)
@echo $(shell echo $(shell cat count.txt)+1) | bc > count.txt
$(GCC) $(CFLAGS) $(SRCS) $(LDFLAGS) -o $@
#objdump -t $(TARGET_OUT) > image.map
nm -S -n $(TARGET_OUT) > image.map
$(SIZE) $@
$(PREFIX)objdump -S $@ > image.lst
PATH=$(FOLDERPREFIX):$$PATH;$(ESPTOOL) elf2image $(TARGET_OUT)
burn : $(FW_FILE_1) $(FW_FILE_2) $(TARGET_OUT)
($(ESPTOOL) --port $(PORT) write_flash 0x00000 image.elf-0x00000.bin -ff 80m -fm dout)||(true)
sleep .1
($(ESPTOOL) --port $(PORT) run)||(true)
clean :
rm -rf $(TARGET_OUT) image.map image.lst $(FW_1) $(FW_2)