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

Adding platform files for tg48m-p and tg4810m #33

Open
wants to merge 6 commits into
base: target_master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions build_debian.sh
Original file line number Diff line number Diff line change
Expand Up @@ -536,6 +536,7 @@ if [[ $CONFIGURED_ARCH == armhf || $CONFIGURED_ARCH == arm64 ]]; then
elif [[ $CONFIGURED_ARCH == arm64 ]]; then
sudo cp -v $PLATFORM_DIR/${sonic_asic_platform}-${CONFIGURED_ARCH}/sonic_fit.its $FILESYSTEM_ROOT/boot/
sudo LANG=C chroot $FILESYSTEM_ROOT mkimage -f /boot/sonic_fit.its /boot/sonic_${CONFIGURED_ARCH}.fit

fi
fi

Expand Down
1 change: 1 addition & 0 deletions platform/marvell-arm64/one-image.mk
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ $(SONIC_ONE_IMAGE)_MACHINE = marvell-arm64
$(SONIC_ONE_IMAGE)_IMAGE_TYPE = onie
$(SONIC_ONE_IMAGE)_INSTALLS += $(SYSTEMD_SONIC_GENERATOR)
$(SONIC_ONE_IMAGE)_INSTALLS += $(LINUX_KERNEL_DTB)
$(SONIC_ONE_IMAGE)_LAZY_INSTALLS += $(TG48M-P_PLATFORM) $(TG4810M_PLATFORM)
ifeq ($(INSTALL_DEBUG_TOOLS),y)
$(SONIC_ONE_IMAGE)_DOCKERS += $(SONIC_INSTALL_DOCKER_DBG_IMAGES)
$(SONIC_ONE_IMAGE)_DOCKERS += $(filter-out $(patsubst %-$(DBG_IMAGE_MARK).gz,%.gz, $(SONIC_INSTALL_DOCKER_DBG_IMAGES)), $(SONIC_INSTALL_DOCKER_IMAGES))
Expand Down
144 changes: 106 additions & 38 deletions platform/marvell-arm64/platform.conf
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,64 @@ initrd_fname="/boot/initrd.img-4.9.0-9-2-arm64"
fdt_fname="/boot/armada-7020-comexpress.dtb"
fit_fname="/boot/sonic_arm64.fit"

if [ "$install_env" = "onie" ]; then
MACH_FILE="/etc/machine.conf"
else
MACH_FILE="/host/machine.conf"
fi

PLATFORM=`sed -n 's/onie_platform=\(.*\)/\1/p' $MACH_FILE`
echo "Intalling SONiC from $install_env on Platform $PLATFORM"

# global mount defines
#demo_dev=/dev/sda1
demo_mnt=/tmp
#mtd_dev=/dev/$(cat /proc/mtd | grep "ENV" | grep -o "mtd[0-9]")
FW_ENV_DEFAULT='/dev/mtd1 0x0 0x10000 0x100000'
UBOOT_FW_DEFAULT=1

# Skip VID Header in UBIFS
LINUX_MISC_CMD='apparmor=1 security=apparmor usbcore.autosuspend=-1'

if [ "$PLATFORM" = "arm64-delta_tg48m_poe-r0" ] || [ "$PLATFORM" = "arm64-delta_tg4810m-r0" ]; then

demo_dev=/dev/sda2
SONIC_LOAD='scsi scan; ext4load scsi 0:2 $fit_addr $fit_name'
SONIC_LOAD_OLD='scsi scan; ext4load scsi 0:2 $fit_addr $fit_name_old'
BOOTARGS='setenv bootargs root='$demo_dev' rw rootwait rootfstype=ext4 panic=1 console=ttyS0,115200 ${othbootargs} ${mtdparts} ${linuxargs}'
BOOTARGS_OLD='setenv bootargs root='$demo_dev' rw rootwait rootfstype=ext4 panic=1 console=ttyS0,115200 ${othbootargs} ${mtdparts} ${linuxargs_old}'
if [ "$PLATFORM" = "arm64-delta_tg4810m-r0" ]; then
SONIC_BOOT_CMD='run sonic_bootargs; run sonic_boot_load; test -n "$boot_once" && setenv boot_once "" && saveenv; bootm $fit_addr#delta_tg4810m'
SONIC_BOOT_CMD_OLD='run sonic_bootargs_old; run sonic_boot_load_old; test -n "$boot_once" && setenv boot_once "" && saveenv; bootm $fit_addr#delta_tg4810m'
else
SONIC_BOOT_CMD='run sonic_bootargs; run sonic_boot_load; test -n "$boot_once" && setenv boot_once "" && saveenv; bootm $fit_addr#delta_tg48m_poe'
SONIC_BOOT_CMD_OLD='run sonic_bootargs_old; run sonic_boot_load_old; test -n "$boot_once" && setenv boot_once "" && saveenv; bootm $fit_addr#delta_tg48m_poe'
fi

