Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sonic installer script for armhf #3303

Merged
merged 11 commits into from
Sep 11, 2019
12 changes: 10 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,15 +83,23 @@ To build SONiC installer image and docker images, run the following commands:

## Usage for ARM Architecture
To build Arm32 bit for (ARMHF) plaform
ARM build has dependency in docker version 18,
if docker version is 19, downgrade to 18 as below
sudo apt-get install --allow-downgrades -y docker-ce=5:18.09.0~3-0~ubuntu-xenial
sudo apt-get install --allow-downgrades -y docker-ce-cli=5:18.09.0~3-0~ubuntu-xenial

# Execute make configure once to configure ASIC and ARCH

make configure PLATFORM=[ASIC_VENDOR] PLATFORM_ARCH=armhf

**example**:
make target/sonic-[ASIC_VENDER]-armhf.bin

# example:

make configure PLATFORM=marvell-armhf PLATFORM_ARCH=armhf

make target/sonic-marvell-armhf.bin



To build Arm64 bit for plaform
Expand All @@ -100,7 +108,7 @@ To build Arm64 bit for plaform

make configure PLATFORM=[ASIC_VENDOR] PLATFORM_ARCH=arm64

**example**:
# example:

make configure PLATFORM=marvell-arm64 PLATFORM_ARCH=arm64

Expand Down
89 changes: 5 additions & 84 deletions installer/armhf/install.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
#!/bin/sh

# Copyright (C) 2014,2015 Curt Brune <curt@cumulusnetworks.com>
# Copyright (C) 2015 david_yang <david_yang@accton.com>
# Copyright (C) Marvell Inc
#
# SPDX-License-Identifier: GPL-2.0

set -e

Expand Down Expand Up @@ -31,99 +29,22 @@ fi

echo "Installer: platform: $platform"

# install_uimage will be overriden from platform.conf as it is non generic
install_uimage() {
echo "Copying uImage to NOR flash:"
flashcp -v demo-${platform}.itb $mtd_dev
}

# hw_load will be overriden from platform.conf as it is non generic
hw_load() {
echo "cp.b $img_start \$loadaddr $img_sz"
}

. ./platform.conf

#install_uimage

#hw_load_str="$(hw_load)"

echo "Copying uImage to NAND flash:"
# global mount defines
demo_dev=ubi0
mtd_dev=/dev/$(cat /proc/mtd | grep "SONIC" | grep -o "mtd[0-9]")
mtd_num=$(echo $mtd_dev | grep -o "[0-9]")
demo_mount=/tmp
onie_dev=$(blkid | grep ONIE-BOOT | head -n 1 | awk '{print $1}' | sed -e 's/:.*$//')

echo "Format mtd partition '$mtd_dev'"
ubiformat $mtd_dev
#attaches MTD devices (which describe raw flash) to UBI and creates corresponding UBI devices; ('-m 2' --> mtd2)
echo "ubiattach mtd '$mtd_num'"
ubiattach /dev/ubi_ctrl -m $mtd_num
#creates UBI volumes on UBI devices
ubimkvol /dev/$demo_dev -N $demo_dev -s 3700MiB

demo_mount=$(mktemp -d)
mkdir -p $demo_mount
echo "Mounting ubifs partition"
mount -t ubifs /dev/ubi0_0 $demo_mount
echo "Mounting $demo_dev on $demo_mount..."
echo "sonic extract image starts ..."
# Decompress the file for the file system directly to the partition
unzip -o $ONIE_INSTALLER_PAYLOAD -x "$FILESYSTEM_DOCKERFS" -d $demo_mount/
cd $demo_mount
if [ -f fs.cpio ]
then
cpio -id < fs.cpio
rm fs.cpio
elif [ -f fs.squashfs ]
then
unsquashfs -f -d $demo_mount fs.squashfs
rm -f fs.squashfs
fi
cd -
TAR_EXTRA_OPTION="--numeric-owner"
mkdir -p $demo_mount/var/lib/$DOCKERFS_DIR
unzip -op $ONIE_INSTALLER_PAYLOAD "$FILESYSTEM_DOCKERFS" | tar -xpz $TAR_EXTRA_OPTION -f - -C $demo_mount/var/lib/$DOCKERFS_DIR

echo "unmounting nand partition"
umount $demo_mount

echo "Updating U-Boot environment variables"
#global uboot enviroment settings
FW_ENV='/dev/mtd0 \t\t 0x00500000 \t 0x80000 \t 0x100000 \t 8'

kernel_addr=0x1100000
fdt_addr=0x1000000

image_name="/boot/zImage"
fdt_name="/boot/armada-385-ET6448M_4G_Nand.dtb"

