aboutsummaryrefslogtreecommitdiff
path: root/96boards-reference-uefi.yaml
blob: 171d3c01d4871b889e8e2a57fd36dd98915b35dd (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
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
- job:
    name: 96boards-reference-uefi
    project-type: matrix
    defaults: global
    logrotate:
        daysToKeep: 30
        numToKeep: 30
    properties:
        - authorization:
            anonymous:
                - job-read
                - job-extended-read
                - job-workspace
            linaro:
                - job-read
                - job-extended-read
                - job-build
                - job-cancel
    parameters:
        - string:
            name: EDK2_VERSION
            default: 'HEAD'
        - string:
            name: ATF_VERSION
            default: 'v1.2'
        - password:
            name: PRIVATE_KEY
            default: ${PRIVATE_KEY}
    disabled: false
    node: build
    child-workspace: .
    display-name: '96boards - Reference Component - UEFI'
    axes:
        - axis:
            type: user-defined
            name: MX_PLATFORM
            values:
                - hikey
                - d02
                - juno
        - axis:
            type: user-defined
            name: MX_TYPE
            values:
                - RELEASE
                - DEBUG
        - axis:
            type: slave
            name: label
            values:
                - docker-jessie-amd64
    execution-strategy:
        sequential: true
        touchstone:
            expr: 'MX_PLATFORM=="hikey" && MX_TYPE=="RELEASE"'
    wrapper:
        - timestamps
        - build-name:
            name: '#${BUILD_NUMBER}-${GIT_REVISION,length=8}'
        - matrix-tie-parent:
            node: build
    builders:
        - linaro-publish-token:
            host: builds.96boards.org
        - shell: |
            #!/bin/bash

            export JOB_NAME=96boards-reference-uefi
            echo "JOB_URL: ${JOB_URL}"
            echo "BUILD_URL: ${BUILD_URL}"
            echo "WORKSPACE: ${WORKSPACE}"
            echo "BUILD_NUMBER: ${BUILD_NUMBER}"

            # Create lower case debug/release string for use in paths
            BUILD_TYPE="${MX_TYPE,,}"

            sudo apt-get update
            sudo apt-get install -y python-pycurl zip

            set -ex

            trap cleanup_exit INT TERM EXIT

            cleanup_exit()
            {
                cd ${WORKSPACE}
                rm -rf arm-trusted-firmware
                rm -rf uefi-tools
                rm -rf l-loader
                rm -rf acpica-unix
                rm -rf OpenPlatformPkg SeattleFDK
                rm -rf out edk2/Build
            }

            # Make sure we're using the right acpica-unix packages
            mkdir acpica-unix; cd acpica-unix
            wget http://repo.linaro.org/ubuntu/linaro-overlay/pool/main/a/acpica-unix/acpica-tools_20150930-1.linarojessie.1_amd64.deb http://repo.linaro.org/ubuntu/linaro-overlay/pool/main/a/acpica-unix/acpidump_20150930-1.linarojessie.1_all.deb http://repo.linaro.org/ubuntu/linaro-overlay/pool/main/a/acpica-unix/iasl_20150930-1.linarojessie.1_all.deb
            sudo dpkg -i --force-all *.deb
            cd ..; rm -rf acpica-unix

            # Private repository setup
            TMPKEYDIR=$(mktemp -d /tmp/rpb.XXXXXX)
            cat > ${TMPKEYDIR}/private-key-wrapper.py << EOF
            #!/usr/bin/python

            import os
            import sys

            def main():
                private_key = os.environ.get("PRIVATE_KEY", "Undefined")
                if private_key == "Undefined":
                    sys.exit("PRIVATE_KEY is not defined.")

                buffer = private_key.replace(' ','\n')
                with open('linaro-private-key', 'w') as f:
                    f.write('-----BEGIN RSA PRIVATE KEY-----\n')
                    f.write(buffer)
                    f.write('\n-----END RSA PRIVATE KEY-----\n')

            if __name__ == "__main__":
                    main()
            EOF
            python ${TMPKEYDIR}/private-key-wrapper.py
            chmod 0600 ${WORKSPACE}/linaro-private-key

            eval `ssh-agent` >/dev/null 2>/dev/null
            ssh-add ${WORKSPACE}/linaro-private-key >/dev/null 2>/dev/null
            rm -rf ${WORKSPACE}/linaro-private-key ${TMPKEYDIR}

            test -d ~/.ssh || mkdir ~/.ssh
            ssh-keyscan dev-private-git.linaro.org >> ~/.ssh/known_hosts
            cat << EOF >> ~/.ssh/config
            Host dev-private-git.linaro.org
                User git
            EOF
            chmod 0600 ~/.ssh/*

            # Use pre-installed linaro toolchain (GCC 4.9)
            export PATH="${HOME}/srv/toolchain/arm-tc-15.02/bin:${HOME}/srv/toolchain/arm64-tc-15.02/bin:$PATH"

            # Common git repositories to fetch
            UEFI_TOOLS_GIT_URL=https://git.linaro.org/uefi/uefi-tools.git
            EDK2_GIT_URL=https://github.com/tianocore/edk2.git
            EDK2_GIT_VERSION=$EDK2_VERSION
            ATF_GIT_URL=https://github.com/ARM-software/arm-trusted-firmware.git
            ATF_GIT_VERSION=$ATF_VERSION
            OPEN_PLATFORM_PKG_GIT_URL=https://git.linaro.org/uefi/OpenPlatformPkg.git
            OPEN_PLATFORM_PKG_GIT_BRANCH=master

            # Per board repositories overrides
            if [ "${MX_PLATFORM}" == "hikey" ]; then
                EDK2_GIT_URL=https://github.com/96boards/edk2.git
                EDK2_GIT_VERSION=7da6cdf18127ee52e79f3cf990c8d630fd037784
                ATF_GIT_URL=https://github.com/96boards/arm-trusted-firmware.git
                ATF_GIT_VERSION=7fb9b0e1bf90d167ba451fa3d1485ad07ca5c1da
            elif [ "${MX_PLATFORM}" == "styx" ]; then
                EDK2_GIT_URL=ssh://dev-private-git.linaro.org/96boards/edk2.git
                EDK2_GIT_VERSION=HEAD
                OPEN_PLATFORM_PKG_GIT_URL=ssh://dev-private-git.linaro.org/96boards/OpenPlatformPkg.git
            elif [ "${MX_PLATFORM}" == "d02" ]; then
                EDK2_GIT_VERSION=d0d34cdf1d2752f0d7c3ca41af7e7ed29c221d11
                OPEN_PLATFORM_PKG_GIT_BRANCH=d02-release
            fi

            # So we can easily identify the build number via build path
            mkdir ${BUILD_NUMBER}; cd ${BUILD_NUMBER}

            # Clone the repos
            git clone $UEFI_TOOLS_GIT_URL uefi-tools
            cd uefi-tools; UEFI_TOOLS_GIT_VERSION=`git log --format="%H" -1`; cd ..

            git clone $EDK2_GIT_URL edk2
            cd edk2; git checkout -b stable-baseline $EDK2_GIT_VERSION; cd ..
            git clone -b $OPEN_PLATFORM_PKG_GIT_BRANCH $OPEN_PLATFORM_PKG_GIT_URL OpenPlatformPkg
            cd edk2; ln -s ../OpenPlatformPkg; cd ..
            cd OpenPlatformPkg; OPEN_PLATFORM_PKG_GIT_VERSION=`git log --format="%H" -1`; cd ..

            git clone $ATF_GIT_URL arm-trusted-firmware
            cd arm-trusted-firmware; git checkout -b stable-baseline $ATF_GIT_VERSION; cd ..

            # Build setup
            export AARCH64_TOOLCHAIN=GCC49
            export EDK2_DIR=${WORKSPACE}/${BUILD_NUMBER}/edk2
            export ATF_DIR=${WORKSPACE}/${BUILD_NUMBER}/arm-trusted-firmware
            export UEFI_TOOLS_DIR=${WORKSPACE}/${BUILD_NUMBER}/uefi-tools
            export JENKINS_WORKSPACE=${WORKSPACE}

            # Board specific setup
            if [ "${MX_PLATFORM}" == "hikey" ]; then
                # Force previous EDK2 + ATF only build, since uefi-tools is now building with OPP
                cd uefi-tools
                # Commit before it was changed to OPP
                UEFI_TOOLS_GIT_VERSION=3831996c5d39d602c3a647ad94cc18d5ee965499
                git reset --hard $UEFI_TOOLS_GIT_VERSION
                cd -
            elif [ "${MX_PLATFORM}" == "styx" ]; then
                git clone -b FDK84 --depth 1 ssh://dev-private-git.linaro.org/96boards/SeattleFDK.git
                cd $EDK2_DIR; ln -s ../SeattleFDK/AmdModulePkg; cd ..
            fi

            # WORKSPACE is used by uefi-build.sh
            unset WORKSPACE

            # Build UEFI for the desired platform, with the specified build type
            cd ${EDK2_DIR}
            bash -x ${UEFI_TOOLS_DIR}/uefi-build.sh -b ${MX_TYPE} -a $ATF_DIR ${MX_PLATFORM}

            unset WORKSPACE
            export WORKSPACE=${JENKINS_WORKSPACE}

            # Find out the artifacts and image dir so we can publish the correct output files
            IMAGES=`$UEFI_TOOLS_DIR/parse-platforms.py -c $UEFI_TOOLS_DIR/platforms.config -p ${MX_PLATFORM} images`
            IMAGE_DIR=`$UEFI_TOOLS_DIR/parse-platforms.py -c $UEFI_TOOLS_DIR/platforms.config -p ${MX_PLATFORM} -o UEFI_IMAGE_DIR get`
            BUILD_ATF=`$UEFI_TOOLS_DIR/parse-platforms.py -c $UEFI_TOOLS_DIR/platforms.config -p ${MX_PLATFORM} -o BUILD_ATF get`

            cd ${WORKSPACE}
            mkdir -p out/${BUILD_TYPE}
            for image in ${IMAGES}; do
                cp -a ${EDK2_DIR}/Build/${IMAGE_DIR}/${MX_TYPE}_*/FV/${image} out/${BUILD_TYPE}/
            done

            if [ "${MX_PLATFORM}" == "hikey" ]; then
                # Additional components for hikey, such as fastboot and l-loader
                cp -a ${EDK2_DIR}/Build/${IMAGE_DIR}/${MX_TYPE}_*/AARCH64/AndroidFastbootApp.efi out/${BUILD_TYPE}
                cd ${WORKSPACE}/${BUILD_NUMBER}
                git clone --depth 1 https://github.com/96boards/l-loader.git
                cd l-loader
                ln -s ${WORKSPACE}/out/${BUILD_TYPE}/bl1.bin
                make
                cp -a l-loader.bin ptable*.img ${WORKSPACE}/out/${BUILD_TYPE}
                wget https://raw.githubusercontent.com/96boards/burn-boot/master/hisi-idt.py -O ${WORKSPACE}/out/${BUILD_TYPE}/hisi-idt.py
                # Ship nvme.img with UEFI binaries for convenience
                dd if=/dev/zero of=${WORKSPACE}/out/${BUILD_TYPE}/nvme.img bs=128 count=1024
            elif [ "${MX_PLATFORM}" == "styx" ]; then
                cd ${WORKSPACE}/${BUILD_NUMBER}/SeattleFDK
                Linaro/make-rom.sh ${EDK2_DIR}/Build/${IMAGE_DIR}/${MX_TYPE}_*/FV/${IMAGES} >/dev/null
                cp Linaro/Styx.bin ${WORKSPACE}/out/${BUILD_TYPE}
            elif [ "${MX_PLATFORM}" == "d02" ]; then
                # Still produce a version that is only SATA compatible
                sed -i "s/include (\"Sas.asl\")/include (\"Sata.asl\")/g" ${WORKSPACE}/${BUILD_NUMBER}/OpenPlatformPkg/Chips/Hisilicon/Pv660/Pv660AcpiTables/Dsdt/Dsdt.asl
                cd ${EDK2_DIR}
                bash -x ${UEFI_TOOLS_DIR}/uefi-build.sh -b ${MX_TYPE} -a $ATF_DIR ${MX_PLATFORM}
                cp -a ${EDK2_DIR}/Build/${IMAGE_DIR}/${MX_TYPE}_*/FV/${IMAGES} ${WORKSPACE}/out/${BUILD_TYPE}/${IMAGES%.*}-SATA.fd
            fi
            cd ${WORKSPACE}

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

            # Build information
            cat > out/${BUILD_TYPE}/README.textile << EOF

            h4. 96Boards - Reference Component - UEFI

            Tianocore EDK2 UEFI build consumed by the 96Boards Reference Platform Builds

            Build Description:
            * Build URL: "$BUILD_URL":$BUILD_URL
            * UEFI Tools: "$UEFI_TOOLS_GIT_URL":$UEFI_TOOLS_GIT_URL
            * UEFI Tools head: $UEFI_TOOLS_GIT_VERSION
            * EDK2: "$EDK2_GIT_URL":$EDK2_GIT_URL
            * EDK2 head: $EDK2_GIT_VERSION
            * OpenPlatformPkg: "$OPEN_PLATFORM_PKG_GIT_URL":$OPEN_PLATFORM_PKG_GIT_URL
            * OpenPlatformPkg branch: $OPEN_PLATFORM_PKG_GIT_BRANCH
            * OpenPlatformPkg head: $OPEN_PLATFORM_PKG_GIT_VERSION
            EOF

            if [ "$BUILD_ATF" == "yes" ]; then
                cat >> out/${BUILD_TYPE}/README.textile << EOF
            * ARM Trusted Firmware: "$ATF_GIT_URL":$ATF_GIT_URL
            * ARM Trusted Firmware head: $ATF_GIT_VERSION
            EOF
            fi

            # Publish
            test -d ${HOME}/bin || mkdir ${HOME}/bin
            wget https://git.linaro.org/ci/publishing-api.git/blob_plain/HEAD:/linaro-cp.py -O ${HOME}/bin/linaro-cp.py
            time python ${HOME}/bin/linaro-cp.py \
              --server ${PUBLISH_SERVER} \
              out/${BUILD_TYPE} snapshots/reference-platform/components/uefi/${BUILD_NUMBER}/${BUILD_TYPE}/${MX_PLATFORM}/
            python ${HOME}/bin/linaro-cp.py \
              --server ${PUBLISH_SERVER} \
              --make-link snapshots/reference-platform/components/uefi/${BUILD_NUMBER}
    publishers:
        - email:
            recipients: 'ricardo.salveti@linaro.org'