Add nexus_clear_eflash function
Additionally we use this function at the end of nexus_flash to reset the
board and boot from the just-flashed image
Change-Id: Ia1915a32a3dcfd08771757773ff8ed65e49ae572
diff --git a/platforms/nexus/setup.sh b/platforms/nexus/setup.sh
index 61951c0..d23a6cf 100644
--- a/platforms/nexus/setup.sh
+++ b/platforms/nexus/setup.sh
@@ -158,6 +158,23 @@
opentitantool gpio write RESET true
}
+function nexus_clear_eflash
+{
+ # Clear the first page of the eflash to prevent restarting from the
+ # loaded program at the next soft reset.
+ if [[ -z "${NEXUS_ID}" ]]; then
+ echo "Run set-nexus-id first"
+ return 1
+ fi
+
+ echo "Clearing nexus-${NEXUS_ID} eflash"
+ local zeros=$(mktemp)
+ dd if=/dev/zero of=${zeros} bs=512 count=1
+ nexus_reset
+ opentitantool bootstrap "${zeros}"
+ rm ${zeros}
+}
+
function nexus_flash
{
# Write tar file to nexus SPI flash and verify
@@ -208,7 +225,7 @@
fi
rm "${readback_file}"
- nexus_reset
+ nexus_clear_eflash # overwrite spi_passthrough in eflash
}
function nexus_clear_flash
diff --git a/platforms/sparrow/setup.sh b/platforms/sparrow/setup.sh
index 6bebc9d..93cbecd 100644
--- a/platforms/sparrow/setup.sh
+++ b/platforms/sparrow/setup.sh
@@ -154,6 +154,23 @@
opentitantool gpio write RESET true
}
+function sparrow_clear_eflash
+{
+ # Clear the first page of the eflash to prevent restarting from the
+ # loaded program at the next soft reset.
+ if [[ -z "${SPARROW_ID}" ]]; then
+ echo "Run set-sparrow-id first"
+ return 1
+ fi
+
+ echo "Clearing sparrow-${SPARROW_ID} eflash"
+ local zeros=$(mktemp)
+ dd if=/dev/zero of=${zeros} bs=512 count=1
+ sparrow_reset
+ opentitantool bootstrap "${zeros}"
+ rm ${zeros}
+}
+
function sparrow_flash
{
# Write tar file to sparrow SPI flash and verify
@@ -204,7 +221,7 @@
fi
rm "${readback_file}"
- sparrow_reset
+ sparrow_clear_eflash
}
function sparrow_clear_flash