#BOOTARGS='setenv bootargs root='$demo_dev' rw rootwait ubi.mtd='$mtd_num' rootfstype=ubifs debug panic=1 ip=${ipaddr}:${serverip}:${gatewayip}:${netmask}:${hostname}:${netdev}:off console=ttyS0,115200 ${othbootargs} ${mtdparts}'
BOOTARGS='setenv bootargs root='$demo_dev' rw rootwait ubi.mtd='$mtd_num' rootfstype=ubifs panic=1 console=ttyS0,115200 ${othbootargs} ${mtdparts}'
UBI_LOAD='run ubi_sonic_boot_mount_ubi; ubifsload $kernel_addr $image_name;ubifsload $fdt_addr $fdt_name'
UBIBOOTCMD='run ubi_sonic_boot_bootargs; run ubi_sonic_boot_load; bootz $kernel_addr - $fdt_addr'


echo -e $FW_ENV > /etc/fw_env.config

fw_setenv -f image_name $image_name > /dev/null
fw_setenv -f fdt_name $fdt_name > /dev/null
fw_setenv -f kernel_addr $kernel_addr > /dev/null
fw_setenv -f fdt_addr $fdt_addr > /dev/null

#make sure ubi number (0) and ubi volume name (ubi0) are set correctly in bootargs_root:
#For example, the below command creates an 3000MiB volume on UBI device 0:
#setenv bootargs_root root=ubi0:ubi0 rw ubi.mtd=2 rootfstype=ubifs

fw_setenv -f mtdids 'nand0=armada-nand' > /dev/null
fw_setenv -f mtdparts 'mtdparts=armada-nand:10m(U-Boot)ro,208m@10m(ONIE),-(SONIC)' > /dev/null
fw_setenv -f ubi_sonic_boot_mount_ubi 'ubi part SONIC; ubifsmount ubi0' > /dev/null

fw_setenv -f ubi_sonic_boot_bootargs $BOOTARGS > /dev/null
fw_setenv -f ubi_sonic_boot_load $UBI_LOAD > /dev/null
fw_setenv -f ubi_sonic_boot $UBIBOOTCMD > /dev/null
fw_setenv -f bootcmd 'usb start; run ubi_sonic_boot' > /dev/null
install_uimage

hw_load_str="$(hw_load)"

cd /

Expand Down
4 changes: 2 additions & 2 deletions platform/marvell-armhf/one-image.mk
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# sonic marvell one image installer

SONIC_ONE_IMAGE = sonic-marvell.bin
$(SONIC_ONE_IMAGE)_MACHINE = marvell
SONIC_ONE_IMAGE = sonic-marvell-armhf.bin
$(SONIC_ONE_IMAGE)_MACHINE = marvell-armhf
$(SONIC_ONE_IMAGE)_IMAGE_TYPE = onie
$(SONIC_ONE_IMAGE)_INSTALLS += $(SYSTEMD_SONIC_GENERATOR)
ifeq ($(INSTALL_DEBUG_TOOLS),y)
Expand Down
143 changes: 143 additions & 0 deletions platform/marvell-armhf/platform.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
# Copyright (C) Marvell Inc

# over ride default behaviour

echo "Preparing for installation ... "

# global defines
kernel_addr=0x1100000
fdt_addr=0x1000000

image_name="/boot/zImage"
fdt_name="/boot/armada-385-ET6448M_4G_Nand.dtb"

# global mount defines
demo_dev=ubi0
mtd_dev=/dev/$(cat /proc/mtd | grep "SONIC" | grep -o "mtd[0-9]")
mtd_num=$(echo $mtd_dev | grep -o "[0-9]")
demo_mount=/tmp
FW_ENV='/dev/mtd0 \t\t 0x00500000 \t 0x80000 \t 0x100000 \t 8'

BOOTARGS='setenv bootargs root='$demo_dev' rw rootwait ubi.mtd='$mtd_num' rootfstype=ubifs panic=1 console=ttyS0,115200 ${othbootargs} ${mtdparts}'
UBI_LOAD='run ubi_sonic_boot_mount_ubi; ubifsload $kernel_addr $image_name;ubifsload $fdt_addr $fdt_name'
UBIBOOTCMD='run ubi_sonic_boot_bootargs; run ubi_sonic_boot_load; bootz $kernel_addr - $fdt_addr'

