Skip to content

Commit 65d34be

Browse files
author
Espressif Systems
committed
add smart_config example
1 parent 43585fa commit 65d34be

File tree

7 files changed

+522
-0
lines changed

7 files changed

+522
-0
lines changed

examples/smart_config/Makefile

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
#############################################################
2+
# Required variables for each makefile
3+
# Discard this section from all parent makefiles
4+
# Expected variables (with automatic defaults):
5+
# CSRCS (all "C" files in the dir)
6+
# SUBDIRS (all subdirs with a Makefile)
7+
# GEN_LIBS - list of libs to be generated ()
8+
# GEN_IMAGES - list of object file images to be generated ()
9+
# GEN_BINS - list of binaries to be generated ()
10+
# COMPONENTS_xxx - a list of libs/objs in the form
11+
# subdir/lib to be extracted and rolled up into
12+
# a generated lib/image xxx.a ()
13+
#
14+
TARGET = eagle
15+
#FLAVOR = release
16+
FLAVOR = debug
17+
18+
#EXTRA_CCFLAGS += -u
19+
20+
ifndef PDIR # {
21+
GEN_IMAGES= eagle.app.v6.out
22+
GEN_BINS= eagle.app.v6.bin
23+
SPECIAL_MKTARGETS=$(APP_MKTARGETS)
24+
SUBDIRS= \
25+
user
26+
27+
endif # } PDIR
28+
29+
APPDIR = .
30+
LDDIR = ../ld
31+
32+
CCFLAGS += -Os
33+
34+
TARGET_LDFLAGS = \
35+
-nostdlib \
36+
-Wl,-EL \
37+
--longcalls \
38+
--text-section-literals
39+
40+
ifeq ($(FLAVOR),debug)
41+
TARGET_LDFLAGS += -g -O2
42+
endif
43+
44+
ifeq ($(FLAVOR),release)
45+
TARGET_LDFLAGS += -g -O0
46+
endif
47+
48+
COMPONENTS_eagle.app.v6 = \
49+
user/libuser.a
50+
51+
LINKFLAGS_eagle.app.v6 = \
52+
-L../lib \
53+
-nostdlib \
54+
-T$(LD_FILE) \
55+
-Wl,--no-check-sections \
56+
-u call_user_start \
57+
-Wl,-static \
58+
-Wl,--start-group \
59+
-lgcc \
60+
-lhal \
61+
-lphy \
62+
-lpp \
63+
-lnet80211 \
64+
-lwpa \
65+
-lmain \
66+
-lfreertos \
67+
-llwip \
68+
-ludhcp \
69+
-lsmartconfig \
70+
$(DEP_LIBS_eagle.app.v6) \
71+
-Wl,--end-group
72+
73+
DEPENDS_eagle.app.v6 = \
74+
$(LD_FILE) \
75+
$(LDDIR)/eagle.rom.addr.v6.ld
76+
77+
#############################################################
78+
# Configuration i.e. compile options etc.
79+
# Target specific stuff (defines etc.) goes in here!
80+
# Generally values applying to a tree are captured in the
81+
# makefile at its root level - these are then overridden
82+
# for a subtree within the makefile rooted therein
83+
#
84+
85+
#UNIVERSAL_TARGET_DEFINES = \
86+
87+
# Other potential configuration flags include:
88+
# -DTXRX_TXBUF_DEBUG
89+
# -DTXRX_RXBUF_DEBUG
90+
# -DWLAN_CONFIG_CCX
91+
CONFIGURATION_DEFINES = -DICACHE_FLASH
92+
93+
DEFINES += \
94+
$(UNIVERSAL_TARGET_DEFINES) \
95+
$(CONFIGURATION_DEFINES)
96+
97+
DDEFINES += \
98+
$(UNIVERSAL_TARGET_DEFINES) \
99+
$(CONFIGURATION_DEFINES)
100+
101+
102+
#############################################################
103+
# Recursion Magic - Don't touch this!!
104+
#
105+
# Each subtree potentially has an include directory
106+
# corresponding to the common APIs applicable to modules
107+
# rooted at that subtree. Accordingly, the INCLUDE PATH
108+
# of a module can only contain the include directories up
109+
# its parent path, and not its siblings
110+
#
111+
# Required for each makefile to inherit from the parent
112+
#
113+
114+
INCLUDES := $(INCLUDES) -I $(PDIR)include
115+
PDIR := ../$(PDIR)
116+
sinclude $(PDIR)Makefile
117+
118+
.PHONY: FORCE
119+
FORCE:
120+

