Skip to content

Commit 5bcf5ef

Browse files
[Marvell][arm64] Installer optimization (#21461)
Why I did it To optimization installer for marvell arm64 to use create and mount partition logic from default_platform.conf. Given that current default_platform.conf only allows install on same disk as ONIE. Add support for install block device selection. Add support for scsi block devices. How I did it Use implementation from default_platform.conf for create and mount partition and remove the implementation in platform_arm64.conf. Add option to override install block device in default_platform.conf. Also added logic to select the install block device from platform_arm64.conf. Added support for selecting scsi disk as install device in platform_arm64.conf. This also needed changes to u-boot env variable. Changed to UUID based 'root' disk selection to have a generic implementation. For backward compatibility using the existing functions for 7215_A1 platform. How to verify it Verified ONIE and SONIC to SONIC install using sonic-marvell.bin and sonic-marvell-arm64.bin. Signed-off-by: Pavan Naregundi <pnaregundi@marvell.com>
1 parent 4641562 commit 5bcf5ef

File tree

2 files changed

+94
-77
lines changed

2 files changed

+94
-77
lines changed

installer/default_platform.conf

+10-8
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ create_partition()
3535
{
3636

3737
# Install demo on same block device as ONIE
38-
if [ "$install_env" != "build" ]; then
38+
if [ "$install_env" != "build" ] && [ -z "$blk_dev" ]; then
3939
onie_dev=$(blkid | grep ONIE-BOOT | head -n 1 | awk '{print $1}' | sed -e 's/:.*$//')
4040
blk_dev=$(echo $onie_dev | sed -e 's/[1-9][0-9]*$//' | sed -e 's/\([0-9]\)\(p\)/\1/')
4141

@@ -154,13 +154,15 @@ create_demo_gpt_partition()
154154
last_part=$(echo "$all_part" | tail -n 1 | awk '{print $1}')
155155
# Find next available partition
156156
demo_part=1
157-
echo "$all_part" > $tmpfifo &
158-
# Find the first available partition number
159-
while read -r used_part; do
160-
echo "Partition #$used_part is in use."
161-
if [ "$used_part" -ne "$demo_part" ]; then break; fi
162-
demo_part=`expr $demo_part + 1`
163-
done < $tmpfifo
157+
if [ ! -z "$all_part" ]; then
158+
echo "$all_part" > $tmpfifo &
159+
# Find the first available partition number
160+
while read -r used_part; do
161+
echo "Partition #$used_part is in use."
162+
if [ "$used_part" -ne "$demo_part" ]; then break; fi
163+
demo_part=`expr $demo_part + 1`
164+
done < $tmpfifo
165+
fi
164166
echo "Partition #$demo_part is available"
165167

166168
# Create new partition

platform/marvell/platform_arm64.conf

+84-69
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,6 @@ kernel_version=6.1.0-22-2-arm64
1313
kernel_fname="/boot/vmlinuz-$kernel_version"
1414
initrd_fname="/boot/initrd.img-$kernel_version"
1515
fit_fname="/boot/sonic_arm64.fit"
16-
demo_volume_label=SONiC-OS
17-
18-
# global mount defines
19-
demo_mnt=/tmp
2016

2117
if [ "$install_env" = "onie" ]; then
2218
MACH_FILE="/etc/machine.conf"
@@ -29,15 +25,20 @@ echo "Intalling SONiC from $install_env on Platform $PLATFORM"
2925

3026
PLATFORM_AC5X=0
3127
PLATFORM_CN9131=0
28+
PLATFORM_7215_A1=0
29+
disk_interface="mmc"
3230

3331
case $PLATFORM in
3432
arm64-nokia_ixs7215_52xb-r0) PLATFORM_7215_A1=1;
33+
mmc_bus="mmc0:0001";
3534
fdt_fname="/usr/lib/linux-image-${kernel_version}/marvell/7215-ixs-a1.dtb";
3635
fit_conf_name="#conf_7215_a1";;
3736
arm64-marvell_rd98DX35xx-r0) PLATFORM_AC5X=1;
37+
mmc_bus="mmc0:0001";
3838
fdt_fname="/usr/lib/linux-image-$kernel_version/marvell/ac5-98dx35xx-rd.dtb";
3939
fit_conf_name="#conf_ac5x";;
4040
arm64-marvell_rd98DX35xx_cn9131-r0) PLATFORM_CN9131=1;
41+
mmc_bus="mmc0:0001";
4142
fdt_fname="/boot/cn9131-db-comexpress.dtb";
4243
fit_conf_name="#conf_cn9131";;
4344
esac
@@ -48,21 +49,16 @@ if [ $PLATFORM_AC5X -eq 1 ]; then
4849
initrd_addr=0x206000000
4950

