forked from wenyi0421/turing-pi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mkfw.sh
79 lines (64 loc) · 1.84 KB
/
mkfw.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
#!/bin/sh
set -e
INIT_FLAG=./buildroot/output/.mkfw.init
CLEAN="${CLEAN:-no}"
DATE="$(date +%F)"
VERSION="${1:-}"
if [ -z "${VERSION}" ]; then
echo "I: no version given as first parameter, auto generating version."
# compose build version
# YYYY-MM-DD-GITREV-DIRTYFLAG
# GITREV is either a short commit hash or tag if tagged
if git status -s | grep ^ > /dev/null; then
# dirty check
VERSION="$(date +%F)-$(git rev-parse --abbrev-ref HEAD 2> /dev/null)-$(git rev-parse --short HEAD 2> /dev/null)+dirty"
INC=0
while [ -f ./build/${DATE}/turingpi-${VERSION}~$INC.img ]; do
INC=$(( INC + 1 ))
done
VERSION="$VERSION~$INC"
else
VERSION="$(date +%F)-$(git rev-parse --abbrev-ref HEAD 2> /dev/null)-$(git rev-parse --short HEAD 2> /dev/null)"
fi
fi
echo "I: Using version $VERSION for this build."
cat > app/bmc/version.h <<EOF
/* This file is auto generated. do not modify */
#define BMCVERSION "${VERSION}"
#define BUILDTIME "${DATE}"
EOF
if [ "${CLEAN}" = yes ]; then
( cd buildroot
make distclean
)
fi
if [ ! -f "$INIT_FLAG" ]; then
. ./init.sh
: > "$INIT_FLAG"
fi
if [ ! -d "build/${DATE}" ];then
mkdir -p "build/${DATE}"
fi
echo "----- make fw -----"
echo "Version: ${VERSION}"
echo "Date: ${DATE}"
echo "build fw"
#- rebuild all stuff for image
( set -x
cd buildroot
make linux-rebuild
make swupdate-rebuild
make bmc-rebuild
make V=1
)
cp -rf buildroot/output/images/buildroot_linux_nand_uart3.img ./build/${DATE}/turingpi-${VERSION}.img
( cd buildroot/output/images/
./genSWU.sh
)
mv -f ./buildroot/output/images/turingpi_.swu ./build/${DATE}/turingpi-${VERSION}.swu
echo "build turing pi firmware CLI"
if [ ! -f "build/tpi/linux/tpi" ];then
mkdir -p build/tpi/linux
gcc app/tpi/tpi.c -o build/tpi/linux/tpi
fi
find "build/$DATE" -type f -exec ls -lt {} + | grep -E --color '[^ ]+(.swu|.img)$'