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

[initramfs] Updated required tools for initramfs #3734

Merged
merged 8 commits into from
Jan 15, 2020
19 changes: 19 additions & 0 deletions build_debian.sh
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,11 @@ sudo chmod +x $FILESYSTEM_ROOT/etc/initramfs-tools/scripts/init-bottom/varlog
sudo cp files/initramfs-tools/union-fsck $FILESYSTEM_ROOT/etc/initramfs-tools/hooks/union-fsck
sudo chmod +x $FILESYSTEM_ROOT/etc/initramfs-tools/hooks/union-fsck
pushd $FILESYSTEM_ROOT/usr/share/initramfs-tools/scripts/init-bottom && sudo patch -p1 < $OLDPWD/files/initramfs-tools/udev.patch; popd
if [[ $CONFIGURED_ARCH == armhf || $CONFIGURED_ARCH == arm64 ]]; then
sudo cp files/initramfs-tools/uboot-utils $FILESYSTEM_ROOT/etc/initramfs-tools/hooks/uboot-utils
sudo chmod +x $FILESYSTEM_ROOT/etc/initramfs-tools/hooks/uboot-utils
cat files/initramfs-tools/modules.arm | sudo tee -a $FILESYSTEM_ROOT/etc/initramfs-tools/modules > /dev/null
fi

if [[ $CONFIGURED_ARCH == amd64 ]]; then
## Install latest intel ixgbe driver
Expand Down Expand Up @@ -499,8 +504,22 @@ fi
## Remove gcc and python dev pkgs
sudo LANG=C DEBIAN_FRONTEND=noninteractive chroot $FILESYSTEM_ROOT apt-get -y remove gcc libpython2.7-dev

## Add mtd and uboot firmware tools package
sudo LANG=C chroot $FILESYSTEM_ROOT apt-get -y install u-boot-tools mtd-utils
sudo LANG=C chroot $FILESYSTEM_ROOT apt-mark manual u-boot-tools mtd-utils

## Update initramfs
sudo chroot $FILESYSTEM_ROOT update-initramfs -u
## Convert initrd image to u-boot format
if [[ $CONFIGURED_ARCH == armhf || $CONFIGURED_ARCH == arm64 ]]; then
INITRD_FILE=initrd.img-${LINUX_KERNEL_VERSION}-${CONFIGURED_ARCH}
if [[ $CONFIGURED_ARCH == armhf ]]; then
INITRD_FILE=initrd.img-${LINUX_KERNEL_VERSION}-armmp
fi
sudo LANG=C chroot $FILESYSTEM_ROOT mkimage -A arm -O linux -T ramdisk -C gzip -d /boot/$INITRD_FILE /boot/u${INITRD_FILE}
## Overwriting the initrd image with uInitrd
sudo LANG=C chroot $FILESYSTEM_ROOT mv /boot/u${INITRD_FILE} /boot/$INITRD_FILE
fi

