[image]: build sonic-broadcom.raw image for sonic conversion from ftos (#901)

1. "make target/sonic-broadcom.raw" will create the compressed dd'able image.
2. This will also update the grub config files (device/dell/*/nos_to_sonic_grub.cfg) with the image versions.
This commit is contained in:
padmanarayana 2017-08-28 08:43:38 +05:30 committed by lguohan
parent 0a9d60ebb2
commit 2d3b064437
10 changed files with 231 additions and 28 deletions

View File

@ -14,11 +14,8 @@
IMAGE_VERSION=$(. functions.sh && sonic_get_version) IMAGE_VERSION=$(. functions.sh && sonic_get_version)
if [ "$IMAGE_TYPE" = "onie" ]; then generate_onie_installer_image()
echo "Build ONIE installer" {
mkdir -p `dirname $OUTPUT_ONIE_IMAGE`
sudo rm -f $OUTPUT_ONIE_IMAGE
# Copy platform-specific ONIE installer config files where onie-mk-demo.sh expects them # Copy platform-specific ONIE installer config files where onie-mk-demo.sh expects them
rm -rf ./installer/x86_64/platforms/ rm -rf ./installer/x86_64/platforms/
mkdir -p ./installer/x86_64/platforms/ mkdir -p ./installer/x86_64/platforms/
@ -27,6 +24,11 @@ if [ "$IMAGE_TYPE" = "onie" ]; then
if [ -f ./device/$VENDOR/$PLATFORM/installer.conf ]; then if [ -f ./device/$VENDOR/$PLATFORM/installer.conf ]; then
cp ./device/$VENDOR/$PLATFORM/installer.conf ./installer/x86_64/platforms/$PLATFORM cp ./device/$VENDOR/$PLATFORM/installer.conf ./installer/x86_64/platforms/$PLATFORM
fi fi
if [ "$IMAGE_TYPE" = "raw" ] && [ -f ./device/$VENDOR/$PLATFORM/nos_to_sonic_grub.cfg ]; then
sed -i -e "s/%%IMAGE_VERSION%%/$IMAGE_VERSION/g" ./device/$VENDOR/$PLATFORM/nos_to_sonic_grub.cfg
echo "IMAGE_VERSION is $IMAGE_VERSION"
fi
done done
done done
@ -35,6 +37,50 @@ if [ "$IMAGE_TYPE" = "onie" ]; then
./onie-mk-demo.sh $TARGET_PLATFORM $TARGET_MACHINE $TARGET_PLATFORM-$TARGET_MACHINE-$ONIEIMAGE_VERSION \ ./onie-mk-demo.sh $TARGET_PLATFORM $TARGET_MACHINE $TARGET_PLATFORM-$TARGET_MACHINE-$ONIEIMAGE_VERSION \
installer platform/$TARGET_MACHINE/platform.conf $OUTPUT_ONIE_IMAGE OS $IMAGE_VERSION $ONIE_IMAGE_PART_SIZE \ installer platform/$TARGET_MACHINE/platform.conf $OUTPUT_ONIE_IMAGE OS $IMAGE_VERSION $ONIE_IMAGE_PART_SIZE \
$ONIE_INSTALLER_PAYLOAD $ONIE_INSTALLER_PAYLOAD
}
if [ "$IMAGE_TYPE" = "onie" ]; then
echo "Build ONIE installer"
mkdir -p `dirname $OUTPUT_ONIE_IMAGE`
sudo rm -f $OUTPUT_ONIE_IMAGE
generate_onie_installer_image
## Build a raw partition dump image using the ONIE installer that can be
## used to dd' in-lieu of using the onie-nos-installer. Used while migrating
## into SONiC from other NOS.
elif [ "$IMAGE_TYPE" = "raw" ]; then
echo "Build RAW image"
mkdir -p `dirname $OUTPUT_RAW_IMAGE`
sudo rm -f $OUTPUT_RAW_IMAGE
generate_onie_installer_image
echo "Creating SONiC raw partition : $OUTPUT_RAW_IMAGE of size $RAW_IMAGE_DISK_SIZE MB"
fallocate -l "$RAW_IMAGE_DISK_SIZE"M $OUTPUT_RAW_IMAGE
## Generate a compressed 8GB partition dump that can be used to 'dd' in-lieu of using the onie-nos-installer
## Run the installer
## The 'build' install mode of the installer is used to generate this dump.
sudo chmod a+x $OUTPUT_ONIE_IMAGE
sudo ./$OUTPUT_ONIE_IMAGE
[ -r $OUTPUT_RAW_IMAGE ] || {
echo "Error : $OUTPUT_RAW_IMAGE not generated!"
exit 1
}
gzip $OUTPUT_RAW_IMAGE
[ -r $OUTPUT_RAW_IMAGE.gz ] || {
echo "Error : gzip $OUTPUT_RAW_IMAGE failed!"
exit 1
}
mv $OUTPUT_RAW_IMAGE.gz $OUTPUT_RAW_IMAGE
echo "The compressed raw image is in $OUTPUT_RAW_IMAGE"
## Use 'aboot' as target machine category which includes Aboot as bootloader ## Use 'aboot' as target machine category which includes Aboot as bootloader
elif [ "$IMAGE_TYPE" = "aboot" ]; then elif [ "$IMAGE_TYPE" = "aboot" ]; then
echo "Build Aboot installer" echo "Build Aboot installer"

View File

@ -0,0 +1,44 @@
#
# Grub config to launch SONiC
# with ONIE boot option
insmod serial
# Initialize USB-Serial com2 port
serial --unit=1 --speed=9600
#Serial port config;Defaults: COM1,9600
serial --unit=0 --speed=9600
terminal_output serial_com0
terminal_input serial_com0
#terminfo added to prevent text wrap issue.
terminfo -g 80x100 serial_com0
terminfo -g 80x100 serial_com1
echo -n "Press Esc to stop autoboot ... "
if sleep --verbose --interruptible 5 ; then
insmod gzio
insmod part_msdos
insmod ext2
set root='(hd0,gpt8)'
linux /image-%%IMAGE_VERSION%%/boot/vmlinuz-3.16.0-4-amd64 root=/dev/sda8 rw console=tty0 console=ttyS1,9600n8 loop=image-%%IMAGE_VERSION%%/fs.squashfs loopfstype=squashfs apparmor=1 security=apparmor
initrd /image-%%IMAGE_VERSION%%/boot/initrd.img-3.16.0-4-amd64
boot
else
menuentry 'SONiC' {
insmod gzio
insmod part_msdos
insmod ext2
set root='(hd0,gpt8)'
linux /image-%%IMAGE_VERSION%%/boot/vmlinuz-3.16.0-4-amd64 root=/dev/sda8 rw console=tty0 console=ttyS1,9600n8 loop=image-%%IMAGE_VERSION%%/fs.squashfs loopfstype=squashfs apparmor=1 security=apparmor
initrd /image-%%IMAGE_VERSION%%/boot/initrd.img-3.16.0-4-amd64
boot
}
menuentry 'ONIE' {
insmod force10
onieboot
}
menuentry 'DELL-DIAG' {
delldiagboot
}
fi

View File

@ -0,0 +1,44 @@
#
# Grub config to launch SONiC
# with ONIE boot option
insmod serial
# Initialize USB-Serial com2 port
serial --unit=1 --speed=9600
#Serial port config;Defaults: COM1,9600
serial --unit=0 --speed=9600
terminal_output serial_com0
terminal_input serial_com0
#terminfo added to prevent text wrap issue.
terminfo -g 80x100 serial_com0
terminfo -g 80x100 serial_com1
echo -n "Press Esc to stop autoboot ... "
if sleep --verbose --interruptible 5 ; then
insmod gzio
insmod part_msdos
insmod ext2
set root='(hd0,gpt8)'
linux /image-%%IMAGE_VERSION%%/boot/vmlinuz-3.16.0-4-amd64 root=/dev/sda8 rw console=tty0 console=ttyS1,9600n8 loop=image-%%IMAGE_VERSION%%/fs.squashfs loopfstype=squashfs apparmor=1 security=apparmor
initrd /image-%%IMAGE_VERSION%%/boot/initrd.img-3.16.0-4-amd64
boot
else
menuentry 'SONiC' {
insmod gzio
insmod part_msdos
insmod ext2
set root='(hd0,gpt8)'
linux /image-%%IMAGE_VERSION%%/boot/vmlinuz-3.16.0-4-amd64 root=/dev/sda8 rw console=tty0 console=ttyS1,9600n8 loop=image-%%IMAGE_VERSION%%/fs.squashfs loopfstype=squashfs apparmor=1 security=apparmor
initrd /image-%%IMAGE_VERSION%%/boot/initrd.img-3.16.0-4-amd64
boot
}
menuentry 'ONIE' {
insmod force10
onieboot
}
menuentry 'DELL-DIAG' {
delldiagboot
}
fi

View File

@ -11,6 +11,27 @@
# #
# By default this script does nothing. # By default this script does nothing.
# If the machine.conf is absent, it indicates that the unit booted
# into SONiC from another NOS. Extract the machine.conf from ONIE.
if [ ! -e /host/machine.conf ]; then
onie_dev=$(blkid | grep ONIE-BOOT | head -n 1 | awk '{print $1}' | sed -e 's/:.*$//')
mkdir -p /mnt/onie-boot
mount $onie_dev /mnt/onie-boot
onie_grub_cfg=/mnt/onie-boot/onie/grub/grub-machine.cfg
if [ ! -e $onie_grub_cfg ]; then
echo "$onie_grub_cfg not found" >> /etc/migration.log
else
. ./$onie_grub_cfg
grep = $onie_grub_cfg | sed -e 's/onie_//' -e 's/=.*$//' | while read var ; do
eval val='$'onie_$var
echo "onie_${var}=${val}" >> /host/machine.conf
done
fi
umount /mnt/onie-boot
fi
. /host/machine.conf . /host/machine.conf
echo "install platform dependent packages at the first boot time" echo "install platform dependent packages at the first boot time"

View File

@ -27,6 +27,7 @@ echo " OK."
# Untar and launch install script in a tmpfs # Untar and launch install script in a tmpfs
cur_wd=$(pwd) cur_wd=$(pwd)
export cur_wd
archive_path=$(realpath "$0") archive_path=$(realpath "$0")
tmp_dir=$(mktemp -d) tmp_dir=$(mktemp -d)
if [ "$(id -u)" = "0" ] ; then if [ "$(id -u)" = "0" ] ; then

View File

@ -24,8 +24,25 @@ _trap_push true
set -e set -e
cd $(dirname $0) cd $(dirname $0)
if [ -d "/etc/sonic" ]; then
echo "Installing SONiC in SONiC"
install_env="sonic"
elif grep -Fxqs "DISTRIB_ID=onie" /etc/lsb-release > /dev/null
then
echo "Installing SONiC in ONIE"
install_env="onie"
else
echo "Installing SONiC in BUILD"
install_env="build"
fi
if [ -r ./machine.conf ]; then
. ./machine.conf . ./machine.conf
fi
if [ -r ./onie-image.conf ]; then
. ./onie-image.conf . ./onie-image.conf
fi
echo "ONIE Installer: platform: $platform" echo "ONIE Installer: platform: $platform"
@ -40,7 +57,7 @@ if [ -r /etc/machine.conf ]; then
. /etc/machine.conf . /etc/machine.conf
elif [ -r /host/machine.conf ]; then elif [ -r /host/machine.conf ]; then
. /host/machine.conf . /host/machine.conf
else elif [ "$install_env" != "build" ]; then
echo "cannot find machine.conf" echo "cannot find machine.conf"
exit 1 exit 1
fi fi
@ -58,26 +75,20 @@ ONIE_PLATFORM_EXTRA_CMDLINE_LINUX=""
# Default var/log device size in MB # Default var/log device size in MB
VAR_LOG_SIZE=4096 VAR_LOG_SIZE=4096
if [ -d "/etc/sonic" ]; then
echo "Installing SONiC in SONiC"
install_env="sonic"
else
echo "Installing SONiC in ONIE"
install_env="onie"
fi
[ -r platforms/$onie_platform ] && . platforms/$onie_platform [ -r platforms/$onie_platform ] && . platforms/$onie_platform
# Install demo on same block device as ONIE # Install demo on same block device as ONIE
onie_dev=$(blkid | grep ONIE-BOOT | head -n 1 | awk '{print $1}' | sed -e 's/:.*$//') if [ "$install_env" != "build" ]; then
blk_dev=$(echo $onie_dev | sed -e 's/[1-9][0-9]*$//' | sed -e 's/\([0-9]\)\(p\)/\1/') onie_dev=$(blkid | grep ONIE-BOOT | head -n 1 | awk '{print $1}' | sed -e 's/:.*$//')
# Note: ONIE has no mount setting for / with device node, so below will be empty string blk_dev=$(echo $onie_dev | sed -e 's/[1-9][0-9]*$//' | sed -e 's/\([0-9]\)\(p\)/\1/')
cur_part=$(cat /proc/mounts | awk "{ if(\$2==\"/\") print \$1 }" | grep $blk_dev || true) # Note: ONIE has no mount setting for / with device node, so below will be empty string
cur_part=$(cat /proc/mounts | awk "{ if(\$2==\"/\") print \$1 }" | grep $blk_dev || true)
[ -b "$blk_dev" ] || { [ -b "$blk_dev" ] || {
echo "Error: Unable to determine block device of ONIE install" echo "Error: Unable to determine block device of ONIE install"
exit 1 exit 1
} }
fi
# If running in ONIE # If running in ONIE
if [ "$install_env" = "onie" ]; then if [ "$install_env" = "onie" ]; then
@ -108,7 +119,7 @@ else
firmware="bios" firmware="bios"
fi fi
if [ "$install_env" != "sonic" ]; then if [ "$install_env" = "onie" ]; then
# determine ONIE partition type # determine ONIE partition type
onie_partition_type=$(${onie_bin} onie-sysinfo -t) onie_partition_type=$(${onie_bin} onie-sysinfo -t)
# demo partition size in MB # demo partition size in MB
@ -310,6 +321,7 @@ demo_install_grub()
cat $grub_install_log && rm -f $grub_install_log cat $grub_install_log && rm -f $grub_install_log
exit 1 exit 1
} }
rm -f $grub_install_log rm -f $grub_install_log
# restore immutable flag on the core.img file as discussed # restore immutable flag on the core.img file as discussed
@ -374,7 +386,7 @@ demo_install_uefi_grub()
image_dir="image-$image_version" image_dir="image-$image_version"
if [ "$install_env" != "sonic" ]; then if [ "$install_env" = "onie" ]; then
eval $create_demo_partition $blk_dev eval $create_demo_partition $blk_dev
demo_dev=$(echo $blk_dev | sed -e 's/\(mmcblk[0-9]\)/\1p/')$demo_part demo_dev=$(echo $blk_dev | sed -e 's/\(mmcblk[0-9]\)/\1p/')$demo_part
@ -391,7 +403,8 @@ if [ "$install_env" != "sonic" ]; then
echo "Error: Unable to mount $demo_dev on $demo_mnt" echo "Error: Unable to mount $demo_dev on $demo_mnt"
exit 1 exit 1
} }
else
elif [ "$install_env" = "sonic" ]; then
demo_mnt="/host" demo_mnt="/host"
running_sonic_revision=$(cat /etc/sonic/sonic_version.yml | grep build_version | cut -f2 -d" ") running_sonic_revision=$(cat /etc/sonic/sonic_version.yml | grep build_version | cut -f2 -d" ")
# Prevent installing existing SONiC if it is running # Prevent installing existing SONiC if it is running
@ -406,6 +419,15 @@ else
rm -rf $f rm -rf $f
fi fi
done done
else
demo_mnt="build_raw_image_mnt"
demo_dev=$cur_wd/"%%OUTPUT_RAW_IMAGE%%"
mkfs.ext4 $demo_dev
echo "Mounting $demo_dev on $demo_mnt..."
mkdir $demo_mnt
mount -t auto -o loop $demo_dev $demo_mnt
fi fi
echo "Installing SONiC to $demo_mnt/$image_dir" echo "Installing SONiC to $demo_mnt/$image_dir"
@ -446,7 +468,7 @@ if [ "$VAR_LOG_SIZE" != "0" ]; then
mkfs.ext4 -q $demo_mnt/disk-img/var-log.ext4 -F mkfs.ext4 -q $demo_mnt/disk-img/var-log.ext4 -F
fi fi
if [ "$install_env" != "sonic" ]; then if [ "$install_env" = "onie" ]; then
# Store machine description in target file system # Store machine description in target file system
cp /etc/machine.conf $demo_mnt cp /etc/machine.conf $demo_mnt
@ -547,7 +569,7 @@ menuentry '$demo_grub_entry' {
} }
EOF EOF
if [ "$install_env" != "sonic" ]; then if [ "$install_env" = "onie" ]; then
# Add menu entries for ONIE -- use the grub fragment provided by the # Add menu entries for ONIE -- use the grub fragment provided by the
# ONIE distribution. # ONIE distribution.
$onie_root_dir/grub.d/50_onie_grub >> $grub_cfg $onie_root_dir/grub.d/50_onie_grub >> $grub_cfg
@ -559,7 +581,11 @@ $onie_menuentry
EOF EOF
fi fi
cp $grub_cfg $onie_initrd_tmp/$demo_mnt/grub/grub.cfg if [ "$install_env" = "build" ]; then
umount $demo_mnt
else
cp $grub_cfg $onie_initrd_tmp/$demo_mnt/grub/grub.cfg
fi
cd / cd /

View File

@ -27,6 +27,12 @@ DOCKERFS_DIR=docker
## Output file name for onie installer ## Output file name for onie installer
OUTPUT_ONIE_IMAGE=target/sonic-$TARGET_MACHINE.bin OUTPUT_ONIE_IMAGE=target/sonic-$TARGET_MACHINE.bin
### Output file name for raw image
OUTPUT_RAW_IMAGE=target/sonic-$TARGET_MACHINE.raw
### Raw image size in MB
RAW_IMAGE_DISK_SIZE=8192
## Output file name for aboot installer ## Output file name for aboot installer
OUTPUT_ABOOT_IMAGE=target/sonic-aboot-$TARGET_MACHINE.swi OUTPUT_ABOOT_IMAGE=target/sonic-aboot-$TARGET_MACHINE.swi

View File

@ -83,11 +83,16 @@ cp onie-image.conf $tmp_installdir
# sed. Special chars are: \ / & # sed. Special chars are: \ / &
EXTRA_CMDLINE_LINUX=`echo $EXTRA_CMDLINE_LINUX | sed -e 's/[\/&]/\\\&/g'` EXTRA_CMDLINE_LINUX=`echo $EXTRA_CMDLINE_LINUX | sed -e 's/[\/&]/\\\&/g'`
output_raw_image=$(cat onie-image.conf | grep OUTPUT_RAW_IMAGE | cut -f2 -d"=")
[ -z "$TARGET_MACHINE" ] && output_raw_image=$(echo $output_raw_image | sed -e 's/$TARGET_MACHINE/$machine/g')
output_raw_image=$(eval echo $output_raw_image)
# Tailor the demo installer for OS mode or DIAG mode # Tailor the demo installer for OS mode or DIAG mode
sed -i -e "s/%%DEMO_TYPE%%/$demo_type/g" \ sed -i -e "s/%%DEMO_TYPE%%/$demo_type/g" \
-e "s/%%IMAGE_VERSION%%/$image_version/g" \ -e "s/%%IMAGE_VERSION%%/$image_version/g" \
-e "s/%%ONIE_IMAGE_PART_SIZE%%/$onie_image_part_size/" \ -e "s/%%ONIE_IMAGE_PART_SIZE%%/$onie_image_part_size/" \
-e "s/%%EXTRA_CMDLINE_LINUX%%/$EXTRA_CMDLINE_LINUX/" \ -e "s/%%EXTRA_CMDLINE_LINUX%%/$EXTRA_CMDLINE_LINUX/" \
-e "s@%%OUTPUT_RAW_IMAGE%%@$output_raw_image@" \
$tmp_installdir/install.sh || clean_up 1 $tmp_installdir/install.sh || clean_up 1
echo -n "." echo -n "."
cp -r $* $tmp_installdir || clean_up 1 cp -r $* $tmp_installdir || clean_up 1

View File

@ -0,0 +1,9 @@
# sonic broadcom raw image installer
SONIC_RAW_IMAGE = sonic-broadcom.raw
$(SONIC_RAW_IMAGE)_MACHINE = broadcom
$(SONIC_RAW_IMAGE)_IMAGE_TYPE = raw
$(SONIC_RAW_IMAGE)_DEPENDS += $(BRCM_OPENNSL_KERNEL)
$(SONIC_RAW_IMAGE)_INSTALLS += $($(SONIC_ONE_IMAGE)_INSTALLS)
$(SONIC_RAW_IMAGE)_DOCKERS += $(SONIC_INSTALL_DOCKER_IMAGES)
SONIC_INSTALLERS += $(SONIC_RAW_IMAGE)

View File

@ -11,6 +11,7 @@ include $(PLATFORM_PATH)/docker-orchagent-brcm.mk
include $(PLATFORM_PATH)/docker-syncd-brcm.mk include $(PLATFORM_PATH)/docker-syncd-brcm.mk
include $(PLATFORM_PATH)/docker-syncd-brcm-rpc.mk include $(PLATFORM_PATH)/docker-syncd-brcm-rpc.mk
include $(PLATFORM_PATH)/one-image.mk include $(PLATFORM_PATH)/one-image.mk
include $(PLATFORM_PATH)/raw-image.mk
include $(PLATFORM_PATH)/one-aboot.mk include $(PLATFORM_PATH)/one-aboot.mk
include $(PLATFORM_PATH)/libsaithrift-dev.mk include $(PLATFORM_PATH)/libsaithrift-dev.mk
include $(PLATFORM_PATH)/python-saithrift.mk include $(PLATFORM_PATH)/python-saithrift.mk