source: mainline/tools/deploy/hikey960/fastboot

Last change on this file was c21cc26, checked in by Martin Decky <martin@…>, 4 years ago

Fastboot deployment script for HiKey 960

Convenience script to deploy HelenOS to the HiKey 960 board using the
fastboot mechanism.

  • Property mode set to 100755
File size: 3.2 KB
Line 
1#!/bin/sh
2
3#
4# Copyright (c) 2021 Martin Decky
5# All rights reserved.
6#
7# Redistribution and use in source and binary forms, with or without
8# modification, are permitted provided that the following conditions
9# are met:
10#
11# - Redistributions of source code must retain the above copyright
12# notice, this list of conditions and the following disclaimer.
13# - Redistributions in binary form must reproduce the above copyright
14# notice, this list of conditions and the following disclaimer in the
15# documentation and/or other materials provided with the distribution.
16# - The name of the author may not be used to endorse or promote products
17# derived from this software without specific prior written permission.
18#
19# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
20# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
21# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
22# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
23# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
24# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
28# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29#
30
31# This script allows to deploy HelenOS conveniently to the HiKey 960 board
32# using the fastboot protocol. The fastboot mechanism is provided as a part
33# of the default UEFI firmware on HiKey 960.
34#
35# The implementation of the fastboot mechanism on HiKey 960 has several
36# quirks and this script tries to accommodate for them:
37#
38# * The boot image must be compressed by GZip. Uncompressed boot images are
39# rejected.
40#
41# * The compressed boot image must end with a device tree blob (even if
42# the device tree is not actually processed). A missing device tree blob
43# crashes the fastboot mechanism.
44#
45# * A RAM disk must be included in the final fastboot image. A missing RAM
46# disk crashes the fastboot mechanism. We use a fake blob for that purpose.
47
48check_error() {
49 if [ "$1" -ne "0" ] ; then
50 echo
51 echo "Error: $2"
52
53 exit 1
54 fi
55}
56
57SCRIPT_DIR="$(readlink -f $(dirname "$0"))"
58
59if [ "$#" -lt "1" ] ; then
60 echo "Usage: $0 <image.boot>"
61 exit 2
62fi
63
64IMAGE="$1"
65IMAGE_GZ="${IMAGE}.gz"
66IMAGE_GZ_DTB="${IMAGE_GZ}+dtb"
67IMAGE_FASTBOOT="${IMAGE}.fastboot"
68
69if [ ! -f "${IMAGE}" ] ; then
70 echo "Error: ${IMAGE} is not a file"
71 exit 3
72fi
73
74# Compress the image
75gzip -c "${IMAGE}" > "${IMAGE_GZ}"
76check_error $? "Compressing ${IMAGE}"
77
78# Append the DTB
79cat "${IMAGE_GZ}" "${SCRIPT_DIR}/hi3660-hikey960.dtb" > "${IMAGE_GZ_DTB}"
80check_error $? "Appending DTB to ${IMAGE_GZ}"
81
82# Create the fastboot image with a fake "RAM disk"
83"${SCRIPT_DIR}/mkfastboot" --kernel ${IMAGE_GZ_DTB} --ramdisk "${SCRIPT_DIR}/hikey960.rd" --base 0x0 --tags-addr 0x07a00000 --kernel_offset 0x00080000 --ramdisk_offset 0x07c00000 --output "${IMAGE_FASTBOOT}"
84check_error $? "Converting ${IMAGE_GZ_DTB} to a fastboot image"
85
86# Deploy the fastboot image on a HiKey 960 board connected to the host machine
87fastboot boot "${IMAGE_FASTBOOT}"
88check_error $? "Deploying ${IMAGE_FASTBOOT}"
Note: See TracBrowser for help on using the repository browser.