else

mass_bus="target0:0:0"
for i in a b c ; do
if $(ls -l /sys/block/sd$i/device 2>/dev/null | grep -q "$mass_bus") ; then
blk_dev=/dev/sd$i
IS_MASS=1
fi
done

if [ ${IS_MASS} -eq 1 ]; then
demo_dev=${blk_dev}1
SONIC_LOAD='ext4load usb 0 $fit_addr $fit_name'
SONIC_LOAD_OLD='ext4load usb 0 $fit_addr $fit_name_old'
else
demo_dev=/dev/mmcblk0p1
SONIC_LOAD='ext4load mmc 0:'$demo_part' $fit_addr $fit_name'
SONIC_LOAD_OLD='ext4load mmc 0:'$demo_part' $fit_addr $fit_name'
fi

SONIC_BOOT_CMD='run sonic_bootargs; run sonic_boot_load; bootm $fit_addr'
SONIC_BOOT_CMD_OLD='run sonic_bootargs_old; run sonic_boot_load_old; bootm $fit_addr'
BOOTARGS='setenv bootargs root='$demo_dev' rw rootwait rootfstype=ext4 panic=1 console=ttyS0,115200 ${othbootargs} ${mtdparts} ${linuxargs}'
BOOTARGS_OLD='setenv bootargs root='$demo_dev' rw rootwait rootfstype=ext4 panic=1 console=ttyS0,115200 ${othbootargs} ${mtdparts} ${linuxargs_old}'
fi