examples/smart_config/gen_misc.bat

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
@echo off
2+
3+
echo Please follow below steps(1-5) to generate specific bin(s):
4+
echo STEP 1: choose boot version(0=boot_v1.1, 1=boot_v1.2+, 2=none)
5+
set input=default
6+
set /p input=enter(0/1/2, default 2):
7+
8+
if %input% equ 0 (
9+
set boot=old
10+
) else (
11+
if %input% equ 1 (
12+
set boot=new
13+
) else (
14+
set boot=none
15+
)
16+
)
17+
18+
echo boot mode: %boot%
19+
echo.
20+
21+
echo STEP 2: choose bin generate(0=eagle.flash.bin+eagle.irom0text.bin, 1=user1.bin, 2=user2.bin)
22+
set input=default
23+
set /p input=enter (0/1/2, default 0):
24+
25+
if %input% equ 1 (
26+
if %boot% equ none (
27+
set app=0
28+
echo choose no boot before
29+
echo generate bin: eagle.flash.bin+eagle.irom0text.bin
30+
) else (
31+
set app=1
32+
echo generate bin: user1.bin
33+
)
34+
) else (
35+
if %input% equ 2 (
36+
if %boot% equ none (
37+
set app=0
38+
echo choose no boot before
39+
echo generate bin: eagle.flash.bin+eagle.irom0text.bin
40+
) else (
41+
set app=2
42+
echo generate bin: user2.bin
43+
)
44+
) else (
45+
if %boot% neq none (
46+
set boot=none
47+
echo ignore boot
48+
)
49+
set app=0
50+
echo generate bin: eagle.flash.bin+eagle.irom0text.bin
51+
))
52+
53+
echo.
54+
55+
echo STEP 3: choose spi speed(0=20MHz, 1=26.7MHz, 2=40MHz, 3=80MHz)
56+
set input=default
57+
set /p input=enter (0/1/2/3, default 2):
58+
59+
if %input% equ 0 (
60+
set spi_speed=20
61+
) else (
62+
if %input% equ 1 (
63+
set spi_speed=26.7
64+
) else (
65+
if %input% equ 3 (
66+
set spi_speed=80
67+
) else (
68+
set spi_speed=40
69+
)))
70+
71+
echo spi speed: %spi_speed% MHz
72+
echo.
73+
74+
echo STEP 4: choose spi mode(0=QIO, 1=QOUT, 2=DIO, 3=DOUT)
75+
set input=default
76+
set /p input=enter (0/1/2/3, default 0):
77+
78+
if %input% equ 1 (
79+
set spi_mode=QOUT
80+
) else (
81+
if %input% equ 2 (
82+
set spi_mode=DIO
83+
) else (
84+
if %input% equ 3 (
85+
set spi_mode=DOUT
86+
) else (
87+
set spi_mode=QIO
88+
)))
89+
90+
echo spi mode: %spi_mode%
91+
echo.
92+
93+
echo STEP 5: choose spi size(0=256KB, 1=512KB, 2=1024KB, 3=2048KB, 4=4096KB)
94+
set input=default
95+
set /p input=enter (0/1/2/3/4, default 1):
96+
97+
if %input% equ 0 (
98+
set spi_size=256
99+
) else (
100+
if %input% equ 2 (
101+
set spi_size=1024
102+
) else (
103+
if %input% equ 3 (
104+
set spi_size=2048
105+
) else (
106+
if %input% equ 4 (
107+
set spi_size=4096
108+
) else (
109+
set spi_size=512
110+
))))
111+
112+
echo spi size: %spi_size% KB
113+
114+
touch user/user_main.c
115+
116+
echo.
117+
echo start...
118+
echo.
119+
120+
make BOOT=%boot% APP=%app% SPI_SPEED=%spi_speed% SPI_MODE=%spi_mode% SPI_SIZE=%spi_size%
121+

