ecfw: move flashing scripts to separate derivation
parent
e5824b756d
commit
6cf5223d41
@ -0,0 +1,81 @@
|
|||||||
|
{ stdenv
|
||||||
|
, lib
|
||||||
|
, runtimeShell
|
||||||
|
, ecfw
|
||||||
|
, ectool
|
||||||
|
, flashrom-chromebook
|
||||||
|
}:
|
||||||
|
|
||||||
|
stdenv.mkDerivation {
|
||||||
|
pname = "ecfw-scripts";
|
||||||
|
inherit (ecfw) version;
|
||||||
|
|
||||||
|
flashEcRw = ''
|
||||||
|
#!${runtimeShell}
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
echo
|
||||||
|
echo "rebooting EC into the RO image..."
|
||||||
|
${ectool}/bin/ectool reboot_ec RO
|
||||||
|
sleep 2
|
||||||
|
${ectool}/bin/ectool version | grep 'Firmware copy: RO'
|
||||||
|
|
||||||
|
echo
|
||||||
|
echo "enabling RO image write protect..."
|
||||||
|
${ectool}/bin/ectool flashprotect enable | head -n1 | grep ro_now
|
||||||
|
${flashrom-chromebook}/bin/flashrom-chromebook -p ec --wp-status | grep "write protect is enabled"
|
||||||
|
|
||||||
|
echo
|
||||||
|
echo "writing the RW image..."
|
||||||
|
${flashrom-chromebook}/bin/flashrom-chromebook -p ec -i EC_RW -w ${ecfw}/ecfw.bin
|
||||||
|
${ectool}/bin/ectool version
|
||||||
|
|
||||||
|
echo
|
||||||
|
echo "rebooting into the new RW image..."
|
||||||
|
${ectool}/bin/ectool reboot_ec RW
|
||||||
|
sleep 2
|
||||||
|
${ectool}/bin/ectool version
|
||||||
|
${ectool}/bin/ectool version | grep 'Firmware copy: RW'
|
||||||
|
'';
|
||||||
|
|
||||||
|
flashEcRo = ''
|
||||||
|
#!${runtimeShell}
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
echo
|
||||||
|
echo "making sure you are in the RW image before flashing the RO..."
|
||||||
|
${ectool}/bin/ectool version | grep 'Firmware copy: RW'
|
||||||
|
|
||||||
|
echo
|
||||||
|
echo "disabling RO image write protect..."
|
||||||
|
${ectool}/bin/ectool flashprotect disable
|
||||||
|
${flashrom-chromebook}/bin/flashrom-chromebook -p ec --wp-status | grep "write protect is disabled"
|
||||||
|
|
||||||
|
echo
|
||||||
|
echo "writing the RO image..."
|
||||||
|
${flashrom-chromebook}/bin/flashrom-chromebook -p ec -i EC_RO -w ${ecfw}/ecfw.bin
|
||||||
|
${ectool}/bin/ectool version
|
||||||
|
|
||||||
|
echo
|
||||||
|
echo "rebooting into the new RO image..."
|
||||||
|
${ectool}/bin/ectool reboot_ec RO
|
||||||
|
sleep 2
|
||||||
|
${ectool}/bin/ectool version
|
||||||
|
${ectool}/bin/ectool version | grep 'Firmware copy: RO'
|
||||||
|
|
||||||
|
echo
|
||||||
|
echo "re-enabling RO image write protect..."
|
||||||
|
${ectool}/bin/ectool flashprotect enable
|
||||||
|
${flashrom-chromebook}/bin/flashrom-chromebook -p ec --wp-status | grep "write protect is enabled"
|
||||||
|
'';
|
||||||
|
|
||||||
|
dontUnpack = true;
|
||||||
|
dontBuild = true;
|
||||||
|
passAsFile = [ "flashEcRo" "flashEcRw" ];
|
||||||
|
installPhase = ''
|
||||||
|
mkdir -p $out/bin
|
||||||
|
cp $flashEcRoPath $out/bin/flash-ec-ro.sh
|
||||||
|
cp $flashEcRwPath $out/bin/flash-ec-rw.sh
|
||||||
|
chmod +x $out/bin/flash-ec-ro.sh $out/bin/flash-ec-rw.sh
|
||||||
|
'';
|
||||||
|
}
|
Loading…
Reference in New Issue