fix ordering of updates to prevent mid-update resets

This commit is contained in:
bunnie 2022-03-19 16:22:09 +08:00
parent 2aa72fae18
commit 1856a83e3e
3 changed files with 55 additions and 22 deletions

View file

@ -13,20 +13,10 @@ if ($decision -eq 0) {
Exit
}
Invoke-WebRequest https://ci.betrusted.io/releases/latest/soc_csr.bin -OutFile soc_csr.bin
python usb_update.py --soc soc_csr.bin --force
Remove-Item soc_csr.bin
python usb_update.py --disable-boot
Write-Output "waiting for device to reboot"
Start-Sleep 5
Invoke-WebRequest https://ci.betrusted.io/releases/latest/loader.bin -OutFile loader.bin
python usb_update.py -l loader.bin
Remove-Item loader.bin
Write-Output "waiting for device to reboot"
Start-Sleep 4
Invoke-WebRequest https://ci.betrusted.io/releases/latest/xous-$LOCALE.img -OutFile xous.img
python usb_update.py -k xous.img
Remove-Item xous.img
@ -45,4 +35,13 @@ Invoke-WebRequest https://ci.betrusted.io/releases/latest/wf200_fw.bin -OutFile
python usb_update.py -w wf200_fw.bin
Remove-Item wf200_fw.bin
Write-Output "waiting for device to reboot"
Start-Sleep 5
Invoke-WebRequest https://ci.betrusted.io/releases/latest/soc_csr.bin -OutFile soc_csr.bin
Invoke-WebRequest https://ci.betrusted.io/releases/latest/loader.bin -OutFile loader.bin
python usb_update.py --enable-boot --soc soc_csr.bin -l loader.bin
Remove-Item soc_csr.bin
Remove-Item loader.bin
Write-Output "IMPORTANT: you must run 'ecup auto' to update the EC with the staged firmware objects."

View file

@ -29,20 +29,10 @@ else
LOCALE=""
fi
wget https://ci.betrusted.io/$REVISION/soc_csr.bin -O /tmp/soc_csr.bin
./usb_update.py --soc /tmp/soc_csr.bin --force
rm /tmp/soc_csr.bin
./usb_update.py --disable-boot
echo "waiting for device to reboot"
sleep 5
wget https://ci.betrusted.io/$REVISION/loader.bin -O /tmp/loader.bin
./usb_update.py -l /tmp/loader.bin
rm /tmp/loader.bin
echo "waiting for device to reboot"
sleep 4
wget https://ci.betrusted.io/$REVISION/xous$LOCALE.img -O /tmp/xous.img
./usb_update.py -k /tmp/xous.img
rm /tmp/xous.img
@ -60,5 +50,15 @@ wget https://ci.betrusted.io/$REVISION/wf200_fw.bin -O /tmp/wf200_fw.bin
./usb_update.py -w /tmp/wf200_fw.bin
rm /tmp/wf200_fw.bin
echo "waiting for device to reboot"
sleep 5
# this should sequence last because it overwrites all of the CSR values on the currently loaded SoC
wget https://ci.betrusted.io/$REVISION/soc_csr.bin -O /tmp/soc_csr.bin
wget https://ci.betrusted.io/$REVISION/loader.bin -O /tmp/loader.bin
./usb_update.py --enable-boot --soc /tmp/soc_csr.bin -l /tmp/loader.bin
rm /tmp/loader.bin
rm /tmp/soc_csr.bin
echo " "
echo "IMPORTANT: you must run 'ecup auto' to update the EC with the staged firmware objects."

View file

@ -404,6 +404,12 @@ def main():
parser.add_argument(
"-l", "--loader", required=False, help="Loader", type=str, nargs='?', metavar=('loader file'), const='../target/riscv32imac-unknown-xous-elf/release/loader.bin'
)
parser.add_argument(
"--disable-boot", required=False, action='store_true', help="Disable system boot (for use in multi-stage updates)"
)
parser.add_argument(
"--enable-boot", required=False, action='store_true', help="Re-enable system boot. Requires both a loader and a soc spec."
)
parser.add_argument(
"-k", "--kernel", required=False, help="Kernel", type=str, nargs='?', metavar=('kernel file'), const='../target/riscv32imac-unknown-xous-elf/release/xous.img'
)
@ -539,6 +545,34 @@ def main():
print("Erasing PDDB region")
pc_usb.erase_region(locs['LOC_PDDB'][0], locs['LOC_EC'][0] - locs['LOC_PDDB'][0])
if args.disable_boot:
print("Disabling boot")
pc_usb.erase_region(locs['LOC_LOADER'][0], 1024 * 256)
if args.enable_boot:
if args.loader == None:
print("Must provide both a loader and soc image")
if args.soc == None:
print("Must provide both a soc and loader image")
print("Enabling boot with {} and {}".format(args.loader, args.soc))
print("Programming loader image {}".format(args.loader))
with open(args.loader, "rb") as f:
image = f.read()
pc_usb.flash_program(locs['LOC_LOADER'][0], image, verify=verify)
print("Programming SoC gateware".format(args.soc))
with open(args.soc, "rb") as f:
image = f.read()
pc_usb.flash_program(locs['LOC_SOC'][0], image, verify=verify)
print("Resuming CPU.")
pc_usb.poke(vexdbg_addr, 0x02000000)
print("Resetting SOC...")
try:
pc_usb.poke(pc_usb.register('reboot_soc_reset'), 0xac, display=False)
except usb.core.USBError:
pass # we expect an error because we reset the SOC and that includes the USB core
exit(0)
if args.image:
image_file, addr_str = args.image
addr = int(addr_str, 0)