@@ -8,6 +8,7 @@ echo "Preparing for installation ... "
88VAR_LOG=512
99UBOOT_FW_DEFAULT=1
1010
11+ is_uefi_based=0
1112kernel_addr=0x1100000
1213kernel_version=6.1.0-29-2-arm64
1314kernel_fname="/boot/vmlinuz-$kernel_version"
@@ -53,7 +54,11 @@ elif [ $PLATFORM_7215_A1 -eq 1 ]; then
5354 fit_addr=0x20000000
5455 VAR_LOG=4096
5556 FW_ENV_DEFAULT='/dev/mtd1 0x0 0x10000 0x10000'
56- demo_part=2
57+ if [ -d /sys/firmware/efi/efivars ]; then
58+ is_uefi_based=1
59+ else
60+ demo_part=2
61+ fi
5762elif [ $PLATFORM_CN9131 -eq 1 ]; then
5863 fdt_addr=0x1000000
5964 fit_addr=0x8000000
@@ -108,7 +113,7 @@ get_install_device()
108113
109114get_install_device
110115
111- if [ $PLATFORM_7215_A1 -eq 1 ]; then
116+ if [ $PLATFORM_7215_A1 -eq 1 ] && [ $is_uefi_based -eq 0 ] ; then
112117 # 7215_A1 to use custom logic for backward compatibility
113118
114119 demo_dev=${blk_dev}p${demo_part}
@@ -162,108 +167,109 @@ if [ $PLATFORM_7215_A1 -eq 1 ]; then
162167 }
163168fi
164169
170+ if [ $is_uefi_based -eq 0 ]; then
165171prepare_boot_menu() {
166- echo "Sync up cache ..."
167- sync
168- echo "Setting up U-Boot environment..."
169-
170- DTB_HAS_ENV_BLK=$(grep uboot-env /proc/mtd | sed -e 's/:.*$//')
171- if [ -c "/dev/$DTB_HAS_ENV_BLK" ]; then
172- PROC_ENV_FILE=$(find /proc/device-tree/ -name env_size)
173- if [ -n "$PROC_ENV_FILE" ]
174- then
175- UBOOT_ENV_SIZ="0x$(hd $PROC_ENV_FILE | awk 'FNR==1 {print $2 $3 $4 $5}')"
176- UBOOT_ENV_ERASE_SIZ="0x$(grep uboot-env /proc/mtd | awk '{print $3}')"
177- if [[ -n "$UBOOT_ENV_SIZ" && -n "$UBOOT_ENV_ERASE_SIZ" ]]
172+ echo "Sync up cache ..."
173+ sync
174+ echo "Setting up U-Boot environment..."
175+
176+ DTB_HAS_ENV_BLK=$(grep uboot-env /proc/mtd | sed -e 's/:.*$//')
177+ if [ -c "/dev/$DTB_HAS_ENV_BLK" ]; then
178+ PROC_ENV_FILE=$(find /proc/device-tree/ -name env_size)
179+ if [ -n "$PROC_ENV_FILE" ]
178180 then
179- # Env info from DTB
180- FW_ENV_DTB="/dev/$DTB_HAS_ENV_BLK 0x00000000 $UBOOT_ENV_SIZ $UBOOT_ENV_ERASE_SIZ"
181+ UBOOT_ENV_SIZ="0x$(hd $PROC_ENV_FILE | awk 'FNR==1 {print $2 $3 $4 $5}')"
182+ UBOOT_ENV_ERASE_SIZ="0x$(grep uboot-env /proc/mtd | awk '{print $3}')"
183+ if [[ -n "$UBOOT_ENV_SIZ" && -n "$UBOOT_ENV_ERASE_SIZ" ]]
184+ then
185+ # Env info from DTB
186+ FW_ENV_DTB="/dev/$DTB_HAS_ENV_BLK 0x00000000 $UBOOT_ENV_SIZ $UBOOT_ENV_ERASE_SIZ"
187+ fi
181188 fi
182189 fi
183- fi
184- if [ $UBOOT_FW_DEFAULT -eq 1 ]
185- then
186- echo $FW_ENV_DEFAULT > /etc/fw_env.config
187- echo "Using pre-configured uboot env"
188- fi
189- image_name =${image_dir}${kernel_fname }
190- initrd_name =${image_dir}${initrd_fname }
191- fdt_name =${image_dir}${fdt_fname }
192- fit_name=${image_dir}${fit_fname}
193-
194- if [ "$install_env" = "onie" ]; then
195- FW_ARG="-f"
196- fw_setenv ${FW_ARG} image_dir_old "" > /dev/null
197- fw_setenv ${FW_ARG} image_name_old "" > /dev/null
198- fw_setenv ${FW_ARG} initrd_name_old "" > /dev/null
199- fw_setenv ${FW_ARG} fdt_name_old "" > /dev/null
200- fw_setenv ${FW_ARG} fit_name_old " " > /dev/null
201- fw_setenv ${FW_ARG} sonic_version_2 "None " > /dev/null
202- fw_setenv ${FW_ARG} linuxargs_old "" > /dev/null
203- else
204- CURR_SONIC_IMAGE="$(sonic-installer list | grep "Current: " | cut -f2 -d' ')"
205- FIRST_SONIC_IMAGE="$(fw_printenv sonic_version_1 | cut -f2 -d'=')"
206- if [ "$CURR_SONIC_IMAGE" = "$FIRST_SONIC_IMAGE" ]; then
207- image_dir_old =$(fw_printenv -n image_dir || true)
208- image_name_old =$(fw_printenv -n image_name || true)
209- initrd_name_old =$(fw_printenv -n initrd_name || true)
210- fdt_name_old =$(fw_printenv -n fdt_name || true)
211- fit_name_old =$(fw_printenv -n fit_name || true)
212- sonic_version_2 =$(fw_printenv -n sonic_version_1 || true)
213- linuxargs_old=$(fw_printenv -n linuxargs || true)
214- fw_setenv ${FW_ARG} image_dir_old "$image_dir_old " > /dev/null
215- fw_setenv ${FW_ARG} image_name_old "$image_name_old " > /dev/null
216- fw_setenv ${FW_ARG} initrd_name_old "$initrd_name_old " > /dev/null
217- fw_setenv ${FW_ARG} fdt_name_old "$fdt_name_old " > /dev/null
218- fw_setenv ${FW_ARG} fit_name_old "$fit_name_old " > /dev/null
219- fw_setenv ${FW_ARG} sonic_version_2 "$sonic_version_2 " > /dev/null
220- fw_setenv ${FW_ARG} linuxargs_old "$linuxargs_old" > /dev/null
190+ if [ $UBOOT_FW_DEFAULT -eq 1 ]
191+ then
192+ echo $FW_ENV_DEFAULT > /etc/fw_env.config
193+ echo "Using pre-configured uboot env"
194+ fi
195+ image_name=${image_dir}${kernel_fname}
196+ initrd_name =${image_dir}${initrd_fname }
197+ fdt_name =${image_dir}${fdt_fname }
198+ fit_name =${image_dir}${fit_fname }
199+
200+ if [ "$install_env" = "onie" ]; then
201+ FW_ARG="-f"
202+ fw_setenv ${ FW_ARG} image_dir_old "" > /dev/null
203+ fw_setenv ${FW_ARG} image_name_old "" > /dev/null
204+ fw_setenv ${FW_ARG} initrd_name_old "" > /dev/null
205+ fw_setenv ${FW_ARG} fdt_name_old "" > /dev/null
206+ fw_setenv ${FW_ARG} fit_name_old "" > /dev/null
207+ fw_setenv ${FW_ARG} sonic_version_2 "None " > /dev/null
208+ fw_setenv ${FW_ARG} linuxargs_old " " > /dev/null
209+ else
210+ CURR_SONIC_IMAGE="$(sonic-installer list | grep "Current: " | cut -f2 -d' ')"
211+ FIRST_SONIC_IMAGE="$(fw_printenv sonic_version_1 | cut -f2 -d'= ')"
212+ if [ "$CURR_SONIC_IMAGE" = "$FIRST_SONIC_IMAGE" ]; then
213+ image_dir_old=$(fw_printenv -n image_dir || true)
214+ image_name_old =$(fw_printenv -n image_name || true)
215+ initrd_name_old =$(fw_printenv -n initrd_name || true)
216+ fdt_name_old =$(fw_printenv -n fdt_name || true)
217+ fit_name_old =$(fw_printenv -n fit_name || true)
218+ sonic_version_2 =$(fw_printenv -n sonic_version_1 || true)
219+ linuxargs_old =$(fw_printenv -n linuxargs || true)
220+ fw_setenv ${FW_ARG} image_dir_old "$image_dir_old" > /dev/null
221+ fw_setenv ${FW_ARG} image_name_old "$image_name_old " > /dev/null
222+ fw_setenv ${FW_ARG} initrd_name_old "$initrd_name_old " > /dev/null
223+ fw_setenv ${FW_ARG} fdt_name_old "$fdt_name_old " > /dev/null
224+ fw_setenv ${FW_ARG} fit_name_old "$fit_name_old " > /dev/null
225+ fw_setenv ${FW_ARG} sonic_version_2 "$sonic_version_2 " > /dev/null
226+ fw_setenv ${FW_ARG} linuxargs_old "$linuxargs_old " > /dev/null
227+ fi
221228 fi
222- fi
223229
224- # Set boot variables
225- fw_setenv ${FW_ARG} image_dir $image_dir > /dev/null
226- fw_setenv ${FW_ARG} image_name $image_name > /dev/null
227- fw_setenv ${FW_ARG} initrd_name $initrd_name > /dev/null
228- fw_setenv ${FW_ARG} fdt_name $fdt_name > /dev/null
229- fw_setenv ${FW_ARG} fit_name $fit_name > /dev/null
230- fw_setenv ${FW_ARG} sonic_version_1 $demo_volume_revision_label > /dev/null
231- BOOT1='echo " > Boot1: $sonic_version_1 - run sonic_image_1";echo;'
232- BOOT2='echo " > Boot2: $sonic_version_2 - run sonic_image_2";echo;'
233- BOOT3='echo " > Boot3: ONIE - run onie_boot";echo;'
234- BORDER='echo "---------------------------------------------------";echo;'
235- fw_setenv ${FW_ARG} print_menu "$BORDER $BOOT1 $BOOT2 $BOOT3 $BORDER" > /dev/null
236-
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
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}'
240- fw_setenv ${FW_ARG} sonic_bootargs_old "$sonic_bootargs_old" > /dev/null || true
241- sonic_boot_load_old=$(fw_printenv -n sonic_boot_load || true)
242- old_str="_old"
243- fw_setenv ${FW_ARG} sonic_boot_load_old "$sonic_boot_load_old$old_str" > /dev/null || true
244-
245- fw_setenv ${FW_ARG} kernel_addr $kernel_addr > /dev/null
246- fw_setenv ${FW_ARG} fdt_addr $fdt_addr > /dev/null
247- fw_setenv ${FW_ARG} fit_addr $fit_addr > /dev/null
248- fw_setenv ${FW_ARG} fit_conf_name $fit_conf_name > /dev/null
249- fw_setenv ${FW_ARG} initrd_addr $initrd_addr > /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
253- SONIC_BOOT_CMD='run sonic_bootargs; run sonic_boot_load; bootm $fit_addr${fit_conf_name}'
254- SONIC_BOOT_CMD_OLD='run sonic_bootargs_old; run sonic_boot_load_old; bootm $fit_addr${fit_conf_name}'
255- BOOTARGS='setenv bootargs root=UUID='$uuid' rw rootwait panic=1 console=ttyS0,${baudrate} ${linuxargs}'
256- fw_setenv ${FW_ARG} sonic_bootargs "$BOOTARGS" > /dev/null
257- fw_setenv ${FW_ARG} sonic_image_2 "$SONIC_BOOT_CMD_OLD" > /dev/null
258- fw_setenv ${FW_ARG} sonic_image_1 "$SONIC_BOOT_CMD" > /dev/null
259- fw_setenv ${FW_ARG} boot_next 'run sonic_image_1'> /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
261-
262- echo "Installed SONiC base image SONiC-OS successfully"
230+ # Set boot variables
231+ fw_setenv ${FW_ARG} image_dir $image_dir > /dev/null
232+ fw_setenv ${FW_ARG} image_name $image_name > /dev/null
233+ fw_setenv ${FW_ARG} initrd_name $initrd_name > /dev/null
234+ fw_setenv ${FW_ARG} fdt_name $fdt_name > /dev/null
235+ fw_setenv ${FW_ARG} fit_name $fit_name > /dev/null
236+ fw_setenv ${FW_ARG} sonic_version_1 $demo_volume_revision_label > /dev/null
237+ BOOT1='echo " > Boot1: $sonic_version_1 - run sonic_image_1";echo;'
238+ BOOT2='echo " > Boot2: $sonic_version_2 - run sonic_image_2";echo;'
239+ BOOT3='echo " > Boot3: ONIE - run onie_boot";echo;'
240+ BORDER='echo "---------------------------------------------------";echo;'
241+ fw_setenv ${FW_ARG} print_menu "$BORDER $BOOT1 $BOOT2 $BOOT3 $BORDER" > /dev/null
242+
243+ 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
244+ uuid=$(blkid | grep "$demo_volume_label" | sed -ne 's/.* UUID=\"\([^"]*\)\".*/\1/p')
245+ sonic_bootargs_old='setenv bootargs root=UUID='$uuid' rw rootwait panic=1 console=ttyS0,${baudrate} ${linuxargs_old}'
246+ fw_setenv ${FW_ARG} sonic_bootargs_old "$sonic_bootargs_old" > /dev/null || true
247+ sonic_boot_load_old=$(fw_printenv -n sonic_boot_load || true)
248+ old_str="_old"
249+ fw_setenv ${FW_ARG} sonic_boot_load_old "$sonic_boot_load_old$old_str" > /dev/null || true
250+
251+ fw_setenv ${FW_ARG} kernel_addr $kernel_addr > /dev/null
252+ fw_setenv ${FW_ARG} fdt_addr $fdt_addr > /dev/null
253+ fw_setenv ${FW_ARG} fit_addr $fit_addr > /dev/null
254+ fw_setenv ${FW_ARG} fit_conf_name $fit_conf_name > /dev/null
255+ fw_setenv ${FW_ARG} initrd_addr $initrd_addr > /dev/null
256+ demo_part=$(sgdisk -p $blk_dev | grep -e "$demo_volume_label" | awk '{print $1}')
257+ DISK_LOAD=''$disk_scan' ext4load '$disk_interface' 0:'$demo_part' $fit_addr $fit_name'
258+ fw_setenv ${FW_ARG} sonic_boot_load "$DISK_LOAD" > /dev/null
259+ SONIC_BOOT_CMD='run sonic_bootargs; run sonic_boot_load; bootm $fit_addr${fit_conf_name}'
260+ SONIC_BOOT_CMD_OLD='run sonic_bootargs_old; run sonic_boot_load_old; bootm $fit_addr${fit_conf_name}'
261+ BOOTARGS='setenv bootargs root=UUID='$uuid' rw rootwait panic=1 console=ttyS0,${baudrate} ${linuxargs}'
262+ fw_setenv ${FW_ARG} sonic_bootargs "$BOOTARGS" > /dev/null
263+ fw_setenv ${FW_ARG} sonic_image_2 "$SONIC_BOOT_CMD_OLD" > /dev/null
264+ fw_setenv ${FW_ARG} sonic_image_1 "$SONIC_BOOT_CMD" > /dev/null
265+ fw_setenv ${FW_ARG} boot_next 'run sonic_image_1'> /dev/null
266+ 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
267+
268+ echo "Installed SONiC base image SONiC-OS successfully"
263269}
264270
265271bootloader_menu_config() {
266- # Update uboot Environment
267- prepare_boot_menu
272+ # Update uboot Environment
273+ prepare_boot_menu
268274}
269-
275+ fi
0 commit comments