@@ -143,12 +143,16 @@ func FlashBoard(ctx context.Context, downloadedImagePath string, version string,
143143
144144 rawProgram := "rawprogram0.xml"
145145 if preserveUser {
146- if ok , errT := checkBoardGPTTable (ctx , qdlPath , flashDir ); ok && errT == nil {
146+ if errT := checkBoardGPTTable (ctx , qdlPath , flashDir ); errT == nil && flashDir . Join ( "rawprogram0.nouser.xml" ). Exist () {
147147 rawProgram = "rawprogram0.nouser.xml"
148148 } else {
149149 res , err := func (target string ) (bool , error ) {
150- feedback .Printf ("\n WARNING: %v.\n Flashing a new Linux image on the board will erase any existing data you have on it." , errT )
151- feedback .Printf ("Do you want to proceed and flash %s on the board? (yes/no)" , target )
150+ warnStr := "Linux image " + target + " does not support user partition preservation"
151+ if errT != nil {
152+ warnStr = errT .Error ()
153+ }
154+ feedback .Printf ("\n WARNING: %s." , warnStr )
155+ feedback .Printf ("Do you want to proceed and flash %s on the board, erasing any existing data you have on it.? (yes/no)" , target )
152156
153157 var yesInput string
154158 _ , err := fmt .Scanf ("%s\n " , & yesInput )
@@ -187,34 +191,33 @@ func FlashBoard(ctx context.Context, downloadedImagePath string, version string,
187191 return nil
188192}
189193
190- func checkBoardGPTTable (ctx context.Context , qdlPath , flashDir * paths.Path ) ( bool , error ) {
194+ func checkBoardGPTTable (ctx context.Context , qdlPath , flashDir * paths.Path ) error {
191195 dumpBinPath := qdlPath .Parent ().Join ("dump.bin" )
192196 readXMLPath := qdlPath .Parent ().Join ("read.xml" )
193197 err := readXMLPath .WriteFile (artifacts .ReadXML )
194198 if err != nil {
195- return false , err
199+ return err
196200 }
197201 cmd , err := paths .NewProcess (nil , qdlPath .String (), "--storage" , "emmc" , flashDir .Join ("prog_firehose_ddr.elf" ).String (), readXMLPath .String ())
198202 if err != nil {
199- return false , err
203+ return err
200204 }
201205 cmd .SetDir (qdlPath .Parent ().String ())
202206 if err := cmd .RunWithinContext (ctx ); err != nil {
203- return false , err
207+ return err
204208 }
205209 if ! dumpBinPath .Exist () {
206- return false , fmt .Errorf ("it was not possible to access the current Debian image GPT table" )
210+ return fmt .Errorf ("it was not possible to access the current Debian image GPT table" )
207211 }
208212 dump , err := dumpBinPath .ReadFile ()
209213 if err != nil {
210- return false , err
214+ return err
211215 }
212216 strDump := hex .Dump (dump )
213217
214218 if strings .Contains (strDump , "00000250 4c 00 00 00" ) {
215- fmt .Println ("R0" )
216- return false , fmt .Errorf ("the current Debian image (R0) does not support user partition preservation" )
219+ return fmt .Errorf ("the current Debian image (R0) does not support user partition preservation" )
217220 }
218221
219- return true , nil
222+ return nil
220223}
0 commit comments