-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·120 lines (92 loc) · 2.75 KB
/
Copy pathbuild.sh
File metadata and controls
executable file
·120 lines (92 loc) · 2.75 KB
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
#!/usr/bin/env bash
SDK=$SIMPLICITY_SDK
TARGET=EFR32MG21A020F768IM32
OBJCOPY=arm-none-eabi-objcopy
# Shenzhen CoolKit Technology Co., Ltd
ZIGBEE_MANUF_ID=0x1286
set -e
trust_sdk()
{
trust_file=~/SimplicityStudio/uc_workspace/.metadata/.trust/primary_trusted.trust
grep -qF "$SDK" "$trust_file" 2>/dev/null || slc-cli signature trust --sdk "$SDK"
}
gen_build_config()
{
slcp="$1"
prj=$(basename -s .slcp "$slcp")
target="$2"
out_type="${3:-cmake}"
[ -d "build/${prj}" ] && return 0
CLUSTER_XML=$PWD/src/zbminir2/mfg-specific-cluster.xml \
slc-cli generate \
--sdk "$SDK" \
--export-destination build/$prj \
--with "$target" \
--output-type "$out_type" \
--project-file "$slcp"
}
build()
{
prj="$1"
build_dir="build/${prj}"
cmake_dir="build/${prj}/${prj}_cmake/"
#[ -f "build/${prj}.bin" ] && return 0
cmake --preset project -S "$cmake_dir" -B "$build_dir" -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
ninja -C "$build_dir"
cp -a "${build_dir}/default_config/${prj}."{bin,s37} build/
}
build_gw()
{
prj="$1"
prj_lower="$(echo -n "$1" | tr A-Z a-z)"
build_dir="build/${prj}"
#[ -f "build/${prj_lower}.elf" ] && return 0
make -C "${build_dir}" -f ${prj}.Makefile -j16
cp -af "${build_dir}/build/debug/${prj}" "build/${prj_lower}.elf"
}
flash()
{
bin="$1"
offset="$2"
openocd -f interface/jlink.cfg \
-c 'transport select swd' \
-f openocd/efm32s2.cfg \
-c "program ${bin} ${offset}; reset; exit"
}
create_ota()
{
bl="$1"
app_name=$(basename -s .s37 "$2")
ver="$3"
basename="${app_name}_${ZIGBEE_MANUF_ID}_${ver}"
commander-cli convert "$bl" build/${app_name}.s37 --outfile "build/${app_name}_full.s37"
${OBJCOPY} -I srec -O binary --gap=0xff "build/${app_name}_full.s37" "build/${app_name}_full.bin"
commander-cli gbl create \
"build/${app_name}.gbl" \
--app "build/${app_name}_full.s37" \
--compress lzma
commander-cli ota create \
--upgrade-image "build/${app_name}.gbl" \
--firmware-version "$ver" \
--manufacturer-id "${ZIGBEE_MANUF_ID}" \
--image-type 0 \
--string "${basename}" \
--outfile "build/${basename}.ota"
}
trust_sdk
# gateway
gen_build_config "${SDK}/protocol/zigbee/app/projects/z3/zigbee_z3_gateway/zigbee_z3_gateway.slcp" linux_arch_32 makefile
build_gw zigbee_z3_gateway
# bootloader
gen_build_config src/bootloader/bootloader-storage-internal-single-768k.slcp $TARGET
build bootloader-storage-internal-single-768k
# main firmware
gen_build_config src/zbminir2/zbminir2.slcp $TARGET
# for development - avoids having to call slc generate after making changes
cp src/zbminir2/*.c build/zbminir2/
build zbminir2
create_ota build/bootloader-storage-internal-single-768k.s37 build/zbminir2.s37 2
if [ "$1" = "flash" ]; then
flash ./build/bootloader-storage-internal-single-768k.bin 0
flash ./build/zbminir2.bin 0x4000
fi