Skip to content

Commit

Permalink
[PXE] Added the installer image for PXE installation (#26)
Browse files Browse the repository at this point in the history
Signed-off-by: Vivek Reddy Karri <vkarri@nvidia.com>
Co-authored-by: Vivek Reddy Karri <vkarri@nvidia.com>
  • Loading branch information
vivekrnv and vivekrnv authored Mar 16, 2022
1 parent bd6896e commit d03e627
Show file tree
Hide file tree
Showing 13 changed files with 361 additions and 36 deletions.
1 change: 1 addition & 0 deletions build_debian.sh
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,7 @@ sudo LANG=C DEBIAN_FRONTEND=noninteractive chroot $FILESYSTEM_ROOT apt-get -y in
fdisk \
gpg \
dmidecode \
binutils \
jq \
auditd

Expand Down
12 changes: 5 additions & 7 deletions build_image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -293,14 +293,12 @@ elif [[ $IMAGE_TYPE = s2s && $CONFIGURED_PLATFORM == nvidia-bluefield ]]; then
sudo rm -f $OUTPUT_ONIE_IMAGE
generate_s2s_installer_image_bluefield

elif [[ $IMAGE_TYPE == bfb && $CONFIGURED_PLATFORM == nvidia-bluefield ]]; then
sudo --preserve-env /sonic/installer/bluefield/create_sonic_bfb --kernel $KVERSION
elif [[ ( $IMAGE_TYPE == bfb || $IMAGE_TYPE == pxe ) && $CONFIGURED_PLATFORM == nvidia-bluefield ]]; then
sudo --preserve-env /sonic/installer/bluefield/create_sonic_image --kernel $KVERSION
sudo chown $USER ./$OUTPUT_BFB_IMAGE

elif [[ $IMAGE_TYPE == pxe && $CONFIGURED_PLATFORM == nvidia-bluefield ]]; then
echo "Not Yet Implemented"
exit 1

if [[ $IMAGE_TYPE == pxe ]]; then
sudo chown $USER ./$OUTPUT_PXE_IMAGE
fi
else
echo "Error: Non supported image type $IMAGE_TYPE"
exit 1
Expand Down
12 changes: 12 additions & 0 deletions installer/bluefield/PXE_README.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
""" Setup PXE Network Installer for Bluefield """
1) vendor-class-identifier option of the DHCP request coming from a bluefield2 will be equal to BF2Client.
2) Add the corresponding line to DHCP conf
if substring (option vendor-class-identifier, 0, 9) = "BF2Client" {
filename "grubnetaa64.efi";
}
3) Extract the tar file. Eg: tar -xvzf <tar_file> .
4) Please place the individual files in the expected locations. For Eg:
a) The above DHCP configuration expects grub-efi binary to be in tftp-root
b) grub.cfg is expected in grub/ directory
c) Location of Image & initramfs can be somewhere in the tftp-root directory, but update the grub.cfg appropriately
5) Doesn't support Secure Boot
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#

# This script generates the corresponding SONiC installer images for Bluefield
# 1) BFB Image
# 2) PXE Archive for Network Booting

set -e

WDIR=
Expand All @@ -34,12 +39,13 @@ BOOTCTL_DRIVER=$CDIR/$FILES_PATH/mlx-bootctl.ko
TMFIFO_DRIVER=$CDIR/$FILES_PATH/mlxbf-tmfifo.ko
TARGET_MACHINE=nvidia-bluefield
BFB="${BFB:-/lib/firmware/mellanox/boot/default.bfb}"
GRUB_AA64=grubnetaa64.efi
CONSOLE_PARAM="console=ttyAMA1 console=hvc0 console=ttyAMA0 earlycon=pl011,0x01000000 earlycon=pl011,0x01800000"

