-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbuild.sh
executable file
·52 lines (37 loc) · 1.28 KB
/
build.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
#!/bin/bash
# Ensure an argument is provided
if [ -z "$1" ]; then
echo "Usage: $0 <working_folder> all|release"
exit 1
fi
if [ -z "$2" ]; then
echo "Usage: $0 <working_folder> all|release"
exit 1
fi
cp -f version.txt ./configurator/version.txt
working_folder=$1
build_type=$2
ST_WORKING_FOLDER=$working_folder/configurator stcmd make $build_type
ST_WORKING_FOLDER=$working_folder stcmd make $build_type
filename_tos="./dist/SIDECART.TOS"
# Copy the SIDECART.TOS file for testing purposes
ST_WORKING_FOLDER=$working_folder stcmd cp ./configurator/dist/SIDECART.TOS $filename_tos
filename="./dist/FIRMWARE.IMG"
# Copy the BOOT.BIN file to a ROM size file for testing
ST_WORKING_FOLDER=$working_folder stcmd cp ./dist/BOOT.BIN $filename
# Determine the file size accordingly
filesize=$(ST_WORKING_FOLDER=$working_folder stcmd stat -c %s "$filename")
# Size for 64Kbytes in bytes
targetsize=$((64 * 1024))
# Check if the file is larger than 64Kbytes
if [ "$filesize" -gt "$targetsize" ]; then
echo "The file is already larger than 64Kbytes."
exit 2
fi
# Resize the file to 64Kbytes
ST_WORKING_FOLDER=$working_folder stcmd truncate -s $targetsize $filename
if [ $? -ne 0 ]; then
echo "Failed to resize the file."
exit 3
fi
echo "File has been resized to 64Kbytes."