5051
FW_ENV_DEFAULT='/dev/mtd0 0x400000 0x10000 0x10000'
51-
demo_part=2
52-
mmc_bus="mmc0:0001"
5352
elif [ $PLATFORM_7215_A1 -eq 1 ]; then
5453
fit_addr=0x20000000
5554
VAR_LOG=4096
5655
FW_ENV_DEFAULT='/dev/mtd1 0x0 0x10000 0x10000'
5756
demo_part=2
58-
mmc_bus="mmc0:0001"
5957
elif [ $PLATFORM_CN9131 -eq 1 ]; then
6058
fdt_addr=0x1000000
6159
fit_addr=0x8000000
6260
initrd_addr=0x2000000
63-
demo_part=2
6461
FW_ENV_DEFAULT='/dev/mtd1 0x1F0000 0x10000 0x10000'
65-
mmc_bus="mmc0:0001"
6662
else
6763
fdt_addr=0x1000000
6864
fit_addr=0x8000000
@@ -71,83 +67,100 @@ else
7167
fdt_fname="/usr/lib/linux-image-$kernel_version/marvell/armada-7020-comexpress.dtb"
7268

7369
FW_ENV_DEFAULT='/dev/mtd1 0x0 0x10000 0x100000'
74-
demo_part=1
7570
mmc_bus="mmc0:aaaa"
7671
fi
7772

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

81-
#Get block device
82-
#Default block device is eMMC, if not look for usb storage
76+
# Get block device
77+
# default_platform.conf will by default install SONIC on same block device as ONIE
78+
# This funtion looks to override SONIC install target disk, with optional eMMC or SCSI disk.
8379
get_install_device()
8480
{
85-
for i in 0 1 2 ; do
86-
if $(ls -l /sys/block/mmcblk$i/device 2>/dev/null | grep -q "$mmc_bus") ; then
87-
echo "/dev/mmcblk$i"
88-
blk_dev=/dev/mmcblk$i
89-
echo "Selected mmc $blk_dev"
90-
return 0
91-
fi
92-
done
81+
if [ ! -z "$mmc_bus" ]; then
82+
for i in 0 1 2 ; do
83+
if $(ls -l /sys/block/mmcblk$i/device 2>/dev/null | grep -q "$mmc_bus") ; then
84+
echo "/dev/mmcblk$i"
85+
blk_dev=/dev/mmcblk$i
86+
disk_interface="mmc"
87+
echo "Selected mmc $blk_dev"
88+
return
89+
fi
90+
done
91+
fi
9392

94-
echo "ERROR storage not found"
95-
return 1
93+
if [ ! -z "$scsi_bus" ]; then
94+
for i in a b c d ; do
95+
if $(ls -l /sys/block/sd$i/device 2>/dev/null | grep -q "$scsi_bus") ; then
96+
echo "/dev/sd$i"
97+
blk_dev=/dev/sd$i
98+
disk_interface="scsi"
99+
disk_scan="scsi scan;"
100+
echo "Selected disk $blk_dev"
101+
return
102+
fi
103+
done
104+
fi
105+
106+
echo "Waring: Storage not found. Will try installing on the same disk as ONIE."
96107
}
97108