usage() {
cat << EOF
Usage: `basename $0` [ OPTIONS ]
OPTIONS:
-i, --install_bfb <BFB> Installation BFB to be used as a basis for the target BFB. Default: $BFB
-k, --kernel <kernel version> Kernel version for the SmartNIC.
-v, --verbose Run script in verbose mode. Will print out each step of execution.
-h, --help Display help
Expand All @@ -53,9 +59,9 @@ parse_args() {
usage
exit 0
;;
-i|--install_bfb)
-v|--verbose)
shift
BFB=$1
set -x
;;
-k|--kernel)
shift
Expand All @@ -72,27 +78,27 @@ parse_args() {

validate_config() {
if [[ ! -d "$CHROOT_DIR" ]]; then
echo "[create_sonic_bfb] Error! Path to CHROOT not found"
echo "[create_sonic_image] Error! Path to CHROOT not found"
exit 1
fi

if [[ ! -f "$INITRD" ]]; then
echo "[create_sonic_bfb] Error! SONiC INITRD not found"
echo "[create_sonic_image] Error! SONiC INITRD not found"
exit 1
fi

if [[ ! -f "$VMLINUZ" ]]; then
echo "[create_sonic_bfb] Error! SONiC VMLINUZ not found"
echo "[create_sonic_image] Error! SONiC VMLINUZ not found"
exit 1
fi

if [[ ! -d "$MODULES_DIR" ]]; then
echo "[create_sonic_bfb] Error! Path to Kernel Modules not found"
echo "[create_sonic_image] Error! Path to Kernel Modules not found"
exit 1
fi

if [[ ! -n "$OUTPUT_BFB_IMAGE" ]]; then
echo "[create_sonic_bfb] Error! OUTPUT_BFB_IMAGE name not defined. Exiting.."
echo "[create_sonic_image] Error! OUTPUT_BFB_IMAGE name not defined. Exiting.."
exit 1
fi

Expand Down Expand Up @@ -134,16 +140,20 @@ validate_config() {
}

cleanup_workdir() {
rm -rf $WDIR
rm -rf $boot_args $boot_path $boot_desc $arxiv_wdir $WDIR
}

create_workdir() {
if [[ $WDIR == "" ]]; then
WDIR=$(mktemp -d /sonic/bfb-wd-XXXX)
trap cleanup_workdir EXIT
else
rm -rf $WDIR/*
fi
boot_args=$(mktemp /tmp/boot-args-XXXX)
boot_path=$(mktemp /tmp/boot-path-XXXX)
boot_desc=$(mktemp /tmp/boot-desc-XXXX)
arxiv_wdir=$(mktemp -d /tmp/pxe-wd-XXXX)
trap cleanup_workdir EXIT
}

add_sonic_to_initramfs() {
Expand Down Expand Up @@ -177,6 +187,8 @@ insmod /usr/lib/modules/5.10.0-8-2-arm64/kernel/drivers/virtio/virtio_ring.ko >
insmod /efivarfs.ko > /dev/null 2>&1
insmod /mlx-bootctl.ko > /dev/null 2>&1
insmod /mlxbf-tmfifo.ko > /dev/null 2>&1
insmod /sbsa_gwdt.ko > /dev/null 2>&1
/usr/sbin/watchdog > /dev/null 2>&1
printf_msg "================================="
printf_msg "Installing SONiC. Please wait..."
Expand Down Expand Up @@ -273,7 +285,8 @@ create_bfb_image() {
`dpkg -L mft` \
`dpkg -L mft-oem` \
`dpkg -L kernel-mft-modules` \
`dpkg -L tar`
`dpkg -L tar` \
/usr/sbin/watchdog
do
if [ -d $tool ]; then
continue
Expand All @@ -296,19 +309,23 @@ create_bfb_image() {
`dpkg -L grub-efi-arm64-bin` \
xz efibootmgr gcc-10 bash getopt hexdump lspci perl \
lsblk shutdown systemctl strings aarch64-linux-gnu-strings \
mlxbf-bootctl id mkfs fsck
mlxbf-bootctl id mkfs fsck watchdog
do
if [ -d $tool ]; then
continue
fi
copy_bin $tool
done

sudo depmod -a -b ./ $KERNEL
mkdir -p usr/share/misc/ bin/ var/log/watchdog
sudo cp /etc/watchdog.conf etc
sudo cp /usr/share/misc/pci.ids usr/share/misc/
cp $CHROOT_DIR/usr/share/misc/pci.ids usr/share/misc/
cp $BOOTCTL_DRIVER .
cp $TMFIFO_DRIVER .
cp $EFIVARS_MOD .
cp $WATCHDOG .

mkdir -p ./lib/firmware/mellanox/boot/
cp /lib/firmware/mellanox/boot/default.bfb ./lib/firmware/mellanox/boot/default.bfb
Expand All @@ -324,12 +341,8 @@ create_bfb_image() {
popd

# Make bfb
boot_args=$(mktemp)
boot_path=$(mktemp)
boot_desc=$(mktemp)
printf "console=ttyAMA1 console=hvc0 console=ttyAMA0 earlycon=pl011,0x01000000 earlycon=pl011,0x01800000 initrd=initramfs" > \
"$boot_args"

printf "$CONSOLE_PARAM initrd=initramfs" > "$boot_args"

printf "VenHw(F019E406-8C9C-11E5-8797-001ACA00BFC4)/Image" > "$boot_path"
printf "Linux from rshim" > "$boot_desc"
vmlinuz=$WDIR/vmlinuz
Expand All @@ -345,7 +358,28 @@ create_bfb_image() {

echo "BFB is ready: $(readlink -f ${DDIR}/${OUTPUT_BFB_IMAGE})"

rm -rf $boot_args $boot_path $boot_desc
popd
}

create_pxe_archive(){
# Installed by grub-efi-arm64-bin deb package
if [[ ! -f "/usr/lib/grub/arm64-efi/monolithic/$GRUB_AA64" ]]; then
echo "Grub EFI binary not found, check if grub-efi-arm64-bin package is installed"
exit 1
fi

pushd $arxiv_wdir

cp /usr/lib/grub/arm64-efi/monolithic/$GRUB_AA64 .

cp $WDIR/vmlinuz Image
cp $WDIR/dump-initramfs-v0 initramfs

console_params=$CONSOLE_PARAM j2 /sonic/installer/bluefield/grub.cfg.j2 > grub.cfg
cp /sonic/installer/bluefield/PXE_README.txt .

tar -C $arxiv_wdir -cvzf ${DDIR}/${OUTPUT_PXE_IMAGE} .

popd
}

Expand All @@ -360,13 +394,18 @@ main() {
VMLINUZ=$CDIR/$FILESYSTEM_ROOT/boot/vmlinuz-$KERNEL
MODULES_DIR=$CDIR/$FILESYSTEM_ROOT/lib/modules/$KERNEL
EFIVARS_MOD=$MODULES_DIR/kernel/fs/efivarfs/efivarfs.ko
WATCHDOG=$MODULES_DIR/kernel/drivers/watchdog/sbsa_gwdt.ko
IMAGE_VER=$(cat $CHROOT_DIR/etc/sonic/sonic_version.yml | grep "build_version" | sed -e "s/build_version: //g;s/'//g")
validate_config

create_workdir
echo "Work directory: $WDIR"

create_bfb_image

if [[ $IMAGE_TYPE == pxe ]]; then
create_pxe_archive
fi
}

main $@
Binary file added installer/bluefield/docs/BFB_flow.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit d03e627

Please sign in to comment.