From c0b40ef8624e598560cdd104c5549ab562ecd01a Mon Sep 17 00:00:00 2001
From: guowenxue <guowenxue@gmail.com>
Date: Tue, 28 Dec 2021 18:58:14 +0800
Subject: [PATCH] update win_flash.bat

---
 bsp/images/wintools/win_flash.bat |   52 +++++++++++++++++++++++++++++++++++++++++-----------
 1 files changed, 41 insertions(+), 11 deletions(-)

diff --git a/bsp/images/wintools/win_flash.bat b/bsp/images/wintools/win_flash.bat
index 68ce0ae..710b5d6 100644
--- a/bsp/images/wintools/win_flash.bat
+++ b/bsp/images/wintools/win_flash.bat
@@ -1,4 +1,3 @@
-
 REM This bat script used to flash u-boot or linux system image to EMMC
 
 REM uuu.exe official address:  https://github.com/NXPmicro/mfgtools
@@ -9,17 +8,48 @@
 
 @echo off
 
-set IMAGE_UBOOT=u-boot-imx6ull-emmc.imx
-set IMAGE_SYS=linuxsys_imx6ull_buildroot.img
-REM set IMAGE_SYS=linuxsys_imx6ull_yocto.img
-REM set IMAGE_SYS=linuxsys_imx6ull_bullseye.img
+REM Boot media should be emmc or sd
+set Media=emmc
 
-echo "Image Download Choices:"
+setlocal enabledelayedexpansion
+set /a i=0
 
-echo 1: Download bootloader   [ %IMAGE_UBOOT% ]
-echo 2: Download System Image [ %IMAGE_SYS% ]
+echo Image Download Choices:
+echo.
 
-set /p choice= Please Input Your Choice:
+REM Scan u-boot file
+for %%f in (*.imx) do (
+   SET /a i+=1
+   echo  [!i!]: %%f
+   set ImgArr[!i!]=%%f
+   set ImgUboot=%%f
+)
 
-if %choice% == 1  uuu -b emmc %IMAGE_UBOOT%
-if %choice% == 2  uuu -b emmc_all %IMAGE_UBOOT% %IMAGE_SYS%
+REM Scan all the system image files
+for %%f in (*.img,*.wic) do (
+   SET /a i+=1
+   echo  [!i!]: %%f
+   set ImgArr[!i!]=%%f
+)
+
+if "%ImgUboot%" == "" (
+    echo ERROR: U-boot image not found!
+    pause
+    exit;
+)
+
+echo.
+set /p choice= Please Input Your Choice: 
+call set image=%%ImgArr[%choice%]%%
+echo.
+
+echo %image% | findstr /i "u-boot" > nul
+if %errorlevel% equ 0 (
+	echo Start burn u-boot image: "%image%"
+	echo.
+	uuu -b %Media% %ImgUboot%
+) else (
+    echo Start burn system image: "%image%"
+    echo.
+    uuu -b %Media%_all %ImgUboot% %image%
+)

--
Gitblit v1.9.1