forked from magore/esp8266_ili9341
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathget_esp-open-sdk
executable file
·245 lines (200 loc) · 4.18 KB
/
get_esp-open-sdk
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
#!/bin/bash
#
# install an build the latest ESP8266 OPEN SDK
# ASSUME Ubuntu 14.04LTS
# Mike Gore May 2015
sep()
{
echo "====================================================="
echo
echo
echo
}
update_packages()
{
sudo apt-get install git make automake autoconf build-essential \
gperf bison flex \
texinfo libtool libncurses5-dev \
wget gawk python-serial libexpat1-dev \
libc6-dev \
gcc g++ \
unrar \
python sed
sep
}
# What: Echo ERROR: and arguments
# Arguments: $*
# Returns: Exit 1
# Example:
# fatal we failed
fatal()
{
echo "$*"; exit 1;
}
# What: Display the absolute path of a file - uses echo
# Arguments: path
# Notes: if argument is -bash then return absolute of current directory
# Example:
# absolute ~/file.txt
absolute()
{
if [ -z "$1" ]
then
fatal " $FUNCNAME: missing argument: [$0]"
fi
# FIXME if the argument is -bash, then is this the correct course of action?
if [ "$1" = "-bash" ]
then
echo -n "$(readlink -f \"`pwd`\")"
return
fi
# Our full path name
echo -n "$(readlink -f "$1")"
}
# What: Change directory and verify we actually end up there
# Argument: directory
# Notes: Useful if verifying permission of traget directory
# Example:
# check_cd /tmp/projects
check_cd()
{
declare DIR="$1"
echo "check_cd $DIR"
declare P="`absolute \"$DIR\"`"
if [ -z "$P" ]
then
fatal "$FUNCNAME: No directory"
fi
cd "$P"
declare PWD=$(pwd)
if [ "$PWD" != "$P" ]
then
fatal "Can NOT change directory to [$P]"
fi
}
check_dir()
{
declare i
for i in $*
do
if [ ! -d "$i" ]
then
fatal "Directory:[$i] missing"
fi
done
}
check_files()
{
declare i
for i in $*
do
if [ ! -f "$i" ]
then
fatal "Directory:[$i] missing"
fi
done
}
set_path()
{
# See: https://nurdspace.nl/ESP8266/First_setup
# https://github.com/esp8266/esp8266-wiki/wiki/Toolchain
export ROOT_DIR="/opt/Espressif"
export SDK_HOME="$ROOT_DIR/esp-open-sdk"
export SDK_BIN="$SDK_HOME/xtensa-lx106-elf/bin"
export PATH="$SDK_BIN:$PATH"
echo "ROOT_DIR[$ROOT_DIR]"
echo "SDK_HOME[$SDK_HOME]"
echo "SDK_BIN[$SDK_BIN]"
sep
}
make_path()
{
set_path
cat <<EOF >"$SDK_HOME/setpath"
#!/bin/bash
#
export ROOT_DIR="$ROOT_DIR"
export SDK_HOME="$SDK_HOME/sdk"
export SDK_BIN="$SDK_BIN"
export PATH="\$SDK_BIN:\$PATH"
EOF
chmod 755 "$SDK_HOME/setpath"
sep
}
#Save a list of libraries we can use in the sdk home directory
list_libs()
{
LIST="sdk/lib xtensa-lx106-elf/xtensa-lx106-elf/sysroot/usr/lib xtensa-lx106-elf/xtensa-lx106-elf/sysroot/lib xtensa-lx106-elf/lib lx106-hal/src"
for i in $LIST
do
find "$SDK_HOME"/$i -type f | grep "\.a$"
done
}
install_open_sdk()
{
echo Installing Open SDK
check_cd $ROOT_DIR
echo Target is $SDK_HOME
declare DIR=$(basename $SDK_HOME)
echo "DIR:[$DIR]"
get_git https://github.com/pfalcon "$DIR"
check_cd $SDK_HOME
make STANDALONE=y
check_dir $SDK_HOME/esptool
sep
}
add_tools()
{
check_dir $SDK_HOME/sdk/bin
cat $SDK_HOME/sdk/bin/blank.bin \
$SDK_HOME/sdk/bin/blank.bin \
$SDK_HOME/sdk/bin/blank.bin >> $SDK_HOME/sdk/bin/clear_eep.bin
get_git https://github.com/themadinventor esptool
cp -p esptool/*.py $SDK_HOME/sdk/tools
chmod 755 $SDK_HOME/sdk/tools/*
}
# ==============================================================
build_examples()
{
echo Building Exampless
check_cd $SDK_HOME
get_git https://github.com/esp8266 source-code-examples
if [ ! -d source-code-examples/blinky ]
then
echo "source-code-examples missing"
exit 1
fi
check_cd source-code-examples/blinky
sed -i -e "s;^XTENSA_TOOLS_ROOT.*$;XTENSA_TOOLS_ROOT=$SDK_BIN;" Makefile
sed -i -e "s;^SDK_BASE.*$;SDK_BASE=$SDK_HOME/sdk;" Makefile
sed -i -e "s;^EXTRA_INCDIR.*$;EXTRA_INCDIR= $SDK_HOME/sdk/include;" Makefile
make clean
make
sep
}
build_nodemcu()
{
echo "Building Nodemcu Firemware"
check_cd "$ROOT_DIR"
get_git https://github.com/nodemcu nodemcu-firmware
check_cd "$ROOT_DIR/nodemcu-firmware"
make
sep
}
flash_nodemcu()
{
echo "Flashinf Nodemcu Firemware"
check_cd "$ROOT_DIR/nodemcu-firmware"
make flash
sep
}
# ===================================================================
set_path
update_packages
install_open_sdk
list_libs >"$SDK_HOME"/libs.txt
add_tools
make_path
#build_examples
#build_nodemcu
#flash_nodemcu