## Clean up apt
sudo LANG=C chroot $FILESYSTEM_ROOT apt-get -y autoremove
Expand Down
106 changes: 53 additions & 53 deletions device/marvell/armhf-marvell_et6448m_52x-r0/et6448m/port_config.ini
Original file line number Diff line number Diff line change
@@ -1,53 +1,53 @@
# name lanes alias
Ethernet0 1 Ethernet0
Ethernet1 2 Ethernet1
Ethernet2 3 Ethernet2
Ethernet3 4 Ethernet3
Ethernet4 5 Ethernet4
Ethernet5 6 Ethernet5
Ethernet6 7 Ethernet6
Ethernet7 8 Ethernet7
Ethernet8 9 Ethernet8
Ethernet9 10 Ethernet9
Ethernet10 11 Ethernet10
Ethernet11 12 Ethernet11
Ethernet12 13 Ethernet12
Ethernet13 14 Ethernet13
Ethernet14 15 Ethernet14
Ethernet15 16 Ethernet15
Ethernet16 17 Ethernet16
Ethernet17 18 Ethernet17
Ethernet18 19 Ethernet18
Ethernet19 20 Ethernet19
Ethernet20 21 Ethernet20
Ethernet21 22 Ethernet21
Ethernet22 23 Ethernet22
Ethernet23 24 Ethernet23
Ethernet24 25 Ethernet24
Ethernet25 26 Ethernet25
Ethernet26 27 Ethernet26
Ethernet27 28 Ethernet27
Ethernet28 29 Ethernet28
Ethernet29 30 Ethernet29
Ethernet30 31 Ethernet30
Ethernet31 32 Ethernet31
Ethernet32 33 Ethernet32
Ethernet33 34 Ethernet33
Ethernet34 35 Ethernet34
Ethernet35 36 Ethernet35
Ethernet36 37 Ethernet36
Ethernet37 38 Ethernet37
Ethernet38 39 Ethernet38
Ethernet39 40 Ethernet39
Ethernet40 41 Ethernet40
Ethernet41 42 Ethernet41
Ethernet42 43 Ethernet42
Ethernet43 44 Ethernet43
Ethernet44 45 Ethernet44
Ethernet45 46 Ethernet45
Ethernet46 47 Ethernet46
Ethernet47 48 Ethernet47
Ethernet48 49 Ethernet48
Ethernet49 50 Ethernet49
Ethernet50 51 Ethernet50
Ethernet51 52 Ethernet51
# name lanes alias index speed
Ethernet0 1 Ethernet0 1 1000
Ethernet1 2 Ethernet1 2 1000
Ethernet2 3 Ethernet2 3 1000
Ethernet3 4 Ethernet3 4 1000
Ethernet4 5 Ethernet4 5 1000
Ethernet5 6 Ethernet5 6 1000
Ethernet6 7 Ethernet6 7 1000
Ethernet7 8 Ethernet7 8 1000
Ethernet8 9 Ethernet8 9 1000
Ethernet9 10 Ethernet9 10 1000
Ethernet10 11 Ethernet10 11 1000
Ethernet11 12 Ethernet11 12 1000
Ethernet12 13 Ethernet12 13 1000
Ethernet13 14 Ethernet13 14 1000
Ethernet14 15 Ethernet14 15 1000
Ethernet15 16 Ethernet15 16 1000
Ethernet16 17 Ethernet16 17 1000
Ethernet17 18 Ethernet17 18 1000
Ethernet18 19 Ethernet18 19 1000
Ethernet19 20 Ethernet19 20 1000
Ethernet20 21 Ethernet20 21 1000
Ethernet21 22 Ethernet21 22 1000
Ethernet22 23 Ethernet22 23 1000
Ethernet23 24 Ethernet23 24 1000
Ethernet24 25 Ethernet24 25 1000
Ethernet25 26 Ethernet25 26 1000
Ethernet26 27 Ethernet26 27 1000
Ethernet27 28 Ethernet27 28 1000
Ethernet28 29 Ethernet28 29 1000
Ethernet29 30 Ethernet29 30 1000
Ethernet30 31 Ethernet30 31 1000
Ethernet31 32 Ethernet31 32 1000
Ethernet32 33 Ethernet32 33 1000
Ethernet33 34 Ethernet33 34 1000
Ethernet34 35 Ethernet34 35 1000
Ethernet35 36 Ethernet35 36 1000
Ethernet36 37 Ethernet36 37 1000
Ethernet37 38 Ethernet37 38 1000
Ethernet38 39 Ethernet38 39 1000
Ethernet39 40 Ethernet39 40 1000
Ethernet40 41 Ethernet40 41 1000
Ethernet41 42 Ethernet41 42 1000
Ethernet42 43 Ethernet42 43 1000
Ethernet43 44 Ethernet43 44 1000
Ethernet44 45 Ethernet44 45 1000
Ethernet45 46 Ethernet45 46 1000
Ethernet46 47 Ethernet46 47 1000
Ethernet47 48 Ethernet47 48 1000
Ethernet48 49 Ethernet48 49 10000
Ethernet49 50 Ethernet49 50 10000
Ethernet50 51 Ethernet50 51 10000
Ethernet51 52 Ethernet51 52 10000
17 changes: 8 additions & 9 deletions device/marvell/armhf-marvell_et6448m_52x-r0/fancontrol
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
INTERVAL=10
DEVPATH=hwmon0=devices/platform/soc/soc:internal-regs/f1011000.i2c/i2c-0/0-002e hwmon1=devices/platform/soc/soc:internal-regs/f1011000.i2c/i2c-0/0-004a hwmon2=devices/platform/soc/soc:internal-regs/f1011000.i2c/i2c-0/0-004b
DEVNAME=hwmon0=adt7473 hwmon1=lm75a hwmon2=lm75a
FCTEMPS=hwmon0/device/pwm2=hwmon2/temp1_input hwmon0/device/pwm1=hwmon1/temp1_input
FCFANS=hwmon0/device/pwm2=hwmon0/device/fan2_input hwmon0/device/pwm1=hwmon0/device/fan1_input
MINTEMP=hwmon0/device/pwm2=20 hwmon0/device/pwm1=20
MAXTEMP=hwmon0/device/pwm2=60 hwmon0/device/pwm1=60
MINSTART=hwmon0/device/pwm2=150 hwmon0/device/pwm1=150
MINSTOP=hwmon0/device/pwm2=0 hwmon0/device/pwm1=0

