aboutsummaryrefslogtreecommitdiff
path: root/lt-qcom-bootloader/rb5/builders.sh
blob: 89b249c5ed023b2d72148112bb5d524bdd302042 (plain)
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
#!/bin/bash

sudo apt-get update
sudo apt-get install -y zip gdisk libncurses5

set -ex

if [ -z "${WORKSPACE}" ]; then
	WORKSPACE="$(pwd)"
	DB_BOOT_TOOLS_DIR="db-boot-tools"

	if [ ! -d "${WORKSPACE}/${DB_BOOT_TOOLS_DIR}" ]; then
		git clone "${DB_BOOT_TOOLS_GIT}" "${WORKSPACE}/${DB_BOOT_TOOLS_DIR}"
	fi
else
	DB_BOOT_TOOLS_DIR="."
	LINARO_PUBLISH="True"
fi

# download the firmware packages
wget -c -q ${QCOM_LINUX_FIRMWARE}
echo "${QCOM_LINUX_FIRMWARE_MD5}  $(basename ${QCOM_LINUX_FIRMWARE})" > MD5
md5sum -c MD5

rm -rf bootloaders-linux
#      "*/05-BTFM/BTFM.bin" \
#      "*/10-imagefv/imagefv.elf" \
unzip -j -d bootloaders-linux $(basename ${QCOM_LINUX_FIRMWARE}) \
      "*/02-firehose_prog/prog_firehose_ddr.elf" \
      "*/04_aop/aop.mbn" \
      "*/06-cmnlib/cmnlib.mbn" \
      "*/06-cmnlib/cmnlib64.mbn" \
      "*/07-devcfg/devcfg.mbn" \
      "*/08-dspso/dspso.bin" \
      "*/09-hyp/hyp.mbn" \
      "*/10-apdp/apdp.mbn" \
      "*/15-tz/tz.mbn" \
      "*/16-xbl/xbl.elf" \
      "*/16-xbl/xbl_config.elf" \
      "*/24-featenabler/featenabler.mbn" \
      "*/36-km4/km4.mbn" \
      "*/40-qupv3fw/qupv3fw.elf" \
      "*/44-multi_image/multi_image.mbn" \
      "*/50-spunvm/spunvm.bin" \
      "*/51-uefi_sec/uefi_sec.mbn"

BOOTLOADER_UFS_LINUX=rb5-bootloader-ufs-linux-${BUILD_NUMBER}
BOOTLOADER_UFS_AOSP=rb5-bootloader-ufs-aosp-${BUILD_NUMBER}

mkdir -p out/${BOOTLOADER_UFS_LINUX} out/${BOOTLOADER_UFS_AOSP}

# get LICENSE file (for Linux BSP)
unzip -j $(basename ${QCOM_LINUX_FIRMWARE}) "*/LICENSE.qcom.txt"
mv LICENSE.qcom.txt LICENSE
echo "${QCOM_LINUX_FIRMWARE_LICENSE_MD5}  LICENSE" > MD5
md5sum -c MD5

# Create ptable and rawprogram/patch command files
if [ ! -d "ptool" ]; then
	git clone --depth 1 https://git.linaro.org/landing-teams/working/qualcomm/partioning_tool.git ptool
fi
(cd ptool && git log -1)
rm -rf linux aosp
(mkdir -p ptool/linux && cd ptool/linux && python2 ${WORKSPACE}/ptool/ptool.py -x ${WORKSPACE}/${DB_BOOT_TOOLS_DIR}/rb5/linux/partition.xml)
(mkdir -p ptool/aosp && cd ptool/aosp && python2 ${WORKSPACE}/ptool/ptool.py -x ${WORKSPACE}/${DB_BOOT_TOOLS_DIR}/rb5/aosp/partition.xml)

# tcbindir from install-gcc-toolchain.sh
export PATH=${tcbindir}:$PATH

# Clang
if [ ! -d "${WORKSPACE}/clang" ]; then
	git clone ${ABL_CLANG_GIT} --depth 1 -b ${ABL_CLANG_REL} ${WORKSPACE}/clang
fi

# get and build abl
if [ ! -d "abl" ]; then
	git clone --depth 1 ${ABL_GIT_LINARO} -b ${ABL_GIT_REL} abl