et6448m_machine_conf() {
SYSCTL_CFG=$demo_mount/usr/share/sonic/device/armhf-marvell_et6448m_52x-r0/syncd.conf

echo "Configure platform et6448m "
rm $demo_mount/lib/udev/rules.d/73-usb-net-by-mac.rules
rm -f $demo_mount/usr/bin/reboot || true
rm -fr $demo_mount/host/machine.conf
cp /etc/machine.conf $demo_mount/host/

SONIC_VERSION=$(cat $demo_mount/etc/sonic/sonic_version.yml | grep build_version | cut -f2 -d"'")
FIRST_BOOT_FILE="$demo_mount/host/image-$SONIC_VERSION/platform"
mkdir -p $FIRST_BOOT_FILE
touch $FIRST_BOOT_FILE/firsttime

MAC_ADDR=$(fw_printenv | grep ^ethaddr= | cut -f2 -d"=")
sed -i "s/switchMacAddress=.*/switchMacAddress=$MAC_ADDR/g" $demo_mount/usr/share/sonic/device/armhf-marvell_et6448m_52x-r0/et6448m/profile.ini

# IPv4 and IPv6 arp cache limits
echo "sysctl -w net.ipv4.neigh.default.gc_thresh1=16000" >> $SYSCTL_CFG
echo "sysctl -w net.ipv4.neigh.default.gc_thresh2=32000" >> $SYSCTL_CFG
echo "sysctl -w net.ipv4.neigh.default.gc_thresh3=48000" >> $SYSCTL_CFG
echo "sysctl -w net.ipv6.neigh.default.gc_thresh1=8000 " >> $SYSCTL_CFG
echo "sysctl -w net.ipv6.neigh.default.gc_thresh2=16000" >> $SYSCTL_CFG
echo "sysctl -w net.ipv6.neigh.default.gc_thresh3=32000" >> $SYSCTL_CFG
}

prepare_uboot() {
echo "Setting up U-Boot environment..."

echo -e $FW_ENV > /etc/fw_env.config

fw_setenv -f image_name $image_name > /dev/null
fw_setenv -f fdt_name $fdt_name > /dev/null
fw_setenv -f kernel_addr $kernel_addr > /dev/null
fw_setenv -f fdt_addr $fdt_addr > /dev/null

#make sure ubi number (0) and ubi volume name (ubi0) are set correctly in bootargs_root:
#For example, the below command creates an 3000MiB volume on UBI device 0:
#setenv bootargs_root root=ubi0:ubi0 rw ubi.mtd=2 rootfstype=ubifs

fw_setenv -f mtdids 'nand0=armada-nand' > /dev/null
fw_setenv -f mtdparts 'mtdparts=armada-nand:10m(U-Boot)ro,20m@10m(ONIE),-(SONIC)' > /dev/null
fw_setenv -f ubi_sonic_boot_mount_ubi 'ubi part SONIC; ubifsmount ubi0' > /dev/null

fw_setenv -f ubi_sonic_boot_bootargs $BOOTARGS > /dev/null
fw_setenv -f ubi_sonic_boot_load $UBI_LOAD > /dev/null
fw_setenv -f ubi_sonic_boot $UBIBOOTCMD > /dev/null
fw_setenv -f bootcmd 'usb start; run ubi_sonic_boot' > /dev/null

}

install_uimage() {

ubidetach /dev/ubi_ctrl -m $mtd_num 2>/dev/null || true

echo -en "Format mtd partition '$mtd_dev' "
ubiformat $mtd_dev -y -q || {
echo "Failed"
}

#attaches MTD devices (which describe raw flash) to UBI and creates corresponding UBI devices; ('-m 2' --> mtd2)
echo -en "ubiattach mtd '$mtd_num' "
ubiattach /dev/ubi_ctrl -m $mtd_num || {
echo "Failed"
}

#creates UBI volumes on UBI devices
ubimkvol /dev/$demo_dev -N $demo_dev -s 3900MiB

demo_mount=$(mktemp -d) || {
echo "Error: Unable to create file sstem mount point"
exit 1
}

echo "Mounting $demo_dev on $demo_mount "
mount -t ubifs /dev/ubi0_0 $demo_mount || {
echo "Failed"
}

echo "Extracting NOS "

# Decompress the file for the file system directly to the partition
unzip -o $ONIE_INSTALLER_PAYLOAD -x "$FILESYSTEM_DOCKERFS" -d $demo_mount/
cd $demo_mount

if [ -f fs.cpio ]; then
cpio -id < fs.cpio
if [ $? -ne 0 ]; then
echo "cpio extraction Failed"
fi
rm fs.cpio
elif [ -f fs.squashfs ]; then
unsquashfs -f -d $demo_mount $FILESYSTEM_SQUASHFS
antony-rheneus marked this conversation as resolved.
Show resolved Hide resolved
if [ $? -ne 0 ]; then
echo "unsquashfs extraction Failed"
fi
rm -f $FILESYSTEM_SQUASHFS
fi

cd -
TAR_EXTRA_OPTION="--numeric-owner"
mkdir -p $demo_mount/var/lib/$DOCKERFS_DIR
unzip -op $ONIE_INSTALLER_PAYLOAD "$FILESYSTEM_DOCKERFS" | tar -xpz $TAR_EXTRA_OPTION -f - -C $demo_mount/var/lib/$DOCKERFS_DIR

# Update uboot Environment
prepare_uboot

# Platform configuration
et6448m_machine_conf

# Unmounting mount path
umount $demo_mount

echo "Reboot board to boot from installed OS"
}

hw_load() {
echo "mtdpart default && ubi part SONIC && ubifsmount 'demo_dev' && ubifsload '$kernel_addr' 'image_name'"
}