prepare_boot_menu() {
echo "Sync up cache ..."
sync
Expand All @@ -40,13 +88,28 @@ prepare_boot_menu() {
then
UBOOT_ENV_SIZ="0x$(hd $PROC_ENV_FILE | awk 'FNR==1 {print $2 $3 $4 $5}')"
UBOOT_ENV_ERASE_SIZ="0x$(grep uboot-env /proc/mtd | awk '{print $3}')"
if [[ -n "$UBOOT_ENV_SIZ" && -n "$UBOOT_ENV_ERASE_SIZ" ]]
if [ -n "$UBOOT_ENV_SIZ" -a -n "$UBOOT_ENV_ERASE_SIZ" ]
then
# Env info from DTB
FW_ENV_DTB="/dev/$DTB_HAS_ENV_BLK 0x00000000 $UBOOT_ENV_SIZ $UBOOT_ENV_ERASE_SIZ"
fi
fi
fi

if [ -n "$FW_ENV_DTB" ]
then
echo $FW_ENV_DTB > /etc/fw_env.config
echo "Found uboot env offset in device tree"
UBOOT_ENV_CRC=$(fw_printenv 2>&1 | grep -c 'Warning: Bad CRC') || true
if [ "$UBOOT_ENV_CRC" -eq 0 ]
then
echo "Uboot env offset in device tree is valid"
UBOOT_FW_DEFAULT=0
else
echo "Uboot env offset in device tree is NOT valid"
UBOOT_FW_DEFAULT=1
fi
fi
if [ $UBOOT_FW_DEFAULT -eq 1 ]
then
echo $FW_ENV_DEFAULT > /etc/fw_env.config
Expand Down Expand Up @@ -81,11 +144,14 @@ prepare_boot_menu() {
fi
if [ ${IS_MASS} -eq 1 ]
then
demo_dev=${blk_dev}1
demo_dev=${blk_dev}1
else
#demo_dev=$(echo $blk_dev | sed -e 's/\(mmcblk[0-9]\)/\1p/')$demo_part
demo_dev=/dev/mmcblk0p1
fi
if [ "$PLATFORM" = "arm64-delta_tg48m_poe-r0" ] || [ "$PLATFORM" = "arm64-delta_tg4810m-r0" ]; then
demo_dev=/dev/sda2
fi
fi
fi

Expand All @@ -105,53 +171,42 @@ prepare_boot_menu() {
BOOT1='echo " > Boot1: $sonic_version_1 - run sonic_image_1";echo;'
BOOT2='echo " > Boot2: $sonic_version_2 - run sonic_image_2";echo;'
BOOT3='echo " > Boot3: ONIE - run onie-nand-boot";echo;'
if [ "$PLATFORM" = "arm64-delta_tg48m_poe-r0" ] || [ "$PLATFORM" = "arm64-delta_tg4810m-r0" ]; then
BOOT3='echo " > Boot3: ONIE - run bootonie";echo;'
fi
BORDER='echo "---------------------------------------------------";echo;'
fw_setenv ${FW_ARG} print_menu $BORDER $BOOT1 $BOOT2 $BOOT3 $BORDER > /dev/null

fw_setenv ${FW_ARG} linuxargs "net.ifnames=0 loopfstype=squashfs loop=$image_dir/$FILESYSTEM_SQUASHFS varlog_size=$VAR_LOG" > /dev/null
fw_setenv ${FW_ARG} linuxargs_old "net.ifnames=0 loopfstype=squashfs loop=$image_dir_old/$FILESYSTEM_SQUASHFS varlog_size=$VAR_LOG" > /dev/null
sonic_bootargs_old='setenv bootargs root='$demo_dev' rw rootwait rootfstype=ext4 panic=1 console=ttyS0,115200 ${othbootargs} ${mtdparts} ${linuxargs_old}'
fw_setenv ${FW_ARG} sonic_bootargs_old $sonic_bootargs_old > /dev/null || true
sonic_boot_load_old=$(fw_printenv -n sonic_boot_load || true)
old_str="_old"
fw_setenv ${FW_ARG} sonic_boot_load_old $sonic_boot_load_old$old_str > /dev/null || true

fw_setenv ${FW_ARG} kernel_addr $kernel_addr > /dev/null
fw_setenv ${FW_ARG} fdt_addr $fdt_addr > /dev/null
fw_setenv ${FW_ARG} fit_addr $fit_addr > /dev/null
fw_setenv ${FW_ARG} initrd_addr $initrd_addr > /dev/null
# Set boot configs
if [ ${IS_MASS} -eq 1 ]
then
#USB_LOAD='ext4load usb 0 $kernel_addr $image_name; ext4load usb 0 $fdt_addr $fdt_name; ext4load usb 0 $initrd_addr $initrd_name'
USB_LOAD='ext4load usb 0 $fit_addr $fit_name'
fw_setenv ${FW_ARG} sonic_boot_load $USB_LOAD > /dev/null
else
#MMC_LOAD='ext4load mmc 0:'$demo_part' $kernel_addr $image_name; ext4load mmc 0:'$demo_part' $fdt_addr $fdt_name; ext4load mmc 0:'$demo_part' $initrd_addr $initrd_name'
MMC_LOAD='ext4load mmc 0:'$demo_part' $fit_addr $fit_name'
fw_setenv ${FW_ARG} sonic_boot_load $MMC_LOAD > /dev/null
fi
#SONIC_BOOT_CMD='run sonic_bootargs; run sonic_boot_load; booti $kernel_addr $initrd_addr $fdt_addr'
SONIC_BOOT_CMD='run sonic_bootargs; run sonic_boot_load; bootm $fit_addr'
SONIC_BOOT_CMD_OLD='run sonic_bootargs_old; run sonic_boot_load_old; bootm $fit_addr'
BOOTARGS='setenv bootargs root='$demo_dev' rw rootwait rootfstype=ext4 panic=1 console=ttyS0,115200 ${othbootargs} ${mtdparts} ${linuxargs}'
fw_setenv ${FW_ARG} sonic_boot_load $SONIC_LOAD > /dev/null
fw_setenv ${FW_ARG} sonic_boot_load_old $SONIC_LOAD_OLD > /dev/null
fw_setenv ${FW_ARG} sonic_bootargs $BOOTARGS > /dev/null
fw_setenv ${FW_ARG} sonic_bootcmd $SONIC_BOOT_CMD > /dev/null
fw_setenv ${FW_ARG} sonic_image_2 $SONIC_BOOT_CMD_OLD > /dev/null
fw_setenv ${FW_ARG} sonic_bootargs_old $BOOTARGS_OLD > /dev/null || true
fw_setenv ${FW_ARG} sonic_bootcmd "$SONIC_BOOT_CMD" > /dev/null
fw_setenv ${FW_ARG} sonic_image_2 "$SONIC_BOOT_CMD_OLD" > /dev/null
fw_setenv ${FW_ARG} sonic_image_1 "$SONIC_BOOT_CMD" > /dev/null
fw_setenv ${FW_ARG} boot_next 'run sonic_image_1'> /dev/null
fw_setenv ${FW_ARG} bootcmd 'run print_menu; usb start; test -n "$boot_once" && run boot_once; run boot_next' > /dev/null

}

#Get block device
#Default block device is eMMC, if not look for usb storage
get_install_device()
{
if [ "$PLATFORM" = "arm64-delta_tg48m_poe-r0" ] || [ "$PLATFORM" = "arm64-delta_tg4810m-r0" ]; then
blk_dev=/dev/sda
echo "Selected SSD Drive $blk_dev"
return 0
fi
mass_bus="target0:0:0"
for i in a b c ; do
if $(ls -l /sys/block/sd$i/device 2>/dev/null | grep -q "$mass_bus") ; then
echo "/dev/sd$i"
blk_dev=/dev/sd$i
IS_MASS=1
echo "Selected Mass storage $blk_dev"
Expand All @@ -161,7 +216,6 @@ get_install_device()
mmc_bus="mmc0:aaaa"
for i in 0 1 2 ; do
if $(ls -l /sys/block/mmcblk$i/device 2>/dev/null | grep -q "$mmc_bus") ; then
echo "/dev/mmcblk$i"
blk_dev=/dev/mmcblk$i
echo "Selected mmc $blk_dev"
return 0
Expand All @@ -174,19 +228,32 @@ get_install_device()

create_demo_partition() {

if [ "$PLATFORM" = "arm64-delta_tg48m_poe-r0" ] || [ "$PLATFORM" = "arm64-delta_tg4810m-r0" ]; then
# SSD drive
blk_dev=/dev/sda
parted -s $blk_dev rm 2 || true
partprobe || true
parted -s --align optimal $blk_dev unit gb mkpart primary 2 26 || true
partprobe || true
echo "SSD drive partition done on $blk_dev"
return 0
fi

if [ ${IS_MASS} -eq 1 ]
then
# USB drive
#"USB drive"
parted -s $blk_dev rm 1 || true
partprobe || true
parted -s --align optimal $blk_dev unit gb mkpart primary 1 $DISK_SIZE || true
partprobe || true
echo "USB drive partition done on $blk_dev"
else
# SD CARD
#"SD CARD"
parted -s /dev/mmcblk0 rm 1
partprobe
parted -s --align optimal /dev/mmcblk0 unit gb mkpart primary 1 $DISK_SIZE
partprobe
echo "SD CARD partition done on $blk_dev"
fi
}

Expand All @@ -201,20 +268,21 @@ create_partition() {
}

mount_partition() {
if [ ${IS_MASS} -eq 1 ]
then

if [ ${IS_MASS} -eq 1 ]; then
demo_dev=${blk_dev}1
else
#demo_dev=$(echo $blk_dev | sed -e 's/\(mmcblk[0-9]\)/\1p/')$demo_part
demo_dev=/dev/mmcblk0p1
fi

# Make filesystem
echo "demo label: $demo_volume_label. $demo_dev..."
mkfs.ext4 -L $demo_volume_label $demo_dev
if [ "$PLATFORM" = "arm64-delta_tg48m_poe-r0" ] || [ "$PLATFORM" = "arm64-delta_tg4810m-r0" ]; then
demo_dev=/dev/sda2
fi

echo "demo label: $demo_volume_label $demo_dev"
mkfs.ext4 -L $demo_volume_label $demo_dev
mount -t ext4 -o defaults,rw $demo_dev $demo_mnt || {
echo "Error: Unable to mount $demo_dev on $demo_mnt"
echo "Error: Unable to mount $demo_dev on $demo_mnt"
exit 1
}
}
Expand Down
46 changes: 44 additions & 2 deletions platform/marvell-arm64/sonic_fit.its
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,30 @@
algo = "sha1";
};
};
fdt@1 {
description = "Flattened Device Tree blob";
data = /incbin/("/boot/tg4810m.dtb");
type = "flat_dt";
arch = "arm64";
load = <0x10000000>;
compression = "none";
hash@1 {
algo = "sha1";
};
};
fdt@2 {
description = "Flattened Device Tree blob";
data = /incbin/("/boot/tg48m-p.dtb");
type = "flat_dt";
arch = "arm64";
load = <0x10000000>;
compression = "none";
hash@1 {
algo = "sha1";
};
};


ramdisk@0 {
description = "ramdisk";
data = /incbin/("/boot/initrd.img-4.9.0-9-2-arm64");
Expand All @@ -41,8 +65,8 @@
};
};
configurations {
default = "conf@1";
conf@1 {
default = "config_falcon";
config_falcon {
description = "Boot Linux kernel with FDT blob + ramdisk";
kernel = "kernel@0";
fdt = "fdt@0";
Expand All @@ -51,5 +75,23 @@
algo = "sha1";
};
};
delta_tg4810m {
description = "Boot Linux kernel with FDT blob + ramdisk";
kernel = "kernel@0";
fdt = "fdt@1";
ramdisk = "ramdisk@0";
hash@1 {
algo = "sha1";
};
};
delta_tg48m_poe {
description = "Boot Linux kernel with FDT blob + ramdisk";
kernel = "kernel@0";
fdt = "fdt@2";
ramdisk = "ramdisk@0";
hash@1 {
algo = "sha1";
};
};
};
};