|
| 1 | +#!/usr/bin/env bash |
| 2 | +# Copyright 2026 Arm Limited and/or its affiliates. |
| 3 | +# |
| 4 | +# This source code is licensed under the BSD-style license found in the |
| 5 | +# LICENSE file in the root directory of this source tree. |
| 6 | + |
| 7 | +apply_patch_if_needed () { |
| 8 | + local patch="$1" |
| 9 | + if git apply --reverse --check "$patch" >/dev/null 2>&1; then |
| 10 | + echo "Already applied: $(basename "$patch")" |
| 11 | + else |
| 12 | + git am "$patch" |
| 13 | + fi |
| 14 | +} |
| 15 | + |
| 16 | +set -euo pipefail |
| 17 | + |
| 18 | +SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)" |
| 19 | + |
| 20 | +# Clone repos if not already cloned |
| 21 | +if [[ ! -d meta-arm/.git ]]; then |
| 22 | + git clone https://git.yoctoproject.org/git/meta-arm -b CORSTONE1000-2025.12 meta-arm |
| 23 | +fi |
| 24 | +if [[ ! -d systemready-patch/.git ]]; then |
| 25 | + git clone https://git.gitlab.arm.com/arm-reference-solutions/systemready-patch.git \ |
| 26 | + -b topics/hugkam01/a320_with_ssh systemready-patch |
| 27 | +fi |
| 28 | + |
| 29 | +cd meta-arm/ |
| 30 | + |
| 31 | +git am --abort 2>/dev/null || true |
| 32 | + |
| 33 | +# Apply patches if not already applied |
| 34 | +# TODO: Remove these patches and the apply_patch_if_needed func once we bump the version |
| 35 | +apply_patch_if_needed ../systemready-patch/embedded-a/corstone1000/remove_second_bank/0001-Platform-Corstone1000-Drop-secondary-bank-reservatio.patch |
| 36 | +apply_patch_if_needed ../systemready-patch/embedded-a/corstone1000/add-ssh-to-a320/0001-kas-Build-Corstone-1000-a320-with-SSH.patch |
| 37 | + |
| 38 | +cd ../ |
| 39 | + |
| 40 | +cp systemready-patch/embedded-a/corstone1000/ethos-u85_test/ethos-u85_test.yml meta-arm/kas/ |
| 41 | + |
| 42 | +mkdir -p meta-arm/kas/local |
| 43 | +cat > meta-arm/kas/local/enable-ssh.yml <<'EOF' |
| 44 | +header: |
| 45 | + version: 14 |
| 46 | +
|
| 47 | +local_conf_header: |
| 48 | + enable-ssh: | |
| 49 | + CORE_IMAGE_EXTRA_INSTALL:append = " packagegroup-core-ssh-dropbear ssh-pregen-hostkeys" |
| 50 | + IMAGE_CLASSES:append = " dropbear-rcs-symlink" |
| 51 | + CORE_IMAGE_EXTRA_INSTALL:append:firmware = " packagegroup-core-ssh-dropbear ssh-pregen-hostkeys" |
| 52 | + IMAGE_CLASSES:append:firmware = " dropbear-rcs-symlink" |
| 53 | + zzz-ssh-autostart: | |
| 54 | + # Re-add host key generation after other config removes it. |
| 55 | + CORE_IMAGE_EXTRA_INSTALL:append = " ssh-pregen-hostkeys" |
| 56 | +EOF |
| 57 | + |
| 58 | +mkdir -p meta-arm/meta-arm-bsp/classes/ |
| 59 | +cat > meta-arm/meta-arm-bsp/classes/dropbear-rcs-symlink.bbclass <<'EOF' |
| 60 | +ROOTFS_POSTPROCESS_COMMAND:append = " dropbear_rcs_symlink; " |
| 61 | +
|
| 62 | +dropbear_rcs_symlink() { |
| 63 | + if [ -e ${IMAGE_ROOTFS}/etc/init.d/dropbear ]; then |
| 64 | + rcs_dir=${IMAGE_ROOTFS}/etc/rcS.d |
| 65 | + install -d ${rcs_dir} |
| 66 | +
|
| 67 | + rm -f ${rcs_dir}/S50dropbear ${rcs_dir}/S50dropbear.sh |
| 68 | +
|
| 69 | + printf '%s\n' \ |
| 70 | + '#!/bin/sh' \ |
| 71 | + '' \ |
| 72 | + 'case "$1" in' \ |
| 73 | + 'start|"")' \ |
| 74 | + ' if ! pidof dropbear >/dev/null 2>&1; then' \ |
| 75 | + ' if [ -x /etc/init.d/dropbear ]; then' \ |
| 76 | + ' /etc/init.d/dropbear start >/dev/console 2>&1 || \' \ |
| 77 | + ' echo "Dropbear auto-start failed" >/dev/console' \ |
| 78 | + ' fi' \ |
| 79 | + ' fi' \ |
| 80 | + ' ;;' \ |
| 81 | + 'esac' \ |
| 82 | + > ${rcs_dir}/S50dropbear.sh |
| 83 | +
|
| 84 | + chmod 0755 ${rcs_dir}/S50dropbear.sh |
| 85 | + fi |
| 86 | +} |
| 87 | +EOF |
| 88 | + |
| 89 | +if [[ "${ARM_FVP_EULA_ACCEPT:-}" != "1" ]]; then |
| 90 | + echo "You must export ARM_FVP_EULA_ACCEPT=1 to accept the Arm FVP EULA." |
| 91 | + exit 1 |
| 92 | +fi |
| 93 | + |
| 94 | +kas build meta-arm/kas/corstone1000-a320.yml:meta-arm/ci/debug.yml:meta-arm/kas/ethos-u85_test.yml:meta-arm/kas/local/enable-ssh.yml |
| 95 | + |
| 96 | +kas shell "meta-arm/kas/corstone1000-fvp.yml:meta-arm/ci/debug.yml:meta-arm/kas/corstone1000-a320.yml:meta-arm/kas/local/enable-ssh.yml" -c "bitbake corstone1000-recovery-image -c populate_sdk" |
0 commit comments