Skip to content

Commit 3dccc28

Browse files
Pavan-Nokiapavannaregundi
authored andcommitted
[Nokia-7215-A1] Add FW upgrade support (#24234)
-Add support for FW upgrade of Uboot and CPLD -fix Kdump reboot cause -use UEFI base design
1 parent 8d22d3c commit 3dccc28

File tree

3 files changed

+180
-122
lines changed

3 files changed

+180
-122
lines changed

platform/marvell-prestera/platform_arm64.conf

Lines changed: 103 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ echo "Preparing for installation ... "
88
VAR_LOG=512
99
UBOOT_FW_DEFAULT=1
1010

11+
is_uefi_based=0
1112
kernel_addr=0x1100000
1213
kernel_version=6.1.0-29-2-arm64
1314
kernel_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
5762
elif [ $PLATFORM_CN9131 -eq 1 ]; then
5863
fdt_addr=0x1000000
5964
fit_addr=0x8000000
@@ -108,7 +113,7 @@ get_install_device()
108113

109114
get_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
}
163168
fi
164169

170+
if [ $is_uefi_based -eq 0 ]; then
165171
prepare_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

265271
bootloader_menu_config() {
266-
# Update uboot Environment
267-
prepare_boot_menu
272+
# Update uboot Environment
273+
prepare_boot_menu
268274
}
269-
275+
fi

platform/marvell-prestera/sonic-platform-nokia/7215-a1/sonic_platform/chassis.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ def __init__(self):
106106
self._thermal_list.append(thermal)
107107

108108
for i in range(MAX_7215_COMPONENT):
109-
component = Component(i)
109+
component = Component(self.get_model(), i)
110110
self._component_list.append(component)
111111

112112
def _read_sysfs_file(self, sysfs_file):
@@ -259,13 +259,19 @@ def get_reboot_cause(self):
259259
is "REBOOT_CAUSE_HARDWARE_OTHER", the second string can be used
260260
to pass a description of the reboot cause.
261261
"""
262+
263+
REBOOT_CAUSE_FILE = "/host/reboot-cause/reboot-cause.txt"
264+
if os.path.isfile(REBOOT_CAUSE_FILE):
265+
with open(REBOOT_CAUSE_FILE) as cause_file:
266+
software_reboot_cause = cause_file.readline().rstrip('\n')
267+
sonic_logger.log_notice("PAVAN Reboot-cause reported by software - {}".format(software_reboot_cause))
262268
value = self._read_sysfs_file(CPLD_DIR+"last_reset_cause")
263269
thermal = self._read_sysfs_file(CPLD_DIR+"temp_event_status")
264270
if (value == 'cold_reset'):
265271
reboot_cause=(ChassisBase.REBOOT_CAUSE_POWER_LOSS, "Cold Reset")
266272
elif (value == 'warm_reset'):
267273
reboot_cause=(ChassisBase.REBOOT_CAUSE_HARDWARE_OTHER, "Warm Reset")
268-
elif (value == 'wdog_reset'):
274+
elif (value == 'wdog_reset' and software_reboot_cause == 'Unknown'):
269275
reboot_cause=(ChassisBase.REBOOT_CAUSE_WATCHDOG, None)
270276
elif (value == 'thermal_reset'):
271277
reboot_cause=(ChassisBase.REBOOT_CAUSE_THERMAL_OVERLOAD_OTHER, thermal)

platform/marvell-prestera/sonic-platform-nokia/7215-a1/sonic_platform/component.py

Lines changed: 69 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,11 @@ class Component(ComponentBase):
3636
]
3737
CPLD_UPDATE_COMMAND = ['./cpldupd_A1', '']
3838

39-
def __init__(self, component_index):
39+
def __init__(self, chassis_model, component_index):
4040
self.index = component_index
4141
self.name = self.CHASSIS_COMPONENTS[self.index][0]
4242
self.description = self.CHASSIS_COMPONENTS[self.index][1]
43+
self.chassis_model = chassis_model
4344

4445
def _get_command_result(self, cmdline):
4546
try:
@@ -52,6 +53,14 @@ def _get_command_result(self, cmdline):
5253
result = None
5354

5455
return result
56+
def get_chassis_model(self):
57+
"""
58+
Retrieves the model number of the Fan
59+
60+
Returns:
61+
string: Model number of Fan. Use part number for this.
62+
"""
63+
return self.chassis_model
5564

5665
def _read_sysfs_file(self, sysfs_file):
5766
# On successful read, returns the value read from given
@@ -175,7 +184,7 @@ def get_firmware_version(self):
175184
return self._get_cpld_version(self.index)
176185

177186
if self.index == 1:
178-
cmdstatus, uboot_version = cmd.getstatusoutput('fw_printenv current_uboot_version |cut -d= -f 2')
187+
cmdstatus, uboot_version = cmd.getstatusoutput('cat /proc/device-tree/chosen/u-boot,version')
179188
return uboot_version or "V1.1"
180189

181190
def install_firmware(self, image_path):
@@ -189,31 +198,68 @@ def install_firmware(self, image_path):
189198
A boolean, True if install was successful, False if not
190199
"""
191200
image_name = ntpath.basename(image_path)
192-
print(" ixs-7215-A1 - install cpld {}".format(image_name))
201+
print(" ixs-7215-A1 - install firmware {}".format(image_name))
193202

