Skip to content

Commit 9dc2860

Browse files
fix: change prog_firehose_ddr.elf path to avoid qdl 2.4 errors on Windows (#73)
* Change prog_firehose path to avoid errors related to qdl 2.4 on Windows * Do not prompt the user when flashing in gRPC mode * Fix check to clean up the directory after a successful run * Print message to make it clear that the flasher is checking if data preservation is possible
1 parent 7cbd67a commit 9dc2860

2 files changed

Lines changed: 10 additions & 4 deletions

File tree

internal/updater/flasher.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,11 @@ func FlashBoard(ctx context.Context, serialStr string, downloadedImagePath *path
120120

121121
rawProgram := "rawprogram0.xml"
122122
if preserveUser {
123+
feedback.Print(i18n.Tr("Checking if the OS version on the UNO Q supports data preservation. Please connect the board in EDL mode."))
123124
if errT := checkBoardGPTTable(ctx, qdlPath, flashDir); errT == nil && flashDir.Join("rawprogram0.nouser.xml").Exist() {
124125
rawProgram = "rawprogram0.nouser.xml"
126+
} else if callback != nil {
127+
return fmt.Errorf("it will not be possible to preserve the data: %w", errT)
125128
} else {
126129
res, err := func(target string) (bool, error) {
127130
warnStr := "Linux image " + target + " does not support user partition preservation"
@@ -251,23 +254,26 @@ func installQdl() (*paths.Path, func(), error) {
251254

252255
// Checks the board GPT table and counts the number of partitions, this tells if the board supports preserving or not user's data.
253256
func checkBoardGPTTable(ctx context.Context, qdlPath, flashDir *paths.Path) error {
254-
dumpBinPath := qdlPath.Parent().Join("dump.bin")
257+
dumpBinPath := flashDir.Join("dump.bin")
255258
readXMLPath := qdlPath.Parent().Join("read.xml")
256259
err := readXMLPath.WriteFile(artifacts.ReadXML)
257260
if err != nil {
258261
return err
259262
}
260-
cmd, err := paths.NewProcess(nil, qdlPath.String(), "--storage", "emmc", flashDir.Join("prog_firehose_ddr.elf").String(), readXMLPath.String())
263+
cmd, err := paths.NewProcess(nil, qdlPath.String(), "--storage", "emmc", "prog_firehose_ddr.elf", readXMLPath.String())
261264
if err != nil {
262265
return err
263266
}
264-
cmd.SetDir(qdlPath.Parent().String())
267+
cmd.SetDir(flashDir.String())
265268
if err := cmd.RunWithinContext(ctx); err != nil {
266269
return err
267270
}
268271
if !dumpBinPath.Exist() {
269272
return fmt.Errorf("it was not possible to access the current Debian image GPT table")
270273
}
274+
defer func() {
275+
_ = dumpBinPath.Remove()
276+
}()
271277
dump, err := dumpBinPath.ReadFile()
272278
if err != nil {
273279
return err

service/service_flash.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ func (s *flasherServerImpl) Flash(req *flasher.FlashRequest, stream flasher.Flas
6262

6363
tmpPath := paths.New(req.GetTempPath())
6464
rmTempPath := func() {
65-
if tmpPath.Exist() {
65+
if tmpPath.IsDir() {
6666
_ = tmpPath.RemoveAll()
6767
}
6868
}

0 commit comments

Comments
 (0)