-
Notifications
You must be signed in to change notification settings - Fork 28
/
Copy pathrun_me.sh
executable file
·81 lines (64 loc) · 2.51 KB
/
run_me.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
#!/bin/sh
#
# Note: only run this script after you have already run '. export.sh' under 'esp-idf'.
#
# Dennis Deng ([email protected])
#
pth=`pwd`
esp="$IDF_PYTHON_ENV_PATH/bin/python $IDF_PATH/components/esptool_py/esptool/esptool.py"
tty="--port /dev/ttyUSB0 --baud 921600"
args="--chip esp32 --before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_freq 40m --flash_size detect"
bootloader="0x1000 $pth/build/bootloader/bootloader.bin"
app="0x10000 $pth/build/ESXP1302-Pkt-Fwd.bin"
part="0x8000 $pth/build/partition_table/partition-table.bin"
pkt_dir=main/packet_forwarder
web_file=$pkt_dir/webpage.html
web_hd_name=$pkt_dir/webpage.h
hd_name=$pkt_dir/global_json.h
conf_dir=$pkt_dir/global_conf.json
json_cn_file=$conf_dir/global_conf.cn490.json
json_eu_file=$conf_dir/global_conf.eu868.json
json_us_file=$conf_dir/global_conf.us915.json
if [ "$#" -eq 0 -o "$1" = "-h" -o "$1" = "--help" ]; then
echo "Usage: $0 [make|make_all|flash|flash_all|run]\n"
exit
fi
if [ "$1" = "make" ]; then
# prepare the webpage by dumping it to a string
scripts/dump_html.py $web_file webpage_str > $web_hd_name
# prepare the C array comes from global_conf.cn490.json
echo '// dump from global_conf.cn490.json as string array' > $hd_name
echo 'const static uint8_t global_cn_conf[] = {' >> $hd_name
scripts/json_to_hex_array.py $json_cn_file >> $hd_name
echo '};\n' >> $hd_name
# prepare the C array comes from global_conf.eu868.json
echo '// dump from global_conf.eu868.json as string array' >> $hd_name
echo 'const static uint8_t global_eu_conf[] = {' >> $hd_name
scripts/json_to_hex_array.py $json_eu_file >> $hd_name
echo '};\n' >> $hd_name
# prepare the C array comes from global_conf.us915.json
echo '// dump from global_conf.us915.json as string array' >> $hd_name
echo 'const static uint8_t global_us_conf[] = {' >> $hd_name
scripts/json_to_hex_array.py $json_us_file >> $hd_name
echo '};\n' >> $hd_name
# indent the code by prefix 4 ' '.
sed -i 's/^0x/ 0x/; s/ *$//' $hd_name
idf.py -DCONFIG_LIBLORAGW_TEST=0 app
fi
if [ "$1" = "make_all" ]; then
# prepare the C array comes from global_conf.json
echo 'const static uint8_t global_conf[] = {' > $hd_name
scripts/json_to_hex_array.py $json_file >> $hd_name
echo '};' >> $hd_name
idf.py build
fi
if [ "$1" = "flash" ]; then
$esp $tty $args $app
fi
# choose this when you flash ESP32 for the first time
if [ "$1" = "flash_all" ]; then
$esp $tty $args $bootloader $app $part
fi
if [ "$1" = "run" -o "$2" = "run" ]; then
sudo minicom -D /dev/ttyUSB0 -con
fi