From f6d8dd10aab819577b9e0fa3bb5698348c568fa6 Mon Sep 17 00:00:00 2001 From: Michael Mandl Date: Mon, 28 Oct 2024 15:43:57 +0100 Subject: [PATCH] feat(shell): replace fu-flash with fu-swu and fu-wic --- horsch/zsh.nix | 42 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/horsch/zsh.nix b/horsch/zsh.nix index ced4a8e..acc233c 100644 --- a/horsch/zsh.nix +++ b/horsch/zsh.nix @@ -26,7 +26,7 @@ ssh fusion "reboot" } - function fu-flash { + function fu-swu { local ssh_login="fusion" local update_file=''${1} @@ -57,5 +57,45 @@ echo "done." } + + function fu-wic { + local fzf_preview='stat --printf "%n\nSize: %s bytes\nModified: %y" {}' + + uuu.exe -lsusb | grep --silent MX8QM + if [ ''$? -eq 0 ]; then + echo "fusion found" + else + echo "fusion not connected" + return 1 + fi + + local bootloader_file=''${1} + local wic_file=''${2} + + if [ -z ''${bootloader_file} ]; then + bootloader_file=$(find build/tmp/deploy/images -name "imx-boot-horsch-fusion-sd*" -type f \ + | fzf --select-1 --exit-0 --header "Select a bootloader file" --preview=''${fzf_preview} --preview-window=top) + fi + + if [ -z ''${bootloader_file} ]; then + echo "no bootloader file selected" + return 1 + fi + + if [ -z ''${wic_file} ]; then + wic_file=$(find build/tmp/deploy/images -name "*.wic" -type f \ + | fzf --select-1 --exit-0 --header="Select a wic image file" --preview=''${fzf_preview} --preview-window=top) + fi + + if [ -z ''${wic_file} ]; then + echo "no wic file selected" + return 1 + fi + + echo "flashing ''${wic_file} to device..." + uuu.exe -v -b emmc_all ''${bootloader_file} ''${wic_file} + + echo "done." + } ''; }