forked from sonic-net/sonic-buildimage
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathplatform.conf
More file actions
272 lines (238 loc) · 11.5 KB
/
platform.conf
File metadata and controls
272 lines (238 loc) · 11.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
# Copyright (C) Marvell Inc
# over ride default behaviour
echo "Preparing for installation ... "
# global defines
kernel_addr=0x1100000
fdt_addr=0x2800000
fdt_high=0x28fffff
initrd_addr=0x2900000
kernel_fname="/boot/vmlinuz-5.10.0-18-2-armmp"
initrd_fname="/boot/initrd.img-5.10.0-18-2-armmp"
fdt_fname="/boot/armada-385-ET6448M_4G_Nand.dtb"
if [ "$install_env" = "onie" ]; then
MACH_FILE="/etc/machine.conf"
else
MACH_FILE="/host/machine.conf"
fi
# armhf-marvell_et6448m_52x-r0 - Platform = Et6448M
# armhf-nokia_ixs7215_52x-r0 - Platform = Nokia IPD6448M
PLATFORM=`sed -n 's/^onie_platform=\(.*\)/\1/p' $MACH_FILE`
echo "Intalling SONiC from $install_env on Platform $PLATFORM"
# global mount defines
if [ "$PLATFORM" = "armhf-marvell_et6448m_52x-r0" ]; then
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]")
fdt_fname="/boot/armada-385-ET6448M_4G_Nand.dtb"
BOOTARGS='setenv bootargs root='$demo_dev' rw rootwait ubi.mtd='$mtd_num' rootfstype=ubifs panic=1 console=ttyS0,115200 ${othbootargs} ${mtdparts} ${linuxargs}'
UBI_LOAD='run ubi_sonic_boot_mount_ubi; ubifsload $kernel_addr $image_name;ubifsload $fdt_addr $fdt_name; ubifsload $initrd_addr $initrd_name'
BOOTARGS_OLD='setenv bootargs root='$demo_dev' rw rootwait ubi.mtd='$mtd_num' rootfstype=ubifs panic=1 console=ttyS0,115200 ${othbootargs} ${mtdparts} ${linuxargs_old}'
UBI_LOAD_OLD='run ubi_sonic_boot_mount_ubi; ubifsload $kernel_addr $image_name_old;ubifsload $fdt_addr $fdt_name_old; ubifsload $initrd_addr $initrd_name_old'
UBIBOOTCMD='run ubi_sonic_boot_bootargs; run ubi_sonic_boot_load; test -n "$boot_once" && setenv boot_once "" && saveenv; bootz $kernel_addr $initrd_addr $fdt_addr'
UBIBOOTCMD_OLD='run ubi_sonic_boot_bootargs_old; run ubi_sonic_boot_load_old; test -n "$boot_once" && setenv boot_once "" && saveenv; bootz $kernel_addr $initrd_addr $fdt_addr'
LINUX_MISC_CMD='apparmor=1 security=apparmor usbcore.autosuspend=-1'
elif [ "$PLATFORM" = "armhf-nokia_ixs7215_52x-r0" ]; then
demo_dev=sda2
fdt_fname="/boot/armada-385-ipd6448m.dtb"
BOOTARGS='setenv bootargs root=/dev/'$demo_dev' rw rootwait rootfstype=ext4 panic=1 console=ttyS0,${baudrate} ${othbootargs} ${mtdparts} ${linuxargs}'
UBI_LOAD='scsi init; ext4load scsi 0:2 $kernel_addr $image_name; ext4load scsi 0:2 $fdt_addr $fdt_name; ext4load scsi 0:2 $initrd_addr $initrd_name'
BOOTARGS_OLD='setenv bootargs root=/dev/'$demo_dev' rw rootwait rootfstype=ext4 panic=1 console=ttyS0,${baudrate} ${othbootargs} ${mtdparts} ${linuxargs_old}'
UBI_LOAD_OLD='scsi init; ext4load scsi 0:2 $kernel_addr $image_name_old; ext4load scsi 0:2 $fdt_addr $fdt_name_old; ext4load scsi 0:2 $initrd_addr $initrd_name_old'
UBIBOOTCMD='run ubi_sonic_boot_bootargs; run ubi_sonic_boot_load; test -n "$boot_once" && setenv boot_once "" && saveenv; bootz $kernel_addr $initrd_addr $fdt_addr'
UBIBOOTCMD_OLD='run ubi_sonic_boot_bootargs_old; run ubi_sonic_boot_load_old; test -n "$boot_once" && setenv boot_once "" && saveenv; bootz $kernel_addr $initrd_addr $fdt_addr'
LINUX_MISC_CMD='apparmor=1 security=apparmor usbcore.autosuspend=-1'
else
echo "Unsupported Platform $PLAFORM"
exit 2
fi
demo_mnt=/tmp
FW_ENV_DEFAULT='/dev/mtd0 0x00500000 0x80000 0x100000 8'
UBOOT_FW_DEFAULT=1
prepare_boot_menu() {
echo "Sync up cache ..."
sync
echo "Setting up U-Boot environment..."
DTB_HAS_ENV_BLK=$(grep uboot-env /proc/mtd | sed -e 's/:.*$//')
if [ -c "/dev/$DTB_HAS_ENV_BLK" ]; then
PROC_ENV_FILE=$(find /proc/device-tree/ -name env_size)
if [ -n "$PROC_ENV_FILE" ]
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" ]]
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
fdt_fname="/boot/armada-385-ET6448M_4G_Nand_r2019.dtb"
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
echo "Using pre-configured uboot env"
fi
if [ "$PLATFORM" = "armhf-nokia_ixs7215_52x-r0" ]; then
FW_ENV_DEFAULT='/dev/mtd0 0x00100000 0x10000 0x10000'
echo $FW_ENV_DEFAULT > /etc/fw_env.config
echo "Using pre-configured uboot env for armhf-nokia_ixs7215_52x-r0"
fi
image_name=${image_dir}${kernel_fname}
initrd_name=${image_dir}${initrd_fname}
fdt_name=${image_dir}${fdt_fname}
if [ "$install_env" = "onie" ]; then
FW_ARG="-f"
image_dir_old=""
image_name_old=""
initrd_name_old=""
fdt_name_old=""
sonic_version_2="None"
else
image_dir_old=$(fw_printenv -n image_dir || true)
image_name_old=$(fw_printenv -n image_name || true)
initrd_name_old=$(fw_printenv -n initrd_name || true)
fdt_name_old=$(fw_printenv -n fdt_name || true)
sonic_version_2=$(fw_printenv -n sonic_version_1 || true)
fi
# Set boot variables
fw_setenv ${FW_ARG} image_dir $image_dir > /dev/null
fw_setenv ${FW_ARG} image_name $image_name > /dev/null
fw_setenv ${FW_ARG} initrd_name $initrd_name > /dev/null
fw_setenv ${FW_ARG} fdt_name $fdt_name > /dev/null
fw_setenv ${FW_ARG} sonic_version_1 $demo_volume_revision_label > /dev/null
fw_setenv ${FW_ARG} image_dir_old $image_dir_old > /dev/null
fw_setenv ${FW_ARG} image_name_old $image_name_old > /dev/null
fw_setenv ${FW_ARG} initrd_name_old $initrd_name_old > /dev/null
fw_setenv ${FW_ARG} fdt_name_old $fdt_name_old > /dev/null
fw_setenv ${FW_ARG} sonic_version_2 $sonic_version_2 > /dev/null
BOOT1='echo " > Boot1: $sonic_version_1 - run sonic_image_1";echo;'
BOOT2='echo " > Boot2: $sonic_version_2 - run sonic_image_2";echo;'
if [ "$PLATFORM" = "armhf-nokia_ixs7215_52x-r0" ]; then
BOOT3='echo " > Boot3: ONIE - run onie_bootcmd";echo;'
else
BOOT3='echo " > Boot3: ONIE - run onie_nand_boot";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 systemd.unified_cgroup_hierarchy=0 varlog_size=$VAR_LOG_SIZE loglevel=4 ${extra_cmdline_linux}" > /dev/null
fw_setenv ${FW_ARG} linuxargs_old "net.ifnames=0 loopfstype=squashfs loop=$image_dir_old/$FILESYSTEM_SQUASHFS systemd.unified_cgroup_hierarchy=0 varlog_size=$VAR_LOG_SIZE loglevel=4" > /dev/null
# Set boot configs
fw_setenv ${FW_ARG} kernel_addr $kernel_addr > /dev/null
fw_setenv ${FW_ARG} fdt_addr $fdt_addr > /dev/null
fw_setenv ${FW_ARG} fdt_high $fdt_high > /dev/null
fw_setenv ${FW_ARG} initrd_addr $initrd_addr > /dev/null
fw_setenv ${FW_ARG} mtdids 'nand0=armada-nand' > /dev/null
if [ $UBOOT_FW_DEFAULT -eq 1 ]
then
fw_setenv ${FW_ARG} mtdparts 'mtdparts=armada-nand:10m(U-Boot)ro,20m@10m(ONIE),-(SONIC)' > /dev/null
else
fw_setenv ${FW_ARG} mtdparts 'mtdparts=armada-nand:4m(uboot)ro,5m@5m(uboot-env),20m@10m(ONIE),-(SONIC)' > /dev/null
fi
if [ "$PLATFORM" = "armhf-nokia_ixs7215_52x-r0" ]; then
fw_setenv ${FW_ARG} mtdparts 'mtdparts=spi0.0:4m(boot),-(spi-rootfs)' > /dev/null
fi
fw_setenv ${FW_ARG} ubi_sonic_boot_mount_ubi 'ubi part SONIC; ubifsmount ubi0' > /dev/null
fw_setenv ${FW_ARG} ubi_sonic_boot_bootargs "$BOOTARGS" > /dev/null
fw_setenv ${FW_ARG} ubi_sonic_boot_load "$UBI_LOAD" > /dev/null
fw_setenv ${FW_ARG} sonic_image_1 "$UBIBOOTCMD" > /dev/null
fw_setenv ${FW_ARG} ubi_sonic_boot_bootargs_old "$BOOTARGS_OLD" > /dev/null
fw_setenv ${FW_ARG} ubi_sonic_boot_load_old "$UBI_LOAD_OLD" > /dev/null
fw_setenv ${FW_ARG} sonic_image_2 "$UBIBOOTCMD_OLD" > /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
}
create_ubi_partition() {
ubidetach /dev/ubi_ctrl -d 0 2>/dev/null || true
trap_push "${onie_bin} ubidetach -d 0 /dev/ubi_ctrl || 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
}
create_gpt_partition() {
blk_dev="/dev/sda"
demo_part=$(sgdisk -p $blk_dev | grep -e "$demo_volume_label" | awk '{print $1}')
# ONIE partition size 168MB
onie_part_size=168
if [ -z "$demo_part" ] ; then
# Partition Does NOT Exists
echo "SONIC label [$demo_volume_label] is NOT found in Partition"
echo "Proceeding to create partition"
attr_bitmask="0x0"
sgdisk --new=${demo_part}::+${onie_part_size}MB \
--attributes=${demo_part}:=:$attr_bitmask \
--change-name=${demo_part}:$demo_volume_label $blk_dev \
|| {
echo "Warning: The first trial of creating partition failed, trying the largest aligned available block of sectors on the disk"
begin=$(sgdisk -F $blk_dev)
end=$(sgdisk -E $blk_dev)
sgdisk --new=${demo_part}:$begin:$end \
--attributes=${demo_part}:=:$attr_bitmask \
--change-name=${demo_part}:$demo_volume_label $blk_dev
} || {
echo "Error: Unable to create partition $demo_part on $blk_dev"
exit 1
}
partprobe || true
else
# Partition Exists
echo "Partition exists $demo_part on $blk_dev"
fi
# Make filesystem
mkfs.ext4 -L $demo_volume_label /dev/$demo_dev
}
create_partition() {
# Platform speicific partition
if [ "$PLATFORM" = "armhf-marvell_et6448m_52x-r0" ]; then
echo "Doing UBI partition"
create_ubi_partition
else
echo "Doing GPT partition"
create_gpt_partition
fi
}
mount_partition() {
demo_mnt=$(mktemp -d) || {
echo "Error: Unable to create file sstem mount point"
exit 1
}
echo "Mounting $demo_dev on $demo_mnt "
if [ "$PLATFORM" = "armhf-marvell_et6448m_52x-r0" ]; then
trap_push "${onie_bin} umount /dev/ubi0_0|| true"
mount -t ubifs /dev/ubi0_0 $demo_mnt || {
echo "mount -t ubifs /dev/ubi0_0 $demo_mnt Failed"
exit 1
}
else
trap_push "${onie_bin} umount /dev/sda2|| true"
mount -t ext4 /dev/sda2 $demo_mnt || {
echo "mount -t ext4 /dev/sda2 $demo_mnt Failed"
exit 1
}
fi
}
bootloader_menu_config() {
# Update uboot Environment
prepare_boot_menu
}