DEVPATH=hwmon1=devices/platform/soc/soc:internal-regs/f1011000.i2c/i2c-0/0-002e
DEVNAME=hwmon1=adt7473
FCTEMPS=hwmon1/device/pwm1=hwmon1/device/temp1_input hwmon1/device/pwm2=hwmon1/device/temp2_input
FCFANS=hwmon1/device/pwm1= hwmon1/device/pwm2=hwmon1/device/fan1_input
MINTEMP=hwmon1/device/pwm1=20 hwmon1/device/pwm2=20
MAXTEMP=hwmon1/device/pwm1=60 hwmon1/device/pwm2=60
MINSTART=hwmon1/device/pwm1=150 hwmon1/device/pwm2=150
MINSTOP=hwmon1/device/pwm1=0 hwmon1/device/pwm2=0
7 changes: 7 additions & 0 deletions files/initramfs-tools/modules.arm
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
crc16
deflate
zlib_deflate
m25p80
ubi
ubifs
squashfs
21 changes: 21 additions & 0 deletions files/initramfs-tools/uboot-utils
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/sh
#Part of the code is revised based on initramfs-tool is under GPL v2.

PREREQ=""

prereqs()
{
echo "$PREREQ"
}

case $1 in
prereqs)
prereqs
exit 0
;;
esac

. /usr/share/initramfs-tools/hook-functions

copy_exec /usr/sbin/ubiattach /sbin/ubiattach
copy_exec /usr/sbin/mtdinfo /sbin/mtdinfo
15 changes: 13 additions & 2 deletions files/initramfs-tools/union-mount.j2
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,19 @@ mkdir -p ${rootmnt}/host/$image_dir/work
mount -n -o lowerdir=${rootmnt},upperdir=${rootmnt}/host/$image_dir/rw,workdir=${rootmnt}/host/$image_dir/work -t overlay root-overlay ${rootmnt}
## Check if the root block device is still there
[ -b ${ROOT} ] || mdev -s
## Mount the raw partition again
mount ${ROOT} ${rootmnt}/host
case "${ROOT}" in
ubi*)
mtd=$(cat /proc/cmdline | sed -e 's/.*ubi.mtd=\([0-9]\) .*/\1/')
if [ ! -f /dev/${ROOT}_0 ]; then
ubiattach /dev/ubi_ctrl -m $mtd || true
fi
mount -t ubifs /dev/${ROOT}_0 ${rootmnt}/host
;;
*)
## Mount the raw partition again
mount ${ROOT} ${rootmnt}/host
;;
esac

mkdir -p ${rootmnt}/var/lib/docker
if [ -f ${rootmnt}/host/$image_dir/{{ FILESYSTEM_DOCKERFS }} ]; then
Expand Down
10 changes: 9 additions & 1 deletion files/initramfs-tools/varlog
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,12 @@ if [ -e "${rootmnt}/host/disk-img/var-log.ext4" ]; then
fi

# create varlog disk
mkdir -p ${rootmnt}/host/disk-img && ${rootmnt}/usr/bin/fallocate -l "$varlog_size"M ${rootmnt}/host/disk-img/var-log.ext4 && mkfs.ext4 -q -F ${rootmnt}/host/disk-img/var-log.ext4
case "${ROOT}" in
ubi*)
# sys_fallocate is NOT supported over UBIFS
mkdir -p ${rootmnt}/host/disk-img && ${rootmnt}/usr/bin/truncate -s "$varlog_size"M ${rootmnt}/host/disk-img/var-log.ext4 && mkfs.ext4 -q -F ${rootmnt}/host/disk-img/var-log.ext4
;;
*)
mkdir -p ${rootmnt}/host/disk-img && ${rootmnt}/usr/bin/fallocate -l "$varlog_size"M ${rootmnt}/host/disk-img/var-log.ext4 && mkfs.ext4 -q -F ${rootmnt}/host/disk-img/var-log.ext4
;;
esac
134 changes: 121 additions & 13 deletions installer/armhf/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,17 @@
# Copyright (C) Marvell Inc
#

_trap_push() {
local next="$1"
eval "trap_push() {
local oldcmd='$(echo "$next" | sed -e s/\'/\'\\\\\'\'/g)'
local newcmd=\"\$1; \$oldcmd\"
trap -- \"\$newcmd\" EXIT INT TERM HUP
_trap_push \"\$newcmd\"
}"
}
_trap_push true

set -e

if [ -d "/etc/sonic" ]; then
Expand All @@ -26,27 +37,124 @@ if [ -r ./onie-image-armhf.conf ]; then
. ./onie-image-armhf.conf
fi

echo "ONIE Installer: platform: $platform"

echo "Installer: platform: $platform"
# Make sure run as root or under 'sudo'
if [ $(id -u) -ne 0 ]
then echo "Please run as root"
exit 1
fi

