diff --git a/build.sh b/build.sh index ce7191d4e43..0dda1a8e4f1 100755 --- a/build.sh +++ b/build.sh @@ -9,6 +9,7 @@ usage() { echo -e "\tz690a_ddr5 - build Dasharo image compatible with MSI PRO Z690-A (WIFI)" echo -e "\tz790p_ddr4 - build Dasharo image compatible with MSI PRO Z790-P (WIFI) DDR4" echo -e "\tz790p_ddr5 - build Dasharo image compatible with MSI PRO Z790-P (WIFI)" + echo -e "\tvp66xx - build Dasharo for Protectli VP66xx" echo -e "\tvp46xx - build Dasharo for Protectli VP46xx" echo -e "\tvp2420 - build Dasharo for Protectli VP2420" @@ -16,140 +17,155 @@ usage() { echo -e "\tV1210 - build Dasharo for Protectli V1210" echo -e "\tV1410 - build Dasharo for Protectli V1410" echo -e "\tV1610 - build Dasharo for Protectli V1610" + echo -e "\tapu2 - build Dasharo for PC Engines APU2" echo -e "\tapu3 - build Dasharo for PC Engines APU3" echo -e "\tapu4 - build Dasharo for PC Engines APU4" echo -e "\tapu6 - build Dasharo for PC Engines APU6" + echo -e "\toptiplex_9010 - build Dasharo compatible with Dell OptiPlex 7010/9010" + echo -e "\tqemu - build Dasharo for QEMU Q35" echo -e "\tqemu_full - build Dasharo for QEMU Q35 with all menus available" + + echo -e "\tv540tu - build Dasharo for Novacustom V540TU" + echo -e "\tv560tu - build Dasharo for Novacustom V560TU" + echo -e "\tns5x7x - build Dasharo for Novacustom NS5x/NS7x" + echo -e "\tnv4x_adl - build Dasharo for Novacustom NV4x 12 gen" + echo -e "\tnx5x7x - build Dasharo for Novacustom Nx5x/Nx7x" + echo -e "\tnv4x_tgl - build Dasharo for Novacustom NV4x 11 gen" } SDKVER="2023-11-24_2731fa619b" -function build_optiplex_9010 { - DEFCONFIG="configs/config.dell_optiplex_9010_sff_uefi_txt" - FW_VERSION=v0.1.0-rc1 - docker run --rm -t -u $UID -v $PWD:/home/coreboot/coreboot \ - -v $HOME/.ssh:/home/coreboot/.ssh \ - -w /home/coreboot/coreboot coreboot/coreboot-sdk:$SDKVER \ - /bin/bash -c "make distclean" +function prepare_for_build { + if [[ -v CB_REVISION ]]; then + git checkout $CB_REVISION + fi - cp "${DEFCONFIG}" .config + if [[ ! -v NO_DISTCLEAN ]]; then + docker run --rm -t -u $UID -v $PWD:/home/coreboot/coreboot \ + -v $HOME/.ssh:/home/coreboot/.ssh \ + -w /home/coreboot/coreboot coreboot/coreboot-sdk:$SDKVER \ + /bin/bash -c "make distclean" + fi - git submodule update --init --checkout + if [[ ! -v NO_CONFIG_OVERRIDE ]]; then + cp "${DEFCONFIG}" .config + fi +} - echo "Building Dasharo compatible with Dell OptiPlex 7010/9010 (version $FW_VERSION)" +function build_coreboot { + TARGET_BINARY=$1 + prepare_for_build docker run --rm -t -u $UID -v $PWD:/home/coreboot/coreboot \ -v $HOME/.ssh:/home/coreboot/.ssh \ -w /home/coreboot/coreboot coreboot/coreboot-sdk:$SDKVER \ /bin/bash -c "make olddefconfig && make -j$(nproc)" - - cp build/coreboot.rom ${BOARD}_${FW_VERSION}.rom + + cp build/coreboot.rom $TARGET_BINARY if [ $? -eq 0 ]; then - echo "Result binary placed in $PWD/${BOARD}_${FW_VERSION}.rom" - sha256sum ${BOARD}_${FW_VERSION}.rom > ${BOARD}_${FW_VERSION}.rom.sha256 + echo "Result binary placed in $PWD/$TARGET_BINARY" + sha256sum $TARGET_BINARY > $TARGET_BINARY.sha256 else echo "Build failed!" exit 1 fi } -function build_msi { - DEFCONFIG="configs/config.${BOARD}_$1" - FW_VERSION=$(cat ${DEFCONFIG} | grep CONFIG_LOCALVERSION | cut -d '=' -f 2 | tr -d '"') - - docker run --rm -t -u $UID -v $PWD:/home/coreboot/coreboot \ - -v $HOME/.ssh:/home/coreboot/.ssh \ - -w /home/coreboot/coreboot coreboot/coreboot-sdk:$SDKVER \ - /bin/bash -c "make distclean" - - cp "${DEFCONFIG}" .config - - git submodule update --init --checkout - - echo "Building Dasharo compatible with MSI PRO $2(WIFI) (version $FW_VERSION)" +function build_ec { + EC_BOARD_VENDOR=$1 + EC_BOARD_MODEL=$2 + if [[ ! -v EC_REVISION ]]; then + echo "EC_REVISION environmental variable is not set. Please provide an EC revision." + exit 1; + fi + + echo "Building EC for $EC_BOARD_VENDOR $EC_BOARD_MODEL from branch $EC_REVISION" + git clone https://github.com/Dasharo/ec.git &> /dev/null || true + cd ec + git checkout $EC_REVISION + git submodule update --init --recursive --checkout + EC_BOARD_VENDOR=novacustom EC_BOARD_MODEL=nv4x_adl ./build.sh || true + cd .. + cp "ec/${EC_BOARD_VENDOR}_${EC_BOARD_MODEL}_ec.rom" ec.rom +} - docker run --rm -t -u $UID -v $PWD:/home/coreboot/coreboot \ - -v $HOME/.ssh:/home/coreboot/.ssh \ - -w /home/coreboot/coreboot coreboot/coreboot-sdk:$SDKVER \ - /bin/bash -c "make olddefconfig && make -j$(nproc)" +function generic_submodules { + if [[ ! -v NO_SUBMODULE_UPDATE ]]; then + git submodule update --init --checkout + fi +} - cp build/coreboot.rom ${BOARD}_${FW_VERSION}_$1.rom - if [ $? -eq 0 ]; then - echo "Result binary placed in $PWD/${BOARD}_${FW_VERSION}_$1.rom" - sha256sum ${BOARD}_${FW_VERSION}_$1.rom > ${BOARD}_${FW_VERSION}_$1.rom.sha256 +function protectli_submodules { + if [[ ! -d 3rdparty/dasharo-blobs/protectli ]]; then + NO_SUBMODULE_UPDATE="true" else - echo "Build failed!" - exit 1 + unset NO_SUBMODULE_UPDATE fi + generic_submodules } -function build_protectli_vault { - DEFCONFIG="configs/config.protectli_${BOARD}" - FW_VERSION=$(cat ${DEFCONFIG} | grep CONFIG_LOCALVERSION | cut -d '=' -f 2 | tr -d '"') +function pcengines_submodules { + if [[ ! -v NO_SUBMODULE_UPDATE ]]; then + # checkout several submodules needed by these boards (some others are checked + # out by coreboot's Makefile) + git submodule update --init --force --checkout \ + 3rdparty/dasharo-blobs \ + 3rdparty/vboot + fi +} - if [ ! -d 3rdparty/dasharo-blobs/protectli ]; then - git submodule update --init --checkout +function qemu_submodules { + if [[ ! -v NO_SUBMODULE_UPDATE ]]; then + # checkout several submodules needed by these boards (some others are checked + # out by coreboot's Makefile) + git submodule update --init --force --checkout \ + 3rdparty/dasharo-blobs fi +} - docker run --rm -t -u $UID -v $PWD:/home/coreboot/coreboot \ - -v $HOME/.ssh:/home/coreboot/.ssh \ - -w /home/coreboot/coreboot coreboot/coreboot-sdk:2021-09-23_b0d87f753c \ - /bin/bash -c "make distclean" +function build_optiplex_9010 { + DEFCONFIG="configs/config.dell_optiplex_9010_sff_uefi_txt" + FW_VERSION=v0.1.0-rc1 - cp $DEFCONFIG .config + generic_submodules + TARGET_BINARY="${BOARD}_${FW_VERSION}" + echo "Building Dasharo compatible with Dell OptiPlex 7010/9010 (version $FW_VERSION)" + build_coreboot $TARGET_BINARY +} - echo "Building Dasharo for Protectli $BOARD (version $FW_VERSION)" +function build_msi { + DEFCONFIG="configs/config.${BOARD}_$1" + FW_VERSION=$(cat ${DEFCONFIG} | grep CONFIG_LOCALVERSION | cut -d '=' -f 2 | tr -d '"') - docker run --rm -t -u $UID -v $PWD:/home/coreboot/coreboot \ - -v $HOME/.ssh:/home/coreboot/.ssh \ - -w /home/coreboot/coreboot coreboot/coreboot-sdk:$SDKVER \ - /bin/bash -c "make olddefconfig && make -j$(nproc)" + generic_submodules + TARGET_BINARY= ${BOARD}_${FW_VERSION}_$1.rom + echo "Building Dasharo compatible with MSI PRO $2(WIFI) (version $FW_VERSION)" + build_coreboot $TARGET_BINARY +} - cp build/coreboot.rom protectli_${BOARD}_${FW_VERSION}.rom - if [ $? -eq 0 ]; then - echo "Result binary placed in $PWD/protectli_${BOARD}_${FW_VERSION}.rom" - sha256sum protectli_${BOARD}_${FW_VERSION}.rom > protectli_${BOARD}_${FW_VERSION}.rom.sha256 - else - echo "Build failed!" - exit 1 - fi +function build_protectli_vault { + DEFCONFIG="configs/config.protectli_${BOARD}" + FW_VERSION=$(cat ${DEFCONFIG} | grep CONFIG_LOCALVERSION | cut -d '=' -f 2 | tr -d '"') + + protectli_submodules + TARGET_BINARY=protectli_${BOARD}_${FW_VERSION}.rom + echo "Building Dasharo for Protectli $BOARD (version $FW_VERSION)" + build_coreboot $TARGET_BINARY } function build_v1x10 { DEFCONFIG="configs/config.protectli_vault_jsl_$1" FW_VERSION=$(cat ${DEFCONFIG} | grep CONFIG_LOCALVERSION | cut -d '=' -f 2 | tr -d '"') - if [ ! -d 3rdparty/dasharo-blobs/protectli ]; then - git submodule update --init --checkout - fi - - docker run --rm -t -u $UID -v $PWD:/home/coreboot/coreboot \ - -v $HOME/.ssh:/home/coreboot/.ssh \ - -w /home/coreboot/coreboot coreboot/coreboot-sdk:$SDKVER \ - /bin/bash -c "make distclean" - - cp $DEFCONFIG .config - + protectli_submodules + TARGET_BINARY=protectli_$1_${FW_VERSION}.rom echo "Building Dasharo for Protectli $1 (version $FW_VERSION)" - - docker run --rm -t -u $UID -v $PWD:/home/coreboot/coreboot \ - -v $HOME/.ssh:/home/coreboot/.ssh \ - -w /home/coreboot/coreboot coreboot/coreboot-sdk:$SDKVER \ - /bin/bash -c "make olddefconfig && make -j$(nproc)" - - cp build/coreboot.rom protectli_$1_${FW_VERSION}.rom - if [ $? -eq 0 ]; then - echo "Result binary placed in $PWD/protectli_$1_${FW_VERSION}.rom" - sha256sum protectli_$1_${FW_VERSION}.rom > protectli_$1_${FW_VERSION}.rom.sha256 - else - echo "Build failed!" - exit 1 - fi + build_coreboot $TARGET_BINARY } function build_pcengines { @@ -157,68 +173,44 @@ function build_pcengines { DEFCONFIG="configs/config.pcengines_uefi_${VARIANT}" FW_VERSION=$(cat ${DEFCONFIG} | grep CONFIG_LOCALVERSION | cut -d '=' -f 2 | tr -d '"') - # checkout several submodules needed by these boards (some others are checked - # out by coreboot's Makefile) - git submodule update --init --force --checkout \ - 3rdparty/dasharo-blobs \ - 3rdparty/vboot - - docker run --rm -t -u $UID -v $PWD:/home/coreboot/coreboot \ - -v $HOME/.ssh:/home/coreboot/.ssh \ - -w /home/coreboot/coreboot coreboot/coreboot-sdk:$SDKVER \ - /bin/bash -c "make distclean" - - cp $DEFCONFIG .config - + pcengines_submodules + TARGET_BINARY=pcengines_${VARIANT}_${FW_VERSION}.rom echo "Building Dasharo for PC Engines ${VARIANT^^*} (version $FW_VERSION)" - - docker run --rm -t -u $UID -v $PWD:/home/coreboot/coreboot \ - -v $HOME/.ssh:/home/coreboot/.ssh \ - -w /home/coreboot/coreboot coreboot/coreboot-sdk:$SDKVER \ - /bin/bash -c "make olddefconfig && make -j$(nproc)" - - cp build/coreboot.rom pcengines_${VARIANT}_${FW_VERSION}.rom - if [ $? -eq 0 ]; then - echo "Result binary placed in $PWD/pcengines_${VARIANT}_${FW_VERSION}.rom" - sha256sum pcengines_${VARIANT}_${FW_VERSION}.rom > pcengines_${VARIANT}_${FW_VERSION}.rom.sha256 - else - echo "Build failed!" - exit 1 - fi + build_coreboot $TARGET_BINARY } function build_qemu { DEFCONFIG="configs/config.emulation_qemu_x86_q35_uefi${1:-}" FW_VERSION=$(cat ${DEFCONFIG} | grep CONFIG_LOCALVERSION | cut -d '=' -f 2 | tr -d '"') - # checkout several submodules needed by these boards (some others are checked - # out by coreboot's Makefile) - git submodule update --init --force --checkout \ - 3rdparty/dasharo-blobs - - docker run --rm -t -u $UID -v $PWD:/home/coreboot/coreboot \ - -v $HOME/.ssh:/home/coreboot/.ssh \ - -w /home/coreboot/coreboot coreboot/coreboot-sdk:$SDKVER \ - /bin/bash -c "make distclean" - - cp $DEFCONFIG .config - + qemu_submodules + TARGET_BINARY=qemu_q35_${FW_VERSION}.rom echo "Building Dasharo for QEMU Q35 (version $FW_VERSION)" + build_coreboot $TARGET_BINARY +} - docker run --rm -t -u $UID -v $PWD:/home/coreboot/coreboot \ - -v $HOME/.ssh:/home/coreboot/.ssh \ - -w /home/coreboot/coreboot coreboot/coreboot-sdk:$SDKVER \ - /bin/bash -c "make olddefconfig && make -j$(nproc)" +function build_nv4x_adl { + DEFCONFIG="configs/config.novacustom_nv4x_adl" + FW_VERSION=$(cat ${DEFCONFIG} | grep CONFIG_LOCALVERSION | cut -d '=' -f 2 | tr -d '"') - cp build/coreboot.rom qemu_q35_${FW_VERSION}.rom - if [ $? -eq 0 ]; then - echo "Result binary placed in $PWD/qemu_q35_${FW_VERSION}.rom" - sha256sum qemu_q35_${FW_VERSION}.rom > qemu_q35_${FW_VERSION}.rom.sha256 + if [[ -v EC_REVISION ]]; then + build_ec novacustom nv4x_adl else - echo "Build failed!" - exit 1 + echo "No EC revision provided. Set EC_REVISION environmental variable + #build_ec novacustom_nv4x_adl_v1.7.2 novacustom nv4x_adl fi + + generic_submodules + TARGET_BINARY=novacustom_nv4x_adl_$FW_VERSION + echo "Building Dasharo for Novacustom NV4x Adl (version $FW_VERSION)" + build_coreboot $TARGET_BINARY } + # echo -3 "\tv540tu - build Dasharo for Novacustom V540TU" + # echo -3 "\tv560tu - build Dasharo for Novacustom V560TU" + # echo -3 "\tns5x7x - build Dasharo for Novacustom NS5x/NS7x" + # echo -3 "\tnv4x - build Dasharo for Novacustom NV4x" + # echo -3 "\tnx5x7x - build Dasharo for Novacustom Nx5x/Nx7x" + # echo -3 "\tnv4x - build Dasharo for Novacustom NV4x" CMD="$1" @@ -289,6 +281,9 @@ case "$CMD" in "qemu_full" | "QEMU_full" | "q35_full" | "Q35_full" ) build_qemu "_all_menus" ;; + "nv4x_adl" ) + build_nv4x_adl + ;; *) echo "Invalid command: \"$CMD\"" usage