@@ -13,10 +13,6 @@ kernel_version=6.1.0-22-2-arm64
13
13
kernel_fname="/boot/vmlinuz-$kernel_version"
14
14
initrd_fname="/boot/initrd.img-$kernel_version"
15
15
fit_fname="/boot/sonic_arm64.fit"
16
- demo_volume_label=SONiC-OS
17
-
18
- # global mount defines
19
- demo_mnt=/tmp
20
16
21
17
if [ "$install_env" = "onie" ]; then
22
18
MACH_FILE="/etc/machine.conf"
@@ -29,15 +25,20 @@ echo "Intalling SONiC from $install_env on Platform $PLATFORM"
29
25
30
26
PLATFORM_AC5X=0
31
27
PLATFORM_CN9131=0
28
+ PLATFORM_7215_A1=0
29
+ disk_interface="mmc"
32
30
33
31
case $PLATFORM in
34
32
arm64-nokia_ixs7215_52xb-r0) PLATFORM_7215_A1=1;
33
+ mmc_bus="mmc0:0001";
35
34
fdt_fname="/usr/lib/linux-image-${kernel_version}/marvell/7215-ixs-a1.dtb";
36
35
fit_conf_name="#conf_7215_a1";;
37
36
arm64-marvell_rd98DX35xx-r0) PLATFORM_AC5X=1;
37
+ mmc_bus="mmc0:0001";
38
38
fdt_fname="/usr/lib/linux-image-$kernel_version/marvell/ac5-98dx35xx-rd.dtb";
39
39
fit_conf_name="#conf_ac5x";;
40
40
arm64-marvell_rd98DX35xx_cn9131-r0) PLATFORM_CN9131=1;
41
+ mmc_bus="mmc0:0001";
41
42
fdt_fname="/boot/cn9131-db-comexpress.dtb";
42
43
fit_conf_name="#conf_cn9131";;
43
44
esac
@@ -48,21 +49,16 @@ if [ $PLATFORM_AC5X -eq 1 ]; then
48
49
initrd_addr=0x206000000
49
50
50
51
FW_ENV_DEFAULT='/dev/mtd0 0x400000 0x10000 0x10000'
51
- demo_part=2
52
- mmc_bus="mmc0:0001"
53
52
elif [ $PLATFORM_7215_A1 -eq 1 ]; then
54
53
fit_addr=0x20000000
55
54
VAR_LOG=4096
56
55
FW_ENV_DEFAULT='/dev/mtd1 0x0 0x10000 0x10000'
57
56
demo_part=2
58
- mmc_bus="mmc0:0001"
59
57
elif [ $PLATFORM_CN9131 -eq 1 ]; then
60
58
fdt_addr=0x1000000
61
59
fit_addr=0x8000000
62
60
initrd_addr=0x2000000
63
- demo_part=2
64
61
FW_ENV_DEFAULT='/dev/mtd1 0x1F0000 0x10000 0x10000'
65
- mmc_bus="mmc0:0001"
66
62
else
67
63
fdt_addr=0x1000000
68
64
fit_addr=0x8000000
@@ -71,83 +67,100 @@ else
71
67
fdt_fname="/usr/lib/linux-image-$kernel_version/marvell/armada-7020-comexpress.dtb"
72
68
73
69
FW_ENV_DEFAULT='/dev/mtd1 0x0 0x10000 0x100000'
74
- demo_part=1
75
70
mmc_bus="mmc0:aaaa"
76
71
fi
77
72
78
73
# Skip VID Header in UBIFS
79
74
LINUX_MISC_CMD='apparmor=1 security=apparmor usbcore.autosuspend=-1'
80
75
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.
83
79
get_install_device()
84
80
{
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
93
92
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."
96
107
}
97
108
98
109
get_install_device
99
- if [ $? -ne 0 ]; then
100
- echo "Error: Unable to detect $blk_dev $demo_dev"
101
- exit 1
102
- fi
103
110
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
105
113
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}
117
115
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
+ }
121
127
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
126
131
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}
129
136
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
+ }
136
139
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
+ }
140
150
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
145
155
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
+ }
149
162
}
150
- }
163
+ fi
151
164
152
165
prepare_boot_menu() {
153
166
echo "Sync up cache ..."
@@ -222,7 +235,8 @@ prepare_boot_menu() {
222
235
fw_setenv ${FW_ARG} print_menu "$BORDER $BOOT1 $BOOT2 $BOOT3 $BORDER" > /dev/null
223
236
224
237
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}'
226
240
fw_setenv ${FW_ARG} sonic_bootargs_old "$sonic_bootargs_old" > /dev/null || true
227
241
sonic_boot_load_old=$(fw_printenv -n sonic_boot_load || true)
228
242
old_str="_old"
@@ -233,16 +247,17 @@ prepare_boot_menu() {
233
247
fw_setenv ${FW_ARG} fit_addr $fit_addr > /dev/null
234
248
fw_setenv ${FW_ARG} fit_conf_name $fit_conf_name > /dev/null
235
249
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
238
253
SONIC_BOOT_CMD='run sonic_bootargs; run sonic_boot_load; bootm $fit_addr${fit_conf_name}'
239
254
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}'
241
256
fw_setenv ${FW_ARG} sonic_bootargs "$BOOTARGS" > /dev/null
242
257
fw_setenv ${FW_ARG} sonic_image_2 "$SONIC_BOOT_CMD_OLD" > /dev/null
243
258
fw_setenv ${FW_ARG} sonic_image_1 "$SONIC_BOOT_CMD" > /dev/null
244
259
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
246
261
247
262
echo "Installed SONiC base image SONiC-OS successfully"
248
263
}
0 commit comments