fi
pushd abl
ABL_GIT_COMMIT=$(git rev-parse HEAD)
mkdir -p out/edk2
make all \
     BOOTLOADER_OUT=out/edk2 \
     BUILD_SYSTEM_ROOT_IMAGE=0 \
     VERIFIED_BOOT=0 \
     VERIFIED_BOOT_2=0 \
     VERIFIED_BOOT_LE=0 \
     USER_BUILD_VARIANT=0 \
     DISABLE_PARALLEL_DOWNLOAD_FLASH=1 \
     ABL_USE_SDLLVM=false \
     ABL_SAFESTACK=false \
     AB_RETRYCOUNT_DISABLE=1 \
     CLANG_BIN=${WORKSPACE}/clang/clang-4691093/bin/ \
     CLANG_PREFIX="aarch64-none-linux-gnu-" \
     CLANG_GCC_TOOLCHAIN="${tcbindir}/aarch64-none-linux-gnu-gcc" \
     TARGET_ARCHITECTURE=AARCH64 \
     BOARD_BOOTLOADER_PRODUCT_NAME="SuperEDK2k"

# get the signing tools, and sign
# add SSH server signatures to known_hosts list.
bash -c "ssh-keyscan dev-private-git.linaro.org >>  ${HOME}/.ssh/known_hosts"
bash -c "ssh-keyscan dev-private-review.linaro.org >>  ${HOME}/.ssh/known_hosts"
if [ ! -d "sectools" ]; then
	git clone --depth 1 ssh://git@dev-private-git.linaro.org/landing-teams/working/qualcomm/sectools.git
fi

python2 sectools/sectools.py secimage -v \
        -c sectools/config/sm8250/sm8250_secimage.xml \
        -g abl -i abl.elf -o out -sa
popd

# Empty/zero boot image file to clear boot partition
dd if=/dev/zero of=boot-erase.img bs=1024 count=1024

# bootloader_ufs_linux
cp -a LICENSE \
   ${DB_BOOT_TOOLS_DIR}/rb5/linux/flashall \
   bootloaders-linux/* \
   abl/out/sm8250/abl/abl.elf \
   ptool/linux/{rawprogram?.xml,patch?.xml,gpt_main?.bin,gpt_backup?.bin,gpt_both?.bin} \
   boot-erase.img \
   out/${BOOTLOADER_UFS_LINUX}

# bootloader_ufs_aosp
cp -a LICENSE \
   ${DB_BOOT_TOOLS_DIR}/rb5/aosp/flashall \
   bootloaders-linux/* \
   abl/out/sm8250/abl/abl.elf \
   ptool/aosp/{rawprogram?.xml,patch?.xml,gpt_main?.bin,gpt_backup?.bin,gpt_both?.bin} \
   boot-erase.img \
   out/${BOOTLOADER_UFS_AOSP}

# Final preparation of archives for publishing
mkdir -p ${WORKSPACE}/out2
for i in ${BOOTLOADER_UFS_LINUX} \
         ${BOOTLOADER_UFS_AOSP} ; do
    (cd out/$i && md5sum * > MD5SUMS.txt)
    (cd out && zip -r ${WORKSPACE}/out2/$i.zip $i)
done

# Create MD5SUMS file
(cd ${WORKSPACE}/out2 && md5sum * > MD5SUMS.txt)

# Build information
cat > ${WORKSPACE}/out2/HEADER.textile << EOF

h4. Bootloaders for Qualcomm RB5

This page provides the bootloaders packages for the Qualcomm RB5. There are several packages:
* *bootloader_ufs_linux* : includes the bootloaders and partition table (GPT) used when booting Linux images from onboard UFS
* *bootloader_ufs_aosp* : includes the bootloaders and partition table (GPT) used when booting AOSP images from onboard UFS

Build description:
* Build URL: "$BUILD_URL":$BUILD_URL
* Linux proprietary bootloaders package: $(basename ${QCOM_LINUX_FIRMWARE})
* "ABL source code":$ABL_GIT_LINARO/commit/?id=$ABL_GIT_COMMIT
* Partition table:
** "Linux":$GIT_URL/tree/rb5/linux/partition.xml?id=$GIT_COMMIT
** "AOSP":$GIT_URL/tree/rb5/aosp/partition.xml?id=$GIT_COMMIT
EOF

# Publish
if [ "${LINARO_PUBLISH}" ]; then
	test -d ${HOME}/bin || mkdir ${HOME}/bin
	wget -q https://git.linaro.org/ci/publishing-api.git/blob_plain/HEAD:/linaro-cp.py -O ${HOME}/bin/linaro-cp.py
	time python3 ${HOME}/bin/linaro-cp.py \
	     --server ${PUBLISH_SERVER} \
	     --link-latest \
	     ${WORKSPACE}/out2 ${PUB_DEST}
fi