aboutsummaryrefslogtreecommitdiff
path: root/96boards-reference-platform-debian.yaml
blob: 1618b8729e722f69750da35f5ad43ed07957be43 (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
- job:
    name: 96boards-reference-platform-debian
    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-configure
                - job-build
                - job-cancel
    disabled: false
    node: build
    child-workspace: .
    display-name: '96boards - Reference Platform - Debian'
    axes:
        - axis:
            type: user-defined
            name: BOARD
            values:
                - hikey
                - dragonboard410c
        - axis:
            type: slave
            name: label
            values:
                - docker-utopic-amd64
    execution-strategy:
        sequential: true
        touchstone:
            expr: 'BOARD=="hikey"'
    wrappers:
        - timestamps
        - build-name:
            name: '#${BUILD_NUMBER}'
        - matrix-tie-parent:
            node: build
    builders:
        - linaro-publish-token:
            host: builds.96boards.org
        - shell: |
            #!/bin/bash

            set -ex

            trap cleanup_exit INT TERM EXIT

            cleanup_exit()
            {
              cd ${WORKSPACE}
              sudo kpartx -dv ${BOARD}-debian-*.img || true
              rm -rf configs out
            }

            # Builder setup
            sudo sed -i -e 's/archive.ubuntu.com\|security.ubuntu.com/old-releases.ubuntu.com/g' /etc/apt/sources.list
            sudo apt-get update
            sudo apt-get install -y kpartx python-pycurl
            wget http://repo.linaro.org/ubuntu/linaro-overlay/pool/main/a/android-tools/android-tools-fsutils_4.2.2+git20130218-3ubuntu41+linaro1_amd64.deb
            sudo dpkg -i --force-all android-tools-fsutils_*.deb
            rm -f android-tools-fsutils_*.deb
            # FIXME - temporary workarounds
            sudo wget https://git.linaro.org/ci/linaro-image-tools.git/blob_plain/HEAD:/linaro-hwpack-install -O /usr/bin/linaro-hwpack-install
            sudo chmod +x /usr/bin/linaro-hwpack-install
            git clone --depth 1 http://git.linaro.org/ci/job/configs.git

            # Get the reference kernel packages
            KERNEL_BUILD_NUMBER=`wget -q --no-check-certificate -O - https://ci.linaro.org/view/96boards/job/96boards-reference-kernel-matrix/MX_PLATFORM=${BOARD},label=docker-utopic-amd64/lastSuccessfulBuild/buildNumber`
            KERNEL_RELEASE=`wget -q --no-check-certificate -O - https://ci.linaro.org/view/96boards/job/96boards-reference-kernel-matrix/MX_PLATFORM=${BOARD},label=docker-utopic-amd64/${KERNEL_BUILD_NUMBER}/injectedEnvVars/export | grep KERNEL_RELEASE | cut -d'=' -f2-`
            KERNEL_BUILD_BASE_URL="https://builds.96boards.org/snapshots/reference-platform/components/linux/${BOARD}/${KERNEL_BUILD_NUMBER}"
            wget --progress=dot -e dotbytes=1M ${KERNEL_BUILD_BASE_URL}/linux-image-${KERNEL_RELEASE}_${KERNEL_RELEASE}-${KERNEL_BUILD_NUMBER}_arm64.deb
            wget --progress=dot -e dotbytes=1M ${KERNEL_BUILD_BASE_URL}/linux-headers-${KERNEL_RELEASE}_${KERNEL_RELEASE}-${KERNEL_BUILD_NUMBER}_arm64.deb

            # Create the hardware pack
            cp -a configs/96boards-reference-platform-debian/hwpacks/linaro-${BOARD} .
            VERSION=`date +%Y%m%d`-${BUILD_NUMBER}
            linaro-hwpack-create --debug linaro-${BOARD} ${VERSION}
            linaro-hwpack-append -t `ls hwpack_linaro-${BOARD}_*_arm64_supported.tar.gz` -p `ls linux-image-*.deb` -d -i
            linaro-hwpack-append -t `ls hwpack_linaro-${BOARD}_*_arm64_supported.tar.gz` -p `ls linux-headers-*.deb` -d -i

            # Get rootfs
            export ROOTFS_BUILD_NUMBER=`wget -q --no-check-certificate -O - https://ci.linaro.org/job/debian-arm64-rootfs/label=docker-jessie-arm64,rootfs=alip/lastSuccessfulBuild/buildNumber`
            export ROOTFS_BUILD_TIMESTAMP=`wget -q --no-check-certificate -O - https://ci.linaro.org/job/debian-arm64-rootfs/label=docker-jessie-arm64,rootfs=alip/lastSuccessfulBuild/buildTimestamp?format=yyyyMMdd`
            export ROOTFS_BUILD_URL="http://snapshots.linaro.org/debian/images/alip-arm64/${ROOTFS_BUILD_NUMBER}/linaro-jessie-alip-${ROOTFS_BUILD_TIMESTAMP}-${ROOTFS_BUILD_NUMBER}.tar.gz"
            wget --progress=dot -e dotbytes=2M ${ROOTFS_BUILD_URL}
            ROOTFS_BUILD_TAR=linaro-jessie-alip-${ROOTFS_BUILD_TIMESTAMP}-${ROOTFS_BUILD_NUMBER}.tar.gz

            # Create pre-built image(s)
            linaro-media-create --dev fastmodel --output-directory ${WORKSPACE} --image-file ${BOARD}-rootfs-debian-jessie-alip-${VERSION}.img --image-size 2G --binary ${ROOTFS_BUILD_TAR} --hwpack hwpack_linaro-${BOARD}_*.tar.gz --hwpack-force-yes --bootloader uefi --part-table gpt

            # Create eMMC rootfs image(s)
            mkdir boot rootfs
            for device in $(sudo kpartx -av ${BOARD}-rootfs-debian-jessie-alip-${VERSION}.img | cut -d' ' -f3); do
              partition=$(echo ${device} | cut -d'p' -f3)
              [ "${partition}" = "1" ] && sudo mount -o loop /dev/mapper/${device} boot
              [ "${partition}" = "2" ] && sudo mount -o loop /dev/mapper/${device} rootfs
            done

            # Needed for make_ext4fs, as it can't handle device files
            sudo rm -rf rootfs/dev
            sudo mkdir rootfs/dev

            sudo ln -sf /etc/resolvconf/run/resolv.conf rootfs/etc/resolv.conf

            cat << EOF | sudo tee rootfs/etc/fstab
            /dev/disk/by-partlabel/system /     ext4 errors=remount-ro 0 1
            EOF

            # Make sure rootfs/boot also got the right dtb and links
            sudo mkdir -p rootfs/boot/dtbs/
            sudo cp *.dtb rootfs/boot/dtbs/
            sudo ln -s Image-${KERNEL_RELEASE} rootfs/boot/Image
            sudo ln -s initrd.img-${KERNEL_RELEASE} rootfs/boot/initrd.img

            mkdir -p out/${BOARD}

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

            h4. 96Boards - Reference Platform Build - Debian

            Build description:
            * Build URL: "$BUILD_URL":$BUILD_URL
            * Kernel packages: "$KERNEL_BUILD_BASE_URL":$KERNEL_BUILD_BASE_URL
            * ALIP Rootfs: "http://snapshots.linaro.org/debian/images/alip-arm64/$ROOTFS_BUILD_NUMBER":http://snapshots.linaro.org/debian/images/alip-arm64/$ROOTFS_BUILD_NUMBER
            EOF

            # Create boot image
            if [ "${BOARD}" == "hikey" ]; then
                FASTBOOT_EFI_BUILD_NUMBER=`wget -q --no-check-certificate -O - https://ci.linaro.org/view/96boards/job/96boards-reference-uefi/MX_PLATFORM=hikey,MX_TYPE=RELEASE,label=docker-utopic-amd64/lastStableBuild/buildNumber`
                FASTBOOT_EFI_URL="http://builds.96boards.org/snapshots/reference-platform/components/uefi/${FASTBOOT_EFI_BUILD_NUMBER}/release/hikey/AndroidFastbootApp.efi"
                wget --progress=dot ${FASTBOOT_EFI_URL} -O fastboot.efi
                GRUB_EFI_BUILD_NUMBER=`wget -q --no-check-certificate -O - https://ci.linaro.org/view/96boards/job/96boards-reference-grub-efi-arm64/lastStableBuild/buildNumber`
                GRUB_EFI_URL="https://builds.96boards.org/snapshots/reference-platform/components/grub/${GRUB_EFI_BUILD_NUMBER}/grubaa64.efi"
                wget --progress=dot ${GRUB_EFI_URL} -O grubaa64.efi

                mkdir boot-fat
                dd if=/dev/zero of=out/${BOARD}/boot-fat.uefi.img bs=512 count=131072
                sudo mkfs.fat -n "BOOT IMG" out/${BOARD}/boot-fat.uefi.img
                sudo mount -o loop,rw,sync out/${BOARD}/boot-fat.uefi.img boot-fat
                sudo cp hi6220-hikey.dtb boot-fat/hi6220-hikey.dtb || true
                sudo cp fastboot.efi boot-fat/fastboot.efi || true
                sudo cp grubaa64.efi boot-fat/grubaa64.efi || true
                sudo umount boot-fat
                sudo chmod 777 out/${BOARD}/boot-fat.uefi.img
                sudo mv out/${BOARD}/boot-fat.uefi.img out/${BOARD}/${BOARD}-boot-linux-${VERSION}.uefi.img
                rm -rf boot-fat

                # Compress boot partition image
                gzip -9 out/${BOARD}/${BOARD}-boot-linux-${VERSION}.uefi.img

                cat >> out/${BOARD}/README.textile << EOF
            * Grub UEFI: "http://builds.96boards.org/snapshots/reference-platform/components/grub/$GRUB_EFI_BUILD_NUMBER":http://builds.96boards.org/snapshots/reference-platform/components/grub/$GRUB_EFI_BUILD_NUMBER
            * ARM TF / EDK2 UEFI: "http://builds.96boards.org/snapshots/reference-platform/components/uefi/$FASTBOOT_EFI_BUILD_NUMBER/release/hikey":http://builds.96boards.org/snapshots/reference-platform/components/uefi/$FASTBOOT_EFI_BUILD_NUMBER/release/hikey
            EOF
                # Grub config to be set as part of the rootfs
                sudo mkdir rootfs/boot/grub
                ## FIXME: Make this generic
                sed -e 's/CONSOLE_UART/ttyAMA3,115200/' -e 's/DEVICE_TREE/hi6220-hikey.dtb/' configs/96boards-reference-platform-debian/grub/grub.cfg.in > grub.cfg
                sudo cp grub.cfg rootfs/boot/grub

                # Since it uses uefi, create the boot efi fstab entry
                sudo mkdir rootfs/boot/efi
                cat << EOF | sudo tee -a rootfs/etc/fstab
            /dev/disk/by-partlabel/boot   /boot/efi vfat defaults          0 0
            EOF

                ## FIXME: Get this in a proper package
                # ******** TI wl18xx R8.6 - out of tree firmware ********
                git clone -b R8.6 --depth 1 git://git.ti.com/wilink8-wlan/wl18xx_fw.git
                sudo cp -a ./wl18xx_fw/wl18xx-fw-4.bin rootfs/lib/firmware/ti-connectivity/
                rm -rf wl18xx_fw
                # ******** TI wl18xx R8.6 - out of tree firmware ********

            elif [ "${BOARD}" == "dragonboard410c" ]; then
                # Boot image tools
                git clone git://codeaurora.org/quic/kernel/skales
                (cd skales && git log -1)
                export PATH=`pwd`/skales:$PATH

                ## FIXME: See if we can find a better way to package this
                # Firmware (adreno, venus and WCN)
                wget --progress=dot -e dotbytes=1M https://developer.qualcomm.com/download/db410c/firmware-410c-1.1.0.bin
                yes | sh firmware-410c-1.1.0.bin > /dev/null
                sudo cp -rf linux-ubuntu-board-support-package-v1.1/proprietary-ubuntu/* rootfs/lib/firmware/

                # add license file in the generated rootfs
                wget https://git.linaro.org/landing-teams/working/qualcomm/lt-docs.git/blob_plain/HEAD:/license/license.txt
                sudo cp -f license.txt rootfs/etc/license.txt

                # Create device tree table
                mkdir -p dtbs
                sudo cp rootfs/lib/firmware/*/device-tree/msm8916-mtp.dtb rootfs/lib/firmware/*/device-tree/apq8016-sbc.dtb dtbs/
                dtbTool -o dt.img -s 2048 dtbs

                # Create boot image
                mkbootimg \
                  --kernel rootfs/boot/Image \
                  --ramdisk rootfs/boot/initrd.img \
                  --output out/${BOARD}/${BOARD}-boot-linux-${VERSION}.img \
                  --dt dt.img \
                  --pagesize "2048" \
                  --base "0x80000000" \
                  --cmdline "root=/dev/disk/by-partlabel/rootfs rw rootwait console=tty0 console=ttyMSM0,115200n8"
                gzip -9 out/${BOARD}/${BOARD}-boot-linux-${VERSION}.img
            fi

            # Create the ext4fs (fastboot compatible)
            sudo make_ext4fs -o -L rootfs -l 3056M -s out/${BOARD}/${BOARD}-rootfs-debian-jessie-alip-${VERSION}.emmc.img rootfs/
            sudo umount boot rootfs
            sudo kpartx -dv ${BOARD}-rootfs-debian-jessie-alip-${VERSION}.img
            sudo rm -rf boot rootfs

            # Compress image
            gzip -9 out/${BOARD}/${BOARD}-rootfs-debian-jessie-alip-${VERSION}.emmc.img

            # Publish remaining files
            mkdir -p out/${BOARD}/hwpack
            cp hwpack* out/${BOARD}/hwpack

            # Create MD5SUMS files
            (cd out/${BOARD} && md5sum *.gz > MD5SUMS.txt)
            (cd out/${BOARD}/hwpack && md5sum * > MD5SUMS.txt)

            # 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/${BOARD} snapshots/reference-platform/debian/${BUILD_NUMBER}/${BOARD}
            python ${HOME}/bin/linaro-cp.py \
              --server ${PUBLISH_SERVER} \
              --make-link snapshots/reference-platform/debian/${BUILD_NUMBER}
    publishers:
        - email:
            recipients: 'ricardo.salveti@linaro.org'