examples/smart_config/gen_misc.sh

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
#!/bin/bash
2+
3+
echo "Please follow below steps(1-5) to generate specific bin(s):"
4+
echo "STEP 1: choose boot version(0=boot_v1.1, 1=boot_v1.2+, 2=none)"
5+
echo "enter(0/1/2, default 2):"
6+
read input
7+
8+
if [ -z "$input" ]; then
9+
boot=none
10+
elif [ $input == 0 ]; then
11+
boot=old
12+
elif [ $input == 1 ]; then
13+
boot=new
14+
else
15+
boot=none
16+
fi
17+
18+
echo "boot mode: $boot"
19+
echo ""
20+
21+
echo "STEP 2: choose bin generate(0=eagle.flash.bin+eagle.irom0text.bin, 1=user1.bin, 2=user2.bin)"
22+
echo "enter (0/1/2, default 0):"
23+
read input
24+
25+
if [ -z "$input" ]; then
26+
if [ $boot != none ]; then
27+
boot=none
28+
echo "ignore boot"
29+
fi
30+
app=0
31+
echo "generate bin: eagle.flash.bin+eagle.irom0text.bin"
32+
elif [ $input == 1 ]; then
33+
if [ $boot == none ]; then
34+
app=0
35+
echo "choose no boot before"
36+
echo "generate bin: eagle.flash.bin+eagle.irom0text.bin"
37+
else
38+
app=1
39+
echo "generate bin: user1.bin"
40+
fi
41+
elif [ $input == 2 ]; then
42+
if [ $boot == none ]; then
43+
app=0
44+
echo "choose no boot before"
45+
echo "generate bin: eagle.flash.bin+eagle.irom0text.bin"
46+
else
47+
app=2
48+
echo "generate bin: user2.bin"
49+
fi
50+
else
51+
if [ $boot != none ]; then
52+
boot=none
53+
echo "ignore boot"
54+
fi
55+
app=0
56+
echo "generate bin: eagle.flash.bin+eagle.irom0text.bin"
57+
fi
58+
59+
echo ""
60+
61+
echo "STEP 3: choose spi speed(0=20MHz, 1=26.7MHz, 2=40MHz, 3=80MHz)"
62+
echo "enter (0/1/2/3, default 2):"
63+
read input
64+
65+
if [ -z "$input" ]; then
66+
spi_speed=40
67+
elif [ $input == 0 ]; then
68+
spi_speed=20
69+
elif [ $input == 1 ]; then
70+
spi_speed=26.7
71+
elif [ $input == 3 ]; then
72+
spi_speed=80
73+
else
74+
spi_speed=40
75+
fi
76+
77+
echo "spi speed: $spi_speed MHz"
78+
echo ""
79+
80+
echo "STEP 4: choose spi mode(0=QIO, 1=QOUT, 2=DIO, 3=DOUT)"
81+
echo "enter (0/1/2/3, default 0):"
82+
read input
83+
84+
if [ -z "$input" ]; then
85+
spi_mode=QIO
86+
elif [ $input == 1 ]; then
87+
spi_mode=QOUT
88+
elif [ $input == 2 ]; then
89+
spi_mode=DIO
90+
elif [ $input == 3 ]; then
91+
spi_mode=DOUT
92+
else
93+
spi_mode=QIO
94+
fi
95+
96+
echo "spi mode: $spi_mode"
97+
echo ""
98+
99+
echo "STEP 5: choose spi size(0=256KB, 1=512KB, 2=1024KB, 3=2048KB, 4=4096KB)"
100+
echo "enter (0/1/2/3/4, default 1):"
101+
read input
102+
103+
if [ -z "$input" ]; then
104+
spi_size=512
105+
elif [ $input == 0 ]; then
106+
spi_size=256
107+
elif [ $input == 2 ]; then
108+
spi_size=1024
109+
elif [ $input == 3 ]; then
110+
spi_size=2048
111+
elif [ $input == 4 ]; then
112+
spi_size=4096
113+
else
114+
spi_size=512
115+
fi
116+
117+
echo "spi size: $spi_size KB"
118+
echo ""
119+
120+
touch user/user_main.c
121+
122+
echo ""
123+
echo "start..."
124+
echo ""
125+
126+
make COMPILE=gcc BOOT=$boot APP=$app SPI_SPEED=$spi_speed SPI_MODE=$spi_mode SPI_SIZE=$spi_size
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#ifndef __USER_CONFIG_H__
2+
#define __USER_CONFIG_H__
3+
4+
#endif
5+

0 commit comments

Comments
 (0)