This repository has been archived by the owner on Jan 28, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 36
/
melis-env.sh
executable file
·510 lines (455 loc) · 11.5 KB
/
melis-env.sh
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
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
#=====================================================================================
#
# Filename: melis-env.sh
#
# Description: setup 'MELIS_BASE' environment variable.
#
# Version: Melis3.0
# Create: 2017-11-09 16:21:57
# Revision: none
# Compiler: gcc version 6.3.0 (crosstool-NG crosstool-ng-1.23.0)
#
# Author: [email protected]
# Organization: BU1-PSW
# Last Modified: 2020-05-06 12:46:08
#
#=====================================================================================
# In zsh the value of $0 depends on the FUNCTION_ARGZERO option which is
# set by default. FUNCTION_ARGZERO, when it is set, sets $0 temporarily
# to the name of the function/script when executing a shell function or
# sourcing a script. POSIX_ARGZERO option, when it is set, exposes the
# original value of $0 in spite of the current FUNCTION_ARGZERO setting.
#
# Note: The version of zsh need to be 5.0.6 or above. Any versions below
# 5.0.6 maybe encoutner errors when sourcing this script.
if [ -n "$ZSH_VERSION" ]; then
DIR="${(%):-%N}"
if [ $options[posixargzero] != "on" ]; then
setopt posixargzero
NAME=$(basename -- "$0")
setopt posixargzero
else
NAME=$(basename -- "$0")
fi
else
DIR="${BASH_SOURCE[0]}"
NAME=$(basename -- "$0")
fi
if [ "X$NAME" "==" "Xmelis-env.sh" ]; then
echo "Source this file (do NOT execute it!) to set the Melis Kernel environment."
exit
fi
# You can further customize your environment by creating a bash script called
# .melisrc in your home directory. It will be automatically
# run (if it exists) by this script.
if uname | grep -q "MINGW"; then
win_build=1
PWD_OPT="-W"
else
win_build=0
PWD_OPT=""
fi
# identify OS source tree root directory
export MELIS_BASE=$(builtin cd "$( dirname "$DIR" )" && pwd ${PWD_OPT})
unset PWD_OPT
scripts_path=${MELIS_BASE}/scripts
if [ "$win_build" -eq 1 ]; then
scripts_path=$(echo "/$scripts_path" | sed 's/\\/\//g' | sed 's/://')
fi
unset win_build
if ! echo "${PATH}" | grep -q "${scripts_path}"; then
export PATH=${scripts_path}:${PATH}
fi
unset scripts_path
# enable custom environment settings
melis_answer_file=~/melis-env_install.bash
[ -f ${melis_answer_file} ] && {
echo "Warning: Please rename ~/melis-env_install.bash to ~/.melisrc";
. ${melis_answer_file};
}
unset melis_answer_file
melis_answer_file=~/.melisrc
[ -f ${melis_answer_file} ] && . ${melis_answer_file};
unset melis_answer_file
. ${MELIS_BASE}/envsetup.sh
function ctop()
{
top_path=${MELIS_BASE}/
if [ "$top_path" ]; then
\cd $top_path
else
echo "Couldn't locate the top dir."
fi
unset top_path
}
function cdoc()
{
doc_path=${MELIS_BASE}/docs
if [ "$doc_path" ]; then
\cd $doc_path
else
echo "Couldn't locate the document dir."
fi
unset doc_path
}
function cout()
{
workspace_path=${MELIS_BASE}/out/${TARGET_BOARD}
if [ "$workspace_path" ]; then
\cd $workspace_path
else
echo "Couldn't locate the workspace."
fi
unset workspace_path
}
function ckernel()
{
workspace_path=${MELIS_BASE}/ekernel
if [ "$workspace_path" ]; then
\cd $workspace_path
else
echo "Couldn't locate the workspace."
fi
unset workspace_path
}
function cdriver()
{
workspace_path=${MELIS_BASE}/ekernel/drivers
if [ "$workspace_path" ]; then
\cd $workspace_path
else
echo "Couldn't locate the workspace."
fi
unset workspace_path
}
function cnetdrv()
{
workspace_path=${MELIS_BASE}/ekernel/drivers/drv/source/net
if [ "$workspace_path" ]; then
\cd $workspace_path
else
echo "Couldn't locate the workspace."
fi
unset workspace_path
}
function csdmmc()
{
workspace_path=${MELIS_BASE}/ekernel/drivers/hal/source/sdmmc
if [ "$workspace_path" ]; then
\cd $workspace_path
else
echo "Couldn't locate the workspace."
fi
unset workspace_path
}
function cIsdmmc()
{
workspace_path=${MELIS_BASE}/ekernel/drivers/include/hal/sdmmc
if [ "$workspace_path" ]; then
\cd $workspace_path
else
echo "Couldn't locate the workspace."
fi
unset workspace_path
}
function croot()
{
root_path=${MELIS_BASE}
if [ "$root_path" ]; then
\cd $root_path
else
echo "Couldn't locate the source."
fi
unset root_path
}
function chal()
{
hal_path=${MELIS_BASE}/../../rtos-hal
if [ "$hal_path" ]; then
\cd $hal_path
else
echo "Couldn't locate the source."
fi
unset hal_path
}
function copensbi()
{
opensbi_path=${MELIS_BASE}/../../brandy-2.0/opensbi
if [ "$opensbi_path" ]; then
\cd $opensbi_path
else
echo "Couldn't locate the source."
fi
unset opensbi_path
}
function cboot()
{
uboot_path=${MELIS_BASE}/../../brandy-2.0/u-boot-2018
if [ "$uboot_path" ]; then
\cd $uboot_path
else
echo "Couldn't locate the source."
fi
unset uboot_path
}
function cboot0()
{
boot0_path=${MELIS_BASE}/../../brandy-2.0/spl
if [ "$boot0_path" ]; then
\cd $boot0_path
else
echo "Couldn't locate the source."
fi
unset boot0_path
}
function caudiolib()
{
audio_lib_path=${MELIS_BASE}/elibrary/bin/3rd/cedar/drivers/audio
if [ "$audio_lib_path" ]; then
\cd $audio_lib_path
else
echo "Couldn't locate the audio library."
fi
unset audio_lib_path
}
function cvideolib()
{
video_lib_path=${MELIS_BASE}/elibrary/bin/3rd/cedar/drivers/video
if [ "$video_lib_path" ]; then
\cd $video_lib_path
else
echo "Couldn't locate the video library."
fi
unset video_lib_path
}
function crtt()
{
rtt_path=${MELIS_BASE}/ekernel/components/thirdparty/net/rt-thread
if [ "$rtt_path" ]; then
\cd $rtt_path
else
echo "Couldn't locate the rtt kernel."
fi
unset rtt_path
}
function cboot1()
{
boot1_path=${MELIS_BASE}/eboot/boot1
if [ "$boot1_path" ]; then
\cd $boot1_path
else
echo "Couldn't locate the boot1."
fi
unset boot1_path
}
function cinclude()
{
include_path=${MELIS_BASE}/include/melis
if [ "$include_path" ]; then
\cd $include_path
else
echo "Couldn't locate the include."
fi
unset include_path
}
function cmodule()
{
module_path=${MELIS_BASE}/emodules
if [ "$module_path" ]; then
\cd $module_path
else
echo "Couldn't locate the emodule."
fi
unset module_path
}
function crootfs()
{
rootfs_path=${UDISK_PATH}
if [ "$rootfs_path" ]; then
\cd $rootfs_path
else
echo "Couldn't locate the rootfs."
fi
unset rootfs_path
}
function cramfs()
{
ramfs_path=${MELIS_BASE}/projects/${TARGET_BOARD}/data/ramfs
if [ "$ramfs_path" ]; then
\cd $ramfs_path
else
echo "Couldn't locate the ramfs."
fi
unset ramfs_path
}
function cefex()
{
efex_path=${MELIS_BASE}/workspace/suniv/eFex
if [ "$efex_path" ]; then
\cd $efex_path
else
echo "Couldn't locate the eFex."
fi
unset efex_path
}
function cconfigs()
{
select_config_path=${MELIS_BASE}/projects/${TARGET_BOARD}/configs
if [ "$select_config_path" ]; then
\cd $select_config_path
else
echo "Couldn't locate the ${select_config_path}."
fi
unset select_config_path
}
function cbin()
{
select_config_path=${MELIS_BASE}/projects/${TARGET_BOARD}/bin
if [ "$select_config_path" ]; then
\cd $select_config_path
else
echo "Couldn't locate the ${select_config_path}."
fi
unset select_config_path
}
function codeline()
{
find ${MELIS_BASE}/ -type f -name "*.[sSch]" | xargs cat | wc -l
cloc ${MELIS_BASE}/
}
function formatall()
{
pushd ${MELIS_BASE}
ASTYLE_TOOL_PATH=${MELIS_BASE}/tools/packtool
${ASTYLE_TOOL_PATH}/astyle --options=${MELIS_BASE}/.astylerc \
"*.cpp" "*.c" "*.inc" "*.h" \
--exclude=workspace \
--exclude=utility \
--exclude=scripts \
--exclude=eboot \
--exclude=emodules \
--exclude=ekernel/subsys \
unset workpath
popd
}
function format()
{
ASTYLE_TOOL_PATH=${MELIS_BASE}/tools/packtool
${ASTYLE_TOOL_PATH}/astyle --options=${MELIS_BASE}/.astylerc "*.cpp"
${ASTYLE_TOOL_PATH}/astyle --options=${MELIS_BASE}/.astylerc "*.cc"
${ASTYLE_TOOL_PATH}/astyle --options=${MELIS_BASE}/.astylerc "*.c"
${ASTYLE_TOOL_PATH}/astyle --options=${MELIS_BASE}/.astylerc "*.inc"
${ASTYLE_TOOL_PATH}/astyle --options=${MELIS_BASE}/.astylerc "*.h"
unset workpath
}
function cgraph()
{
git log --graph --decorate --oneline --simplify-by-decoration --all
}
function flash()
{
SUNXI_FEL_PATH=${MELIS_BASE}/tools/packtool
image_file="${workpath}/melis100.fex"
if [ -f "$image_file" ]; then
echo "start buring........."
else
echo "image file not exist!"
fi
${SUNXI_FEL_PATH}/packtool/sunxi-fel spiflash-info
${SUNXI_FEL_PATH}/packtool/sunxi-fel -p spiflash-write 0 $1
unset workpath
unset image_file
}
function rdrom()
{
workpath=${MELIS_BASE}/workspace/suniv/beetles
image_file="${workpath}/flashrom.bin"
if [ -f "$image_file" ]; then
rm -fr image_file
fi
echo "start reading rom........."
${workpath}/packtool/sunxi-fel spiflash-info
${workpath}/packtool/sunxi-fel -p spiflash-read 0 0xa00000 $1
unset workpath
unset image_file
}
function comopen()
{
ports_USB=$(ls /dev/ttyUSB*)
ports_ACM=$(ls /dev/ttyACM*)
ports="$ports_USB $ports_ACM"
datename=$(date +%Y%m%d-%H%M%S)
select port in $ports;do
if [ "$port" ]; then
echo "You select the choice '$port'"
echo "love" | sudo -S minicom -c on -D "$port" -C /tmp/"$datename".log "$@"
break
else
echo "Invaild selection"
fi
done
}
function openocd_connect()
{
sudo JLinkGDBServer -device arm9
#sudo JLinkGDBServer -device cortex-a7
}
function gdb_connect()
{
arm-melis-eabi-gdb -se ./ekernel/melis.elf
#then execute following instructions in gdb environment.
#tar remote localhost:2331
}
function gerit_push()
{
git push origin melis-kbuild:refs/for/melis-kbuild
}
function scan_path ()
{
IFS=":"
for path in $PATH; do
find "$path" -maxdepth 1 -executable -name 'arm*-gcc' -printf '%f\t\n' 2>/dev/null
done
}
function find_gcc()
{
# Use only the first field from result, and convert it to a toolchain prefix
scan_path | cut -f 1 | sed -e 's/-gcc/-/'
}
function find_address()
{
arm-melis-eabi-addr2line -e ekernel/melis30.elf -a -f -p "$@"
}
function find_branch_base()
{
git merge-base $1 $2
}
function callstack()
{
python ${MELIS_BASE}/tools/python/backtrace_parser.py $1 ${MELIS_BASE}/ekernel/melis30.elf
}
function delog()
{
git log --diff-filter=D --summary
}
function cmpp()
{
local mpp_middleware_path=${MELIS_BASE}/ekernel/subsys/avframework/eyesee-mpp/middleware/sun8iw19p1
if [ -d "${mpp_middleware_path}" ]; then
cd ${mpp_middleware_path}
else
echo "Couldn't locate the mpp middleware path:[${mpp_middleware_path}]."
fi
}
function cv4l2()
{
local v4l2_path=${MELIS_BASE}/ekernel/subsys/avframework/v4l2
if [ -d "${v4l2_path}" ]; then
cd ${v4l2_path}
else
echo "Couldn't locate the mpp middleware path:[${v4l2_path}]."
fi
}
if ! echo "${PATH}" | grep -q "${MELIS_BASE}/toolchain/bin"; then
export PATH=$PATH:${MELIS_BASE}/toolchain/bin
fi