98109
get_install_device
99-
if [ $? -ne 0 ]; then
100-
echo "Error: Unable to detect $blk_dev $demo_dev"
101-
exit 1
102-
fi
103110

104-
demo_dev=${blk_dev}p${demo_part}
111+
if [ $PLATFORM_7215_A1 -eq 1 ]; then
112+
# 7215_A1 to use custom logic for backward compatibility
105113

106-
remove_dev_partitions() {
107-
echo "Remove all existing partitions starting partnum: ${demo_part} from ${blk_dev}"
108-
local dev_to_install=${blk_dev}p
109-
for p in $(seq ${demo_part} 9) ; do
110-
if [[ -e ${dev_to_install}${p} ]]; then
111-
echo "Removing partition ${dev_to_install}${p}"
112-
sgdisk -d ${p} ${blk_dev} || true
113-
fi
114-
done
115-
partprobe ${blk_dev}
116-
}
114+
demo_dev=${blk_dev}p${demo_part}
117115

118-
create_demo_partition() {
119-
# SD CARD
120-
remove_dev_partitions
116+
remove_dev_partitions() {
117+
echo "Remove all existing partitions starting partnum: ${demo_part} from ${blk_dev}"
118+
local dev_to_install=${blk_dev}p
119+
for p in $(seq ${demo_part} 9) ; do
120+
if [[ -e ${dev_to_install}${p} ]]; then
121+
echo "Removing partition ${dev_to_install}${p}"
122+
sgdisk -d ${p} ${blk_dev} || true
123+
fi
124+
done
125+
partprobe ${blk_dev}
126+
}
121127

122-
# Create sonic partition
123-
sgdisk --new ${demo_part}:: \
124-
--change-name=${demo_part}:${demo_volume_label} \
125-
--typecode=${demo_part}:8300 -p ${blk_dev}
128+
create_demo_partition() {
129+
# SD CARD
130+
remove_dev_partitions
126131

127-
partprobe
128-
}
132+
# Create sonic partition
133+
sgdisk --new ${demo_part}:: \
134+
--change-name=${demo_part}:${demo_volume_label} \
135+
--typecode=${demo_part}:8300 -p ${blk_dev}
129136

130-
create_partition() {
131-
get_install_device
132-
if [ $? -ne 0 ]; then
133-
echo "Error: Unable to detect $blk_dev $demo_dev"
134-
exit 1
135-
fi
137+
partprobe
138+
}
136139

137-
# Platform specific partition
138-
create_demo_partition
139-
}
140+
create_partition() {
141+
get_install_device
142+
if [ $? -ne 0 ]; then
143+
echo "Error: Unable to detect $blk_dev $demo_dev"
144+
exit 1
145+
fi
146+
147+
# Platform specific partition
148+
create_demo_partition
149+
}
140150