# 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
}
if [ -r /etc/machine.conf ]; then
. /etc/machine.conf
elif [ -r /host/machine.conf ]; then
. /host/machine.conf
elif [ "$install_env" != "build" ]; then
echo "cannot find machine.conf"
exit 1
fi

echo "onie_platform: $onie_platform"

# Get platform specific linux kernel command line arguments
ONIE_PLATFORM_EXTRA_CMDLINE_LINUX=""

# Default var/log device size in MB
VAR_LOG_SIZE=4096

[ -r platforms/$onie_platform ] && . platforms/$onie_platform


# If running in ONIE
if [ "$install_env" = "onie" ]; then
# The onie bin tool prefix
onie_bin=
# The persistent ONIE directory location
onie_root_dir=/mnt/onie-boot/onie
# The onie file system root
onie_initrd_tmp=/
fi

# The build system prepares this script by replacing %%DEMO-TYPE%%
# with "OS" or "DIAG".
demo_type="%%DEMO_TYPE%%"

# The build system prepares this script by replacing %%IMAGE_VERSION%%
# with git revision hash as a version identifier
image_version="%%IMAGE_VERSION%%"
timestamp="$(date -u +%Y%m%d)"

demo_volume_label="SONiC-${demo_type}"
demo_volume_revision_label="SONiC-${demo_type}-${image_version}"

# 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
image_dir="image-$image_version"

if [ "$install_env" = "onie" ]; then
# Create/format the flash
create_partition
mount_partition
elif [ "$install_env" = "sonic" ]; then
demo_mnt="/host"
eval running_sonic_revision=$(cat /etc/sonic/sonic_version.yml | grep build_version | cut -f2 -d" ")
# Prevent installing existing SONiC if it is running
if [ "$image_dir" = "image-$running_sonic_revision" ]; then
echo "Not installing SONiC version $running_sonic_revision, as current running SONiC has the same version"
exit 0
fi
# Remove extra SONiC images if any
for f in $demo_mnt/image-* ; do
if [ -d $f ] && [ "$f" != "$demo_mnt/image-$running_sonic_revision" ] && [ "$f" != "$demo_mnt/$image_dir" ]; then
echo "Removing old SONiC installation $f"
rm -rf $f
fi
done
fi

# Create target directory or clean it up if exists
if [ -d $demo_mnt/$image_dir ]; then
echo "Directory $demo_mnt/$image_dir/ already exists. Cleaning up..."
rm -rf $demo_mnt/$image_dir/*
else
mkdir $demo_mnt/$image_dir || {
echo "Error: Unable to create SONiC directory"
exit 1
}
fi

hw_load_str="$(hw_load)"
# Decompress the file for the file system directly to the partition
if [ x"$docker_inram" = x"on" ]; then
# when disk is small, keep dockerfs.tar.gz in disk, expand it into ramfs during initrd
unzip -o $ONIE_INSTALLER_PAYLOAD -d $demo_mnt/$image_dir
else
unzip -o $ONIE_INSTALLER_PAYLOAD -x "$FILESYSTEM_DOCKERFS" -d $demo_mnt/$image_dir

if [ "$install_env" = "onie" ]; then
TAR_EXTRA_OPTION="--numeric-owner"
else
TAR_EXTRA_OPTION="--numeric-owner --warning=no-timestamp"
fi
mkdir -p $demo_mnt/$image_dir/$DOCKERFS_DIR
unzip -op $ONIE_INSTALLER_PAYLOAD "$FILESYSTEM_DOCKERFS" | tar xz $TAR_EXTRA_OPTION -f - -C $demo_mnt/$image_dir/$DOCKERFS_DIR
fi


if [ "$install_env" = "onie" ]; then
# Store machine description in target file system
if [ -f /etc/machine-build.conf ]; then
# onie_ variable are generate at runtime.
# they are no longer hardcoded in /etc/machine.conf
# also remove single quotes around the value
set | grep ^onie | sed -e "s/='/=/" -e "s/'$//" > $demo_mnt/machine.conf
else
cp /etc/machine.conf $demo_mnt
fi
fi

cd /
# Update Bootloader Menu with installed image
bootloader_menu_config

# Set NOS mode if available. For manufacturing diag installers, you
# probably want to skip this step so that the system remains in ONIE
Expand Down
3 changes: 3 additions & 0 deletions onie-image-armhf.conf
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ FILESYSTEM_DOCKERFS=dockerfs.tar.gz
## docker directory on the root filesystem
DOCKERFS_DIR=docker

## docker ramfs disk space
DOCKER_RAMFS_SIZE=900M

## Output file name for onie installer
OUTPUT_ONIE_IMAGE=target/sonic-$TARGET_MACHINE.bin

Expand Down
Loading