aboutsummaryrefslogtreecommitdiff
path: root/96boards-hikey-mainline-rebase.yaml
blob: 887acd37f5df23c4932e1091a9f0a55ea70fd06c (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
- job:
    name: 96boards-hikey-mainline-rebase
    project-type: freestyle
    defaults: global
    logrotate:
        daysToKeep: 30
        numToKeep: 30
    properties:
        - authorization:
            anonymous:
                - job-read
                - job-extended-read
                - job-workspace
    parameters:
        - string:
            name: ROOTFS
            default: 'alip developer'
    disabled: false
    node: docker-jessie-amd64
    display-name: '96boards - HiKey (hikey-mainline-rebase)'
    scm:
        - git:
            url: https://github.com/96boards-hikey/linux.git
            refspec: +refs/heads/hikey-mainline-rebase:refs/remotes/origin/hikey-mainline-rebase
            name: origin
            branches:
                - refs/heads/hikey-mainline-rebase
            skip-tag: true
            shallow-clone: true
            wipe-workspace: false
    wrappers:
        - timestamps
        - build-name:
            name: '#${BUILD_NUMBER}-${GIT_REVISION,length=8}'
    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 out/hikey-jessie_*.img || true
              rm -rf builddir*
              rm -rf out
            }

            sudo apt-get update
            sudo apt-get install -y android-tools-fsutils kpartx mtools python-pycurl
            wget -q \
              http://repo.linaro.org/ubuntu/linaro-tools/pool/main/l/linaro-image-tools/linaro-image-tools_2016.05-1linarojessie1_amd64.deb \
              http://repo.linaro.org/ubuntu/linaro-tools/pool/main/l/linaro-image-tools/python-linaro-image-tools_2016.05-1linarojessie1_all.deb
            sudo dpkg -i --force-all *.deb
            rm -f *.deb

            export LANG=C
            export make_bootwrapper=false
            export make_install=true
            export kernel_flavour=hikey
            export kernel_config=defconfig
            export MAKE_DTBS=true
            export ARCH=arm64
            export tcbindir="${HOME}/srv/toolchain/arm64-tc-15.08/bin"
            export toolchain_url=http://releases.linaro.org/components/toolchain/binaries/5.1-2015.08/aarch64-linux-gnu/gcc-linaro-5.1-2015.08-x86_64_aarch64-linux-gnu.tar.xz

            # FIXME workaround build failure introduced by
            # https://github.com/96boards-hikey/linux/commit/18d938d
            sed -i '/etnaviv/d' drivers/gpu/drm/Makefile

            rm -rf configs lci-build-tools
            git clone --depth 1 http://git.linaro.org/ci/lci-build-tools.git
            git clone --depth 1 http://git.linaro.org/ci/job/configs.git
            bash -x lci-build-tools/jenkins_kernel_build_inst
            rm -rf out/dtbs
            cp -a linux-*.deb out/

            git clone --depth 1 https://github.com/OP-TEE/optee_linuxdriver.git
            export PATH=${WORKSPACE}/srv/toolchain/arm64-tc-15.08/bin:${PATH}
            export CROSS_COMPILE=aarch64-linux-gnu-
            #make -C ${KERNEL_PATH} M=${WORKSPACE}/optee_linuxdriver modules
            #make -C ${KERNEL_PATH} M=${WORKSPACE}/optee_linuxdriver INSTALL_MOD_PATH=${WORKSPACE}/build-utilites/fs modules_install
            cd ${WORKSPACE}

            # Create the hardware pack
            cp -a configs/96boards-hikey/hwpacks/linaro-hikey .

            VERSION=`date +%Y%m%d`-${BUILD_NUMBER}
            linaro-hwpack-create --debug linaro-hikey ${VERSION}
            linaro-hwpack-replace -t `ls hwpack_linaro-hikey_*_arm64_supported.tar.gz` -p `ls linux-image-*-linaro-hikey_*.deb` -r linux-image -d -i
            linaro-hwpack-replace -t `ls hwpack_linaro-hikey_*_arm64_supported.tar.gz` -p `ls linux-headers-*-linaro-hikey_*.deb` -r linux-headers -d -i

            FASTBOOT_EFI_BUILD_NUMBER=`wget -q --no-check-certificate -O - https://ci.linaro.org/job/96boards-hikey-uefi/lastSuccessfulBuild/buildNumber`
            FASTBOOT_EFI_URL="http://builds.96boards.org/snapshots/hikey/linaro/uefi/${FASTBOOT_EFI_BUILD_NUMBER}/AndroidFastbootApp.efi"
            wget --progress=dot ${FASTBOOT_EFI_URL} -O fastboot.efi

            GRUB_EFI_URL="http://builds.96boards.org/snapshots/hikey/linaro/grub/latest"
            wget --progress=dot ${GRUB_EFI_URL}/grubaa64.efi -O grubaa64.efi

            cat > out/README.txt << EOF
            Build information:
            * build: ${BUILD_URL}
            * git URL: ${GIT_URL}
            * git branch: ${GIT_BRANCH}
            * git commit: ${GIT_COMMIT}
            * uefi: http://builds.96boards.org/snapshots/hikey/linaro/uefi/${FASTBOOT_EFI_BUILD_NUMBER}
            EOF

            for rootfs in ${ROOTFS}; do
              # 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=${rootfs}/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=${rootfs}/lastSuccessfulBuild/buildTimestamp?format=yyyyMMdd`
              export ROOTFS_BUILD_URL="http://snapshots.linaro.org/debian/images/${rootfs}-arm64/${ROOTFS_BUILD_NUMBER}/linaro-jessie-${rootfs}-${ROOTFS_BUILD_TIMESTAMP}-${ROOTFS_BUILD_NUMBER}.tar.gz"
              wget --progress=dot -e dotbytes=2M ${ROOTFS_BUILD_URL}

              cat >> out/README.txt << EOF
            * rootfs (${rootfs}): http://snapshots.linaro.org/debian/images/${rootfs}-arm64/${ROOTFS_BUILD_NUMBER}
            EOF

              if [ "${rootfs}" = "alip" ]; then
                mali_pkg="libmali-450_0.0.1-1_all.deb"
                wget https://builds.96boards.org/snapshots/hikey/linaro/binaries/20150825/${mali_pkg} -O ${mali_pkg}
                linaro-hwpack-append -t `ls hwpack_linaro-hikey_*_arm64_supported.tar.gz` -p ${mali_pkg} -d -i
                rm -f ${mali_pkg}
                armsoc_pkg="xserver-xorg-video-armsoc_1.4.0-0linaro1.linarojessie.4_arm64.deb"
                wget http://repo.linaro.org/ubuntu/linaro-overlay/pool/main/x/xf86-video-armsoc/${armsoc_pkg} -O ${armsoc_pkg}
                linaro-hwpack-append -t `ls hwpack_linaro-hikey_*_arm64_supported.tar.gz` -p ${armsoc_pkg} -d -i
                rm -f ${armsoc_pkg}
              fi

              # Create pre-built image(s)
              linaro-media-create --dev fastmodel --output-directory ${WORKSPACE}/out --image-file hikey-jessie_${rootfs}_${VERSION}.img --image-size 2G --binary linaro-jessie-${rootfs}-${ROOTFS_BUILD_TIMESTAMP}-${ROOTFS_BUILD_NUMBER}.tar.gz --hwpack hwpack_linaro-hikey_*.tar.gz --hwpack-force-yes --bootloader uefi

              # Create eMMC rootfs image(s)
              mkdir boot rootfs
              for device in $(sudo kpartx -avs out/hikey-jessie_${rootfs}_${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

              if [ "${rootfs}" = "developer" ]; then
                sed -e "s|^PULSEAUDIO_SYSTEM_START=0|PULSEAUDIO_SYSTEM_START=1|" \
                    -e "s|^DISALLOW_MODULE_LOADING=1|DISALLOW_MODULE_LOADING=0|" \
                    < rootfs/usr/share/doc/pulseaudio/examples/pulseaudio.default.example \
                    | sudo tee rootfs/etc/default/pulseaudio
                sudo install -D -p -m0755 \
                  rootfs/usr/share/doc/pulseaudio/examples/pulseaudio.init.example \
                  rootfs/etc/init.d/pulseaudio
                cat << EOF | sudo tee -a rootfs/etc/pulse/system.pa

            ### Automatically load driver modules for Bluetooth hardware
            .ifexists module-bluetooth-policy.so
            load-module module-bluetooth-policy
            .endif

            .ifexists module-bluetooth-discover.so
            load-module module-bluetooth-discover
            .endif
            EOF
              else
                sudo install -D -p -m0644 \
                  rootfs/etc/xdg/lxsession/LXDE/autostart \
                  rootfs/home/linaro/.config/lxsession/LXDE/autostart
                cat << EOF | sudo tee -a rootfs/home/linaro/.config/lxsession/LXDE/autostart
            @bash -c /home/linaro/bin/xmms2-output-plugin-pulse
            EOF
              fi

              sudo mkdir rootfs/boot/grub
              (cd rootfs/boot/grub && sudo ln -sf /boot/efi/EFI/BOOT/grub.cfg)
              (cd rootfs/boot && sudo ln -s Image-* Image)
              sudo cp -a out/hi6220-hikey.dtb rootfs/boot/
              (cd rootfs/boot && sudo ln -s initrd.img-* initrd.img)

              cat << EOF | sudo tee rootfs/etc/NetworkManager/dispatcher.d/99hikey
            #!/bin/sh

            if [ "$1" = "wlan0" -a "$2" = "pre-up" ]; then
              /sbin/iw wlan0 set power_save off
              echo 0 > /sys/kernel/debug/ieee80211/phy0/wlcore/sleep_auth
            fi
            EOF

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

              sudo rm -rf rootfs/dev rootfs/var/lib/apt/lists
              sudo mkdir rootfs/dev rootfs/var/lib/apt/lists rootfs/home/linaro/bin

              sudo wget https://raw.githubusercontent.com/96boards/usb_speed_switch/master/usb_speed -O rootfs/home/linaro/bin/usb_speed
              cat << EOF | sudo tee -a rootfs/home/linaro/bin/xmms2-output-plugin-pulse
            #!/bin/sh

            [ ! -f "\$HOME/.config/xmms2/xmms2.conf" ] && xmms2 server config output.plugin pulse
            EOF
              cat << EOF | sudo tee -a rootfs/home/linaro/.profile

            /home/linaro/bin/xmms2-output-plugin-pulse
            EOF
              sudo chmod a+x rootfs/home/linaro/bin/* \
                             rootfs/etc/NetworkManager/dispatcher.d/99hikey
              sudo chown -R 1000:1000 rootfs/home/linaro

              # ******** 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 ********

              sudo mkfs.ext4 -L rootfs out/hikey-jessie_${rootfs}_${VERSION}.emmc.img.ext4 2G
              mkdir rootfs-ext4
              sudo mount -o loop out/hikey-jessie_${rootfs}_${VERSION}.emmc.img.ext4 rootfs-ext4
              sudo cp -a rootfs/* rootfs-ext4
              sudo umount boot rootfs rootfs-ext4
              sudo kpartx -dv out/hikey-jessie_${rootfs}_${VERSION}.img
              sudo ext2simg -v out/hikey-jessie_${rootfs}_${VERSION}.emmc.img.ext4 out/hikey-jessie_${rootfs}_${VERSION}.emmc.img
              sudo rm -rf boot rootfs rootfs-ext4 out/*.ext4

              # Compress image(s)
              gzip -9 out/hikey-jessie_${rootfs}_${VERSION}.emmc.img
              gzip -9 out/hikey-jessie_${rootfs}_${VERSION}.img
            done

            # Create boot image(s)
            /sbin/mkfs.fat -F32 -n "boot" -C out/boot-fat.uefi.img 65536
            mmd -i out/boot-fat.uefi.img ::EFI
            mmd -i out/boot-fat.uefi.img ::EFI/BOOT
            mcopy -i out/boot-fat.uefi.img fastboot.efi ::EFI/BOOT/fastboot.efi
            mcopy -i out/boot-fat.uefi.img grubaa64.efi ::EFI/BOOT/grubaa64.efi
            mcopy -i out/boot-fat.uefi.img configs/96boards-hikey/boot/grub.cfg ::EFI/BOOT/grub.cfg
            chmod 644 out/boot-fat.uefi.img

            # Compress boot partition image(s)
            gzip -9 out/boot-fat.uefi.img

            # Create MD5SUMS file
            (cd out && 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
            wget https://git.linaro.org/ci/job/configs.git/blob_plain/HEAD:/96boards-hikey/build-info/template.txt -O out/BUILD-INFO.txt
            time python ${HOME}/bin/linaro-cp.py \
              --server ${PUBLISH_SERVER} \
              --build-info out/BUILD-INFO.txt \
              --link-latest \
              out snapshots/hikey/community/hikey-mainline-rebase/${BUILD_NUMBER}
    publishers:
        - email:
            recipients: 'fathi.boudra@linaro.org guodong.xu@linaro.org'