1@rem Copyright (c) 2020-2023 Huawei Device Co., Ltd.
2@rem Licensed under the Apache License, Version 2.0 (the "License");
3@rem you may not use this file except in compliance with the License.
4@rem You may obtain a copy of the License at
5@rem
6@rem     http://www.apache.org/licenses/LICENSE-2.0
7@rem
8@rem Unless required by applicable law or agreed to in writing, software
9@rem distributed under the License is distributed on an "AS IS" BASIS,
10@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11@rem See the License for the specific language governing permissions and
12@rem limitations under the License.
13
14@echo off
15setlocal enabledelayedexpansion
16@echo -----------------------------
17@echo %date%-%time%
18@echo "Baltimore Updating:"
19@echo "Start Reboot Flashd..."
20hdc shell write_updater boot_flash
21hdc shell reboot updater
22@C:\Windows\System32\PING.EXE -n 15 127.0.0.1>nul
23
24@SET images_table=^
25    flash:uboot:uboot.img ^
26    flash:updater:updater.img ^
27	flash:boot_linux:boot_linux.img ^
28	flash:ramdisk:ramdisk.img ^
29	flash:system:system.img ^
30	flash:vendor:vendor.img ^
31    flash:resource:resource.img
32
33@echo off
34@FOR %%i IN (%images_table%) do (
35    @for /f "delims=: tokens=1,2,3" %%j in ("%%i") do (
36            @if "%%j"=="flash" (
37				@echo start flash %%k
38				set start=!time!
39				hdc flash %%k  -f %~dp0%%l  2>&1 |find "[Success]"
40				@if errorlevel 1 (
41					@echo flash %%k fail, please check
42					goto error
43				)
44				set end=!time!
45				call:GetTimes !start! !end!
46            )
47    )
48	C:\Windows\System32\PING.EXE -n 3 127.0.0.1>nul
49)
50@hdc shell ./bin/updater_reboot >nul
51@goto sucess
52
53
54:error
55@echo "Update Failed!"
56@pause
57@goto end
58
59:sucess
60@echo updater success
61@pause
62@goto end
63
64:GetTimes
65@echo off
66set options="tokens=1-4 delims=:.,"
67for /f %options% %%a in ("%~1") do set start_h=%%a&set /a start_m=100%%b %% 100&set /a start_s=100%%c %% 100&set /a start_ms=100%%d %% 100
68for /f %options% %%a in ("%~2") do set end_h=%%a&set /a end_m=100%%b %% 100&set /a end_s=100%%c %% 100&set /a end_ms=100%%d %% 100
69set /a hours=%end_h%-%start_h%
70set /a mins=%end_m%-%start_m%
71set /a secs=%end_s%-%start_s%
72set /a ms=%end_ms%-%start_ms%
73if %ms% lss 0 set /a secs = %secs% - 1 & set /a ms = 100%ms%
74if %secs% lss 0 set /a mins = %mins% - 1 & set /a secs = 60%secs%
75if %mins% lss 0 set /a hours = %hours% - 1 & set /a mins = 60%mins%
76if %hours% lss 0 set /a hours = 24%hours%
77if 1%ms% lss 100 set ms=0%ms%
78:: 计算时间并输出
79set /a totalsecs = %hours%*3600 + %mins%*60 + %secs%
80echo Total time %totalsecs%.%ms%s
81echo --------------------------------------------------
82
83
84:end
85