194203
# check whether the image file exists
195204
if not os.path.isfile(image_path):
196-
print("ERROR: the cpld image {} doesn't exist ".format(image_path))
197-
return False
198-
199-
# check whether the cpld exe exists
200-
if not os.path.isfile('/tmp/cpldupd_A1'):
201-
print("ERROR: the cpld exe {} doesn't exist ".format('/tmp/cpldupd_A1'))
205+
print("ERROR: the firmware image {} doesn't exist ".format(image_path))
202206
return False
207+
if self.name == "System-CPLD":
208+
# check whether the cpld exe exists
209+
if not os.path.isfile('/tmp/cpldupd_A1'):
210+
print("ERROR: the cpld exe {} doesn't exist ".format('/tmp/cpldupd_A1'))
211+
return False
203212

204-
self.CPLD_UPDATE_COMMAND[1] = image_name
213+
self.CPLD_UPDATE_COMMAND[1] = image_name
205214

206-
success_flag = False
215+
success_flag = False
207216

208-
try:
209-
subprocess.check_call(self.CPLD_UPDATE_COMMAND, stderr=subprocess.STDOUT)
210-
211-
success_flag = True
212-
except subprocess.CalledProcessError as e:
213-
print("ERROR: Failed to upgrade CPLD: rc={}".format(e.returncode))
214-
215-
if success_flag:
216-
print("INFO: Refresh or power cycle is required to finish CPLD installation")
217-
218-
return success_flag
219-
217+
try:
218+
subprocess.check_call(self.CPLD_UPDATE_COMMAND, stderr=subprocess.STDOUT)
219+
220+
success_flag = True
221+
except subprocess.CalledProcessError as e:
222+
print("ERROR: Failed to upgrade CPLD: rc={}".format(e.returncode))
223+
224+
if success_flag:
225+
print("INFO: Refresh or power cycle is required to finish CPLD installation")
226+
227+
return success_flag
228+
elif self.name == "U-Boot":
229+
ch_model=self.get_chassis_model()
230+
if(ch_model[8:10]=='AB'):
231+
mount_point = "/mnt/p1"
232+
success_flag = False
233+
UBOOT_UPDATE_COMMAND1 = ['sudo', 'mkdir', mount_point]
234+
UBOOT_UPDATE_COMMAND2 = ['sudo', 'mount', '/dev/mmcblk0p1', mount_point]
235+
UBOOT_UPDATE_COMMAND3 = ['cp', image_path, '/mnt/p1/EFI/UpdateCapsule']
236+
UBOOT_UPDATE_COMMAND4 = ['sudo', 'umount', mount_point]
237+
UBOOT_UPDATE_COMMAND5 = ['sudo', 'rmdir', mount_point]
238+
UBOOT_UPDATE_COMMAND6 = ['sudo', 'reboot']
239+
240+
try:
241+
if not os.path.isdir(mount_point):
242+
subprocess.check_call(UBOOT_UPDATE_COMMAND1, stderr=subprocess.STDOUT)
243+
if not os.path.ismount(mount_point):
244+
subprocess.check_call(UBOOT_UPDATE_COMMAND2, stderr=subprocess.STDOUT)
245+
subprocess.check_call(UBOOT_UPDATE_COMMAND3, stderr=subprocess.STDOUT)
246+
subprocess.check_call(UBOOT_UPDATE_COMMAND4, stderr=subprocess.STDOUT)
247+
subprocess.check_call(UBOOT_UPDATE_COMMAND5, stderr=subprocess.STDOUT)
248+
subprocess.check_call(UBOOT_UPDATE_COMMAND6, stderr=subprocess.STDOUT)
249+
success_flag = True
250+
except subprocess.CalledProcessError as e:
251+
print("ERROR: Failed to upgrade U-BOOT: rc={}",format(e.returncode))
252+
253+
return success_flag
254+
elif(ch_model[8:10]=='AA'):
255+
success_flag = False
256+
UBOOT_UPDATE_COMMAND1 = ['sudo', 'flashcp', '-A', image_path, '/dev/mtd0']
257+
UBOOT_UPDATE_COMMAND2 = ['sudo', 'reboot']
258+
try:
259+
subprocess.check_call(UBOOT_UPDATE_COMMAND1, stderr=subprocess.STDOUT)
260+
subprocess.check_call(UBOOT_UPDATE_COMMAND2, stderr=subprocess.STDOUT)
261+
success_flag = True
262+
except subprocess.CalledProcessError as e:
263+
print("ERROR: Failed to upgrade U-BOOT: command={}, rc={}",format(e.cmd),format(e.returncode))
264+
265+
return success_flag

0 commit comments

Comments
 (0)