141-
mount_partition() {
142-
# Make filesystem
143-
echo "demo label: $demo_volume_label. $demo_dev..."
144-
mkfs.ext4 -L $demo_volume_label $demo_dev
151+
mount_partition() {
152+
# Make filesystem
153+
echo "demo label: $demo_volume_label. $demo_dev..."
154+
mkfs.ext4 -L $demo_volume_label $demo_dev
145155

146-
mount -t ext4 -o defaults,rw $demo_dev $demo_mnt || {
147-
echo "Error: Unable to mount $demo_dev on $demo_mnt"
148-
exit 1
156+
demo_mnt=/tmp
157+
158+
mount -t ext4 -o defaults,rw $demo_dev $demo_mnt || {
159+
echo "Error: Unable to mount $demo_dev on $demo_mnt"
160+
exit 1
161+
}
149162
}
150-
}
163+
fi
151164

152165
prepare_boot_menu() {
153166
echo "Sync up cache ..."
@@ -222,7 +235,8 @@ prepare_boot_menu() {
222235
fw_setenv ${FW_ARG} print_menu "$BORDER $BOOT1 $BOOT2 $BOOT3 $BORDER" > /dev/null
223236

224237
fw_setenv ${FW_ARG} linuxargs "net.ifnames=0 loopfstype=squashfs loop=$image_dir/$FILESYSTEM_SQUASHFS systemd.unified_cgroup_hierarchy=0 varlog_size=$VAR_LOG ${ONIE_PLATFORM_EXTRA_CMDLINE_LINUX}" > /dev/null
225-
sonic_bootargs_old='setenv bootargs root='$demo_dev' rw rootwait panic=1 console=ttyS0,${baudrate} ${linuxargs_old}'
238+
uuid=$(blkid | grep "$demo_volume_label" | sed -ne 's/.* UUID=\"\([^"]*\)\".*/\1/p')
239+
sonic_bootargs_old='setenv bootargs root=UUID='$uuid' rw rootwait panic=1 console=ttyS0,${baudrate} ${linuxargs_old}'
226240
fw_setenv ${FW_ARG} sonic_bootargs_old "$sonic_bootargs_old" > /dev/null || true
227241
sonic_boot_load_old=$(fw_printenv -n sonic_boot_load || true)
228242
old_str="_old"
@@ -233,16 +247,17 @@ prepare_boot_menu() {
233247
fw_setenv ${FW_ARG} fit_addr $fit_addr > /dev/null
234248
fw_setenv ${FW_ARG} fit_conf_name $fit_conf_name > /dev/null
235249
fw_setenv ${FW_ARG} initrd_addr $initrd_addr > /dev/null
236-
MMC_LOAD='ext4load mmc 0:'$demo_part' $fit_addr $fit_name'
237-
fw_setenv ${FW_ARG} sonic_boot_load "$MMC_LOAD" > /dev/null
250+
demo_part=$(sgdisk -p $blk_dev | grep -e "$demo_volume_label" | awk '{print $1}')
251+
DISK_LOAD=''$disk_scan' ext4load '$disk_interface' 0:'$demo_part' $fit_addr $fit_name'
252+
fw_setenv ${FW_ARG} sonic_boot_load "$DISK_LOAD" > /dev/null
238253
SONIC_BOOT_CMD='run sonic_bootargs; run sonic_boot_load; bootm $fit_addr${fit_conf_name}'
239254
SONIC_BOOT_CMD_OLD='run sonic_bootargs_old; run sonic_boot_load_old; bootm $fit_addr${fit_conf_name}'
240-
BOOTARGS='setenv bootargs root='$demo_dev' rw rootwait panic=1 console=ttyS0,${baudrate} ${linuxargs}'
255+
BOOTARGS='setenv bootargs root=UUID='$uuid' rw rootwait panic=1 console=ttyS0,${baudrate} ${linuxargs}'
241256
fw_setenv ${FW_ARG} sonic_bootargs "$BOOTARGS" > /dev/null
242257
fw_setenv ${FW_ARG} sonic_image_2 "$SONIC_BOOT_CMD_OLD" > /dev/null
243258
fw_setenv ${FW_ARG} sonic_image_1 "$SONIC_BOOT_CMD" > /dev/null
244259
fw_setenv ${FW_ARG} boot_next 'run sonic_image_1'> /dev/null
245-
fw_setenv ${FW_ARG} bootcmd 'run print_menu; usb start; test -n "$boot_once" && setenv do_boot_once "$boot_once" && setenv boot_once "" && saveenv && run do_boot_once; run boot_next' > /dev/null
260+
fw_setenv ${FW_ARG} bootcmd 'run print_menu; test -n "$boot_once" && setenv do_boot_once "$boot_once" && setenv boot_once "" && saveenv && run do_boot_once; run boot_next' > /dev/null
246261

247262
echo "Installed SONiC base image SONiC-OS successfully"
248263
}

0 commit comments

Comments
 (0)